Definition in file theme.inc.
Go to the source code of this file.
Functions | |
| _views_theme_functions ($hook, $view, $display=NULL) | |
| Provide a full array of possible themes to try for a given hook. | |
| template_preprocess_views_view (&$vars) | |
| Preprocess the primary theme implementation for a view. | |
| template_preprocess_views_view_fields (&$vars) | |
| Preprocess theme function to print a single record from a row, with fields. | |
| theme_views_view_field ($view, $field, $row) | |
| Display a single views field. | |
| template_preprocess_views_view_field (&$vars) | |
| Process a single field within a view. | |
| template_preprocess_views_view_summary (&$vars) | |
| Preprocess theme function to print a single record from a row, with fields. | |
| template_preprocess_views_view_summary_unformatted (&$vars) | |
| Template preprocess theme function to print summary basically unformatted. | |
| template_preprocess_views_view_table (&$vars) | |
| Display a view as a table style. | |
| template_preprocess_views_view_grid (&$vars) | |
| Display a view as a grid style. | |
| template_preprocess_views_view_unformatted (&$vars) | |
| Display the simple view of rows one after another. | |
| template_preprocess_views_view_list (&$vars) | |
| Display the view as an HTML list element. | |
| template_preprocess_views_view_rss (&$vars) | |
| Preprocess an RSS feed. | |
| template_preprocess_views_view_row_rss (&$vars) | |
| Default theme function for all RSS rows. | |
| template_preprocess_views_exposed_form (&$vars) | |
| Default theme function for all filter forms. | |
| theme_views_mini_pager ($tags=array(), $limit=10, $element=0, $parameters=array(), $quantity=9) | |
| _views_theme_functions | ( | $ | hook, | |
| $ | view, | |||
| $ | display = NULL | |||
| ) |
Provide a full array of possible themes to try for a given hook.
| $hook | The hook to use. This is the base theme/template name. | |
| $view | The view being rendered. | |
| $display | The display being rendered, if applicable. |
Definition at line 21 of file theme.inc.
00021 { 00022 $themes = array(); 00023 00024 if ($display) { 00025 $themes[] = $hook . '__' . $view->name . '__' . $display->id; 00026 $themes[] = $hook . '__' . $display->id; 00027 $themes[] = $hook . '__' . preg_replace('/[^a-z0-9]/', '-', strtolower($view->tag)); 00028 if ($display->id != $display->display_plugin) { 00029 $themes[] = $hook . '__' . $view->name . '__' . $display->display_plugin; 00030 $themes[] = $hook . '__' . $display->display_plugin; 00031 } 00032 } 00033 $themes[] = $hook . '__' . $view->name; 00034 $themes[] = $hook; 00035 return $themes; 00036 }
| template_preprocess_views_exposed_form | ( | &$ | vars | ) |
Default theme function for all filter forms.
Definition at line 553 of file theme.inc.
00553 { 00554 views_add_css('views'); 00555 $form = &$vars['form']; 00556 00557 // Put all single checkboxes together in the last spot. 00558 $checkboxes = ''; 00559 00560 if (!empty($form['q'])) { 00561 $vars['q'] = drupal_render($form['q']); 00562 } 00563 00564 $vars['widgets'] = array(); 00565 foreach ($form['#info'] as $id => $info) { 00566 // Set aside checkboxes. 00567 if (isset($form[$info['value']]['#type']) && $form[$info['value']]['#type'] == 'checkbox') { 00568 $checkboxes .= drupal_render($form[$info['value']]); 00569 continue; 00570 } 00571 $widget = new stdClass; 00572 // set up defaults so that there's always something there. 00573 $widget->label = $widget->operator = $widget->widget = NULL; 00574 00575 $widget->id = $form[$info['value']]['#id']; 00576 if (!empty($info['label'])) { 00577 $widget->label = $info['label']; 00578 } 00579 if (!empty($info['operator'])) { 00580 $widget->operator = drupal_render($form[$info['operator']]); 00581 } 00582 $widget->widget = drupal_render($form[$info['value']]); 00583 $vars['widgets'][$id] = $widget; 00584 } 00585 00586 // Wrap up all the checkboxes we set aside into a widget. 00587 if ($checkboxes) { 00588 $widget = new stdClass; 00589 // set up defaults so that there's always something there. 00590 $widget->label = $widget->operator = $widget->widget = NULL; 00591 $widget->widget = $checkboxes; 00592 $vars['widgets']['checkboxes'] = $widget; 00593 } 00594 00595 // Don't render these: 00596 unset($form['form_id']); 00597 unset($form['form_build_id']); 00598 unset($form['form_token']); 00599 00600 // This includes the submit button. 00601 $vars['button'] = drupal_render($form); 00602 }
| template_preprocess_views_view | ( | &$ | vars | ) |
Preprocess the primary theme implementation for a view.
Definition at line 41 of file theme.inc.
References $dom_id.
00041 { 00042 global $base_path; 00043 00044 $view = $vars['view']; 00045 00046 $vars['rows'] = !empty($view->result) || !empty($view->style_plugin->definition['even empty']) ? $view->style_plugin->render($view->result) : ''; 00047 00048 $vars['css_name'] = views_css_safe($view->name); 00049 $vars['name'] = $view->name; 00050 $vars['display_id'] = $view->current_display; 00051 00052 if (!$vars['rows']) { 00053 $vars['empty'] = $view->display_handler->render_empty(); 00054 if (!$view->display_handler->get_option('header_empty')) { 00055 $vars['header'] = ''; 00056 } 00057 if (!$view->display_handler->get_option('footer_empty')) { 00058 $vars['footer'] = ''; 00059 } 00060 } 00061 else { 00062 $vars['empty'] = ''; 00063 $header = TRUE; 00064 } 00065 00066 $vars['exposed'] = !empty($view->exposed_widgets) ? $view->exposed_widgets : ''; 00067 if (!isset($vars['header'])) { 00068 $vars['header'] = $view->display_handler->render_header(); 00069 } 00070 if (!isset($vars['footer'])) { 00071 $vars['footer'] = $view->display_handler->render_footer(); 00072 } 00073 $vars['more'] = $view->display_handler->render_more_link(); 00074 $vars['feed_icon'] = !empty($view->feed_icon) ? $view->feed_icon : ''; 00075 00076 $vars['attachment_before'] = !empty($view->attachment_before) ? $view->attachment_before : ''; 00077 $vars['attachment_after'] = !empty($view->attachment_after) ? $view->attachment_after : ''; 00078 00079 $vars['pager'] = ''; 00080 00081 $exposed_input = isset($view->exposed_data_raw) ? $view->exposed_data_raw : NULL; 00082 if ($view->display_handler->render_pager()) { 00083 $pager_type = ($view->pager['use_pager'] === 'mini' ? 'views_mini_pager' : 'pager'); 00084 $pager_theme = views_theme_functions($pager_type, $view, $view->display_handler->display); 00085 $vars['pager'] = theme($pager_theme, $exposed_input, $view->pager['items_per_page'], $view->pager['element']); 00086 } 00087 00088 // if administrator, add some links. These used to be tabs, but this is better. 00089 if (user_access('administer views') && module_exists('views_ui') && empty($view->hide_admin_links) && !variable_get('views_no_hover_links', FALSE)) { 00090 $vars['admin_links_raw'] = array( 00091 array( 00092 'title' => t('Edit'), 00093 'alt' => t("Edit this view"), 00094 'href' => "admin/build/views/edit/$view->name", 00095 'fragment' => 'views-tab-' . $view->current_display, 00096 'query' => drupal_get_destination(), 00097 ), 00098 array( 00099 'title' => t('Export'), 00100 'alt' => t("Export this view"), 00101 'href' => "admin/build/views/export/$view->name", 00102 ), 00103 array( 00104 'title' => t('Clone'), 00105 'alt' => t("Create a copy of this view"), 00106 'href' => "admin/build/views/clone/$view->name", 00107 ), 00108 ); 00109 00110 drupal_alter('views_admin_links', $vars['admin_links_raw'], $view); 00111 $vars['admin_links'] = theme('links', $vars['admin_links_raw']); 00112 } 00113 else { 00114 $vars['admin_links'] = ''; 00115 $vars['admin_links_raw'] = array(); 00116 } 00117 views_add_css('views'); 00118 00119 // Our JavaScript needs to have some means to find the HTML belonging to this 00120 // view. 00121 // 00122 // It is true that the DIV wrapper has classes denoting the name of the view 00123 // and its display ID, but this is not enough to unequivocally match a view 00124 // with its HTML, because one view may appear several times on the page. So 00125 // we set up a running counter, $dom_id, to issue a "unique" identifier for 00126 // each view. This identifier is written to both Drupal.settings and the DIV 00127 // wrapper. 00128 static $dom_id = 1; 00129 $vars['dom_id'] = !empty($view->dom_id) ? $view->dom_id : $dom_id++; 00130 00131 // If using AJAX, send identifying data about this view. 00132 if ($view->use_ajax) { 00133 $settings = array( 00134 'views' => array( 00135 'ajax_path' => url('views/ajax'), 00136 'ajaxViews' => array( 00137 array( 00138 'view_name' => $view->name, 00139 'view_display_id' => $view->current_display, 00140 'view_args' => implode('/', $view->args), 00141 'view_path' => $_GET['q'], 00142 // Pass through URL to ensure we get e.g. language prefixes. 00143 // 'view_base_path' => isset($view->display['page']) ? substr(url($view->display['page']->display_options['path']), strlen($base_path)) : '', 00144 'view_base_path' => $view->get_path(), 00145 'view_dom_id' => $vars['dom_id'], 00146 // To fit multiple views on a page, the programmer may have 00147 // overridden the display's pager_element. 00148 'pager_element' => $view->pager['element'], 00149 ), 00150 ), 00151 ), 00152 ); 00153 00154 drupal_add_js($settings, 'setting'); 00155 views_add_js('ajax_view'); 00156 } 00157 }
| template_preprocess_views_view_field | ( | &$ | vars | ) |
| template_preprocess_views_view_fields | ( | &$ | vars | ) |
Preprocess theme function to print a single record from a row, with fields.
Definition at line 162 of file theme.inc.
References $field.
00162 { 00163 $view = $vars['view']; 00164 00165 // Loop through the fields for this view. 00166 $inline = FALSE; 00167 $vars['fields'] = array(); // ensure it's at least an empty array. 00168 foreach ($view->field as $id => $field) { 00169 // render this even if set to exclude so it can be used elsewhere. 00170 $field_output = $view->style_plugin->get_field($view->row_index, $id); 00171 $empty = $field_output !== 0 && empty($field_output); 00172 if (empty($field->options['exclude']) && (!$empty || empty($field->options['hide_empty']))) { 00173 $object = new stdClass(); 00174 00175 $object->content = $field_output; 00176 if (isset($view->field[$id]->field_alias) && isset($vars['row']->{$view->field[$id]->field_alias})) { 00177 $object->raw = $vars['row']->{$view->field[$id]->field_alias}; 00178 } 00179 else { 00180 $object->raw = NULL; // make sure it exists to reduce NOTICE 00181 } 00182 $object->inline = !empty($vars['options']['inline'][$id]); 00183 $object->inline_html = $object->inline ? 'span' : 'div'; 00184 if (!empty($vars['options']['separator']) && $inline && $object->inline && $object->content) { 00185 $object->separator = filter_xss_admin($vars['options']['separator']); 00186 } 00187 00188 $inline = $object->inline; 00189 00190 $object->handler = &$view->field[$id]; 00191 $object->element_type = $object->handler->element_type(); 00192 00193 $object->class = views_css_safe($id); 00194 $object->label = check_plain($view->field[$id]->label()); 00195 $vars['fields'][$id] = $object; 00196 } 00197 } 00198 00199 }
| template_preprocess_views_view_grid | ( | &$ | vars | ) |
Display a view as a grid style.
Definition at line 384 of file theme.inc.
References $item.
00384 { 00385 $view = $vars['view']; 00386 $result = $view->result; 00387 $options = $view->style_plugin->options; 00388 $handler = $view->style_plugin; 00389 00390 $columns = $options['columns']; 00391 00392 $rows = array(); 00393 00394 if ($options['alignment'] == 'horizontal') { 00395 $row = array(); 00396 $row_count = 0; 00397 foreach ($vars['rows'] as $count => $item) { 00398 $row[] = $item; 00399 $row_count++; 00400 if (($count + 1) % $columns == 0) { 00401 $rows[] = $row; 00402 $row = array(); 00403 $row_count = 0; 00404 } 00405 } 00406 if ($row) { 00407 // Fill up the last line. 00408 for ($i = 0; $i < ($columns - $row_count); $i++) { 00409 $row[] = ''; 00410 } 00411 $rows[] = $row; 00412 } 00413 } 00414 else { 00415 $num_rows = floor(count($vars['rows']) / $columns); 00416 // The remainders are the 'odd' columns that are slightly longer. 00417 $remainders = count($vars['rows']) % $columns; 00418 $row = 0; 00419 $col = 0; 00420 foreach ($vars['rows'] as $count => $item) { 00421 $rows[$row][$col] = $item; 00422 $row++; 00423 00424 if (!$remainders && $row == $num_rows) { 00425 $row = 0; 00426 $col++; 00427 } 00428 else if ($remainders && $row == $num_rows + 1) { 00429 $row = 0; 00430 $col++; 00431 $remainders--; 00432 } 00433 } 00434 for ($i = 0; $i < count($rows[0]); $i++) { 00435 // This should be string so that's okay :) 00436 if (!isset($rows[count($rows) - 1][$i])) { 00437 $rows[count($rows) - 1][$i] = ''; 00438 } 00439 } 00440 } 00441 $vars['rows'] = $rows; 00442 }
| template_preprocess_views_view_list | ( | &$ | vars | ) |
Display the view as an HTML list element.
Definition at line 467 of file theme.inc.
References template_preprocess_views_view_unformatted().
00467 { 00468 template_preprocess_views_view_unformatted($vars); 00469 }
| template_preprocess_views_view_row_rss | ( | &$ | vars | ) |
Default theme function for all RSS rows.
Definition at line 539 of file theme.inc.
References $item.
00539 { 00540 $view = &$vars['view']; 00541 $options = &$vars['options']; 00542 $item = &$vars['row']; 00543 00544 $vars['title'] = check_plain($item->title); 00545 $vars['link'] = check_url($item->link); 00546 $vars['description'] = check_plain($item->description); 00547 $vars['item_elements'] = empty($item->elements) ? '' : format_xml_elements($item->elements); 00548 }
| template_preprocess_views_view_rss | ( | &$ | vars | ) |
Preprocess an RSS feed.
Definition at line 474 of file theme.inc.
References $description, $items, and $title.
00474 { 00475 global $base_url; 00476 global $language; 00477 00478 $view = &$vars['view']; 00479 $options = &$vars['options']; 00480 $items = &$vars['rows']; 00481 00482 $style = &$view->style_plugin; 00483 00484 if (!empty($options['mission_description'])) { 00485 $description = variable_get('site_mission', ''); 00486 } 00487 else { 00488 $description = $options['description']; 00489 } 00490 // The RSS 2.0 "spec" doesn't indicate HTML can be used in the description. 00491 // We strip all HTML tags, but need to prevent double encoding from properly 00492 // escaped source data (such as & becoming &amp;). 00493 $vars['description'] = check_plain(decode_entities(strip_tags($description))); 00494 00495 if ($view->display_handler->get_option('sitename_title')) { 00496 $title = variable_get('site_name', 'Drupal'); 00497 if ($slogan = variable_get('site_slogan', '')) { 00498 $title .= ' - ' . $slogan; 00499 } 00500 } 00501 else { 00502 $title = $view->get_title(); 00503 } 00504 $vars['title'] = check_plain($title); 00505 00506 // Figure out which display which has a path we're using for this feed. If there isn't 00507 // one, use the global $base_url 00508 $link_display_id = $view->display_handler->get_link_display(); 00509 if ($link_display_id && !empty($view->display[$link_display_id])) { 00510 $path = $view->display[$link_display_id]->handler->get_path(); 00511 } 00512 00513 if ($path) { 00514 $path = $view->get_url(NULL, $path); 00515 $url_options = array('absolute' => TRUE); 00516 if (!empty($view->exposed_raw_input)) { 00517 $url_options['query'] = $view->exposed_raw_input; 00518 } 00519 00520 // Compare the link to the default home page; if it's the default home page, just use $base_url. 00521 if ($path == variable_get('site_frontpage', 'node')) { 00522 $path = ''; 00523 } 00524 00525 $vars['link'] = check_url(url($path, $url_options)); 00526 } 00527 00528 $vars['langcode'] = check_plain($language->language); 00529 $vars['namespaces'] = drupal_attributes($style->namespaces); 00530 $vars['items'] = $items; 00531 $vars['channel_elements'] = format_xml_elements($style->channel_elements); 00532 00533 drupal_set_header('Content-Type: application/rss+xml; charset=utf-8'); 00534 }
| template_preprocess_views_view_summary | ( | &$ | vars | ) |
Preprocess theme function to print a single record from a row, with fields.
Definition at line 226 of file theme.inc.
00226 { 00227 $view = $vars['view']; 00228 $argument = $view->argument[$view->build_info['summary_level']]; 00229 00230 $url_options = array(); 00231 00232 if (!empty($view->exposed_raw_input)) { 00233 $url_options['query'] = $view->exposed_raw_input; 00234 } 00235 foreach ($vars['rows'] as $id => $row) { 00236 $vars['rows'][$id]->link = $argument->summary_name($row); 00237 $args = $view->args; 00238 $args[$argument->position] = $argument->summary_argument($row); 00239 00240 $vars['rows'][$id]->url = url($view->get_url($args), $url_options); 00241 $vars['rows'][$id]->count = intval($row->{$argument->count_alias}); 00242 } 00243 }
| template_preprocess_views_view_summary_unformatted | ( | &$ | vars | ) |
Template preprocess theme function to print summary basically unformatted.
Definition at line 249 of file theme.inc.
00249 { 00250 $view = $vars['view']; 00251 $argument = $view->argument[$view->build_info['summary_level']]; 00252 00253 $url_options = array(); 00254 00255 if (!empty($view->exposed_raw_input)) { 00256 $url_options['query'] = $view->exposed_raw_input; 00257 } 00258 00259 $count = 0; 00260 foreach ($vars['rows'] as $id => $row) { 00261 // only false on first time: 00262 if ($count++) { 00263 $vars['rows'][$id]->separator = filter_xss_admin($vars['options']['separator']); 00264 } 00265 $vars['rows'][$id]->link = $argument->summary_name($row); 00266 $args = $view->args; 00267 $args[$argument->position] = $argument->summary_argument($row); 00268 00269 $vars['rows'][$id]->url = url($view->get_url($args), $url_options); 00270 $vars['rows'][$id]->count = intval($row->{$argument->count_alias}); 00271 } 00272 }
| template_preprocess_views_view_table | ( | &$ | vars | ) |
Display a view as a table style.
Definition at line 277 of file theme.inc.
References $field, and $title.
00277 { 00278 $view = $vars['view']; 00279 00280 // We need the raw data for this grouping, which is passed in as $vars['rows']. 00281 // However, the template also needs to use for the rendered fields. We 00282 // therefore swap the raw data out to a new variable and reset $vars['rows'] 00283 // so that it can get rebuilt. 00284 // Store rows so that they may be used by further preprocess functions. 00285 $result = $vars['result'] = $vars['rows']; 00286 $vars['rows'] = array(); 00287 00288 $options = $view->style_plugin->options; 00289 $handler = $view->style_plugin; 00290 00291 $fields = &$view->field; 00292 $columns = $handler->sanitize_columns($options['columns'], $fields); 00293 00294 $active = !empty($handler->active) ? $handler->active : ''; 00295 $order = !empty($handler->order) ? $handler->order : 'asc'; 00296 00297 $query = tablesort_get_querystring(); 00298 if ($query) { 00299 $query = '&' . $query; 00300 } 00301 00302 // Fields must be rendered in order as of Views 2.3, so we will pre-render 00303 // everything. 00304 $renders = $handler->render_fields($result); 00305 00306 foreach ($columns as $field => $column) { 00307 // render the header labels 00308 if ($field == $column && empty($fields[$field]->options['exclude'])) { 00309 $label = check_plain(!empty($fields[$field]) ? $fields[$field]->label() : ''); 00310 if (empty($options['info'][$field]['sortable']) || !$fields[$field]->click_sortable()) { 00311 $vars['header'][$field] = $label; 00312 } 00313 else { 00314 // @todo -- make this a setting 00315 $initial = 'asc'; 00316 00317 if ($active == $field && $order == 'asc') { 00318 $initial = 'desc'; 00319 } 00320 00321 $title = t('sort by @s', array('@s' => $label)); 00322 if ($active == $field) { 00323 $label .= theme('tablesort_indicator', $initial); 00324 } 00325 $link_options = array( 00326 'html' => true, 00327 'attributes' => array('title' => $title), 00328 'query' => 'order=' . urlencode($field) . '&sort=' . $initial . $query, 00329 ); 00330 $vars['header'][$field] = l($label, $_GET['q'], $link_options); 00331 } 00332 } 00333 00334 // Create a second variable so we can easily find what fields we have and what the 00335 // CSS classes should be. 00336 $vars['fields'][$field] = views_css_safe($field); 00337 if ($active == $field) { 00338 $vars['fields'][$field] .= ' active'; 00339 } 00340 00341 // Render each field into its appropriate column. 00342 foreach ($result as $num => $row) { 00343 if (!empty($fields[$field]) && empty($fields[$field]->options['exclude'])) { 00344 $field_output = $renders[$num][$field]; 00345 00346 if (!isset($vars['rows'][$num][$column])) { 00347 $vars['rows'][$num][$column] = ''; 00348 } 00349 00350 // Don't bother with separators and stuff if the field does not show up. 00351 if ($field_output === '') { 00352 continue; 00353 } 00354 00355 // Place the field into the column, along with an optional separator. 00356 if ($vars['rows'][$num][$column] !== '') { 00357 if (!empty($options['info'][$column]['separator'])) { 00358 $vars['rows'][$num][$column] .= filter_xss_admin($options['info'][$column]['separator']); 00359 } 00360 } 00361 00362 $vars['rows'][$num][$column] .= $field_output; 00363 } 00364 } 00365 } 00366 00367 foreach ($vars['rows'] as $num => $row) { 00368 $vars['row_classes'][$num][] = ($num % 2 == 0) ? 'odd' : 'even'; 00369 } 00370 00371 $vars['row_classes'][0][] = 'views-row-first'; 00372 $vars['row_classes'][count($vars['row_classes']) - 1][] = 'views-row-last'; 00373 00374 $vars['class'] = 'views-table'; 00375 if (!empty($options['sticky'])) { 00376 drupal_add_js('misc/tableheader.js'); 00377 $vars['class'] .= " sticky-enabled"; 00378 } 00379 }
| template_preprocess_views_view_unformatted | ( | &$ | vars | ) |
Display the simple view of rows one after another.
Definition at line 447 of file theme.inc.
Referenced by template_preprocess_views_view_list().
00447 { 00448 $view = $vars['view']; 00449 $rows = $vars['rows']; 00450 00451 $vars['classes'] = array(); 00452 // Set up striping values. 00453 foreach ($rows as $id => $row) { 00454 $vars['classes'][$id] = 'views-row'; 00455 $vars['classes'][$id] .= ' views-row-' . ($id + 1); 00456 $vars['classes'][$id] .= ' views-row-' . ($id % 2 ? 'even' : 'odd'); 00457 if ($id == 0) { 00458 $vars['classes'][$id] .= ' views-row-first'; 00459 } 00460 } 00461 $vars['classes'][$id] .= ' views-row-last'; 00462 }
| theme_views_view_field | ( | $ | view, | |
| $ | field, | |||
| $ | row | |||
| ) |
1.4.7