Commit 2dd9526a authored by Aaron Wells's avatar Aaron Wells
Browse files

Adding a default empty "menu_items()" method for interactions & modules

Bug 1356563

Change-Id: Ic238ab691e1738e5e28f13606c7da4862d1b4d9c
parent d1b79a4e
......@@ -54,9 +54,10 @@ abstract class PluginArtefact extends Plugin implements IPluginArtefact {
/**
* This function returns an array of menu items
* to be displayed
* Each item should be a StdClass object containing -
* - name language pack key
* - url relative to wwwroot
*
* See the function find_menu_children() in lib/web.php
* for a description of the expected array structure.
*
* @return array
*/
public static function menu_items() {
......
......@@ -86,6 +86,18 @@ abstract class PluginInteraction extends Plugin implements IPluginInteraction {
);
}
/**
* This function returns an array of menu items
* to be displayed
*
* See the function find_menu_children() in lib/web.php
* for a description of the expected array structure.
*
* @return array
*/
public static function menu_items() {
return array();
}
}
/**
......
......@@ -1951,6 +1951,9 @@ function in_admin_section() {
/**
* Returns the entries in the standard admin menu
*
* See the function find_menu_children() in lib/web.php
* for a description of the expected array structure.
*
* @return $adminnav a data structure containing the admin navigation
*/
function admin_nav() {
......@@ -2261,6 +2264,9 @@ function admin_nav() {
/**
* Returns the entries in the standard institutional admin menu
*
* See the function find_menu_children() in lib/web.php
* for a description of the expected array structure.
*
* @return $adminnav a data structure containing the admin navigation
*/
function institutional_admin_nav() {
......@@ -2421,6 +2427,9 @@ function institutional_admin_nav() {
/**
* Returns the entries in the staff menu
*
* See the function find_menu_children() in lib/web.php
* for a description of the expected array structure.
*
* @return a data structure containing the staff navigation
*/
function staff_nav() {
......@@ -2452,6 +2461,9 @@ function staff_nav() {
/**
* Returns the entries in the institutional staff menu
*
* See the function find_menu_children() in lib/web.php
* for a description of the expected array structure.
*
* @return a data structure containing the institutional staff navigation
*/
function institutional_staff_nav() {
......@@ -2476,6 +2488,9 @@ function institutional_staff_nav() {
/**
* Returns the entries in the standard user menu
*
* See the function find_menu_children() in lib/web.php
* for a description of the expected array structure.
*
* @return $standardnav a data structure containing the standard navigation
*/
function mahara_standard_nav() {
......@@ -2594,6 +2609,8 @@ function mahara_standard_nav() {
/**
* Builds a data structure representing the menu for Mahara.
*
* @return array
*/
function main_nav() {
if (in_admin_section()) {
......@@ -2613,31 +2630,19 @@ function main_nav() {
}
else {
// Build the menu structure for the site
// The keys of each entry are as follows:
// path: Where the link sits in the menu. E.g. 'myporfolio/myplugin'
// url: The URL to the page, relative to wwwroot. E.g. 'artefact/myplugin/'
// title: Translated text to use for the text of the link. E.g. get_string('myplugin', 'artefact.myplugin')
// weight: Where in the menu the item should be inserted. Larger number are to the right.
$menu = mahara_standard_nav();
}
$menu = array_filter($menu, create_function('$a', 'return empty($a["ignore"]);'));
if ($plugins = plugins_installed('artefact')) {
foreach ($plugins as &$plugin) {
if (safe_require_plugin('artefact', $plugin->name)) {
$plugin_menu = call_static_method(generate_class_name('artefact',$plugin->name), 'menu_items');
$menu = array_merge($menu, $plugin_menu);
}
}
}
if ($plugins = plugins_installed('interaction')) {
foreach ($plugins as &$plugin) {
if (safe_require_plugin('interaction', $plugin->name)) {
$plugin_menu = call_static_method(generate_class_name('interaction',$plugin->name), 'menu_items');
$menu = array_merge($menu, $plugin_menu);
// enable plugins to augment the menu structure
foreach (array('artefact', 'interaction', 'module') as $plugintype) {
if ($plugins = plugins_installed($plugintype)) {
foreach ($plugins as &$plugin) {
if (safe_require_plugin($plugintype, $plugin->name)) {
$plugin_menu = call_static_method(generate_class_name($plugintype,$plugin->name), 'menu_items');
$menu = array_merge($menu, $plugin_menu);
}
}
}
}
......@@ -2756,6 +2761,15 @@ function footer_menu($all=false) {
* of the child menu items of the path, and removes those items from the menu
* structure
*
* The menu structure should be an array. Each item in the array should be
* a sub-array representing one of the nodes in the menu.
*
* The keys of each menu node are as follows:
* path: Where the link sits in the menu. E.g. 'myporfolio/myplugin'
* url: The URL to the page, relative to wwwroot. E.g. 'artefact/myplugin/'
* title: Translated text to use for the text of the link. E.g. get_string('myplugin', 'artefact.myplugin')
* weight: Where in the menu the item should be inserted. Larger number are to the right.
*
* Used by main_nav()
*/
function find_menu_children(&$menu, $path) {
......
......@@ -24,4 +24,17 @@ abstract class PluginModule extends Plugin {
*/
public static function bootstrap() {
}
/**
* This function returns an array of menu items
* to be displayed
*
* See the function find_menu_children() in lib/web.php
* for a description of the expected array structure.
*
* @return array
*/
public static function menu_items() {
return array();
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment