当前位置: 首页>>代码示例>>PHP>>正文


PHP CMSMenu::get_viewable_menu_items方法代码示例

本文整理汇总了PHP中CMSMenu::get_viewable_menu_items方法的典型用法代码示例。如果您正苦于以下问题:PHP CMSMenu::get_viewable_menu_items方法的具体用法?PHP CMSMenu::get_viewable_menu_items怎么用?PHP CMSMenu::get_viewable_menu_items使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CMSMenu的用法示例。


在下文中一共展示了CMSMenu::get_viewable_menu_items方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getAwesomeIconCSS

 /**
  * Answers a string containing the custom CSS for the CMS interface.
  *
  * @return string
  */
 public function getAwesomeIconCSS()
 {
     // Initialise Variables:
     $css = array();
     // Obtain Default ModelAdmin Icon:
     $dma_icon = Config::inst()->get('ModelAdmin', 'menu_icon', Config::FIRST_SET);
     // Obtain Viewable Menu Items:
     $menu_items = CMSMenu::get_viewable_menu_items();
     // Iterate Viewable Menu Items:
     foreach ($menu_items as $class => $item) {
         // Obtain Bitmap Icon:
         $bmp_icon = Config::inst()->get($class, 'menu_icon', Config::FIRST_SET);
         // Does this class have an awesome icon?
         if ($icon = Config::inst()->get($class, 'awesome_icon', Config::FIRST_SET)) {
             // Fix the prefix of the icon class name:
             $icon = $this->prefix($icon);
         } elseif ($class == 'Help') {
             // The icon for the Help menu item:
             $icon = 'fa-question-circle';
         } elseif ($bmp_icon == $dma_icon) {
             // Replace default ModelAdmin icon:
             $icon = 'fa-database';
         } else {
             // By default, fallback to the bitmap icon:
             $icon = false;
         }
         // Define CSS for this icon:
         if ($icon) {
             // Disable Bitmap Icon:
             $css[] = ".icon.icon-16.icon-" . strtolower($class) . " {";
             $css[] = "  background-image: none !important;";
             $css[] = "}";
             // Enable Awesome Icon:
             $css[] = ".icon.icon-16.icon-" . strtolower($class) . ":before {";
             $css[] = "  content: \"\\" . $this->getIconUnicode($icon) . "\";";
             $css[] = "}";
         }
     }
     // Answer CSS String:
     return implode("\n", $css);
 }
开发者ID:praxisnetau,项目名称:silverstripe-moderno-admin,代码行数:46,代码来源:AwesomeIconExtension.php

示例2: getAwesomeIconCSS

 /**
  * Answers a string containing the custom CSS for the CMS interface.
  *
  * @return string
  */
 public function getAwesomeIconCSS()
 {
     // Initialise Variables:
     $css = array();
     $menu_items = CMSMenu::get_viewable_menu_items();
     // Iterate Viewable Menu Items:
     foreach ($menu_items as $class => $item) {
         // Does this class have an awesome icon?
         if ($icon = Config::inst()->get($class, 'icon', Config::FIRST_SET)) {
             // Fix the prefix of the icon class name:
             $icon = $this->prefix($icon);
         } elseif ($class == 'Help') {
             // The icon for the Help menu item:
             $icon = 'help_outline';
         } else {
             // The default icon, for ModelAdmin menu items:
             $icon = 'content_copy';
         }
         // Define CSS for this icon:
         $css[] = ".icon.icon-16.icon-" . strtolower($class) . ":before { content: \"\\" . self::$icons[$icon] . "\"; }";
     }
     // Answer CSS String:
     return implode("\n", $css);
 }
开发者ID:toastnz,项目名称:flat-cms,代码行数:29,代码来源:FlatCMSLeftAndMainExtension.php

示例3: 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;
 }
开发者ID:prostart,项目名称:cobblestonepath,代码行数:73,代码来源:LeftAndMain.php

示例4: MainMenu

 /**
  * Returns the main menu of the CMS.  This is also used by init() 
  * to work out which sections the user has access to.
  * 
  * @return DataObjectSet
  */
 public function MainMenu()
 {
     // Don't accidentally return a menu if you're not logged in - it's used to determine access.
     if (!Member::currentUser()) {
         return new DataObjectSet();
     }
     // Encode into DO set
     $menu = new DataObjectSet();
     $menuItems = CMSMenu::get_viewable_menu_items();
     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 = "";
             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;
             }
             $menu->push(new ArrayData(array("MenuItem" => $menuItem, "Title" => Convert::raw2xml($title), "Code" => $code, "Link" => $menuItem->url, "LinkingMode" => $linkingmode)));
         }
     }
     // if no current item is found, assume that first item is shown
     //if(!isset($foundCurrent))
     return $menu;
 }
