diff options
author | Angie Byron <webchick@24967.no-reply.drupal.org> | 2009-02-05 01:05:17 +0000 |
---|---|---|
committer | Angie Byron <webchick@24967.no-reply.drupal.org> | 2009-02-05 01:05:17 +0000 |
commit | 993675ab6a1e0ab4ad6777f32e5f927e610b8b4c (patch) | |
tree | 2d604875d8f7d07f3a01c8f75420fd1949b13725 /modules | |
parent | c6dd7bec5e09c9a381f18f90baf9dacb280bd4cf (diff) | |
download | brdo-993675ab6a1e0ab4ad6777f32e5f927e610b8b4c.tar.gz brdo-993675ab6a1e0ab4ad6777f32e5f927e610b8b4c.tar.bz2 |
#348627 by smk-ka and catch: Allow menu title callback property to bypass t() (+documentation and tests)
Diffstat (limited to 'modules')
-rw-r--r-- | modules/menu/menu.api.php | 3 | ||||
-rw-r--r-- | modules/simpletest/tests/menu.test | 9 | ||||
-rw-r--r-- | modules/simpletest/tests/menu_test.module | 30 |
3 files changed, 36 insertions, 6 deletions
diff --git a/modules/menu/menu.api.php b/modules/menu/menu.api.php index c69eaa79d..da1a36fc5 100644 --- a/modules/menu/menu.api.php +++ b/modules/menu/menu.api.php @@ -27,6 +27,9 @@ * contain the following key-value pairs: * * - "title": Required. The untranslated title of the menu item. + * - "title callback": Function to generate the title, defaults to t(). + * If you require only the raw string to be output, set this to FALSE. + * - "title arguments": Arguments to send to t() or your custom callback. * - "description": The untranslated description of the menu item. * - "page callback": The function to call to display a web page when the user * visits the path. If omitted, the parent menu item's callback will be used diff --git a/modules/simpletest/tests/menu.test b/modules/simpletest/tests/menu.test index 802216c26..a4935c968 100644 --- a/modules/simpletest/tests/menu.test +++ b/modules/simpletest/tests/menu.test @@ -21,6 +21,15 @@ class MenuIncTestCase extends DrupalWebTestCase { } /** + * Test title callback set to FALSE. + */ + function testTitleCallbackFalse() { + $this->drupalGet('node'); + $this->assertText('A title with @placeholder', t('Raw text found on the page')); + $this->assertNoText(t('A title with @placeholder', array('@placeholder' => 'some other text')), t('Text with placeholder substitutions not found.')); + } + + /** * Tests for menu_name parameter for hook_menu(). */ function testMenuName() { diff --git a/modules/simpletest/tests/menu_test.module b/modules/simpletest/tests/menu_test.module index a2bbbdc15..7a25f6aff 100644 --- a/modules/simpletest/tests/menu_test.module +++ b/modules/simpletest/tests/menu_test.module @@ -3,18 +3,36 @@ /** * @file - * Dummy module implementing hook menu to test changing the menu name. + * Dummy module implementing hook menu. */ - /** - * The name of the menu changes during the course of this test. Use a $_GET. +/** + * Implementation of hook_menu(). */ function menu_test_menu() { - + // The name of the menu changes during the course of the test. Using a $_GET. $items['menu_name_test'] = array( - 'title' => t('Test menu_name router item'), + 'title' => 'Test menu_name router item', 'page callback' => 'node_save', 'menu_name' => isset($_GET["hook_menu_name"]) ? $_GET["hook_menu_name"] : 'original', ); + // Use FALSE as 'title callback' to bypass t(). + $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'), + ); return $items; -}
\ No newline at end of file +} + +/** + * Dummy callback for hook_menu() to point to. + * + * @return + * A random string. + */ +function menu_test_callback() { + return $this->randomName(); +} |