mirror of
https://github.com/silverstripe/silverstripe-reports
synced 2024-10-22 11:05:53 +02:00
API CHANGE Added LeftAndMain::populate_default_menu() and LeftAndMain::clear_menu()
git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/cms/trunk@52174 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
parent
ca8f721db2
commit
4b97afea04
44
_config.php
44
_config.php
@ -22,48 +22,6 @@ Director::addRules(50, array(
|
|||||||
));
|
));
|
||||||
|
|
||||||
// Built-in modules
|
// Built-in modules
|
||||||
LeftAndMain::add_menu_item(
|
LeftAndMain::populate_default_menu();
|
||||||
"content",
|
|
||||||
_t('LeftAndMain.SITECONTENT',"Site Content",PR_HIGH,"Menu title"),
|
|
||||||
"admin/",
|
|
||||||
"CMSMain"
|
|
||||||
);
|
|
||||||
LeftAndMain::add_menu_item(
|
|
||||||
"files",
|
|
||||||
_t('LeftAndMain.FILESIMAGES',"Files & Images",PR_HIGH,"Menu title"),
|
|
||||||
"admin/assets/",
|
|
||||||
"AssetAdmin"
|
|
||||||
);
|
|
||||||
LeftAndMain::add_menu_item(
|
|
||||||
"newsletter",
|
|
||||||
_t('LeftAndMain.NEWSLETTERS',"Newsletters",PR_HIGH,"Menu title"),
|
|
||||||
"admin/newsletter/",
|
|
||||||
"NewsletterAdmin"
|
|
||||||
);
|
|
||||||
if(ReportAdmin::has_reports()) {
|
|
||||||
LeftAndMain::add_menu_item(
|
|
||||||
"report",
|
|
||||||
_t('LeftAndMain.REPORTS',"Reports",PR_HIGH,'Menu title'),
|
|
||||||
"admin/reports/",
|
|
||||||
"ReportAdmin"
|
|
||||||
);
|
|
||||||
}
|
|
||||||
LeftAndMain::add_menu_item(
|
|
||||||
"security",
|
|
||||||
_t('LeftAndMain.SECURITY',"Security",PR_HIGH,'Menu title'),
|
|
||||||
"admin/security/",
|
|
||||||
"SecurityAdmin"
|
|
||||||
);
|
|
||||||
LeftAndMain::add_menu_item(
|
|
||||||
"comments",
|
|
||||||
_t('LeftAndMain.COMMENTS',"Comments",PR_HIGH,'Menu title'),
|
|
||||||
"admin/comments/",
|
|
||||||
"CommentAdmin"
|
|
||||||
);
|
|
||||||
LeftAndMain::add_menu_item(
|
|
||||||
"help",
|
|
||||||
_t('LeftAndMain.HELP',"Help",PR_HIGH,'Menu title'),
|
|
||||||
"http://userhelp.silverstripe.com"
|
|
||||||
);
|
|
||||||
|
|
||||||
?>
|
?>
|
@ -837,6 +837,55 @@ JS;
|
|||||||
return $record->$methodName($data, $form);
|
return $record->$methodName($data, $form);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Generate the default entries for the CMS main menu.
|
||||||
|
*/
|
||||||
|
public static function populate_default_menu() {
|
||||||
|
self::add_menu_item(
|
||||||
|
"content",
|
||||||
|
_t('LeftAndMain.SITECONTENT',"Site Content",PR_HIGH,"Menu title"),
|
||||||
|
"admin/",
|
||||||
|
"CMSMain"
|
||||||
|
);
|
||||||
|
self::add_menu_item(
|
||||||
|
"files",
|
||||||
|
_t('LeftAndMain.FILESIMAGES',"Files & Images",PR_HIGH,"Menu title"),
|
||||||
|
"admin/assets/",
|
||||||
|
"AssetAdmin"
|
||||||
|
);
|
||||||
|
self::add_menu_item(
|
||||||
|
"newsletter",
|
||||||
|
_t('LeftAndMain.NEWSLETTERS',"Newsletters",PR_HIGH,"Menu title"),
|
||||||
|
"admin/newsletter/",
|
||||||
|
"NewsletterAdmin"
|
||||||
|
);
|
||||||
|
if(ReportAdmin::has_reports()) {
|
||||||
|
self::add_menu_item(
|
||||||
|
"report",
|
||||||
|
_t('LeftAndMain.REPORTS',"Reports",PR_HIGH,'Menu title'),
|
||||||
|
"admin/reports/",
|
||||||
|
"ReportAdmin"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
self::add_menu_item(
|
||||||
|
"security",
|
||||||
|
_t('LeftAndMain.SECURITY',"Security",PR_HIGH,'Menu title'),
|
||||||
|
"admin/security/",
|
||||||
|
"SecurityAdmin"
|
||||||
|
);
|
||||||
|
self::add_menu_item(
|
||||||
|
"comments",
|
||||||
|
_t('LeftAndMain.COMMENTS',"Comments",PR_HIGH,'Menu title'),
|
||||||
|
"admin/comments/",
|
||||||
|
"CommentAdmin"
|
||||||
|
);
|
||||||
|
self::add_menu_item(
|
||||||
|
"help",
|
||||||
|
_t('LeftAndMain.HELP',"Help",PR_HIGH,'Menu title'),
|
||||||
|
"http://userhelp.silverstripe.com"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add a navigation item to the main administration menu showing in the top bar.
|
* Add a navigation item to the main administration menu showing in the top bar.
|
||||||
*
|
*
|
||||||
@ -848,17 +897,42 @@ JS;
|
|||||||
* @param string $controllerClass The controller class for this menu, used to check permisssions.
|
* @param string $controllerClass The controller class for this menu, used to check permisssions.
|
||||||
* If blank, it's assumed that this is public, and always shown to users who
|
* If blank, it's assumed that this is public, and always shown to users who
|
||||||
* have the rights to access some other part of the admin area.
|
* have the rights to access some other part of the admin area.
|
||||||
|
* @return boolean Success
|
||||||
*/
|
*/
|
||||||
public static function add_menu_item($code, $menuTitle, $url, $controllerClass = null) {
|
public static function add_menu_item($code, $menuTitle, $url, $controllerClass = null) {
|
||||||
$menuItems = singleton('LeftAndMain')->stat('menu_items', true);
|
$menuItems = singleton('LeftAndMain')->stat('menu_items', true);
|
||||||
|
|
||||||
|
if(isset($menuItems[$code])) return false;
|
||||||
|
/*
|
||||||
if(isset($menuItems[$code])) {
|
if(isset($menuItems[$code])) {
|
||||||
user_error("LeftAndMain::add_menu_item(): A menu item with code '{$menuItems}'
|
user_error("LeftAndMain::add_menu_item(): A menu item with code '{$menuItems}'
|
||||||
already exists, can't add it. Please use replace_menu_item() to explicitly replace it",
|
already exists, can't add it. Please use replace_menu_item() to explicitly replace it",
|
||||||
E_USER_ERROR
|
E_USER_ERROR
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
self::replace_menu_item($code, $menuTitle, $url, $controllerClass);
|
return self::replace_menu_item($code, $menuTitle, $url, $controllerClass);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get a single menu item by its code value.
|
||||||
|
*
|
||||||
|
* @param string $code
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public static function get_menu_item($code) {
|
||||||
|
$menuItems = singleton('LeftAndMain')->stat('menu_items', true);
|
||||||
|
return (isset($menuItems[$code])) ? $menuItems[$code] : false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get all menu entries.
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public static function get_menu_items() {
|
||||||
|
return singleton('LeftAndMain')->stat('menu_items', true);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -877,6 +951,18 @@ JS;
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Clears the entire menu
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public static function clear_menu() {
|
||||||
|
Object::addStaticVars(
|
||||||
|
'LeftAndMain',
|
||||||
|
array('menu_items' => array()),
|
||||||
|
true
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Replace a navigation item to the main administration menu showing in the top bar.
|
* Replace a navigation item to the main administration menu showing in the top bar.
|
||||||
*
|
*
|
||||||
@ -888,6 +974,7 @@ JS;
|
|||||||
* @param string $controllerClass The controller class for this menu, used to check permisssions.
|
* @param string $controllerClass The controller class for this menu, used to check permisssions.
|
||||||
* If blank, it's assumed that this is public, and always shown to users who
|
* If blank, it's assumed that this is public, and always shown to users who
|
||||||
* have the rights to access some other part of the admin area.
|
* have the rights to access some other part of the admin area.
|
||||||
|
* @return boolean Success
|
||||||
*/
|
*/
|
||||||
public static function replace_menu_item($code, $menuTitle, $url, $controllerClass = null) {
|
public static function replace_menu_item($code, $menuTitle, $url, $controllerClass = null) {
|
||||||
$menuItems = singleton('LeftAndMain')->stat('menu_items', true);
|
$menuItems = singleton('LeftAndMain')->stat('menu_items', true);
|
||||||
@ -901,6 +988,8 @@ JS;
|
|||||||
array('menu_items' => $menuItems),
|
array('menu_items' => $menuItems),
|
||||||
true
|
true
|
||||||
);
|
);
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user