Exemplo n.º 1
0
 public function testGetHref()
 {
     $uri = 'spotify:album:4YzcWwBUSzibRsqD9Sgu4A';
     $page = new Zend_Navigation_Page_Uri();
     $page->setUri($uri);
     $this->assertEquals($uri, $page->getHref());
 }
Exemplo n.º 2
0
 /**
  * @group ZF-8922
  */
 public function testGetHrefWithFragmentIdentifier()
 {
     $uri = 'http://www.example.com/foo.html';
     $page = new Zend_Navigation_Page_Uri();
     $page->setUri($uri);
     $page->setFragment('bar');
     $this->assertEquals($uri . '#bar', $page->getHref());
     $page->setUri('#');
     $this->assertEquals('#bar', $page->getHref());
 }
Exemplo n.º 3
0
 /**
  * Testing that navigation order is done correctly
  * 
  * @group   ZF-8337
  * @group   ZF-8313
  */
 public function testNavigationArraySortsCorrectly()
 {
     $page1 = new Zend_Navigation_Page_Uri(array('uri' => 'page1'));
     $page2 = new Zend_Navigation_Page_Uri(array('uri' => 'page2'));
     $page3 = new Zend_Navigation_Page_Uri(array('uri' => 'page3'));
     $this->_navigation->setPages(array($page1, $page2, $page3));
     $page1->setOrder(1);
     $page3->setOrder(0);
     $page2->setOrder(2);
     $pages = $this->_navigation->toArray();
     $this->assertSame(3, count($pages));
     $this->assertEquals('page3', $pages[0]['uri']);
     $this->assertEquals('page1', $pages[1]['uri']);
     $this->assertEquals('page2', $pages[2]['uri']);
 }
Exemplo n.º 4
0
 public static function factory($options)
 {
     if ($options instanceof Zend_Config) {
         $options = $options->toArray();
     }
     $options['type'] = __CLASS__;
     return parent::factory($options);
 }
Exemplo n.º 5
0
 /**
  * Constructor
  *
  * @param array|Zend_Config $options An array or config object with Zend_Navigation_Page options
  * @param object $item A Zend_Db_Table_Row object
  */
 public function __construct($options = null, Zend_Db_Table_Row $item)
 {
     $this->setView();
     $this->_item = $item;
     $this->id = $this->_item->id;
     $pageOptions = $this->_getPageAsArray();
     $this->setOptions($pageOptions);
     $this->_setActive();
     $this->_setVisible();
     parent::__construct($options);
 }
Exemplo n.º 6
0
 /**
  * @param SysModule $module
  * @return Zend_Navigation_Page
  */
 private function createPage(SysModule $module)
 {
     $resourceId = $module->getId();
     if ($module->isMvcPage()) {
         $page = new Zend_Navigation_Page_Mvc();
         $page->setLabel($module->getName());
         $page->setOptions(array('icon' => $module->getIcon(), 'title' => $module->getTitle(), 'subtitle' => $module->getSubTitle(), 'inMenu' => $module->getInMenu()));
         $page->setModule($module->getModule());
         $page->setController($module->getController());
         $page->setAction($module->getAction());
         //$page->setClass('ui-state-default ui-corner-top');
     } else {
         $page = new Zend_Navigation_Page_Uri();
         $page->setOptions(array('icon' => $module->getIcon(), 'title' => $module->getTitle(), 'subtitle' => $module->getSubTitle(), 'inMenu' => $module->getInMenu()));
         $page->setLabel($module->getName());
         $page->setActive(false);
         //$page->setClass('ui-state-default ui-corner-top');
         $page->setUri('javascript:void(0);');
     }
     if ($resourceId) {
         $page->setResource((string) $resourceId);
     }
     return $page;
 }
Exemplo n.º 7
0
 public function testSetVisibleShouldJuggleValue()
 {
     $page = new Zend_Navigation_Page_Uri();
     $page->setVisible(1);
     $this->assertTrue($page->isVisible());
     $page->setVisible('true');
     $this->assertTrue($page->isVisible());
     $page->setVisible(0);
     $this->assertFalse($page->isVisible());
     /**
      * ZF-10146
      * 
      * @link http://framework.zend.com/issues/browse/ZF-10146
      */
     $page->setVisible('False');
     $this->assertFalse($page->isVisible());
     $page->setVisible(array());
     $this->assertFalse($page->isVisible());
 }
