AlkantarClanX12

Your IP : 216.73.217.128


Current Path : /var/www/clients/client1/web1/web/sites/all/themes/hawell/
Upload File :
Current File : /var/www/clients/client1/web1/web/sites/all/themes/hawell/template.php

<?php
global $base_url;

function hawell_preprocess_html(&$variables) {
	// GOOGLE FONT
	drupal_add_css('http://fonts.googleapis.com/css?family=Lato:300,400,700%7COpen+Sans:400,300,700', array('type' => 'external','scope' => 'header'));
	// GOOGLE MAP
	//drupal_add_js(base_path().path_to_theme().'/js/jquery-1.11.2.min.js', array('type' => 'external','scope' => 'header'));
	drupal_add_js('http://maps.google.com/maps/api/js?sensor=false&amp;language=en', array('type' => 'external','scope' => 'header'));

	if (arg(0) == 'node' && is_numeric(arg(1))) {
      $node = entity_load_unchanged('node', arg(1));

      if (isset($node ->field_boxed['und'][0]['value']) && $node ->field_boxed['und'][0]['value']) {
        $variables['home_boxed'] = $node ->field_boxed['und'][0]['value'];
      }
    }
}


// Add css skin
$setting_skin = theme_get_setting('built_in_skins', 'hawell');
if(!empty($setting_skin)){
	$skin_color = '/css/skins/'.$setting_skin;
}else{
	$skin_color = '/css/skins/default.css';
}
$css_skin = array(
	'#tag' => 'link', // The #tag is the html tag - <link />
	'#attributes' => array( // Set up an array of attributes inside the tag
	'href' => $base_url.'/'.path_to_theme().$skin_color,
	'rel' => 'stylesheet',
	'type' => 'text/css',
	'id' => 'skin',
	'data-baseurl'=>$base_url.'/'.path_to_theme()
	),
	'#weight' => 1,
);
//drupal_add_html_head($css_skin, 'skin');

function hawell_form_comment_form_alter(&$form, &$form_state) {
  $form['comment_body']['#after_build'][] = 'hawell_customize_comment_form';
	// echo '<pre>'; print_r($form['#id']);echo '</pre>';
   	$form['#action']=false;
	$form['author']['name']['#required'] = TRUE;
}

function hawell_customize_comment_form(&$form) {
  $form[LANGUAGE_NONE][0]['format']['#access'] = FALSE;
  return $form;
}

function hawell_preprocess_page(&$vars) {

	if (isset($vars['node'])) {
		$vars['theme_hook_suggestions'][] = 'page__'. $vars['node']->type;
	}

	//404 page
	$status = drupal_get_http_header("status");
	if($status == "404 Not Found") {
		$vars['theme_hook_suggestions'][] = 'page__404';
	}

	//Taxonomy page
	if (arg(0) == 'taxonomy') {
    	$vars['theme_hook_suggestions'][] = 'page__taxonomy';
  	}

	//View portfolio template
	$views_page = views_get_page_view();
  	if(isset($views_page) && $views_page->name =='_hawell_page_portfoilio')   {
    	$vars['theme_hook_suggestions'][] = 'page__views_portfolio';
	}

	//View shop template
	$views_page = views_get_page_view();
  	if(isset($views_page) && $views_page->name =='_hawell_page_shop')   {
    	$vars['theme_hook_suggestions'][] = 'page__shop';
	}

}


// Remove superfish css files.
function hawell_css_alter(&$css) {
	unset($css[drupal_get_path('module', 'system') . '/system.menus.css']);
	unset($css[drupal_get_path('module', 'system') . '/system.theme.css']);

//	unset($css[drupal_get_path('module', 'system') . '/system.base.css']);
}

