From 35e21e54e1122f98bede28f89d80f2fb13b3fd97 Mon Sep 17 00:00:00 2001 From: Dries Buytaert Date: Thu, 15 Oct 2009 12:27:34 +0000 Subject: - Patch #412730 by Crell, jbomb, JohnAlbin: theme system should report when a theme key is not found. --- modules/forum/forum.admin.inc | 15 +++++++++++++++ modules/forum/forum.module | 4 ++++ modules/simpletest/tests/theme.test | 19 ++++++++++++++++++- modules/system/system.admin.inc | 15 +++++++++++++++ modules/system/system.module | 25 +++++++++++++++++++++++-- 5 files changed, 75 insertions(+), 3 deletions(-) (limited to 'modules') diff --git a/modules/forum/forum.admin.inc b/modules/forum/forum.admin.inc index d7dbe5fa3..105e2fd26 100644 --- a/modules/forum/forum.admin.inc +++ b/modules/forum/forum.admin.inc @@ -98,6 +98,21 @@ function forum_form_submit($form, &$form_state) { return; } +/** + * Theme forum forms. + * + * By default this does not alter the appearance of a form at all, + * but is provided as a convenience for themers. + * + * @param $variables + * An associative array containing: + * - form: An associative array containing the structure of the form. + * @ingroup themeable + */ +function theme_forum_form($variables) { + return drupal_render_children($variables['form']); +} + /** * Returns a form for adding a container to the forum vocabulary * diff --git a/modules/forum/forum.module b/modules/forum/forum.module index 95c0337e6..6a62bdfe8 100644 --- a/modules/forum/forum.module +++ b/modules/forum/forum.module @@ -57,6 +57,10 @@ function forum_theme() { 'template' => 'forum-submitted', 'arguments' => array('topic' => NULL), ), + 'forum_form' => array( + 'arguments' => array('form' => NULL), + 'file' => 'forum.admin.inc', + ), ); } diff --git a/modules/simpletest/tests/theme.test b/modules/simpletest/tests/theme.test index 56860bd13..823a50c67 100644 --- a/modules/simpletest/tests/theme.test +++ b/modules/simpletest/tests/theme.test @@ -50,6 +50,23 @@ class TemplateUnitTest extends DrupalWebTestCase { $suggestions = array("page\0"); $this->assertEqual(drupal_discover_template(array('themes/garland'), $suggestions), 'themes/garland/page.tpl.php', t('Unsafe template suggestion fixed')); } + + /** + * Test that not-found theme hook throw a proper exception. + */ + function testThemeHookNotFound() { + try { + theme('this_does_not_exist'); + + $this->fail(t('Exception not thrown for invalid theme hook.')); + } + catch (ThemeHookNotFoundException $e) { + $this->assertEqual($e->getMessage(), t('Theme hook "this_does_not_exist" not found.'), t('Correct exception thrown with correct error message.')); + } + catch (Exception $e) { + $this->fail(t('Exception of type "@type" thrown instead of ThemeHookNotFoundException.', array('@type' => gettype($e)))); + } + } } /** @@ -63,7 +80,7 @@ class ThemeTableUnitTest extends DrupalWebTestCase { 'group' => 'Theme', ); } - + /** * Tableheader.js provides 'sticky' table headers, and is included by default. */ diff --git a/modules/system/system.admin.inc b/modules/system/system.admin.inc index 825249f70..3694848bf 100644 --- a/modules/system/system.admin.inc +++ b/modules/system/system.admin.inc @@ -2380,6 +2380,21 @@ function theme_system_modules_uninstall($variables) { return $output; } +/** + * Theme function for the system settings form. + * + * By default this does not alter the appearance of a form at all, + * but is provided as a convenience for themers. + * + * @param $variables + * An associative array containing: + * - form: An associative array containing the structure of the form. + * @ingroup themeable + */ +function theme_system_settings_form($variables) { + return drupal_render_children($variables['form']); +} + /** * Theme function for the system themes form. * diff --git a/modules/system/system.module b/modules/system/system.module index a6278b485..98ceebc0f 100644 --- a/modules/system/system.module +++ b/modules/system/system.module @@ -159,6 +159,13 @@ function system_theme() { 'arguments' => array('form' => NULL), 'file' => 'system.admin.inc', ), + 'system_settings_form' => array( + 'arguments' => array('form' => NULL), + 'file' => 'system.admin.inc', + ), + 'confirm_form' => array( + 'arguments' => array('form' => NULL), + ), 'system_modules_fieldset' => array( 'arguments' => array('form' => NULL), 'file' => 'system.admin.inc', @@ -1746,7 +1753,7 @@ function system_admin_menu_block($item) { $has_subitems = FALSE; $result = db_query(" SELECT m.load_functions, m.to_arg_functions, m.access_callback, m.access_arguments, m.page_callback, m.page_arguments, m.title, m.title_callback, m.title_arguments, m.theme_callback, m.theme_arguments, m.type, m.description, m.path, m.weight as router_weight, ml.* - FROM {menu_router} m + FROM {menu_router} m LEFT JOIN {menu_links} ml ON m.path = ml.router_path WHERE (ml.plid = :plid AND ml.menu_name = :name AND hidden = 0) OR (m.tab_parent = :path AND m.type IN (:local_task, :default_task))", array(':plid' => $item['mlid'], ':name' => $item['menu_name'], ':path' => $item['path'], ':local_task' => MENU_LOCAL_TASK, ':default_task' => MENU_DEFAULT_LOCAL_TASK), array('fetch' => PDO::FETCH_ASSOC)); foreach ($result as $link) { @@ -1780,7 +1787,7 @@ function system_admin_menu_block($item) { } } if ($has_subitems) { - // If we've had at least one non-tab subitem, remove the link for the + // If we've had at least one non-tab subitem, remove the link for the // default task, since that is already broken down to subitems. unset($content[$default_task]); } @@ -3364,3 +3371,17 @@ function system_date_format_delete($dfid) { ->execute(); } +/** + * Theme confirmation forms. + * + * By default this does not alter the appearance of a form at all, + * but is provided as a convenience for themers. + * + * @param $variables + * An associative array containing: + * - form: An associative array containing the structure of the form. + * @ingroup themeable + */ +function theme_confirm_form($variables) { + return drupal_render_children($variables['form']); +} -- cgit v1.2.3