Commit 35e21e54 authored by Dries's avatar Dries

- Patch #412730 by Crell, jbomb, JohnAlbin: theme system should report when a...

- Patch #412730 by Crell, jbomb, JohnAlbin: theme system should report when a theme key is not found.
parent 5acbec27
......@@ -37,6 +37,12 @@
* @} End of "Content markers".
*/
/**
* An exception to throw when a theme function is requested that does not exist.
*/
class ThemeHookNotFoundException extends Exception {}
/**
* Determines if a theme is available to use.
*
......@@ -256,7 +262,7 @@ function _theme_load_registry($theme, $base_theme = NULL, $theme_engine = NULL)
else {
// If not, build one and cache it.
$registry = _theme_build_registry($theme, $base_theme, $theme_engine);
// Only persist this registry if all modules are loaded. This assures a
// Only persist this registry if all modules are loaded. This assures a
// complete set of theme hooks.
if (drupal_get_bootstrap_phase() == DRUPAL_BOOTSTRAP_FULL) {
_theme_save_registry($theme, $registry);
......@@ -762,7 +768,7 @@ function theme($hook, $variables = array()) {
}
if (!isset($hooks[$hook])) {
return;
throw new ThemeHookNotFoundException(t('Theme hook "@hook" not found.', array('@hook' => $hook)));
}
$info = $hooks[$hook];
......@@ -2139,7 +2145,7 @@ function template_preprocess_html(&$variables) {
else {
$variables['classes_array'][] = 'no-sidebars';
}
// Populate the body classes.
if ($suggestions = template_page_suggestions(arg(), 'page')) {
foreach ($suggestions as $suggestion) {
......@@ -2151,7 +2157,7 @@ function template_preprocess_html(&$variables) {
}
}
}
// If on an individual node page, add the node type to body classes.
if ($node = menu_get_object()) {
$variables['classes_array'][] = drupal_html_class('node-type-' . $node->type);
......@@ -2183,7 +2189,7 @@ function template_preprocess_html(&$variables) {
}
}
$variables['head_title'] = implode(' | ', $head_title);
// Populate the page template suggestions.
if ($suggestions = template_page_suggestions(arg(), 'html')) {
$variables['template_files'] = $suggestions;
......
......@@ -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
*
......
......@@ -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',
),
);
}
......
......@@ -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.
*/
......
......@@ -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.
*
......
......@@ -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']);
}
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