<?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;
}

