Esempio n. 1
0
File: Head.php Progetto: ssrsfs/blg
 public function output(\Pagemill_Data $data, \Pagemill_Stream $stream)
 {
     $this->_hasTitle = false;
     $this->_hasMetaDescription = false;
     $this->_hasMetaKeywords = false;
     $this->_recurseThroughChildren($this);
     if (!$this->_hasTitle) {
         new Typeframe_Tag_Seo_Title('title', array(), $this);
     }
     if (!$this->_hasMetaDescription) {
         new Typeframe_Tag_Seo_Meta('meta', array('name' => 'description'), $this);
     }
     if (!$this->_hasMetaKeywords) {
         new Typeframe_Tag_Seo_Meta('meta', array('name' => 'keywords'), $this);
     }
     $urlmeta = Model_UrlMeta::GetUrl(null, false);
     $tag = null;
     if ($urlmeta->exists()) {
         $seo = Model_SeoHead::Get($urlmeta['id']);
         if ($seo->exists()) {
             if ($seo['extra']) {
                 $fragment = new Pagemill_Node_Frag($this->doctype());
                 $fragment->appendRawText($seo['extra']);
                 $this->appendChild($fragment);
             }
         }
     }
     parent::output($data, $stream);
     // TODO: Do we need to detach the fragment?
 }
Esempio n. 2
0
 private function _xmlEndElement($parser, $name)
 {
     /* @var Pagemill_Tag */
     $last = array_pop($this->_tagStack);
     $last->appendText($this->_currentCharacterData);
     $this->_currentCharacterData = '';
     $attributeRegistry = $last->doctype()->attributeRegistry();
     foreach ($last->attributes() as $k => $v) {
         if (isset($attributeRegistry[$k])) {
             $cls = $attributeRegistry[$k];
             $attribute = new $cls($k, $v, $last);
         }
     }
     // Check if children are combinable
     $combinable = false;
     if ($last->parent()) {
         if ($this->_nodeIsCombinable($last)) {
             $combinable = true;
             foreach ($last->children() as $child) {
                 if (count($child->children())) {
                     $combinable = false;
                     break;
                 }
                 if (!$this->_nodeIsCombinable($child)) {
                     $combinable = false;
                     break;
                 }
             }
         }
     }
     if ($combinable) {
         $frag = new Pagemill_Node_Frag($last->doctype());
         //foreach ($last->children() as $child) {
         //	$frag->appendChild($last);
         //}
         $frag->appendChild($last);
         $last->parent()->appendChild($frag);
         $last->detach();
         $last = $frag;
     }
     if (!count($this->_tagStack)) {
         $this->_root = $last;
     }
 }