function hawell_form_alter(&$form, &$form_state, $form_id) {
	if ($form_id == 'search_block_form') {
		//print_r($form);
		$form['actions']['submit']['#value'] = '';
		$form['search_block_form']['#title_display'] = 'invisible'; // Toggle label visibilty
		$form['search_block_form']['#default_value'] = t('Search'); // Set a default value for the textfield
		$form['search_block_form']['#attributes']['id'] = array("mod-search-searchword");
		//disabled submit button
		//unset($form['actions']['submit']);
		unset($form['search_block_form']['#title']);
		$form['search_block_form']['#attributes']['onblur'] = "if (this.value == '') {this.value = 'Search';}";
		$form['search_block_form']['#attributes']['onfocus'] = "if (this.value == 'Search') {this.value = '';}";
	}
	if($form_id == 'contact_site_form'){
		$form['mail']['#attributes']['class'] = array("input-contact-form");
		$form['name']['#attributes']['class'] = array("input-contact-form");
		$form['subject']['#attributes']['class'] = array("input-contact-form");
		$form['message']['#attributes']['class'] = array("message-contact-form");
		$form['actions']['submit']['#attributes']['class'] = array('btn btn-success contact-form-button');
	}
	if ($form_id == 'comment_form') {
		$form['comment_filter']['format'] = array(); // nuke wysiwyg from comments
		
	}

}


function hawell_textarea($variables) {
  $element = $variables['element'];
  $element['#attributes']['name'] = $element['#name'];
  $element['#attributes']['id'] = $element['#id'];
  $element['#attributes']['cols'] = $element['#cols'];
  $element['#attributes']['rows'] = $element['#rows'];
  _form_set_class($element, array('form-textarea'));

  $wrapper_attributes = array(
    'class' => array('form-textarea-wrapper'),
  );

  // Add resizable behavior.
  if (!empty($element['#resizable'])) {
    $wrapper_attributes['class'][] = 'resizable';
  }

  $output = '<div' . drupal_attributes($wrapper_attributes) . '>';
  $output .= '<textarea' . drupal_attributes($element['#attributes']) . '>' . check_plain($element['#value']) . '</textarea>';
  $output .= '</div>';
  return $output;
}
function hawell_breadcrumb($variables) {
	$crumbs ='';
	$breadcrumb = $variables['breadcrumb'];
	if (!empty($breadcrumb)) {
		$crumbs .= '<div class="breadcrumbs">';
		$crumbs .= $breadcrumb[0].'<span class="slash-divider">/</span>';
		if(isset($breadcrumb[1])) {
			$crumbs .= $breadcrumb[1].'<span class="slash-divider">/</span>';
		}
		$crumbs .= '<span class="bread-current">'.drupal_get_title().'</span>';
		return $crumbs .'</div>';
	}else{
		return NULL;
	}
}
//custom main menu
function hawell_menu_tree__main_menu(array $variables) {
	$str = '';
	$str .= '<ul class="nav navbar-nav">';
		$str .= $variables['tree'];
	$str .= '</ul>';

	return $str;
}


/**Override Menu theme */

function hawell_menu_tree__menu_top_menu($variables) {
	$str = '';
	$str .= '<ul class="top-bar-section right">';
		$str .= $variables['tree'];
	$str .= '</ul>';

	return $str;
}

function hawell_menu_tree__menu_footer_menu($variables) {
	$str = '';
	$str .= '<ul class="links-list bold a-text-cont">';
		$str .= $variables['tree'];
	$str .= '</ul>';

	return $str;
}

function hawell_menu_tree__menu_min_menu($variables) {
	$str = '';
	$str .= '<ul class="block-center-xy">';
		$str .= $variables['tree'];
	$str .= '</ul>';

	return $str;
}

function hawell_menu_tree__menu_side_menu($variables) {
	$str = '';
	$str .= '<ul class="nav navbar-nav">';
		$str .= $variables['tree'];
	$str .= '</ul>';

	return $str;
}

function hawell_theme() {
  return array(
    'comment_form' => array(
      'arguments' => array('form' => NULL),
      'template' => 'tpl/comment-form',
      'render element' => 'form'
    ),
  );
}

function hook_preprocess_page(&$variables) {
       if (arg(0) == 'node' && is_numeric($nid)) {
    if (isset($variables['page']['content']['system_main']['nodes'][$nid])) {
      $variables['node_content'] =& $variables['page']['content']['system_main']['nodes'][$nid];
      if (empty($variables['node_content']['field_show_page_title'])) {
        $variables['node_content']['field_show_page_title'] = NULL;
      }
    }
  }
}


