[ Index ]

PHP Cross Reference of Drupal 6 (gatewave)

title

Body

[close]

/sites/all/modules/project/views/theme/ -> theme.inc (source)

   1  <?php
   2  // $Id: theme.inc,v 1.3 2009/01/15 00:29:29 dww Exp $
   3  
   4  
   5  /**
   6   * @file
   7   * Theme functions related to Views support (style plugins, etc).
   8   */
   9  
  10  /**
  11   * Theme the extra_options form for the project_sort_method filter.
  12   */
  13  function theme_project_views_project_sort_method_options_form($form) {
  14    $header = array(
  15      array('data' => t('Enabled')),
  16      array('data' => t('ID')),
  17      array('data' => t('Name')),
  18      array('data' => t('Weight')),
  19      array('data' => t('Display name')),
  20    );
  21    $rows = array();
  22    foreach (element_children($form) as $key) {
  23      $row = array();
  24      $row[] = drupal_render($form[$key]['enabled']);
  25      $row[] = drupal_render($form[$key]['id']);
  26      $row[] = drupal_render($form[$key]['name']);
  27      $form[$key]['weight']['#attributes']['class'] = 'weight';
  28      $row[] = drupal_render($form[$key]['weight']);
  29      $row[] = drupal_render($form[$key]['display_name']);
  30  
  31      $rows[] = array('data' => $row, 'class' => 'draggable');
  32    }
  33    if (empty($rows)) {
  34      $rows[] = array(array('data' => t('No fields available.'), 'colspan' => '2'));
  35    }
  36  
  37    drupal_add_tabledrag('exposed-sort-weight', 'order', 'sibling', 'weight');
  38    $output = theme('table', $header, $rows, array('id' => 'exposed-sort-weight'));
  39    $output .= drupal_render($form);
  40    return $output;
  41  }
  42  
  43  /**
  44   * Template helper for theme_project_views_view_row_project_node
  45   */
  46  function template_preprocess_project_views_view_row_project_node(&$vars) {
  47    $options = $vars['options'];
  48    $vars['node'] = ''; // make sure var is defined.
  49    $nid = $vars['row']->nid;
  50    if (!is_numeric($nid)) {
  51      return;
  52    }
  53  
  54    $node = node_load($nid);
  55    $node->view = $vars['view'];
  56  
  57    if (empty($node)) {
  58      return;
  59    }
  60  
  61    $id = $vars['id'];
  62    $vars['project']->class = ($id % 2) ? 'odd' : 'even';
  63  
  64    // Build the term links for the project.
  65    if (module_exists('taxonomy') && !empty($options['project_term_links'])) {
  66      if (!empty($vars['view']->project->project_type)) {
  67        // Hide the top-level project type term from the links.
  68        unset($node->taxonomy[$vars['view']->project->project_type->tid]);
  69      }
  70      $vars['project']->terms = theme('links', taxonomy_link('taxonomy terms', $node));
  71    }
  72  
  73    // Because $vars['id'] is one based but $vars['view']>result-># is zero based, subtract
  74    // one from $vars['id'] to get the corresponding index into $vars['view']->result.
  75    $result_id = $id - 1;
  76  
  77    $vars['project']->title = l($node->title, "node/$node->nid");
  78    $vars['project']->new_date = isset($vars['view']->project->project_new_date[$result_id]) ? $node->changed : FALSE;
  79    $vars['project']->changed = t('Last changed: !interval ago', array('!interval' => format_interval(time() - $node->changed, 2)));
  80    $vars['project']->body = check_markup($options['project_teaser'] ? $node->teaser : $node->body, $node->format, FALSE);
  81    if (!empty($options['project_release_download_table'])) {
  82      $vars['project_release']->download_table = $project->download_table = theme('project_release_table_overview', $node, 'recommended', 'all', t('Version'), FALSE);
  83    }
  84  
  85    // Link to a downloadable file.
  86    if (!empty($options['project_release_download_link'])) {
  87  //  @TODO:  Given the potential for confusion with multiple supported versions, I think it might
  88  //  be best to not display a download link at all on the project overview page.
  89  //    if ($node->file_path) {
  90  //      $vars['project_release']->download_link = theme('project_release_download_link', $node->file_path, t('Download'), 'array');
  91  //    }
  92    }
  93  
  94    // Link to the project's issue queue.
  95    if (!empty($options['project_issue_issues_link'])) {
  96      if (isset($node->project_issue['issues'])) {
  97        $vars['project_issue']->issues_link = array(
  98          'title' => t('Bugs and feature requests'),
  99          'href' => 'project/issues/'. $node->project['uri'],
 100        );
 101      }
 102    }
 103  }
 104  
 105  /**
 106   * Preprocess theme function that is used for the project list style.
 107   */
 108  function template_preprocess_project_views_view_project_list(&$vars) {
 109    $view = $vars['view'];
 110  
 111    // Sanitize all of the project type term information before placing
 112    // the values into $vars.
 113    if (!empty($view->project->project_type)) {
 114      $term = $view->project->project_type;
 115      $vars['project']['arguments'][0] = array(
 116        'tid' => $term->tid,
 117        'vid' => $term->vid,
 118        'name' => check_plain($term->name),
 119        'description' => filter_xss_admin($term->description),
 120        'weight' => $term->weight,
 121      );
 122    }
 123  }
 124  
 125  /**
 126   * Preprocess theme function that is used for the collapsible summary style.
 127   */
 128  function template_preprocess_project_views_view_collapsible_summary(&$vars) {
 129    $view = $vars['view'];
 130    $argument = $view->argument[$view->build_info['summary_level']];
 131  
 132    $url_options = array();
 133    $terms = array();
 134  
 135    if (!empty($view->exposed_raw_input)) {
 136      $url_options['query'] = $view->exposed_raw_input;
 137    }
 138  
 139    $children = array();
 140  
 141    foreach ($vars['rows'] as $id => $row) {
 142      $name = $argument->summary_name($row);
 143      $count = intval($row->{$argument->count_alias});
 144      $tid = $row->term_node_tid;
 145      $term = taxonomy_get_term($tid);
 146      //$url = url($view->get_url($args), $url_options);
 147      $url = taxonomy_term_path($term);
 148  
 149    // @TODO:  We might not want to print terms with no projects so the user doesn't click on the
 150    // term and end up with a 404 error.
 151  
 152    // @TODO:  We want to include the description of the term as well.
 153  
 154      $vars['rows'][$id]->link = $name;
 155      $vars['rows'][$id]->url = $url;
 156      $vars['rows'][$id]->count = $count;
 157      $vars['rows'][$id]->term = $term;
 158  
 159      // Prepare terms for sending to theme_project_term_list().
 160      $l_options = array('attributes' => array('title' => strip_tags($term->description)), 'absolute' => TRUE);
 161      $l_options = array_merge($l_options, $url_options);
 162      $children[] = l("$name ($count)", $url, $l_options);
 163    }
 164  
 165    // For each row returned, we store the data in two different ways for use
 166    // and display by the template.
 167    $vars['project_terms'] = array(
 168      '#title' => t('Categories'),
 169      '#collapsible' => TRUE,
 170      '#collapsed' => isset($view->original_args[1]) ? TRUE : FALSE,
 171      '#children' => theme('item_list', $children),
 172    );
 173  }
 174  
 175  /**
 176   * Preprocess theme function to print a single project record from a row, using fields.
 177   */
 178  function template_preprocess_project_views_view_row_project_fields(&$vars) {
 179    $view = $vars['view'];
 180  
 181    // Loop through the fields for this view.
 182    $inline = FALSE;
 183    $vars['fields'] = array(); // ensure it's at least an empty array.
 184    foreach ($view->field as $id => $field) {
 185      if (empty($field->options['exclude'])) {
 186        $object = new stdClass();
 187  
 188        $object->content = $view->field[$id]->theme($vars['row']);
 189        if (isset($view->field[$id]->field_alias) && isset($vars['row']->{$view->field[$id]->field_alias})) {
 190          $object->raw = $vars['row']->{$view->field[$id]->field_alias};
 191        }
 192        else {
 193          $object->raw = NULL; // make sure it exists to reduce NOTICE
 194        }
 195  
 196        $object->handler = $view->field[$id];
 197        $object->class = views_css_safe($id);
 198        $object->label = check_plain($view->field[$id]->label());
 199        $vars['fields'][$id] = $object;
 200      }
 201    }
 202  }
 203  


Generated: Thu Mar 24 11:18:33 2011 Cross-referenced by PHPXref 0.7