Exemplo n.º 8
0
 public function testAddSingleExplicitNotVisibleZendNavigationPageUri()
 {
     $page = new Zend_Navigation_Page_Uri(array('label' => __('Browse Items'), 'uri' => url('items/browse'), 'visible' => false));
     $this->assertNull($page->get('uid'));
     $this->_nav->addPage($page);
     $this->assertEquals(CURRENT_BASE_URL, PUBLIC_BASE_URL);
     $uid = PUBLIC_BASE_URL . '/items/browse';
     // this page should not be altered because it should create a new Omeka_Zend_Navigation_Page_Uri
     $this->assertNull($page->get('uid'));
     $this->assertEquals(1, $this->_nav->count());
     $this->assertTrue($this->_nav->hasChildren());
     $firstChild = $this->_nav->getChildren();
     $this->assertNotEquals($page, $firstChild);
     $this->assertInstanceOf('Omeka_Navigation_Page_Uri', $firstChild);
     $this->assertEquals(__('Browse Items'), $firstChild->getLabel());
     $this->assertEquals(url('items/browse'), $firstChild->getUri());
     $this->assertFalse($firstChild->getVisible());
     $this->assertEquals(0, $firstChild->getOrder());
     $this->assertEquals($uid, $firstChild->get('uid'));
     $this->assertEquals($uid, $firstChild->getHref());
     $this->assertTrue($this->_nav->hasPages());
     $pages = $this->_nav->getPages();
     // it should convert the Zend_Navigation_Page_Uri to an
     // Omeka_Navigation_Page_Uri page
     $this->assertContainsOnly('Omeka_Navigation_Page_Uri', $pages);
     $this->assertNotContains($page, $pages);
     $this->assertContains($firstChild, $pages);
     $foundPage = $this->_nav->findOneBy('uid', $uid);
     $this->assertNotEquals($page, $foundPage);
     $this->assertEquals($firstChild, $foundPage);
     $pageArray = $firstChild->toArray();
     $this->assertContains($pageArray, $this->_nav->toArray());
 }
Exemplo n.º 9
0
 public function testSetVisibleShouldJuggleValue()
 {
     $page = new Zend_Navigation_Page_Uri();
     $page->setVisible(1);
     $this->assertTrue($page->isVisible());
     $page->setVisible('true');
     $this->assertTrue($page->isVisible());
     $page->setVisible(0);
     $this->assertFalse($page->isVisible());
     $page->setVisible(array());
     $this->assertFalse($page->isVisible());
 }
Exemplo n.º 10
0
 /** \brief Set parent menu item
     \param Zend_Navigation_Container $parent the parent
     \return void
     */
 public function setParent(Zend_Navigation_Container $parent = NULL)
 {
     parent::setParent($parent);
     $this->setMenuDepth($parent->getMenuDepth() + 1);
 }
Exemplo n.º 11
0
 /**
  * Returns whether page should be considered active or not
  *
  * @param  bool $recursive  [optional] whether page should be considered
  *                          active if any child pages are active. Default is
  *                          false.
  * @return bool             whether page should be considered active
  */
 public function isActive($recursive = false)
 {
     $this->_active = is_current_url($this->getUri());
     return parent::isActive($recursive);
 }
Exemplo n.º 12
0
 /**
  * @param $uri
  * @param string $label
  * @param bool $active
  * @return Zend_Navigation_Page_Uri
  */
 protected function _addPage($uri = '', $label = '', $active = true)
 {
     $page = new Zend_Navigation_Page_Uri();
     if (is_string($uri)) {
         $page->setUri($uri);
     } elseif (is_array($uri)) {
         if (isset($uri['route']) && is_array($uri['route'])) {
             if (!isset($uri['routeName'])) {
                 $uri['routeName'] = 'default';
             }
             $page->setUri($this->view->url($uri['route'], false, $uri['routeName']));
         }
     }
     $page->setLabel($label);
     if ($active) {
         $page->setActive();
     }
     return $page;
 }