comparison includes/theme.inc @ 7:fff6d4c8c043 6.3

Drupal 6.3
author Franck Deroche <webmaster@defr.org>
date Tue, 23 Dec 2008 14:30:28 +0100
parents 2427550111ae
children 589fb7c02327
comparison
equal deleted inserted replaced
6:2cfdc3c92142 7:fff6d4c8c043
1 <?php 1 <?php
2 // $Id: theme.inc,v 1.415.2.2 2008/03/25 11:55:08 goba Exp $ 2 // $Id: theme.inc,v 1.415.2.9 2008/07/09 21:48:28 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 *
328 328
329 foreach ($prefixes as $prefix) { 329 foreach ($prefixes as $prefix) {
330 if (function_exists($prefix .'_preprocess')) { 330 if (function_exists($prefix .'_preprocess')) {
331 $info['preprocess functions'][] = $prefix .'_preprocess'; 331 $info['preprocess functions'][] = $prefix .'_preprocess';
332 } 332 }
333
333 if (function_exists($prefix .'_preprocess_'. $hook)) { 334 if (function_exists($prefix .'_preprocess_'. $hook)) {
334 $info['preprocess functions'][] = $prefix .'_preprocess_'. $hook; 335 $info['preprocess functions'][] = $prefix .'_preprocess_'. $hook;
336 }
337
338 if (!empty($info['original hook']) && function_exists($prefix .'_preprocess_'. $info['original hook'])) {
339 $info['preprocess functions'][] = $prefix .'_preprocess_'. $info['original hook'];
335 } 340 }
336 } 341 }
337 } 342 }
338 // Check for the override flag and prevent the cached preprocess functions from being used. 343 // Check for the override flag and prevent the cached preprocess functions from being used.
339 // This allows themes or theme engines to remove preprocessors set earlier in the registry build. 344 // This allows themes or theme engines to remove preprocessors set earlier in the registry build.
341 // Flag not needed inside the registry. 346 // Flag not needed inside the registry.
342 unset($result[$hook]['override preprocess functions']); 347 unset($result[$hook]['override preprocess functions']);
343 } 348 }
344 elseif (isset($cache[$hook]['preprocess functions']) && is_array($cache[$hook]['preprocess functions'])) { 349 elseif (isset($cache[$hook]['preprocess functions']) && is_array($cache[$hook]['preprocess functions'])) {
345 $info['preprocess functions'] = array_merge($cache[$hook]['preprocess functions'], $info['preprocess functions']); 350 $info['preprocess functions'] = array_merge($cache[$hook]['preprocess functions'], $info['preprocess functions']);
351 }
352 elseif (isset($info['original hook']) && isset($cache[$info['original hook']]['preprocess functions']) && is_array($cache[$info['original hook']]['preprocess functions'])) {
353 $info['preprocess functions'] = array_merge($cache[$info['original hook']]['preprocess functions'], $info['preprocess functions']);
346 } 354 }
347 $result[$hook]['preprocess functions'] = $info['preprocess functions']; 355 $result[$hook]['preprocess functions'] = $info['preprocess functions'];
348 } 356 }
349 357
350 // Merge the newly created theme hooks into the existing cache. 358 // Merge the newly created theme hooks into the existing cache.
432 } 440 }
433 441
434 foreach ($themes as $theme) { 442 foreach ($themes as $theme) {
435 foreach ($theme->info['stylesheets'] as $media => $stylesheets) { 443 foreach ($theme->info['stylesheets'] as $media => $stylesheets) {
436 foreach ($stylesheets as $stylesheet => $path) { 444 foreach ($stylesheets as $stylesheet => $path) {
437 if (file_exists($path)) { 445 $theme->stylesheets[$media][$stylesheet] = $path;
438 $theme->stylesheets[$media][$stylesheet] = $path;
439 }
440 } 446 }
441 } 447 }
442 foreach ($theme->info['scripts'] as $script => $path) { 448 foreach ($theme->info['scripts'] as $script => $path) {
443 if (file_exists($path)) { 449 if (file_exists($path)) {
444 $theme->scripts[$script] = $path; 450 $theme->scripts[$script] = $path;
723 foreach ($matches as $match) { 729 foreach ($matches as $match) {
724 $new_hook = str_replace($prefix .'_', '', $match); 730 $new_hook = str_replace($prefix .'_', '', $match);
725 $templates[$new_hook] = array( 731 $templates[$new_hook] = array(
726 'function' => $match, 732 'function' => $match,
727 'arguments' => $info['arguments'], 733 'arguments' => $info['arguments'],
734 'original hook' => $hook,
728 ); 735 );
729 } 736 }
730 } 737 }
731 } 738 }
732 if (function_exists($prefix .'_'. $hook)) { 739 if (function_exists($prefix .'_'. $hook)) {
815 // Put the underscores back in for the hook name and register this pattern. 822 // Put the underscores back in for the hook name and register this pattern.
816 $templates[strtr($file, '-', '_')] = array( 823 $templates[strtr($file, '-', '_')] = array(
817 'template' => $file, 824 'template' => $file,
818 'path' => dirname($files[$match]->filename), 825 'path' => dirname($files[$match]->filename),
819 'arguments' => $info['arguments'], 826 'arguments' => $info['arguments'],
827 'original hook' => $hook,
820 ); 828 );
821 } 829 }
822 } 830 }
823 } 831 }
824 } 832 }
997 * array of arrays with information about the hook. It describes the 1005 * array of arrays with information about the hook. It describes the
998 * arguments the function or template will need, and provides 1006 * arguments the function or template will need, and provides
999 * defaults for the template in case they are not filled in. If the default 1007 * defaults for the template in case they are not filled in. If the default
1000 * implementation is a function, by convention it is named theme_HOOK(). 1008 * implementation is a function, by convention it is named theme_HOOK().
1001 * 1009 *
1002 * Each module should provide a default implementation for themes that 1010 * Each module should provide a default implementation for theme_hooks that
1003 * it registers. This implementation may be either a function or a template; 1011 * it registers. This implementation may be either a function or a template;
1004 * if it is a function it must be specified via hook_theme(). By convention, 1012 * if it is a function it must be specified via hook_theme(). By convention,
1005 * default implementations of theme hooks are named theme_HOOK. Default 1013 * default implementations of theme hooks are named theme_HOOK. Default
1006 * template implementations are stored in the module directory. 1014 * template implementations are stored in the module directory.
1007 * 1015 *
1104 $class .= ' last'; 1112 $class .= ' last';
1105 } 1113 }
1106 if (isset($link['href']) && ($link['href'] == $_GET['q'] || ($link['href'] == '<front>' && drupal_is_front_page()))) { 1114 if (isset($link['href']) && ($link['href'] == $_GET['q'] || ($link['href'] == '<front>' && drupal_is_front_page()))) {
1107 $class .= ' active'; 1115 $class .= ' active';
1108 } 1116 }
1109 $output .= '<li class="'. $class .'">'; 1117 $output .= '<li'. drupal_attributes(array('class' => $class)) .'>';
1110 1118
1111 if (isset($link['href'])) { 1119 if (isset($link['href'])) {
1112 // Pass in $link as $options, they share the same keys. 1120 // Pass in $link as $options, they share the same keys.
1113 $output .= l($link['title'], $link['href'], $link); 1121 $output .= l($link['title'], $link['href'], $link);
1114 } 1122 }
1452 return '<div class="more-help-link">'. t('[<a href="@link">more help...</a>]', array('@link' => check_url($url))) .'</div>'; 1460 return '<div class="more-help-link">'. t('[<a href="@link">more help...</a>]', array('@link' => check_url($url))) .'</div>';
1453 } 1461 }
1454 1462
1455 /** 1463 /**
1456 * Return code that emits an XML icon. 1464 * Return code that emits an XML icon.
1457 * 1465 *
1458 * For most use cases, this function has been superseded by theme_feed_icon(). 1466 * For most use cases, this function has been superseded by theme_feed_icon().
1459 * 1467 *
1460 * @see theme_feed_icon() 1468 * @see theme_feed_icon()
1461 * @param $url 1469 * @param $url
1462 * The url of the feed. 1470 * The url of the feed.
1463 */ 1471 */
1464 function theme_xml_icon($url) { 1472 function theme_xml_icon($url) {
1562 // Sometimes modules display content composed by people who are 1570 // Sometimes modules display content composed by people who are
1563 // not registered members of the site (e.g. mailing list or news 1571 // not registered members of the site (e.g. mailing list or news
1564 // aggregator modules). This clause enables modules to display 1572 // aggregator modules). This clause enables modules to display
1565 // the true author of the content. 1573 // the true author of the content.
1566 if (!empty($object->homepage)) { 1574 if (!empty($object->homepage)) {
1567 $output = l($object->name, $object->homepage, array('rel' => 'nofollow')); 1575 $output = l($object->name, $object->homepage, array('attributes' => array('rel' => 'nofollow')));
1568 } 1576 }
1569 else { 1577 else {
1570 $output = check_plain($object->name); 1578 $output = check_plain($object->name);
1571 } 1579 }
1572 1580