Projet

Général

Profil

Révision 5d12d676

Ajouté par Assos Assos il y a environ 6 ans

Weekly update of contrib modules

Voir les différences:

drupal7/sites/all/modules/views/theme/theme.inc
8 8
/**
9 9
 * Provide a full array of possible themes to try for a given hook.
10 10
 *
11
 * @param $hook
11
 * @param string $hook
12 12
 *   The hook to use. This is the base theme/template name.
13
 * @param $view
13
 * @param object $view
14 14
 *   The view being rendered.
15
 * @param $display
15
 * @param object $display
16 16
 *   The display being rendered, if applicable.
17 17
 */
18 18
function _views_theme_functions($hook, $view, $display = NULL) {
......
52 52
  $vars['name']       = $view->name;
53 53
  $vars['display_id'] = $view->current_display;
54 54

  
55
  // Basic classes
55
  // Basic classes.
56 56
  $vars['css_class'] = '';
57 57

  
58 58
  $vars['classes_array'] = array();
......
81 81

  
82 82
  $vars['pager']      = '';
83 83

  
84
  // @todo: Figure out whether this belongs into views_ui_preprocess_views_view.
84
  // @todo Figure out whether this belongs into views_ui_preprocess_views_view.
85 85
  // Render title for the admin preview.
86 86
  $vars['title'] = !empty($view->views_ui_context) ? filter_xss_admin($view->get_title()) : '';
87 87

  
......
104 104
  // Attachments are always updated with the outer view, never by themselves,
105 105
  // so they do not have dom ids.
106 106
  if (empty($view->is_attachment)) {
107
    // Our JavaScript needs to have some means to find the HTML belonging to this
108
    // view.
107
    // Our JavaScript needs to have some means to find the HTML belonging to
108
    // this view.
109 109
    //
110 110
    // It is true that the DIV wrapper has classes denoting the name of the view
111 111
    // and its display ID, but this is not enough to unequivocally match a view
112 112
    // with its HTML, because one view may appear several times on the page. So
113
    // we set up a hash with the current time, $dom_id, to issue a "unique" identifier for
114
    // each view. This identifier is written to both Drupal.settings and the DIV
115
    // wrapper.
113
    // we set up a hash with the current time, $dom_id, to issue a "unique"
114
    // identifier for each view. This identifier is written to both
115
    // Drupal.settings and the DIV wrapper.
116 116
    $vars['dom_id'] = $view->dom_id;
117 117
    $vars['classes_array'][] = 'view-dom-id-' . $vars['dom_id'];
118 118
  }
......
129 129
            'view_args' => check_plain(implode('/', $view->args)),
130 130
            'view_path' => check_plain($_GET['q']),
131 131
            // Pass through URL to ensure we get e.g. language prefixes.
132
//            'view_base_path' => isset($view->display['page']) ? substr(url($view->display['page']->display_options['path']), strlen($base_path)) : '',
132
            // 'view_base_path' => isset($view->display['page']) ?
133
            //   substr(url($view->display['page']->display_options['path']),
134
            //   strlen($base_path)) : '',
133 135
            'view_base_path' => $view->get_path(),
134 136
            'view_dom_id' => $vars['dom_id'],
135 137
            // To fit multiple views on a page, the programmer may have
......
179 181
}
180 182

  
181 183
/**
182
 * Preprocess theme function to print a single record from a row, with fields
184
 * Preprocess theme function to print a single record from a row, with fields.
183 185
 */
184 186
function template_preprocess_views_view_fields(&$vars) {
185 187
  $view = $vars['view'];
186 188

  
187 189
  // Loop through the fields for this view.
188 190
  $previous_inline = FALSE;
189
  $vars['fields'] = array(); // ensure it's at least an empty array.
191
  $vars['fields'] = array();
192
  // Ensure it's at least an empty array.
190 193
  foreach ($view->field as $id => $field) {
191
    // render this even if set to exclude so it can be used elsewhere.
194
    // Render this even if set to exclude so it can be used elsewhere.
192 195
    $field_output = $view->style_plugin->get_field($view->row_index, $id);
193 196
    $empty = $field->is_value_empty($field_output, $field->options['empty_zero']);
194 197
    if (empty($field->options['exclude']) && (!$empty || (empty($field->options['hide_empty']) && empty($vars['options']['hide_empty'])))) {
......
207 210
          if ($class) {
208 211
            $class .= ' ';
209 212
          }
210
          $class .=  $classes;
213
          $class .= $classes;
211 214
        }
212 215

  
213 216
        $pre = '<' . $object->element_type;
......
218 221
      }
219 222

  
220 223
      // Protect ourself somewhat for backward compatibility. This will prevent
221
      // old templates from producing invalid HTML when no element type is selected.
224
      // old templates from producing invalid HTML when no element type is
225
      // selected.
222 226
      if (empty($object->element_type)) {
223 227
        $object->element_type = 'span';
224 228
      }
......
228 232
        $object->raw = $vars['row']->{$view->field[$id]->field_alias};
229 233
      }
