drupal/core/themes/engines/phptemplate/phptemplate.engine

58 lines
1.3 KiB
Plaintext

<?php
/**
* @file
* Handles integration of PHP templates with the Drupal theme system.
*/
/**
* Implements hook_init().
*/
function phptemplate_init($template) {
$file = dirname($template->filename) . '/' . $template->name . '.theme';
if (file_exists($file)) {
include_once DRUPAL_ROOT . '/' . $file;
}
}
/**
* Implements hook_theme().
*/
function phptemplate_theme($existing, $type, $theme, $path) {
$templates = drupal_find_theme_functions($existing, array($theme));
$templates += drupal_find_theme_templates($existing, '.tpl.php', $path);
return $templates;
}
/**
* Implements hook_extension().
*/
function phptemplate_extension() {
return '.tpl.php';
}
/**
* Renders a system default template, which is essentially a PHP template.
*
* @param $template_file
* The filename of the template to render.
* @param $variables
* A keyed array of variables that will appear in the output.
*
* @return
* The output generated by the template.
*/
function phptemplate_render_template($template_file, $variables) {
// Extract the variables to a local namespace
extract($variables, EXTR_SKIP);
// Start output buffering
ob_start();
// Include the template file
include DRUPAL_ROOT . '/' . $template_file;
// End buffering and return its contents
return ob_get_clean();
}