Ejemplo n.º 1
0
 function setUp()
 {
     parent::setUp();
     // @todo fix controller stack problems and re-activate
     //$this->autoFollowRedirection = false;
     CMSMenu::populate_menu();
 }
 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));
         }
     }
 }
Ejemplo n.º 3
0
	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');
		}
	}
 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');
     }
 }
 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);
     }
 }
 /**
  * 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;
 }
 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);
 }
 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') . ';}');
 }
 /**
  * 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;
 }
 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');
     }
 }
 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 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');
             }
         }
     }
 }
 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);
     }
 }
 /**
  * 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);
 }
 /**
  * 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);
 }
 /**
  * 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;
 }
Ejemplo n.º 17
0
 /**
  * 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;
 }
Ejemplo n.º 18
0
    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('*****@*****.**'), 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);
 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"));
 }
 /**
  * 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;
 }
Ejemplo n.º 21
0
<?php

define('KICKASSETS_DIR', basename(__DIR__));
// IE9 doesn't get to play with us.
if (!preg_match('/(?i)msie [5-9]/', $_SERVER['HTTP_USER_AGENT'])) {
    CMSMenu::remove_menu_item('AssetAdmin');
} else {
    CMSMenu::remove_menu_item('KickAssets');
}
if (KickAssets::config()->use_on_uploadfield) {
    Config::inst()->update('LeftAndMain', 'extra_requirements_javascript', array(KICKASSETS_DIR . '/javascript/kickassets-uploadfield.js' => array()));
}
if (KickAssets::config()->use_on_tinymce) {
    HtmlEditorConfig::get('cms')->enablePlugins(array('kickassets' => '../../../' . KICKASSETS_DIR . '/javascript/kickassets-tinymce.js'));
    HtmlEditorConfig::get('cms')->insertButtonsAfter('ssmedia', 'kickassets');
}
<?php

LeftAndMain::require_css(basename(__DIR__) . '/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);
}
Ejemplo n.º 23
0
<?php

/**
 * 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/ReportField//$Action/$ID/$Type/$OtherID' => 'ReportField_Controller',
	'admin/bulkload//$Action/$ID/$OtherID' => 'BulkLoaderAdmin',
	'admin//ImageEditor/$Action' => 'ImageEditor',
	'admin/cms//$Action/$ID/$OtherID' => 'CMSMain', 
	'PageComment//$Action/$ID' => 'PageComment_Controller',
	'dev/buildcache' => 'RebuildStaticCacheTask',
));

CMSMenu::populate_menu();
?>
Ejemplo n.º 24
0
<?php

CMSMenu::remove_menu_item('CMSPageBlockBuilderController');
<?php

/**
 * - CMS_DIR: Path relative to webroot, e.g. "cms"
 * - CMS_PATH: Absolute filepath, e.g. "/var/www/my-webroot/cms"
 */
define('CMS_DIR', 'cms');
define('CMS_PATH', BASE_PATH . '/' . CMS_DIR);
/**
 * Register the default internal shortcodes.
 */
ShortcodeParser::get('default')->register('sitetree_link', array('SiteTree', 'link_shortcode_handler'));
File::add_extension('SiteTreeFileExtension');
// TODO Remove once we can configure CMSMenu through static, nested configuration files
CMSMenu::remove_menu_item('CMSMain');
CMSMenu::remove_menu_item('CMSPageEditController');
CMSMenu::remove_menu_item('CMSPageSettingsController');
CMSMenu::remove_menu_item('CMSPageHistoryController');
CMSMenu::remove_menu_item('CMSPageReportsController');
CMSMenu::remove_menu_item('CMSPageAddController');
CMSMenu::remove_menu_item("SiteConfigLeftAndMain");
 /**
  * Clear menu to default state as per LeftAndMain::init()
  */
 protected function resetMenu()
 {
     CMSMenu::clear_menu();
     CMSMenu::populate_menu();
     CMSMenu::add_link('Help', _t('LeftAndMain.HELP', 'Help', 'Menu title'), LeftAndMain::config()->help_link, -2, array('target' => '_blank'));
 }
 public function init()
 {
     parent::init();
     CMSMenu::remove_menu_item('Help');
 }
Ejemplo n.º 28
0
 /**
  * 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;
 }
 /**
  * Remove the help menu item, we're replacing this
  */
 public function onAfterInit()
 {
     CMSMenu::remove_menu_item('Help');
 }
Ejemplo n.º 30
0
 /**
  * Clears the entire menu
  */
 public static function clear_menu()
 {
     self::$menu_item_changes = array();
     self::$menu_is_cleared = true;
 }