Esempio n. 1
0
/**
 * Views preprocessing
 * Add view type class (e.g., node, teaser, list, table)
 */
function fusion_core_preprocess_views_view(&$vars)
{
    $vars['css_name'] = $vars['css_name'] . ' view-style-' . views_css_safe(strtolower($vars['view']->type));
}
 function render_fields($row)
 {
     $field_ids = array_keys($this->view->field);
     $rendered_fields = array();
     foreach ($field_ids as $id) {
         $field = $this->view->field[$id];
         $field_is_multiple = FALSE;
         $field_raw = array();
         $field_output = $this->view->field[$field->options['id']]->advanced_render($row);
         $field_raw = isset($this->view->field[$id]->field_alias) && isset($row->{$this->view->field[$id]->field_alias}) ? $row->{$this->view->field[$id]->field_alias} : NULL;
         if (empty($field->options['exclude']) && $field_output != "" && !empty($field_output)) {
             $object = new stdClass();
             $object->id = $id;
             $object->content = $field_output;
             $object->raw = $field_raw;
             $object->class = views_css_safe($id);
             $object->label = check_plain($this->view->field[$id]->label());
             $object->is_multiple = $field_is_multiple;
             $rendered_fields[$id] = $object;
         }
     }
     return $rendered_fields;
 }
<div class="views-field-<?php 
print views_css_safe($view->field[$field]->field);
?>
">
  <?php 
if ($view->field[$field]->label()) {
    ?>
    <label class="view-label-<?php 
    print views_css_safe($view->field[$field]->field);
    ?>
">
      <?php 
    print $view->field[$field]->label();
    ?>
:
    </label>
  <?php 
}
?>
  <div class="views-content-<?php 
print views_css_safe($view->field[$field]->field);
?>
">
    <?php 
print $view->style_plugin->rendered_fields[$count][$field];
?>
  </div>
</div>
Esempio n. 4
0
/**
 * Display a view as a table style.
 * version = "6.x-2.16"
 * location = views/theme/theme.inc
 * Customized to avoid plain sting process two times for anchor tag title attribute.
 */
