/** * Sets the tag name to $this->tagName. * Additionally, sets all tag attributes which were registered in * $this->tagAttributes and additionalArguments. * * Will be invoked just before the render method. * * @return void * @author Bastian Waidelich <*****@*****.**> * @api */ public function initialize() { parent::initialize(); $this->tag->reset(); $this->tag->setTagName($this->tagName); if (is_array($this->arguments['additionalAttributes'])) { $this->tag->addAttributes($this->arguments['additionalAttributes']); } foreach ($this->tagAttributes as $attributeName) { if ($this->arguments->hasArgument($attributeName) && $this->arguments[$attributeName] !== '') { $this->tag->addAttribute($attributeName, $this->arguments[$attributeName]); } } }
/** * render the tags for one page (<loc> and <lastmod>) * * @param Tx_Hriseo_Domain_Model_Pages $page * @return string */ public function render($page) { $cObj = new tslib_cObj(); $path = $cObj->getTypoLink_URL($page->getUid()); // @see http://sitemaps.org and // http://php.net/manual/de/function.htmlspecialchars.php $link = htmlspecialchars($this->settings['baseURL'] . $path, ENT_QUOTES, 'UTF-8', false); $this->loc->setContent($link); $ret = $this->loc->render(); $date = new DateTime(); $date->setTimestamp($page->getLastmod()); $this->lastmod->setContent($date->format('Y-m-d')); $ret .= $this->lastmod->render(); $changefreq = $page->getChangefreq(); if (!empty($changefreq)) { $this->tagBuilder->reset(); $this->tagBuilder->setTagName('changefreq'); $this->tagBuilder->setContent($changefreq); $ret .= $this->tagBuilder->render(); } $priority = $page->getPriority(); // 0.0: ignore // 0.5: default - do not display if (0 < $priority and 0.5 != $priority) { $this->tagBuilder->reset(); $this->tagBuilder->setTagName('priority'); $this->tagBuilder->setContent(number_format($priority, 1)); $ret .= $this->tagBuilder->render(); } return $ret; }
/** * @test * @author Bastian Waidelich <*****@*****.**> */ public function tagIsNotRenderedIfTagNameIsEmpty() { $tagBuilder = new Tx_Fluid_Core_ViewHelper_TagBuilder('foo'); $tagBuilder->setTagName(''); $this->assertEquals('', $tagBuilder->render()); }