1: <?php
2:
3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21:
22:
23: namespace picon;
24:
25: 26: 27: 28: 29: 30:
31: abstract class AbstractAssociatedMarkupSource extends AbstractMarkupSource
32: {
33: public function getMarkup(MarkupContainer $container, Component $child)
34: {
35: $markup = $container->loadAssociatedMarkup();
36: $root = $this->getRootTag($markup);
37: return MarkupUtils::findComponentTag($root, $child->getId(), $container);
38: }
39:
40: public function renderHead(Component $component, HeaderContainer $headerContainer, HeaderResponse $headerResponse)
41: {
42: $markup = $component->loadAssociatedMarkup();
43: $heads = $this->findHead(array($markup));
44:
45: foreach($heads as $index => $head)
46: {
47: $id = $component->getId().'_head_'.$index;
48: $headerPart = new HeaderPartContainer($id, $head);
49: $headerPart->render();
50: }
51: }
52:
53: private function findHead($markup)
54: {
55: $heads = array();
56: foreach($markup as $element)
57: {
58: if($element instanceof PiconTag && $element->isHeaderTag())
59: {
60: array_push($heads, $element);
61: }
62: if($element instanceof MarkupElement && $element->hasChildren())
63: {
64: $heads = array_merge($heads, $this->findHead($element->getChildren()));
65: }
66: }
67: return $heads;
68: }
69:
70: public abstract function getRootTag(MarkupElement $markup);
71: }
72:
73: ?>
74: