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

