Commit 5bbbf10b authored by Dries's avatar Dries

- Patch #130987 by merlinofchaos: added theme registry for easier themability.

parent 21c5b717
......@@ -2,6 +2,7 @@
Drupal 6.0, xxxx-xx-xx (development version)
----------------------
- Added theme registry: modules can directly provide .tpl.php files for their themes without having to create theme_ functions.
- Added versioning support to node terms.
- Made it easier to theme the forum overview page.
- Drupal works with error reporting set to E_ALL.
......
......@@ -929,6 +929,15 @@ function drupal_maintenance_theme() {
drupal_add_css(drupal_get_path('module', 'system') .'/defaults.css', 'module');
drupal_add_css(drupal_get_path('module', 'system') .'/system.css', 'module');
$theme = '';
// Special case registry of theme functions used by the installer
$themes = drupal_common_themes();
foreach ($themes as $hook => $info) {
if (!isset($info['file']) && !isset($info['function'])) {
$themes[$hook]['function'] = 'theme_' . $hook;
}
}
_theme_set_registry($themes);
}
/**
......
......@@ -2292,3 +2292,193 @@ function element_child($key) {
function element_children($element) {
return array_filter(array_keys((array) $element), 'element_child');
}
/**
* Provide theme registration for themes across .inc files.
*/
function drupal_common_themes() {
return array(
// theme.inc
'placeholder' => array(
'arguments' => array('text' => NULL)
),
'page' => array(
'arguments' => array('content' => NULL, 'show_blocks' => TRUE),
),
'maintenance_page' => array(
'arguments' => array('content' => NULL, 'messages' => TRUE),
),
'install_page' => array(
'arguments' => array('content' => NULL),
),
'task_list' => array(
'arguments' => array('items' => NULL, 'active' => NULL),
),
'status_messages' => array(
'arguments' => array('display' => NULL),
),
'links' => array(
'arguments' => array('links' => NULL, 'attributes' => array('class' => 'links')),
),
'image' => array(
'arguments' => array('path' => NULL, 'alt' => '', 'title' => '', 'attributes' => NULL, 'getsize' => TRUE),
),
'breadcrumb' => array(
'arguments' => array('breadcrumb' => NULL),
),
'help' => array(
'arguments' => array(),
),
'node' => array(
'arguments' => array('node' => NULL, 'teaser' => FALSE, 'page' => FALSE),
),
'submenu' => array(
'arguments' => array('links' => NULL),
),
'table' => array(
'arguments' => array('header' => NULL, 'rows' => NULL, 'attributes' => array(), 'caption' => NULL),
),
'table_select_header_cell' => array(
'arguments' => array(),
),
'tablesort_indicator' => array(
'arguments' => array('style' => NULL),
),
'box' => array(
'arguments' => array('title' => NULL, 'content' => NULL, 'region' => 'main'),
),
'block' => array(
'arguments' => array('block' => NULL),
),
'mark' => array(
'arguments' => array('type' => MARK_NEW),
),
'item_list' => array(
'arguments' => array('items' => array(), 'title' => NULL, 'type' => 'ul', 'attributes' => NULL),
),
'more_help_link' => array(
'arguments' => array('url' => NULL),
),
'xml_icon' => array(
'arguments' => array('url' => NULL),
),
'feed_icon' => array(
'arguments' => array('url' => NULL),
),
'closure' => array(
'arguments' => array('main' => 0),
),
'blocks' => array(
'arguments' => array('region' => NULL),
),
'username' => array(
'arguments' => array('object' => NULL),
),
'progress_bar' => array(
'arguments' => array('percent' => NULL, 'message' => NULL),
),
// from pager.inc
'pager' => array(
'arguments' => array('tags' => array(), 'limit' => 10, 'element' => 0, 'parameters' => array()),
),
'pager_first' => array(
'arguments' => array('text' => NULL, 'limit' => NULL, 'element' => 0, 'parameters' => array()),
),
'pager_previous' => array(
'arguments' => array('text' => NULL, 'limit' => NULL, 'element' => 0, 'interval' => 1, 'parameters' => array()),
),
'pager_next' => array(
'arguments' => array('text' => NULL, 'limit' => NULL, 'element' => 0, 'interval' => 1, 'parameters' => array()),
),
'pager_last' => array(
'arguments' => array('text' => NULL, 'limit' => NULL, 'element' => 0, 'parameters' => array()),
),
'pager_list' => array(
'arguments' => array('limit' => NULL, 'element' => 0, 'quantity' => 5, 'text' => '', 'parameters' => array()),
),
'pager_link' => array(
'arguments' => array('text' => NULL, 'page_new' => NULL, 'element' => NULL, 'parameters' => array(), 'attributes' => array()),
),
// from locale.inc
'locale_admin_manage_screen' => array(
'arguments' => array('form' => NULL),
),
// from menu.inc
'menu_item_link' => array(
'arguments' => array('item' => NULL),
),
'menu_tree' => array(
'arguments' => array('tree' => NULL),
),
'menu_item' => array(
'arguments' => array('link' => NULL, 'has_children' => NULL, 'menu' => ''),
),
'menu_local_task' => array(
'arguments' => array('link' => NULL, 'active' => FALSE),
),
'menu_local_tasks' => array(
'arguments' => array(),
),
// from form.inc
'select' => array(
'arguments' => array('element' => NULL),
),
'fieldset' => array(
'arguments' => array('element' => NULL),
),
'radio' => array(
'arguments' => array('element' => NULL),
),
'radios' => array(
'arguments' => array('element' => NULL),
),
'password_confirm' => array(
'arguments' => array('element' => NULL),
),
'date' => array(
'arguments' => array('element' => NULL),
),
'item' => array(
'arguments' => array('element' => NULL),
),
'checkbox' => array(
'arguments' => array('element' => NULL),
),
'checkboxes' => array(
'arguments' => array('element' => NULL),
),
'submit' => array(
'arguments' => array('element' => NULL),
),
'button' => array(
'arguments' => array('element' => NULL),
),
'hidden' => array(
'arguments' => array('element' => NULL),
),
'token' => array(
'arguments' => array('element' => NULL),
),
'textfield' => array(
'arguments' => array('element' => NULL),
),
'form' => array(
'arguments' => array('element' => NULL),
),
'textarea' => array(
'arguments' => array('element' => NULL),
),
'markup' => array(
'arguments' => array('element' => NULL),
),
'password' => array(
'arguments' => array('element' => NULL),
),
'file' => array(
'arguments' => array('element' => NULL),
),
'form_element' => array(
'arguments' => array('element' => NULL, 'value' => NULL),
),
);
}
......@@ -457,7 +457,9 @@ function drupal_render_form($form_id, &$form) {
// Don't override #theme if someone already set it.
if (!isset($form['#theme'])) {
if (theme_get_function($form_id)) {
init_theme();
$registry = theme_get_registry();
if (isset($registry[$form_id])) {
$form['#theme'] = $form_id;
}
}
......
This diff is collapsed.
......@@ -31,7 +31,6 @@
elseif (isset($return)) {
// Print any value (including an empty string) except NULL or undefined:
print theme('page', $return);
}
drupal_page_footer();
......@@ -25,6 +25,29 @@ function aggregator_help($section) {
}
}
/**
* Implementation of hook_theme()
*/
function aggregator_theme() {
return array(
'aggregator_page_list' => array(
'arguments' => array('form' => NULL),
),
'aggregator_feed' => array(
'arguments' => array('feed' => NULL),
),
'aggregator_block_item' => array(
'arguments' => array('item' => NULL, 'feed' => 0),
),
'aggregator_summary_item' => array(
'arguments' => array('item' => NULL),
),
'aggregator_page_item' => array(
'arguments' => array('item' => NULL),
),
);
/**
* Implementation of hook_menu().
*/
......
......@@ -48,6 +48,17 @@ function block_help($section) {
}
}
/**
* Implementation of hook_theme()
*/
function block_theme() {
return array(
'block_admin_display' => array(
'arguments' => array('form' => NULL),
),
);
}
/**
* Implementation of hook_perm().
*/
......
......@@ -19,6 +19,23 @@ function book_node_info() {
);
}
/**
* Implementation of hook_theme()
*/
function book_theme() {
return array(
'book_navigation' => array(
'arguments' => array('node' => NULL),
),
'book_export_html' => array(
'arguments' => array('title' => NULL, 'content' => NULL),
),
'book_admin_table' => array(
'arguments' => array('form' => NULL),
),
);
}
/**
* Implementation of hook_perm().
*/
......
<?php
// $Id$
/**
* Implementation of hook_theme()
*/
function color_theme() {
return array(
'color_scheme_form' => array(
'arguments' => array('form' => NULL),
),
);
}
/**
* Implementation of hook_form_alter().
*/
......
......@@ -140,6 +140,53 @@ function comment_help($section) {
}
}
/**
* Implementation of hook_theme()
*/
function comment_theme() {
return array(
'comment_block' => array(
'arguments' => array(),
),
'comment_admin_overview' => array(
'arguments' => array('form' => NULL),
),
'comment_preview' => array(
'arguments' => array('comment' => NULL, 'links' => array(), 'visible' => 1),
),
'comment_view' => array(
'arguments' => array('comment' => NULL, 'links' => array(), 'visible' => 1),
),
'comment_controls' => array(
'arguments' => array('form' => NULL),
),
'comment' => array(
'arguments' => array('comment' => NULL, 'links' => array()),
),
'comment_folded' => array(
'arguments' => array('comment' => NULL),
),
'comment_flat_collapsed' => array(
'arguments' => array('comment' => NULL),
),
'comment_flat_expanded' => array(
'arguments' => array('comment' => NULL),
),
'comment_thread_collapsed' => array(
'arguments' => array('comment' => NULL),
),
'comment_thread_expanded' => array(
'arguments' => array('comment' => NULL),
),
'comment_post_forbidden' => array(
'arguments' => array('nid' => NULL),
),
'comment_wrapper' => array(
'arguments' => array('content' => NULL),
),
);
}
function _comment_view_access($node, $cid) {
return $node && $cid;
}
......
......@@ -46,6 +46,17 @@ function drupal_help($section) {
}
}
/**
* Implementation of hook_theme()
*/
function drupal_theme() {
return array(
'client_list' => array(
'arguments' => array('clients' => NULL),
),
);
}
function drupal_sites_registry_settings() {
// Check if all required fields are present
if ((variable_get('site_name', 'Drupal') == 'Drupal') || (variable_get('site_name', 'Drupal') == '')) {
......
......@@ -47,6 +47,26 @@ function filter_help($section) {
}
}
/**
* Implementation of hook_theme()
*/
function filter_theme() {
return array(
'filter_admin_overview' => array(
'arguments' => array('form' => NULL),
),
'filter_admin_order' => array(
'arguments' => array('form' => NULL),
),
'filter_tips' => array(
'arguments' => array('tips' => NULL, 'long' => FALSE, 'extra' => ''),
),
'filter_tips_more_info' => array(
'arguments' => array(),
),
);
}
/**
* Implementation of hook_menu().
*/
......
......@@ -28,6 +28,29 @@ function forum_help($section) {
}
}
/**
* Implementation of hook_theme()
*/
function forum_theme() {
return array(
'forum_display' => array(
'arguments' => array('forums' => NULL, 'topics' => NULL, 'parents' => NULL, 'tid' => NULL, 'sortby' => NULL, 'forum_per_page' => NULL),
),
'forum_list' => array(
'arguments' => array('forums' => NULL, 'parents' => NULL, 'tid' => NULL),
),
'forum_topic_list' => array(
'arguments' => array('tid' => NULL, 'topics' => NULL, 'sortby' => NULL, 'forum_per_page' => NULL),
),
'forum_icon' => array(
'arguments' => array('new_posts' => NULL, 'num_posts' => 0, 'comment_mode' => 0, 'sticky' => 0),
),
'forum_topic_navigation' => array(
'arguments' => array('node' => NULL),
),
);
}
/**
* Implementation of hook_menu().
*/
......
......@@ -187,7 +187,7 @@ function menu_overview() {
}
return theme('table', $header, $rows);
}
/**
* Menu callback; enable/disable a menu item.
*
......
......@@ -45,6 +45,38 @@ function node_help($section) {
}
}
/**
* Implementation of hook_theme()
*/
function node_theme() {
return array(
'node_list' => array(
'arguments' => array('items' => NULL, 'title' => NULL),
),
'node_search_admin' => array(
'arguments' => array('form' => NULL),
),
'node_filter_form' => array(
'arguments' => array('form' => NULL),
),
'node_filters' => array(
'arguments' => array('form' => NULL),
),
'node_admin_nodes' => array(
'arguments' => array('form' => NULL),
),
'node_form' => array(
'arguments' => array('form' => NULL),
),
'node_preview' => array(
'arguments' => array('node' => NULL),
),
'node_log_message' => array(
'arguments' => array('log' => NULL),
),
);
}
/**
* Implementation of hook_cron().
*/
......@@ -2349,7 +2381,6 @@ function node_revisions() {
* Menu callback; Generate a listing of promoted nodes.
*/
function node_page_default() {
$result = pager_query(db_rewrite_sql('SELECT n.nid, n.sticky, n.created FROM {node} n WHERE n.promote = 1 AND n.status = 1 ORDER BY n.sticky DESC, n.created DESC'), variable_get('default_nodes_main', 10));
if (db_num_rows($result)) {
......
......@@ -20,6 +20,23 @@ function poll_help($section) {
}
}
/**
* Implementation of hook_theme()
*/
function poll_theme() {
return array(
'poll_view_voting' => array(
'arguments' => array('form' => NULL),
),
'poll_results' => array(
'arguments' => array('title' => NULL, 'results' => NULL, 'votes' => NULL, 'links' => NULL, 'block' => NULL, 'nid' => NULL, 'vote' => NULL),
),
'poll_bar' => array(
'arguments' => array('title' => NULL, 'percentage' => NULL, 'votes' => NULL, 'block' => NULL),
),
);
}
/**
* Implementation of hook_access().
*/
......
......@@ -51,6 +51,19 @@ function profile_help($section) {
}
}
/**
* Implementation of hook_theme()
*/
function profile_theme() {
return array(
'profile_block' => array(
'arguments' => array('account' => NULL, 'fields' => array()),
),
'profile_listing' => array(
'arguments' => array('account' => NULL, 'fields' => array()),
), );
}
/**
* Implementation of hook_menu().
*/
......
......@@ -111,6 +111,26 @@ function search_help($section) {
}
}
/**
* Implementation of hook_theme()
*/
function search_theme() {
return array(
'search_theme_form' => array(
'arguments' => array('form' => NULL),
),
'search_block_form' => array(
'arguments' => array('form' => NULL),
),
'search_item' => array(
'arguments' => array('item' => NULL, 'type' => NULL),
),
'search_page' => array(
'arguments' => array('results' => NULL, 'type' => NULL),
),
);
}
/**
* Implementation of hook_perm().
*/
......
......@@ -48,6 +48,37 @@ function system_help($section) {
}
}
function system_theme() {
return array_merge(drupal_common_themes(), array(
'system_theme_select_form' => array(
'arguments' => array('form' => NULL),
),
'system_themes_form' => array(
'arguments' => array('form' => NULL),
),
'system_modules' => array(
'arguments' => array('form' => NULL),
),
'system_modules_uninstall' => array(
'arguments' => array('form' => NULL),
),
'status_report' => array(
'arguments' => array('requirements' => NULL),
),
'admin_page' => array(
'arguments' => array('blocks' => NULL),
),
'admin_block' => array(
'arguments' => array('block' => NULL),
),
'admin_block_content' => array(
'arguments' => array('content' => NULL),
),
'system_admin_by_module' => array(
'arguments' => array('menu_items' => NULL),
),
));
}
/**
* Implementation of hook_perm().
*/
......@@ -150,7 +181,7 @@ function system_menu() {
'title' => t('Themes'),
'description' => t('Change which theme your site uses or allows users to set.'),
'page callback' => 'drupal_get_form',
'page arguments' => array('system_themes'),
'page arguments' => array('system_themes_form'),
);
$items['admin/build/themes/select'] = array(
'title' => t('List'),
......@@ -1137,13 +1168,13 @@ function system_settings_form_submit($form_id, $form_values) {
drupal_set_message(t('The configuration options have been saved.'));
}
menu_rebuild();
drupal_rebuild_theme_registry();
}
/**
* Menu callback; displays a listing of all themes.
*/
function system_themes() {
function system_themes_form() {
drupal_clear_css_cache();
$themes = system_theme_data();
......@@ -1177,7 +1208,7 @@ function system_themes() {
return $form;
}
function theme_system_themes($form) {
function theme_system_themes_form($form) {
foreach (element_children($form) as $key) {
$row = array();
if (isset($form[$key]['description']) && is_array($form[$key]['description'])) {
......@@ -1199,7 +1230,7 @@ function theme_system_themes($form) {
}
function system_themes_submit($form_id, $form_values) {
function system_themes_form_submit($form_id, $form_values) {
db_query("UPDATE {system} SET status = 0 WHERE type = 'theme'");
......@@ -1513,6 +1544,7 @@ function system_modules_submit($form_id, $form_values) {
}
if ($old_module_list != $current_module_list) {
drupal_rebuild_theme_registry();
menu_rebuild();
node_types_rebuild();
drupal_set_message(t('The configuration options have been saved.'));
......
......@@ -13,6 +13,17 @@ function taxonomy_perm() {
return array('administer taxonomy');
}
/**
* Implementation of hook_theme()
*/
function taxonomy_theme() {
return array(
'taxonomy_term_select' => array(
'arguments' => array('element' => NULL),
),
);
}
/**
* Implementation of hook_link().
*
......@@ -1516,7 +1527,7 @@ function taxonomy_explode_tags($tags) {
$tags[] = $tag;
}
}
return $tags;
}
......@@ -1537,5 +1548,5 @@ function taxonomy_implode_tags($tags, $vid = NULL) {
$typed_tags[] = $term->name;
}
}
return implode(', ', $typed_tags);
return implode(', ', $typed_tags);
}
......@@ -22,6 +22,23 @@ function upload_help($section) {
}
}
/**
* Implementation of hook_theme()
*/
function upload_theme() {
return array(
'upload_attachments' => array(
'arguments' => array('files' => NULL),
),
'upload_form_current' => array(
'arguments' => array('form' => NULL),
),
'upload_form_new' => array(
'arguments' => array('form' => NULL),
),
);