12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115 |
- <?php
- use Drupal\Component\Utility\Html;
- use Drupal\Component\Utility\Xss;
- use Drupal\Core\Template\Attribute;
- use Drupal\Core\Url;
- use Drupal\Core\Utility\TableSort;
- function template_preprocess_views_view(&$variables) {
- $view = $variables['view'];
- $id = $view->storage->id();
- $variables['css_name'] = Html::cleanCssIdentifier($id);
- $variables['id'] = $id;
- $variables['display_id'] = $view->current_display;
-
-
-
-
- $variables['title'] = '';
- $css_class = $view->display_handler->getOption('css_class');
- if (!empty($css_class)) {
-
-
-
-
- $bc_classes = explode(' ', preg_replace('/[^a-zA-Z0-9- ]/', '-', $css_class));
-
- $sanitized_classes = array_map('\Drupal\Component\Utility\Html::cleanCssIdentifier', explode(' ', $css_class));
- $view_classes = array_unique(array_merge($bc_classes, $sanitized_classes));
-
- $variables['attributes']['class'] = !empty($variables['attributes']['class']) ? array_merge($variables['attributes']['class'], $view_classes) : $view_classes;
- $variables['css_class'] = implode(' ', $view_classes);
- }
-
-
-
-
-
-
-
-
-
-
- $variables['view_array'] = $variables['view']->element;
-
-
- if (empty($view->is_attachment)) {
-
-
-
-
-
-
-
-
-
- $variables['dom_id'] = $view->dom_id;
- }
- }
- function template_preprocess_views_view_fields(&$variables) {
- $view = $variables['view'];
-
- $previous_inline = FALSE;
-
- $variables['fields'] = [];
-
- $row = $variables['row'];
- foreach ($view->field as $id => $field) {
-
- $field_output = $view->style_plugin->getField($row->index, $id);
- $empty = $field->isValueEmpty($field_output, $field->options['empty_zero']);
- if (empty($field->options['exclude']) && (!$empty || (empty($field->options['hide_empty']) && empty($variables['options']['hide_empty'])))) {
- $object = new stdClass();
- $object->handler = $view->field[$id];
- $object->inline = !empty($variables['options']['inline'][$id]);
-
-
- $object->has_label_colon = FALSE;
- $object->element_type = $object->handler->elementType(TRUE, !$variables['options']['default_field_elements'], $object->inline);
- if ($object->element_type) {
- $attributes = [];
- if ($object->handler->options['element_default_classes']) {
- $attributes['class'][] = 'field-content';
- }
- if ($classes = $object->handler->elementClasses($row->index)) {
- $attributes['class'][] = $classes;
- }
- $object->element_attributes = new Attribute($attributes);
- }
- $object->content = $field_output;
- if (isset($view->field[$id]->field_alias) && isset($row->{$view->field[$id]->field_alias})) {
- $object->raw = $row->{$view->field[$id]->field_alias};
- }
- else {
-
- $object->raw = NULL;
- }
- if (!empty($variables['options']['separator']) && $previous_inline && $object->inline && $object->content) {
- $object->separator = [
- '#markup' => $variables['options']['separator'],
- ];
- }
- $object->class = Html::cleanCssIdentifier($id);
- $previous_inline = $object->inline;
-
- $object->wrapper_element = $object->handler->elementWrapperType(TRUE, TRUE);
- if ($object->wrapper_element === '' && $variables['options']['default_field_elements']) {
- $object->wrapper_element = $object->inline ? 'span' : 'div';
- }
-
- if ($object->wrapper_element) {
- $attributes = [];
- if ($object->handler->options['element_default_classes']) {
- $attributes['class'][] = 'views-field';
- $attributes['class'][] = 'views-field-' . $object->class;
- }
- if ($classes = $object->handler->elementWrapperClasses($row->index)) {
- $attributes['class'][] = $classes;
- }
- $object->wrapper_attributes = new Attribute($attributes);
- }
-
- $object->label = $view->field[$id]->label();
-
- if ($object->label) {
-
- if ($object->handler->options['element_label_colon']) {
- $object->label_suffix = ': ';
- $object->has_label_colon = TRUE;
- }
-
- $object->label_element = $object->handler->elementLabelType(TRUE, !$variables['options']['default_field_elements']);
-
- if ($object->label_element) {
- $attributes = [];
- if ($object->handler->options['element_default_classes']) {
- $attributes['class'][] = 'views-label';
- $attributes['class'][] = 'views-label-' . $object->class;
- }
-
- $element_label_class = $object->handler->elementLabelClasses($row->index);
- if ($element_label_class) {
- $attributes['class'][] = $element_label_class;
- }
- $object->label_attributes = new Attribute($attributes);
- }
- }
- $variables['fields'][$id] = $object;
- }
- }
- }
- function template_preprocess_views_view_grouping(&$variables) {
- $variables['content'] = $variables['view']->style_plugin->renderGroupingSets($variables['rows'], $variables['grouping_level']);
- }
- function template_preprocess_views_view_field(&$variables) {
- $variables['output'] = $variables['field']->advancedRender($variables['row']);
- }
- function template_preprocess_views_view_summary(&$variables) {
-
- $view = $variables['view'];
- $argument = $view->argument[$view->build_info['summary_level']];
- $url_options = [];
- if (!empty($view->exposed_raw_input)) {
- $url_options['query'] = $view->exposed_raw_input;
- }
- $active_urls = [
-
- Url::fromRoute('<current>', [], ['alias' => TRUE])->toString(),
-
- Url::fromRouteMatch(\Drupal::routeMatch())->setOption('alias', TRUE)->toString(),
-
- Url::fromRoute('<current>')->toString(),
-
- Url::fromRouteMatch(\Drupal::routeMatch())->toString(),
- ];
- $active_urls = array_combine($active_urls, $active_urls);
-
-
-
- $row_args = [];
- foreach ($variables['rows'] as $id => $row) {
- $row_args[$id] = $argument->summaryArgument($row);
- }
- $argument->processSummaryArguments($row_args);
- foreach ($variables['rows'] as $id => $row) {
- $variables['rows'][$id]->attributes = [];
- $variables['rows'][$id]->link = $argument->summaryName($row);
- $args = $view->args;
- $args[$argument->position] = $row_args[$id];
- if (!empty($argument->options['summary_options']['base_path'])) {
- $base_path = $argument->options['summary_options']['base_path'];
- $tokens = $view->getDisplay()->getArgumentsTokens();
- $base_path = $argument->globalTokenReplace($base_path, $tokens);
-
-
- $url = Url::fromUserInput('/' . $base_path);
- try {
-
- $route_name = $url->getRouteName();
- $route = \Drupal::service('router.route_provider')->getRouteByName($route_name);
- $route_variables = $route->compile()->getVariables();
- $parameters = $url->getRouteParameters();
- foreach ($route_variables as $variable_name) {
- $parameters[$variable_name] = array_shift($args);
- }
- $url->setRouteParameters($parameters);
- }
- catch (Exception $e) {
-
- $url = Url::fromRoute('<front>');
- }
- }
- else {
- $url = $view->getUrl($args)->setOptions($url_options);
- }
- $variables['rows'][$id]->url = $url->toString();
- $variables['rows'][$id]->count = intval($row->{$argument->count_alias});
- $variables['rows'][$id]->attributes = new Attribute($variables['rows'][$id]->attributes);
- $variables['rows'][$id]->active = isset($active_urls[$variables['rows'][$id]->url]);
- }
- }
- function template_preprocess_views_view_summary_unformatted(&$variables) {
-
- $view = $variables['view'];
- $argument = $view->argument[$view->build_info['summary_level']];
- $url_options = [];
- if (!empty($view->exposed_raw_input)) {
- $url_options['query'] = $view->exposed_raw_input;
- }
- $count = 0;
- $active_urls = [
-
- Url::fromRoute('<current>', [], ['alias' => TRUE])->toString(),
-
- Url::fromRoute('<current>')->toString(),
- ];
- $active_urls = array_combine($active_urls, $active_urls);
-
-
-
- $row_args = [];
- foreach ($variables['rows'] as $id => $row) {
- $row_args[$id] = $argument->summaryArgument($row);
- }
- $argument->processSummaryArguments($row_args);
- foreach ($variables['rows'] as $id => $row) {
-
- if ($count++) {
- $variables['rows'][$id]->separator = Xss::filterAdmin($variables['options']['separator']);
- }
- $variables['rows'][$id]->attributes = [];
- $variables['rows'][$id]->link = $argument->summaryName($row);
- $args = $view->args;
- $args[$argument->position] = $row_args[$id];
- if (!empty($argument->options['summary_options']['base_path'])) {
- $base_path = $argument->options['summary_options']['base_path'];
- $tokens = $view->getDisplay()->getArgumentsTokens();
- $base_path = $argument->globalTokenReplace($base_path, $tokens);
-
-
- $url = Url::fromUserInput('/' . $base_path);
- try {
-
- $route = \Drupal::service('router.route_provider')->getRouteByName($url->getRouteName());
- $route_variables = $route->compile()->getVariables();
- $parameters = $url->getRouteParameters();
- foreach ($route_variables as $variable_name) {
- $parameters[$variable_name] = array_shift($args);
- }
- $url->setRouteParameters($parameters);
- }
- catch (Exception $e) {
-
- $url = Url::fromRoute('<front>');
- }
- }
- else {
- $url = $view->getUrl($args)->setOptions($url_options);
- }
- $variables['rows'][$id]->url = $url->toString();
- $variables['rows'][$id]->count = intval($row->{$argument->count_alias});
- $variables['rows'][$id]->active = isset($active_urls[$variables['rows'][$id]->url]);
- $variables['rows'][$id]->attributes = new Attribute($variables['rows'][$id]->attributes);
- }
- }
- function template_preprocess_views_view_table(&$variables) {
- $view = $variables['view'];
-
-
-
-
-
-
- $result = $variables['result'] = $variables['rows'];
- $variables['rows'] = [];
- $variables['header'] = [];
- $options = $view->style_plugin->options;
- $handler = $view->style_plugin;
- $fields = &$view->field;
- $columns = $handler->sanitizeColumns($options['columns'], $fields);
- $active = !empty($handler->active) ? $handler->active : '';
- $order = !empty($handler->order) ? $handler->order : 'asc';
-
- $responsive = FALSE;
-
-
-
-
- $route_name = !empty($view->live_preview) ? '<current>' : '<none>';
- $query = TableSort::getQueryParameters(\Drupal::request());
- if (isset($view->exposed_raw_input)) {
- $query += $view->exposed_raw_input;
- }
-
- $has_header_labels = FALSE;
- foreach ($columns as $field => $column) {
-
-
- $variables['fields'][$field] = Html::cleanCssIdentifier($field);
- if ($active == $field) {
- $variables['fields'][$field] .= ' is-active';
- }
-
- if ($field == $column && empty($fields[$field]->options['exclude'])) {
- $label = !empty($fields[$field]) ? $fields[$field]->label() : '';
- if (empty($options['info'][$field]['sortable']) || !$fields[$field]->clickSortable()) {
- $variables['header'][$field]['content'] = $label;
- }
- else {
- $initial = !empty($options['info'][$field]['default_sort_order']) ? $options['info'][$field]['default_sort_order'] : 'asc';
- if ($active == $field) {
- $initial = ($order == 'asc') ? 'desc' : 'asc';
- }
- $title = t('sort by @s', ['@s' => $label]);
- if ($active == $field) {
- $variables['header'][$field]['sort_indicator'] = [
- '#theme' => 'tablesort_indicator',
- '#style' => $initial,
- ];
- }
- $query['order'] = $field;
- $query['sort'] = $initial;
- $link_options = [
- 'query' => $query,
- ];
- $url = new Url($route_name, [], $link_options);
- $variables['header'][$field]['url'] = $url->toString();
- $variables['header'][$field]['content'] = $label;
- $variables['header'][$field]['title'] = $title;
- }
- $variables['header'][$field]['default_classes'] = $fields[$field]->options['element_default_classes'];
-
- $variables['header'][$field]['attributes'] = [];
- $class = $fields[$field]->elementLabelClasses(0);
- if ($class) {
- $variables['header'][$field]['attributes']['class'][] = $class;
- }
-
- if (!empty($options['info'][$field]['responsive'])) {
- $variables['header'][$field]['attributes']['class'][] = $options['info'][$field]['responsive'];
- $responsive = TRUE;
- }
-
- if (!empty($options['info'][$field]['align'])) {
- $variables['header'][$field]['attributes']['class'][] = Html::cleanCssIdentifier($options['info'][$field]['align']);
- }
-
- if ($variables['header'][$field]['content']) {
- $element_label_type = $fields[$field]->elementLabelType(TRUE, TRUE);
- if ($element_label_type) {
- $variables['header'][$field]['wrapper_element'] = $element_label_type;
- }
-
- $variables['header'][$field]['attributes']['id'] = Html::getUniqueId('view-' . $field . '-table-column');
- }
-
- if (!empty($variables['header'][$field]['content'])) {
- $has_header_labels = TRUE;
- }
- $variables['header'][$field]['attributes'] = new Attribute($variables['header'][$field]['attributes']);
- }
-
- if (!empty($options['info'][$field]['align'])) {
- $variables['fields'][$field] .= ' ' . Html::cleanCssIdentifier($options['info'][$field]['align']);
- }
-
- foreach ($result as $num => $row) {
-
-
- if (!empty($fields[$field]->options['exclude'])) {
- continue;
- }
-
- $column_reference =& $variables['rows'][$num]['columns'][$column];
- $column_reference['default_classes'] = $fields[$field]->options['element_default_classes'];
-
-
- $column_reference['fields'][] = $variables['fields'][$field];
-
- if (!isset($column_reference['attributes'])) {
- $column_reference['attributes'] = [];
- }
- if ($classes = $fields[$field]->elementClasses($num)) {
- $column_reference['attributes']['class'][] = $classes;
- }
-
- if (!empty($options['info'][$field]['responsive'])) {
- $column_reference['attributes']['class'][] = $options['info'][$field]['responsive'];
- }
-
- if (isset($variables['header'][$field]['attributes']['id'])) {
- $column_reference['attributes']['headers'] = [$variables['header'][$field]['attributes']['id']];
- }
- if (!empty($fields[$field])) {
- $field_output = $handler->getField($num, $field);
- $column_reference['wrapper_element'] = $fields[$field]->elementType(TRUE, TRUE);
- if (!isset($column_reference['content'])) {
- $column_reference['content'] = [];
- }
-
-
- if (trim($field_output) != '') {
- if (!empty($column_reference['content']) && !empty($options['info'][$column]['separator'])) {
- $column_reference['content'][] = [
- 'separator' => ['#markup' => $options['info'][$column]['separator']],
- 'field_output' => ['#markup' => $field_output],
- ];
- }
- else {
- $column_reference['content'][] = [
- 'field_output' => ['#markup' => $field_output],
- ];
- }
- }
- }
- $column_reference['attributes'] = new Attribute($column_reference['attributes']);
- }
-
-
- if (!empty($options['info'][$field]['empty_column'])) {
- $empty = TRUE;
- foreach ($variables['rows'] as $columns) {
- $empty &= empty($columns['columns'][$column]['content']);
- }
- if ($empty) {
- foreach ($variables['rows'] as &$column_items) {
- unset($column_items['columns'][$column]);
- }
- unset($variables['header'][$column]);
- }
- }
- }
-
- if (!$has_header_labels) {
- $variables['header'] = [];
- }
- foreach ($variables['rows'] as $num => $row) {
- $variables['rows'][$num]['attributes'] = [];
- if ($row_class = $handler->getRowClass($num)) {
- $variables['rows'][$num]['attributes']['class'][] = $row_class;
- }
- $variables['rows'][$num]['attributes'] = new Attribute($variables['rows'][$num]['attributes']);
- }
- if (empty($variables['rows']) && !empty($options['empty_table'])) {
- $build = $view->display_handler->renderArea('empty');
- $variables['rows'][0]['columns'][0]['content'][0]['field_output'] = $build;
- $variables['rows'][0]['attributes'] = new Attribute(['class' => ['odd']]);
-
- $variables['rows'][0]['columns'][0]['attributes'] = new Attribute([
- 'colspan' => count($variables['header']),
- 'class' => ['views-empty'],
- ]);
- }
- $variables['sticky'] = FALSE;
- if (!empty($options['sticky'])) {
- $variables['view']->element['#attached']['library'][] = 'core/drupal.tableheader';
- $variables['sticky'] = TRUE;
- }
-
- if (!empty($handler->options['caption'])) {
- $variables['caption'] = ['#markup' => $handler->options['caption']];
- $variables['caption_needed'] = TRUE;
- }
- elseif (!empty($variables['title'])) {
- $variables['caption'] = ['#markup' => $variables['title']];
- $variables['caption_needed'] = TRUE;
- }
- else {
- $variables['caption'] = '';
- $variables['caption_needed'] = FALSE;
- }
-
-
- $variables['summary'] = $handler->options['summary'];
- $variables['description'] = $handler->options['description'];
- if (!empty($handler->options['summary']) || !empty($handler->options['description'])) {
- $variables['summary_element'] = [
- '#type' => 'details',
- '#title' => $handler->options['summary'],
-
-
- 'description' => [
- '#type' => 'inline_template',
- '#template' => '{{ description }}',
- '#context' => [
- 'description' => $handler->options['description'],
- ],
- ],
- ];
- $variables['caption_needed'] = TRUE;
- }
- $variables['responsive'] = FALSE;
-
-
-
- if (isset($variables['header']) && $responsive) {
- $variables['view']->element['#attached']['library'][] = 'core/drupal.tableresponsive';
-
-
- $variables['responsive'] = TRUE;
- }
- }
- function template_preprocess_views_view_grid(&$variables) {
- $options = $variables['options'] = $variables['view']->style_plugin->options;
- $horizontal = ($options['alignment'] === 'horizontal');
- $col = 0;
- $row = 0;
- $items = [];
- $remainders = count($variables['rows']) % $options['columns'];
- $num_rows = floor(count($variables['rows']) / $options['columns']);
-
- foreach ($variables['rows'] as $result_index => $item) {
-
- if ($horizontal) {
- $items[$row]['content'][$col]['content'] = $item;
- }
- else {
- $items[$col]['content'][$row]['content'] = $item;
- }
-
- if (!$horizontal || ($horizontal && empty($items[$row]['attributes']))) {
- $row_attributes = ['class' => []];
-
- $row_class = array_filter(explode(' ', $variables['view']->style_plugin->getCustomClass($result_index, 'row')));
- if (!empty($row_class)) {
- $row_attributes['class'] = array_merge($row_attributes['class'], $row_class);
- }
-
- if ($horizontal) {
- $items[$row]['attributes'] = new Attribute($row_attributes);
- }
- else {
- $items[$col]['content'][$row]['attributes'] = new Attribute($row_attributes);
- }
- }
-
- if ($horizontal || (!$horizontal && empty($items[$col]['attributes']))) {
- $col_attributes = ['class' => []];
-
-
- $col_class = array_filter(explode(' ', $variables['view']->style_plugin->getCustomClass($result_index, 'col')));
- if (!empty($col_class)) {
- $col_attributes['class'] = array_merge($col_attributes['class'], $col_class);
- }
-
- if ($options['automatic_width']) {
- $col_attributes['style'] = 'width: ' . (100 / $options['columns']) . '%;';
- }
-
- if ($horizontal) {
- $items[$row]['content'][$col]['attributes'] = new Attribute($col_attributes);
- }
- else {
- $items[$col]['attributes'] = new Attribute($col_attributes);
- }
- }
-
- if ($horizontal) {
- if ($col == 0 && $col != ($options['columns'] - 1)) {
- $col++;
- }
- elseif ($col >= ($options['columns'] - 1)) {
- $col = 0;
- $row++;
- }
- else {
- $col++;
- }
- }
- else {
- $row++;
- if (!$remainders && $row == $num_rows) {
- $row = 0;
- $col++;
- }
- elseif ($remainders && $row == $num_rows + 1) {
- $row = 0;
- $col++;
- $remainders--;
- }
- }
- }
-
- $variables['items'] = $items;
- }
- function template_preprocess_views_view_unformatted(&$variables) {
- $view = $variables['view'];
- $rows = $variables['rows'];
- $style = $view->style_plugin;
- $options = $style->options;
- $variables['default_row_class'] = !empty($options['default_row_class']);
- foreach ($rows as $id => $row) {
- $variables['rows'][$id] = [];
- $variables['rows'][$id]['content'] = $row;
- $variables['rows'][$id]['attributes'] = new Attribute();
- if ($row_class = $view->style_plugin->getRowClass($id)) {
- $variables['rows'][$id]['attributes']->addClass($row_class);
- }
- }
- }
- function template_preprocess_views_view_list(&$variables) {
- $handler = $variables['view']->style_plugin;
-
- if ($handler->options['class']) {
- $class = explode(' ', $handler->options['class']);
- $class = array_map('\Drupal\Component\Utility\Html::cleanCssIdentifier', $class);
-
- $variables['list']['attributes'] = new Attribute(['class' => $class]);
- }
-
- if ($handler->options['wrapper_class']) {
- $wrapper_class = explode(' ', $handler->options['wrapper_class']);
- $variables['attributes']['class'] = array_map('\Drupal\Component\Utility\Html::cleanCssIdentifier', $wrapper_class);
- }
- $variables['list']['type'] = $handler->options['type'];
- template_preprocess_views_view_unformatted($variables);
- }
- function template_preprocess_views_view_rss(&$variables) {
- $view = $variables['view'];
- $items = $variables['rows'];
- $style = $view->style_plugin;
- $config = \Drupal::config('system.site');
-
-
-
- $variables['description'] = Html::decodeEntities(strip_tags($style->getDescription()));
- if ($view->display_handler->getOption('sitename_title')) {
- $title = $config->get('name');
- if ($slogan = $config->get('slogan')) {
- $title .= ' - ' . $slogan;
- }
- }
- else {
- $title = $view->getTitle();
- }
- $variables['title'] = $title;
- $variables['link'] = Url::fromRoute('<front>')->setAbsolute()->toString();
- $variables['langcode'] = \Drupal::languageManager()->getCurrentLanguage()->getId();
- $variables['namespaces'] = new Attribute($style->namespaces);
- $variables['items'] = $items;
- $variables['channel_elements'] = $style->channel_elements;
-
-
- if (empty($variables['view']->live_preview)) {
- $variables['view']->getResponse()->headers->set('Content-Type', 'application/rss+xml; charset=utf-8');
- }
- }
- function template_preprocess_views_view_row_rss(&$variables) {
- $item = $variables['row'];
- $variables['title'] = $item->title;
- $variables['link'] = $item->link;
-
-
-
-
- if (isset($item->description) && is_array($item->description)) {
- $variables['description'] = (string) \Drupal::service('renderer')->render($item->description);
- }
- $variables['item_elements'] = [];
- foreach ($item->elements as $element) {
- if (isset($element['attributes']) && is_array($element['attributes'])) {
- $element['attributes'] = new Attribute($element['attributes']);
- }
- $variables['item_elements'][] = $element;
- }
- }
- function template_preprocess_views_view_opml(&$variables) {
- $view = $variables['view'];
- $items = $variables['rows'];
- $config = \Drupal::config('system.site');
- if ($view->display_handler->getOption('sitename_title')) {
- $title = $config->get('name');
- if ($slogan = $config->get('slogan')) {
- $title .= ' - ' . $slogan;
- }
- }
- else {
- $title = $view->getTitle();
- }
- $variables['title'] = $title;
- $variables['items'] = $items;
- $variables['updated'] = gmdate(DATE_RFC2822, REQUEST_TIME);
-
-
- if (empty($variables['view']->live_preview)) {
- $variables['view']->getResponse()->headers->set('Content-Type', 'text/xml; charset=utf-8');
- }
- }
- function template_preprocess_views_view_row_opml(&$variables) {
- $item = $variables['row'];
- $variables['attributes'] = new Attribute($item);
- }
- function template_preprocess_views_exposed_form(&$variables) {
- $form = &$variables['form'];
- if (!empty($form['q'])) {
- $variables['q'] = $form['q'];
- }
- foreach ($form['#info'] as $info) {
- if (!empty($info['label'])) {
- $form[$info['value']]['#title'] = $info['label'];
- }
- if (!empty($info['description'])) {
- $form[$info['value']]['#description'] = $info['description'];
- }
- }
- }
- function template_preprocess_views_mini_pager(&$variables) {
-
- $pager_manager = \Drupal::service('pager.manager');
- $tags = &$variables['tags'];
- $element = $variables['element'];
- $parameters = $variables['parameters'];
- $pager = $pager_manager->getPager($element);
- if (!$pager) {
- return;
- }
- $current = $pager->getCurrentPage();
- $total = $pager->getTotalPages();
-
- $variables['items']['current'] = $current + 1;
- if ($total > 1 && $current > 0) {
- $options = [
- 'query' => $pager_manager->getUpdatedParameters($parameters, $element, $current - 1),
- ];
- $variables['items']['previous']['href'] = Url::fromRoute('<current>', [], $options)->toString();
- if (isset($tags[1])) {
- $variables['items']['previous']['text'] = $tags[1];
- }
- $variables['items']['previous']['attributes'] = new Attribute();
- }
- if ($current < ($total - 1)) {
- $options = [
- 'query' => $pager_manager->getUpdatedParameters($parameters, $element, $current + 1),
- ];
- $variables['items']['next']['href'] = Url::fromRoute('<current>', [], $options)->toString();
- if (isset($tags[3])) {
- $variables['items']['next']['text'] = $tags[3];
- }
- $variables['items']['next']['attributes'] = new Attribute();
- }
-
-
- $variables['#cache']['contexts'][] = 'url.query_args';
- $variables['heading_id'] = Html::getUniqueId('pagination-heading');
- }
|