setItemClass() 공개 메소드

Set the li classes
public setItemClass ( mixed $class ) : void
$class mixed An array of class names, or a single string class name.
리턴 void
예제 #1
0
파일: start.php 프로젝트: remy40/gvrs
function gvtheme_init()
{
    // custom topbar
    elgg_unregister_menu_item('topbar', 'elgg_logo');
    elgg_register_plugin_hook_handler('register', 'menu:topbar', 'gvtheme_custom_topbarmenu_setup');
    elgg_register_plugin_hook_handler('register', 'menu:entity', 'gvtheme_custom_entitymenu_setup');
    elgg_register_plugin_hook_handler('register', 'menu:river', 'gvtheme_custom_rivermenu_setup');
    elgg_register_event_handler('pagesetup', 'system', 'gvtheme_custom_usersettings_pagesetup');
    elgg_extend_view('css/elgg', 'gvtheme/css');
    elgg_extend_view('page/elements/head', 'gvtheme/head');
    // remove entities statistics views from user account
    elgg_unextend_view('core/settings/statistics', 'core/settings/statistics/numentities');
    // override some actions
    $action_base = elgg_get_plugins_path() . 'gvtheme/actions';
    elgg_register_action("avatar/upload", "{$action_base}/avatar/upload.php");
    elgg_register_action("avatar/crop", "{$action_base}/avatar/crop.php");
    elgg_register_action("friends/add", "{$action_base}/friends/add.php");
    // get number of users
    $num_members = get_number_users();
    elgg_register_menu_item('topbar', array('name' => 'member_number', 'href' => "members/newest", 'text' => elgg_echo("gvtheme:num_members", array($num_members)), 'priority' => 1000, 'section' => 'alt'));
    $initiatives_item = new ElggMenuItem('initiatives', elgg_echo('gvtheme:initiatives'));
    $cnc_item = new ElggMenuItem('cnc', elgg_echo('gvtheme:cnc'), 'file/group/9545/all');
    $cnc_item->setItemClass('gvgroup-child-menu');
    $initiatives_item->addChild($cnc_item);
    elgg_register_menu_item('site', $initiatives_item);
}
예제 #2
0
 /**
  * ElggMenuItem factory method
  *
  * This static method creates an ElggMenuItem from an associative array.
  * Required keys are name, text, and href.
  *
  * @param array $options Option array of key value pairs
  *
  * @return ElggMenuItem or NULL on error
  */
 public static function factory($options)
 {
     if (!isset($options['name']) || !isset($options['text'])) {
         return NULL;
     }
     if (!isset($options['href'])) {
         $options['href'] = '';
     }
     $item = new ElggMenuItem($options['name'], $options['text'], $options['href']);
     unset($options['name']);
     unset($options['text']);
     unset($options['href']);
     // special catch in case someone uses context rather than contexts
     if (isset($options['context'])) {
         $options['contexts'] = $options['context'];
         unset($options['context']);
     }
     // make sure contexts is set correctly
     if (isset($options['contexts'])) {
         $item->setContext($options['contexts']);
         unset($options['contexts']);
     }
     if (isset($options['link_class'])) {
         $item->setLinkClass($options['link_class']);
         unset($options['link_class']);
     }
     if (isset($options['item_class'])) {
         $item->setItemClass($options['item_class']);
         unset($options['item_class']);
     }
     if (isset($options['data']) && is_array($options['data'])) {
         $item->setData($options['data']);
         unset($options['data']);
     }
     foreach ($options as $key => $value) {
         if (isset($item->data[$key])) {
             $item->data[$key] = $value;
         } else {
             $item->{$key} = $value;
         }
     }
     return $item;
 }
 /**
  * ElggMenuItem factory method
  *
  * This static method creates an ElggMenuItem from an associative array.
  * Required keys are name, text, and href.
  *
  * @param array $options Option array of key value pairs
  *
  * @return ElggMenuItem or null on error
  */
 public static function factory($options)
 {
     if (!isset($options['name']) || !isset($options['text'])) {
         return null;
     }
     if (!isset($options['href'])) {
         $options['href'] = '';
     }
     $item = new ElggMenuItem($options['name'], $options['text'], $options['href']);
     unset($options['name']);
     unset($options['text']);
     unset($options['href']);
     // special catch in case someone uses context rather than contexts
     if (isset($options['context'])) {
         $options['contexts'] = $options['context'];
         unset($options['context']);
     }
     // make sure contexts is set correctly
     if (isset($options['contexts'])) {
         $item->setContext($options['contexts']);
         unset($options['contexts']);
     }
     if (isset($options['link_class'])) {
         $item->setLinkClass($options['link_class']);
         unset($options['link_class']);
     } elseif (isset($options['class'])) {
         elgg_deprecated_notice("ElggMenuItem::factory() does not accept 'class' key anymore, use 'link_class' instead", 1.9);
         $item->setLinkClass($options['class']);
         unset($options['class']);
     }
     if (isset($options['item_class'])) {
         $item->setItemClass($options['item_class']);
         unset($options['item_class']);
     }
     if (isset($options['data']) && is_array($options['data'])) {
         $item->setData($options['data']);
         unset($options['data']);
     }
     foreach ($options as $key => $value) {
         if (isset($item->data[$key])) {
             $item->data[$key] = $value;
         } else {
             $item->{$key} = $value;
         }
     }
     return $item;
 }
예제 #4
0
파일: start.php 프로젝트: remy40/gvrs
/**
 * Transform group item site menu to a dropdrown menu with local and working group menu items
 */
function gvgroups_custom_sitemenu_setup($hook, $type, $values)
{
    $menus = array();
    foreach ($values as $item) {
        if ($item->getName() == 'groups') {
            // remove menu item link
            $item->setHref('');
            // add 2 children items (local groups and working groups)
            $localgroup_item = new ElggMenuItem('localgroups', elgg_echo('gvgroups:localgroups'), 'groups/local');
            $localgroup_item->setItemClass('gvgroup-child-menu');
            $item->addChild($localgroup_item);
            $workinggroup_item = new ElggMenuItem('workinggroups', elgg_echo('gvgroups:workinggroups'), 'groups/working');
            $workinggroup_item->setItemClass('gvgroup-child-menu');
            $item->addChild($workinggroup_item);
        }
        $menus[] = $item;
    }
    return $menus;
}
예제 #5
0
 public function testGetItemClass()
 {
     $item = new \ElggMenuItem('name', 'text', 'url');
     $item->setItemClass('new-link');
     $item->addItemClass(array('2nd-link'));
     $this->assertEquals('elgg-menu-item-name new-link 2nd-link', $item->getItemClass());
 }