<?php
function CSE_theme() {
return array(
'comment_form' => array(
'arguments' => array('form' => array()),
),
);
}
function CSE_comment_form($form)
{
$form['name']['#title'] = t('Your Name');
return drupal_render($form);
}
function cse_preprocess_page(&$vars) {
if(isset($vars['node'])){
foreach($vars['node']->taxonomy as $term)
{
$parents = taxonomy_get_parents($term->tid);
$isClimateChange=false;
foreach($parents as $parent)
if($parent->tid=="27")
$isClimateChange=true;
if($term->vid==1 && ($term->tid==27 || $isClimateChange) || $term->vid==32){
$vars['template_files'] = array();
$vars['template_files'][] = 'page-climate-change';
return;
}
}
}
if(arg(0)=="taxonomy" && arg(1)=="term"){
$term = taxonomy_get_term(arg(2));
if($term->vid==32){
$vars['template_files'] = array();
$vars['template_files'][] = 'page-climate-change';
return;
}
}
if(isset($vars['node'])){
if($vars['node']->type=='anil_agarwal_dialogue')
{
$vars['template_files'] = array();
$vars['template_files'][] = 'page-aagarwal-dialogue1';
return;
}
}
if (isset($vars['node']) && $vars['node']->type=="about_us") {
// Add template naming suggestion. It should alway use hyphens.
$vars['template_files'] = array();
$vars['template_files'][] = 'page-about_us';
}
if (isset($vars['node']) && $vars['node']->nid==3830) {
// Add template naming suggestion. It should alway use hyphens.
$vars['template_files'] = array();
$vars['template_files'][] = 'page-aagarwal-dialogue';
}
if (isset($vars['node']) && $vars['node']->nid==3759) {
// Add template naming suggestion. It should alway use hyphens.
$vars['template_files'] = array();
$vars['template_files'][] = 'page-climate-change';
}
if (isset($vars['node']) && $vars['node']->type=="volunteer") {
// Add template naming suggestion. It should alway use hyphens.
$vars['template_files'] = array();
$vars['template_files'][] = 'page-volunteer';
}
if (isset($vars['node']) && $vars['node']->type=="climate_change") {
// Add template naming suggestion. It should alway use hyphens.
$vars['template_files'] = array();
$vars['template_files'][] = 'page-durban';
}
if (isset($vars['node']) && $vars['node']->type=="alumni") {
// Add template naming suggestion. It should alway use hyphens.
$vars['template_files'] = array();
$vars['template_files'][] = 'page-alumni';
}
if(substr(arg(0),0,6)=="alumni")
{
$vars['template_files'] = array();
$vars['template_files'][] = 'page-alumni';
}
if (isset($vars['node']) && $vars['node']->type=="webform") {
// Add template naming suggestion. It should alway use hyphens.
$vars['template_files'] = array();
$vars['template_files'][] = 'page-webforms';
}
if (isset($vars['node']) && $vars['node']->type=="blog") {
// Add template naming suggestion. It should alway use hyphens.
$vars['template_files'] = array();
$vars['template_files'][] = 'page-blog';
}
if (isset($vars['node']) && $vars['node']->type=="forum") {
// Add template naming suggestion. It should alway use hyphens.
$vars['template_files'] = array();
$vars['template_files'][] = 'page-forum';
}
if (arg(1)=="durban") {
// Add template naming suggestion. It should alway use hyphens.
$vars['template_files'] = array();
$vars['template_files'][] = 'page-durban';
}
}
function CSE_links($links, $attributes = array('class' => 'links')) {
global $language;
$output = '';
if (count($links) > 0) {
$output = '
$num_links = count($links);
$i = 1;
foreach ($links as $key => $link) {
$class = $key;
// Add first, last and active classes to the list of links to help out themers.
if ($i == 1) {
$class .= ' first';
}
if ($i == $num_links) {
$class .= ' last';
}
if (isset($link['href']) && ($link['href'] == $_GET['q'] || ($link['href'] == '
&& (empty($link['language']) || $link['language']->language == $language->language)) {
$class .= ' active';
}
$output .= '
if (isset($link['href'])) {
// Pass in $link as $options, they share the same keys.
$output .= l($link['title'], $link['href'], $link);
}
else if (!empty($link['title'])) {
// Some links are actually not links, but we wrap these in for adding title and class attributes
if (empty($link['html'])) {
$link['title'] = check_plain($link['title']);
}
$span_attributes = '';
if (isset($link['attributes'])) {
$span_attributes = drupal_attributes($link['attributes']);
}
$output .= ''. $link['title'] .'';
}
if($attributes["class"]=="primaryLinks")
$output .= '
'.$link['attributes']['title'];
$i++;
$output .= "
\n";
}
$output .= '
';
}
return $output;
}
function CSE_child_terms($vid = 1) {
$term=0;
if(arg(0) == 'node')
{
$node = node_load(arg(1));
$term = $node->taxonomy->tid;
$t = taxonomy_node_get_terms_by_vocabulary($node,1);
foreach($t as $value)
{
$term = $value->tid;
$obj = taxonomy_get_term($term);
if(!$obj && $obj->vid!="1" && $obj->vid!=32)
return;
break;
}
$vid=32;
}
elseif(arg(0) == 'taxonomy' && arg(1) == 'term')
{
$term=arg(2);
$obj = taxonomy_get_term($term);
if(!$obj || ($obj->vid!="1" && $obj->vid!="32"))
return;
$vid=$obj->vid;
}
else
return;
if($term==0) return;
$children = taxonomy_get_children($term, $vid);
if(!$children) {
$custom_parent = taxonomy_get_parents($term);
$parent_tree = array();
foreach ($custom_parent as $custom_child => $key) {
$parent_tree = taxonomy_get_tree($vid, $key->tid);
}
$children = $parent_tree;
}
if($vid==32)
{
$children = taxonomy_get_tree($vid,0);
}
$output = '
foreach ($custom_parent as $parent)
$output .= l($parent->name." Home", 'taxonomy/term/' . $parent->tid."/menu");
}
$output .= '
';
foreach ($children as $term) {
$output .= '
}
$output .= '
';
}
$output .= '
';
return $output;
}
function CSE_About_Us_Menu() {
$aboutUsMenu = array();
$aboutUsMenu["Overview"]=214;
$aboutUsMenu["Anil Agarwal"]=216;
$aboutUsMenu["Timeline"]=218;
$aboutUsMenu["Executive Board"]=219;
$aboutUsMenu["Programme Directors"]=220;
$aboutUsMenu["Sunita Narain"]=221;
$aboutUsMenu["Annual Reports"]=222;
$aboutUsMenu["Financial Reports"]=223;
$aboutUsMenu["Awards"]=1174;
$aboutUsMenu["Green CSE"]=1169;
$output = '
foreach ($aboutUsMenu as $menuName=>$menuLink) {
$output .= '
';
}
$output .= '
';
return $output;
}
function CSE_username($object) {
if ($object->uid && $object->name) {
// Shorten the name when it is too long or it will break many tables.
if (drupal_strlen($object->name) > 20) {
$name = drupal_substr($object->name, 0, 15) .'...';
}
else {
$name = $object->name;
}
if (user_access('access user profiles')) {
$output = l($name, 'user/'. $object->uid, array('attributes' => array('title' => t('View user profile.'))));
}
else {
$output = check_plain($name);
}
}
else if ($object->name) {
// Sometimes modules display content composed by people who are
// not registered members of the site (e.g. mailing list or news
// aggregator modules). This clause enables modules to display
// the true author of the content.
if (!empty($object->homepage)) {
$output = l($object->name, $object->homepage, array('attributes' => array('rel' => 'nofollow')));
}
else {
$output = check_plain($object->name);
}
//$output .= ' ('. t('not verified') .')';
}
else {
$output = variable_get('anonymous', t('Anonymous'));
}
return $output;
}
?>