123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139 |
- <?php
- if (!defined('STATUSNET')) {
-
-
- exit(1);
- }
- class MoreMenu extends Menu
- {
- const SOFT_MAX = 5;
- const HARD_MAX = 15;
-
- function show()
- {
- $items = $this->getItems();
- $tag = $this->tag();
- $menuID = null;
- $attrs = array('class' => 'nav');
- if (!is_null($tag)) {
- $menuID = 'nav_' . $tag;
- $attrs['id'] = $menuID;
- }
- if (Event::handle('StartNav', array($this, &$tag, &$items))) {
- $this->out->elementStart('ul', $attrs);
- $total = count($items);
- if ($total <= self::SOFT_MAX + 1) {
- $toShow = $items;
- } else {
- $toShow = array_slice($items, 0, self::SOFT_MAX);
- }
- foreach ($toShow as $item) {
- if (count($item) == 5) {
- list($actionName, $args, $label, $description, $id) = $item;
- } else {
- list($actionName, $args, $label, $description) = $item;
- $id = null;
- }
- $this->item($actionName, $args, $label, $description, $id);
- }
- if ($total > self::SOFT_MAX + 1) {
- $this->out->elementStart('li', array('class' => 'more_link'));
- $this->out->element('a', array('href' => '#',
- 'onclick' => 'SN.U.showMoreMenuItems("'.$menuID.'"); return false;'),
-
- _('More ▼'));
- $this->out->elementEnd('li');
- $extended = array_slice($items, self::SOFT_MAX, self::HARD_MAX - self::SOFT_MAX);
- foreach ($extended as $item) {
- if (count($item) == 5) {
- list($actionName, $args, $label, $description, $id) = $item;
- } else {
- list($actionName, $args, $label, $description) = $item;
- $id = null;
- }
- $this->item($actionName, $args, $label, $description, $id, 'extended_menu');
- }
- if ($total > self::HARD_MAX) {
- $seeAll = $this->seeAllItem();
- if (!empty($seeAll)) {
- if (count($seeAll) == 5) {
- list($actionName, $args, $label, $description, $id) = $seeAll;
- } else {
- list($actionName, $args, $label, $description) = $seeAll;
- $id = null;
- }
- $this->item($actionName, $args, $label, $description, $id, 'extended_menu see_all');
- }
- }
- }
- $this->out->elementEnd('ul');
- Event::handle('EndNav', array($this, $tag, $items));
- }
- }
- function seeAllItem()
- {
- return null;
- }
- }
|