- <?php
- * @file
- * Dummy module implementing hook menu.
- */
-
- * Implements hook_menu().
- */
- function menu_test_menu() {
-
- $items['menu_name_test'] = array(
- 'title' => 'Test menu_name router item',
- 'page callback' => 'node_save',
- 'menu_name' => menu_test_menu_name(),
- );
-
- $items['menu_callback_title'] = array(
- 'title' => 'Menu Callback Title',
- 'page callback' => 'menu_test_callback',
- 'type' => MENU_CALLBACK,
- 'access arguments' => array('access content'),
- 'menu_name' => 'main-menu',
- );
-
- $items['menu_no_title_callback'] = array(
- 'title' => 'A title with @placeholder',
- 'title callback' => FALSE,
- 'title arguments' => array('@placeholder' => 'some other text'),
- 'page callback' => 'menu_test_callback',
- 'access arguments' => array('access content'),
- 'menu_name' => 'main-menu',
- );
-
-
- $items['menu_test_maintain/%'] = array(
- 'title' => 'Menu maintain test',
- 'page callback' => 'node_page_default',
- 'access arguments' => array('access content'),
- );
-
- $items['menu-test/hierarchy/parent'] = array(
- 'title' => 'Parent menu router',
- 'page callback' => 'node_page_default',
- 'menu_name' => 'main-menu',
- );
- $items['menu-test/hierarchy/parent/child'] = array(
- 'title' => 'Child menu router',
- 'page callback' => 'node_page_default',
- );
- $items['menu-test/hierarchy/parent/child2/child'] = array(
- 'title' => 'Unattached subchild router',
- 'page callback' => 'node_page_default',
- );
-
- $items['menu-test/theme-callback/%'] = array(
- 'title' => 'Page that displays different themes',
- 'page callback' => 'menu_test_theme_page_callback',
- 'access arguments' => array('access content'),
- 'theme callback' => 'menu_test_theme_callback',
- 'theme arguments' => array(2),
- );
- $items['menu-test/theme-callback/%/inheritance'] = array(
- 'title' => 'Page that tests theme callback inheritance.',
- 'page callback' => 'menu_test_theme_page_callback',
- 'page arguments' => array(TRUE),
- 'access arguments' => array('access content'),
- );
- $items['menu-test/no-theme-callback'] = array(
- 'title' => 'Page that displays different themes without using a theme callback.',
- 'page callback' => 'menu_test_theme_page_callback',
- 'access arguments' => array('access content'),
- );
-
- $path = "menu-test/ -._~!$'\"()*@[]?&+%#,;=:" .
- "%23%25%26%2B%2F%3F" .
- "éøïвβ中國書۞";
- $items[$path] = array(
- 'title' => '"Exotic" path',
- 'page callback' => 'menu_test_callback',
- 'access arguments' => array('access content'),
- );
-
-
-
-
- $items['menu-test'] = array(
- 'title' => 'Menu test root',
- 'page callback' => 'node_page_default',
- 'access arguments' => array('access content'),
- 'menu_name' => 'main-menu',
- );
- $items['menu-test/hidden'] = array(
- 'title' => 'Hidden test root',
- 'page callback' => 'node_page_default',
- 'access arguments' => array('access content'),
- );
-
-
- $items['menu-test/hidden/menu'] = array(
- 'title' => 'Menus',
- 'page callback' => 'node_page_default',
- 'access arguments' => array('access content'),
- );
- $items['menu-test/hidden/menu/list'] = array(
- 'title' => 'List menus',
- 'type' => MENU_DEFAULT_LOCAL_TASK,
- 'weight' => -10,
- );
- $items['menu-test/hidden/menu/add'] = array(
- 'title' => 'Add menu',
- 'page callback' => 'node_page_default',
- 'access arguments' => array('access content'),
- 'type' => MENU_LOCAL_ACTION,
- );
- $items['menu-test/hidden/menu/settings'] = array(
- 'title' => 'Settings',
- 'page callback' => 'node_page_default',
- 'access arguments' => array('access content'),
- 'type' => MENU_LOCAL_TASK,
- 'weight' => 5,
- );
- $items['menu-test/hidden/menu/manage/%menu'] = array(
- 'title' => 'Customize menu',
- 'page callback' => 'node_page_default',
- 'access arguments' => array('access content'),
- );
- $items['menu-test/hidden/menu/manage/%menu/list'] = array(
- 'title' => 'List links',
- 'weight' => -10,
- 'type' => MENU_DEFAULT_LOCAL_TASK,
- 'context' => MENU_CONTEXT_PAGE | MENU_CONTEXT_INLINE,
- );
- $items['menu-test/hidden/menu/manage/%menu/add'] = array(
- 'title' => 'Add link',
- 'page callback' => 'node_page_default',
- 'access arguments' => array('access content'),
- 'type' => MENU_LOCAL_ACTION,
- );
- $items['menu-test/hidden/menu/manage/%menu/edit'] = array(
- 'title' => 'Edit menu',
- 'page callback' => 'node_page_default',
- 'access arguments' => array('access content'),
- 'type' => MENU_LOCAL_TASK,
- 'context' => MENU_CONTEXT_PAGE | MENU_CONTEXT_INLINE,
- );
- $items['menu-test/hidden/menu/manage/%menu/delete'] = array(
- 'title' => 'Delete menu',
- 'page callback' => 'node_page_default',
- 'access arguments' => array('access content'),
- );
-
-
- $items['menu-test/hidden/block'] = array(
- 'title' => 'Blocks',
- 'page callback' => 'node_page_default',
- 'access arguments' => array('access content'),
- );
- $items['menu-test/hidden/block/list'] = array(
- 'title' => 'List',
- 'type' => MENU_DEFAULT_LOCAL_TASK,
- 'weight' => -10,
- );
- $items['menu-test/hidden/block/add'] = array(
- 'title' => 'Add block',
- 'page callback' => 'node_page_default',
- 'access arguments' => array('access content'),
- 'type' => MENU_LOCAL_ACTION,
- );
- $items['menu-test/hidden/block/manage/%/%'] = array(
- 'title' => 'Configure block',
- 'page callback' => 'node_page_default',
- 'access arguments' => array('access content'),
- );
- $items['menu-test/hidden/block/manage/%/%/configure'] = array(
- 'title' => 'Configure block',
- 'type' => MENU_DEFAULT_LOCAL_TASK,
- 'context' => MENU_CONTEXT_INLINE,
- );
- $items['menu-test/hidden/block/manage/%/%/delete'] = array(
- 'title' => 'Delete block',
- 'page callback' => 'node_page_default',
- 'access arguments' => array('access content'),
- 'type' => MENU_LOCAL_TASK,
- 'context' => MENU_CONTEXT_NONE,
- );
-
-
-
- $base = array(
- 'page callback' => 'menu_test_callback',
- 'access callback' => TRUE,
- );
-
- $items['menu-test/breadcrumb/tasks'] = array(
- 'title' => 'Breadcrumbs test: Local tasks',
- ) + $base;
- $items['menu-test/breadcrumb/tasks/first'] = array(
- 'title' => 'First',
- 'type' => MENU_DEFAULT_LOCAL_TASK,
- ) + $base;
- $items['menu-test/breadcrumb/tasks/second'] = array(
- 'title' => 'Second',
- 'type' => MENU_LOCAL_TASK,
- ) + $base;
- $items['menu-test/breadcrumb/tasks/first/first'] = array(
- 'title' => 'First first',
- 'type' => MENU_DEFAULT_LOCAL_TASK,
- ) + $base;
- $items['menu-test/breadcrumb/tasks/first/second'] = array(
- 'title' => 'First second',
- 'type' => MENU_LOCAL_TASK,
- ) + $base;
- $items['menu-test/breadcrumb/tasks/second/first'] = array(
- 'title' => 'Second first',
- 'type' => MENU_DEFAULT_LOCAL_TASK,
- ) + $base;
- $items['menu-test/breadcrumb/tasks/second/second'] = array(
- 'title' => 'Second second',
- 'type' => MENU_LOCAL_TASK,
- ) + $base;
-
-
-
- $items['menu-test/menu-trail'] = array(
- 'title' => 'Menu trail - Case 1',
- 'page callback' => 'menu_test_menu_trail_callback',
- 'access arguments' => array('access content'),
- );
- $items['admin/config/development/menu-trail'] = array(
- 'title' => 'Menu trail - Case 2',
- 'description' => 'Tests menu_tree_set_path()',
- 'page callback' => 'menu_test_menu_trail_callback',
- 'access arguments' => array('access administration pages'),
- );
- $items['menu-test/custom-403-page'] = array(
- 'title' => 'Custom 403 page',
- 'page callback' => 'menu_test_custom_403_404_callback',
- 'access arguments' => array('access content'),
- );
- $items['menu-test/custom-404-page'] = array(
- 'title' => 'Custom 404 page',
- 'page callback' => 'menu_test_custom_403_404_callback',
- 'access arguments' => array('access content'),
- );
-
-
- $items['menu-test/changes'] = array(
- 'title' => 'Menu link changes',
- 'page callback' => 'menu_test_callback',
- 'access callback' => TRUE,
- 'type' => menu_test_change_menu_type(),
- );
-
-
-
-
- $items['admin/config/development/file-inheritance'] = array(
- 'title' => 'File inheritance',
- 'description' => 'Test file inheritance',
- 'access arguments' => array('access content'),
- );
- $items['admin/config/development/file-inheritance/inherit'] = array(
- 'title' => 'Inherit',
- 'description' => 'File inheritance test description',
- 'page callback' => 'menu_test_callback',
- 'access arguments' => array('access content'),
- );
-
- $items['menu_login_callback'] = array(
- 'title' => 'Used as a login path',
- 'page callback' => 'menu_login_callback',
- 'access callback' => TRUE,
- );
-
- $items['menu-title-test/case1'] = array(
- 'title' => 'Example title - Case 1',
- 'access callback' => TRUE,
- 'page callback' => 'menu_test_callback',
- );
- $items['menu-title-test/case2'] = array(
- 'title' => 'Example @sub1 - Case @op2',
-
- 'title arguments' => array('@sub1' => 'title', '@op2' => '2'),
- 'access callback' => TRUE,
- 'page callback' => 'menu_test_callback',
- );
- $items['menu-title-test/case3'] = array(
- 'title' => 'Example title',
- 'title callback' => 'menu_test_title_callback',
- 'access callback' => TRUE,
- 'page callback' => 'menu_test_callback',
- );
- $items['menu-title-test/case4'] = array(
-
- 'title' => 'Bike sheds full of blue smurfs',
- 'title callback' => 'menu_test_title_callback',
-
- 'title arguments' => array('Example title', '4'),
- 'access callback' => TRUE,
- 'page callback' => 'menu_test_callback',
- );
-
-
- $items['menu-test/arguments/%menu_test_argument/%'] = array(
- 'title' => 'Load arguments inheritance test',
- 'load arguments' => array(3),
- 'page callback' => 'menu_test_callback',
- 'access callback' => TRUE,
- );
- $items['menu-test/arguments/%menu_test_argument/%/default'] = array(
- 'title' => 'Default local task',
- 'type' => MENU_DEFAULT_LOCAL_TASK,
- );
- $items['menu-test/arguments/%menu_test_argument/%/task'] = array(
- 'title' => 'Local task',
- 'page callback' => 'menu_test_callback',
- 'access callback' => TRUE,
- 'type' => MENU_LOCAL_TASK,
- );
-
- $items['menu-test/arguments/%menu_test_argument/%menu_test_other_argument/common-loader'] = array(
- 'title' => 'Local task',
- 'page callback' => 'menu_test_callback',
- 'access callback' => TRUE,
- 'type' => MENU_LOCAL_TASK,
- );
-
-
- $items['menu-test/arguments/%/%menu_test_argument/different-loaders-1'] = array(
- 'title' => 'An item not sharing the same loader',
- 'page callback' => 'menu_test_callback',
- 'access callback' => TRUE,
- );
-
- $items['menu-test/arguments/%menu_test_other_argument/%/different-loaders-2'] = array(
- 'title' => 'An item not sharing the same loader',
- 'page callback' => 'menu_test_callback',
- 'access callback' => TRUE,
- );
-
- $items['menu-test/arguments/%/%/different-loaders-3'] = array(
- 'title' => 'An item not sharing the same loader',
- 'page callback' => 'menu_test_callback',
- 'access callback' => TRUE,
- );
-
- $items['menu-test/arguments/%menu_test_argument/%/explicit-arguments'] = array(
- 'title' => 'An item defining explicit load arguments',
- 'load arguments' => array(),
- 'page callback' => 'menu_test_callback',
- 'access callback' => TRUE,
- );
-
- return $items;
- }
-
- * Dummy argument loader for hook_menu() to point to.
- */
- function menu_test_argument_load($arg1) {
- return FALSE;
- }
-
- * Dummy argument loader for hook_menu() to point to.
- */
- function menu_test_other_argument_load($arg1) {
- return FALSE;
- }
-
- * Dummy callback for hook_menu() to point to.
- *
- * @return
- * A random string.
- */
- function menu_test_callback() {
- return 'This is menu_test_callback().';
- }
-
- * Callback that test menu_test_menu_tree_set_path().
- */
- function menu_test_menu_trail_callback() {
- $menu_path = state_get('menu_test_menu_tree_set_path', array());
- if (!empty($menu_path)) {
- menu_tree_set_path($menu_path['menu_name'], $menu_path['path']);
- }
- return 'This is menu_test_menu_trail_callback().';
- }
-
- * Implements hook_init().
- */
- function menu_test_init() {
-
-
-
- if (state_get('menu_test_record_active_trail', FALSE)) {
- state_set('menu_test_active_trail_initial', menu_get_active_trail());
- }
-
-
- $string_overrides = array(
- 'Example title - Case 1' => 'Alternative example title - Case 1',
- 'Example @sub1 - Case @op2' => 'Alternative example @sub1 - Case @op2',
- 'Example title' => 'Alternative example title',
- 'Example title' => 'Alternative example title',
- );
- $GLOBALS['settings']['locale_custom_strings_en'] = array('' => $string_overrides);
- backdrop_static_reset('t');
- }
-
- * Callback for our custom 403 and 404 pages.
- */
- function menu_test_custom_403_404_callback() {
-
-
-
- if (state_get('menu_test_record_active_trail', FALSE)) {
- state_set('menu_test_active_trail_final', menu_get_active_trail());
- }
-
- return 'This is menu_test_custom_403_404_callback().';
- }
-
- * Page callback to use when testing the theme callback functionality.
- *
- * @param $inherited
- * An optional boolean to set to TRUE when the requested page is intended to
- * inherit the theme of its parent.
- * @return
- * A string describing the requested custom theme and actual theme being used
- * for the current page request.
- */
- function menu_test_theme_page_callback($inherited = FALSE) {
- global $theme_key;
-
- backdrop_theme_initialize();
-
- $custom_theme = menu_get_custom_theme();
- $requested_theme = empty($custom_theme) ? 'NONE' : $custom_theme;
- $output = "Custom theme: $requested_theme. Actual theme: $theme_key.";
- if ($inherited) {
- $output .= ' Theme callback inheritance is being tested.';
- }
- return $output;
- }
-
- * Theme callback to use when testing the theme callback functionality.
- *
- * @param $argument
- * The argument passed in from the URL.
- * @return
- * The name of the custom theme to request for the current page.
- */
- function menu_test_theme_callback($argument) {
-
- if ($argument == 'use-admin-theme') {
- return config_get('system.core', 'admin_theme');
- }
-
- elseif ($argument == 'use-stark-theme') {
- return 'stark';
- }
-
- elseif ($argument == 'use-fake-theme') {
- return 'fake_theme';
- }
-
-
-
- }
-
- * Implement hook_custom_theme().
- *
- * @return
- * The name of the custom theme to use for the current page.
- */
- function menu_test_custom_theme() {
-
-
-
- if ($theme = state_get('menu_test_hook_custom_theme_name', FALSE)) {
- return $theme;
- }
- }
-
- * Helper function for the testMenuName() test. Used to change the menu_name
- * parameter of a menu.
- *
- * @param $new_name
- * If set, will change the menu_name value.
- * @return
- * The menu_name value to use.
- */
- function menu_test_menu_name($new_name = '') {
- static $name = 'original';
- if ($new_name) {
- $name = $new_name;
- }
- return $name;
- }
-
- * Implements hook_menu_link_insert().
- *
- * @return
- * A random string.
- */
- function menu_test_menu_link_insert($item) {
- menu_test_static_variable('insert');
- }
-
- * Implements hook_menu_link_update().
- *
- * @return
- * A random string.
- */
- function menu_test_menu_link_update($item) {
- menu_test_static_variable('update');
- }
-
- * Implements hook_menu_link_delete().
- *
- * @return
- * A random string.
- */
- function menu_test_menu_link_delete($item) {
- menu_test_static_variable('delete');
- }
-
- * Static function for testing hook results.
- *
- * @param $value
- * The value to set or NULL to return the current value.
- * @return
- * A text string for comparison to test assertions.
- */
- function menu_test_static_variable($value = NULL) {
- static $variable;
- if (!empty($value)) {
- $variable = $value;
- }
- return $variable;
- }
-
- * Implements hook_menu_site_status_alter().
- */
- function menu_test_menu_site_status_alter(&$menu_site_status, $path) {
-
- if ($menu_site_status == MENU_SITE_OFFLINE && $path == 'menu_login_callback') {
- $menu_site_status = MENU_SITE_ONLINE;
- }
- }
-
- * Menu callback to be used as a login path.
- */
- function menu_login_callback() {
- return 'This is menu_login_callback().';
- }
-
- * Concatenates a string, by using the t() function and a case number.
- *
- * @param $title
- * Title string.
- * @param $case_number
- * The current case number which is tests (defaults to 3).
- */
- function menu_test_title_callback($title, $case_no = 3) {
- return t($title) . ' - Case ' . $case_no;
- }
-
- * Helper function for MenuChangeTestCase.
- *
- * @param string $new_type
- * If set, will change the type value.
- *
- * @return int
- * The type value to use.
- */
- function menu_test_change_menu_type($new_type = NULL) {
- static $type = MENU_NORMAL_ITEM;
- if ($new_type == 'callback') {
- $type = MENU_CALLBACK;
- }
- return $type;
- }