230 234
      else {
231
        $object->raw = NULL; // make sure it exists to reduce NOTICE
235
        // Make sure it exists to reduce NOTICE.
236
        $object->raw = NULL;
232 237
      }
233 238

  
234 239
      if (!empty($vars['options']['separator']) && $previous_inline && $object->inline && $object->content) {
......
268 273
        $object->wrapper_suffix = '</' . $object->inline_html . '>';
269 274
      }
270 275

  
271
      // Set up the label for the value and the HTML to make it easier
272
      // on the template.
276
      // Set up the label for the value and the HTML to make it easier on the
277
      // template.
273 278
      $object->label = check_plain($view->field[$id]->label());
274 279
      $object->label_html = '';
275 280
      if ($object->label) {
......
307 312
      $vars['fields'][$id] = $object;
308 313
    }
309 314
  }
310

  
311 315
}
312 316

  
313 317
/**
......
320 324

  
321 325
  $output = '<div class="view-grouping">';
322 326
  $output .= '<div class="view-grouping-header">' . $title . '</div>';
323
  $output .= '<div class="view-grouping-content">' . $content . '</div>' ;
327
  $output .= '<div class="view-grouping-content">' . $content . '</div>';
324 328
  $output .= '</div>';
325 329

  
326 330
  return $output;
......
338 342
 *
339 343
 * Interesting bits of info:
340 344
 * $field->field_alias says what the raw value in $row will be. Reach it like
341
 * this: @code { $row->{$field->field_alias} @endcode
345
 * this: @code { $row->{$field->field_alias} @endcode.
342 346
 */
343 347
function theme_views_view_field($vars) {
344 348
  $view = $vars['view'];
......
359 363
}
360 364

  
361 365
/**
362
 * Preprocess theme function to print a single record from a row, with fields
366
 * Preprocess theme function to print a single record from a row, with fields.
363 367
 */
364 368
function template_preprocess_views_view_summary(&$vars) {
365 369
  $view     = $vars['view'];
......
373 377
  }
374 378

  
375 379
  $active_urls = drupal_map_assoc(array(
376
    url($_GET['q'], array('alias' => TRUE)), // force system path
377
    url($_GET['q']), // could be an alias
380
    // Force system path.
381
    url($_GET['q'], array('alias' => TRUE)),
382
    // Could be an alias.
383
    url($_GET['q']),
378 384
  ));
379 385

  
380
  // Collect all arguments foreach row, to be able to alter them for example by the validator.
381
  // This is not done per single argument value, because this could cause performance problems.
386
  // Collect all arguments foreach row, to be able to alter them for example by
387
  // the validator. This is not done per single argument value, because this
388
  // could cause performance problems.
382 389
  $row_args = array();
383 390

  
384 391
  foreach ($vars['rows'] as $id => $row) {
......
406 413
}
407 414

  
408 415
/**
409
 * Template preprocess theme function to print summary basically
410
 * unformatted.
416
 * Template preprocess theme function to print summary basically unformatted.
411 417
 */
