| 1 |
<?php |
<?php |
| 2 |
/* $Id: phptal.engine,v 1.6 2006/06/22 15:24:10 olav Exp $ */ |
// $Id$ |
| 3 |
|
|
| 4 |
/** |
/** |
| 5 |
* @file |
* @file |
| 6 |
* Handles integration of templates written in PHPTAL <http://phptal.sourceforge.net/> |
* Handles integration of templates written in PHPTAL |
| 7 |
* with the Drupal theme system. This integration has only been tested with |
* with the Drupal theme system. |
|
* the PHP5 version of PHPTAL. |
|
|
* |
|
|
* Relies on phptemplate.engine to do most of the Drupal-specific magic. |
|
| 8 |
*/ |
*/ |
| 9 |
|
|
| 10 |
// phptal implements allmost any of its magic through calls to phptemplate.engine |
// phptal implements allmost any of its magic through calls to phptemplate.engine |
| 11 |
require_once('themes/engines/phptemplate/phptemplate.engine'); |
require_once('themes/engines/phptemplate/phptemplate.engine'); |
| 12 |
|
require_once 'PHPTAL.php'; |
|
/* |
|
|
* Theme functions |
|
|
*/ |
|
|
function phptal_node_class($sticky, $zebra, $status, $teaser, $type='node') { |
|
|
$class = 'node ' . $type; |
|
|
$class .= $sticky ? '-sticky' : ''; |
|
|
$class .= $zebra == 'odd' ? ' odd' : ' even'; |
|
|
$class .= !$status ? " node-unpublished" : ''; |
|
|
$class .= $teaser ? " node-teaser" : ''; |
|
|
|
|
|
return $class; |
|
|
} |
|
|
|
|
|
function phptal_block_class($block) { |
|
|
return "region-$block->region block block-$block->module"; |
|
|
} |
|
|
|
|
|
function phptal_block_id($block) { |
|
|
return "block-$block->module-$block->delta"; |
|
|
} |
|
|
|
|
|
function phptal_permalink($node_url) { |
|
|
return sprintf('<a href="%s" title="%s">#</a>', $node_url, |
|
|
check_plain(t('Copy this link as the URL of this article'))); |
|
|
} |
|
|
|
|
|
function phptal_comment_class($new) { |
|
|
return 'comment' . ($new ? ' comment-new' : ''); |
|
|
} |
|
|
|
|
|
/* |
|
|
* The engine |
|
|
*/ |
|
| 13 |
|
|
| 14 |
function phptal_init($template) { |
function phptal_init($template) { |
| 15 |
//ini_set('include_path', realpath('themes/engines/phptal/libs') . ':' . ini_get('include_path')); |
return phptemplate_init($template); |
|
require_once('PHPTAL.php'); |
|
|
|
|
|
phptemplate_init($template); |
|
| 16 |
} |
} |
| 17 |
|
|
| 18 |
function phptal_templates($directory = 'themes') { |
function phptal_templates($directory = 'themes') { |
| 19 |
return system_listing('^page\.tal$', $directory, 'filename'); |
return drupal_system_listing('^page\.tal$', $directory, 'filename'); |
| 20 |
} |
} |
| 21 |
|
|
| 22 |
function phptal_regions() { |
function phptal_regions() { |
| 23 |
return phptemplate_regions(); |
return phptemplate_regions(); |
| 24 |
} |
} |
| 25 |
|
|
| 26 |
function _phptal_callback($hook, $variables = array(), $file = NULL) { |
function _phptal_default($hook, $variables, $suggestions) { |
| 27 |
return _phptemplate_callback($hook, $variables, $file); |
return _phptemplate_default($hook, $variables, $suggestions, $extension = '.tal'); |
|
} |
|
|
|
|
|
function _phptal_default_variables($hook, $variables) { |
|
|
return _phptemplate_default_variables($hook, $variables); |
|
| 28 |
} |
} |
| 29 |
|
|
| 30 |
function phptal_features() { |
function phptal_features() { |
| 31 |
return phptemplate_features(); |
return phptemplate_features(); |
| 32 |
} |
} |
| 33 |
|
|
| 34 |
function phptal_page($content) { |
function phptal_page($content, $show_blocks = TRUE) { |
| 35 |
return phptemplate_page($content); |
return phptemplate_page($content, $show_blocks); |
| 36 |
} |
} |
| 37 |
|
|
| 38 |
function phptal_node($node, $teaser = 0, $page = 0) { |
function phptal_node($node, $teaser = 0, $page = 0) { |
| 51 |
return phptemplate_box($title, $content, $region); |
return phptemplate_box($title, $content, $region); |
| 52 |
} |
} |
| 53 |
|
|
|
function _phptal_default($hook, $variables, $file = NULL) { |
|
|
return _phptemplate_default($hook, $variables, $file, '.tal'); |
|
|
} |
|
|
|
|
| 54 |
function _phptal_render($file, $variables) { |
function _phptal_render($file, $variables) { |
| 55 |
global $theme_engine; |
global $theme_engine; |
| 56 |
global $theme_key; |
global $theme_key; |
| 72 |
return html_entity_decode($phptal->execute()); |
return html_entity_decode($phptal->execute()); |
| 73 |
} |
} |
| 74 |
catch (Exception $e) { |
catch (Exception $e) { |
| 75 |
watchdog('error', t('%engine.engine, %file: %message.', array('%engine' => $theme_engine, '%file' => $file, '%message' => $e->getMessage()))); |
watchdog('error', t('%engine.engine, %file: %message.', array('%engine' => $theme_engine, '%file' => $file, |
| 76 |
|
'%message' => $e->getMessage()))); |
| 77 |
error_log("[phptal] $file: " . $e->getMessage()); |
error_log("[phptal] $file: " . $e->getMessage()); |
| 78 |
} |
} |
| 79 |
} |
} |
|
|
|
|
?> |
|