Ejemplo n.º 1
0
 /**
  * Fix link in the canonical metatag
  * It works only with
  * - item
  * - category
  */
 public function canonicalFix()
 {
     if (!$this->_jbrequest->is('option', 'com_zoo')) {
         return null;
     }
     $this->_jbdebug->mark('jbzoo-sef::canonicalFix::start');
     $flags = array($this->_jbrequest->getWord('task'), $this->_jbrequest->getWord('view'), $this->_jbrequest->getWord('layout'));
     $newCanUrl = null;
     if (in_array('item', $flags)) {
         $itemId = $this->_jbrequest->getSystem('item');
         $newCanUrl = $this->_getUrl($this->_itemTable->get($itemId), 'item');
     } else {
         if (in_array('category', $flags)) {
             $categoryId = $this->_jbrequest->getSystem('category');
             $newCanUrl = $this->_getUrl($this->_catTable->get($categoryId), 'category');
         }
     }
     if ($newCanUrl) {
         // remove all canocical link
         $headData = $this->_joomlaDoc->getHeadData();
         $canKey = array_search(array('relation' => 'canonical', 'relType' => 'rel', 'attribs' => array()), $headData['links']);
         unset($headData['links'][$canKey]);
         $this->_joomlaDoc->setHeadData($headData);
         // set new url
         $baseUrl = $this->_jbrouter->getHostUrl();
         $this->_joomlaDoc->addHeadLink($baseUrl . $newCanUrl, 'canonical');
     }
     $this->_jbdebug->mark('jbzoo-sef::canonicalFix::finish');
 }
 /**
  * Test...
  *
  * @return  void
  *
  * @note    MDC: <link>  https://developer.mozilla.org/en-US/docs/HTML/Element/link
  */
 public function testAddHeadLink()
 {
     // Simple
     $this->object->addHeadLink('index.php', 'Start');
     $this->assertThat($this->object->_links['index.php'], $this->equalTo(array('relation' => 'Start', 'relType' => 'rel', 'attribs' => array())), 'addHeadLink did not work');
     // RSS
     $link = '&format=feed&limitstart=';
     $attribs = array('type' => 'application/rss+xml', 'title' => 'RSS 2.0');
     $this->object->addHeadLink($link, 'alternate', 'rel', $attribs);
     $this->assertThat($this->object->_links[$link], $this->equalTo(array('relation' => 'alternate', 'relType' => 'rel', 'attribs' => $attribs)), 'JDocumentHtml::addHeadLink did not work for RSS');
 }
Ejemplo n.º 3
0
 /**
  * @testdox  Test that addHeadLink returns an instance of $this
  */
 public function testEnsureAddHeadLinkReturnsThisObject()
 {
     $this->assertSame($this->object, $this->object->addHeadLink('index.php', 'Start'));
 }