function getRelatedPosts($ntype,$nid,$image){
	$nids = db_query("SELECT n.nid, title FROM {node} n WHERE n.status = 1 AND n.type = :type AND n.nid <> :nid ORDER BY RAND() LIMIT 0,6", array(':type' => $ntype, ':nid' => $nid))->fetchCol();
	$nodes = node_load_multiple($nids);
	$return_string = '<div class="row related-posts">' ;
	$i = 0;
	if (!empty($nodes)):
		foreach ($nodes as $node) :
			$field_image = field_get_items('node', $node, $image);
		if (!empty($field_image[0]) && $i < 3) {
			$i++;
			$return_string .= '<div class="col-sm-6 col-md-4 col-lg-4 wow fadeIn pb-50" >';
			$return_string .= '<div class="post-prev-img">';
			$return_string .= '<a href="'.url("node/" . $node->nid).'">';
			$return_string .= theme('image_style', array('style_name' => 'image_650x415', 'path' => $field_image[0]['uri'], 'attributes'=>array('alt'=>$node->title)));
			$return_string .= '</a></div>';
			$return_string .= '<div class="post-prev-title"><h3>';
			$return_string .= '<a href="'.url("node/" . $node->nid).'">'.$node->title.'</a></h3></div>';
			$return_string .= '<div class="post-prev-info">'.format_date($node->created, 'custom', 'd F Y').'<span class="slash-divider">/</span>';
			$return_string .= $node->name.'</div></div>';
		}
		endforeach;
	endif;
	return $return_string.'</div>';
}

function hawell_menu_link(array $variables) {
  	$element = $variables['element'];
  	$sub_menu = '';
  	if($element['#original_link']['menu_name'] == 'main-menu' || $element['#original_link']['menu_name'] == 'menu-side-menu') {

	  	if ($element['#below'] && $element['#original_link']['depth'] == 1) {
	  		unset($element['#below']['#theme_wrappers']);
	  		$element['#attributes']['class'][] = 'level-' . $element['#original_link']['depth'];
	  		$element['#attributes']['class'][] = 'parent';
	    	$sub_menu = '<ul class="sub">'.drupal_render($element['#below']).'</ul>';
	  	} elseif ($element['#below'] && $element['#original_link']['depth'] != 1) {
	  		unset($element['#below']['#theme_wrappers']);
	  		$element['#attributes']['class'][] = 'parent';
	  		$sub_menu = '<ul class="sub">'.drupal_render($element['#below']).'</ul>';
	  	} else {
	  		$element['#attributes']['class'][] = 'level-' . $element['#original_link']['depth'];
	  	}
	  	$output = l($element['#title'], $element['#href'], $element['#localized_options']);

	} else {
		if ($element['#below']) {
	    $sub_menu = drupal_render($element['#below']);
	  	}
		$output = l($element['#title'], $element['#href'], $element['#localized_options']);
	}
	return '<li' . drupal_attributes($element ['#attributes']) . '>' . $output . $sub_menu . "</li>\n";

}

function single_navigation ($ntype,$nid, $nav) {
	$current_node = node_load($nid);
	$prev_nid = db_query("SELECT n.nid FROM {node} n WHERE n.type = :type AND n.created < :created LIMIT 1", array(':created' => $current_node->created, ':type' => $ntype))->fetchField();
	$next_nid = db_query("SELECT n.nid FROM {node} n WHERE n.type = :type AND n.created > :created LIMIT 1", array(':created' => $current_node->created, ':type' => $ntype))->fetchField();
	$link = '';
	if ($prev_nid > 0 && $nav == 'prev') {
		$node = node_load($prev_nid);
	  	$link .= '<a href="'.url("node/" . $node->nid).'" class="work-prev"><span><span class="icon icon-arrows-left"></span>&nbsp;'.t("Prev").'</span></a>';
	} elseif ($next_nid > 0 && $nav == 'next') {
		$node = node_load($next_nid);
	  	$link .= '<a href="'.url("node/" . $node->nid).'" class="work-next"><span>'.t("Next").'&nbsp;<span class="icon icon-arrows-right"></span></span></a>';
	}
	return $link;

}