views_megarow.module in Views Megarow 8
Same filename and directory in other branches
File
views_megarow.moduleView source
<?php
function views_megarow_views_data() {
$data['views']['views_megarow_edit_node'] = array(
'field' => array(
'title' => t('Link to quick edit content'),
'help' => t('Provide a simple link to quickly edit the content.'),
'id' => 'views_megarow_node_link_edit',
),
);
return $data;
}
//function template_preprocess_views_view_megarow_table(&$variables) {
// $view = $variables['view'];
//
// // We need the raw data for this grouping, which is passed in
// // as $variables['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 $variables['rows']
// // so that it can get rebuilt.
// // Store rows so that they may be used by further preprocess functions.
// $result = $variables['result'] = $variables['rows'];
// $variables['rows'] = array();
// $variables['header'] = array();
//
// $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';
//
// // A boolean variable which stores whether the table has a responsive class.
// $responsive = FALSE;
//
// $query = tablesort_get_query_parameters();
// if (isset($view->exposed_raw_input)) {
// $query += $view->exposed_raw_input;
// }
//
// // A boolean to store whether the table's header has any labels.
// $has_header_labels = FALSE;
// foreach ($columns as $field => $column) {
// // Create a second variable so we can easily find what fields we have and
// // what the CSS classes should be.
// $variables['fields'][$field] = drupal_clean_css_identifier($field);
// if ($active == $field) {
// $variables['fields'][$field] .= ' active';
// }
//
// // Render the header labels.
// if ($field == $column && empty($fields[$field]->options['exclude'])) {
// $label = String::checkPlain(!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', array('@s' => $label));
// if ($active == $field) {
// $tablesort_indicator = array(
// '#theme' => 'tablesort_indicator',
// '#style' => $initial,
// );
// $label .= drupal_render($tablesort_indicator);
// }
//
// $query['order'] = $field;
// $query['sort'] = $initial;
// $link_options = array(
// 'html' => TRUE,
// 'attributes' => array('title' => $title),
// 'query' => $query,
// );
// $variables['header'][$field]['content'] = l($label, current_path(), $link_options);
// }
//
// // Set up the header label class.
// $variables['header'][$field]['attributes'] = array();
// if ($fields[$field]->options['element_default_classes']) {
// $variables['header'][$field]['attributes']['class'][] = 'views-field';
// $variables['header'][$field]['attributes']['class'][] = 'views-field-' . $variables['fields'][$field];
// }
// $class = $fields[$field]->elementLabelClasses(0);
// if ($class) {
// $variables['header'][$field]['attributes']['class'][] = $class;
// }
// // Add responsive header classes.
// if (!empty($options['info'][$field]['responsive'])) {
// $variables['header'][$field]['attributes']['class'][] = $options['info'][$field]['responsive'];
// $responsive = TRUE;
// }
// // Add a CSS align class to each field if one was set.
// if (!empty($options['info'][$field]['align'])) {
// $variables['header'][$field]['attributes']['class'][] = drupal_clean_css_identifier($options['info'][$field]['align']);
// }
// // Add a header label wrapper if one was selected.
// if ($variables['header'][$field]['content']) {
// $element_label_type = $fields[$field]->elementLabelType(TRUE, TRUE);
// if ($element_label_type) {
// $variables['header'][$field]['content'] = '<' . $element_label_type . '>' . $variables['header'][$field]['content'] . '</' . $element_label_type . '>';
// }
// // Improves accessibility of complex tables.
// $variables['header'][$field]['attributes']['id'] = drupal_html_id('view-' . $field . '-table-column');
// }
// // Check if header label is not empty.
// if (!empty($variables['header'][$field]['content'])) {
// $has_header_labels = TRUE;
// }
//
// $variables['header'][$field]['attributes'] = new Attribute($variables['header'][$field]['attributes']);
// }
//
// // Add a CSS align class to each field if one was set.
// if (!empty($options['info'][$field]['align'])) {
// $variables['fields'][$field] .= ' ' . drupal_clean_css_identifier($options['info'][$field]['align']);
// }
//
// // Render each field into its appropriate column.
// foreach ($result as $num => $row) {
//
// // Skip building the attributes and content if the field is to be excluded
// // from the display.
// if (!empty($fields[$field]->options['exclude'])) {
// continue;
// }
//
// // Reference to the column in the loop to make the code easier to read.
// $column_reference =& $variables['rows'][$num]['columns'][$column];
//
// // Add field classes.
// $column_reference['attributes'] = array();
// if ($fields[$field]->options['element_default_classes']) {
// $column_reference['attributes']['class'][] = 'views-field';
// $column_reference['attributes']['class'][] = 'views-field-' . $variables['fields'][$field];
// }
//
// if ($classes = $fields[$field]->elementClasses($num)) {
// $column_reference['attributes']['class'][] = $classes;
// }
//
// // Add responsive header classes.
// if (!empty($options['info'][$field]['responsive'])) {
// $column_reference['attributes']['class'][] = $options['info'][$field]['responsive'];
// }
//
// // Improves accessibility of complex tables.
// if (isset($variables['header'][$field]['attributes']['id'])) {
// $column_reference['attributes']['headers'] = array($variables['header'][$field]['attributes']['id']);
// }
//
// if (!empty($fields[$field])) {
// $field_output = $handler->getField($num, $field);
// $element_type = $fields[$field]->elementType(TRUE, TRUE);
// if ($element_type) {
// $field_output = '<' . $element_type . '>' . $field_output . '</' . $element_type . '>';
// }
//
// // Only bother with separators and stuff if the field shows up.
// if (!empty($field_output) && empty($column_reference['content'])) {
// // Place the field into the column, along with an optional separator.
// if (!empty($column_reference['content'])) {
// if (!empty($options['info'][$column]['separator'])) {
// $column_reference['content'] .= Xss::filterAdmin($options['info'][$column]['separator']);
// }
// }
// else {
// $column_reference['content'] = '';
// }
// $column_reference['content'] .= $field_output;
// }
// }
// $column_reference['attributes'] = new Attribute($column_reference['attributes']);
// }
//
// // Remove columns if the option is hide empty column is checked and the
// // field is not empty.
// if (!empty($options['info'][$field]['empty_column'])) {
// $empty = TRUE;
// foreach ($variables['rows'] as $columns) {
// $empty &= empty($columns[$column]);
// }
// if ($empty) {
// foreach ($variables['rows'] as &$column_items) {
// unset($column_items[$column]);
// unset($variables['header'][$column]);
// }
// }
// }
// }
//
// // Hide table header if all labels are empty.
// if (!$has_header_labels) {
// $variables['header'] = array();
// }
//
// foreach ($variables['rows'] as $num => $row) {
// $variables['rows'][$num]['attributes'] = array();
// if ($row_class = $handler->getRowClass($num)) {
// $variables['rows'][$num]['attributes']['class'][] = $row_class;
// }
// $variables['rows'][$num]['attributes'] = new Attribute($variables['rows'][$num]['attributes']);
// }
//
// $variables['attributes']['class'][] = 'views-table';
// $variables['attributes']['class'][] = 'views-view-table';
// if (empty($variables['rows']) && !empty($options['empty_table'])) {
// $build = $view->display_handler->renderArea('empty');
// $variables['rows'][0]['columns'][0]['content'] = drupal_render($build);
// $variables['rows'][0]['attributes'] = new Attribute(array('class' => 'odd'));
// // Calculate the amounts of rows with output.
// $variables['rows'][0]['columns'][0]['attributes'] = new Attribute(array(
// 'colspan' => count($variables['header']),
// 'class' => 'views-empty',
// ));
// }
//
// if (!empty($options['sticky'])) {
// $variables['view']->element['#attached']['library'][] = 'core/drupal.tableheader';
// $variables['attributes']['class'][] = "sticky-enabled";
// }
// $variables['attributes']['class'][] = 'cols-' . count($variables['header']);
//
// // Add the caption to the list if set.
// if (!empty($handler->options['caption'])) {
// $variables['caption'] = Xss::filterAdmin($handler->options['caption']);
// $variables['caption_needed'] = TRUE;
// }
// else {
// $variables['caption'] = '';
// $variables['caption_needed'] = FALSE;
// }
//
// $variables['summary'] = $handler->options['summary'];
// $variables['description'] = $handler->options['description'];
// $variables['caption_needed'] |= !empty($variables['summary']) || !empty($variables['description']);
//
// // If the table has headers and it should react responsively to columns hidden
// // with the classes represented by the constants RESPONSIVE_PRIORITY_MEDIUM
// // and RESPONSIVE_PRIORITY_LOW, add the tableresponsive behaviors.
// if (isset($variables['header']) && $responsive) {
// $variables['view']->element['#attached']['library'][] = 'core/drupal.tableresponsive';
// // Add 'responsive-enabled' class to the table to identify it for JS.
// // This is needed to target tables constructed by this function.
// $variables['attributes']['class'][] = 'responsive-enabled';
// }
//}
Functions
Name | Description |
---|---|
views_megarow_views_data |