_phptemplate_default_variables

Хочешь помочь с переводом? Это очень просто и быстро. Лишь зарегистрируйся, и можешь тут же начать переводить.

themes/engines/phptemplate/phptemplate.engine, строка 94

Версии
5
_phptemplate_default_variables($hook, $variables)

Adds additional helper variables to all templates.

Counts how many times certain hooks have been called. Sidebar left / right are special cases.

Параметры

$hook Название используемой функции темизации.

$variables Последовательный массив переменных, которые передаются в функцию темизации.

Код

<?php
function _phptemplate_default_variables($hook, $variables) {
  global $theme, $sidebar_indicator;
  static $count = array();

  $count[$hook] = isset($count[$hook]) && is_int($count[$hook]) ? $count[$hook] : 1;
  $variables['zebra'] = ($count[$hook] % 2) ? 'odd' : 'even';
  $variables['id'] = $count[$hook]++;

  if ($hook == 'block') {
    $count['block_counter'][$sidebar_indicator] = isset($count['block_counter'][$sidebar_indicator]) && is_int($count['block_counter'][$sidebar_indicator]) ? $count['block_counter'][$sidebar_indicator] : 1;
    $variables['block_zebra'] = ($count['block_counter'][$sidebar_indicator] % 2) ? 'odd' : 'even';
    $variables['block_id'] = $count['block_counter'][$sidebar_indicator]++;
  }
  elseif ($hook == 'page') {
    $regions = system_region_list($theme);
    // Load all region content assigned via blocks.
    foreach (array_keys($regions) as $region) {
      // Skip blocks in this region that have already been loaded.
      // This pre-loading is necessary because phptemplate uses variable names different from
      // the region names, e.g., 'sidebar_left' instead of 'left'.
      if (!in_array($region, array('left', 'right', 'footer'))) {
        $normal_blocks = (isset($variables['regions'])) ? $variables['regions'][$region] : theme('blocks', $region);

        isset($variables[$region]) ? $variables[$region] .= $normal_blocks : $variables[$region] = $normal_blocks;
      }
    }
  }
  // Tell all templates where they are located.
  $variables['directory'] = path_to_theme();
  $variables['is_front'] = drupal_is_front_page();

  return $variables;
}
?>
Войдите или зарегистрируйтесь, чтобы получить возможность отправлять комментарии

Вход в систему