All pastes #501789 Raw Edit

Unnamed

public text v1 · immutable
·published 2007-05-22 06:33 UTC
rendered paste body
<?php
// $Id: template.php,v 1.6.2.1.4.2 2007/04/10 01:04:51 jwolf Exp $

// regions for amadou
function amadou_regions() {
    return array(
	'header' => t ('header'),
        'content_top' => t('content top'),
        'sidebar_left' => t('sidebar left'),
        'sidebar_right' => t('sidebar right'),
        'content_bottom' => t('content bottom'),
        'footer' => t('footer')
    );
}
// resize main content width according to the presence of side bars
function amadou_get_primaryContent_width($sidebar_left, $sidebar_right) {
  $width = 100;
  if (!$sidebar_left) {
    $width = $width + 30;
  }
  if (!$sidebar_right) {
    $width = $width + 30;
  }
  return $width;
}
//adjusts the sidebars content top margin according to the presence of  the searchbox
function amadou_get_sidebarsContent_margin($search_box) {
  $margin = 0;
  if ($search_box) {
    $margin = '20px 0 0 0';
  }
  return $margin;
}
// sets delimiter and styles for $links
function amadou_links($links, $attributes = array('class' => 'links')) {
  $output = '';

  if (count($links) > 0) {
    //$output = '<div'. drupal_attributes($attributes) .'>';

    $num_links = count($links);
    $i = 1;

    foreach ($links as $key => $link) {
      $class = '';

      // Automatically add a class to each link and also to each LI
      if (isset($link['attributes']) && isset($link['attributes']['class'])) {
        $link['attributes']['class'] .= ' ' . $key;
        $class = $key;
      }
      else {
        $link['attributes']['class'] = $key;
        $class = $key;
      }

      // Add first and last classes to the list of links to help out themers.
      $extra_class = '';
      if ($i == 1) {
        $extra_class .= 'first ';
      } else {
        $output .= '&nbsp;&bull; &nbsp;';
      }
      if ($i == $num_links) {
        $extra_class .= 'last ';
      }
      $output .= '<span class="'. $extra_class . $class .'">';

      // Is the title HTML?
      $html = isset($link['html']) && $link['html'];

      // Initialize fragment and query variables.
      $link['query'] = isset($link['query']) ? $link['query'] : NULL;
      $link['fragment'] = isset($link['fragment']) ? $link['fragment'] : NULL;

      if (isset($link['href'])) {
        $output .= l($link['title'], $link['href'], $link['attributes'], $link['query'], $link['fragment'], FALSE, $html);
      }
      else if ($link['title']) {
        //Some links are actually not links, but we wrap these in <span> for adding title and class attributes
        if (!$html) {
          $link['title'] = check_plain($link['title']);
        }
        $output .= '<span'. drupal_attributes($link['attributes']) .'>'. $link['title'] .'</span>';
      }

      $i++;
      $output .= "</span>\n";
    }

    //$output .= '</div>';
  }

  return $output;
}