开发者ID:rodneyway,项目名称:silverstripe-cms,代码行数:53,代码来源:LeftAndMain.php

示例5: SilvercartMenus

 /**
  * Returns Silvercart specific menus.
  * 
  * @return ArrayList
  *
  * @author Sascha Koehler <skoehler@pixeltricks.de>,
  *         Sebastian Diel <sdiel@pixeltricks.de>
  * @since 28.02.2013
  */
 public function SilvercartMenus()
 {
     $silvercartMenus = new ArrayList();
     $menuItems = CMSMenu::get_viewable_menu_items();
     $hiddenMenus = SilvercartConfig::getHiddenRegisteredMenus();
     foreach (SilvercartConfig::getRegisteredMenus() as $menu) {
         if (in_array($menu['code'], $hiddenMenus)) {
             continue;
         }
         $modelAdmins = new ArrayList();
         foreach ($menuItems as $code => $menuItem) {
             if (isset($menuItem->controller) && $this->owner->hasMethod('alternateMenuDisplayCheck') && !$this->owner->alternateMenuDisplayCheck($menuItem->controller)) {
                 continue;
             }
             if (empty($menuItem->controller)) {
                 continue;
             }
             if (in_array($menuItem->controller, self::$model_admins_to_ignore)) {
                 continue;
             }
             $menuCode = Config::inst()->get($menuItem->controller, 'menuCode');
             $menuSection = Config::inst()->get($menuItem->controller, 'menuSection');
             $menuSortIndex = Config::inst()->get($menuItem->controller, 'menuSortIndex');
             $url_segment = Config::inst()->get($menuItem->controller, 'url_segment');
             if ($menuCode == $menu['code'] || is_null($menuCode) && $menu['code'] == 'default') {
                 $defaultTitle = LeftAndMain::menu_title_for_class($menuItem->controller);
                 $title = _t("{$menuItem->controller}.MENUTITLE", $defaultTitle);
                 $linkingmode = "";
                 if (strpos($this->owner->Link(), $menuItem->url) !== false) {
                     if ($this->owner->Link() == $menuItem->url) {
                         $linkingmode = "current";
                         // default menu is the one with a blank {@link url_segment}
                     } elseif ($url_segment == '') {
                         if ($this->owner->Link() == $this->owner->stat('url_base') . '/') {
                             $linkingmode = "current";
                         }
                     } else {
                         $linkingmode = "current";
                     }
                 }
                 if (empty($menuSection)) {
                     $menuSection = 'base';
                 }
                 if (empty($menuSortIndex)) {
                     $menuSortIndex = 1000;
                 }
                 $modelAdmins->push(new ArrayData(array("MenuItem" => $menuItem, "Title" => Convert::raw2xml($title), "Code" => $code, 'MenuCode' => $menu['code'], "IsSection" => false, "Section" => $menuSection, "SortIndex" => $menuSortIndex, "Link" => $menuItem->url, "LinkingMode" => $linkingmode)));
                 unset($menuItems[$code]);
             }
         }
         $modelAdmins = $modelAdmins->sort('SortIndex', 'ASC');
         if ($modelAdmins->exists()) {
             $menu['name'] = _t('SilvercartStoreAdminMenu.' . strtoupper($menu['code']), $menu['name']);
             $silvercartMenus->push(new DataObject(array('name' => $menu['name'], 'code' => $menu['code'], 'Code' => $menu['code'], 'ModelAdmins' => $modelAdmins)));
         }
     }
     return $silvercartMenus;
 }
开发者ID:silvercart,项目名称:silvercart,代码行数:67,代码来源:SilvercartLeftAndMainExtension.php

示例6: all_accessible_sites

 public static function all_accessible_sites($includeMainSite = true, $mainSiteTitle = "Main site", $member = null)
 {
     // Rationalise member arguments
     if (!$member) {
         $member = Member::currentUser();
     }
     if (!$member) {
         return new ArrayList();
     }
     if (!is_object($member)) {
         $member = DataObject::get_by_id('Member', $member);
     }
     $subsites = new ArrayList();
     // Collect subsites for all sections.
     $menu = CMSMenu::get_viewable_menu_items();
     foreach ($menu as $candidate) {
         if ($candidate->controller) {
             $accessibleSites = singleton($candidate->controller)->sectionSites($includeMainSite, $mainSiteTitle, $member);
             // Replace existing keys so no one site appears twice.
             $subsites->merge($accessibleSites);
         }
     }
     $subsites->removeDuplicates();
     return $subsites;
 }
开发者ID:hamaka,项目名称:silverstripe-subsites,代码行数:25,代码来源:Subsite.php


注:本文中的CMSMenu::get_viewable_menu_items方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。