C:/drupal/includes/theme.inc File Reference

Go to the source code of this file.


Enumerations

Content markers
Markers used by theme_mark() and node_mark() to designate content.
See also:
theme_mark(), node_mark()


enum  MARK_READ
enum  MARK_NEW
enum  MARK_UPDATED

Functions

 init_theme ()
 _init_theme ($theme, $base_theme=array(), $registry_callback= '_theme_load_registry')
 theme_get_registry ($registry=NULL)
 _theme_set_registry ($registry)
 _theme_load_registry ($theme, $base_theme=NULL, $theme_engine=NULL)
 _theme_save_registry ($theme, $registry)
 drupal_rebuild_theme_registry ()
 _theme_process_registry (&$cache, $name, $type, $theme, $path)
 _theme_build_registry ($theme, $base_theme, $theme_engine)
 list_themes ($refresh=FALSE)
 theme ()
 drupal_discover_template ($paths, $suggestions, $extension= '.tpl.php')
 path_to_theme ()
 drupal_find_theme_functions ($cache, $prefixes)
 drupal_find_theme_templates ($cache, $extension, $path)
 theme_get_settings ($key=NULL)
 theme_get_setting ($setting_name, $refresh=FALSE)
 theme_render_template ($file, $variables)
 theme_placeholder ($text)
 theme_status_messages ($display=NULL)
 theme_links ($links, $attributes=array('class'=> 'links'))
 theme_image ($path, $alt= '', $title= '', $attributes=NULL, $getsize=TRUE)
 theme_breadcrumb ($breadcrumb)
 theme_help ()
 theme_submenu ($links)
 theme_table ($header, $rows, $attributes=array(), $caption=NULL, $colgroups=array())
 theme_table_select_header_cell ()
 theme_tablesort_indicator ($style)
 theme_box ($title, $content, $region= 'main')
 theme_mark ($type=MARK_NEW)
 theme_item_list ($items=array(), $title=NULL, $type= 'ul', $attributes=NULL)
 theme_more_help_link ($url)
 theme_xml_icon ($url)
 theme_feed_icon ($url, $title)
 theme_more_link ($url, $title)
 theme_closure ($main=0)
 theme_blocks ($region)
 theme_username ($object)
 theme_progress_bar ($percent, $message)
 theme_indentation ($size=1)
 _theme_table_cell ($cell, $header=FALSE)
 template_preprocess (&$variables, $hook)
 template_preprocess_page (&$variables)
 template_preprocess_node (&$variables)
 template_preprocess_block (&$variables)


Detailed Description

The theme system, which controls the output of Drupal.

The theme system allows for nearly all output of the Drupal system to be customized by user themes.

See also:

Default theme implementations

Definition in file theme.inc.


Enumeration Type Documentation

enum MARK_NEW

Mark content as being new.

Definition at line 30 of file theme.inc.

enum MARK_READ

Mark content as read.

Definition at line 25 of file theme.inc.

Mark content as being updated.

Definition at line 35 of file theme.inc.


Function Documentation

_init_theme ( theme,
base_theme = array(),
registry_callback = '_theme_load_registry' 
)

Initialize the theme system given already loaded information. This function is useful to initialize a theme when no database is present.

Parameters:
$theme An object with the following information: filename The .info file for this theme. The 'path' to the theme will be in this file's directory. (Required) owner The path to the .theme file or the .engine file to load for the theme. (Required) stylesheet The primary stylesheet for the theme. (Optional) engine The name of theme engine to use. (Optional)
$base_theme An optional array of objects that represent the 'base theme' if the theme is meant to be derivative of another theme. It requires the same information as the $theme object. It should be in 'oldest first' order, meaning the top level of the chain will be first.
$registry_callback The callback to invoke to set the theme registry.

Definition at line 101 of file theme.inc.

References $name, drupal_add_css(), drupal_add_js(), and drupal_function_exists().

Referenced by _drupal_maintenance_theme(), and init_theme().

Here is the call graph for this function:

_theme_build_registry ( theme,
base_theme,
theme_engine 
)

Rebuild the hook theme_registry cache.