function _phptemplate_variables($hook, $vars) {
static $is_forum;
  $variables = array();
  if (!isset($is_forum)) {
    if (arg(0) == 'node' && is_numeric(arg(1)) && arg(2) == '') {
      $nid = arg(1);
    }
    if (arg(0) == 'comment' && arg(1) == 'reply' && is_numeric(arg(2))) {
      $nid = arg(2);
    }
    if ($nid) {
      $node = node_load(array('nid' => $nid));
    }
    $is_forum = ($node && $node->type == 'forum');
    _is_forum($is_forum);
  }
    if ($is_forum) {
      switch ($hook) {
        case 'comment' :
          $variables['template_file'] = 'node-forum';
          $variables['row_class'] = _row_class();
          $variables['name'] = $vars['author'];
          $variables['userid'] = $vars['comment']->uid;
          $joined = module_invoke('flatforum', 'get_created', $vars['comment']->uid);
          $variables['joined'] = $joined ? format_date($joined, 'custom', 'Y-m-d') : '';
          $posts = module_invoke('flatforum', 'get', $vars['comment']->uid);
          $variables['posts'] = $posts ? $posts : 0;
          $variables['submitted'] = format_date($vars['comment']->timestamp);
          $subject = $vars['comment']->subject;
          $variables['title'] = empty($subject) ? '&nbsp' : $subject;
          $variables['content'] = $vars['comment']->comment;
          $variables['links'] = empty($vars['links']) ? '&nbsp' : $vars['links'];
          break;
        case 'node' :
          $variables['row_class'] = _row_class();
          $variables['userid']=$vars['node']->uid;
          $joined = module_invoke('flatforum', 'get_created', $vars['node']->uid);
          $variables['joined'] = $joined ? format_date($joined, 'custom', 'Y-m-d') : '';
          $posts = module_invoke('flatforum', 'get', $vars['node']->uid);
          $variables['posts'] = $posts ? $posts : 0;
          $variables['title'] = empty($vars['title']) ? '&nbsp' : $vars['title'];
          $variables['content'] = $vars['node']->body;
          $variables['links'] = empty($vars['links']) ? '&nbsp' : $vars['links'];
          break;
      }
  }



 if (!$is_forum) {
  switch($hook) {
    case 'node':
      $variables['storylink_url'] = check_url($vars['node']->vote_storylink_url);
      if (arg(1) != 'add' && arg(1) != 'edit') {
        $style = variable_get('vote_up_down_widget_style_node', 0) == 1 ? '_alt' : '';
        $variables['vote_up_down_widget'] = theme("vote_up_down_widget$style", $vars['node']->nid, 'node');
        $variables['vote_up_down_points'] = theme("vote_up_down_points$style", $vars['node']->nid, 'node');
      }
      $variables['vote_storylink_via'] = theme('vote_storylink_via', $vars['node']->vote_storylink_url);
      if (arg(1) == 'top') {
        static $count;
        $count = is_array($count) ? $count : array();
        $count[$hook] = is_int($count[$hook]) ? $count[$hook] : 1;
        $variables['seqid'] = $count[$hook]++;
      }
      break;
  }
  }
  return $variables;
}

function _row_class() {
  static $forum_row = TRUE;
  $forum_row = !$forum_row;
  return $forum_row ? 'odd' : 'even';
}
function _is_forum($arg = NULL) {
  static $is_forum = FALSE;
  if ($arg) {
    $is_forum = $arg;
  }
  return $is_forum;
}

function phptemplate_user_profile($user, $fields = array()) {
   return _phptemplate_callback('user_profile', array('user' => $user, 'fields' => $fields));
  }


function phptemplate_views_view_list_ImageList($view, $nodes, $type) {
  $fields = _views_get_fields();

  $taken = array();

  // Group our nodes
  $set = array();
  foreach ($nodes as $node) {
    $set[$node->image_nid][] = $node;
  }

  // Set up the fields in nicely named chunks.
  foreach ($view->field as $id => $field) {
    $field_name = $field['field'];
    if (isset($taken[$field_name])) {
      $field_name = $field['queryname'];
    }
    $taken[$field_name] = true;
    $field_names[$id] = $field_name;
  }

  // Set up some variables that won't change.
  $base_vars = array(
    'view' => $view,
    'view_type' => $type,
  );

  $output = '';
  foreach ($set as $label => $nodes) {
    $items = array();
    foreach ($nodes as $i => $node) {
      $vars = $base_vars;
      $vars['node'] = $node;
      $vars['count'] = $i;
      $vars['stripe'] = $i % 2 ? 'even' : 'odd';
      foreach ($view->field as $id => $field) {
        $name = $field_names[$id];
        $vars[$name] = views_theme_field('views_handle_field', $field['queryname'], $fields, $field, $node, $view);
        if (isset($field['label'])) {
          $vars[$name . '_label'] = $field['label'];
        }
      }
      $items[] = _phptemplate_callback('views-list-ImageList', $vars);
    }
    if ($items) {
      $output .= theme('item_list', $items, $label);
    }
  }
  return $output;
}