/sites/all/themes/titan/template.php
PHP | 553 lines | 441 code | 48 blank | 64 comment | 109 complexity | 1c34eaffb21ee5303c46c211bd9a8702 MD5 | raw file
Possible License(s): GPL-2.0, LGPL-3.0, AGPL-1.0
- <?php
- // $Id: template.php,v 1.5 2011/01/10 13:46:19 jarek Exp $
- /**
- * Implements hook_css_alter().
- */
- function titan_css_alter(&$css) {
- unset($css[drupal_get_path('module', 'aggregator') . '/aggregator.css']);
- unset($css[drupal_get_path('module', 'block') . '/block.css']);
- unset($css[drupal_get_path('module', 'book') . '/book.css']);
- unset($css[drupal_get_path('module', 'comment') . '/comment.css']);
- unset($css[drupal_get_path('module', 'field') . '/theme/field.css']);
- unset($css[drupal_get_path('module', 'filter') . '/filter.css']);
- unset($css[drupal_get_path('module', 'forum') . '/forum.css']);
- unset($css[drupal_get_path('module', 'locale') . '/locale.css']);
- unset($css[drupal_get_path('module', 'node') . '/node.css']);
- unset($css[drupal_get_path('module', 'poll') . '/poll.css']);
- unset($css[drupal_get_path('module', 'search') . '/search.css']);
- unset($css[drupal_get_path('module', 'system') . '/system.css']);
- unset($css[drupal_get_path('module', 'system') . '/system.base.css']);
- unset($css[drupal_get_path('module', 'system') . '/system.behavior.css']);
- unset($css[drupal_get_path('module', 'system') . '/system.theme.css']);
- unset($css[drupal_get_path('module', 'system') . '/system.menus.css']);
- unset($css[drupal_get_path('module', 'system') . '/system.messages.css']);
- unset($css[drupal_get_path('module', 'user') . '/user.css']);
- unset($css['misc/vertical-tabs.css']);
- unset($css['misc/vertical-tabs-rtl.css']);
- }
- /**
- * Implements template_preprocess_html().
- */
- function titan_preprocess_html(&$variables) {
- // Add reset CSS
- drupal_add_css($data = path_to_theme() . '/reset.css', $options['type'] = 'file', $options['weight'] = CSS_SYSTEM - 1);
- // Add conditional stylesheet for IEs
- drupal_add_css(path_to_theme() . '/ie8.css', array('group' => CSS_THEME, 'browsers' => array('IE' => 'lte IE 8', '!IE' => FALSE), 'preprocess' => FALSE));
- drupal_add_css(path_to_theme() . '/ie7.css', array('group' => CSS_THEME, 'browsers' => array('IE' => 'lte IE 7', '!IE' => FALSE), 'preprocess' => FALSE));
-
- // Add "has-footer" class to body element. This class is used for styling page closure
- if (!empty($variables['page']['footer_column_first']) || !empty($variables['page']['footer_column_second']) || !empty($variables['page']['footer_column_third']) || !empty($variables['page']['footer_column_fourth'])) {
- $variables['classes_array'][] = 'has-footer';
- }
- }
- /**
- * Implements template_preprocess_page().
- */
- function titan_process_page(&$variables) {
- //echo "<pre>";print_r($variables['page']['header_menu']['system_main-menu']['800']['#href']); exit;
- // Add $footer_columns_number variable to page.tpl.php file
- $columns = 0;
- foreach (array('first', 'second', 'third', 'fourth') as $n) {
- if ($variables["page"]["footer_column_$n"]) {
- $columns++;
- }
- }
- $variables['footer_columns_number'] = $columns;
- //echo "<pre>"; print_r($variables['page']['header_top']['system_user-menu']['775']['#href']); exit;
- //if($variables['page']['header_top']['system_user-menu']){
- global $user;
- $userid=$user->uid;
- //$menu_names = menu_get_names();
- //$menu = menu_load_links('secondary_menu');
- //$menu_entity=menu_load('secondary_menu');
- $variables['page']['header_top']['system_user-menu']['775']['#href']='user/'. $userid .'/edit/';
- //}
- }
- /**
- * Implements template_preprocess_block().
- */
- function titan_preprocess_block(&$variables) {
- // Remove "block" class from blocks in "Main page content" region
- if ($variables['elements']['#block']->region == 'content') {
- foreach ($variables['classes_array'] as $key => $val) {
- if ($val == 'block') {
- unset($variables['classes_array'][$key]);
- }
- }
- }
- $variables['classes_array'][] = 'block-content';
- }
- /**
- * Implements template_preprocess_comment().
- */
- function titan_preprocess_comment(&$variables) {
- // Change permalink text from "#" to "permalink"
- $comment = $variables['elements']['#comment'];
- $variables['permalink'] = l('permalink', 'comment/' . $comment->cid, array('fragment' => "comment-$comment->cid"));
- }
- /**
- * Overrides theme_more_link().
- */
- function titan_more_link($variables) {
- /* Append arrow */
- return '<div class="more-link">' . t('<a href="@link" title="@title">more ›</a>', array('@link' => check_url($variables['url']), '@title' => $variables['title'])) . '</div>';
- }
- /**
- * Overrides theme_messages().
- */
- function titan_messages($variables) {
- // If there are serveral messages, print them in separate divs.
- $display = $variables['display'];
- $output = '';
- $status_heading = array(
- 'status' => t('Status message'),
- 'error' => t('Error message'),
- 'warning' => t('Warning message'),
- );
- foreach (drupal_get_messages($display) as $type => $messages) {
- if (!empty($status_heading[$type])) {
- $output .= '<h2 class="element-invisible">' . $status_heading[$type] . "</h2>\n";
- }
- foreach ($messages as $message) {
- $output .= "<div class=\"messages message-$type\">\n";
- $output .= $message;
- $output .= "</div>\n";
- }
- }
- return $output;
- }
- /**
- * Overrides theme_node_recent_block().
- */
- function titan_node_recent_block($variables) {
- // Make output for "Recent content" block consistent with other blocks
- $output = '';
- foreach ($variables['nodes'] as $node) {
- $items[] = theme('node_recent_content', array('node' => $node));
- }
- if (user_access('access content overview')) {
- $items[] = theme('more_link', array('url' => url('admin/content'), 'title' => t('more ›')));
- }
- return theme('item_list', array('items' => $items));
- }
- /**
- * Overrides theme_node_recent_content().
- */
- function titan_node_recent_content($variables) {
- // Make output for "Recent content" block consistent with other blocks
- $node = $variables['node'];
- $output = l($node->title, 'node/' . $node->nid);
- $output .= theme('mark', array('type' => node_mark($node->nid, $node->changed)));
- return $output;
- }
- /**
- * Override of theme_pager().
- */
- function titan_pager($variables) {
- // Reimplement the pager
- $tags = $variables['tags'];
- $element = $variables['element'];
- $parameters = $variables['parameters'];
- $pager_width = theme_get_setting('trim_pager');
- global $pager_page_array, $pager_total;
- $li_previous = theme('pager_previous', array('text' => (isset($tags[1]) ? $tags[1] : t('‹ previous')), 'element' => $element, 'interval' => 1, 'parameters' => $parameters));
- $li_next = theme('pager_next', array('text' => (isset($tags[3]) ? $tags[3] : t('next ›')), 'element' => $element, 'interval' => 1, 'parameters' => $parameters));
- $total_number_of_pages = $pager_total[$element];
- $current_page_number = $pager_page_array[$element] + 1;
- /* If there is just one page we don't need a pager. */
- if ($total_number_of_pages <= 1) {
- return;
- }
- /* Elipsis does not make sense if there is just one page more than the pager width. */
- if ($total_number_of_pages - $pager_width == 1) {
- $pager_width++;
- }
- /* Genarate pager without any elipsis */
- if ($total_number_of_pages <= $pager_width) {
- if ($li_previous) {
- $items[] = array('class' => array('pager-previous'), 'data' => $li_previous,);
- }
- for ($i = 1; $i <= $total_number_of_pages; $i++) {
- if ($i < $current_page_number) {
- $items[] = array('class' => array('pager-item'), 'data' => theme('pager_previous', array('text' => $i, 'element' => $element, 'interval' => ($current_page_number - $i), 'parameters' => $parameters)) );
- }
- if ($i == $current_page_number) {
- $items[] = array('class' => array('pager-current'), 'data' => $i);
- }
- if ($i > $current_page_number) {
- $items[] = array('class' => array('pager-item'), 'data' => theme('pager_next', array('text' => $i, 'element' => $element, 'interval' => ($i - $current_page_number), 'parameters' => $parameters)) );
- }
- }
- if ($li_next) {
- $items[] = array('class' => array('pager-next'), 'data' => $li_next );
- }
- }
- /* Genarate pager with elipsis */
- if ($total_number_of_pages > $pager_width) {
- /* Genarate pager with elpisis on right side. */
- if ($current_page_number < $pager_width) {
- if ($li_previous) {
- $items[] = array('class' => array('pager-previous'), 'data' => $li_previous,);
- }
- for ($i = 1; $i <= $pager_width; $i++) {
- if ($i < $current_page_number) {
- $items[] = array('class' => array('pager-item'), 'data' => theme('pager_previous', array('text' => $i, 'element' => $element, 'interval' => ($current_page_number - $i), 'parameters' => $parameters)) );
- }
- if ($i == $current_page_number) {
- $items[] = array('class' => array('pager-item pager-current'), 'data' => $i);
- }
- if ($i > $current_page_number) {
- $items[] = array('class' => array('pager-item'), 'data' => theme('pager_next', array('text' => $i, 'element' => $element, 'interval' => ($i - $current_page_number), 'parameters' => $parameters)) );
- }
- }
- $items[] = array(
- 'class' => array('pager-ellipsis'),
- 'data' => '…',
- );
- $items[] = array('class' => array('pager-item'), 'data' => theme('pager_last', array('text' => $total_number_of_pages, 'element' => $element, 'interval' => 1, 'parameters' => $parameters)) );
- $items[] = array('class' => array('pager-next'), 'data' => $li_next );
- }
- /* Genarate pager with elpisis on both sides. */
- if($current_page_number >= $pager_width && $current_page_number <= $total_number_of_pages - $pager_width + 1) {
- if ($li_previous) {
- $items[] = array('class' => array('pager-previous'), 'data' => $li_previous,);
- }
- $items[] = array('class' => array('pager-item'), 'data' => theme('pager_first', array('text' => "1", 'element' => $element, 'interval' => 1, 'parameters' => $parameters)) );
- $items[] = array(
- 'class' => array('pager-ellipsis'),
- 'data' => '…',
- );
- function isEven($num){
- return ($num%2) ? TRUE : FALSE;
- }
- if (isEven($pager_width) == TRUE) {
- $a = floor($pager_width/2);
- }
- if (isEven($pager_width) == FALSE) {
- $a = floor($pager_width/2) - 1;
- }
- for ($i = $current_page_number - $a; $i <= $current_page_number + floor($pager_width/2); $i++) {
- if ($i < $current_page_number) {
- $items[] = array('class' => array('pager-item'), 'data' => theme('pager_previous', array('text' => $i, 'element' => $element, 'interval' => ($current_page_number - $i), 'parameters' => $parameters)) );
- }
- if ($i == $current_page_number) {
- $items[] = array('class' => array('pager-current'), 'data' => $i);
- }
- if ($i > $current_page_number) {
- $items[] = array('class' => array('pager-item'), 'data' => theme('pager_next', array('text' => $i, 'element' => $element, 'interval' => ($i - $current_page_number), 'parameters' => $parameters)) );
- }
- }
- $items[] = array(
- 'class' => array('pager-ellipsis'),
- 'data' => '…',
- );
- $items[] = array('class' => array('pager-item'), 'data' => theme('pager_last', array('text' => $total_number_of_pages, 'element' => $element, 'interval' => 1, 'parameters' => $parameters)) );
- $items[] = array('class' => array('pager-next'), 'data' => $li_next );
- }
- /* Genarate pager with elpisis on left side. */
- if($current_page_number >= $pager_width && $current_page_number > $total_number_of_pages - $pager_width + 1) {
- if ($li_previous) {
- $items[] = array('class' => array('pager-previous'), 'data' => $li_previous,);
- }
- $items[] = array('class' => array('pager-item'), 'data' => theme('pager_first', array('text' => "1", 'element' => $element, 'interval' => 1, 'parameters' => $parameters)) );
- $items[] = array(
- 'class' => array('pager-ellipsis'),
- 'data' => '…',
- );
- for ($i = $total_number_of_pages - $pager_width + 1; $i <= $total_number_of_pages; $i++) {
- if ($i < $current_page_number) {
- $items[] = array('class' => array('pager-item'), 'data' => theme('pager_previous', array('text' => $i, 'element' => $element, 'interval' => ($current_page_number - $i), 'parameters' => $parameters)) );
- }
- if ($i == $current_page_number) {
- $items[] = array('class' => array('pager-current'), 'data' => $i);
- }
- if ($i > $current_page_number) {
- $items[] = array('class' => array('pager-item'), 'data' => theme('pager_next', array('text' => $i, 'element' => $element, 'interval' => ($i - $current_page_number), 'parameters' => $parameters)) );
- }
- }
- $items[] = array('class' => array('pager-next'), 'data' => $li_next );
- }
- }
- /* Print generated pager */
- return '<h2 class="element-invisible">' . t('Pages') . '</h2>' . theme('item_list', array('items' => $items, 'title' => NULL, 'type' => 'ul', 'attributes' => array('class' => array('pager'))));
- }
- function titan_preprocess_page(&$variables, $hook){
- //echo "<pre>"; print_r($variables);exit;
- if(isset($variables['node'])){
- switch($variables['node']->nid){
- case '38':
- $variables['title'] = '';
- $variables['tabs'] = '';
- $variables['action_links'] = '';
- $variables['breadcrumb'] = '';
- break;
- case '44':
- $variables['title'] = '';
- $variables['tabs'] = '';
- $variables['action_links'] = '';
- $variables['breadcrumb'] = '';
- break;
- case '45':
- $variables['title'] = '';
- $variables['tabs'] = '';
- $variables['action_links'] = '';
- $variables['breadcrumb'] = '';
- break;
- case '68':
- $variables['title'] = '';
- $variables['tabs'] = '';
- $variables['action_links'] = '';
- //$variables['breadcrumb'] = '';
- break;
- case '61':
- $variables['title'] = '';
- $variables['tabs'] = '';
- $variables['action_links'] = '';
- $variables['breadcrumb'] = '';
- break;
- case '75':
- $variables['node']->title = '';
- $variables['tabs'] = '';
- $variables['action_links'] = '';
- $variables['breadcrumb'] = '';
- break;
- }
- }
- if(isset($_SESSION['nid']) && $_SESSION['show_announcement'] == true){
- $variables['show_announcement'] = true;
- $_SESSION['show_announcement']= false;
- }
- }
- function titan_breadcrumb(&$variables) {
- $breadcrumb = $variables['breadcrumb'];
- if(isset($breadcrumb[0])){
- $breadcrumb[0] = l('Home','<front>',array('attributes' => array('class' => array('home'),'title' => 'Home')));
- }
- $argument = arg();
- if ($argument[0]=='company-directory') {
- $breadcrumb[1] = l('People', 'company-directory');
-
- }
- if($argument[0]=='user'){
- $breadcrumb =NULL;
- }
-
- if ($argument[0]=='user'){
- if(isset($argument[1])){
- if($argument[1]!='register')
- {
- $breadcrumb_query = db_select('profile', 'p');
- $breadcrumb_data=$breadcrumb_query->fields('p', array('pid'))
- ->condition('p.uid', $argument[1], '=')
- ->execute();
- $breadcrumb_obj = $breadcrumb_data->fetchObject();
- //echo "<pre>";print_r($breadcrumb_obj->pid);exit;
- $cpid=$breadcrumb_obj->pid;
- $query = db_select('field_data_field_first_name','f');
- $query_data=$query->fields('f',array('field_first_name_value'))
- ->condition('f.entity_id',$cpid,'=')
- ->execute();
- $query_obj=$query_data->fetchObject();
- // echo "<pre>";print_r($query_obj->field_first_name_value);exit;
- $breadcrumb[0] = l('Home','<front>',array('attributes' => array('class' => array('home'),'title' => 'Home')));
- $breadcrumb[1] = l('People', 'company-directory');
- $breadcrumb[2] = l($query_obj->field_first_name_value, 'user/' . $argument[1]);
- }
- }
- }
- if ($argument[0]=='user'){
- if(isset($argument[1] )){
- if($argument[1]=='register'){
- $breadcrumb =NULL;
- }
- }
- }
- if ($argument[0]=='user'){
- if( isset($argument[2]) && $argument[2]=='edit'){
-
-
- $breadcrumb_query = db_select('profile', 'p');
- $breadcrumb_data=$breadcrumb_query->fields('p', array('pid'))
- ->condition('p.uid', $argument[1], '=')
- ->execute();
- $breadcrumb_obj = $breadcrumb_data->fetchObject();
- //echo "<pre>";print_r($breadcrumb_obj->pid);exit;
- $cpid=$breadcrumb_obj->pid;
- $query = db_select('field_data_field_first_name','f');
- $query_data=$query->fields('f',array('field_first_name_value'))
- ->condition('f.entity_id',$cpid,'=')
- ->execute();
- $query_obj=$query_data->fetchObject();
-
- $breadcrumb[1] = l('People', 'company-directory');
- $breadcrumb[2] = l($query_obj->field_first_name_value, 'user/' . $argument[1]);
- $breadcrumb[3] = l('Edit', 'user/' . $argument[1].'/edit');
- }
- }
- if ($argument[0]=='user'){
- if( isset($argument[2]) && $argument[2]=='followers-list'){
-
-
- $breadcrumb_query = db_select('profile', 'p');
- $breadcrumb_data=$breadcrumb_query->fields('p', array('pid'))
- ->condition('p.uid', $argument[1], '=')
- ->execute();
- $breadcrumb_obj = $breadcrumb_data->fetchObject();
- //echo "<pre>";print_r($breadcrumb_obj->pid);exit;
- $cpid=$breadcrumb_obj->pid;
- $query = db_select('field_data_field_first_name','f');
- $query_data=$query->fields('f',array('field_first_name_value'))
- ->condition('f.entity_id',$cpid,'=')
- ->execute();
- $query_obj=$query_data->fetchObject();
-
- $breadcrumb[1] = l('People', 'company-directory');
- $breadcrumb[2] = l($query_obj->field_first_name_value, 'user/' . $argument[1]);
- $breadcrumb[3] = l('Followers List', 'user/' . $argument[1].'/followers-list');
- }
- }
- if ($argument[0]=='node'){
- if( isset($argument[2]) && $argument[2]=='code'){
- $breadcrumb[1] = l('Snippet', 'node/61');
- $breadcrumb[2] = l('Create', 'node/add/code');
-
- }
- }
- if ($argument[0]=='node'){
- if( isset($argument[2]) && $argument[2]=='reply-to-post'){
- $breadcrumb[1] ='Reply';
- //$breadcrumb[2] = l('Create', 'node/add/');
-
- }
- }
- if ($argument[0]=='snippet'){
- $breadcrumb[1] = l('Snippet', 'node/61');
- $breadcrumb[2] = l('View', 'snippet');
- }
- if ($argument[0]=='node'){
-
- if( isset($argument[2]) && $argument[2]=='question'){
- $breadcrumb[1] = l('Solution Bucket', 'questions/all');
- $breadcrumb[2] = l('Ask a new question', 'node/add/question');
-
- }
- }
-
- if ($argument[0]=='questions' ){
- if(isset($argument[1]) && $argument[1]=='all'){
- $breadcrumb[0] = l('Home','<front>',array('attributes' => array('class' => array('home'),'title' => 'Home')));
- $breadcrumb[1] = l('Solution Bucket', 'questions/all');
- $breadcrumb[2] = l('View all questions', 'questions/all');}
-
-
- }
- if ($argument[0]=='questions' ){
- if(isset($argument[1])&& $argument[1]=='unanswered'){
- $breadcrumb[1] = l('Solution Bucket', 'questions/all');
- $breadcrumb[2] = l('View unanswered questions', 'questions/unanswered');
- }
- }
- if ($argument[0]=='questions'){
- if(isset($argument[1])&& $argument[1]=='search'){
- $breadcrumb[1] = l('Solution Bucket', 'questions/all');
- $breadcrumb[2] = l('Search for a question', 'questions/search');
- }
- }
- if($argument[0]=='questions'){
- if(!isset($argument[1])){
- $breadcrumb[1] = l('Solution Bucket', 'questions/all');
- $breadcrumb[2] = l('All Questions', 'questions');
- }
-
- }
-
- if ($argument[0]=='node'){
- if( isset($argument[2]) && $argument[2]=='announcement'){
- $breadcrumb[1] = l('Announcements', 'node/44');
- $breadcrumb[2] = l('Create', 'node/add/announcement');
- }
- }
- if ($argument[0]=='announcement'){
- $breadcrumb[1] = l('Announcements', 'node/44');
- $breadcrumb[2] = l('View', 'announcement');
- }
- if ($argument[0]=='node'){
- if( isset($argument[2]) && $argument[2]=='events'){
- $breadcrumb[1] = l('Events', 'node/45');
- $breadcrumb[2] = l('Create', 'node/add/events');
- }
- }
- if ($argument[0]=='events'){
- $breadcrumb[1] = l('Events', 'node/45');
- $breadcrumb[2] = l('View', 'events');
- }
- if ($argument[0]=='notifications'){
- $breadcrumb[1] = l('Notifications', 'notifications');
- }
- if ($argument[0]=='node'){
- if( isset($argument[2]) && $argument[2]=='add-item'){
- $breadcrumb[1] = l('Market Place', 'node/38');
- $breadcrumb[2] = l('Add an Item', 'node/add/add-item');
- }
- }
- if ($argument[0]=='node'){
- if( isset($argument[2]) && $argument[2]=='request-item'){
- $breadcrumb[1] = l('Market Place', 'node/38');
- $breadcrumb[2] = l('Request an Item', 'node/add/request-item');
- }
- }
- if ($argument[0]=='items-wanted'){
- $breadcrumb[1] = l('Market Place', 'node/38');
- $breadcrumb[2] = l('Items Required', 'items-wanted');
- }
- if ($argument[0]=='items-for-sale'){
- $breadcrumb[1] = l('Market Place', 'node/38');
- $breadcrumb[2] = l('Items for Sale', 'items-for-sale');
- }
- if ($argument[0]=='freebies'){
- $breadcrumb[1] = l('Market Place', 'node/38');
- $breadcrumb[2] = l('Freebies', 'freebies');
- }
- if ($argument[0]=='all-items'){
- $breadcrumb[1] = l('Market Place', 'node/38');
- $breadcrumb[2] = l('All Items', 'all-items');
- }
- if ($argument[0]=='your-item'){
- $breadcrumb[1] = l('Market Place', 'node/38');
- $breadcrumb[2] = l('Your Items', 'your-item');
- }
- if(!empty($breadcrumb)){
- $output = '<div class="breadcrumb">' . implode('» ', $breadcrumb) . '</div>';
- return $output;
- }
-
-
- }