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: class HeaderContainer extends TransparentMarkupContainer
32: {
33:     public function __construct($id, Model $model = null)
34:     {
35:         parent::__construct($id, $model);
36:         $this->setRenderBodyOnly(true);
37:     }
38:     
39:     protected function onComponentTagBody(ComponentTag $tag)
40:     {
41:         $this->getResponse()->write('<head>');
42:         parent::onComponentTagBody($tag);
43:         $page = $this->getPage();
44:         $headerResponse = new HeaderResponse($this->getResponse());
45:         PiconApplication::get()->getComponentRenderHeadListener()->onHeadRendering($this, $headerResponse);
46:         $page->renderHead($headerResponse);
47:         $self = $this;
48:         $callback = function(Component &$component) use($headerResponse, $self)
49:         {
50:             $component->renderHeadContainer($self, $headerResponse);
51:             return Component::VISITOR_CONTINUE_TRAVERSAL;
52:         };
53:         
54:         $page->visitChildren(Component::getIdentifier(), $callback);
55:         $this->getResponse()->write('</head>');
56:     }
57:     
58:     public function getMarkup()
59:     {
60:         $parent = $this->getParent();
61:         
62:         if($parent==null)
63:         {
64:             throw new \RuntimeException('Unable to locate parent for header container');
65:         }
66:         
67:         $headerMarkup = $parent->getMarkup()->getChildByName('head');
68:         
69:         if($headerMarkup!=null)
70:         {
71:             return $headerMarkup;
72:         }
73:         
74:         $headerMarkup = MarkupUtils::findPiconTag('head', $parent->getMarkup());
75:         return $headerMarkup;         
76:     }
77:     
78: }
79: 
80: ?>
81: