Mercurial > defr > drupal > core
comparison includes/theme.inc @ 11:589fb7c02327 6.5
Drupal 6.5
author | Franck Deroche <webmaster@defr.org> |
---|---|
date | Tue, 23 Dec 2008 14:32:19 +0100 |
parents | fff6d4c8c043 |
children | 8b6c45761e01 |
comparison
equal
deleted
inserted
replaced
10:6f15c9d74937 | 11:589fb7c02327 |
---|---|
1 <?php | 1 <?php |
2 // $Id: theme.inc,v 1.415.2.9 2008/07/09 21:48:28 goba Exp $ | 2 // $Id: theme.inc,v 1.415.2.12 2008/09/17 08:57:23 goba Exp $ |
3 | 3 |
4 /** | 4 /** |
5 * @file | 5 * @file |
6 * The theme system, which controls the output of Drupal. | 6 * The theme system, which controls the output of Drupal. |
7 * | 7 * |
8 * The theme system allows for nearly all output of the Drupal system to be | 8 * The theme system allows for nearly all output of the Drupal system to be |
9 * customized by user themes. | 9 * customized by user themes. |
10 * | 10 * |
11 * @see <a href="http://drupal.org/node/253">Theme system</a> | 11 * @see <a href="http://drupal.org/node/171179">Theme guide</a> |
12 * @see themeable | 12 * @see themeable |
13 */ | 13 */ |
14 | 14 |
15 /** | 15 /** |
16 * @name Content markers | 16 * @name Content markers |
245 cache_clear_all('theme_registry', 'cache', TRUE); | 245 cache_clear_all('theme_registry', 'cache', TRUE); |
246 } | 246 } |
247 | 247 |
248 /** | 248 /** |
249 * Process a single invocation of the theme hook. $type will be one | 249 * Process a single invocation of the theme hook. $type will be one |
250 * of 'module', 'theme_engine' or 'theme' and it tells us some | 250 * of 'module', 'theme_engine', 'base_theme_engine', 'theme', or 'base_theme' |
251 * important information. | 251 * and it tells us some important information. |
252 * | 252 * |
253 * Because $cache is a reference, the cache will be continually | 253 * Because $cache is a reference, the cache will be continually |
254 * expanded upon; new entries will replace old entries in the | 254 * expanded upon; new entries will replace old entries in the |
255 * array_merge, but we are careful to ensure some data is carried | 255 * array_merge, but we are careful to ensure some data is carried |
256 * forward, such as the arguments a theme hook needs. | 256 * forward, such as the arguments a theme hook needs. |
312 $prefixes[] = 'template'; | 312 $prefixes[] = 'template'; |
313 // Add all modules so they can intervene with their own preprocessors. This allows them | 313 // Add all modules so they can intervene with their own preprocessors. This allows them |
314 // to provide preprocess functions even if they are not the owner of the current hook. | 314 // to provide preprocess functions even if they are not the owner of the current hook. |
315 $prefixes += module_list(); | 315 $prefixes += module_list(); |
316 } | 316 } |
317 elseif ($type == 'theme_engine') { | 317 elseif ($type == 'theme_engine' || $type == 'base_theme_engine') { |
318 // Theme engines get an extra set that come before the normally named preprocessors. | 318 // Theme engines get an extra set that come before the normally named preprocessors. |
319 $prefixes[] = $name .'_engine'; | 319 $prefixes[] = $name .'_engine'; |
320 // The theme engine also registers on behalf of the theme. The theme or engine name can be used. | 320 // The theme engine also registers on behalf of the theme. The theme or engine name can be used. |
321 $prefixes[] = $name; | 321 $prefixes[] = $name; |
322 $prefixes[] = $theme; | 322 $prefixes[] = $theme; |
379 _theme_process_registry($cache, $module, 'module', $module, drupal_get_path('module', $module)); | 379 _theme_process_registry($cache, $module, 'module', $module, drupal_get_path('module', $module)); |
380 } | 380 } |
381 | 381 |
382 // Process each base theme. | 382 // Process each base theme. |
383 foreach ($base_theme as $base) { | 383 foreach ($base_theme as $base) { |
384 // If the theme uses a theme engine, process its hooks. | 384 // If the base theme uses a theme engine, process its hooks. |
385 $base_path = dirname($base->filename); | 385 $base_path = dirname($base->filename); |
386 if ($theme_engine) { | 386 if ($theme_engine) { |
387 _theme_process_registry($cache, $theme_engine, 'base_theme_engine', $base->name, $base_path); | 387 _theme_process_registry($cache, $theme_engine, 'base_theme_engine', $base->name, $base_path); |
388 } | 388 } |
389 _theme_process_registry($cache, $base->name, 'base_theme', $base->name, $base_path); | 389 _theme_process_registry($cache, $base->name, 'base_theme', $base->name, $base_path); |
955 } | 955 } |
956 | 956 |
957 /** | 957 /** |
958 * Render a system default template, which is essentially a PHP template. | 958 * Render a system default template, which is essentially a PHP template. |
959 * | 959 * |
960 * @param $file | 960 * @param $template_file |
961 * The filename of the template to render. | 961 * The filename of the template to render. Note that this will overwrite |
962 * anything stored in $variables['template_file'] if using a preprocess hook. | |
962 * @param $variables | 963 * @param $variables |
963 * A keyed array of variables that will appear in the output. | 964 * A keyed array of variables that will appear in the output. |
964 * | 965 * |
965 * @return | 966 * @return |
966 * The output generated by the template. | 967 * The output generated by the template. |
967 */ | 968 */ |
968 function theme_render_template($file, $variables) { | 969 function theme_render_template($template_file, $variables) { |
969 extract($variables, EXTR_SKIP); // Extract the variables to a local namespace | 970 extract($variables, EXTR_SKIP); // Extract the variables to a local namespace |
970 ob_start(); // Start output buffering | 971 ob_start(); // Start output buffering |
971 include "./$file"; // Include the file | 972 include "./$template_file"; // Include the template file |
972 $contents = ob_get_contents(); // Get the contents of the buffer | 973 $contents = ob_get_contents(); // Get the contents of the buffer |
973 ob_end_clean(); // End buffering and discard | 974 ob_end_clean(); // End buffering and discard |
974 return $contents; // Return the contents | 975 return $contents; // Return the contents |
975 } | 976 } |
976 | 977 |