Parameters:
$theme The loaded $theme object.
$base_theme An array of loaded $theme objects representing the ancestor themes in oldest first order.
theme_engine The name of the theme engine.

Definition at line 381 of file theme.inc.

References _theme_process_registry(), drupal_alter(), drupal_get_path(), module_implements(), and name.

Referenced by _theme_load_offline_registry(), and _theme_load_registry().

Here is the call graph for this function:

_theme_load_registry ( theme,
base_theme = NULL,
theme_engine = NULL 
)

Get the theme_registry cache from the database; if it doesn't exist, build it.

Parameters:
$theme The loaded $theme object.
$base_theme An array of loaded $theme objects representing the ancestor themes in oldest first order.
theme_engine The name of the theme engine.

Definition at line 233 of file theme.inc.

References _theme_build_registry(), _theme_save_registry(), _theme_set_registry(), and cache_get().

Here is the call graph for this function:

_theme_process_registry ( &$  cache,
name,
type,
theme,
path 
)

Process a single invocation of the theme hook. $type will be one of 'module', 'theme_engine' or 'theme' and it tells us some important information.

Because $cache is a reference, the cache will be continually expanded upon; new entries will replace old entries in the array_merge, but we are careful to ensure some data is carried forward, such as the arguments a theme hook needs.

An override flag can be set for preprocess functions. When detected the cached preprocessors for the hook will not be merged with the newly set. This can be useful to themes and theme engines by giving them more control over how and when the preprocess functions are run.

Definition at line 278 of file theme.inc.

References $name, $result, $type, and module_list().

Referenced by _theme_build_registry().

Here is the call graph for this function:

_theme_save_registry ( theme,
registry 
)

Write the theme_registry cache into the database.

Definition at line 250 of file theme.inc.

References cache_set().

Referenced by _theme_load_registry().

Here is the call graph for this function:

_theme_set_registry ( registry  ) 

Store the theme registry in memory.

Definition at line 216 of file theme.inc.

References theme_get_registry().

Referenced by _theme_load_offline_registry(), and _theme_load_registry().

Here is the call graph for this function:

_theme_table_cell ( cell,
header = FALSE 
)

End of "defgroup themeable".

Definition at line 1702 of file theme.inc.

References $attributes, $header, $output, and drupal_attributes().

Referenced by theme_table().

Here is the call graph for this function:

drupal_discover_template ( paths,
suggestions,
extension = '.tpl.php' 
)

Choose which template file to actually render. These are all suggested templates from themes and modules. Theming implementations can occur on multiple levels. All paths are checked to account for this.

Definition at line 687 of file theme.inc.

Referenced by theme().

drupal_find_theme_functions ( cache,
prefixes 
)

Find overridden theme functions. Called by themes and/or theme engines to easily discover theme functions.

Parameters:
$cache The existing cache of theme hooks to test against.
$prefixes An array of prefixes to test, in reverse order of importance.
Returns:
$templates The functions found, suitable for returning from hook_theme;

Definition at line 729 of file theme.inc.

drupal_find_theme_templates ( cache,
extension,
path 
)

Find overridden theme templates. Called by themes and/or theme engines to easily discover templates.

Parameters:
$cache The existing cache of theme hooks to test against.
$extension The extension that these templates will have.
$path The path to search.

Definition at line 769 of file theme.inc.

References drupal_system_listing(), and list_themes().

Here is the call graph for this function:

drupal_rebuild_theme_registry (  ) 

Force the system to rebuild the theme registry; this should be called when modules are added to the system, or when a dynamic system needs to add more theme hooks.

Definition at line 259 of file theme.inc.

References cache_clear_all().

Referenced by drupal_flush_all_caches(), DrupalWebTestCase::drupalModuleDisable(), DrupalWebTestCase::drupalModuleEnable(), system_modules(), and system_themes_form_submit().

Here is the call graph for this function:

init_theme (  ) 

End of "Content markers". Initialize the theme system by loading the theme.

Definition at line 44 of file theme.inc.

References _init_theme(), drupal_bootstrap(), list_themes(), theme(), and variable_get().