function template_custom_views_view_table(&$vars) {
  $view = $vars['view'];

  // We need the raw data for this grouping, which is passed in as $vars['rows'].
  // However, the template also needs to use for the rendered fields.  We
  // therefore swap the raw data out to a new variable and reset $vars['rows']
  // so that it can get rebuilt.
  // Store rows so that they may be used by further preprocess functions.
  $result = $vars['result'] = $vars['rows'];
  $vars['rows'] = array();

  $options = $view->style_plugin->options;
  $handler = $view->style_plugin;

  $fields = &$view->field;
  $columns = $handler->sanitize_columns($options['columns'], $fields);

  $active = !empty($handler->active) ? $handler->active : '';
  $order = !empty($handler->order) ? $handler->order : 'asc';

  parse_str(tablesort_get_querystring(), $query);
  if (isset($view->exposed_raw_input)) {
    $query += $view->exposed_raw_input;
  }
  $query = empty($query) ? '' : '&' . http_build_query($query, '', '&');

  $header = array();

  // Fields must be rendered in order as of Views 2.3, so we will pre-render
  // everything.
  $renders = $handler->render_fields($result);

  foreach ($columns as $field => $column) {
    // render the header labels
    if ($field == $column && empty($fields[$field]->options['exclude'])) {
      $label = (!empty($fields[$field]) ? $fields[$field]->label() : '');
      if (empty($options['info'][$field]['sortable']) || !$fields[$field]->click_sortable()) {
        $vars['header'][$field] = $label;
      } else {
        // @todo -- make this a setting
        $initial = 'asc';

        if ($active == $field && $order == 'asc') {
          $initial = 'desc';
        }

        $title = t('sort by !s', array('!s' => $label));
        if ($active == $field) {
          $label .= theme('tablesort_indicator', $initial);
        }
        $link_options = array(
          'html' => true,
          'attributes' => array('title' => $title),
          'query' => 'order=' . urlencode($field) . '&sort=' . $initial . $query,
        );
        $vars['header'][$field] = l($label, $_GET['q'], $link_options);
      }
    }

    // Create a second variable so we can easily find what fields we have and what the
    // CSS classes should be.
    $vars['fields'][$field] = views_css_safe($field);
    if ($active == $field) {
      $vars['fields'][$field] .= ' active';
    }

    // Render each field into its appropriate column.
    foreach ($result as $num => $row) {
      if (!empty($fields[$field]) && empty($fields[$field]->options['exclude'])) {
        $field_output = $renders[$num][$field];

        if (!isset($vars['rows'][$num][$column])) {
          $vars['rows'][$num][$column] = '';
        }

        // Don't bother with separators and stuff if the field does not show up.
        if ($field_output === '') {
          continue;
        }

        // Place the field into the column, along with an optional separator.
        if ($vars['rows'][$num][$column] !== '') {
          if (!empty($options['info'][$column]['separator'])) {
            $vars['rows'][$num][$column] .= filter_xss_admin($options['info'][$column]['separator']);
          }
        }

        $vars['rows'][$num][$column] .= $field_output;
      }
    }
  }

  $count = 0;
  foreach ($vars['rows'] as $num => $row) {
    $vars['row_classes'][$num][] = ($count++ % 2 == 0) ? 'odd' : 'even';
  }

  $vars['row_classes'][0][] = 'views-row-first';
  $vars['row_classes'][count($vars['row_classes']) - 1][] = 'views-row-last';

  $vars['class'] = 'views-table';
  if (!empty($options['sticky'])) {
    drupal_add_js('misc/tableheader.js');
    $vars['class'] .= " sticky-enabled";
  }
  $vars['class'] .= ' cols-' . count($vars['header']);

  $vars['attributes'] = '';
  if (!empty($handler->options['summary'])) {
    $vars['attributes'] = drupal_attributes(array('summary' => $handler->options['summary']));
  }
}
Esempio n. 5
0
/**
 * Adds a class for the style of view  
 * (e.g., node, teaser, list, table, etc.)
 * (Requires views-view.tpl.php file in theme directory)
 */
function acquia_marina_preprocess_views_view(&$vars)
{
    $vars['css_name'] = $vars['css_name'] . ' view-style-' . views_css_safe(strtolower($vars['view']->type));
}
foreach ($types as $type) {
    ?>
      <?php 
    if ($view->date_info->style_max_items_behavior != 'more') {
        ?>
        <?php 
        print theme('calendar_stripe_stripe', $type);
        ?>
      <?php 
    }
    ?>
    <?php 
}
?>
    <div class="view-item <?php 
print views_css_safe('view-item-' . $view->name);
?>
">
      <?php 
