function phptemplate_page in Drupal 5
Same name and namespace in other branches
- 4 themes/engines/phptemplate/phptemplate.engine \phptemplate_page()
Prepare the values passed to the theme_page function to be passed into a pluggable template engine. Uses the arg() function to generate a series of page template files suggestions based on the current path. If none are found, the default page.tpl.php is used.
File
- themes/
engines/ phptemplate/ phptemplate.engine, line 152 - Handles integration of templates written in pure php with the Drupal theme system.
Code
function phptemplate_page($content, $show_blocks = TRUE) {
global $theme;
$regions = array_keys(system_region_list($theme));
$variables = array(
'regions' => array(),
);
/* Set title and breadcrumb to declared values */
if (drupal_is_front_page()) {
$mission = filter_xss_admin(theme_get_setting('mission'));
}
/* Add favicon */
if (theme_get_setting('toggle_favicon')) {
drupal_set_html_head('<link rel="shortcut icon" href="' . check_url(theme_get_setting('favicon')) . '" type="image/x-icon" />');
}
// Populate sidebars
$layout = 'none';
if ($show_blocks) {
global $sidebar_indicator;
// Load blocks early for adding header info
foreach ($regions as $region) {
// Sidebar_indicator tells the block counting code
// to count sidebars separately.
if ($region == 'left' || $region == 'right') {
$sidebar_indicator = $region;
}
else {
$sidebar_indicator = NULL;
}
$variables['regions'][$region] = theme('blocks', $region);
}
$sidebar_indicator = NULL;
$sidebar_left = $variables['regions']['left'];
if ($sidebar_left != '') {
$layout = 'left';
}
$sidebar_right = $variables['regions']['right'];
if ($sidebar_right != '') {
$layout = $layout == 'left' ? 'both' : 'right';
}
}
else {
// Add empty strings as default
foreach ($regions as $region) {
$variables['regions'][$region] = '';
}
}
// Construct page title
if (drupal_get_title()) {
$head_title = array(
strip_tags(drupal_get_title()),
variable_get('site_name', 'Drupal'),
);
}
else {
$head_title = array(
variable_get('site_name', 'Drupal'),
);
if (variable_get('site_slogan', '')) {
$head_title[] = variable_get('site_slogan', '');
}
}
$variables = array_merge($variables, array(
'base_path' => base_path(),
'breadcrumb' => theme('breadcrumb', drupal_get_breadcrumb()),
'closure' => theme('closure'),
'content' => $content,
'feed_icons' => drupal_get_feeds(),
'footer_message' => filter_xss_admin(variable_get('site_footer', FALSE)) . "\n" . $variables['regions']['footer'],
'head' => drupal_get_html_head(),
'head_title' => implode(' | ', $head_title),
'help' => theme('help'),
'language' => $GLOBALS['locale'],
'layout' => $layout,
'logo' => theme_get_setting('logo'),
'messages' => theme('status_messages'),
'mission' => isset($mission) ? $mission : '',
'primary_links' => menu_primary_links(),
'search_box' => theme_get_setting('toggle_search') ? drupal_get_form('search_theme_form') : '',
'secondary_links' => menu_secondary_links(),
'sidebar_left' => $sidebar_left,
'sidebar_right' => $sidebar_right,
'site_name' => theme_get_setting('toggle_name') ? variable_get('site_name', 'Drupal') : '',
'site_slogan' => theme_get_setting('toggle_slogan') ? variable_get('site_slogan', '') : '',
'css' => drupal_add_css(),
'styles' => drupal_get_css(),
'scripts' => drupal_get_js(),
'tabs' => theme('menu_local_tasks'),
'title' => drupal_get_title(),
));
if (arg(0) == 'node' && is_numeric(arg(1))) {
$variables['node'] = node_load(arg(1));
}
// Build a list of suggested template files in order of specificity. One
// suggestion is made for every element of the current path, though
// numeric elements are not carried to subsequent suggestions. For example,
// http://www.example.com/node/1/edit would result in the following
// suggestions:
//
// page-node-edit.tpl.php
// page-node-1.tpl.php
// page-node.tpl.php
// page.tpl.php
$i = 0;
$suggestion = 'page';
$suggestions = array(
$suggestion,
);
while ($arg = arg($i++)) {
$arg = str_replace(array(
"/",
"\\",
"\0",
), '', $arg);
$suggestions[] = $suggestion . '-' . $arg;
if (!is_numeric($arg)) {
$suggestion .= '-' . $arg;
}
}
if (drupal_is_front_page()) {
$suggestions[] = 'page-front';
}
return _phptemplate_callback('page', $variables, $suggestions);
}