Referenced by block_admin_display_form(), drupal_render_form(), path_to_theme(), and theme().

Here is the call graph for this function:

list_themes ( refresh = FALSE  ) 

Provides a list of currently available themes.

If the database is active then it will be retrieved from the database. Otherwise it will retrieve a new list.

Parameters:
$refresh Whether to reload the list of themes from the database.
Returns:
An array of the currently available themes.

Definition at line 423 of file theme.inc.

References $result, db_fetch_object(), db_is_active(), and db_query().

Referenced by _drupal_maintenance_theme(), block_add_block_form_submit(), drupal_find_theme_templates(), init_theme(), system_themes_form_submit(), and theme_get_setting().

Here is the call graph for this function:

path_to_theme (  ) 

Return the path to the currently selected theme.

Definition at line 707 of file theme.inc.

References init_theme().

Referenced by garland_get_ie_styles(), and template_preprocess().

Here is the call graph for this function:

template_preprocess ( &$  variables,
hook 
)

Adds a default set of helper variables for preprocess functions and templates. This comes in before any other preprocess function which makes it possible to be used in default theme implementations (non-overriden theme functions).

Definition at line 1732 of file theme.inc.

References db_is_active(), drupal_is_front_page(), and path_to_theme().

Here is the call graph for this function:

template_preprocess_block ( &$  variables  ) 

Process variables for block.tpl.php

Prepare the values passed to the theme_block function to be passed into a pluggable template engine. Uses block properties to generate a series of template file suggestions. If none are found, the default block.tpl.php is used.

Most themes utilize their own copy of block.tpl.php. The default is located inside "modules/system/block.tpl.php". Look in there for the full list of variables.

The $variables array contains the following arguments:

  • $block

See also:
block.tpl.php

Definition at line 1988 of file theme.inc.

template_preprocess_node ( &$  variables  ) 

Process variables for node.tpl.php

Most themes utilize their own copy of node.tpl.php. The default is located inside "modules/node/node.tpl.php". Look in there for the full list of variables.

The $variables array contains the following arguments:

  • $node
  • $teaser
  • $page

See also:
node.tpl.php

Definition at line 1929 of file theme.inc.

References check_plain(), format_date(), module_exists(), nid, theme(), theme_get_setting(), and url().

Here is the call graph for this function:

template_preprocess_page ( &$  variables  ) 

Process variables for page.tpl.php

Most themes utilize their own copy of page.tpl.php. The default is located inside "modules/system/page.tpl.php". Look in there for the full list of variables.

Uses the arg() function to generate a series of page template suggestions based on the current path.

Any changes to variables in this preprocessor should also be changed inside template_preprocess_maintenance_page() to keep all them consistent.

The $variables array contains the following arguments:

  • $content
  • $show_blocks

See also:
page.tpl.php

Definition at line 1782 of file theme.inc.

References $body_classes, $head_title, arg(), base_path(), check_url(), drupal_add_css(), drupal_get_breadcrumb(), drupal_get_css(), drupal_get_feeds(), drupal_get_form(), drupal_get_html_head(), drupal_get_js(), drupal_get_title(), drupal_is_front_page(), drupal_set_html_head(), drupal_strtolower(), form_clean_id(), menu_get_object(), menu_primary_links(), menu_secondary_links(), theme(), theme_get_setting(), url(), and variable_get().

Here is the call graph for this function:

theme (  ) 

Generate the themed output.

All requests for theme hooks must go through this function. It examines the request and routes it to the appropriate theme function. The theme registry is checked to determine which implementation to use, which may be a function or a template.

If the implementation is a function, it is executed and its return value passed along.

