本文整理汇总了PHP中CMSMenu类的典型用法代码示例。如果您正苦于以下问题:PHP CMSMenu类的具体用法?PHP CMSMenu怎么用?PHP CMSMenu使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CMSMenu类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: setUp
function setUp()
{
parent::setUp();
// @todo fix controller stack problems and re-activate
//$this->autoFollowRedirection = false;
CMSMenu::populate_menu();
}
开发者ID:rodneyway,项目名称:silverstripe-cms,代码行数:7,代码来源:LeftAndMainTest.php
示例2: init
public function init()
{
parent::init();
Requirements::css($this->ModuleBase() . '/css/cms-tweaks.css');
Requirements::javascript($this->ModuleBase() . '/javascript/cms-tweaks.js');
/* Remove help link */
CMSMenu::remove_menu_item('Help');
/* Hide "Add new" page, page Settings tab */
if (!Permission::check('SITETREE_REORGANISE')) {
Requirements::javascript($this->ModuleBase() . '/javascript/sitetree-noedit.js');
}
/* Hide all error pages in SiteTree and Files (modeladmin) */
if (!Permission::check('ADMIN')) {
Requirements::javascript($this->ModuleBase() . '/javascript/hide-error-pages.js');
}
/* Add file timestamps for TinyMCE's content_css */
$css = HtmlEditorConfig::get('cms')->getOption('content_css');
if ($css) {
$base_folder = Director::baseFolder();
$timestamped_css = array();
$regular_css = preg_split('/,/', $css, -1, PREG_SPLIT_NO_EMPTY);
foreach ($regular_css as $file) {
if (is_file($base_folder . '/' . $file)) {
array_push($timestamped_css, $file . '?m=' . filemtime($base_folder . '/' . $file));
}
}
if (count($timestamped_css > 0)) {
HtmlEditorConfig::get('cms')->setOption('content_css', implode(',', $timestamped_css));
}
}
}
开发者ID:axllent,项目名称:silverstripe-cms-tweaks,代码行数:31,代码来源:LeftAndMainCMSTweaksExt.php
示例3: testAdvancedMenuHandling
public function testAdvancedMenuHandling() {
// Populate from CMS Classes, check for existance of SecurityAdmin
CMSMenu::clear_menu();
CMSMenu::populate_menu();
$menuItem = CMSMenu::get_menu_item('SecurityAdmin');
$this->assertType('CMSMenuItem', $menuItem, 'SecurityAdmin menu item exists');
$this->assertEquals($menuItem->url, singleton('SecurityAdmin')->Link(), 'Menu item has the correct link');
$this->assertEquals($menuItem->controller, 'SecurityAdmin', 'Menu item has the correct controller class');
$this->assertEquals(
$menuItem->priority,
singleton('SecurityAdmin')->stat('menu_priority'),
'Menu item has the correct priority'
);
// Check that menu order is correct by priority
// Note this will break if populate_menu includes normal links (ie, as not controller)
$menuItems = CMSMenu::get_menu_items();
$priority = 9999; // ok, *could* be set larger, but shouldn't need to be!
foreach($menuItems as $menuItem) {
$this->assertEquals(
$menuItem->priority,
singleton($menuItem->controller)->stat('menu_priority'),
"Menu item $menuItem->title has the correct priority"
);
$this->assertLessThanOrEqual($priority, $menuItem->priority, 'Menu item is of lower or equal priority');
}
}
开发者ID:redema,项目名称:sapphire,代码行数:28,代码来源:CMSMenuTest.php
示例4: init
public function init()
{
/**
* If the config is set, display the menu item in the LeftAndMain
*/
if (!$this->owner->config()->enable_menu_item) {
CMSMenu::remove_menu_item('CMSSiteDesignController');
}
}
开发者ID:helpfulrobot,项目名称:toastnz-silverstripe-site-designer,代码行数:9,代码来源:SiteDesignLeftAndMainExtension.php
示例5: init
public function init()
{
parent::init();
Requirements::css('silverstripe-upgrade-notification/css/custom.css');
CMSMenu::remove_menu_item('UpgradeNotificationPage');
$upgrade_notification_page = new UpgradeNotificationPage();
if (!$upgrade_notification_page->isCurrentVersion() || $upgrade_notification_page->isCurrentVersion() && $upgrade_notification_page->config()->ShowMenuItemWhenCurrent) {
CMSMenu::add_menu_item($upgrade_notification_page->getCode(), $upgrade_notification_page->getUpgradeMessage(), 'admin/upgrade/', null, 1000);
}
}
开发者ID:bluehousegroup,项目名称:silverstripe-upgrade-notification,代码行数:10,代码来源:UpgradeNotificationLeftAndMainExtension.php
示例6: rules
/**
* Gets a list of url_pattern => controller k/v pairs for each LeftAndMain derived controller
*/
public static function rules()
{
if (self::$_rules === null) {
self::$_rules = array();
// Map over the array calling add_rule_for_controller on each
$classes = CMSMenu::get_cms_classes(null, true, CMSMenu::URL_PRIORITY);
array_map(array(__CLASS__, 'add_rule_for_controller'), $classes);
}
return self::$_rules;
}
开发者ID:jacobbuck,项目名称:silverstripe-framework,代码行数:13,代码来源:AdminRootController.php
示例7: setUp
public function setUp()
{
parent::setUp();
// @todo fix controller stack problems and re-activate
//$this->autoFollowRedirection = false;
CMSMenu::populate_menu();
$this->backupCss = Config::inst()->get('LeftAndMain', 'extra_requirements_css');
$this->backupJs = Config::inst()->get('LeftAndMain', 'extra_requirements_javascript');
$this->backupCombined = Requirements::get_combined_files_enabled();
Config::inst()->update('LeftAndMain', 'extra_requirements_css', array(FRAMEWORK_DIR . '/tests/assets/LeftAndMainTest.css'));
Config::inst()->update('LeftAndMain', 'extra_requirements_javascript', array(FRAMEWORK_DIR . '/tests/assets/LeftAndMainTest.js'));
Requirements::set_combined_files_enabled(false);
}
开发者ID:nickbooties,项目名称:silverstripe-framework,代码行数:13,代码来源:LeftAndMainTest.php
示例8: init
public function init()
{
/** =========================================
* @var SiteConfig $config
===========================================*/
$config = SiteConfig::current_site_config();
/**
* Remove the Reports menu item in the CMS
*/
if (!$config->ShowAssetAdmin) {
CMSMenu::remove_menu_item('AssetAdmin');
}
/**
* Remove the Blog menu item in the CMS
*/
if (!$config->ShowBlogAdmin) {
CMSMenu::remove_menu_item('BlogPageModelAdmin');
}
/**
* Remove the Help Link in the CMS
*/
if (!$config->ShowHelpLink) {
CMSMenu::remove_menu_item('Help');
}
/**
* Remove the Messages menu item in the CMS
*/
if (!$config->ShowMessagesAdmin) {
CMSMenu::remove_menu_item('ContactMessageModelAdmin');
}
/**
* Remove the Portfolio menu item in the CMS
*/
if (!$config->ShowPortfolioAdmin) {
CMSMenu::remove_menu_item('PortfolioPageModelAdmin');
}
/**
* Remove the Reports menu item in the CMS
*/
if (!$config->ShowReportAdmin) {
CMSMenu::remove_menu_item('ReportAdmin');
}
/**
* Remove the Security menu item in the CMS
*/
if (!$config->ShowSecurityAdmin) {
CMSMenu::remove_menu_item('SecurityAdmin');
}
/** Set the background colour of the cms sidebar menu. */
Requirements::customCSS('.cms-menu {background: ' . $this->owner->stat('cms_menu_background') . ';}');
}
开发者ID:stevie-mayhew,项目名称:silverstripe-boilerplate-installer,代码行数:51,代码来源:LeftAndMain.php
示例9: rules
/**
* Gets a list of url_pattern => controller k/v pairs for each LeftAndMain derived controller
*/
public static function rules()
{
if (self::$_rules === null) {
self::$_rules = array();
// Build an array of class => url_priority k/v pairs
$classes = array();
foreach (CMSMenu::get_cms_classes() as $class) {
$classes[$class] = Config::inst()->get($class, 'url_priority', Config::FIRST_SET);
}
// Sort them so highest priority item is first
arsort($classes, SORT_NUMERIC);
// Map over the array calling add_rule_for_controller on each
array_map(array(__CLASS__, 'add_rule_for_controller'), array_keys($classes));
}
return self::$_rules;
}
开发者ID:prostart,项目名称:cobblestonepath,代码行数:19,代码来源:AdminRootController.php
示例10: init
public function init()
{
$config = SiteConfig::current_site_config();
if ($config->CustomApplicationLink) {
Config::inst()->update('LeftAndMain', 'application_link', $config->CustomApplicationLink);
}
if ($config->CustomApplicationName) {
Config::inst()->update('LeftAndMain', 'application_name', $config->CustomApplicationName);
}
if (!$config->ShowReportAdmin) {
CMSMenu::remove_menu_item('ReportAdmin');
}
if (!$config->ShowHelpLink) {
CMSMenu::remove_menu_item('Help');
}
}
开发者ID:helpfulrobot,项目名称:thisisbd-silverstripe-cms-branding,代码行数:16,代码来源:LeftAndMainExtension.php
示例11: init
public function init()
{
/** @var SiteConfig $config */
$config = SiteConfig::current_site_config();
/**
* Remove the Reports menu item in the CMS
*/
if (!$config->ShowAssetAdmin) {
CMSMenu::remove_menu_item('AssetAdmin');
}
/**
* Remove the Blog menu item in the CMS
*/
if (!$config->ShowBlogAdmin) {
CMSMenu::remove_menu_item('BlogPageModelAdmin');
}
/**
* Remove the Help Link in the CMS
*/
if (!$config->ShowHelpLink) {
CMSMenu::remove_menu_item('Help');
}
/**
* Remove the Messages menu item in the CMS
*/
if (!$config->ShowMessagesAdmin) {
CMSMenu::remove_menu_item('ContactMessageModelAdmin');
}
/**
* Remove the Portfolio menu item in the CMS
*/
if (!$config->ShowPortfolioAdmin) {
CMSMenu::remove_menu_item('PortfolioPageModelAdmin');
}
/**
* Remove the Reports menu item in the CMS
*/
if (!$config->ShowReportAdmin) {
CMSMenu::remove_menu_item('ReportAdmin');
}
/**
* Remove the Security menu item in the CMS
*/
if (!$config->ShowSecurityAdmin) {
CMSMenu::remove_menu_item('SecurityAdmin');
}
}
开发者ID:helpfulrobot,项目名称:toastnz-silverstripe-boilerplate-installer,代码行数:47,代码来源:ProjectLeftAndMainExtension.php
示例12: customise_data_objects
/**
* Set JSON/XML data object exclusions/inclusions.
* NOTE: ALL data objects are included by default (excluding some core), unless disabled or inclusions have explicitly been defined.
*
* @parameter <{FILTER_TYPE}> string
* @parameter <{DATA_OBJECT_NAMES}> array(string)
*/
public static function customise_data_objects($type, $objects = null)
{
// Merge the exclusions/inclusions in case of multiple definitions.
if (is_array($objects) && strtolower($type) === 'exclude') {
self::$custom_exclusions = array_unique(array_merge(self::$custom_exclusions, $objects));
} else {
if (is_array($objects) && strtolower($type) === 'include') {
self::$custom_inclusions = array_unique(array_merge(self::$custom_inclusions, $objects));
} else {
if (strtolower($type) === 'disabled') {
self::$disabled = true;
// The CMS interface will no longer be required.
CMSMenu::remove_menu_item('APIwesomeAdmin');
}
}
}
}
开发者ID:helpfulrobot,项目名称:nglasl-silverstripe-apiwesome,代码行数:24,代码来源:DataObjectOutputConfiguration.php
示例13: init
public function init()
{
parent::init();
if (!Permission::check("VIEW_DEVTASKS")) {
return;
}
$tasks = array('devbuild' => array('title' => 'Dev/Build', 'link' => 'dev/build', 'reset_time' => '5000', 'error_handler' => 'newtab', 'success_handler' => 'ignore'));
$config_tasks = Config::inst()->get(__CLASS__, 'tasks');
if (is_array($config_tasks)) {
$tasks = array_merge($tasks, $config_tasks);
}
foreach ($tasks as $item => $values) {
$attributes = array('class' => 'devbuild-trigger', 'data-title' => isset($values['title']) ? $values['title'] : $item, 'data-link' => isset($values['link']) ? $values['link'] : 'dev/build', 'data-reset-time' => isset($values['reset_time']) ? $values['reset_time'] : '5000', 'data-error-handler' => isset($values['error_handler']) ? $values['error_handler'] : 'newtab', 'data-success-handler' => isset($values['success_handler']) ? $values['success_handler'] : 'ignore');
// priority controls the ordering of the link in the stack. The
// lower the number, the lower in the list
$priority = -90;
CMSMenu::add_link($item, '', '#', $priority, $attributes);
}
}
开发者ID:gorriecoe,项目名称:silverstripe-fancy-devbuild,代码行数:19,代码来源:DevTasks.php
示例14: 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
示例15: 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
示例16: ListOfAllModelAdmins
/**
* returns a list of all model admin links
* @return Array(String)
*/
private function ListOfAllModelAdmins()
{
$models = array();
$modelAdmins = CMSMenu::get_cms_classes("ModelAdmin");
if ($modelAdmins && count($modelAdmins)) {
foreach ($modelAdmins as $modelAdmin) {
if ($modelAdmin != "ModelAdminEcommerceBaseClass") {
$obj = singleton($modelAdmin);
$modelAdminLink = $obj->Link();
$models[] = $modelAdminLink;
$modelsToAdd = $obj->getManagedModels();
if ($modelsToAdd && count($modelsToAdd)) {
foreach ($modelsToAdd as $key => $model) {
if (is_array($model) || !is_subclass_of($model, "DataObject")) {
$model = $key;
}
if (!is_subclass_of($model, "DataObject")) {
continue;
}
$modelLink = $modelAdminLink . $model . "/";
$models[] = $modelLink;
$models[] = $modelLink . "EditForm/field/" . $model . "/item/new/";
if ($item = $model::get()->First()) {
$models[] = $modelLink . "EditForm/field/" . $model . "/item/" . $item->ID . "/edit";
}
}
}
}
}
}
return $models;
}
开发者ID:helpfulrobot,项目名称:purplespider-mypswd-tweaks,代码行数:36,代码来源:CheckAllTemplates.php
示例17: 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
示例18: array
SSViewer::flush_template_cache();
Debug::log_errors_to('err.log');
}
//(v2.4) Log errors to an email address
//SS_Log::add_writer(new SS_LogEmailWriter('[email protected]'), SS_Log::ERR);
//
//(v2.4) Log errors to a file
//SS_Log::add_writer(new SS_LogFileWriter('error_log.txt'), SS_Log::ERR);
//
/**
* Extended URL rules for the CMS module
*
* @package cms
*/
Director::addRules(50, array('processes//$Action/$ID/$Batch' => 'BatchProcess_Controller', 'admin/help//$Action/$ID' => 'CMSHelp', 'admin/bulkload//$Action/$ID/$OtherID' => 'BulkLoaderAdmin', 'admin/cms//$Action/$ID/$OtherID' => 'CMSMain', 'PageComment//$Action/$ID' => 'PageComment_Controller', 'dev/buildcache/$Action' => 'RebuildStaticCacheTask'));
CMSMenu::add_director_rules();
// Default CMS HTMLEditorConfig
HtmlEditorConfig::get('cms')->setOptions(array('friendly_name' => 'Default CMS', 'priority' => '50', 'mode' => 'none', 'language' => i18n::get_tinymce_lang(), 'body_class' => 'typography', 'document_base_url' => Director::absoluteBaseURL(), 'urlconverter_callback' => "nullConverter", 'setupcontent_callback' => "sapphiremce_setupcontent", 'cleanup_callback' => "sapphiremce_cleanup", 'use_native_selects' => true, 'valid_elements' => "@[id|class|style|title],#a[id|rel|rev|dir|tabindex|accesskey|type|name|href|target|title|class],-strong/-b[class],-em/-i[class],-strike[class],-u[class],#p[id|dir|class|align|style],-ol[class],-ul[class],-li[class],br,img[id|dir|longdesc|usemap|class|src|border|alt=|title|width|height|align],-sub[class],-sup[class],-blockquote[dir|class],-table[border=0|cellspacing|cellpadding|width|height|class|align|summary|dir|id|style],-tr[id|dir|class|rowspan|width|height|align|valign|bgcolor|background|bordercolor|style],tbody[id|class|style],thead[id|class|style],tfoot[id|class|style],#td[id|dir|class|colspan|rowspan|width|height|align|valign|scope|style],-th[id|dir|class|colspan|rowspan|width|height|align|valign|scope|style],caption[id|dir|class],-div[id|dir|class|align|style],-span[class|align|style],-pre[class|align],address[class|align],-h1[id|dir|class|align|style],-h2[id|dir|class|align|style],-h3[id|dir|class|align|style],-h4[id|dir|class|align|style],-h5[id|dir|class|align|style],-h6[id|dir|class|align|style],hr[class],dd[id|class|title|dir],dl[id|class|title|dir],dt[id|class|title|dir],@[id,style,class]", 'extended_valid_elements' => "img[class|src|alt|title|hspace|vspace|width|height|align|onmouseover|onmouseout|name|usemap],iframe[src|name|width|height|align|frameborder|marginwidth|marginheight|scrolling],object[width|height|data|type],param[name|value],map[class|name|id],area[shape|coords|href|target|alt]"));
HtmlEditorConfig::get('cms')->enablePlugins('media', 'fullscreen');
HtmlEditorConfig::get('cms')->enablePlugins(array('ssbuttons' => '../../../cms/javascript/tinymce_ssbuttons/editor_plugin_src.js'));
HtmlEditorConfig::get('cms')->insertButtonsBefore('formatselect', 'styleselect');
HtmlEditorConfig::get('cms')->insertButtonsBefore('advcode', 'ssimage', 'ssflash', 'sslink', 'unlink', 'anchor', 'separator');
HtmlEditorConfig::get('cms')->insertButtonsAfter('advcode', 'fullscreen', 'separator');
HtmlEditorConfig::get('cms')->removeButtons('tablecontrols');
HtmlEditorConfig::get('cms')->addButtonsToLine(3, 'tablecontrols');
// Register default side reports
SS_Report::register("SideReport", "SideReport_EmptyPages");
SS_Report::register("SideReport", "SideReport_RecentlyEdited");
SS_Report::register("SideReport", "SideReport_ToDo");
if (class_exists('SubsiteReportWrapper')) {
SS_Report::register('ReportAdmin', 'SubsiteReportWrapper("BrokenLinksReport")', -20);
开发者ID:Raiser,项目名称:Praktikum,代码行数:31,代码来源:_config.php
示例19: init
function init()
{
CMSMenu::remove_menu_item('Help');
CMSMenu::add_link('Help', "Help", "http://www.silverstripe.purplespider.com/" . Config::inst()->get($this->class, 'url'), -2, array("target" => "_blank"));
}
开发者ID:helpfulrobot,项目名称:purplespider-mypswd-tweaks,代码行数:5,代码来源:CMSHelpLink.php
示例20: alternateAccessCheck
/**
* Alternative security checker for LeftAndMain.
* If security isn't found, then it will switch to a subsite where we do have access.
*/
public function alternateAccessCheck()
{
$className = $this->owner->class;
// Switch to the subsite of the current page
if ($this->owner->class == 'CMSMain' && ($currentPage = $this->owner->currentPage())) {
if (Subsite::currentSubsiteID() != $currentPage->SubsiteID) {
Subsite::changeSubsite($currentPage->SubsiteID);
}
}
// Switch to a subsite that this user can actually access.
$member = Member::currentUser();
if ($member && $member->isAdmin()) {
return true;
}
//admin can access all subsites
$sites = Subsite::accessible_sites("CMS_ACCESS_{$this->owner->class}")->toDropdownMap();
if ($sites && !isset($sites[Subsite::currentSubsiteID()])) {
$siteIDs = array_keys($sites);
Subsite::changeSubsite($siteIDs[0]);
return true;
}
// Switch to a different top-level menu item
$menu = CMSMenu::get_menu_items();
foreach ($menu as $candidate) {
if ($candidate->controller != $this->owner->class) {
$sites = Subsite::accessible_sites("CMS_ACCESS_{$candidate->controller}")->toDropdownMap();
if ($sites && !isset($sites[Subsite::currentSubsiteID()])) {
$siteIDs = array_keys($sites);
Subsite::changeSubsite($siteIDs[0]);
$cClass = $candidate->controller;
$cObj = new $cClass();
Director::redirect($cObj->Link());
return null;
}
}
}
// If all of those fail, you really don't have access to the CMS
return null;
}
开发者ID:hafriedlander,项目名称:silverstripe-config-experiment,代码行数:43,代码来源:LeftAndMainSubsites.php
注:本文中的CMSMenu类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论