if ($view->date_info->style_max_items_behavior != 'more') {
    ?>
        <div class="multiple-events"> 
          <?php 
    print l(t('Click to see all @count events', array('@count' => $count)), $link);
    ?>
        </div>    
    </div>
    <?php 
} else {
    ?>
      <div class="calendar-more"><?php 
Esempio n. 7
0
function phptemplate_views_view_table_forumTracker($view, $nodes, $type)
{
    $fields = _views_get_fields();
    $comments_per_page = _comment_get_display_setting('comments_per_page');
    foreach ($nodes as $node) {
        $row = array();
        foreach ($view->field as $field) {
            if ($fields[$field['id']]['visible'] !== FALSE) {
                if ($field['field'] == 'comment_count') {
                    $count = db_result(db_query('SELECT COUNT(c.cid) FROM {comments} c WHERE c.nid=%d', $node->nid));
                    // Find the ending point. The pager URL is always 1 less than
                    // the number being displayed because the first page is 0.
                    $last_display_page = ceil($count / $comments_per_page);
                    $last_pager_page = $last_display_page - 1;
                    if ($last_pager_page < 0) {
                        $last_pager_page = 0;
                    }
                    $cell['data'] = $node->node_comment_statistics_comment_count . '<br />';
                    //$cell['data'] .= l('new', 'node/'.$node->nid, array(), 'page='.$last_pager_page.'#new');
                    $cell['data'] .= advanced_forum_first_new_post_link($node, $count);
                    $cell['class'] = "view-field " . views_css_safe('view-field-' . $field['queryname']);
                    $row[] = $cell;
                } else {
                    $cell['data'] = views_theme_field('views_handle_field', $field['queryname'], $fields, $field, $node, $view);
                    $cell['class'] = "view-field " . views_css_safe('view-field-' . $field['queryname']);
                    $row[] = $cell;
                }
            }
        }
        $rows[] = $row;
    }
    return theme('table', $view->table_header, $rows);
}
Esempio n. 8
0
function kr2011_views_slideshow_thumbnailhover_no_display_section($view, $rows, $vss_id, $options, $teaser = TRUE)
{
    // Add the slideshow elements.
    $attributes['id'] = "views_slideshow_thumbnailhover_teaser_section_" . $vss_id;
    $attributes['class'] = 'views_slideshow_thumbnailhover_teaser_section views_slideshow_teaser_section';
    $attributes = drupal_attributes($attributes);
    $output = "<div{$attributes}>";
    foreach ($view->result as $count => $node) {
        if ($view->display_handler->uses_fields()) {
            $rendered = '';
            foreach ($options['views_slideshow_thumbnailhover']['main_fields'] as $field => $use) {
                if ($use !== 0 && is_object($view->field[$field]) && !$view->field[$field]->options['exclude']) {
                    $rendered .= '<div class="views-field-' . views_css_safe($view->field[$field]->field) . '">';
                    if ($view->field[$field]->label()) {
                        $rendered .= '<label class="view-label-' . views_css_safe($view->field[$field]->field) . '">';
                        $rendered .= $view->field[$field]->label() . ':';
                        $rendered .= '</label>';
                    }
                    //field-main-image-data
                    if (views_css_safe($view->field[$field]->field) == 'field-main-image-data') {
                        if (strlen($view->style_plugin->rendered_fields[$count][$field]) > 3) {
                            $rendered .= '<div class="views-content-' . views_css_safe($view->field[$field]->field) . '">';
                            $rendered .= $view->style_plugin->rendered_fields[$count][$field];
                            $rendered .= '</div>';
                            $rendered .= '</div>';
                        } else {
                            $rendered .= '</div>';
                        }
                    } else {
                        $rendered .= '<div class="views-content-' . views_css_safe($view->field[$field]->field) . '">';
                        $rendered .= $view->style_plugin->rendered_fields[$count][$field];
                        $rendered .= '</div>';
                        $rendered .= '</div>';
                    }
                }
            }
        } else {
            $rendered = node_view(node_load($node->nid), $teaser, FALSE, FALSE);
        }
        $output .= theme('views_slideshow_thumbnailhover_no_display_teaser', $rendered, $vss_id, $count);
    }
    $output .= "</div>";
    return $output;
}
Esempio n. 9
0
/**
 * Display a view as a table style.
 */
function mothership_preprocess_views_view_table(&$vars)
{
    $view = $vars['view'];
    // We need the raw data for this grouping, which is passed in as $vars['rows'].
    // However, the template also needs to use for the rendered fields.  We
    // therefore swap the raw data out to a new variable and reset $vars['rows']
    // so that it can get rebuilt.
    // $result   = $vars['rows']; http://drupal.org/node/348190#comment-1451822
    $result = $view->result;
    $vars['rows'] = array();
    $options = $view->style_plugin->options;
    $handler = $view->style_plugin;
    $fields =& $view->field;
    $columns = $handler->sanitize_columns($options['columns'], $fields);
    $active = !empty($handler->active) ? $handler->active : '';
    $order = !empty($handler->order) ? $handler->order : 'asc';
    $query = tablesort_get_querystring();
    if ($query) {
        $query = '&' . $query;
    }
    // Fields must be rendered in order as of Views 2.3, so we will pre-render
    // everything.
    $renders = array();
    $keys = array_keys($view->field);
    foreach ($result as $count => $row) {
        foreach ($keys as $id) {
            $renders[$count][$id] = $view->field[$id]->theme($row);
        }
    }
    foreach ($columns as $field => $column) {
        // render the header labels
        if ($field == $column && empty($fields[$field]->options['exclude'])) {
            $label = check_plain(!empty($fields[$field]) ? $fields[$field]->label() : '');
            if (empty($options['info'][$field]['sortable']) || !$fields[$field]->click_sortable()) {
                $vars['header'][$field] = $label;
            } else {
                // @todo -- make this a setting
                $initial = 'asc';
                if ($active == $field && $order == 'asc') {
                    $initial = 'desc';
                }
                $title = t('sort by @s', array('@s' => $label));
                if ($active == $field) {
                    $label .= theme('tablesort_indicator', $initial);
                }
                $link_options = array('html' => true, 'attributes' => array('title' => $title), 'query' => 'order=' . urlencode($field) . '&sort=' . $initial . $query);
                $vars['header'][$field] = l($label, $_GET['q'], $link_options);
            }
        }
        // Create a second variable so we can easily find what fields we have and what the
        // CSS classes should be.
        $vars['fields'][$field] = views_css_safe($field);
        if ($active == $field) {
            $vars['fields'][$field] .= ' active';
        }
        // Render each field into its appropriate column.
        foreach ($result as $num => $row) {
            if (!empty($fields[$field]) && empty($fields[$field]->options['exclude'])) {
                $field_output = $renders[$num][$field];
                // Don't bother with separators and stuff if the field does not show up.
                if (empty($field_output) && !empty($vars['rows'][$num][$column])) {
                    continue;
                }
                // Place the field into the column, along with an optional separator.
                if (!empty($vars['rows'][$num][$column])) {
                    if (!empty($options['info'][$column]['separator'])) {
                        $vars['rows'][$num][$column] .= filter_xss_admin($options['info'][$column]['separator']);
                    }
                } else {
                    $vars['rows'][$num][$column] = '';
                }
                $vars['rows'][$num][$column] .= $field_output;
            }
        }
    }
    //rows classes
    foreach ($vars['rows'] as $num => $row) {
        if ($num == 0 and theme_get_setting(mothership_cleanup_views_table_first_last)) {
            $vars['row_classes'][$num]['first'] = "first";
        }
        if (theme_get_setting(mothership_cleanup_views_table_row_count)) {
            $vars['row_classes'][$num]['count'] = "row-" . $num;
        }
        if (theme_get_setting(mothership_cleanup_views_table_zebra)) {
            $vars['row_classes'][$num]['zebra'] = $num % 2 == 0 ? 'odd' : 'even';
        }
    }
    if (theme_get_setting(mothership_cleanup_views_table_first_last)) {
        $vars['row_classes'][$num][] = "last";
    }
    $vars['class'] = 'views-table';
    if (!empty($options['sticky'])) {
        drupal_add_js('misc/tableheader.js');
        $vars['class'] .= " sticky-enabled";
    }
}
Esempio n. 10
0
/**
 * Adds a class for the style of view  
 * (e.g., node, teaser, list, table, etc.)
 * (Requires views-view.tpl.php file in theme directory)
 */
function davisonsoftware_preprocess_views_view(&$vars)
{
    $vars['css_name'] = $vars['css_name'] . ' view-style-' . views_css_safe(strtolower($vars['view']->type));
}