If the implementation is a template, the arguments are converted to a $variables array. This array is then modified by the module implementing the hook, theme engine (if applicable) and the theme. The following functions may be used to modify the $variables array. They are processed in this order when available:

  • template_preprocess(&$variables) This sets a default set of variables for all template implementations.

  • template_preprocess_HOOK(&$variables) This is the first preprocessor called specific to the hook; it should be implemented by the module that registers it.

  • MODULE_preprocess(&$variables) This will be called for all templates; it should only be used if there is a real need. It's purpose is similar to template_preprocess().

  • MODULE_preprocess_HOOK(&$variables) This is for modules that want to alter or provide extra variables for theming hooks not registered to itself. For example, if a module named "foo" wanted to alter the $submitted variable for the hook "node" a preprocess function of foo_preprocess_node() can be created to intercept and alter the variable.

  • ENGINE_engine_preprocess(&$variables) This function should only be implemented by theme engines and exists so that it can set necessary variables for all hooks.

  • ENGINE_engine_preprocess_HOOK(&$variables) This is the same as the previous function, but it is called for a single theming hook.

  • ENGINE_preprocess(&$variables) This is meant to be used by themes that utilize a theme engine. It is provided so that the preprocessor is not locked into a specific theme. This makes it easy to share and transport code but theme authors must be careful to prevent fatal re-declaration errors when using sub-themes that have their own preprocessor named exactly the same as its base theme. In the default theme engine (PHPTemplate), sub-themes will load their own template.php file in addition to the one used for its parent theme. This increases the risk for these errors. A good practice is to use the engine name for the base theme and the theme name for the sub-themes to minimize this possibility.

  • ENGINE_preprocess_HOOK(&$variables) The same applies from the previous function, but it is called for a specific hook.

  • THEME_preprocess(&$variables) These functions are based upon the raw theme; they should primarily be used by themes that do not use an engine or by sub-themes. It serves the same purpose as ENGINE_preprocess().

  • THEME_preprocess_HOOK(&$variables) The same applies from the previous function, but it is called for a specific hook.

There are two special variables that these hooks can set: 'template_file' and 'template_files'. These will be merged together to form a list of 'suggested' alternate template files to use, in reverse order of priority. template_file will always be a higher priority than items in template_files. theme() will then look for these files, one at a time, and use the first one that exists.

Parameters:
$hook The name of the theme function to call. May be an array, in which case the first hook that actually has an implementation registered will be used. This can be used to choose 'fallback' theme implementations, so that if the specific theme hook isn't implemented anywhere, a more generic one will be used. This can allow themes to create specific theme implementations for named objects.
... Additional arguments to pass along to the theme function.
Returns:
An HTML string that generates the themed output.

Definition at line 567 of file theme.inc.

References $name, $output, drupal_discover_template(), drupal_function_exists(), init_theme(), and theme_get_registry().

