本文整理汇总了PHP中LeftAndMain::menu_icon_for_class方法的典型用法代码示例。如果您正苦于以下问题:PHP LeftAndMain::menu_icon_for_class方法的具体用法?PHP LeftAndMain::menu_icon_for_class怎么用?PHP LeftAndMain::menu_icon_for_class使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LeftAndMain
的用法示例。
在下文中一共展示了LeftAndMain::menu_icon_for_class方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: MainMenu
/**
* Returns the main menu of the CMS. This is also used by init()
* to work out which sections the user has access to.
*
* @param Boolean
* @return SS_List
*/
public function MainMenu($cached = true)
{
if (!isset($this->_cache_MainMenu) || !$cached) {
// Don't accidentally return a menu if you're not logged in - it's used to determine access.
if (!Member::currentUser()) {
return new ArrayList();
}
// Encode into DO set
$menu = new ArrayList();
$menuItems = CMSMenu::get_viewable_menu_items();
// extra styling for custom menu-icons
$menuIconStyling = '';
if ($menuItems) {
foreach ($menuItems as $code => $menuItem) {
// alternate permission checks (in addition to LeftAndMain->canView())
if (isset($menuItem->controller) && $this->hasMethod('alternateMenuDisplayCheck') && !$this->alternateMenuDisplayCheck($menuItem->controller)) {
continue;
}
$linkingmode = "link";
if ($menuItem->controller && get_class($this) == $menuItem->controller) {
$linkingmode = "current";
} else {
if (strpos($this->Link(), $menuItem->url) !== false) {
if ($this->Link() == $menuItem->url) {
$linkingmode = "current";
// default menu is the one with a blank {@link url_segment}
} else {
if (singleton($menuItem->controller)->stat('url_segment') == '') {
if ($this->Link() == $this->stat('url_base') . '/') {
$linkingmode = "current";
}
} else {
$linkingmode = "current";
}
}
}
}
// already set in CMSMenu::populate_menu(), but from a static pre-controller
// context, so doesn't respect the current user locale in _t() calls - as a workaround,
// we simply call LeftAndMain::menu_title_for_class() again
// if we're dealing with a controller
if ($menuItem->controller) {
$defaultTitle = LeftAndMain::menu_title_for_class($menuItem->controller);
$title = _t("{$menuItem->controller}.MENUTITLE", $defaultTitle);
} else {
$title = $menuItem->title;
}
// Provide styling for custom $menu-icon. Done here instead of in
// CMSMenu::populate_menu(), because the icon is part of
// the CMS right pane for the specified class as well...
if ($menuItem->controller) {
$menuIcon = LeftAndMain::menu_icon_for_class($menuItem->controller);
if (!empty($menuIcon)) {
$menuIconStyling .= $menuIcon;
}
}
$menu->push(new ArrayData(array("MenuItem" => $menuItem, "Title" => Convert::raw2xml($title), "Code" => DBField::create_field('Text', $code), "Link" => $menuItem->url, "LinkingMode" => $linkingmode)));
}
}
if ($menuIconStyling) {
Requirements::customCSS($menuIconStyling);
}
$this->_cache_MainMenu = $menu;
}
return $this->_cache_MainMenu;
}