Esempio n. 1
0
 public function test()
 {
     $element = new Element('ul', ['role' => 'menu']);
     $element->append(new Element('li'));
     $element->append(new Element('li'));
     $html = $element->formatRender();
     $this->assertNotNull($html);
 }
Esempio n. 2
0
 public function render($attributes = array())
 {
     // <nav aria-label="breadcrumb" role="navigation">
     $nav = new Element('nav', $attributes);
     $nav->setAttributeValue('aria-label', 'Breadcrumbs');
     $nav->setAttributeValue('role', 'navigation');
     $nav->addChild(parent::render());
     return $nav->render();
 }
Esempio n. 3
0
File: Menu.php Progetto: azole/WebUI
 public function render($attrs = array())
 {
     foreach ($this->menuItemCollections as $collection) {
         $this->append($collection);
     }
     return Element::render($attrs);
 }
Esempio n. 4
0
 public function render($attrs = array())
 {
     $this->setAttributeValue('role', 'menu');
     $this->setAttributes(array('itemscope' => null, 'itemtype' => "http://schema.org/ItemList"));
     foreach ($this->menuItems as $item) {
         $this->append($item);
     }
     return Element::render($attrs);
 }
Esempio n. 5
0
 public function render($attributes = array())
 {
     if (!$this->label) {
         throw new Exception('Missing menu label');
     }
     // create label with tag "a"
     $a = new Element('a', $this->linkAttributes);
     $a->setAttributeValue("role", "menuitem");
     $a->appendText($this->label);
     $this->append($a);
     return parent::render($attributes);
 }
Esempio n. 6
0
File: Span.php Progetto: azole/WebUI
 public function __construct($attributes = array())
 {
     parent::__construct($this->tagName, $attributes);
 }
Esempio n. 7
0
 public function render($attrs = array())
 {
     // create a wrapper div
     // <div itemscope itemtype="http://schema.org/SiteNavigationElement">
     if (!$this->label) {
         throw new Exception('Missing menu label');
     }
     // create label with tag "a"
     $a = new Element('a');
     $a->appendText($this->label);
     $this->append($a);
     $this->append($this->menuItemCollection);
     return parent::render($attrs);
 }
Esempio n. 8
0
 public function render($attributes = array())
 {
     $cur = $this->currentPage;
     $totalPages = $this->totalPages;
     if ($this->whenOverflow && $this->totalPages <= 1) {
         return "";
     }
     $pageStart = $cur > $this->rangeLimit ? $cur - $this->rangeLimit : 1;
     $pageEnd = $cur + $this->rangeLimit < $totalPages ? $cur + $this->rangeLimit : $totalPages;
     // Create inner elements and append to children element list.
     if ($this->showNavigator) {
         if ($cur > 2) {
             $li = $this->appendNavItem($this->firstPageLabel, 1, $cur == 1, $cur == 1);
             $li->getChildAt(0)->setAttributeValue('rel', 'first');
         }
         $li = $this->appendNavItem($this->prevPageLabel, $cur - 1, false, $cur == 1);
         $li->getChildAt(0)->setAttributeValue('rel', 'prev');
     }
     if ($this->showNearbyPages) {
         if ($cur > 5) {
             $this->appendNavItem(1, 1);
             $this->appendPageOmitNavItem('...');
         }
         for ($i = $pageStart; $i <= $pageEnd; $i++) {
             $this->appendNavItem($i, $i, $cur == $i);
         }
         if ($cur + 5 < $totalPages) {
             $this->appendPageOmitNavItem('...');
             $this->appendNavItem($totalPages, $totalPages);
         }
     }
     if ($this->showNavigator) {
         $li = $this->appendNavItem($this->nextPageLabel, $cur + 1, $cur >= $totalPages);
         $li->getChildAt(0)->setAttributeValue('rel', 'next');
         if ($totalPages > 1 && $cur < $totalPages) {
             $li = $this->appendNavItem($this->lastPageLabel, $this->totalPages);
             $li->getChildAt(0)->setAttributeValue('rel', 'last');
         }
     }
     $html = parent::render();
     if ($this->navWrapper) {
         $nav = new Element('nav');
         $nav->setAttributeValue('role', 'navigation');
         $nav->setAttributeValue('aria-label', "Pagination");
         $nav->setInnerHtml($html);
         return $nav->render($attributes);
     }
     return $html;
 }