Referenced by _aggregator_page_list(), _batch_progress_page_nojs(), _db_error_page(), _locale_translate_seek(), _node_mass_update_batch_finished(), _system_sql(), aggregator_categorize_items(), aggregator_page_categories(), aggregator_page_opml(), aggregator_page_rss(), aggregator_page_source(), aggregator_page_sources(), aggregator_view(), blog_page_last(), blog_page_user(), book_admin_overview(), book_export_html(), book_render(), comment_admin_overview(), comment_reply(), contact_admin_categories(), dblog_event(), dblog_overview(), dblog_top(), drupal_access_denied(), drupal_add_feed(), drupal_not_found(), drupal_render(), drupal_site_offline(), filter_admin_format_form(), filter_tips_long(), forum_page(), garland_node_submitted(), garland_preprocess_page(), help_page(), init_theme(), install_already_done_error(), install_change_settings(), install_main(), install_no_profile_error(), install_select_locale(), install_select_profile(), install_tasks(), locale_translate_overview_screen(), menu_get_active_help(), menu_local_tasks(), menu_overview_page(), menu_tree_output(), node_add_page(), node_admin_nodes(), node_overview_types(), node_preview(), node_revision_overview(), node_type_form(), openid_user_identities(), DrupalReporter::paintError(), DrupalReporter::paintFail(), DrupalReporter::paintGroupEnd(), DrupalReporter::paintPass(), path_admin_overview(), phptemplate_comment_submitted(), poll_page(), poll_votes(), profile_browse(), search_view(), statistics_access_log(), statistics_node_tracker(), statistics_recent_hits(), statistics_top_pages(), statistics_top_referrers(), statistics_top_visitors(), statistics_user_tracker(), system_admin_by_module(), system_admin_menu_block_page(), system_batch_page(), system_ip_blocking(), system_logging_overview(), system_main_admin_page(), system_modules(), system_modules_confirm_form(), system_modules_uninstall_confirm_form(), system_settings_overview(), system_status(), system_themes_form(), t(), tablesort_header(), taxonomy_term_page(), template_preprocess_aggregator_feed_source(), template_preprocess_aggregator_summary_items(), template_preprocess_aggregator_wrapper(), template_preprocess_maintenance_page(), template_preprocess_node(), template_preprocess_page(), template_preprocess_search_results(), theme_admin_page(), theme_aggregator_categorize_items(), theme_blocks(), theme_book_admin_table(), theme_checkbox(), theme_checkboxes(), theme_comment_admin_overview(), theme_date(), theme_feed_icon(), theme_file(), theme_filter_admin_order(), theme_filter_admin_overview(), theme_install_page(), theme_item(), theme_locale_languages_overview_form(), theme_menu_overview_form(), theme_node_admin_nodes(), theme_pager(), theme_pager_first(), theme_pager_last(), theme_pager_next(), theme_pager_previous(), theme_password(), theme_password_confirm(), theme_profile_admin_overview(), theme_radio(), theme_radios(), theme_select(), theme_submit(), theme_system_admin_by_module(), theme_system_modules(), theme_system_modules_uninstall(), theme_system_theme_select_form(), theme_system_themes_form(), theme_tablesort_indicator(), theme_taxonomy_overview_terms(), theme_taxonomy_overview_vocabularies(), theme_textarea(), theme_textfield(), theme_token(), theme_trigger_display(), theme_update_page(), theme_update_report(), theme_update_version(), theme_user_admin_account(), theme_user_admin_new_role(), theme_user_admin_perm(), theme_xml_icon(), tracker_page(), translation_node_overview(), update_results_page(), update_status(), update_task_list(), user_admin_account(), and user_view().

Here is the call graph for this function:

theme_get_registry ( registry = NULL  ) 

Retrieve the stored theme registry. If the theme registry is already in memory it will be returned; otherwise it will attempt to load the registry from cache. If this fails, it will construct the registry and cache it.

Definition at line 204 of file theme.inc.

Referenced by _theme_set_registry(), drupal_render_form(), and theme().

theme_get_setting ( setting_name,
refresh = FALSE 
)

Retrieve a setting for the current theme. This function is designed for use from within themes & engines to determine theme settings made in the admin interface.

Caches values for speed (use $refresh = TRUE to refresh cache)

Parameters:
$setting_name The name of the setting to be retrieved.
$refresh Whether to reload the cache of settings.
Returns:
The value of the requested setting, NULL if the setting does not exist.

Definition at line 916 of file theme.inc.

References base_path(), list_themes(), theme_get_settings(), and variable_get().

Referenced by template_preprocess_maintenance_page(), template_preprocess_node(), and template_preprocess_page().

Here is the call graph for this function:

theme_get_settings ( key = NULL  ) 

Retrieve an associative array containing the settings for a theme.

The final settings are arrived at by merging the default settings, the site-wide settings, and the settings defined for the specific theme. If no $key was specified, only the site-wide theme defaults are retrieved.

The default values for each of settings are also defined in this function. To add new settings, add their default values here, and then add form elements to system_theme_settings() in system.module.

Parameters:
$key The template/style value for a given theme.
Returns:
An associative array containing theme settings.

Definition at line 860 of file theme.inc.

References $name, $type, module_exists(), and variable_get().

Referenced by system_theme_settings(), and theme_get_setting().

Here is the call graph for this function:

theme_render_template ( file,
variables 
)

Render a system default template, which is essentially a PHP template.

Parameters:
$file The filename of the template to render.
$variables A keyed array of variables that will appear in the output.
Returns:
The output generated by the template.

Definition at line 975 of file theme.inc.

Referenced by theme_install_page(), and theme_update_page().


Generated on Mon Jun 2 15:08:09 2008 for SimpleTest by  1.5.5