Commit e274f97c authored by Dries's avatar Dries
Browse files

- Removed the Xtemplate engine and added the PHPTemplate engine.

- Converted the Bluemarine theme from XTemplate to PHPTemplate.
- Moved the the Pushbutton theme and the Xtemplate engine to the contributions repository.
parent 00212935
......@@ -3,6 +3,10 @@ Drupal x.x.x, xxxx-xx-xx (Development version)
- added free tagging support (folksonomies).
- added a site-wide contact form.
- theme system:
* removed the Xtemplate theme engine.
* added the PHPTemplate theme engine.
* converted the bluemarine theme from XTemplate to PHPTemplate.
- reworked the 'request new password' functionality.
- profiles:
* added a block to display author information along with posts.
......
......@@ -2407,6 +2407,24 @@ function update_132() {
return $ret;
}
function update_130() {
$ret = array();
if ($GLOBALS['db_type'] == 'mysql') {
$ret[] = update_sql("ALTER TABLE {locales_source} CHANGE location location varchar(255) NOT NULL default ''");
}
elseif ($GLOBALS['db_type'] == 'pgsql') {
$ret[] = update_sql("ALTER TABLE {locales_source} RENAME location TO location_old");
$ret[] = update_sql("ALTER TABLE {locales_source} ADD location varchar(255)");
$ret[] = update_sql("ALTER TABLE {locales_source} ALTER location SET NOT NULL");
$ret[] = update_sql("ALTER TABLE {locales_source} ALTER location SET DEFAULT ''");
$ret[] = update_sql("UPDATE {locales_source} SET location = location_old");
$ret[] = update_sql("ALTER TABLE {locales_source} DROP location_old");
}
return $ret;
}
function update_133() {
$ret[] = update_sql("CREATE TABLE {contact} (
subject varchar(255) NOT NULL default '',
......
......@@ -211,8 +211,8 @@ function path_to_theme() {
*/
function theme_get_settings($key = NULL) {
$defaults = array(
'primary_links' => l(t('edit primary links'), 'admin/themes/settings'),
'secondary_links' => l(t('edit secondary links'), 'admin/themes/settings'),
'primary_links' => array(),
'secondary_links' => array(),
'mission' => '',
'default_logo' => 1,
'logo_path' => '',
......
......@@ -652,9 +652,44 @@ function system_theme_settings($key = '') {
// System wide only settings.
if (!$key) {
// Menu settings
$group = form_textarea(t('Primary links'), "$var][primary_links", $settings['primary_links'], 70, 8, t('The HTML code for the primary links.'));
$group .= form_textarea(t('Secondary links'), "$var][secondary_links", $settings['secondary_links'], 70, 8, t('The HTML code for the secondary links.'));
$form .= form_group(t('Menu Settings'), $group, t('Customize the menus that are displayed at the top and/or bottom of the page. This configuration screen is only available in the site wide display configuration.'));
$header = array(t('link text'), t('url'), t('description'));
foreach (array('Primary', 'Secondary') as $utype) {
$group = '';
$rows = array();
//Use $utype field , and strtolower() it to get the type field.. to avoid issues with ucfirst() and unicode.
$type = strtolower($utype);
$value = theme_get_setting($type . '_links');
if (!is_array($value)) {
$value = array();
}
//Increment the link count, if the user has requested more links.
if (variable_get($type . '_links_more', false)) {
variable_del($type . '_links_more');
variable_set($type . '_link_count', variable_get($type . '_link_count', 5) + 5);
}
//Get the amount of links to show, possibly expanding if there are more links defined than the count specifies.
$count = variable_get($type . '_link_count', 5);
$count = ($count > sizeof($value['link'])) ? $count : sizeof($value['link']);
if (variable_get($type . '_link_count', 5) != $count) {
variable_set($type . '_link_count', $count);
}
for ($i = 0; $i < $count; $i++) {
$row = array();
foreach (array('text', 'link', 'description') as $field) {
$row[] = form_textfield('', $var . '][' . $type . '_links][' . $field . '][' . $i, $value[$field][$i], 15, 90);
}
$rows[] = $row;
}
$group .= form_item('', theme("table", $header, $rows), t('You can specify your _TYPE_ links here, one link per line.<br /> The link text field is the text you want to link.<br /> The url field is the location the link points to.<br /> The description field is an optional description of where the link points.', array('_TYPE_' => $type)));
$group .= form_checkbox(t('I need more _TYPE_ links.', array('_TYPE_' => $type)), $type . '_links_more', 1, FALSE, t('Checking this box will give you 5 additional _TYPE_ links.', array('_TYPE_' => $type)));
$form .= form_group(t('_TYPE_ link settings', array('_TYPE_' => $utype)), $group);
}
// Toggle node display.
$group = '';
......
......@@ -652,9 +652,44 @@ function system_theme_settings($key = '') {
// System wide only settings.
if (!$key) {
// Menu settings
$group = form_textarea(t('Primary links'), "$var][primary_links", $settings['primary_links'], 70, 8, t('The HTML code for the primary links.'));
$group .= form_textarea(t('Secondary links'), "$var][secondary_links", $settings['secondary_links'], 70, 8, t('The HTML code for the secondary links.'));
$form .= form_group(t('Menu Settings'), $group, t('Customize the menus that are displayed at the top and/or bottom of the page. This configuration screen is only available in the site wide display configuration.'));
$header = array(t('link text'), t('url'), t('description'));
foreach (array('Primary', 'Secondary') as $utype) {
$group = '';
$rows = array();
//Use $utype field , and strtolower() it to get the type field.. to avoid issues with ucfirst() and unicode.
$type = strtolower($utype);
$value = theme_get_setting($type . '_links');
if (!is_array($value)) {
$value = array();
}
//Increment the link count, if the user has requested more links.
if (variable_get($type . '_links_more', false)) {
variable_del($type . '_links_more');
variable_set($type . '_link_count', variable_get($type . '_link_count', 5) + 5);
}
//Get the amount of links to show, possibly expanding if there are more links defined than the count specifies.
$count = variable_get($type . '_link_count', 5);
$count = ($count > sizeof($value['link'])) ? $count : sizeof($value['link']);
if (variable_get($type . '_link_count', 5) != $count) {
variable_set($type . '_link_count', $count);
}
for ($i = 0; $i < $count; $i++) {
$row = array();
foreach (array('text', 'link', 'description') as $field) {
$row[] = form_textfield('', $var . '][' . $type . '_links][' . $field . '][' . $i, $value[$field][$i], 15, 90);
}
$rows[] = $row;
}
$group .= form_item('', theme("table", $header, $rows), t('You can specify your _TYPE_ links here, one link per line.<br /> The link text field is the text you want to link.<br /> The url field is the location the link points to.<br /> The description field is an optional description of where the link points.', array('_TYPE_' => $type)));
$group .= form_checkbox(t('I need more _TYPE_ links.', array('_TYPE_' => $type)), $type . '_links_more', 1, FALSE, t('Checking this box will give you 5 additional _TYPE_ links.', array('_TYPE_' => $type)));
$form .= form_group(t('_TYPE_ link settings', array('_TYPE_' => $utype)), $group);
}
// Toggle node display.
$group = '';
......
<div class="block block-<?php print $block->module; ?>" id="block-<?php print $block->module; ?>-<?php print $block->delta; ?>">
<h2 class="title"><?php print $block->title; ?></h2>
<div class="content"><?php print $block->content; ?></div>
</div>
<div class="box">
<h2 class="title"><?php print $title; ?></h2>
<div class="content"><?php print $content; ?></div>
</div>
<div class="comment">
<?php if ($picture) {
print $picture;
} ?>
<h3 class="title"><?php print $title; ?></h3><?php if ($new != '') { ?><span class="new"><?php print $new; ?></span><?php } ?>
<div class="submitted"><?php print $submitted; ?></div>
<div class="content"><?php print $content; ?></div>
<div class="links">&raquo; <?php print $links; ?></div>
</div>
<div class="node<?php if ($sticky) { print " sticky"; } ?>">
<?php if ($picture) {
print $picture;
}?>
<h2 class="title"><a href="<?php print $node_url?>"><?php print $title?></a></h2>
<span class="submitted"><?php print $submitted?></span>
<span class="taxonomy"><?php print $terms?></span>
<div class="content"><?php print $content?></div>
<div class="links">&raquo; <?php print $links?></div>
</div>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><?php global $theme ?>
<html xmlns="http://www.w3.org/1999/xhtml" lang="<?php print $language ?>" xml:lang="<?php print $language ?>">
<head>
<title><?php print $head_title ?></title>
<?php print $head ?>
<?php print $styles ?>
<script type="text/javascript"> </script>
</head>
<body<?php print $onload_attributes ?>>
<table border="0" cellpadding="0" cellspacing="0" id="header">
<tr>
<td id="logo">
<a href="./" title="Home"><img src="<?php print $logo ?>" alt="Home" border="0" /></a>
<h1 class='site-name'><a href="./" title="Home"><?php print $site_name ?></a></h1>
<div class='site-slogan'><?php print $site_slogan ?></div>
</td>
<td id="menu">
<div id="secondary"><?php print (is_array($secondary_links) && count($secondary_links) > 0) ? theme('links', $secondary_links) : l(t('edit secondary links'),'admin/themes/settings') ?></div>
<div id="primary"><?php print (is_array($primary_links) && count($primary_links) > 0) ? theme('links', $primary_links) : l(t('edit primary links'), 'admin/themes/settings') ?></div>
<?php if ($search_box) { ?><form action="<?php print $search_url ?>" method="post">
<div id="search">
<input class="form-text" type="text" size="15" value="" name="keys" alt="<?php print $search_description ?>" />
<input class="form-submit" type="submit" value="<?php print $search_button_text ?>" />
</div>
</form><?php } ?>
</td>
</tr>
</table>
<table border="0" cellpadding="0" cellspacing="0" id="content">
<tr>
<?php if ($sidebar_left) { ?><td id="sidebar-left">
<?php print $sidebar_left ?>
</td><?php } ?>
<td valign="top">
<?php if ($mission) { ?><div id="mission"><?php print $mission ?></div><?php } ?>
<div id="main">
<?php print $breadcrumb ?>
<h1 class="title"><?php print $title ?></h1>
<div class="tabs"><?php print $tabs ?></div>
<div id="help"><?php print $help ?></div>
<?php print $messages ?>
<?php print $content; ?>
</div>
</td>
<?php if ($sidebar_right) { ?><td id="sidebar-right">
<?php print $sidebar_right ?>
</td><?php } ?>
</tr>
</table>
<div id="footer">
<?php print $footer_message ?>
</div>
<?php print $closure ?>
</body>
</html>
......@@ -14,7 +14,7 @@ tr.dark td, tr.light td {
padding: 0.3em;
}
h1, h2, h3, h4, h5, h6 {
margin-bottom: 0.5em;
margin: 0.5;
}
h1 {
font-size: 1.3em;
......@@ -25,10 +25,6 @@ h2 {
h3, h4, h5, h6 {
font-size: 1.1em;
}
p {
margin-top: 0.5em;
margin-bottom: 0.9em;
}
a {
text-decoration: none;
font-weight: bold;
......@@ -87,7 +83,6 @@ table {
#logo img {
float: left;
padding: 0em 1.0em 0em 1em;
border: 0;
}
#menu {
padding: 0.5em 0.5em 0 0.5em;
......
<div class="<?php print "block block-$block->module" ?>" id="<?php print "block-$block->module-$block->delta"; ?>">
<h2><?php print $block->subject ?></h2>
<div class="content"><?php print $block->content ?></div>
</div>
<div class="box">
<h2><?php print $title ?></h2>
<div class="content"><?php print $content ?></div>
</div>
<div class="comment <?php print ($comment->new) ? 'comment-new' : '' ?>">
<?php if ($comment->new) : ?>
<a id="new"></a>
<span class="new"><?php print $new ?></span>
<?php endif; ?>
<div class="title"><?php print $title ?></div>
<?php print $picture ?>
<div class="author"><?php print $submitted ?></div>
<div class="content"><?php print $content ?></div>
<?php if ($picture) : ?>
<br class="clear" />
<?php endif; ?>
<div class="links"><?php print $links ?></div>
</div>
<!-- PHPTemplate was instructed to override the <?php print $hook ?> theme function, but no valid template file was found. -->
<div class="node<?php print ($sticky) ? " sticky" : ""; ?>">
<?php if ($page == 0): ?>
<h2><a href="<?php print $node_url ?>" title="<?php print $title ?>"><?php print $title ?></a></h2>
<?php endif; ?>
<?php print $picture ?>
<div class="info"><?php print $submitted ?><span class="terms"><?php print $terms ?></span></div>
<div class="content">
<?php print $content ?>
</div>
<?php if ($links): ?>
<?php if ($picture): ?>
<br class='clear' />
<?php endif; ?>
<div class="links"><?php print $links ?></div>
<?php endif; ?>
</div>
<?php
// $Id$
/**
* @file
* Handles integration of templates written in pure php with the Drupal theme system.
*/
function phptemplate_init($template) {
$file = dirname($template->filename) . '/template.php';
if (file_exists($file)) {
include_once($file);
}
}
function phptemplate_templates($directory = 'themes') {
return system_listing('^page\.tpl\.php$', $directory, 'filename');
}
/**
* Execute a template engine call.
*
* Each call to the template engine has two parts. Namely preparing
* the variables, and then doing something with them.
*
* The first step is done by all template engines / themes, the second
* step is dependent on the engine used.
*
* @param $hook
* The name of the theme function being executed.
* @param $variables
* A sequential array of variables passed to the theme function.
* @param $file
* A suggested template file to use. If the file is not found, the default $hook.tpl.php will be used.
* @return
* The HTML generated by the template system.
*/
function _phptemplate_callback($hook, $variables = array(), $file = null) {
$variables = array_merge($variables, _phptemplate_default_variables($hook, $variables));
// Allow specified variables to be overridden
if (function_exists('_phptemplate_variables')) {
$variables = array_merge($variables, _phptemplate_variables($hook, $variables));
}
if ($variables['template_file']) {
$file = $variables['template_file'];
}
if (function_exists('_phptemplate_' . $hook)) {
return call_user_func('_phptemplate_' . $hook, $variables, $file);
}
elseif (function_exists('_phptemplate_default')) {
return call_user_func('_phptemplate_default', $hook, $variables, $file);
}
}
/**
* Adds additional helper variables to all templates.
*
* Counts how many times certain hooks have been called. Sidebar left / right are special cases.
*
* @param $hook
* The name of the theme function being executed.
* @param $variables
* A sequential array of variables passed to the theme function.
*/
function _phptemplate_default_variables($hook, $variables) {
static $count = array();
$count[$hook] = is_int($count[$hook]) ? $count[$hook] : 1;
$variables['zebra'] = ($count[$hook] % 2) ? 'odd' : 'even';
$variables['id'] = $count[$hook]++;
global $sidebar_indicator;
if ($hook == 'block') {
$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]++;
}
// Tell all templates where they are located.
$variables['directory'] = path_to_theme();
if (drupal_get_path_alias($_GET['q']) == variable_get('site_frontpage', 'node')) {
$variables['is_front'] = true;
}
return $variables;
}
function phptemplate_features() {
return array(
'logo',
'toggle_name',
'toggle_search',
'toggle_slogan',
'toggle_mission',
'toggle_primary_links',
'toggle_secondary_links',
'toggle_node_user_picture',
'toggle_comment_user_picture');
}
/**
* Prepare the values passed to the theme_page function to be passed
* into a pluggable template engine.
*/
function phptemplate_page($content) {
/* Set title and breadcrumb to declared values */
if (file_exists(path_to_theme() . '/favicon.ico')) {
drupal_set_html_head("<link rel=\"shortcut icon\" href=\"" . path_to_theme() . "/favicon.ico\" />\n");
}
if ($_GET['q'] == variable_get('site_frontpage', 'node')) {
$mission = theme_get_setting('mission');
$frontpage = true;
}
$links['primary'] = array();
$links['secondary'] = array();
foreach (array('primary', 'secondary') as $type) {
//Get the data to populate the textfields, if the variable is not an array .. try to parse the old-style link format.
$value = theme_get_setting($type . '_links');
//Get the amount of links to show, possibly expanding if there are more links defined than the count specifies.
$count = variable_get($type . '_link_count', 5);
$count = ($count > sizeof($value['link'])) ? $count : sizeof($value['link']);
if (theme_get_setting('toggle_' . $type . '_links')) {
for ($i =0; $i < $count; $i++) {
unset($attributes);
if (!empty($value['text'][$i])) {
if (!empty($value['description'][$i])) {
$attributes['title'] = $value['description'][$i];
}
$text = $value['text'][$i];
$link = $value['link'][$i];
if (substr($link, 0, 4) == 'http') {
$links[$type][] = '<a href="'. $link .'"'. drupal_attributes($attributes) .'>'. $text .'</a>';
}
else {
$links[$type][] = l($text, $link, $attributes);
}
}
}
}
}
/**
* Populate sidebars.
*/
$layout = "none";
global $sidebar_indicator;
/**
* Sidebar_indicator tells the block counting code to count sidebars seperately.
*/
$sidebar_indicator = 'left';
$sidebar_left = theme("blocks", "left");
if ($sidebar_left != "") {
$layout = "left";
}
$sidebar_indicator = 'right';
$sidebar_right = theme("blocks", "right");
if ($sidebar_right != "") {
$layout = ($layout == "left") ? "both" : "right";
}
$sidebar_indicator = null;
$variables = array(
'head_title' => (drupal_get_title() ? strip_tags(drupal_get_title()) .' | '. variable_get('site_name', 'drupal') : variable_get('site_name', 'drupal') .' | '. variable_get('site_slogan', '')),
'language' => $GLOBALS['locale'],
'site' => variable_get('site_name', 'drupal'),
'head' => drupal_get_html_head(),
'onload_attributes' => theme('onload_attribute'),
'logo' => theme_get_setting('logo'),
'site_name' => (theme_get_setting('toggle_name') ? variable_get('site_name', 'Drupal') : ''),
'site_slogan' => (theme_get_setting('toggle_slogan') ? variable_get('site_slogan', '') : ''),
'search_box' => theme_get_setting('toggle_search'),
'search_url' => url('search'),
'search_button_text' => t('search'),
'search_description' => t('Enter the terms you wish to search for.'),
'title' => drupal_get_title(),
'primary_links' => $links['primary'],
'secondary_links' => $links['secondary'],
'breadcrumb' => theme('breadcrumb', drupal_get_breadcrumb()),
'tabs' => theme('menu_local_tasks'),
'messages' => theme('status_messages'),
'layout' => $layout,
'help' => theme('help'),
'styles' => theme_get_styles(),
'mission' => $mission,
'sidebar_left' => $sidebar_left,
'content' => '<!-- begin content -->' . $content . '<!-- end content -->',
'sidebar_right' => $sidebar_right,
'footer_message' => variable_get('site_footer', FALSE),
'closure' => theme('closure')
);
if ((arg(0) == 'node') && is_int(arg(1))) {
$variables['node'] = node_load(array('nid' => arg(1)));
}
return _phptemplate_callback('page', $variables);
}
/**
* Prepare the values passed to the theme_node function to be passed
* into a pluggable template engine.
*/
function phptemplate_node($node, $main = 0, $page = 0) {
if (module_exist('taxonomy')) {
$taxonomy = taxonomy_link('taxonomy terms', $node);
}
else {
$taxonomy = array();
}
$variables = array(
'title' => check_plain($node->title),
'node_url' => url('node/' . $node->nid),
'terms' => theme('links',$taxonomy),
'name' => format_name($node),
'date' => format_date($node->created),
'sticky' => $node->sticky,
'picture' => theme_get_setting('toggle_node_user_picture') ? theme('user_picture', $node) : '',
'content' => ($main && $node->teaser) ? $node->teaser : $node->body,
'links' => $node->links ? theme('links', $node->links) : '',
'mission' => $mission,
'page' => $page,
'taxonomy' => $taxonomy,
/* Lastly , pass the actual node to allow more customization */
'node' => $node,
'main' => $main,
'page' => $page
);
// Display info only on certain node types.
if (theme_get_setting('toggle_node_info_' . $node->type)) {
$variables['submitted'] = t('Submitted by %a on %b.', array('%a' => format_name($node), '%b' => format_date($node->created)));
}
return _phptemplate_callback('node', $variables, 'node-' . $node->type);
}
/**
* Prepare the values passed to the theme_comment function to be passed
* into a pluggable template engine.
*/
function phptemplate_comment($comment, $links = 0) {
return _phptemplate_callback('comment', array(
'new' => $comment->new ? t('new') : '',
'comment' => $comment,
'submitted' => t('Submitted by %a on %b.',
array('%a' => format_name($comment),
'%b' => format_date($comment->timestamp))),
'title' => l($comment->subject, $_GET['q'], NULL, NULL, "comment-$comment->cid"),