D.I.Y. kit テーマ のすべてのリリースファイルのソースコード
template.php 5.x-1.x head
<?php
/**
* ==============================
* D.I.Y. kit template.php v.1.3
* ------------------------------
* (c) 2008 DRUPAL*DRUPAL
* ==============================
*/
/**
* ------------------------------
* ブロック表示領域の定義
* ------------------------------
* 関数名は function テーマ名_regions()
* ** 関数命名規則
* ** 1) まず文字かアンダースコア(_)で始まる
* ** 2) その後に任意の数の文字・数字・アンダースコアが続く
* ------------------------------
*/
function diykit_regions() {
return array(
'left' => t('left sidebar'),
'right' => t('right sidebar'),
'content' => t('content'),
'header' => t('header'),
'footer' => t('footer'),
'before_content' => t('before content'),
'after_content' => t('after content'),
'left_content' => t('left content'),
'right_content' => t('right content'),
);
}
/**
* ------------------------------
* 既存のテーマ関数の設定を上書き
* ------------------------------
* ** ファイルの読み込み優先順位
* ** 1) template.php
* ** 2) phptemplate.engine
* ** 3) theme.inc
* ------------------------------
* ** 関数の読み込み優先順位
* ** 1) テーマ名_function()
* ** 2) phptemplate_function()
* ** 3) theme_function()
* ------------------------------
*/
/**
* パンくずリスト
*/
function phptemplate_breadcrumb($breadcrumb) {
if ($breadcrumb) {
return '<div class="breadcrumb">'. implode(' <span class="breadcrumb-separate">»</span> ', $breadcrumb) . '</div>';
}
}
/**
* フィードアイコン
*/
function phptemplate_feed_icon($url) {
$path = path_to_theme() . '/images/feed.png';
if (!is_file($path)) {
$path = 'misc/feed.png';
}
if ($image = theme('image', $path, t('Syndicate content'), t('Syndicate content'))) {
return '<a href="'. check_url($url) .'" class="feed-icon">'. $image. '</a>';
}
}
/**
* マーカー
*/
function phptemplate_mark($type = MARK_NEW) {
global $user;
if ($user->uid) {
if ($type == MARK_NEW) {
return ' <span class="marker marker-new">'. t('new') .'</span>';
}
else if ($type == MARK_UPDATED) {
return ' <span class="marker marker-update">'. t('updated') .'</span>';
}
}
}
/**
* ------------------------------
* 新しいテーマ変数を定義
* ------------------------------
* ** page.tpl.php
* ** 1) $xml(ブラウザ判定と XML 宣言)
* ** 2) $body_id_class(body タグに id と class を設定)
* ** フロントページの場合 -> front : そうでない場合 -> page
* ** ログインユーザの場合 -> logged-in : そうでない場合 -> not-logged-in
* ** サイドバーの有無を判定 -> none/left/right/both
* ** 3) $head_page_title(ページタイトルまたはスローガンを表示)
* ** 4) $site_footer, $footer(サイトフッタの内容とフッタ領域の内容を分離)
* ------------------------------
* ** node.tpl.php
* ** 1) $node_id_class(div タグに id と class を設定)
* ** ティーザーリストページの場合 -> list
* ** 前面固定の場合 -> sticky
* ** 未公開の場合 -> node-unpublished
* ** コンテンツタイプ別 -> type-[$node->type]
* ** ゼブラ(奇数または偶数)判定 -> odd/even
* ** 2) $changed_date(更新日時を表示)
* ------------------------------
* ** comment.tpl.php
* ** 1) $comment_class(div タグに class を設定)
* ** 新しいコメントの場合 -> comment-new
* ** 未公開の場合 -> comment-unpublished
* ** ゼブラ(奇数または偶数)判定 -> odd/even
* ------------------------------
* ** block.tpl.php
* ** 1) $block_id_class(div タグに id と class を設定)
* ** モジュール名を付加 -> block-[$block->module]
* ** ゼブラ(奇数または偶数)判定 -> odd/even
* ** サイドバーブロックのゼブラ(奇数または偶数)判定 -> left-odd/left-even, right-odd/right-even
* ------------------------------
*/
function _phptemplate_variables($hook, $vars) {
switch($hook) {
case 'page':
// $xml
$user_agent = getenv('HTTP_USER_AGENT');
if (!(strpos($user_agent, 'Windows') !== FALSE && strpos($user_agent, 'MSIE') !== FALSE) || strpos($user_agent, 'MSIE 7') !== FALSE) {
$vars['xml'] = '<?xml version="1.0" encoding="utf-8"?>' . "\n";
}
// $body_id_class
if ($vars['is_front']) {
$body_id = 'front';
}
else {
$body_id = 'page';
}
global $user;
if ($user->uid > 0) {
$loged_in = ' logged-in';
}
else {
$loged_in = ' not-logged-in';
}
$vars['body_id_class'] = ' id="' . $body_id . '" class="' . $vars['layout'] . $loged_in . '"';
// $head_page_title
if (drupal_get_title()) {
$title = strip_tags(drupal_get_title());
}
else if (variable_get('site_slogan', '')) {
$title = variable_get('site_slogan', '');
}
$vars['head_page_title'] = $title;
// $site_footer, $footer
$vars['site_footer'] = filter_xss_admin(variable_get('site_footer', FALSE));
$vars['footer'] = theme('blocks', 'footer');
break;
case 'node':
// $node_id_class
$node_id = 'node-' . $vars['node']->nid;
$node_class = array('node');
if ($vars['page'] == 0) {
$node_class[] = 'list';
}
if ($vars['sticky']) {
$node_class[] = 'sticky';
}
if (!$vars['node']->status) {
$node_class[] = 'node-unpublished';
}
if ($vars['node']->type) {
$node_class[] = 'type-' . $vars['node']->type;
}
if ($vars['page'] == 0) {
$node_class[] = $vars['zebra'];
}
$vars['node_id_class'] = ' id="' . $node_id . '" class="' . implode(' ', $node_class) . '"';
// $changed_date
$vars['changed_date'] = format_date($vars['node']->changed);
break;
case 'comment':
// $comment_class
$comment_class = array('comment');
if ($vars['comment']->new) {
$comment_class[] = 'comment-new';
}
if ($vars['comment']->status == COMMENT_NOT_PUBLISHED) {
$comment_class[] = 'comment-unpublished';
}
$comment_class[] = $vars['zebra'];
$vars['comment_class'] = ' class="' . implode(' ', $comment_class) . '"';
break;
case 'block':
// $block_id_class
$block_id = 'block-' . $vars['block']->module . '-' . $vars['block']->delta;
$block_class = array('block');
$block_class[] = 'block-' . $vars['block']->module;
$block_class[] = $vars['zebra'];
if ($vars['block']->region == 'left') {
$block_class[] = 'left-' . $vars['block_zebra'];
}
else if ($vars['block']->region == 'right') {
$block_class[] = 'right-' . $vars['block_zebra'];
}
$vars['block_id_class'] = ' id="' .$block_id . '" class="' . implode(' ', $block_class) . '"';
break;
}
return $vars;
}
/**
* ==============================
* D.I.Y. kit template.php v.1.3
* ------------------------------
* (c) 2008 DRUPAL*DRUPAL
* ==============================
*/
/**
* ------------------------------
* ブロック表示領域の定義
* ------------------------------
* 関数名は function テーマ名_regions()
* ** 関数命名規則
* ** 1) まず文字かアンダースコア(_)で始まる
* ** 2) その後に任意の数の文字・数字・アンダースコアが続く
* ------------------------------
*/
function diykit_regions() {
return array(
'left' => t('left sidebar'),
'right' => t('right sidebar'),
'content' => t('content'),
'header' => t('header'),
'footer' => t('footer'),
'before_content' => t('before content'),
'after_content' => t('after content'),
'left_content' => t('left content'),
'right_content' => t('right content'),
);
}
/**
* ------------------------------
* 既存のテーマ関数の設定を上書き
* ------------------------------
* ** ファイルの読み込み優先順位
* ** 1) template.php
* ** 2) phptemplate.engine
* ** 3) theme.inc
* ------------------------------
* ** 関数の読み込み優先順位
* ** 1) テーマ名_function()
* ** 2) phptemplate_function()
* ** 3) theme_function()
* ------------------------------
*/
/**
* パンくずリスト
*/
function phptemplate_breadcrumb($breadcrumb) {
if ($breadcrumb) {
return '<div class="breadcrumb">'. implode(' <span class="breadcrumb-separate">»</span> ', $breadcrumb) . '</div>';
}
}
/**
* フィードアイコン
*/
function phptemplate_feed_icon($url) {
$path = path_to_theme() . '/images/feed.png';
if (!is_file($path)) {
$path = 'misc/feed.png';
}
if ($image = theme('image', $path, t('Syndicate content'), t('Syndicate content'))) {
return '<a href="'. check_url($url) .'" class="feed-icon">'. $image. '</a>';
}
}
/**
* マーカー
*/
function phptemplate_mark($type = MARK_NEW) {
global $user;
if ($user->uid) {
if ($type == MARK_NEW) {
return ' <span class="marker marker-new">'. t('new') .'</span>';
}
else if ($type == MARK_UPDATED) {
return ' <span class="marker marker-update">'. t('updated') .'</span>';
}
}
}
/**
* ------------------------------
* 新しいテーマ変数を定義
* ------------------------------
* ** page.tpl.php
* ** 1) $xml(ブラウザ判定と XML 宣言)
* ** 2) $body_id_class(body タグに id と class を設定)
* ** フロントページの場合 -> front : そうでない場合 -> page
* ** ログインユーザの場合 -> logged-in : そうでない場合 -> not-logged-in
* ** サイドバーの有無を判定 -> none/left/right/both
* ** 3) $head_page_title(ページタイトルまたはスローガンを表示)
* ** 4) $site_footer, $footer(サイトフッタの内容とフッタ領域の内容を分離)
* ------------------------------
* ** node.tpl.php
* ** 1) $node_id_class(div タグに id と class を設定)
* ** ティーザーリストページの場合 -> list
* ** 前面固定の場合 -> sticky
* ** 未公開の場合 -> node-unpublished
* ** コンテンツタイプ別 -> type-[$node->type]
* ** ゼブラ(奇数または偶数)判定 -> odd/even
* ** 2) $changed_date(更新日時を表示)
* ------------------------------
* ** comment.tpl.php
* ** 1) $comment_class(div タグに class を設定)
* ** 新しいコメントの場合 -> comment-new
* ** 未公開の場合 -> comment-unpublished
* ** ゼブラ(奇数または偶数)判定 -> odd/even
* ------------------------------
* ** block.tpl.php
* ** 1) $block_id_class(div タグに id と class を設定)
* ** モジュール名を付加 -> block-[$block->module]
* ** ゼブラ(奇数または偶数)判定 -> odd/even
* ** サイドバーブロックのゼブラ(奇数または偶数)判定 -> left-odd/left-even, right-odd/right-even
* ------------------------------
*/
function _phptemplate_variables($hook, $vars) {
switch($hook) {
case 'page':
// $xml
$user_agent = getenv('HTTP_USER_AGENT');
if (!(strpos($user_agent, 'Windows') !== FALSE && strpos($user_agent, 'MSIE') !== FALSE) || strpos($user_agent, 'MSIE 7') !== FALSE) {
$vars['xml'] = '<?xml version="1.0" encoding="utf-8"?>' . "\n";
}
// $body_id_class
if ($vars['is_front']) {
$body_id = 'front';
}
else {
$body_id = 'page';
}
global $user;
if ($user->uid > 0) {
$loged_in = ' logged-in';
}
else {
$loged_in = ' not-logged-in';
}
$vars['body_id_class'] = ' id="' . $body_id . '" class="' . $vars['layout'] . $loged_in . '"';
// $head_page_title
if (drupal_get_title()) {
$title = strip_tags(drupal_get_title());
}
else if (variable_get('site_slogan', '')) {
$title = variable_get('site_slogan', '');
}
$vars['head_page_title'] = $title;
// $site_footer, $footer
$vars['site_footer'] = filter_xss_admin(variable_get('site_footer', FALSE));
$vars['footer'] = theme('blocks', 'footer');
break;
case 'node':
// $node_id_class
$node_id = 'node-' . $vars['node']->nid;
$node_class = array('node');
if ($vars['page'] == 0) {
$node_class[] = 'list';
}
if ($vars['sticky']) {
$node_class[] = 'sticky';
}
if (!$vars['node']->status) {
$node_class[] = 'node-unpublished';
}
if ($vars['node']->type) {
$node_class[] = 'type-' . $vars['node']->type;
}
if ($vars['page'] == 0) {
$node_class[] = $vars['zebra'];
}
$vars['node_id_class'] = ' id="' . $node_id . '" class="' . implode(' ', $node_class) . '"';
// $changed_date
$vars['changed_date'] = format_date($vars['node']->changed);
break;
case 'comment':
// $comment_class
$comment_class = array('comment');
if ($vars['comment']->new) {
$comment_class[] = 'comment-new';
}
if ($vars['comment']->status == COMMENT_NOT_PUBLISHED) {
$comment_class[] = 'comment-unpublished';
}
$comment_class[] = $vars['zebra'];
$vars['comment_class'] = ' class="' . implode(' ', $comment_class) . '"';
break;
case 'block':
// $block_id_class
$block_id = 'block-' . $vars['block']->module . '-' . $vars['block']->delta;
$block_class = array('block');
$block_class[] = 'block-' . $vars['block']->module;
$block_class[] = $vars['zebra'];
if ($vars['block']->region == 'left') {
$block_class[] = 'left-' . $vars['block_zebra'];
}
else if ($vars['block']->region == 'right') {
$block_class[] = 'right-' . $vars['block_zebra'];
}
$vars['block_id_class'] = ' id="' .$block_id . '" class="' . implode(' ', $block_class) . '"';
break;
}
return $vars;
}
template.php 5.x-2.x head
<?php
// $Id: template.php,v 1.3 2008/09/26 0829 Exp $
/**
* Get theme setting values.
*/
if (is_null(theme_get_setting('diykit_skin'))) {
global $theme_key;
$defaults = array(
'diykit_skin' => 'default',
'diykit_layout' => 'fixed',
'diykit_column' => 'portal',
);
$settings = theme_get_settings($theme_key);
if (module_exists('node')) {
foreach (node_get_types() as $type => $name) {
unset($settings['toggle_node_info_' . $type]);
}
}
variable_set(
str_replace('/', '_', 'theme_'. $theme_key .'_settings'),
array_merge($defaults, $settings)
);
theme_get_setting('', TRUE);
}
/**
* Block regions.
*/
function diykit_regions() {
return array(
'header' => t('header'),
'footer' => t('footer'),
'left' => t('left sidebar'),
'right' => t('right sidebar'),
'content_top' => t('content top'),
'content_bottom' => t('content bottom'),
'content_body_top' => t('content body top'),
'content_body_bottom' => t('content body bottom'),
);
}
/**
* Override and insert phptemplate variables.
*/
function _phptemplate_variables($hook, $vars) {
switch($hook) {
case 'page':
global $user;
global $theme;
// $xml
$user_agent = getenv('HTTP_USER_AGENT');
if (!(strpos($user_agent, 'Windows') !== FALSE && strpos($user_agent, 'MSIE 6') !== FALSE)) {
$vars['xml'] = '<?xml version="1.0" encoding="utf-8"?>'. "\n";
}
// $css, $styles, $iefix
$skin = theme_get_setting($theme . '_skin');
$iefix = $vars['directory'] . '/css/ie-fix.css';
$vars['iefix'] = '';
if (file_exists($iefix)) {
$vars['iefix'] .= '<!--[if IE]><style type="text/css" media="all">@import "' . base_path() . $iefix . '";</style><![endif]-->' . "\n";
}
if ($skin == 'default') {
$css = $vars['directory'] . '/css/skin.css';
if (file_exists($css)) {
drupal_add_css($css, 'theme', 'all');
}
}
else if ($skin) {
$css = $vars['directory'] . '/skin/' . $skin . '/skin.css';
$skin_iefix = $vars['directory'] . '/skin/' . $skin . '/ie-fix.css';
if (file_exists($css)) {
drupal_add_css($css, 'theme', 'all');
}
if (file_exists($skin_iefix)) {
$vars['iefix'] .= '<!--[if IE]><style type="text/css" media="all">@import "' . base_path() . $skin_iefix . '";</style><![endif]-->' . "\n";
}
}
$vars['css'] = drupal_add_css();
$vars['styles'] = drupal_get_css();
// $body_classes
$layout = theme_get_setting($theme . '_layout');
$column = theme_get_setting($theme . '_column');
$body_classes[] = !empty($vars['is_front']) ? 'front' : 'not-front';
$body_classes[] = ($user->uid > 0) ? ' logged-in' : ' not-logged-in';
$body_classes[] = preg_replace('![^abcdefghijklmnopqrstuvwxyz0-9-_]+!s', '', 'page-'. form_clean_id(drupal_strtolower(arg(0))));
if (isset($vars['node']) && $vars['node']->type) {
$body_classes[] = 'node-type-'. form_clean_id($vars['node']->type);
}
if ($vars['layout'] == 'both') {
$body_classes[] = 'two-sidebars';
}
elseif ($vars['layout'] == 'none') {
$body_classes[] = 'no-sidebars';
}
else {
$body_classes[] = 'one-sidebar sidebar-'. $vars['layout'];
}
if ($layout) { $body_classes[] = $layout; }
if ($column) { $body_classes[] = $column; }
$vars['body_classes'] = implode(' ', $body_classes);
// $site_footer, $footer
$vars['site_footer'] = filter_xss_admin(variable_get('site_footer', FALSE));
$vars['footer'] = theme('blocks', 'footer');
break;
case 'node':
// $node_classes
$node_classes[] = 'node';
if ($vars['page'] == 0) {
$node_classes[] = 'teaser';
$node_classes[] = $vars['zebra'];
}
if ($vars['page'] == 1) {
$node_classes[] = 'page';
}
if ($vars['sticky']) {
$node_classes[] = 'sticky';
}
if (!$vars['node']->status) {
$node_classes[] = 'node-unpublished';
}
if ($vars['node']->type) {
$node_classes[] = 'type-' . $vars['node']->type;
}
$vars['node_classes'] = implode(' ', $node_classes);
// $content_body_top, $content_body_bottom
if ($vars['page'] == 1) {
$vars['content_body_top'] = theme('blocks', 'content_body_top');
$vars['content_body_bottom'] = theme('blocks', 'content_body_bottom');
}
break;
case 'comment':
global $user;
$node = node_load($vars['comment']->nid);
// $comment_classes
$comment_classes[] = 'comment';
if ($vars['comment']->new) {
$comment_classes[] = 'comment-new';
}
if ($vars['comment']->status == COMMENT_NOT_PUBLISHED) {
$comment_classes[] = 'comment-unpublished';
}
if ($vars['comment']->uid == $node->uid) {
$comment_classes[] = 'comment-by-author';
}
if ($user->uid && $vars['comment']->uid == $user->uid) {
$comment_classes[] = 'comment-mine';
}
if ($vars['comment']->uid) {
$comment_classes[] = 'comment-uid-' . $vars['comment']->uid;
}
$comment_classes[] = $vars['zebra'];
$vars['comment_classes'] = implode(' ', $comment_classes);
break;
case 'block':
// $block_classes
$block_classes[] = 'block';
$block_classes[] = 'block-' . $vars['block']->module;
$block_classes[] = $vars['zebra'];
$block_classes[] = $vars['block']->region . '-' . $vars['block_zebra'];
$block_classes[] = $vars['block']->region . '-' . $vars['block_id'];
$vars['block_classes'] = implode(' ', $block_classes);
break;
}
return $vars;
}
/**
* Override theme functions.
*/
function phptemplate_comment_wrapper($content, $type = null) {
static $node_type;
if (isset($type)) {
$node_type = $type;
}
if ($content) {
if ($node_type == 'forum') {
$output[] = '<div id="comments">'. $content .'</div>';
}
else {
$output[] = '<div id="comments">';
$output[] = '<h2 class="title comments">'. t('Comments') .'</h2>';
$output[] = $content .'</div>';
}
return implode("\n", $output);
}
return '';
}
function phptemplate_links($links, $attributes = array('class' => 'links')) {
$output = '';
if (count($links) > 0) {
$output = '<ul'. drupal_attributes($attributes) .'>';
$num_links = count($links);
$i = 1;
foreach ($links as $key => $link) {
$class = $key;
if (isset($link['attributes']) && isset($link['attributes']['class'])) {
$link['attributes']['class'] .= ' '. $key;
}
else {
$link['attributes']['class'] = $key;
}
if ($i == 1) {
$class .= ' first';
}
if ($i == $num_links) {
$class .= ' last';
}
if (isset($link['href']) && ($link['href'] == $_GET['q'] || ($link['href'] == '<front>' && drupal_is_front_page()))) {
$class .= ' active';
}
$output .= '<li'. drupal_attributes(array('class' => $class)) .'>';
$html = isset($link['html']) && $link['html'];
$link['query'] = isset($link['query']) ? $link['query'] : NULL;
$link['fragment'] = isset($link['fragment']) ? $link['fragment'] : NULL;
if (isset($link['href'])) {
$output .= l('<span>'. $link['title'] .'</span>', $link['href'], $link['attributes'], $link['query'], $link['fragment'], FALSE, $html = TRUE);
}
else if (!empty($link['title'])) {
if (empty($link['html'])) {
$link['title'] = check_plain($link['title']);
}
$output .= '<span'. drupal_attributes($link['attributes']) .'>'. $link['title'] .'</span>';
}
$i++;
$output .= "</li>\n";
}
$output .= '</ul>';
}
return $output;
}
function phptemplate_item_list($items = array(), $title = NULL, $type = 'ul', $attributes = NULL) {
$output = '<div class="item-list">';
if (isset($title)) {
$output .= '<h3>'. $title .'</h3>';
}
if (!empty($items)) {
$output .= "<$type" . drupal_attributes($attributes) . '>';
$num_items = count($items);
foreach ($items as $i => $item) {
$attributes = array();
$children = array();
if (is_array($item)) {
foreach ($item as $key => $value) {
if ($key == 'data') {
$data = $value;
}
elseif ($key == 'children') {
$children = $value;
}
else {
$attributes[$key] = $value;
}
}
}
else {
$data = $item;
}
if (count($children) > 0) {
$data .= theme_item_list($children, NULL, $type, $attributes);
}
if ($i == 0) {
$attributes['class'] = empty($attributes['class']) ? 'first' : ($attributes['class'] .' first');
}
if ($i == $num_items - 1) {
$attributes['class'] = empty($attributes['class']) ? 'last' : ($attributes['class'] .' last');
}
$output .= '<li' . drupal_attributes($attributes) . '>'. $data .'</li>'. "\n";
}
$output .= "</$type>";
}
$output .= '</div>';
return $output;
}
function phptemplate_breadcrumb($breadcrumb) {
if (!empty($breadcrumb)) {
return '<div class="breadcrumb">' . implode('<span class="breadcrumb-separate"> » </span>', $breadcrumb) . '</div>';
}
}
function phptemplate_feed_icon($url) {
global $theme;
$skin = theme_get_setting($theme . '_skin');
if ($skin && $skin != 'default') {
$path = path_to_theme() . '/skin/' . $skin . '/images/feed.png';
if (!is_file($path)) {
$path = path_to_theme() . '/images/feed.png';
}
}
else {
$path = path_to_theme() . '/images/feed.png';
}
if (!is_file($path)) {
$path = 'misc/feed.png';
}
if ($image = theme('image', $path, t('Syndicate content'), t('Syndicate content'))) {
return '<a href="' . check_url($url) . '" class="feed-icon">' . $image . '</a>';
}
}
function phptemplate_mark($type = MARK_NEW) {
global $user;
if ($user->uid) {
if ($type == MARK_NEW) {
return ' <span class="marker marker-new">' . t('new') . '</span>';
}
else if ($type == MARK_UPDATED) {
return ' <span class="marker marker-update">' . t('updated') . '</span>';
}
}
}
// $Id: template.php,v 1.3 2008/09/26 0829 Exp $
/**
* Get theme setting values.
*/
if (is_null(theme_get_setting('diykit_skin'))) {
global $theme_key;
$defaults = array(
'diykit_skin' => 'default',
'diykit_layout' => 'fixed',
'diykit_column' => 'portal',
);
$settings = theme_get_settings($theme_key);
if (module_exists('node')) {
foreach (node_get_types() as $type => $name) {
unset($settings['toggle_node_info_' . $type]);
}
}
variable_set(
str_replace('/', '_', 'theme_'. $theme_key .'_settings'),
array_merge($defaults, $settings)
);
theme_get_setting('', TRUE);
}
/**
* Block regions.
*/
function diykit_regions() {
return array(
'header' => t('header'),
'footer' => t('footer'),
'left' => t('left sidebar'),
'right' => t('right sidebar'),
'content_top' => t('content top'),
'content_bottom' => t('content bottom'),
'content_body_top' => t('content body top'),
'content_body_bottom' => t('content body bottom'),
);
}
/**
* Override and insert phptemplate variables.
*/
function _phptemplate_variables($hook, $vars) {
switch($hook) {
case 'page':
global $user;
global $theme;
// $xml
$user_agent = getenv('HTTP_USER_AGENT');
if (!(strpos($user_agent, 'Windows') !== FALSE && strpos($user_agent, 'MSIE 6') !== FALSE)) {
$vars['xml'] = '<?xml version="1.0" encoding="utf-8"?>'. "\n";
}
// $css, $styles, $iefix
$skin = theme_get_setting($theme . '_skin');
$iefix = $vars['directory'] . '/css/ie-fix.css';
$vars['iefix'] = '';
if (file_exists($iefix)) {
$vars['iefix'] .= '<!--[if IE]><style type="text/css" media="all">@import "' . base_path() . $iefix . '";</style><![endif]-->' . "\n";
}
if ($skin == 'default') {
$css = $vars['directory'] . '/css/skin.css';
if (file_exists($css)) {
drupal_add_css($css, 'theme', 'all');
}
}
else if ($skin) {
$css = $vars['directory'] . '/skin/' . $skin . '/skin.css';
$skin_iefix = $vars['directory'] . '/skin/' . $skin . '/ie-fix.css';
if (file_exists($css)) {
drupal_add_css($css, 'theme', 'all');
}
if (file_exists($skin_iefix)) {
$vars['iefix'] .= '<!--[if IE]><style type="text/css" media="all">@import "' . base_path() . $skin_iefix . '";</style><![endif]-->' . "\n";
}
}
$vars['css'] = drupal_add_css();
$vars['styles'] = drupal_get_css();
// $body_classes
$layout = theme_get_setting($theme . '_layout');
$column = theme_get_setting($theme . '_column');
$body_classes[] = !empty($vars['is_front']) ? 'front' : 'not-front';
$body_classes[] = ($user->uid > 0) ? ' logged-in' : ' not-logged-in';
$body_classes[] = preg_replace('![^abcdefghijklmnopqrstuvwxyz0-9-_]+!s', '', 'page-'. form_clean_id(drupal_strtolower(arg(0))));
if (isset($vars['node']) && $vars['node']->type) {
$body_classes[] = 'node-type-'. form_clean_id($vars['node']->type);
}
if ($vars['layout'] == 'both') {
$body_classes[] = 'two-sidebars';
}
elseif ($vars['layout'] == 'none') {
$body_classes[] = 'no-sidebars';
}
else {
$body_classes[] = 'one-sidebar sidebar-'. $vars['layout'];
}
if ($layout) { $body_classes[] = $layout; }
if ($column) { $body_classes[] = $column; }
$vars['body_classes'] = implode(' ', $body_classes);
// $site_footer, $footer
$vars['site_footer'] = filter_xss_admin(variable_get('site_footer', FALSE));
$vars['footer'] = theme('blocks', 'footer');
break;
case 'node':
// $node_classes
$node_classes[] = 'node';
if ($vars['page'] == 0) {
$node_classes[] = 'teaser';
$node_classes[] = $vars['zebra'];
}
if ($vars['page'] == 1) {
$node_classes[] = 'page';
}
if ($vars['sticky']) {
$node_classes[] = 'sticky';
}
if (!$vars['node']->status) {
$node_classes[] = 'node-unpublished';
}
if ($vars['node']->type) {
$node_classes[] = 'type-' . $vars['node']->type;
}
$vars['node_classes'] = implode(' ', $node_classes);
// $content_body_top, $content_body_bottom
if ($vars['page'] == 1) {
$vars['content_body_top'] = theme('blocks', 'content_body_top');
$vars['content_body_bottom'] = theme('blocks', 'content_body_bottom');
}
break;
case 'comment':
global $user;
$node = node_load($vars['comment']->nid);
// $comment_classes
$comment_classes[] = 'comment';
if ($vars['comment']->new) {
$comment_classes[] = 'comment-new';
}
if ($vars['comment']->status == COMMENT_NOT_PUBLISHED) {
$comment_classes[] = 'comment-unpublished';
}
if ($vars['comment']->uid == $node->uid) {
$comment_classes[] = 'comment-by-author';
}
if ($user->uid && $vars['comment']->uid == $user->uid) {
$comment_classes[] = 'comment-mine';
}
if ($vars['comment']->uid) {
$comment_classes[] = 'comment-uid-' . $vars['comment']->uid;
}
$comment_classes[] = $vars['zebra'];
$vars['comment_classes'] = implode(' ', $comment_classes);
break;
case 'block':
// $block_classes
$block_classes[] = 'block';
$block_classes[] = 'block-' . $vars['block']->module;
$block_classes[] = $vars['zebra'];
$block_classes[] = $vars['block']->region . '-' . $vars['block_zebra'];
$block_classes[] = $vars['block']->region . '-' . $vars['block_id'];
$vars['block_classes'] = implode(' ', $block_classes);
break;
}
return $vars;
}
/**
* Override theme functions.
*/
function phptemplate_comment_wrapper($content, $type = null) {
static $node_type;
if (isset($type)) {
$node_type = $type;
}
if ($content) {
if ($node_type == 'forum') {
$output[] = '<div id="comments">'. $content .'</div>';
}
else {
$output[] = '<div id="comments">';
$output[] = '<h2 class="title comments">'. t('Comments') .'</h2>';
$output[] = $content .'</div>';
}
return implode("\n", $output);
}
return '';
}
function phptemplate_links($links, $attributes = array('class' => 'links')) {
$output = '';
if (count($links) > 0) {
$output = '<ul'. drupal_attributes($attributes) .'>';
$num_links = count($links);
$i = 1;
foreach ($links as $key => $link) {
$class = $key;
if (isset($link['attributes']) && isset($link['attributes']['class'])) {
$link['attributes']['class'] .= ' '. $key;
}
else {
$link['attributes']['class'] = $key;
}
if ($i == 1) {
$class .= ' first';
}
if ($i == $num_links) {
$class .= ' last';
}
if (isset($link['href']) && ($link['href'] == $_GET['q'] || ($link['href'] == '<front>' && drupal_is_front_page()))) {
$class .= ' active';
}
$output .= '<li'. drupal_attributes(array('class' => $class)) .'>';
$html = isset($link['html']) && $link['html'];
$link['query'] = isset($link['query']) ? $link['query'] : NULL;
$link['fragment'] = isset($link['fragment']) ? $link['fragment'] : NULL;
if (isset($link['href'])) {
$output .= l('<span>'. $link['title'] .'</span>', $link['href'], $link['attributes'], $link['query'], $link['fragment'], FALSE, $html = TRUE);
}
else if (!empty($link['title'])) {
if (empty($link['html'])) {
$link['title'] = check_plain($link['title']);
}
$output .= '<span'. drupal_attributes($link['attributes']) .'>'. $link['title'] .'</span>';
}
$i++;
$output .= "</li>\n";
}
$output .= '</ul>';
}
return $output;
}
function phptemplate_item_list($items = array(), $title = NULL, $type = 'ul', $attributes = NULL) {
$output = '<div class="item-list">';
if (isset($title)) {
$output .= '<h3>'. $title .'</h3>';
}
if (!empty($items)) {
$output .= "<$type" . drupal_attributes($attributes) . '>';
$num_items = count($items);
foreach ($items as $i => $item) {
$attributes = array();
$children = array();
if (is_array($item)) {
foreach ($item as $key => $value) {
if ($key == 'data') {
$data = $value;
}
elseif ($key == 'children') {
$children = $value;
}
else {
$attributes[$key] = $value;
}
}
}
else {
$data = $item;
}
if (count($children) > 0) {
$data .= theme_item_list($children, NULL, $type, $attributes);
}
if ($i == 0) {
$attributes['class'] = empty($attributes['class']) ? 'first' : ($attributes['class'] .' first');
}
if ($i == $num_items - 1) {
$attributes['class'] = empty($attributes['class']) ? 'last' : ($attributes['class'] .' last');
}
$output .= '<li' . drupal_attributes($attributes) . '>'. $data .'</li>'. "\n";
}
$output .= "</$type>";
}
$output .= '</div>';
return $output;
}
function phptemplate_breadcrumb($breadcrumb) {
if (!empty($breadcrumb)) {
return '<div class="breadcrumb">' . implode('<span class="breadcrumb-separate"> » </span>', $breadcrumb) . '</div>';
}
}
function phptemplate_feed_icon($url) {
global $theme;
$skin = theme_get_setting($theme . '_skin');
if ($skin && $skin != 'default') {
$path = path_to_theme() . '/skin/' . $skin . '/images/feed.png';
if (!is_file($path)) {
$path = path_to_theme() . '/images/feed.png';
}
}
else {
$path = path_to_theme() . '/images/feed.png';
}
if (!is_file($path)) {
$path = 'misc/feed.png';
}
if ($image = theme('image', $path, t('Syndicate content'), t('Syndicate content'))) {
return '<a href="' . check_url($url) . '" class="feed-icon">' . $image . '</a>';
}
}
function phptemplate_mark($type = MARK_NEW) {
global $user;
if ($user->uid) {
if ($type == MARK_NEW) {
return ' <span class="marker marker-new">' . t('new') . '</span>';
}
else if ($type == MARK_UPDATED) {
return ' <span class="marker marker-update">' . t('updated') . '</span>';
}
}
}
theme-settings.php 5.x-2.x head
<?php
// $Id: theme-settings.php,v 1.1 2008/05/16 0829 Exp $
/**
* Implementation of themehook_settings().
*/
function phptemplate_settings($saved_settings) {
$defaults = array(
'diykit_skin' => 'default',
'diykit_layout' => 'fixed',
'diykit_column' => 'portal',
);
$settings = array_merge($defaults, $saved_settings);
$form['diykit_skin'] = array(
'#type' => 'select',
'#title' => t('Skin design'),
'#description' => t("Select the skin."),
'#default_value' => $settings['diykit_skin'],
'#options' => diykit_skinlist(),
);
$form['diykit_layout'] = array(
'#type' => 'select',
'#title' => t('Page layout'),
'#description' => t("Select the page layout type."),
'#default_value' => $settings['diykit_layout'],
'#options' => array(
'fixed' => t('Fixed'),
'liquid' => t('Liquid'),
'flexible' => t('Flexible'),
),
);
$form['diykit_column'] = array(
'#type' => 'select',
'#title' => t('Column layout'),
'#description' => t("Select the layout type of columns position."),
'#default_value' => $settings['diykit_column'],
'#options' => array(
'portal' => t('Portal'),
'news' => t('News'),
),
);
return $form;
}
function diykit_skinlist() {
$list['default'] = t('default');
$path = drupal_get_path('theme', 'diykit') . '/skin/';
if (file_exists($path)) {
$dir = dir($path);
while (false !== ($skin = $dir->read())) {
if ($skin != '.' && $skin != '..') {
$list[$skin] = t($skin);
}
}
$dir->close();
}
return $list;
}
// $Id: theme-settings.php,v 1.1 2008/05/16 0829 Exp $
/**
* Implementation of themehook_settings().
*/
function phptemplate_settings($saved_settings) {
$defaults = array(
'diykit_skin' => 'default',
'diykit_layout' => 'fixed',
'diykit_column' => 'portal',
);
$settings = array_merge($defaults, $saved_settings);
$form['diykit_skin'] = array(
'#type' => 'select',
'#title' => t('Skin design'),
'#description' => t("Select the skin."),
'#default_value' => $settings['diykit_skin'],
'#options' => diykit_skinlist(),
);
$form['diykit_layout'] = array(
'#type' => 'select',
'#title' => t('Page layout'),
'#description' => t("Select the page layout type."),
'#default_value' => $settings['diykit_layout'],
'#options' => array(
'fixed' => t('Fixed'),
'liquid' => t('Liquid'),
'flexible' => t('Flexible'),
),
);
$form['diykit_column'] = array(
'#type' => 'select',
'#title' => t('Column layout'),
'#description' => t("Select the layout type of columns position."),
'#default_value' => $settings['diykit_column'],
'#options' => array(
'portal' => t('Portal'),
'news' => t('News'),
),
);
return $form;
}
function diykit_skinlist() {
$list['default'] = t('default');
$path = drupal_get_path('theme', 'diykit') . '/skin/';
if (file_exists($path)) {
$dir = dir($path);
while (false !== ($skin = $dir->read())) {
if ($skin != '.' && $skin != '..') {
$list[$skin] = t($skin);
}
}
$dir->close();
}
return $list;
}
template.php 6.x-2.x head
<?php
// $Id: template.php,v 1.3 2008/09/26 0829 Exp $
/**
* Get theme setting values.
*/
if (is_null(theme_get_setting('diykit_skin'))) {
global $theme_key;
$themes = list_themes();
$defaults = $themes[$theme_key]->info['settings'];
$settings = theme_get_settings($theme_key);
if (module_exists('node')) {
foreach (node_get_types() as $type => $name) {
unset($settings['toggle_node_info_' . $type]);
}
}
variable_set(
str_replace('/', '_', 'theme_'. $theme_key .'_settings'),
array_merge($defaults, $settings)
);
theme_get_setting('', TRUE);
}
/**
* Override or insert PHPTemplate variables into the page.tpl.php.
*/
function phptemplate_preprocess_page(&$vars) {
global $theme;
// $xml
$user_agent = getenv('HTTP_USER_AGENT');
if (!(strpos($user_agent, 'Windows') !== FALSE && strpos($user_agent, 'MSIE 6') !== FALSE)) {
$vars['xml'] = '<?xml version="1.0" encoding="utf-8"?>'. "\n";
}
// $css, $styles, $iefix
$skin = theme_get_setting($theme . '_skin');
$iefix = $vars['directory'] . '/css/ie-fix.css';
$vars['iefix'] = '';
if (file_exists($iefix)) {
$vars['iefix'] .= '<!--[if IE]><link type="text/css" rel="stylesheet" media="all" href="' . base_path() . $iefix . '" /><![endif]-->' . "\n";
}
if ($skin == 'default') {
$css = $vars['directory'] . '/css/skin.css';
if (file_exists($css)) {
drupal_add_css($css, 'theme', 'all');
}
}
else if ($skin) {
$css = $vars['directory'] . '/skin/' . $skin . '/skin.css';
$skin_iefix = $vars['directory'] . '/skin/' . $skin . '/ie-fix.css';
if (file_exists($css)) {
drupal_add_css($css, 'theme', 'all');
}
if (file_exists($skin_iefix)) {
$vars['iefix'] .= '<!--[if IE]><link type="text/css" rel="stylesheet" media="all" href="' . base_path() . $skin_iefix . '" /><![endif]-->' . "\n";
}
}
$vars['css'] = drupal_add_css();
$vars['styles'] = drupal_get_css();
// $body_classes
$body_classes = array($vars['body_classes']);
$layout = theme_get_setting($theme . '_layout');
$column = theme_get_setting($theme . '_column');
if ($layout) { $body_classes[] = $layout; }
if ($column) { $body_classes[] = $column; }
$vars['body_classes'] = implode(' ', $body_classes);
}
/**
* Override or insert PHPTemplate variables into the node.tpl.php.
*/
function phptemplate_preprocess_node(&$vars) {
// $node_classes
$node_classes[] = 'node';
if ($vars['teaser']) {
$node_classes[] = 'teaser';
$node_classes[] = $vars['zebra'];
}
if ($vars['page']) {
$node_classes[] = 'page';
}
if ($vars['sticky']) {
$node_classes[] = 'sticky';
}
if (!$vars['status']) {
$node_classes[] = 'node-unpublished';
}
$vars['node_classes'] = implode(' ', $node_classes);
// $content_body_top, $content_body_bottom
if ($vars['page']) {
$vars['content_body_top'] = theme('blocks', 'content_body_top');
$vars['content_body_bottom'] = theme('blocks', 'content_body_bottom');
}
}
/**
* Override or insert PHPTemplate variables into the comment-wrapper.tpl.php.
*/
function phptemplate_preprocess_comment_wrapper(&$vars) {
// $comments_title
if ($vars['content'] && $vars['node']->type != 'forum') {
$vars['comments_title'] = t('Comments');
}
}
/**
* Override or insert PHPTemplate variables into the comment.tpl.php.
*/
function phptemplate_preprocess_comment(&$vars) {
global $user;
// $comment_classes
$comment_classes[] = 'comment';
if ($vars['comment']->new) {
$comment_classes[] = 'comment-new';
}
if ($vars['comment']->status == COMMENT_NOT_PUBLISHED) {
$comment_classes[] = 'comment-unpublished';
}
if ($vars['comment']->uid == $vars['node']->uid) {
$comment_classes[] = 'comment-by-author';
}
if ($user->uid && $vars['comment']->uid == $user->uid) {
$comment_classes[] = 'comment-mine';
}
if ($vars['comment']->uid) {
$comment_classes[] = 'comment-uid-' . $vars['comment']->uid;
}
$comment_classes[] = $vars['zebra'];
$vars['comment_classes'] = implode(' ', $comment_classes);
}
/**
* Override or insert PHPTemplate variables into the block.tpl.php.
*/
function phptemplate_preprocess_block(&$vars) {
// $block_classes
$block_classes[] = 'block';
$block_classes[] = 'block-' . $vars['block']->module;
$block_classes[] = $vars['zebra'];
$block_classes[] = $vars['block']->region . '-' . $vars['block_zebra'];
$block_classes[] = $vars['block']->region . '-' . $vars['block_id'];
$vars['block_classes'] = implode(' ', $block_classes);
}
/**
* Override theme functions.
*/
function phptemplate_links($links, $attributes = array('class' => 'links')) {
$output = '';
if (count($links) > 0) {
$output = '<ul' . drupal_attributes($attributes) . '>';
$num_links = count($links);
$i = 1;
foreach ($links as $key => $link) {
$class = $key;
if ($i == 1) {
$class .= ' first';
}
if ($i == $num_links) {
$class .= ' last';
}
if (isset($link['href']) && ($link['href'] == $_GET['q'] || ($link['href'] == '<front>' && drupal_is_front_page()))) {
$class .= ' active';
}
$output .= '<li class="'. $class . '">';
if (isset($link['href'])) {
$link['html'] = TRUE;
$output .= l('<span>' . $link['title'] . '</span>', $link['href'], $link);
}
else if (!empty($link['title'])) {
if (empty($link['html'])) {
$link['title'] = check_plain($link['title']);
}
$span_attributes = '';
if (isset($link['attributes'])) {
$span_attributes = drupal_attributes($link['attributes']);
}
$output .= '<span' . $span_attributes . '>' . $link['title'] . '</span>';
}
$i++;
$output .= "</li>\n";
}
$output .= '</ul>';
}
return $output;
}
function phptemplate_breadcrumb($breadcrumb) {
if (!empty($breadcrumb)) {
return '<div class="breadcrumb">' . implode('<span class="breadcrumb-separate"> » </span>', $breadcrumb) . '</div>';
}
}
function phptemplate_feed_icon($url, $title) {
global $theme;
$skin = theme_get_setting($theme . '_skin');
if ($skin && $skin != 'default') {
$path = path_to_theme() . '/skin/' . $skin . '/images/feed.png';
if (!is_file($path)) {
$path = path_to_theme() . '/images/feed.png';
}
}
else {
$path = path_to_theme() . '/images/feed.png';
}
if (!is_file($path)) {
$path = 'misc/feed.png';
}
if ($image = theme('image', $path, t('Syndicate content'), t('Syndicate content'), $title)) {
return '<a href="' . check_url($url) . '" class="feed-icon">' . $image . '</a>';
}
}
function phptemplate_mark($type = MARK_NEW) {
global $user;
if ($user->uid) {
if ($type == MARK_NEW) {
return ' <span class="marker marker-new">' . t('new') . '</span>';
}
else if ($type == MARK_UPDATED) {
return ' <span class="marker marker-update">' . t('updated') . '</span>';
}
}
}
// $Id: template.php,v 1.3 2008/09/26 0829 Exp $
/**
* Get theme setting values.
*/
if (is_null(theme_get_setting('diykit_skin'))) {
global $theme_key;
$themes = list_themes();
$defaults = $themes[$theme_key]->info['settings'];
$settings = theme_get_settings($theme_key);
if (module_exists('node')) {
foreach (node_get_types() as $type => $name) {
unset($settings['toggle_node_info_' . $type]);
}
}
variable_set(
str_replace('/', '_', 'theme_'. $theme_key .'_settings'),
array_merge($defaults, $settings)
);
theme_get_setting('', TRUE);
}
/**
* Override or insert PHPTemplate variables into the page.tpl.php.
*/
function phptemplate_preprocess_page(&$vars) {
global $theme;
// $xml
$user_agent = getenv('HTTP_USER_AGENT');
if (!(strpos($user_agent, 'Windows') !== FALSE && strpos($user_agent, 'MSIE 6') !== FALSE)) {
$vars['xml'] = '<?xml version="1.0" encoding="utf-8"?>'. "\n";
}
// $css, $styles, $iefix
$skin = theme_get_setting($theme . '_skin');
$iefix = $vars['directory'] . '/css/ie-fix.css';
$vars['iefix'] = '';
if (file_exists($iefix)) {
$vars['iefix'] .= '<!--[if IE]><link type="text/css" rel="stylesheet" media="all" href="' . base_path() . $iefix . '" /><![endif]-->' . "\n";
}
if ($skin == 'default') {
$css = $vars['directory'] . '/css/skin.css';
if (file_exists($css)) {
drupal_add_css($css, 'theme', 'all');
}
}
else if ($skin) {
$css = $vars['directory'] . '/skin/' . $skin . '/skin.css';
$skin_iefix = $vars['directory'] . '/skin/' . $skin . '/ie-fix.css';
if (file_exists($css)) {
drupal_add_css($css, 'theme', 'all');
}
if (file_exists($skin_iefix)) {
$vars['iefix'] .= '<!--[if IE]><link type="text/css" rel="stylesheet" media="all" href="' . base_path() . $skin_iefix . '" /><![endif]-->' . "\n";
}
}
$vars['css'] = drupal_add_css();
$vars['styles'] = drupal_get_css();
// $body_classes
$body_classes = array($vars['body_classes']);
$layout = theme_get_setting($theme . '_layout');
$column = theme_get_setting($theme . '_column');
if ($layout) { $body_classes[] = $layout; }
if ($column) { $body_classes[] = $column; }
$vars['body_classes'] = implode(' ', $body_classes);
}
/**
* Override or insert PHPTemplate variables into the node.tpl.php.
*/
function phptemplate_preprocess_node(&$vars) {
// $node_classes
$node_classes[] = 'node';
if ($vars['teaser']) {
$node_classes[] = 'teaser';
$node_classes[] = $vars['zebra'];
}
if ($vars['page']) {
$node_classes[] = 'page';
}
if ($vars['sticky']) {
$node_classes[] = 'sticky';
}
if (!$vars['status']) {
$node_classes[] = 'node-unpublished';
}
$vars['node_classes'] = implode(' ', $node_classes);
// $content_body_top, $content_body_bottom
if ($vars['page']) {
$vars['content_body_top'] = theme('blocks', 'content_body_top');
$vars['content_body_bottom'] = theme('blocks', 'content_body_bottom');
}
}
/**
* Override or insert PHPTemplate variables into the comment-wrapper.tpl.php.
*/
function phptemplate_preprocess_comment_wrapper(&$vars) {
// $comments_title
if ($vars['content'] && $vars['node']->type != 'forum') {
$vars['comments_title'] = t('Comments');
}
}
/**
* Override or insert PHPTemplate variables into the comment.tpl.php.
*/
function phptemplate_preprocess_comment(&$vars) {
global $user;
// $comment_classes
$comment_classes[] = 'comment';
if ($vars['comment']->new) {
$comment_classes[] = 'comment-new';
}
if ($vars['comment']->status == COMMENT_NOT_PUBLISHED) {
$comment_classes[] = 'comment-unpublished';
}
if ($vars['comment']->uid == $vars['node']->uid) {
$comment_classes[] = 'comment-by-author';
}
if ($user->uid && $vars['comment']->uid == $user->uid) {
$comment_classes[] = 'comment-mine';
}
if ($vars['comment']->uid) {
$comment_classes[] = 'comment-uid-' . $vars['comment']->uid;
}
$comment_classes[] = $vars['zebra'];
$vars['comment_classes'] = implode(' ', $comment_classes);
}
/**
* Override or insert PHPTemplate variables into the block.tpl.php.
*/
function phptemplate_preprocess_block(&$vars) {
// $block_classes
$block_classes[] = 'block';
$block_classes[] = 'block-' . $vars['block']->module;
$block_classes[] = $vars['zebra'];
$block_classes[] = $vars['block']->region . '-' . $vars['block_zebra'];
$block_classes[] = $vars['block']->region . '-' . $vars['block_id'];
$vars['block_classes'] = implode(' ', $block_classes);
}
/**
* Override theme functions.
*/
function phptemplate_links($links, $attributes = array('class' => 'links')) {
$output = '';
if (count($links) > 0) {
$output = '<ul' . drupal_attributes($attributes) . '>';
$num_links = count($links);
$i = 1;
foreach ($links as $key => $link) {
$class = $key;
if ($i == 1) {
$class .= ' first';
}
if ($i == $num_links) {
$class .= ' last';
}
if (isset($link['href']) && ($link['href'] == $_GET['q'] || ($link['href'] == '<front>' && drupal_is_front_page()))) {
$class .= ' active';
}
$output .= '<li class="'. $class . '">';
if (isset($link['href'])) {
$link['html'] = TRUE;
$output .= l('<span>' . $link['title'] . '</span>', $link['href'], $link);
}
else if (!empty($link['title'])) {
if (empty($link['html'])) {
$link['title'] = check_plain($link['title']);
}
$span_attributes = '';
if (isset($link['attributes'])) {
$span_attributes = drupal_attributes($link['attributes']);
}
$output .= '<span' . $span_attributes . '>' . $link['title'] . '</span>';
}
$i++;
$output .= "</li>\n";
}
$output .= '</ul>';
}
return $output;
}
function phptemplate_breadcrumb($breadcrumb) {
if (!empty($breadcrumb)) {
return '<div class="breadcrumb">' . implode('<span class="breadcrumb-separate"> » </span>', $breadcrumb) . '</div>';
}
}
function phptemplate_feed_icon($url, $title) {
global $theme;
$skin = theme_get_setting($theme . '_skin');
if ($skin && $skin != 'default') {
$path = path_to_theme() . '/skin/' . $skin . '/images/feed.png';
if (!is_file($path)) {
$path = path_to_theme() . '/images/feed.png';
}
}
else {
$path = path_to_theme() . '/images/feed.png';
}
if (!is_file($path)) {
$path = 'misc/feed.png';
}
if ($image = theme('image', $path, t('Syndicate content'), t('Syndicate content'), $title)) {
return '<a href="' . check_url($url) . '" class="feed-icon">' . $image . '</a>';
}
}
function phptemplate_mark($type = MARK_NEW) {
global $user;
if ($user->uid) {
if ($type == MARK_NEW) {
return ' <span class="marker marker-new">' . t('new') . '</span>';
}
else if ($type == MARK_UPDATED) {
return ' <span class="marker marker-update">' . t('updated') . '</span>';
}
}
}
theme-settings.php 6.x-2.x head
<?php
// $Id: theme-settings.php,v 1.1 2008/05/16 0829 Exp $
/**
* Implementation of themehook_settings().
*/
function phptemplate_settings($saved_settings) {
$themes = list_themes();
$defaults = $themes['diykit']->info['settings'];
$settings = array_merge($defaults, $saved_settings);
$form['diykit_skin'] = array(
'#type' => 'select',
'#title' => t('Skin design'),
'#description' => t("Select the skin."),
'#default_value' => $settings['diykit_skin'],
'#options' => diykit_skinlist(),
);
$form['diykit_layout'] = array(
'#type' => 'select',
'#title' => t('Page layout'),
'#description' => t("Select the page layout type."),
'#default_value' => $settings['diykit_layout'],
'#options' => array(
'fixed' => t('Fixed'),
'liquid' => t('Liquid'),
'flexible' => t('Flexible'),
),
);
$form['diykit_column'] = array(
'#type' => 'select',
'#title' => t('Column layout'),
'#description' => t("Select the layout type of columns position."),
'#default_value' => $settings['diykit_column'],
'#options' => array(
'portal' => t('Portal'),
'news' => t('News'),
),
);
return $form;
}
function diykit_skinlist() {
$list['default'] = t('default');
$path = drupal_get_path('theme', 'diykit') . '/skin/';
if (file_exists($path)) {
$dir = dir($path);
while (false !== ($skin = $dir->read())) {
if ($skin != '.' && $skin != '..') {
$list[$skin] = t($skin);
}
}
$dir->close();
}
return $list;
}
// $Id: theme-settings.php,v 1.1 2008/05/16 0829 Exp $
/**
* Implementation of themehook_settings().
*/
function phptemplate_settings($saved_settings) {
$themes = list_themes();
$defaults = $themes['diykit']->info['settings'];
$settings = array_merge($defaults, $saved_settings);
$form['diykit_skin'] = array(
'#type' => 'select',
'#title' => t('Skin design'),
'#description' => t("Select the skin."),
'#default_value' => $settings['diykit_skin'],
'#options' => diykit_skinlist(),
);
$form['diykit_layout'] = array(
'#type' => 'select',
'#title' => t('Page layout'),
'#description' => t("Select the page layout type."),
'#default_value' => $settings['diykit_layout'],
'#options' => array(
'fixed' => t('Fixed'),
'liquid' => t('Liquid'),
'flexible' => t('Flexible'),
),
);
$form['diykit_column'] = array(
'#type' => 'select',
'#title' => t('Column layout'),
'#description' => t("Select the layout type of columns position."),
'#default_value' => $settings['diykit_column'],
'#options' => array(
'portal' => t('Portal'),
'news' => t('News'),
),
);
return $form;
}
function diykit_skinlist() {
$list['default'] = t('default');
$path = drupal_get_path('theme', 'diykit') . '/skin/';
if (file_exists($path)) {
$dir = dir($path);
while (false !== ($skin = $dir->read())) {
if ($skin != '.' && $skin != '..') {
$list[$skin] = t($skin);
}
}
$dir->close();
}
return $list;
}
template.php 5.x-3.x head
<?php
// $Id: template.php,v 1.6 2008/12/07 0829 Exp $
/**
* Get theme setting values.
*/
if (is_null(theme_get_setting('diykit_skin'))) {
global $theme_key;
$defaults = array(
'diykit_skin' => 'none',
'diykit_layout' => 'fixed',
'diykit_column' => 'portal',
'diykit_breadcrumb' => 0,
);
$settings = theme_get_settings($theme_key);
if (module_exists('node')) {
foreach (node_get_types() as $type => $name) {
unset($settings['toggle_node_info_'. $type]);
}
}
variable_set(
str_replace('/', '_', 'theme_'. $theme_key .'_settings'),
array_merge($defaults, $settings)
);
theme_get_setting('', TRUE);
}
/**
* Block regions.
*/
function diykit_regions() {
return array(
'header' => t('header'),
'footer' => t('footer'),
'left' => t('left sidebar'),
'right' => t('right sidebar'),
'node_top' => t('node top'),
'node_bottom' => t('node bottom'),
'node_body_top' => t('node body top'),
'node_body_bottom' => t('node body bottom'),
);
}
/**
* Override and insert phptemplate variables.
*/
function _phptemplate_variables($hook, $vars) {
switch($hook) {
case 'page':
global $user;
global $theme;
// $xml
$user_agent = getenv('HTTP_USER_AGENT');
if (!(strpos($user_agent, 'Windows') !== FALSE && strpos($user_agent, 'MSIE 6') !== FALSE)) {
$vars['xml'] = '<?xml version="1.0" encoding="utf-8"?>'. "\n";
}
// $css, $styles, $iefix
$skin = theme_get_setting($theme .'_skin');
$iefix = $vars['directory'] .'/ie-fix.css';
$vars['iefix'] = '';
if (file_exists($iefix)) {
$vars['iefix'] .= '<!--[if IE]><style type="text/css" media="all">@import "'. base_path() . $iefix .'";</style><![endif]-->'. "\n";
}
if ($skin != 'none') {
$css = $vars['directory'] .'/skin/'. $skin .'/skin.css';
$skin_iefix = $vars['directory'] .'/skin/'. $skin .'/ie-fix.css';
if (file_exists($css)) {
drupal_add_css($css, 'theme', 'all');
}
if (file_exists($skin_iefix)) {
$vars['iefix'] .= '<!--[if IE]><style type="text/css" media="all">@import "'. base_path() . $skin_iefix .'";</style><![endif]-->'. "\n";
}
}
drupal_add_css($vars['directory'] .'/common.css', 'theme', 'all');
$vars['css'] = drupal_add_css();
$vars['styles'] = drupal_get_css();
// $body_classes
$body_classes[] = !empty($vars['is_front']) ? 'front' : 'not-front';
$body_classes[] = ($user->uid > 0) ? 'logged-in' : 'not-logged-in';
$body_classes[] = preg_replace('![^abcdefghijklmnopqrstuvwxyz0-9-_]+!s', '', 'page-'. form_clean_id(drupal_strtolower(arg(0))));
$body_classes[] = (isset($vars['node']) && $vars['node']->type) ? 'node-type-'. form_clean_id($vars['node']->type) : '';
if ($vars['layout'] == 'both') {
$body_classes[] = 'two-sidebars';
}
elseif ($vars['layout'] == 'none') {
$body_classes[] = 'no-sidebars';
}
else {
$body_classes[] = 'one-sidebar sidebar-'. $vars['layout'];
}
$body_classes[] = theme_get_setting($theme .'_layout');
$body_classes[] = theme_get_setting($theme .'_column');
$vars['body_classes'] = implode(' ', $body_classes);
// $site_footer, $footer
$vars['site_footer'] = filter_xss_admin(variable_get('site_footer', FALSE));
$vars['footer'] = theme('blocks', 'footer');
break;
case 'node':
// $node_classes
$node_classes[] = 'node';
if ($vars['page'] == 0) {
$node_classes[] = 'teaser';
$node_classes[] = $vars['zebra'];
}
if ($vars['page'] == 1) {
$node_classes[] = 'page';
}
if ($vars['sticky']) {
$node_classes[] = 'sticky';
}
if (!$vars['node']->status) {
$node_classes[] = 'node-unpublished';
}
if ($vars['node']->type) {
$node_classes[] = 'type-'. $vars['node']->type;
}
$vars['node_classes'] = implode(' ', $node_classes);
// $node_body_top, $node_body_bottom
if ($vars['page'] == 1) {
$vars['node_body_top'] = theme('blocks', 'node_body_top');
$vars['node_body_bottom'] = theme('blocks', 'node_body_bottom');
}
break;
case 'comment':
global $user;
$node = node_load($vars['comment']->nid);
// $comment_classes
$comment_classes[] = 'comment';
if ($vars['comment']->new) {
$comment_classes[] = 'comment-new';
}
if ($vars['comment']->status == COMMENT_NOT_PUBLISHED) {
$comment_classes[] = 'comment-unpublished';
}
if ($vars['comment']->uid == $node->uid) {
$comment_classes[] = 'comment-by-author';
}
if ($user->uid && $vars['comment']->uid == $user->uid) {
$comment_classes[] = 'comment-mine';
}
if ($vars['comment']->uid) {
$comment_classes[] = 'comment-uid-'. $vars['comment']->uid;
}
$comment_classes[] = $vars['zebra'];
$vars['comment_classes'] = implode(' ', $comment_classes);
break;
case 'block':
// $block_classes
$block_classes[] = 'block';
$block_classes[] = 'block-'. $vars['block']->module;
$block_classes[] = $vars['zebra'];
$block_classes[] = $vars['block']->region .'-'. $vars['block_zebra'];
$block_classes[] = $vars['block']->region .'-'. $vars['block_id'];
$vars['block_classes'] = implode(' ', $block_classes);
break;
}
return $vars;
}
/**
* Override theme functions.
*/
function phptemplate_comment_wrapper($content, $type = null) {
static $node_type;
if (isset($type)) {
$node_type = $type;
}
if ($content) {
if ($node_type == 'forum') {
$output[] = '<div id="comments">'. $content .'</div>';
}
else {
$output[] = '<div id="comments">';
$output[] = '<h2 class="title comments">'. t('Comments') .'</h2>';
$output[] = $content .'</div>';
}
return implode("\n", $output);
}
return '';
}
function phptemplate_links($links, $attributes = array('class' => 'links')) {
$output = '';
if (count($links) > 0) {
$output = '<ul'. drupal_attributes($attributes) .'>';
$num_links = count($links);
$i = 1;
foreach ($links as $key => $link) {
$class = $key;
if (isset($link['attributes']) && isset($link['attributes']['class'])) {
$link['attributes']['class'] .= ' '. $key;
}
else {
$link['attributes']['class'] = $key;
}
if ($i == 1) {
$class .= ' first';
}
if ($i == $num_links) {
$class .= ' last';
}
if (isset($link['href']) && ($link['href'] == $_GET['q'] || ($link['href'] == '<front>' && drupal_is_front_page()))) {
$class .= ' active';
}
$output .= '<li'. drupal_attributes(array('class' => $class)) .'>';
$html = isset($link['html']) && $link['html'];
$link['query'] = isset($link['query']) ? $link['query'] : NULL;
$link['fragment'] = isset($link['fragment']) ? $link['fragment'] : NULL;
if (isset($link['href'])) {
$output .= l('<span>'. $link['title'] .'</span>', $link['href'], $link['attributes'], $link['query'], $link['fragment'], FALSE, $html = TRUE);
}
else if (!empty($link['title'])) {
if (empty($link['html'])) {
$link['title'] = check_plain($link['title']);
}
$output .= '<span'. drupal_attributes($link['attributes']) .'>'. $link['title'] .'</span>';
}
$i++;
$output .= "</li>\n";
}
$output .= '</ul>';
}
return $output;
}
function phptemplate_item_list($items = array(), $title = NULL, $type = 'ul', $attributes = NULL) {
$output = '<div class="item-list">';
if (isset($title)) {
$output .= '<h3>'. $title .'</h3>';
}
if (!empty($items)) {
$output .= "<$type" . drupal_attributes($attributes) . '>';
$num_items = count($items);
foreach ($items as $i => $item) {
$attributes = array();
$children = array();
if (is_array($item)) {
foreach ($item as $key => $value) {
if ($key == 'data') {
$data = $value;
}
elseif ($key == 'children') {
$children = $value;
}
else {
$attributes[$key] = $value;
}
}
}
else {
$data = $item;
}
if (count($children) > 0) {
$data .= theme_item_list($children, NULL, $type, $attributes);
}
if ($i == 0) {
$attributes['class'] = empty($attributes['class']) ? 'first' : ($attributes['class'] .' first');
}
if ($i == $num_items - 1) {
$attributes['class'] = empty($attributes['class']) ? 'last' : ($attributes['class'] .' last');
}
$output .= '<li' . drupal_attributes($attributes) . '>'. $data .'</li>'. "\n";
}
$output .= "</$type>";
}
$output .= '</div>';
return $output;
}
function phptemplate_breadcrumb($breadcrumb) {
if (!empty($breadcrumb)) {
global $theme;
if (theme_get_setting($theme .'_breadcrumb') == 1 && $title = drupal_get_title()) {
$breadcrumb[] = '<span class="current">'. $title .'</span>';
}
return '<div class="breadcrumb">'. implode('<span class="breadcrumb-separate"> » </span>', $breadcrumb) .'</div>';
}
}
function phptemplate_feed_icon($url) {
global $theme;
$skin = theme_get_setting($theme .'_skin');
$path = 'misc/feed.png';
if (is_file($file = path_to_theme() .'/skin/'. $skin .'/images/feed.png')) {
$path = $file;
}
else if (is_file($file = path_to_theme() .'/images/feed.png')) {
$path = $file;
}
if ($image = theme('image', $path, t('Syndicate content'), t('Syndicate content'))) {
return '<a href="'. check_url($url) .'" class="feed-icon">'. $image .'</a>';
}
}
function phptemplate_mark($type = MARK_NEW) {
global $user;
if ($user->uid) {
if ($type == MARK_NEW) {
return '<span class="marker marker-new">'. t('new') .'</span>';
}
else if ($type == MARK_UPDATED) {
return '<span class="marker marker-update">'. t('updated') .'</span>';
}
}
}
function phptemplate_pager($tags = array(), $limit = 10, $element = 0, $parameters = array()) {
global $pager_total;
$items = array();
if ($pager_total[$element] > 1) {
$first = theme('pager_first', ($tags[0] ? $tags[0] : t('<span>«</span>First')), $limit, $element, $parameters);
$previous = theme('pager_previous', ($tags[1] ? $tags[1] : t('<span>‹</span>Prev')), $limit, $element, 1, $parameters);
$list = theme('pager_list', $limit, $element, ($tags[2] ? $tags[2] : 5 ), '', $parameters);
$next = theme('pager_next', ($tags[3] ? $tags[3] : t('Next<span>›</span>')), $limit, $element, 1, $parameters);
$last = theme('pager_last', ($tags[4] ? $tags[4] : t('Last<span>»</span>')), $limit, $element, $parameters);
if (!empty($first)) {
$items[] = array(
'class' => 'pager-first',
'data' => $first,
);
}
if (!empty($previous)) {
$items[] = array(
'class' => 'pager-previous',
'data' => $previous,
);
}
if (!empty($list)) {
$items = array_merge($items, $list);
}
if (!empty($next)) {
$items[] = array(
'class' => 'pager-next',
'data' => $next,
);
}
if (!empty($last)) {
$items[] = array(
'class' => 'pager-last',
'data' => $last,
);
}
return theme('item_list', $items, NULL, 'ul', array('id' => 'pager'));
}
}
function phptemplate_pager_list($limit, $element = 0, $quantity = 5, $text = '', $parameters = array()) {
global $pager_page_array, $pager_total;
$items = array();
$pager_middle = ceil($quantity / 2);
$pager_current = $pager_page_array[$element] + 1;
$pager_first = $pager_current - $pager_middle + 1;
$pager_last = $pager_current + $quantity - $pager_middle;
$pager_max = $pager_total[$element];
$i = $pager_first;
if ($pager_last > $pager_max) {
$i = $i + ($pager_max - $pager_last);
$pager_last = $pager_max;
}
if ($i <= 0) {
$pager_last = $pager_last + (1 - $i);
$i = 1;
}
if ($i != $pager_max) {
if ($i > 1) {
$items[] = array(
'class' => 'pager-ellipsis ellipsis-previous',
'data' => '<span class="pager-ellipsis">…</span>',
);
}
for (; $i <= $pager_last && $i <= $pager_max; $i++) {
if ($i < $pager_current) {
$items[] = array(
'class' => 'pager-item item-previous',
'data' => theme('pager_previous', $i, $limit, $element, ($pager_current - $i), $parameters),
);
}
if ($i == $pager_current) {
$items[] = array(
'class' => 'pager-current',
'data' => '<strong class="pager-current">'. $i .'</strong>',
);
}
if ($i > $pager_current) {
$items[] = array(
'class' => 'pager-item item-next',
'data' => theme('pager_next', $i, $limit, $element, ($i - $pager_current), $parameters),
);
}
}
if ($i < $pager_max) {
$items[] = array(
'class' => 'pager-ellipsis ellipsis-next',
'data' => '<span class="ellipsis">…</span>',
);
}
}
return $items;
}
function phptemplate_pager_link($text, $page_new, $element, $parameters = array(), $attributes = array()) {
$page = isset($_GET['page']) ? $_GET['page'] : '';
if ($new_page = implode(',', pager_load_array($page_new[$element], $element, explode(',', $page)))) {
$parameters['page'] = $new_page;
}
$query = array();
if (count($parameters)) {
$query[] = drupal_query_string_encode($parameters, array());
}
$querystring = pager_get_querystring();
if ($querystring != '') {
$query[] = $querystring;
}
if (!isset($attributes['title'])) {
static $titles = NULL;
if (!isset($titles)) {
$titles = array(
t('<span>«</span>First') => t('Go to first page'),
t('<span>‹</span>Prev') => t('Go to previous page'),
t('Next<span>›</span>') => t('Go to next page'),
t('Last<span>»</span>') => t('Go to last page'),
);
}
if (isset($titles[$text])) {
$attributes['title'] = $titles[$text];
}
else if (is_numeric($text)) {
$attributes['title'] = t('Go to page @number', array('@number' => $text));
}
}
return l($text, $_GET['q'], $attributes, count($query) ? implode('&', $query) : NULL, FALSE, FALSE, $html = TRUE);
}
// $Id: template.php,v 1.6 2008/12/07 0829 Exp $
/**
* Get theme setting values.
*/
if (is_null(theme_get_setting('diykit_skin'))) {
global $theme_key;
$defaults = array(
'diykit_skin' => 'none',
'diykit_layout' => 'fixed',
'diykit_column' => 'portal',
'diykit_breadcrumb' => 0,
);
$settings = theme_get_settings($theme_key);
if (module_exists('node')) {
foreach (node_get_types() as $type => $name) {
unset($settings['toggle_node_info_'. $type]);
}
}
variable_set(
str_replace('/', '_', 'theme_'. $theme_key .'_settings'),
array_merge($defaults, $settings)
);
theme_get_setting('', TRUE);
}
/**
* Block regions.
*/
function diykit_regions() {
return array(
'header' => t('header'),
'footer' => t('footer'),
'left' => t('left sidebar'),
'right' => t('right sidebar'),
'node_top' => t('node top'),
'node_bottom' => t('node bottom'),
'node_body_top' => t('node body top'),
'node_body_bottom' => t('node body bottom'),
);
}
/**
* Override and insert phptemplate variables.
*/
function _phptemplate_variables($hook, $vars) {
switch($hook) {
case 'page':
global $user;
global $theme;
// $xml
$user_agent = getenv('HTTP_USER_AGENT');
if (!(strpos($user_agent, 'Windows') !== FALSE && strpos($user_agent, 'MSIE 6') !== FALSE)) {
$vars['xml'] = '<?xml version="1.0" encoding="utf-8"?>'. "\n";
}
// $css, $styles, $iefix
$skin = theme_get_setting($theme .'_skin');
$iefix = $vars['directory'] .'/ie-fix.css';
$vars['iefix'] = '';
if (file_exists($iefix)) {
$vars['iefix'] .= '<!--[if IE]><style type="text/css" media="all">@import "'. base_path() . $iefix .'";</style><![endif]-->'. "\n";
}
if ($skin != 'none') {
$css = $vars['directory'] .'/skin/'. $skin .'/skin.css';
$skin_iefix = $vars['directory'] .'/skin/'. $skin .'/ie-fix.css';
if (file_exists($css)) {
drupal_add_css($css, 'theme', 'all');
}
if (file_exists($skin_iefix)) {
$vars['iefix'] .= '<!--[if IE]><style type="text/css" media="all">@import "'. base_path() . $skin_iefix .'";</style><![endif]-->'. "\n";
}
}
drupal_add_css($vars['directory'] .'/common.css', 'theme', 'all');
$vars['css'] = drupal_add_css();
$vars['styles'] = drupal_get_css();
// $body_classes
$body_classes[] = !empty($vars['is_front']) ? 'front' : 'not-front';
$body_classes[] = ($user->uid > 0) ? 'logged-in' : 'not-logged-in';
$body_classes[] = preg_replace('![^abcdefghijklmnopqrstuvwxyz0-9-_]+!s', '', 'page-'. form_clean_id(drupal_strtolower(arg(0))));
$body_classes[] = (isset($vars['node']) && $vars['node']->type) ? 'node-type-'. form_clean_id($vars['node']->type) : '';
if ($vars['layout'] == 'both') {
$body_classes[] = 'two-sidebars';
}
elseif ($vars['layout'] == 'none') {
$body_classes[] = 'no-sidebars';
}
else {
$body_classes[] = 'one-sidebar sidebar-'. $vars['layout'];
}
$body_classes[] = theme_get_setting($theme .'_layout');
$body_classes[] = theme_get_setting($theme .'_column');
$vars['body_classes'] = implode(' ', $body_classes);
// $site_footer, $footer
$vars['site_footer'] = filter_xss_admin(variable_get('site_footer', FALSE));
$vars['footer'] = theme('blocks', 'footer');
break;
case 'node':
// $node_classes
$node_classes[] = 'node';
if ($vars['page'] == 0) {
$node_classes[] = 'teaser';
$node_classes[] = $vars['zebra'];
}
if ($vars['page'] == 1) {
$node_classes[] = 'page';
}
if ($vars['sticky']) {
$node_classes[] = 'sticky';
}
if (!$vars['node']->status) {
$node_classes[] = 'node-unpublished';
}
if ($vars['node']->type) {
$node_classes[] = 'type-'. $vars['node']->type;
}
$vars['node_classes'] = implode(' ', $node_classes);
// $node_body_top, $node_body_bottom
if ($vars['page'] == 1) {
$vars['node_body_top'] = theme('blocks', 'node_body_top');
$vars['node_body_bottom'] = theme('blocks', 'node_body_bottom');
}
break;
case 'comment':
global $user;
$node = node_load($vars['comment']->nid);
// $comment_classes
$comment_classes[] = 'comment';
if ($vars['comment']->new) {
$comment_classes[] = 'comment-new';
}
if ($vars['comment']->status == COMMENT_NOT_PUBLISHED) {
$comment_classes[] = 'comment-unpublished';
}
if ($vars['comment']->uid == $node->uid) {
$comment_classes[] = 'comment-by-author';
}
if ($user->uid && $vars['comment']->uid == $user->uid) {
$comment_classes[] = 'comment-mine';
}
if ($vars['comment']->uid) {
$comment_classes[] = 'comment-uid-'. $vars['comment']->uid;
}
$comment_classes[] = $vars['zebra'];
$vars['comment_classes'] = implode(' ', $comment_classes);
break;
case 'block':
// $block_classes
$block_classes[] = 'block';
$block_classes[] = 'block-'. $vars['block']->module;
$block_classes[] = $vars['zebra'];
$block_classes[] = $vars['block']->region .'-'. $vars['block_zebra'];
$block_classes[] = $vars['block']->region .'-'. $vars['block_id'];
$vars['block_classes'] = implode(' ', $block_classes);
break;
}
return $vars;
}
/**
* Override theme functions.
*/
function phptemplate_comment_wrapper($content, $type = null) {
static $node_type;
if (isset($type)) {
$node_type = $type;
}
if ($content) {
if ($node_type == 'forum') {
$output[] = '<div id="comments">'. $content .'</div>';
}
else {
$output[] = '<div id="comments">';
$output[] = '<h2 class="title comments">'. t('Comments') .'</h2>';
$output[] = $content .'</div>';
}
return implode("\n", $output);
}
return '';
}
function phptemplate_links($links, $attributes = array('class' => 'links')) {
$output = '';
if (count($links) > 0) {
$output = '<ul'. drupal_attributes($attributes) .'>';
$num_links = count($links);
$i = 1;
foreach ($links as $key => $link) {
$class = $key;
if (isset($link['attributes']) && isset($link['attributes']['class'])) {
$link['attributes']['class'] .= ' '. $key;
}
else {
$link['attributes']['class'] = $key;
}
if ($i == 1) {
$class .= ' first';
}
if ($i == $num_links) {
$class .= ' last';
}
if (isset($link['href']) && ($link['href'] == $_GET['q'] || ($link['href'] == '<front>' && drupal_is_front_page()))) {
$class .= ' active';
}
$output .= '<li'. drupal_attributes(array('class' => $class)) .'>';
$html = isset($link['html']) && $link['html'];
$link['query'] = isset($link['query']) ? $link['query'] : NULL;
$link['fragment'] = isset($link['fragment']) ? $link['fragment'] : NULL;
if (isset($link['href'])) {
$output .= l('<span>'. $link['title'] .'</span>', $link['href'], $link['attributes'], $link['query'], $link['fragment'], FALSE, $html = TRUE);
}
else if (!empty($link['title'])) {
if (empty($link['html'])) {
$link['title'] = check_plain($link['title']);
}
$output .= '<span'. drupal_attributes($link['attributes']) .'>'. $link['title'] .'</span>';
}
$i++;
$output .= "</li>\n";
}
$output .= '</ul>';
}
return $output;
}
function phptemplate_item_list($items = array(), $title = NULL, $type = 'ul', $attributes = NULL) {
$output = '<div class="item-list">';
if (isset($title)) {
$output .= '<h3>'. $title .'</h3>';
}
if (!empty($items)) {
$output .= "<$type" . drupal_attributes($attributes) . '>';
$num_items = count($items);
foreach ($items as $i => $item) {
$attributes = array();
$children = array();
if (is_array($item)) {
foreach ($item as $key => $value) {
if ($key == 'data') {
$data = $value;
}
elseif ($key == 'children') {
$children = $value;
}
else {
$attributes[$key] = $value;
}
}
}
else {
$data = $item;
}
if (count($children) > 0) {
$data .= theme_item_list($children, NULL, $type, $attributes);
}
if ($i == 0) {
$attributes['class'] = empty($attributes['class']) ? 'first' : ($attributes['class'] .' first');
}
if ($i == $num_items - 1) {
$attributes['class'] = empty($attributes['class']) ? 'last' : ($attributes['class'] .' last');
}
$output .= '<li' . drupal_attributes($attributes) . '>'. $data .'</li>'. "\n";
}
$output .= "</$type>";
}
$output .= '</div>';
return $output;
}
function phptemplate_breadcrumb($breadcrumb) {
if (!empty($breadcrumb)) {
global $theme;
if (theme_get_setting($theme .'_breadcrumb') == 1 && $title = drupal_get_title()) {
$breadcrumb[] = '<span class="current">'. $title .'</span>';
}
return '<div class="breadcrumb">'. implode('<span class="breadcrumb-separate"> » </span>', $breadcrumb) .'</div>';
}
}
function phptemplate_feed_icon($url) {
global $theme;
$skin = theme_get_setting($theme .'_skin');
$path = 'misc/feed.png';
if (is_file($file = path_to_theme() .'/skin/'. $skin .'/images/feed.png')) {
$path = $file;
}
else if (is_file($file = path_to_theme() .'/images/feed.png')) {
$path = $file;
}
if ($image = theme('image', $path, t('Syndicate content'), t('Syndicate content'))) {
return '<a href="'. check_url($url) .'" class="feed-icon">'. $image .'</a>';
}
}
function phptemplate_mark($type = MARK_NEW) {
global $user;
if ($user->uid) {
if ($type == MARK_NEW) {
return '<span class="marker marker-new">'. t('new') .'</span>';
}
else if ($type == MARK_UPDATED) {
return '<span class="marker marker-update">'. t('updated') .'</span>';
}
}
}
function phptemplate_pager($tags = array(), $limit = 10, $element = 0, $parameters = array()) {
global $pager_total;
$items = array();
if ($pager_total[$element] > 1) {
$first = theme('pager_first', ($tags[0] ? $tags[0] : t('<span>«</span>First')), $limit, $element, $parameters);
$previous = theme('pager_previous', ($tags[1] ? $tags[1] : t('<span>‹</span>Prev')), $limit, $element, 1, $parameters);
$list = theme('pager_list', $limit, $element, ($tags[2] ? $tags[2] : 5 ), '', $parameters);
$next = theme('pager_next', ($tags[3] ? $tags[3] : t('Next<span>›</span>')), $limit, $element, 1, $parameters);
$last = theme('pager_last', ($tags[4] ? $tags[4] : t('Last<span>»</span>')), $limit, $element, $parameters);
if (!empty($first)) {
$items[] = array(
'class' => 'pager-first',
'data' => $first,
);
}
if (!empty($previous)) {
$items[] = array(
'class' => 'pager-previous',
'data' => $previous,
);
}
if (!empty($list)) {
$items = array_merge($items, $list);
}
if (!empty($next)) {
$items[] = array(
'class' => 'pager-next',
'data' => $next,
);
}
if (!empty($last)) {
$items[] = array(
'class' => 'pager-last',
'data' => $last,
);
}
return theme('item_list', $items, NULL, 'ul', array('id' => 'pager'));
}
}
function phptemplate_pager_list($limit, $element = 0, $quantity = 5, $text = '', $parameters = array()) {
global $pager_page_array, $pager_total;
$items = array();
$pager_middle = ceil($quantity / 2);
$pager_current = $pager_page_array[$element] + 1;
$pager_first = $pager_current - $pager_middle + 1;
$pager_last = $pager_current + $quantity - $pager_middle;
$pager_max = $pager_total[$element];
$i = $pager_first;
if ($pager_last > $pager_max) {
$i = $i + ($pager_max - $pager_last);
$pager_last = $pager_max;
}
if ($i <= 0) {
$pager_last = $pager_last + (1 - $i);
$i = 1;
}
if ($i != $pager_max) {
if ($i > 1) {
$items[] = array(
'class' => 'pager-ellipsis ellipsis-previous',
'data' => '<span class="pager-ellipsis">…</span>',
);
}
for (; $i <= $pager_last && $i <= $pager_max; $i++) {
if ($i < $pager_current) {
$items[] = array(
'class' => 'pager-item item-previous',
'data' => theme('pager_previous', $i, $limit, $element, ($pager_current - $i), $parameters),
);
}
if ($i == $pager_current) {
$items[] = array(
'class' => 'pager-current',
'data' => '<strong class="pager-current">'. $i .'</strong>',
);
}
if ($i > $pager_current) {
$items[] = array(
'class' => 'pager-item item-next',
'data' => theme('pager_next', $i, $limit, $element, ($i - $pager_current), $parameters),
);
}
}
if ($i < $pager_max) {
$items[] = array(
'class' => 'pager-ellipsis ellipsis-next',
'data' => '<span class="ellipsis">…</span>',
);
}
}
return $items;
}
function phptemplate_pager_link($text, $page_new, $element, $parameters = array(), $attributes = array()) {
$page = isset($_GET['page']) ? $_GET['page'] : '';
if ($new_page = implode(',', pager_load_array($page_new[$element], $element, explode(',', $page)))) {
$parameters['page'] = $new_page;
}
$query = array();
if (count($parameters)) {
$query[] = drupal_query_string_encode($parameters, array());
}
$querystring = pager_get_querystring();
if ($querystring != '') {
$query[] = $querystring;
}
if (!isset($attributes['title'])) {
static $titles = NULL;
if (!isset($titles)) {
$titles = array(
t('<span>«</span>First') => t('Go to first page'),
t('<span>‹</span>Prev') => t('Go to previous page'),
t('Next<span>›</span>') => t('Go to next page'),
t('Last<span>»</span>') => t('Go to last page'),
);
}
if (isset($titles[$text])) {
$attributes['title'] = $titles[$text];
}
else if (is_numeric($text)) {
$attributes['title'] = t('Go to page @number', array('@number' => $text));
}
}
return l($text, $_GET['q'], $attributes, count($query) ? implode('&', $query) : NULL, FALSE, FALSE, $html = TRUE);
}
theme-settings.php 5.x-3.x head
<?php
// $Id: theme-settings.php,v 1.3 2008/12/07 0829 Exp $
/**
* Implementation of themehook_settings().
*/
function phptemplate_settings($saved_settings) {
$defaults = array(
'diykit_skin' => 'none',
'diykit_layout' => 'fixed',
'diykit_column' => 'portal',
'diykit_breadcrumb' => 0,
);
$settings = array_merge($defaults, $saved_settings);
$form['diykit_skins'] = array(
'#type' => 'fieldset',
'#title' => t('Skin design'),
'#description' => t('Select the skin.'),
'#collapsible' => TRUE,
'#collapsed' => FALSE,
'#attributes' => array(
'class' => 'fieldset-skins',
),
);
$form['diykit_skins']['diykit_skin'] = array(
'#type' => 'radios',
'#default_value' => $settings['diykit_skin'],
'#options' => diykit_skinlist('screenshot'),
);
$form['diykit_layouts'] = array(
'#type' => 'fieldset',
'#title' => t('Layout design'),
'#description' => t('Select the page layout type and the layout type of columns position.'),
'#collapsible' => TRUE,
'#collapsed' => FALSE,
'#attributes' => array(
'class' => 'fieldset-layouts',
),
);
$form['diykit_layouts']['diykit_layout'] = array(
'#type' => 'select',
'#title' => t('Page layout'),
'#default_value' => $settings['diykit_layout'],
'#options' => array(
'fixed' => t('Fixed'),
'liquid' => t('Liquid'),
'flexible' => t('Flexible'),
),
);
$form['diykit_layouts']['diykit_column'] = array(
'#type' => 'select',
'#title' => t('Column layout'),
'#default_value' => $settings['diykit_column'],
'#options' => array(
'portal' => t('Portal'),
'news' => t('News'),
),
);
$form['diykit_options'] = array(
'#type' => 'fieldset',
'#title' => t('Other settings'),
'#collapsible' => TRUE,
'#collapsed' => FALSE,
'#attributes' => array(
'class' => 'fieldset-options',
),
);
$form['diykit_options']['diykit_breadcrumb'] = array(
'#type' => 'checkbox',
'#title' => t('Display the title in a list of breadcrumbs?'),
'#default_value' => $settings['diykit_breadcrumb'],
);
return $form;
}
function diykit_skinlist($type = '') {
$list['none'] = t('none');
$path = drupal_get_path('theme', 'diykit') .'/skin/';
if (file_exists($path)) {
$dir = dir($path);
while (FALSE !== ($skin = $dir->read())) {
if ($skin != '.' && $skin != '..') {
$screenshot = $path . $skin .'/screenshot.png';
$list[$skin] = t($skin);
if ($type == 'screenshot' && file_exists($screenshot)) {
$text = t('Screenshot for @skin', array('@skin' => t($skin)));
$list[$skin] .= '<br />';
$list[$skin] .= theme('image', $screenshot, $text, $text, array('class' => 'screenshot'), TRUE);
}
}
}
$dir->close();
}
return $list;
}
// $Id: theme-settings.php,v 1.3 2008/12/07 0829 Exp $
/**
* Implementation of themehook_settings().
*/
function phptemplate_settings($saved_settings) {
$defaults = array(
'diykit_skin' => 'none',
'diykit_layout' => 'fixed',
'diykit_column' => 'portal',
'diykit_breadcrumb' => 0,
);
$settings = array_merge($defaults, $saved_settings);
$form['diykit_skins'] = array(
'#type' => 'fieldset',
'#title' => t('Skin design'),
'#description' => t('Select the skin.'),
'#collapsible' => TRUE,
'#collapsed' => FALSE,
'#attributes' => array(
'class' => 'fieldset-skins',
),
);
$form['diykit_skins']['diykit_skin'] = array(
'#type' => 'radios',
'#default_value' => $settings['diykit_skin'],
'#options' => diykit_skinlist('screenshot'),
);
$form['diykit_layouts'] = array(
'#type' => 'fieldset',
'#title' => t('Layout design'),
'#description' => t('Select the page layout type and the layout type of columns position.'),
'#collapsible' => TRUE,
'#collapsed' => FALSE,
'#attributes' => array(
'class' => 'fieldset-layouts',
),
);
$form['diykit_layouts']['diykit_layout'] = array(
'#type' => 'select',
'#title' => t('Page layout'),
'#default_value' => $settings['diykit_layout'],
'#options' => array(
'fixed' => t('Fixed'),
'liquid' => t('Liquid'),
'flexible' => t('Flexible'),
),
);
$form['diykit_layouts']['diykit_column'] = array(
'#type' => 'select',
'#title' => t('Column layout'),
'#default_value' => $settings['diykit_column'],
'#options' => array(
'portal' => t('Portal'),
'news' => t('News'),
),
);
$form['diykit_options'] = array(
'#type' => 'fieldset',
'#title' => t('Other settings'),
'#collapsible' => TRUE,
'#collapsed' => FALSE,
'#attributes' => array(
'class' => 'fieldset-options',
),
);
$form['diykit_options']['diykit_breadcrumb'] = array(
'#type' => 'checkbox',
'#title' => t('Display the title in a list of breadcrumbs?'),
'#default_value' => $settings['diykit_breadcrumb'],
);
return $form;
}
function diykit_skinlist($type = '') {
$list['none'] = t('none');
$path = drupal_get_path('theme', 'diykit') .'/skin/';
if (file_exists($path)) {
$dir = dir($path);
while (FALSE !== ($skin = $dir->read())) {
if ($skin != '.' && $skin != '..') {
$screenshot = $path . $skin .'/screenshot.png';
$list[$skin] = t($skin);
if ($type == 'screenshot' && file_exists($screenshot)) {
$text = t('Screenshot for @skin', array('@skin' => t($skin)));
$list[$skin] .= '<br />';
$list[$skin] .= theme('image', $screenshot, $text, $text, array('class' => 'screenshot'), TRUE);
}
}
}
$dir->close();
}
return $list;
}
template.php 6.x-3.x head
<?php
// $Id: template.php,v 1.6 2009/05/25 0829 Exp $
/**
* Get theme setting values.
*/
if (is_null(theme_get_setting('diykit_skin'))) {
global $theme_key;
$themes = list_themes();
$defaults = $themes[$theme_key]->info['settings'];
$settings = theme_get_settings($theme_key);
if (module_exists('node')) {
foreach (node_get_types() as $type => $name) {
unset($settings['toggle_node_info_'. $type]);
}
}
variable_set(
str_replace('/', '_', 'theme_'. $theme_key .'_settings'),
array_merge($defaults, $settings)
);
theme_get_setting('', TRUE);
}
/**
* Override or insert PHPTemplate variables into the page.tpl.php.
*/
function phptemplate_preprocess_page(&$vars) {
global $theme;
// $xml
$user_agent = getenv('HTTP_USER_AGENT');
if (!(strpos($user_agent, 'Windows') !== FALSE && strpos($user_agent, 'MSIE 6') !== FALSE)) {
$vars['xml'] = '<?xml version="1.0" encoding="utf-8"?>'. "\n";
}
// $css, $styles, $iefix
$skin = theme_get_setting($theme .'_skin');
$iefix = $vars['directory'] .'/ie-fix.css';
$vars['iefix'] = '';
if (file_exists($iefix)) {
$vars['iefix'] .= '<!--[if IE]><link type="text/css" rel="stylesheet" media="all" href="'. base_path() . $iefix .'" /><![endif]-->'. "\n";
}
if ($skin != 'none') {
$css = $vars['directory'] .'/skin/'. $skin .'/skin.css';
$skin_iefix = $vars['directory'] .'/skin/'. $skin .'/ie-fix.css';
if (file_exists($css)) {
drupal_add_css($css, 'theme', 'all');
}
if (file_exists($skin_iefix)) {
$vars['iefix'] .= '<!--[if IE]><link type="text/css" rel="stylesheet" media="all" href="'. base_path() . $skin_iefix .'" /><![endif]-->'. "\n";
}
}
drupal_add_css($vars['directory'] .'/common.css', 'theme', 'all');
$vars['css'] = drupal_add_css();
$vars['styles'] = drupal_get_css();
// $body_classes
$body_classes = array($vars['body_classes']);
$body_classes[] = theme_get_setting($theme .'_layout');
$body_classes[] = theme_get_setting($theme .'_column');
$vars['body_classes'] = implode(' ', $body_classes);
}
/**
* Override or insert PHPTemplate variables into the node.tpl.php.
*/
function phptemplate_preprocess_node(&$vars) {
// $node_classes
$node_classes[] = 'node';
if ($vars['teaser']) {
$node_classes[] = 'teaser';
$node_classes[] = $vars['zebra'];
}
if ($vars['page']) {
$node_classes[] = 'page';
}
if ($vars['sticky']) {
$node_classes[] = 'sticky';
}
if (!$vars['status']) {
$node_classes[] = 'node-unpublished';
}
$vars['node_classes'] = implode(' ', $node_classes);
// $node_body_top, $node_body_bottom
if ($vars['page']) {
$vars['node_body_top'] = theme('blocks', 'node_body_top');
$vars['node_body_bottom'] = theme('blocks', 'node_body_bottom');
}
}
/**
* Override or insert PHPTemplate variables into the comment-wrapper.tpl.php.
*/
function phptemplate_preprocess_comment_wrapper(&$vars) {
// $comments_title
if ($vars['content'] && $vars['node']->type != 'forum') {
$vars['comments_title'] = t('Comments');
}
}
/**
* Override or insert PHPTemplate variables into the comment.tpl.php.
*/
function phptemplate_preprocess_comment(&$vars) {
global $user;
// $comment_classes
$comment_classes[] = 'comment';
if ($vars['comment']->new) {
$comment_classes[] = 'comment-new';
}
if ($vars['comment']->status == COMMENT_NOT_PUBLISHED) {
$comment_classes[] = 'comment-unpublished';
}
if ($vars['comment']->uid == $vars['node']->uid) {
$comment_classes[] = 'comment-by-author';
}
if ($user->uid && $vars['comment']->uid == $user->uid) {
$comment_classes[] = 'comment-mine';
}
if ($vars['comment']->uid) {
$comment_classes[] = 'comment-uid-'. $vars['comment']->uid;
}
$comment_classes[] = $vars['zebra'];
$vars['comment_classes'] = implode(' ', $comment_classes);
}
/**
* Override or insert PHPTemplate variables into the block.tpl.php.
*/
function phptemplate_preprocess_block(&$vars) {
// $block_classes
$block_classes[] = 'block';
$block_classes[] = 'block-'. $vars['block']->module;
$block_classes[] = $vars['zebra'];
$block_classes[] = $vars['block']->region .'-'. $vars['block_zebra'];
$block_classes[] = $vars['block']->region .'-'. $vars['block_id'];
$vars['block_classes'] = implode(' ', $block_classes);
}
/**
* Override theme functions.
*/
function phptemplate_links($links, $attributes = array('class' => 'links')) {
global $language;
$output = '';
if (count($links) > 0) {
$output = '<ul'. drupal_attributes($attributes) .'>';
$num_links = count($links);
$i = 1;
foreach ($links as $key => $link) {
$class = $key;
if ($i == 1) {
$class .= ' first';
}
if ($i == $num_links) {
$class .= ' last';
}
if (isset($link['href']) && ($link['href'] == $_GET['q'] || ($link['href'] == '<front>' && drupal_is_front_page()))
&& (empty($link['language']) || $link['language']->language == $language->language)) {
$class .= ' active';
}
$output .= '<li'. drupal_attributes(array('class' => $class)) .'>';
if (isset($link['href'])) {
$link['html'] = TRUE;
$output .= l('<span>'. $link['title'] .'</span>', $link['href'], $link);
}
else if (!empty($link['title'])) {
if (empty($link['html'])) {
$link['title'] = check_plain($link['title']);
}
$span_attributes = '';
if (isset($link['attributes'])) {
$span_attributes = drupal_attributes($link['attributes']);
}
$output .= '<span'. $span_attributes .'>'. $link['title'] .'</span>';
}
$i++;
$output .= "</li>\n";
}
$output .= '</ul>';
}
return $output;
}
function phptemplate_breadcrumb($breadcrumb) {
if (!empty($breadcrumb)) {
global $theme;
if (theme_get_setting($theme .'_breadcrumb') == 1 && $title = drupal_get_title()) {
$breadcrumb[] = '<span class="current">'. $title .'</span>';
}
return '<div class="breadcrumb">'. implode('<span class="breadcrumb-separate"> » </span>', $breadcrumb) .'</div>';
}
}
function phptemplate_feed_icon($url, $title) {
global $theme;
$skin = theme_get_setting($theme .'_skin');
$path = 'misc/feed.png';
if (is_file($file = path_to_theme() .'/skin/'. $skin .'/images/feed.png')) {
$path = $file;
}
else if (is_file($file = path_to_theme() .'/images/feed.png')) {
$path = $file;
}
if ($image = theme('image', $path, t('Syndicate content'), t('Syndicate content'), $title)) {
return '<a href="'. check_url($url) .'" class="feed-icon">'. $image .'</a>';
}
}
function phptemplate_mark($type = MARK_NEW) {
global $user;
if ($user->uid) {
if ($type == MARK_NEW) {
return '<span class="marker marker-new">'. t('new') .'</span>';
}
else if ($type == MARK_UPDATED) {
return '<span class="marker marker-update">'. t('updated') .'</span>';
}
}
}
function phptemplate_pager($tags = array(), $limit = 10, $element = 0, $parameters = array(), $quantity = 5) {
global $pager_page_array, $pager_total;
$pager_middle = ceil($quantity / 2);
$pager_current = $pager_page_array[$element] + 1;
$pager_first = $pager_current - $pager_middle + 1;
$pager_last = $pager_current + $quantity - $pager_middle;
$pager_max = $pager_total[$element];
$i = $pager_first;
if ($pager_last > $pager_max) {
$i = $i + ($pager_max - $pager_last);
$pager_last = $pager_max;
}
if ($i <= 0) {
$pager_last = $pager_last + (1 - $i);
$i = 1;
}
$li_first = theme('pager_first', (isset($tags[0]) ? $tags[0] : t('<span>«</span>First')), $limit, $element, $parameters);
$li_previous = theme('pager_previous', (isset($tags[1]) ? $tags[1] : t('<span>‹</span>Prev')), $limit, $element, 1, $parameters);
$li_next = theme('pager_next', (isset($tags[3]) ? $tags[3] : t('Next<span>›</span>')), $limit, $element, 1, $parameters);
$li_last = theme('pager_last', (isset($tags[4]) ? $tags[4] : t('Last<span>»</span>')), $limit, $element, $parameters);
if ($pager_total[$element] > 1) {
if ($li_first) {
$items[] = array(
'class' => 'pager-first',
'data' => $li_first,
);
}
if ($li_previous) {
$items[] = array(
'class' => 'pager-previous',
'data' => $li_previous,
);
}
if ($i != $pager_max) {
if ($i > 1) {
$items[] = array(
'class' => 'pager-ellipsis ellipsis-previous',
'data' => '<span class="pager-ellipsis">…</span>',
);
}
for (; $i <= $pager_last && $i <= $pager_max; $i++) {
if ($i < $pager_current) {
$items[] = array(
'class' => 'pager-item item-previous',
'data' => theme('pager_previous', $i, $limit, $element, ($pager_current - $i), $parameters),
);
}
if ($i == $pager_current) {
$items[] = array(
'class' => 'pager-current',
'data' => '<strong class="pager-current">'. $i .'</strong>',
);
}
if ($i > $pager_current) {
$items[] = array(
'class' => 'pager-item item-next',
'data' => theme('pager_next', $i, $limit, $element, ($i - $pager_current), $parameters),
);
}
}
if ($i < $pager_max) {
$items[] = array(
'class' => 'pager-ellipsis ellipsis-next',
'data' => '<span class="pager-ellipsis">…</span>',
);
}
}
if ($li_next) {
$items[] = array(
'class' => 'pager-next',
'data' => $li_next,
);
}
if ($li_last) {
$items[] = array(
'class' => 'pager-last',
'data' => $li_last,
);
}
return theme('item_list', $items, NULL, 'ul', array('id' => 'pager'));
}
}
function phptemplate_pager_link($text, $page_new, $element, $parameters = array(), $attributes = array()) {
$page = isset($_GET['page']) ? $_GET['page'] : '';
if ($new_page = implode(',', pager_load_array($page_new[$element], $element, explode(',', $page)))) {
$parameters['page'] = $new_page;
}
$query = array();
if (count($parameters)) {
$query[] = drupal_query_string_encode($parameters, array());
}
$querystring = pager_get_querystring();
if ($querystring != '') {
$query[] = $querystring;
}
if (!isset($attributes['title'])) {
static $titles = NULL;
if (!isset($titles)) {
$titles = array(
t('<span>«</span>First') => t('Go to first page'),
t('<span>‹</span>Prev') => t('Go to previous page'),
t('Next<span>›</span>') => t('Go to next page'),
t('Last<span>»</span>') => t('Go to last page'),
);
}
if (isset($titles[$text])) {
$attributes['title'] = $titles[$text];
}
else if (is_numeric($text)) {
$attributes['title'] = t('Go to page @number', array('@number' => $text));
}
}
return l($text, $_GET['q'], array('attributes' => $attributes, 'query' => count($query) ? implode('&', $query) : NULL, 'html' => TRUE));
}
// $Id: template.php,v 1.6 2009/05/25 0829 Exp $
/**
* Get theme setting values.
*/
if (is_null(theme_get_setting('diykit_skin'))) {
global $theme_key;
$themes = list_themes();
$defaults = $themes[$theme_key]->info['settings'];
$settings = theme_get_settings($theme_key);
if (module_exists('node')) {
foreach (node_get_types() as $type => $name) {
unset($settings['toggle_node_info_'. $type]);
}
}
variable_set(
str_replace('/', '_', 'theme_'. $theme_key .'_settings'),
array_merge($defaults, $settings)
);
theme_get_setting('', TRUE);
}
/**
* Override or insert PHPTemplate variables into the page.tpl.php.
*/
function phptemplate_preprocess_page(&$vars) {
global $theme;
// $xml
$user_agent = getenv('HTTP_USER_AGENT');
if (!(strpos($user_agent, 'Windows') !== FALSE && strpos($user_agent, 'MSIE 6') !== FALSE)) {
$vars['xml'] = '<?xml version="1.0" encoding="utf-8"?>'. "\n";
}
// $css, $styles, $iefix
$skin = theme_get_setting($theme .'_skin');
$iefix = $vars['directory'] .'/ie-fix.css';
$vars['iefix'] = '';
if (file_exists($iefix)) {
$vars['iefix'] .= '<!--[if IE]><link type="text/css" rel="stylesheet" media="all" href="'. base_path() . $iefix .'" /><![endif]-->'. "\n";
}
if ($skin != 'none') {
$css = $vars['directory'] .'/skin/'. $skin .'/skin.css';
$skin_iefix = $vars['directory'] .'/skin/'. $skin .'/ie-fix.css';
if (file_exists($css)) {
drupal_add_css($css, 'theme', 'all');
}
if (file_exists($skin_iefix)) {
$vars['iefix'] .= '<!--[if IE]><link type="text/css" rel="stylesheet" media="all" href="'. base_path() . $skin_iefix .'" /><![endif]-->'. "\n";
}
}
drupal_add_css($vars['directory'] .'/common.css', 'theme', 'all');
$vars['css'] = drupal_add_css();
$vars['styles'] = drupal_get_css();
// $body_classes
$body_classes = array($vars['body_classes']);
$body_classes[] = theme_get_setting($theme .'_layout');
$body_classes[] = theme_get_setting($theme .'_column');
$vars['body_classes'] = implode(' ', $body_classes);
}
/**
* Override or insert PHPTemplate variables into the node.tpl.php.
*/
function phptemplate_preprocess_node(&$vars) {
// $node_classes
$node_classes[] = 'node';
if ($vars['teaser']) {
$node_classes[] = 'teaser';
$node_classes[] = $vars['zebra'];
}
if ($vars['page']) {
$node_classes[] = 'page';
}
if ($vars['sticky']) {
$node_classes[] = 'sticky';
}
if (!$vars['status']) {
$node_classes[] = 'node-unpublished';
}
$vars['node_classes'] = implode(' ', $node_classes);
// $node_body_top, $node_body_bottom
if ($vars['page']) {
$vars['node_body_top'] = theme('blocks', 'node_body_top');
$vars['node_body_bottom'] = theme('blocks', 'node_body_bottom');
}
}
/**
* Override or insert PHPTemplate variables into the comment-wrapper.tpl.php.
*/
function phptemplate_preprocess_comment_wrapper(&$vars) {
// $comments_title
if ($vars['content'] && $vars['node']->type != 'forum') {
$vars['comments_title'] = t('Comments');
}
}
/**
* Override or insert PHPTemplate variables into the comment.tpl.php.
*/
function phptemplate_preprocess_comment(&$vars) {
global $user;
// $comment_classes
$comment_classes[] = 'comment';
if ($vars['comment']->new) {
$comment_classes[] = 'comment-new';
}
if ($vars['comment']->status == COMMENT_NOT_PUBLISHED) {
$comment_classes[] = 'comment-unpublished';
}
if ($vars['comment']->uid == $vars['node']->uid) {
$comment_classes[] = 'comment-by-author';
}
if ($user->uid && $vars['comment']->uid == $user->uid) {
$comment_classes[] = 'comment-mine';
}
if ($vars['comment']->uid) {
$comment_classes[] = 'comment-uid-'. $vars['comment']->uid;
}
$comment_classes[] = $vars['zebra'];
$vars['comment_classes'] = implode(' ', $comment_classes);
}
/**
* Override or insert PHPTemplate variables into the block.tpl.php.
*/
function phptemplate_preprocess_block(&$vars) {
// $block_classes
$block_classes[] = 'block';
$block_classes[] = 'block-'. $vars['block']->module;
$block_classes[] = $vars['zebra'];
$block_classes[] = $vars['block']->region .'-'. $vars['block_zebra'];
$block_classes[] = $vars['block']->region .'-'. $vars['block_id'];
$vars['block_classes'] = implode(' ', $block_classes);
}
/**
* Override theme functions.
*/
function phptemplate_links($links, $attributes = array('class' => 'links')) {
global $language;
$output = '';
if (count($links) > 0) {
$output = '<ul'. drupal_attributes($attributes) .'>';
$num_links = count($links);
$i = 1;
foreach ($links as $key => $link) {
$class = $key;
if ($i == 1) {
$class .= ' first';
}
if ($i == $num_links) {
$class .= ' last';
}
if (isset($link['href']) && ($link['href'] == $_GET['q'] || ($link['href'] == '<front>' && drupal_is_front_page()))
&& (empty($link['language']) || $link['language']->language == $language->language)) {
$class .= ' active';
}
$output .= '<li'. drupal_attributes(array('class' => $class)) .'>';
if (isset($link['href'])) {
$link['html'] = TRUE;
$output .= l('<span>'. $link['title'] .'</span>', $link['href'], $link);
}
else if (!empty($link['title'])) {
if (empty($link['html'])) {
$link['title'] = check_plain($link['title']);
}
$span_attributes = '';
if (isset($link['attributes'])) {
$span_attributes = drupal_attributes($link['attributes']);
}
$output .= '<span'. $span_attributes .'>'. $link['title'] .'</span>';
}
$i++;
$output .= "</li>\n";
}
$output .= '</ul>';
}
return $output;
}
function phptemplate_breadcrumb($breadcrumb) {
if (!empty($breadcrumb)) {
global $theme;
if (theme_get_setting($theme .'_breadcrumb') == 1 && $title = drupal_get_title()) {
$breadcrumb[] = '<span class="current">'. $title .'</span>';
}
return '<div class="breadcrumb">'. implode('<span class="breadcrumb-separate"> » </span>', $breadcrumb) .'</div>';
}
}
function phptemplate_feed_icon($url, $title) {
global $theme;
$skin = theme_get_setting($theme .'_skin');
$path = 'misc/feed.png';
if (is_file($file = path_to_theme() .'/skin/'. $skin .'/images/feed.png')) {
$path = $file;
}
else if (is_file($file = path_to_theme() .'/images/feed.png')) {
$path = $file;
}
if ($image = theme('image', $path, t('Syndicate content'), t('Syndicate content'), $title)) {
return '<a href="'. check_url($url) .'" class="feed-icon">'. $image .'</a>';
}
}
function phptemplate_mark($type = MARK_NEW) {
global $user;
if ($user->uid) {
if ($type == MARK_NEW) {
return '<span class="marker marker-new">'. t('new') .'</span>';
}
else if ($type == MARK_UPDATED) {
return '<span class="marker marker-update">'. t('updated') .'</span>';
}
}
}
function phptemplate_pager($tags = array(), $limit = 10, $element = 0, $parameters = array(), $quantity = 5) {
global $pager_page_array, $pager_total;
$pager_middle = ceil($quantity / 2);
$pager_current = $pager_page_array[$element] + 1;
$pager_first = $pager_current - $pager_middle + 1;
$pager_last = $pager_current + $quantity - $pager_middle;
$pager_max = $pager_total[$element];
$i = $pager_first;
if ($pager_last > $pager_max) {
$i = $i + ($pager_max - $pager_last);
$pager_last = $pager_max;
}
if ($i <= 0) {
$pager_last = $pager_last + (1 - $i);
$i = 1;
}
$li_first = theme('pager_first', (isset($tags[0]) ? $tags[0] : t('<span>«</span>First')), $limit, $element, $parameters);
$li_previous = theme('pager_previous', (isset($tags[1]) ? $tags[1] : t('<span>‹</span>Prev')), $limit, $element, 1, $parameters);
$li_next = theme('pager_next', (isset($tags[3]) ? $tags[3] : t('Next<span>›</span>')), $limit, $element, 1, $parameters);
$li_last = theme('pager_last', (isset($tags[4]) ? $tags[4] : t('Last<span>»</span>')), $limit, $element, $parameters);
if ($pager_total[$element] > 1) {
if ($li_first) {
$items[] = array(
'class' => 'pager-first',
'data' => $li_first,
);
}
if ($li_previous) {
$items[] = array(
'class' => 'pager-previous',
'data' => $li_previous,
);
}
if ($i != $pager_max) {
if ($i > 1) {
$items[] = array(
'class' => 'pager-ellipsis ellipsis-previous',
'data' => '<span class="pager-ellipsis">…</span>',
);
}
for (; $i <= $pager_last && $i <= $pager_max; $i++) {
if ($i < $pager_current) {
$items[] = array(
'class' => 'pager-item item-previous',
'data' => theme('pager_previous', $i, $limit, $element, ($pager_current - $i), $parameters),
);
}
if ($i == $pager_current) {
$items[] = array(
'class' => 'pager-current',
'data' => '<strong class="pager-current">'. $i .'</strong>',
);
}
if ($i > $pager_current) {
$items[] = array(
'class' => 'pager-item item-next',
'data' => theme('pager_next', $i, $limit, $element, ($i - $pager_current), $parameters),
);
}
}
if ($i < $pager_max) {
$items[] = array(
'class' => 'pager-ellipsis ellipsis-next',
'data' => '<span class="pager-ellipsis">…</span>',
);
}
}
if ($li_next) {
$items[] = array(
'class' => 'pager-next',
'data' => $li_next,
);
}
if ($li_last) {
$items[] = array(
'class' => 'pager-last',
'data' => $li_last,
);
}
return theme('item_list', $items, NULL, 'ul', array('id' => 'pager'));
}
}
function phptemplate_pager_link($text, $page_new, $element, $parameters = array(), $attributes = array()) {
$page = isset($_GET['page']) ? $_GET['page'] : '';
if ($new_page = implode(',', pager_load_array($page_new[$element], $element, explode(',', $page)))) {
$parameters['page'] = $new_page;
}
$query = array();
if (count($parameters)) {
$query[] = drupal_query_string_encode($parameters, array());
}
$querystring = pager_get_querystring();
if ($querystring != '') {
$query[] = $querystring;
}
if (!isset($attributes['title'])) {
static $titles = NULL;
if (!isset($titles)) {
$titles = array(
t('<span>«</span>First') => t('Go to first page'),
t('<span>‹</span>Prev') => t('Go to previous page'),
t('Next<span>›</span>') => t('Go to next page'),
t('Last<span>»</span>') => t('Go to last page'),
);
}
if (isset($titles[$text])) {
$attributes['title'] = $titles[$text];
}
else if (is_numeric($text)) {
$attributes['title'] = t('Go to page @number', array('@number' => $text));
}
}
return l($text, $_GET['q'], array('attributes' => $attributes, 'query' => count($query) ? implode('&', $query) : NULL, 'html' => TRUE));
}
theme-settings.php 6.x-3.x head
<?php
// $Id: theme-settings.php,v 1.3 2008/12/07 0829 Exp $
/**
* Implementation of themehook_settings().
*/
function phptemplate_settings($saved_settings) {
$themes = list_themes();
$defaults = $themes['diykit']->info['settings'];
$settings = array_merge($defaults, $saved_settings);
$form['diykit_skins'] = array(
'#type' => 'fieldset',
'#title' => t('Skin design'),
'#description' => t('Select the skin.'),
'#collapsible' => TRUE,
'#collapsed' => FALSE,
'#attributes' => array(
'class' => 'fieldset-skins',
),
);
$form['diykit_skins']['diykit_skin'] = array(
'#type' => 'radios',
'#default_value' => $settings['diykit_skin'],
'#options' => diykit_skinlist('screenshot'),
);
$form['diykit_layouts'] = array(
'#type' => 'fieldset',
'#title' => t('Layout design'),
'#description' => t('Select the page layout type and the layout type of columns position.'),
'#collapsible' => TRUE,
'#collapsed' => FALSE,
'#attributes' => array(
'class' => 'fieldset-layouts',
),
);
$form['diykit_layouts']['diykit_layout'] = array(
'#type' => 'select',
'#title' => t('Page layout'),
'#default_value' => $settings['diykit_layout'],
'#options' => array(
'fixed' => t('Fixed'),
'liquid' => t('Liquid'),
'flexible' => t('Flexible'),
),
);
$form['diykit_layouts']['diykit_column'] = array(
'#type' => 'select',
'#title' => t('Column layout'),
'#default_value' => $settings['diykit_column'],
'#options' => array(
'portal' => t('Portal'),
'news' => t('News'),
),
);
$form['diykit_options'] = array(
'#type' => 'fieldset',
'#title' => t('Other settings'),
'#collapsible' => TRUE,
'#collapsed' => FALSE,
'#attributes' => array(
'class' => 'fieldset-options',
),
);
$form['diykit_options']['diykit_breadcrumb'] = array(
'#type' => 'checkbox',
'#title' => t('Display the title in a list of breadcrumbs?'),
'#default_value' => $settings['diykit_breadcrumb'],
);
return $form;
}
function diykit_skinlist($type = '') {
$list['none'] = t('none');
$path = drupal_get_path('theme', 'diykit') .'/skin/';
if (file_exists($path)) {
$dir = dir($path);
while (FALSE !== ($skin = $dir->read())) {
if ($skin != '.' && $skin != '..') {
$screenshot = $path . $skin .'/screenshot.png';
$list[$skin] = t($skin);
if ($type == 'screenshot' && file_exists($screenshot)) {
$text = t('Screenshot for @skin', array('@skin' => t($skin)));
$list[$skin] .= '<br />';
$list[$skin] .= theme('image', $screenshot, $text, $text, array('class' => 'screenshot'), TRUE);
}
}
}
$dir->close();
}
return $list;
}
// $Id: theme-settings.php,v 1.3 2008/12/07 0829 Exp $
/**
* Implementation of themehook_settings().
*/
function phptemplate_settings($saved_settings) {
$themes = list_themes();
$defaults = $themes['diykit']->info['settings'];
$settings = array_merge($defaults, $saved_settings);
$form['diykit_skins'] = array(
'#type' => 'fieldset',
'#title' => t('Skin design'),
'#description' => t('Select the skin.'),
'#collapsible' => TRUE,
'#collapsed' => FALSE,
'#attributes' => array(
'class' => 'fieldset-skins',
),
);
$form['diykit_skins']['diykit_skin'] = array(
'#type' => 'radios',
'#default_value' => $settings['diykit_skin'],
'#options' => diykit_skinlist('screenshot'),
);
$form['diykit_layouts'] = array(
'#type' => 'fieldset',
'#title' => t('Layout design'),
'#description' => t('Select the page layout type and the layout type of columns position.'),
'#collapsible' => TRUE,
'#collapsed' => FALSE,
'#attributes' => array(
'class' => 'fieldset-layouts',
),
);
$form['diykit_layouts']['diykit_layout'] = array(
'#type' => 'select',
'#title' => t('Page layout'),
'#default_value' => $settings['diykit_layout'],
'#options' => array(
'fixed' => t('Fixed'),
'liquid' => t('Liquid'),
'flexible' => t('Flexible'),
),
);
$form['diykit_layouts']['diykit_column'] = array(
'#type' => 'select',
'#title' => t('Column layout'),
'#default_value' => $settings['diykit_column'],
'#options' => array(
'portal' => t('Portal'),
'news' => t('News'),
),
);
$form['diykit_options'] = array(
'#type' => 'fieldset',
'#title' => t('Other settings'),
'#collapsible' => TRUE,
'#collapsed' => FALSE,
'#attributes' => array(
'class' => 'fieldset-options',
),
);
$form['diykit_options']['diykit_breadcrumb'] = array(
'#type' => 'checkbox',
'#title' => t('Display the title in a list of breadcrumbs?'),
'#default_value' => $settings['diykit_breadcrumb'],
);
return $form;
}
function diykit_skinlist($type = '') {
$list['none'] = t('none');
$path = drupal_get_path('theme', 'diykit') .'/skin/';
if (file_exists($path)) {
$dir = dir($path);
while (FALSE !== ($skin = $dir->read())) {
if ($skin != '.' && $skin != '..') {
$screenshot = $path . $skin .'/screenshot.png';
$list[$skin] = t($skin);
if ($type == 'screenshot' && file_exists($screenshot)) {
$text = t('Screenshot for @skin', array('@skin' => t($skin)));
$list[$skin] .= '<br />';
$list[$skin] .= theme('image', $screenshot, $text, $text, array('class' => 'screenshot'), TRUE);
}
}
}
$dir->close();
}
return $list;
}