412 418
function template_preprocess_views_view_summary_unformatted(&$vars) {
413 419
  $view     = $vars['view'];
......
422 428

  
423 429
  $count = 0;
424 430
  $active_urls = drupal_map_assoc(array(
425
    url($_GET['q'], array('alias' => TRUE)), // force system path
426
    url($_GET['q']), // could be an alias
431
    // Force system path.
432
    url($_GET['q'], array('alias' => TRUE)),
433
    // Could be an alias.
434
    url($_GET['q']),
427 435
  ));
428 436

  
429
  // Collect all arguments foreach row, to be able to alter them for example by the validator.
430
  // This is not done per single argument value, because this could cause performance problems.
437
  // Collect all arguments foreach row, to be able to alter them for example by
438
  // the validator. This is not done per single argument value, because this
439
  // could cause performance problems.
431 440
  $row_args = array();
432 441
  foreach ($vars['rows'] as $id => $row) {
433 442
    $row_args[$id] = $argument->summary_argument($row);
......
435 444
  $argument->process_summary_arguments($row_args);
436 445

  
437 446
  foreach ($vars['rows'] as $id => $row) {
438
    // only false on first time:
447
    // Only false on first time.
439 448
    if ($count++) {
440 449
      $vars['rows'][$id]->separator = filter_xss_admin($vars['options']['separator']);
441 450
    }
......
461 470
function template_preprocess_views_view_table(&$vars) {
462 471
  $view     = $vars['view'];
463 472

  
464
  // We need the raw data for this grouping, which is passed in as $vars['rows'].
465
  // However, the template also needs to use for the rendered fields.  We
466
  // therefore swap the raw data out to a new variable and reset $vars['rows']
467
  // so that it can get rebuilt.
468
  // Store rows so that they may be used by further preprocess functions.
473
  // We need the raw data for this grouping, which is passed in as
474
  // $vars['rows']. However, the template also needs to use for the rendered
475
  // fields. We therefore swap the raw data out to a new variable and reset
476
  // $vars['rows'] so that it can get rebuilt. Store rows so that they may be
477
  // used by further preprocess functions.
469 478
  $result   = $vars['result'] = $vars['rows'];
470 479
  $vars['rows'] = array();
471 480
  $vars['field_classes'] = array();
......
493 502
  $renders = $handler->render_fields($result);
494 503

  
495 504
  foreach ($columns as $field => $column) {
496
    // Create a second variable so we can easily find what fields we have and what the
497
    // CSS classes should be.
505
    // Create a second variable so we can easily find what fields we have and
506
    // what the CSS classes should be.
498 507
    $vars['fields'][$field] = drupal_clean_css_identifier($field);
499 508
    if ($active == $field) {
500 509
      $vars['fields'][$field] .= ' active';
501 510
    }
502 511

  
503
    // render the header labels
512
    // Render the header labels.
504 513
    if ($field == $column && empty($fields[$field]->options['exclude'])) {
505 514
      $label = check_plain(!empty($fields[$field]) ? $fields[$field]->label() : '');
506 515
      if (empty($options['info'][$field]['sortable']) || !$fields[$field]->click_sortable()) {
......
540 549
        }
541 550
        $vars['header_classes'][$field] .= $class;
542 551
      }
543
      // Add a CSS align class to each field if one was set
552
      // Add a CSS align class to each field if one was set.
544 553
      if (!empty($options['info'][$field]['align'])) {
545 554
        $vars['header_classes'][$field] .= ' ' . drupal_clean_css_identifier($options['info'][$field]['align']);
546 555
      }
......
552 561
          $vars['header'][$field] = '<' . $element_label_type . '>' . $vars['header'][$field] . '</' . $element_label_type . '>';
553 562
        }
554 563
      }
555

  
556 564
    }
557 565

  
558
    // Add a CSS align class to each field if one was set
566
    // Add a CSS align class to each field if one was set.
559 567
    if (!empty($options['info'][$field]['align'])) {
560 568
      $vars['fields'][$field] .= ' ' . drupal_clean_css_identifier($options['info'][$field]['align']);
561 569
    }
562 570

  
563 571
    // Render each field into its appropriate column.
564 572
    foreach ($result as $num => $row) {
565
      // Add field classes
573
      // Add field classes.
566 574
      $vars['field_classes'][$field][$num] = '';
567 575
      if ($fields[$field]->options['element_default_classes']) {
568 576
        $vars['field_classes'][$field][$num] = "views-field views-field-" . $vars['fields'][$field];
......
602 610
      }
603 611
    }
604 612

  
605
    // Remove columns if the option is hide empty column is checked and the field is not empty.
613
    // Remove columns if the option is hide empty column is checked and the
614
    // field is not empty.
606 615
    if (!empty($options['info'][$field]['empty_column'])) {
607 616
      $empty = TRUE;
608 617
      foreach ($vars['rows'] as $num => $columns) {
......
646 655
    $vars['field_classes'][0][0] = 'views-empty';
647 656
  }
648 657

  
649

  
650 658
  if (!empty($options['sticky'])) {
651 659
    drupal_add_js('misc/tableheader.js');
652 660
    $vars['classes_array'][] = "sticky-enabled";
653 661
  }
654
  $vars['classes_array'][] = 'cols-'. count($vars['header']);
662
  $vars['classes_array'][] = 'cols-' . count($vars['header']);
655 663

  
656 664
  // Add the summary to the list if set.
657 665
  if (!empty($handler->options['summary'])) {
......
739 747
    }
740 748
  }
741 749

  
742
  // Apply the row classes
750
  // Apply the row classes.
743 751
  foreach ($rows as $row_number => $row) {
744 752
    $row_classes = array();
745 753
    if ($default_row_class) {
746
      $row_classes[] =  'row-' . ($row_number + 1);
754
      $row_classes[] = 'row-' . ($row_number + 1);
747 755
    }
748 756
    if ($row_class_special) {
749 757
      if ($row_number == 0) {
750
        $row_classes[] =  'row-first';
758
        $row_classes[] = 'row-first';
751 759
      }
752 760
      if (count($rows) == ($row_number + 1)) {
753
        $row_classes[] =  'row-last';
761
        $row_classes[] = 'row-last';
754 762
      }
755 763
    }
756 764
    $vars['row_classes'][$row_number] = implode(' ', $row_classes);
757 765
    foreach ($rows[$row_number] as $column_number => $item) {
758 766
      $column_classes = array();
759 767
      if ($default_row_class) {
760
        $column_classes[] = 'col-'. ($column_number + 1);
768
        $column_classes[] = 'col-' . ($column_number + 1);
761 769
      }
762 770
      if ($row_class_special) {
763 771
        if ($column_number == 0) {
......
791 799
}
792 800

  
793 801
/**
794
 * Display the simple view of rows one after another
802
 * Display the simple view of rows one after another.
795 803
 */
796 804
function template_preprocess_views_view_unformatted(&$vars) {
797 805
  $view = $vars['view'];
......
832 840
}
833 841

  
834 842
/**
835
 * Display the view as an HTML list element
843
 * Display the view as an HTML list element.
836 844
 */
837 845
function template_preprocess_views_view_list(&$vars) {
838 846
  $handler  = $vars['view']->style_plugin;
......
861 869
}
862 870

  
863 871
/**
864
 * Preprocess an RSS feed
872
 * Preprocess an RSS feed.
865 873
 */
866 874
function template_preprocess_views_view_rss(&$vars) {
867 875
  global $base_url;
......
889 897
  }
890 898
  $vars['title'] = check_plain($title);
891 899

  
892
  // Figure out which display which has a path we're using for this feed. If there isn't
893
  // one, use the global $base_url
900
  // Figure out which display which has a path we're using for this feed. If
901
  // there isn't one, use the global $base_url.
894 902
  $link_display_id = $view->display_handler->get_link_display();
895 903
  if ($link_display_id && !empty($view->display[$link_display_id])) {
896 904
    $path = $view->display[$link_display_id]->handler->get_path();
......
903 911
      $url_options['query'] = $view->exposed_raw_input;
904 912
    }
905 913

  
906
    // Compare the link to the default home page; if it's the default home page, just use $base_url.
914
    // Compare the link to the default home page; if it's the default home
915
    // page, just use $base_url.
907 916
    if ($path == variable_get('site_frontpage', 'node')) {
908 917
      $path = '';
909 918
    }
......
957 966
      $checkboxes .= drupal_render($form[$info['value']]);
958 967
      continue;
959 968
    }
960
    $widget = new stdClass;
961
    // set up defaults so that there's always something there.
969
    $widget = new stdClass();
970
    // Set up defaults so that there's always something there.
962 971
    $widget->label = $widget->operator = $widget->widget = $widget->description = NULL;
963 972

  
964 973
    $widget->id = isset($form[$info['value']]['#id']) ? $form[$info['value']]['#id'] : '';
......
981 990

  
982 991
  // Wrap up all the checkboxes we set aside into a widget.
983 992
  if ($checkboxes) {
984
    $widget = new stdClass;
985
    // set up defaults so that there's always something there.
993
    $widget = new stdClass();
994
    // Set up defaults so that there's always something there.
986 995
    $widget->label = $widget->operator = $widget->widget = NULL;
987 996
    $widget->id = 'checkboxes';
988 997
    $widget->widget = $checkboxes;
......
1038 1047
  return drupal_render_children($form);
1039 1048
}
1040 1049

  
1050
/**
1051
 * theme function for a mini pager.
1052
 */
1041 1053
function theme_views_mini_pager($vars) {
1042 1054
  global $pager_page_array, $pager_total;
1043 1055

  
......
1045 1057
  $element = $vars['element'];
1046 1058
  $parameters = $vars['parameters'];
1047 1059

  
1048
  // current is the page we are currently paged to
1060
  // Current is the page we are currently paged to.
1049 1061
  $pager_current = $pager_page_array[$element] + 1;
1050
  // max is the maximum page number
1062
  // Max is the maximum page number.
1051 1063
  $pager_max = $pager_total[$element];
1052 1064
  // End of marker calculations.
1053

  
1054 1065
  if ($pager_total[$element] > 1) {
1055 1066

  
1056 1067
    $li_previous = theme('pager_previous',
......
1092 1103
      'class' => array('pager-next'),
1093 1104
      'data' => $li_next,
1094 1105
    );
1106

  
1095 1107
    return theme('item_list',
1096 1108
      array(
1097 1109
        'items' => $items,

Formats disponibles : Unified diff