diff --git a/includes/admin.inc b/includes/admin.inc index 01b336f4dda7135c934b0d7380cfa56b0301ceea..0bab69fc7deef9347f1ec906a36a0041aae9c58a 100644 --- a/includes/admin.inc +++ b/includes/admin.inc @@ -676,10 +676,10 @@ function views_ui_add_form_save_submit($form, &$form_state) { $view->save(); $form_state['redirect'] = 'admin/structure/views'; - if (!empty($view->display['page'])) { - $display = $view->display['page']; - if ($display->handler->hasPath()) { - $one_path = $display->handler->getOption('path'); + if (!empty($view->displayHandlers['page'])) { + $display = $view->displayHandlers['page']; + if ($display->hasPath()) { + $one_path = $display->getOption('path'); if (strpos($one_path, '%') === FALSE) { $form_state['redirect'] = $one_path; // PATH TO THE VIEW IF IT HAS ONE return; @@ -1045,8 +1045,8 @@ function views_ui_edit_form($form, &$form_state, $view, $display_id = NULL) { $form['displays']['settings']['#title'] = '<h2>' . t('@display_title details', array('@display_title' => ucwords($display_title))) . '</h2>'; // Add a text that the display is disabled. - if (!empty($view->display[$display_id]->handler)) { - $enabled = $view->display[$display_id]->handler->getOption('enabled'); + if (!empty($view->displayHandlers[$display_id])) { + $enabled = $view->displayHandlers[$display_id]->getOption('enabled'); if (empty($enabled)) { $form['displays']['settings']['disabled']['#markup'] = t('This display is disabled.'); } @@ -1262,9 +1262,9 @@ function views_ui_edit_form_submit_duplicate_display($form, &$form_state) { // Create the new display. $display = $view->display[$display_id]; - $new_display_id = $view->addDisplay($display->display_plugin); + $new_display_id = $view->addDisplay($display['display_plugin']); $view->display[$new_display_id] = clone $display; - $view->display[$new_display_id]->id = $new_display_id; + $view->display[$new_display_id]['id'] = $new_display_id; // By setting the current display the changed marker will appear on the new // display. @@ -1312,7 +1312,7 @@ function views_ui_edit_form_submit_undo_delete_display($form, &$form_state) { function views_ui_edit_form_submit_enable_display($form, &$form_state) { $id = $form_state['display_id']; // setOption doesn't work because this would might affect upper displays - $form_state['view']->display[$id]->handler->setOption('enabled', TRUE); + $form_state['view']->displayHandlers[$id]->setOption('enabled', TRUE); // Store in cache views_ui_cache_set($form_state['view']); @@ -1326,7 +1326,7 @@ function views_ui_edit_form_submit_enable_display($form, &$form_state) { */ function views_ui_edit_form_submit_disable_display($form, &$form_state) { $id = $form_state['display_id']; - $form_state['view']->display[$id]->handler->setOption('enabled', FALSE); + $form_state['view']->displayHandlers[$id]->setOption('enabled', FALSE); // Store in cache views_ui_cache_set($form_state['view']); @@ -1404,7 +1404,7 @@ function views_ui_edit_page_display_tabs($view, $display_id = NULL) { if (!empty($display->deleted)) { $tabs[$id]['#link']['localized_options']['attributes']['class'][] = 'views-display-deleted-link'; } - if (isset($display->display_options['enabled']) && !$display->display_options['enabled']) { + if (isset($display['display_options']['enabled']) && !$display['display_options']['enabled']) { $tabs[$id]['#link']['localized_options']['attributes']['class'][] = 'views-display-disabled-link'; } } @@ -1450,10 +1450,10 @@ function views_ui_get_display_tab($view, $display_id) { $display = $view->display[$display_id]; // If the plugin doesn't exist, display an error message instead of an edit // page. - if (empty($display->handler)) { - $title = isset($display->display_title) ? $display->display_title : t('Invalid'); + if (empty($display)) { + $title = isset($display['display_title']) ? $display['display_title'] : t('Invalid'); // @TODO: Improved UX for the case where a plugin is missing. - $build['#markup'] = t("Error: Display @display refers to a plugin named '@plugin', but that plugin is not available.", array('@display' => $display->id, '@plugin' => $display->display_plugin)); + $build['#markup'] = t("Error: Display @display refers to a plugin named '@plugin', but that plugin is not available.", array('@display' => $display['id'], '@plugin' => $display['display_plugin'])); } // Build the content of the edit page. else { @@ -1475,7 +1475,7 @@ function views_ui_get_display_tab($view, $display_id) { * A renderable page build array. */ function views_ui_get_display_tab_details($view, $display) { - $display_title = views_ui_get_display_label($view, $display->id, FALSE); + $display_title = views_ui_get_display_label($view, $display['id'], FALSE); $build = array( '#theme_wrappers' => array('container'), '#attributes' => array('id' => 'edit-display-settings-details'), @@ -1486,9 +1486,9 @@ function views_ui_get_display_tab_details($view, $display) { // actions in the .ctools-button class. $is_display_deleted = !empty($display->deleted); // The master display cannot be cloned. - $is_default = $display->id == 'default'; + $is_default = $display['id'] == 'default'; // @todo: Figure out why getOption doesn't work here. - $is_enabled = $display->handler->getOption('enabled'); + $is_enabled = $view->displayHandlers[$display['id']]->getOption('enabled'); if (!$is_display_deleted && !$is_default) { $prefix = '<div class="ctools-no-js ctools-button ctools-dropbutton"><div class="ctools-link"><a href="#" class="ctools-twisty ctools-text">open</a></div><div class="ctools-content"><ul class="horizontal right actions">'; @@ -1501,7 +1501,7 @@ function views_ui_get_display_tab_details($view, $display) { $item_element = 'li'; } - if ($display->id != 'default') { + if ($display['id'] != 'default') { $build['top']['#theme_wrappers'] = array('container'); $build['top']['#attributes']['id'] = 'edit-display-settings-top'; $build['top']['#attributes']['class'] = array('views-ui-display-tab-actions', 'views-ui-display-tab-bucket', 'clearfix'); @@ -1524,12 +1524,12 @@ function views_ui_get_display_tab_details($view, $display) { ); } // Add a link to view the page. - elseif ($display->handler->hasPath()) { - $path = $display->handler->getPath(); + elseif ($view->displayHandlers[$display['id']]->hasPath()) { + $path = $view->displayHandlers[$display['id']]->getPath(); if (strpos($path, '%') === FALSE) { $build['top']['actions']['path'] = array( '#type' => 'link', - '#title' => t('view @display', array('@display' => $display->display_title)), + '#title' => t('view @display', array('@display' => $display['display_title'])), '#options' => array('alt' => array(t("Go to the real page for this display"))), '#href' => $path, '#prefix' => '<' . $item_element . ' class="view">', @@ -1582,7 +1582,7 @@ function views_ui_get_display_tab_details($view, $display) { $build['top']['display_title'] = array( '#theme' => 'views_ui_display_tab_setting', '#description' => t('Display name'), - '#link' => $display->handler->optionLink(check_plain($display_title), 'display_title'), + '#link' => $view->displayHandlers[$display['id']]->optionLink(check_plain($display_title), 'display_title'), ); } @@ -1627,7 +1627,7 @@ function views_ui_get_display_tab_details($view, $display) { // Fetch options from the display plugin, with a list of buckets they go into. $options = array(); - $display->handler->optionsSummary($buckets, $options); + $view->displayHandlers[$display['id']]->optionsSummary($buckets, $options); // Place each option into its bucket. foreach ($options as $id => $option) { @@ -1678,23 +1678,23 @@ function views_ui_edit_form_get_build_from_option($id, $option, $view, $display) $option_build['#description'] = $option['title']; - $option_build['#link'] = $display->handler->optionLink($option['value'], $id, '', empty($option['desc']) ? '' : $option['desc']); + $option_build['#link'] = $view->displayHandlers[$display['id']]->optionLink($option['value'], $id, '', empty($option['desc']) ? '' : $option['desc']); $option_build['#links'] = array(); if (!empty($option['links']) && is_array($option['links'])) { foreach ($option['links'] as $link_id => $link_value) { - $option_build['#settings_links'][] = $display->handler->optionLink($option['setting'], $link_id, 'views-button-configure', $link_value); + $option_build['#settings_links'][] = $view->displayHandlers[$display['id']]->optionLink($option['setting'], $link_id, 'views-button-configure', $link_value); } } - if (!empty($display->handler->options['defaults'][$id])) { + if (!empty($view->displayHandlers[$display['id']]->options['defaults'][$id])) { $display_id = 'default'; $option_build['#defaulted'] = TRUE; } else { - $display_id = $display->id; - if (!$display->handler->isDefaultDisplay()) { - if ($display->handler->defaultableSections($id)) { + $display_id = $display['id']; + if (!$view->displayHandlers[$display['id']]->isDefaultDisplay()) { + if ($view->displayHandlers[$display['id']]->defaultableSections($id)) { $option_build['#overridden'] = TRUE; } } @@ -1956,28 +1956,28 @@ function views_ui_import_validate($form, &$form_state) { // Bypass the validation of view pluigns/handlers if option is checked. if (!$form_state['values']['bypass_validation']) { // Make sure that all plugins and handlers needed by this view actually exist. - foreach ($view->display as $id => $display) { - if (empty($display->handler) || !empty($display->handler->broken)) { - drupal_set_message(t('Display plugin @plugin is not available.', array('@plugin' => $display->display_plugin)), 'error'); + foreach ($view->displayHandlers as $id => $display) { + if (empty($display) || !empty($display->broken)) { + drupal_set_message(t('Display plugin @plugin is not available.', array('@plugin' => $display->getPluginId())), 'error'); $broken = TRUE; continue; } - $plugin = views_get_plugin('style', $display->handler->getOption('style_plugin')); + $plugin = views_get_plugin('style', $display->getOption('style_plugin')); if (!$plugin) { - drupal_set_message(t('Style plugin @plugin is not available.', array('@plugin' => $display->handler->getOption('style_plugin'))), 'error'); + drupal_set_message(t('Style plugin @plugin is not available.', array('@plugin' => $display->getOption('style_plugin'))), 'error'); $broken = TRUE; } elseif ($plugin->usesRowPlugin()) { - $plugin = views_get_plugin('row', $display->handler->getOption('row_plugin')); + $plugin = views_get_plugin('row', $display->getOption('row_plugin')); if (!$plugin) { - drupal_set_message(t('Row plugin @plugin is not available.', array('@plugin' => $display->handler->getOption('row_plugin'))), 'error'); + drupal_set_message(t('Row plugin @plugin is not available.', array('@plugin' => $display->getOption('row_plugin'))), 'error'); $broken = TRUE; } } foreach (ViewExecutable::viewsHandlerTypes() as $type => $info) { - $handlers = $display->handler->getHandlers($type); + $handlers = $display->getHandlers($type); if ($handlers) { foreach ($handlers as $id => $handler) { if ($handler->broken()) { @@ -2039,10 +2039,10 @@ function views_ui_edit_view_form_submit($form, &$form_state) { } // Rename display ids if needed. foreach ($form_state['view']->display as $id => $display) { - if (!empty($display->new_id)) { - $form_state['view']->display[$id]->id = $display->new_id; + if (!empty($display['new_id'])) { + $form_state['view']->display[$id]['id'] = $display['new_id']; // Redirect the user to the renamed display to be sure that the page itself exists and doesn't throw errors. - $form_state['redirect'] = 'admin/structure/views/view/' . $form_state['view']->name . '/edit/' . $display->new_id; + $form_state['redirect'] = 'admin/structure/views/view/' . $form_state['view']->name . '/edit/' . $display['new_id']; } } @@ -2055,12 +2055,12 @@ function views_ui_edit_view_form_submit($form, &$form_state) { $old_view = views_get_view($form_state['view']->name); foreach ($old_view->display as $id => $display) { // Only check for displays with a path. - if (!isset($display->display_options['path'])) { + if (!isset($display['display_options']['path'])) { continue; } - $old_path = $display->display_options['path']; - if (($display->display_plugin == 'page') && ($old_path == $destination) && ($old_path != $form_state['view']->display[$id]->display_options['path'])) { - $destination = $form_state['view']->display[$id]->display_options['path']; + $old_path = $display['display_options']['path']; + if (($display['display_plugin'] == 'page') && ($old_path == $destination) && ($old_path != $form_state['view']->display[$id]['display_options']['path'])) { + $destination = $form_state['view']->display[$id]['display_options']['path']; $query->remove('destination'); } } @@ -2115,15 +2115,15 @@ function views_ui_edit_form_get_bucket($type, $view, $display) { // to get the right one. switch ($type) { case 'filter': - $rearrange_url = "admin/structure/views/nojs/rearrange-$type/$view->name/$display->id/$type"; + $rearrange_url = "admin/structure/views/nojs/rearrange-$type/$view->name/{$display['id']}/$type"; $rearrange_text = t('And/Or, Rearrange'); // TODO: Add another class to have another symbol for filter rearrange. $class = 'icon compact rearrange'; break; case 'field': // Fetch the style plugin info so we know whether to list fields or not. - $name = $display->handler->getOption('style_plugin'); - $style_plugin = $display->handler->getPlugin('style', $name); + $name = $view->displayHandlers[$display['id']]->getOption('style_plugin'); + $style_plugin = $view->displayHandlers[$display['id']]->getPlugin('style', $name); $uses_fields = $style_plugin && $style_plugin->usesFields(); if (!$uses_fields) { $build['fields'][] = array( @@ -2135,17 +2135,17 @@ function views_ui_edit_form_get_bucket($type, $view, $display) { } default: - $rearrange_url = "admin/structure/views/nojs/rearrange/$view->name/$display->id/$type"; + $rearrange_url = "admin/structure/views/nojs/rearrange/$view->name/{$display['id']}/$type"; $rearrange_text = t('Rearrange'); $class = 'icon compact rearrange'; } // Create an array of actions to pass to theme_links $actions = array(); - $count_handlers = count($display->handler->getHandlers($type)); + $count_handlers = count($view->displayHandlers[$display['id']]->getHandlers($type)); $actions['add'] = array( 'title' => t('Add'), - 'href' => "admin/structure/views/nojs/add-item/$view->name/$display->id/$type", + 'href' => "admin/structure/views/nojs/add-item/$view->name/{$display['id']}/$type", 'attributes' => array('class' => array('icon compact add', 'views-ajax-link'), 'title' => t('Add'), 'id' => 'views-add-' . $type), 'html' => TRUE, ); @@ -2169,8 +2169,8 @@ function views_ui_edit_form_get_bucket($type, $view, $display) { ) ); - if (!$display->handler->isDefaultDisplay()) { - if (!$display->handler->isDefaulted($types[$type]['plural'])) { + if (!$view->displayHandlers[$display['id']]->isDefaultDisplay()) { + if (!$view->displayHandlers[$display['id']]->isDefaulted($types[$type]['plural'])) { $build['#overridden'] = TRUE; } else { @@ -2180,14 +2180,14 @@ function views_ui_edit_form_get_bucket($type, $view, $display) { // If there's an options form for the bucket, link to it. if (!empty($types[$type]['options'])) { - $build['#title'] = l($build['#title'], "admin/structure/views/nojs/config-type/$view->name/$display->id/$type", array('attributes' => array('class' => array('views-ajax-link'), 'id' => 'views-title-' . $type))); + $build['#title'] = l($build['#title'], "admin/structure/views/nojs/config-type/$view->name/{$display['id']}/$type", array('attributes' => array('class' => array('views-ajax-link'), 'id' => 'views-title-' . $type))); } static $relationships = NULL; if (!isset($relationships)) { // Get relationship labels $relationships = array(); - foreach ($display->handler->getHandlers('relationship') as $id => $handler) { + foreach ($view->displayHandlers[$display['id']]->getHandlers('relationship') as $id => $handler) { $relationships[$id] = $handler->label(); } } @@ -2208,16 +2208,16 @@ function views_ui_edit_form_get_bucket($type, $view, $display) { $build['fields'] = array(); - foreach ($display->handler->getOption($types[$type]['plural']) as $id => $field) { + foreach ($view->displayHandlers[$display['id']]->getOption($types[$type]['plural']) as $id => $field) { // Build the option link for this handler ("Node: ID = article"). $build['fields'][$id] = array(); $build['fields'][$id]['#theme'] = 'views_ui_display_tab_setting'; - $handler = $display->handler->getHandler($type, $id); + $handler = $view->displayHandlers[$display['id']]->getHandler($type, $id); if (empty($handler)) { $build['fields'][$id]['#class'][] = 'broken'; $field_name = t('Broken/missing handler: @table > @field', array('@table' => $field['table'], '@field' => $field['field'])); - $build['fields'][$id]['#link'] = l($field_name, "admin/structure/views/nojs/config-item/$view->name/$display->id/$type/$id", array('attributes' => array('class' => array('views-ajax-link')), 'html' => TRUE)); + $build['fields'][$id]['#link'] = l($field_name, "admin/structure/views/nojs/config-item/$view->name/{$display['id']}/$type/$id", array('attributes' => array('class' => array('views-ajax-link')), 'html' => TRUE)); continue; } @@ -2232,15 +2232,15 @@ function views_ui_edit_form_get_bucket($type, $view, $display) { if (!empty($field['exclude'])) { $link_attributes['class'][] = 'views-field-excluded'; } - $build['fields'][$id]['#link'] = l($link_text, "admin/structure/views/nojs/config-item/$view->name/$display->id/$type/$id", array('attributes' => $link_attributes, 'html' => TRUE)); - $build['fields'][$id]['#class'][] = drupal_clean_css_identifier($display->id . '-' . $type . '-' . $id); + $build['fields'][$id]['#link'] = l($link_text, "admin/structure/views/nojs/config-item/$view->name/{$display['id']}/$type/$id", array('attributes' => $link_attributes, 'html' => TRUE)); + $build['fields'][$id]['#class'][] = drupal_clean_css_identifier($display['id']. '-' . $type . '-' . $id); - if ($display->handler->useGroupBy() && $handler->usesGroupBy()) { - $build['fields'][$id]['#settings_links'][] = l('<span class="label">' . t('Aggregation settings') . '</span>', "admin/structure/views/nojs/config-item-group/$view->name/$display->id/$type/$id", array('attributes' => array('class' => 'views-button-configure views-ajax-link', 'title' => t('Aggregation settings')), 'html' => TRUE)); + if ($view->displayHandlers[$display['id']]->useGroupBy() && $handler->usesGroupBy()) { + $build['fields'][$id]['#settings_links'][] = l('<span class="label">' . t('Aggregation settings') . '</span>', "admin/structure/views/nojs/config-item-group/$view->name/{$display['id']}/$type/$id", array('attributes' => array('class' => 'views-button-configure views-ajax-link', 'title' => t('Aggregation settings')), 'html' => TRUE)); } if ($handler->hasExtraOptions()) { - $build['fields'][$id]['#settings_links'][] = l('<span class="label">' . t('Settings') . '</span>', "admin/structure/views/nojs/config-item-extra/$view->name/$display->id/$type/$id", array('attributes' => array('class' => array('views-button-configure', 'views-ajax-link'), 'title' => t('Settings')), 'html' => TRUE)); + $build['fields'][$id]['#settings_links'][] = l('<span class="label">' . t('Settings') . '</span>', "admin/structure/views/nojs/config-item-extra/$view->name/{$display['id']}/$type/$id", array('attributes' => array('class' => array('views-button-configure', 'views-ajax-link'), 'title' => t('Settings')), 'html' => TRUE)); } if ($grouping) { @@ -2433,8 +2433,8 @@ function views_ui_standard_submit($form, &$form_state) { // these changes apply to. if ($revert) { // If it's revert just change the override and return. - $display = &$form_state['view']->display[$form_state['display_id']]; - $display->handler->optionsOverride($form, $form_state); + $display = &$form_state['view']->displayHandlers[$form_state['display_id']]; + $display->optionsOverride($form, $form_state); // Don't execute the normal submit handling but still store the changed view into cache. views_ui_cache_set($form_state['view']); @@ -2447,20 +2447,20 @@ function views_ui_standard_submit($form, &$form_state) { elseif ($was_defaulted && !$is_defaulted) { // We were using the default display's values, but we're now overriding // the default display and saving values specific to this display. - $display = &$form_state['view']->display[$form_state['display_id']]; + $display = &$form_state['view']->displayHandlers[$form_state['display_id']]; // optionsOverride toggles the override of this section. - $display->handler->optionsOverride($form, $form_state); - $display->handler->submitOptionsForm($form, $form_state); + $display->optionsOverride($form, $form_state); + $display->submitOptionsForm($form, $form_state); } elseif (!$was_defaulted && $is_defaulted) { // We used to have an override for this display, but the user now wants // to go back to the default display. // Overwrite the default display with the current form values, and make // the current display use the new default values. - $display = &$form_state['view']->display[$form_state['display_id']]; + $display = &$form_state['view']->displayHandlers[$form_state['display_id']]; // optionsOverride toggles the override of this section. - $display->handler->optionsOverride($form, $form_state); - $display->handler->submitOptionsForm($form, $form_state); + $display->optionsOverride($form, $form_state); + $display->submitOptionsForm($form, $form_state); } $submit_handler = $form['#form_id'] . '_submit'; @@ -2517,8 +2517,8 @@ function views_ui_standard_cancel($form, &$form_state) { function views_ui_standard_display_dropdown(&$form, &$form_state, $section) { $view = &$form_state['view']; $display_id = $form_state['display_id']; - $displays = $view->display; - $current_display = $view->display[$display_id]; + $displays = $view->displayHandlers; + $current_display = $view->displayHandlers[$display_id]; // Add the "2 of 3" progress indicator. // @TODO: Move this to a separate function if it's needed on any forms that @@ -2528,24 +2528,24 @@ function views_ui_standard_display_dropdown(&$form, &$form_state, $section) { $form['progress']['#weight'] = -1001; } - if ($current_display->handler->isDefaultDisplay()) { + if ($current_display->isDefaultDisplay()) { return; } // Determine whether any other displays have overrides for this section. $section_overrides = FALSE; - $section_defaulted = $current_display->handler->isDefaulted($section); + $section_defaulted = $current_display->isDefaulted($section); foreach ($displays as $id => $display) { if ($id === 'default' || $id === $display_id) { continue; } - if ($display->handler && !$display->handler->isDefaulted($section)) { + if ($display && !$display->isDefaulted($section)) { $section_overrides = TRUE; } } $display_dropdown['default'] = ($section_overrides ? t('All displays (except overridden)') : t('All displays')); - $display_dropdown[$display_id] = t('This @display_type (override)', array('@display_type' => $current_display->display_plugin)); + $display_dropdown[$display_id] = t('This @display_type (override)', array('@display_type' => $current_display->getPluginId())); // Only display the revert option if we are in a overridden section. if (!$section_defaulted) { $display_dropdown['default_revert'] = t('Revert to default'); @@ -2562,7 +2562,7 @@ function views_ui_standard_display_dropdown(&$form, &$form_state, $section) { '#title' => t('For'), // @TODO: Translators may need more context than this. '#options' => $display_dropdown, ); - if ($current_display->handler->isDefaulted($section)) { + if ($current_display->isDefaulted($section)) { $form['override']['dropdown']['#default_value'] = 'defaults'; } else { @@ -2912,31 +2912,31 @@ function views_ui_reorder_displays_form($form, &$form_state) { $last_display = end($view->display); foreach ($view->display as $display) { - $form[$display->id] = array( - 'title' => array('#markup' => $display->display_title), + $form[$display['id']] = array( + 'title' => array('#markup' => $display['display_title']), 'weight' => array( '#type' => 'weight', - '#value' => $display->position, - '#delta' => $last_display->position, - '#title' => t('Weight for @display', array('@display' => $display->display_title)), + '#value' => $display['position'], + '#delta' => $last_display['position'], + '#title' => t('Weight for @display', array('@display' => $display['display_title'])), '#title_display' => 'invisible', ), '#tree' => TRUE, '#display' => $display, 'removed' => array( '#type' => 'checkbox', - '#id' => 'display-removed-' . $display->id, + '#id' => 'display-removed-' . $display['id'], '#attributes' => array('class' => array('views-remove-checkbox')), '#default_value' => isset($display->deleted), ), ); if (isset($display->deleted) && $display->deleted) { - $form[$display->id]['deleted'] = array('#type' => 'value', '#value' => TRUE); + $form[$display['id']]['deleted'] = array('#type' => 'value', '#value' => TRUE); } - if ($display->id === 'default') { - unset($form[$display->id]['weight']); - unset($form[$display->id]['removed']); + if ($display['id'] === 'default') { + unset($form[$display['id']]['weight']); + unset($form[$display['id']]['removed']); } } @@ -2965,8 +2965,8 @@ function views_ui_reorder_displays_form($form, &$form_state) { * Display position sorting function */ function _views_position_sort($display1, $display2) { - if ($display1->position != $display2->position) { - return $display1->position < $display2->position ? -1 : 1; + if ($display1['position'] != $display2['position']) { + return $display1['position'] < $display2['position'] ? -1 : 1; } return 0; @@ -3002,7 +3002,7 @@ function views_ui_reorder_displays_form_submit($form, &$form_state) { continue; } if (isset($order[$display_id])) { - $form_state['view']->display[$display_id]->position = $order[$display_id]; + $form_state['view']->display[$display_id]['position'] = $order[$display_id]; } else { $form_state['view']->display[$display_id]->deleted = TRUE; @@ -3146,7 +3146,7 @@ function views_ui_edit_display_form($form, &$form_state) { '#theme_wrappers' => array('container'), '#attributes' => array('class' => array('scroll')), ); - $display->handler->buildOptionsForm($form['options'], $form_state); + $view->displayHandlers[$display['id']]->buildOptionsForm($form['options'], $form_state); // The handler options form sets $form['#title'], which we need on the entire // $form instead of just the ['options'] section. @@ -3172,8 +3172,7 @@ function views_ui_edit_display_form($form, &$form_state) { * Validate handler for views_ui_edit_display_form */ function views_ui_edit_display_form_validate($form, &$form_state) { - $display = &$form_state['view']->display[$form_state['display_id']]; - $display->handler->validateOptionsForm($form['options'], $form_state); + $form_state['view']->displayHandlers[$form_state['display_id']]->validateOptionsForm($form['options'], $form_state); if (form_get_errors()) { $form_state['rerender'] = TRUE; @@ -3184,8 +3183,7 @@ function views_ui_edit_display_form_validate($form, &$form_state) { * Submit handler for views_ui_edit_display_form */ function views_ui_edit_display_form_submit($form, &$form_state) { - $display = &$form_state['view']->display[$form_state['display_id']]; - $display->handler->submitOptionsForm($form, $form_state); + $form_state['view']->displayHandlers[$form_state['display_id']]->submitOptionsForm($form['options'], $form_state); views_ui_cache_set($form_state['view']); } @@ -3196,8 +3194,7 @@ function views_ui_edit_display_form_submit($form, &$form_state) { * @TODO: Not currently used. Remove unless we implement an override toggle. */ function views_ui_edit_display_form_override($form, &$form_state) { - $display = &$form_state['view']->display[$form_state['display_id']]; - $display->handler->optionsOverride($form, $form_state); + $form_state['view']->displayHandlers[$form_state['display_id']]->optionsOverride($form['options'], $form_state); views_ui_cache_set($form_state['view']); $form_state['rerender'] = TRUE; @@ -3216,11 +3213,11 @@ function views_ui_config_type_form($form, &$form_state) { if (!$view->setDisplay($display_id)) { views_ajax_error(t('Invalid display id @display', array('@display' => $display_id))); } - $display = &$view->display[$display_id]; + $display = &$view->displayHandlers[$display_id]; $form['#title'] = t('Configure @type', array('@type' => $types[$type]['ltitle'])); $form['#section'] = $display_id . 'config-item'; - if ($display->handler->defaultableSections($types[$type]['plural'])) { + if ($display->defaultableSections($types[$type]['plural'])) { $form_state['section'] = $types[$type]['plural']; views_ui_standard_display_dropdown($form, $form_state, $form_state['section']); } @@ -3263,11 +3260,11 @@ function views_ui_rearrange_form($form, &$form_state) { if (!$view->setDisplay($display_id)) { views_ajax_error(t('Invalid display id @display', array('@display' => $display_id))); } - $display = &$view->display[$display_id]; + $display = &$view->displayHandlers[$display_id]; $form['#title'] = t('Rearrange @type', array('@type' => $types[$type]['ltitle'])); $form['#section'] = $display_id . 'rearrange-item'; - if ($display->handler->defaultableSections($types[$type]['plural'])) { + if ($display->defaultableSections($types[$type]['plural'])) { $form_state['section'] = $types[$type]['plural']; views_ui_standard_display_dropdown($form, $form_state, $form_state['section']); } @@ -3276,7 +3273,7 @@ function views_ui_rearrange_form($form, &$form_state) { // Get relationship labels $relationships = array(); - foreach ($display->handler->getHandlers('relationship') as $id => $handler) { + foreach ($display->getHandlers('relationship') as $id => $handler) { $relationships[$id] = $handler->label(); } @@ -3291,13 +3288,13 @@ function views_ui_rearrange_form($form, &$form_state) { } } - foreach ($display->handler->getOption($types[$type]['plural']) as $id => $field) { + foreach ($display->getOption($types[$type]['plural']) as $id => $field) { $form['fields'][$id] = array('#tree' => TRUE); $form['fields'][$id]['weight'] = array( '#type' => 'textfield', '#default_value' => ++$count, ); - $handler = $display->handler->getHandler($type, $id); + $handler = $display->getHandler($type, $id); if ($handler) { $name = $handler->adminLabel() . ' ' . $handler->adminSummary(); if (!empty($field['relationship']) && !empty($relationships[$field['relationship']])) { @@ -3485,9 +3482,9 @@ function theme_views_ui_build_group_filter_form($variables) { */ function views_ui_rearrange_form_submit($form, &$form_state) { $types = ViewExecutable::viewsHandlerTypes(); - $display = &$form_state['view']->display[$form_state['display_id']]; + $display = &$form_state['view']->displayHandlers[$form_state['display_id']]; - $old_fields = $display->handler->getOption($types[$form_state['type']]['plural']); + $old_fields = $display->getOption($types[$form_state['type']]['plural']); $new_fields = $order = array(); // Make an array with the weights @@ -3506,7 +3503,7 @@ function views_ui_rearrange_form_submit($form, &$form_state) { foreach (array_keys($order) as $field) { $new_fields[$field] = $old_fields[$field]; } - $display->handler->setOption($types[$form_state['type']]['plural'], $new_fields); + $display->setOption($types[$form_state['type']]['plural'], $new_fields); // Store in cache views_ui_cache_set($form_state['view']); @@ -3525,11 +3522,11 @@ function views_ui_rearrange_filter_form($form, &$form_state) { views_ajax_render(t('Invalid display id @display', array('@display' => $display_id))); } $display = &$view->display[$display_id]; - $form['#title'] = check_plain($display->display_title) . ': '; + $form['#title'] = check_plain($view->display[$display_id]['display_title']) . ': '; $form['#title'] .= t('Rearrange @type', array('@type' => $types[$type]['ltitle'])); $form['#section'] = $display_id . 'rearrange-item'; - if ($display->handler->defaultableSections($types[$type]['plural'])) { + if ($display->defaultableSections($types[$type]['plural'])) { $form_state['section'] = $types[$type]['plural']; views_ui_standard_display_dropdown($form, $form_state, $form_state['section']); } @@ -3539,14 +3536,14 @@ function views_ui_rearrange_filter_form($form, &$form_state) { $handlers = $view->form_cache['handlers']; } else { - $groups = $display->handler->getOption('filter_groups'); - $handlers = $display->handler->getOption($types[$type]['plural']); + $groups = $display->getOption('filter_groups'); + $handlers = $display->getOption($types[$type]['plural']); } $count = 0; // Get relationship labels $relationships = array(); - foreach ($display->handler->getHandlers('relationship') as $id => $handler) { + foreach ($display->getHandlers('relationship') as $id => $handler) { $relationships[$id] = $handler->label(); } @@ -3623,7 +3620,7 @@ function views_ui_rearrange_filter_form($form, &$form_state) { $field['group'] = 1; } - $handler = $display->handler->getHandler($type, $id); + $handler = $display->getHandler($type, $id); if ($grouping && $handler && !$handler->can_group()) { $field['group'] = 'ungroupable'; } @@ -3787,14 +3784,14 @@ function theme_views_ui_rearrange_filter_form(&$vars) { */ function views_ui_rearrange_filter_form_submit($form, &$form_state) { $types = ViewExecutable::viewsHandlerTypes(); - $display = &$form_state['view']->display[$form_state['display_id']]; + $display = &$form_state['view']->displayHandlers[$form_state['display_id']]; $remember_groups = array(); if (!empty($form_state['view']->form_cache)) { $old_fields = $form_state['view']->form_cache['handlers']; } else { - $old_fields = $display->handler->getOption($types[$form_state['type']]['plural']); + $old_fields = $display->getOption($types[$form_state['type']]['plural']); } $count = 0; @@ -3878,8 +3875,8 @@ function views_ui_rearrange_filter_form_submit($form, &$form_state) { } // Write the changed handler values. - $display->handler->setOption($types[$form_state['type']]['plural'], $new_fields); - $display->handler->setOption('filter_groups', $groups); + $display->setOption($types[$form_state['type']]['plural'], $new_fields); + $display->setOption('filter_groups', $groups); if (isset($form_state['view']->form_cache)) { unset($form_state['view']->form_cache); } @@ -3907,7 +3904,7 @@ function views_ui_add_item_form($form, &$form_state) { if (!$view->setDisplay($display_id)) { views_ajax_error(t('Invalid display id @display', array('@display' => $display_id))); } - $display = &$view->display[$display_id]; + $display = &$view->displayHandlers[$display_id]; $types = ViewExecutable::viewsHandlerTypes(); $ltitle = $types[$type]['ltitle']; @@ -3925,7 +3922,7 @@ function views_ui_add_item_form($form, &$form_state) { // Figure out all the base tables allowed based upon what the relationships provide. $base_tables = $view->getBaseTables(); - $options = views_fetch_fields(array_keys($base_tables), $type, $display->handler->useGroupBy()); + $options = views_fetch_fields(array_keys($base_tables), $type, $display->useGroupBy()); if (!empty($options)) { $form['options']['controls'] = array( @@ -4039,18 +4036,18 @@ function views_ui_add_item_form_submit($form, &$form_state) { if ($was_defaulted && !$is_defaulted) { // We were using the default display's values, but we're now overriding // the default display and saving values specific to this display. - $display = &$form_state['view']->display[$form_state['display_id']]; + $display = &$form_state['view']->displayHandlers[$form_state['display_id']]; // setOverride toggles the override of this section. - $display->handler->setOverride($section); + $display->setOverride($section); } elseif (!$was_defaulted && $is_defaulted) { // We used to have an override for this display, but the user now wants // to go back to the default display. // Overwrite the default display with the current form values, and make // the current display use the new default values. - $display = &$form_state['view']->display[$form_state['display_id']]; + $display = &$form_state['view']->displayHandlers[$form_state['display_id']]; // optionsOverride toggles the override of this section. - $display->handler->setOverride($section); + $display->setOverride($section); } if (!empty($form_state['values']['name']) && is_array($form_state['values']['name'])) { @@ -4449,8 +4446,8 @@ function views_ui_config_item_form_remove($form, &$form_state) { list($was_defaulted, $is_defaulted) = views_ui_standard_override_values($form, $form_state); // If the display selection was changed toggle the override value. if ($was_defaulted != $is_defaulted) { - $display =& $form_state['view']->display[$form_state['display_id']]; - $display->handler->optionsOverride($form, $form_state); + $display =& $form_state['view']->displayHandlers[$form_state['display_id']]; + $display->optionsOverride($form, $form_state); } $form_state['view']->setItem($form_state['display_id'], $form_state['type'], $form_state['id'], NULL); @@ -5200,12 +5197,12 @@ function theme_views_ui_style_plugin_table($variables) { } /** - * Placeholder function for overriding $display->display_title. + * Placeholder function for overriding $display['display_title']. * * @todo Remove this function once editing the display title is possible. */ function views_ui_get_display_label($view, $display_id, $check_changed = TRUE) { - $title = $display_id == 'default' ? t('Master') : $view->display[$display_id]->display_title; + $title = $display_id == 'default' ? t('Master') : $view->display[$display_id]['display_title']; $title = views_ui_truncate($title, 25); if ($check_changed && !empty($view->changed_display[$display_id])) { diff --git a/includes/ajax.inc b/includes/ajax.inc index ab562429c6eb62b39f87f471a3d07ba22d17dafb..b19d3114f12ec9fdf5042fbdff85f2f1442bd3fb 100644 --- a/includes/ajax.inc +++ b/includes/ajax.inc @@ -69,7 +69,7 @@ function views_ajax() { // Override the display's pager_element with the one actually used. if (isset($pager_element)) { $commands[] = views_ajax_command_scroll_top('.view-dom-id-' . $dom_id); - $view->display[$display_id]->handler->setOption('pager_element', $pager_element); + $view->displayHandlers[$display_id]->setOption('pager_element', $pager_element); } // Reuse the same DOM id so it matches that in Drupal.settings. $view->dom_id = $dom_id; diff --git a/includes/analyze.inc b/includes/analyze.inc index e650c4a8b13a8a47a72996171f59fe4b43b53fe9..9338ec0e6d225ebfa97fe20a29f788d551d10652 100644 --- a/includes/analyze.inc +++ b/includes/analyze.inc @@ -23,14 +23,14 @@ function views_ui_views_analyze($view) { // You can give a page display the same path as an alias existing in the // system, so the alias will not work anymore. Report this to the user, // because he probably wanted something else. - foreach ($view->display as $id => $display) { - if (empty($display->handler)) { + foreach ($view->displayHandlers as $display) { + if (empty($display)) { continue; } - if ($display->handler->hasPath() && $path = $display->handler->getOption('path')) { + if ($display->hasPath() && $path = $display->getOption('path')) { $normal_path = drupal_get_normal_path($path); if ($path != $normal_path) { - $ret[] = Analyzer::formatMessage(t('You have configured display %display with a path which is an path alias as well. This might lead to unwanted effects so better use an internal path.', array('%display' => $display->display_title)), 'warning'); + $ret[] = Analyzer::formatMessage(t('You have configured display %display with a path which is an path alias as well. This might lead to unwanted effects so better use an internal path.', array('%display' => $display['display_title'])), 'warning'); } } } diff --git a/lib/Drupal/views/Plugin/views/HandlerBase.php b/lib/Drupal/views/Plugin/views/HandlerBase.php index 87ad125ac1c7beeb10bceb7b3c17234e6a7d651b..907b8396f8cb9f64471bcfce009a9b020d034d0f 100644 --- a/lib/Drupal/views/Plugin/views/HandlerBase.php +++ b/lib/Drupal/views/Plugin/views/HandlerBase.php @@ -326,7 +326,7 @@ public function buildGroupByForm(&$form, &$form_state) { $type = $form_state['type']; $id = $form_state['id']; - $form['#title'] = check_plain($view->display[$display_id]->display_title) . ': '; + $form['#title'] = check_plain($view->display[$display_id]['display_title']) . ': '; $form['#title'] .= t('Configure aggregation settings for @type %item', array('@type' => $types[$type]['lstitle'], '%item' => $this->adminLabel())); $form['#section'] = $display_id . '-' . $type . '-' . $id; diff --git a/lib/Drupal/views/Plugin/views/PluginBase.php b/lib/Drupal/views/Plugin/views/PluginBase.php index 69ed8ebd7351556cb218251ba27a73f1dc949431..118eb1c2d27a640329eae8998cf4d8338c945f35 100644 --- a/lib/Drupal/views/Plugin/views/PluginBase.php +++ b/lib/Drupal/views/Plugin/views/PluginBase.php @@ -26,6 +26,17 @@ abstract class PluginBase extends ComponentPluginBase { */ public $view = NULL; + /** + * The display object this plugin is for. + * + * For display plugins this is empty. + * + * @todo find a better description + * + * @var Drupal\views\Plugin\views\display\DisplayPluginBase + */ + public $displayHandler; + /** * Plugins's definition * @@ -40,6 +51,7 @@ abstract class PluginBase extends ComponentPluginBase { */ protected $usesOptions = FALSE; + /** * Constructs a Plugin object. */ @@ -164,7 +176,7 @@ public function query() { } * Provide a full list of possible theme templates used by this style. */ public function themeFunctions() { - return views_theme_functions($this->definition['theme'], $this->view, $this->display); + return views_theme_functions($this->definition['theme'], $this->view, $this->view->display_handler->display); } /** @@ -174,7 +186,7 @@ public function additionalThemeFunctions() { $funcs = array(); if (!empty($this->definition['additional themes'])) { foreach ($this->definition['additional themes'] as $theme => $type) { - $funcs[] = views_theme_functions($theme, $this->view, $this->display); + $funcs[] = views_theme_functions($theme, $this->view, $this->view->display_handler->display); } } return $funcs; diff --git a/lib/Drupal/views/Plugin/views/access/AccessPluginBase.php b/lib/Drupal/views/Plugin/views/access/AccessPluginBase.php index 0e3f1b05188c818f932aacbb9d24a120be55adbb..31a92fb8fe91360aac8c100e26e6e6d6ee675339 100644 --- a/lib/Drupal/views/Plugin/views/access/AccessPluginBase.php +++ b/lib/Drupal/views/Plugin/views/access/AccessPluginBase.php @@ -36,10 +36,10 @@ abstract class AccessPluginBase extends PluginBase { public function init(&$view, &$display) { $this->setOptionDefaults($this->options, $this->defineOptions()); $this->view = &$view; - $this->display = &$display; + $this->displayHandler = &$display; - if (is_object($display->handler)) { - $options = $display->handler->getOption('access'); + if (is_object($display)) { + $options = $display->getOption('access'); // Overlay incoming options on top of defaults $this->unpackOptions($this->options, $options); } diff --git a/lib/Drupal/views/Plugin/views/cache/CachePluginBase.php b/lib/Drupal/views/Plugin/views/cache/CachePluginBase.php index 4cf5848b2e9554f30fe5dafc695b4271bc3d966a..014acb8f4dcda4de7f6cc922b7a6beebb79bd2a8 100644 --- a/lib/Drupal/views/Plugin/views/cache/CachePluginBase.php +++ b/lib/Drupal/views/Plugin/views/cache/CachePluginBase.php @@ -65,10 +65,10 @@ abstract class CachePluginBase extends PluginBase { public function init(&$view, &$display) { $this->setOptionDefaults($this->options, $this->defineOptions()); $this->view = &$view; - $this->display = &$display; + $this->displayHandler = &$display; - if (is_object($display->handler)) { - $options = $display->handler->getOption('cache'); + if (is_object($display)) { + $options = $display->getOption('cache'); // Overlay incoming options on top of defaults $this->unpackOptions($this->options, $options); } @@ -302,7 +302,7 @@ function get_results_key() { } } - $this->_results_key = $this->view->name . ':' . $this->display->id . ':results:' . md5(serialize($key_data)); + $this->_results_key = $this->view->name . ':' . $this->displayHandler->display['id'] . ':results:' . md5(serialize($key_data)); } return $this->_results_key; @@ -320,7 +320,7 @@ function get_output_key() { 'base_url' => $GLOBALS['base_url'], ); - $this->_output_key = $this->view->name . ':' . $this->display->id . ':output:' . md5(serialize($key_data)); + $this->_output_key = $this->view->name . ':' . $this->displayHandler->display['id'] . ':output:' . md5(serialize($key_data)); } return $this->_output_key; diff --git a/lib/Drupal/views/Plugin/views/display/Attachment.php b/lib/Drupal/views/Plugin/views/display/Attachment.php index d52d743359eb3fdecea0edd217ee66380a621489..a0f6a2fb03b6560e7fb01212b4b1d10a3460b8ae 100644 --- a/lib/Drupal/views/Plugin/views/display/Attachment.php +++ b/lib/Drupal/views/Plugin/views/display/Attachment.php @@ -50,7 +50,7 @@ protected function defineOptions() { } public function execute() { - return $this->view->render($this->display->id); + return $this->view->render($this->display['id']); } public function attachmentPositions($position = NULL) { @@ -91,7 +91,7 @@ public function optionsSummary(&$categories, &$options) { elseif (count($displays) == 1) { $display = array_shift($displays); if (!empty($this->view->display[$display])) { - $attach_to = check_plain($this->view->display[$display]->display_title); + $attach_to = check_plain($this->view->display[$display]['display_title']); } } @@ -194,8 +194,8 @@ public function buildOptionsForm(&$form, &$form_state) { $form['#title'] .= t('Attach to'); $displays = array(); foreach ($this->view->display as $display_id => $display) { - if (!empty($display->handler) && $display->handler->acceptAttachments()) { - $displays[$display_id] = $display->display_title; + if (!empty($this->view->displayHandlers[$display_id]) && $this->view->displayHandlers[$display_id]->acceptAttachments()) { + $displays[$display_id] = $display['display_title']; } } $form['displays'] = array( @@ -247,13 +247,13 @@ public function attachTo($display_id) { $args = $this->getOption('inherit_arguments') ? $this->view->args : array(); $view->setArguments($args); - $view->setDisplay($this->display->id); + $view->setDisplay($this->display['id']); if ($this->getOption('inherit_pager')) { $view->display_handler->usesPager = $this->view->display[$display_id]->handler->usesPager(); $view->display_handler->setOption('pager', $this->view->display[$display_id]->handler->getOption('pager')); } - $attachment = $view->executeDisplay($this->display->id, $args); + $attachment = $view->executeDisplay($this->display['id'], $args); switch ($this->getOption('attachment_position')) { case 'before': diff --git a/lib/Drupal/views/Plugin/views/display/DefaultDisplay.php b/lib/Drupal/views/Plugin/views/display/DefaultDisplay.php index 7a0cfce67e27b61668696197fd77a66cded31448..c739973aa1379cf26c11428eb2553cbd6317cc9a 100644 --- a/lib/Drupal/views/Plugin/views/display/DefaultDisplay.php +++ b/lib/Drupal/views/Plugin/views/display/DefaultDisplay.php @@ -73,7 +73,7 @@ public function isDefaultDisplay() { return TRUE; } * data if necessary. */ public function execute() { - return $this->view->render($this->display->id); + return $this->view->render($this->display['id']); } } diff --git a/lib/Drupal/views/Plugin/views/display/DisplayPluginBase.php b/lib/Drupal/views/Plugin/views/display/DisplayPluginBase.php index 7cfdbff1c3f65229b8d1b565f6192492fb0c4d98..0ca5f5db4569b6f6a5db79853628d86f20e9e071 100644 --- a/lib/Drupal/views/Plugin/views/display/DisplayPluginBase.php +++ b/lib/Drupal/views/Plugin/views/display/DisplayPluginBase.php @@ -107,8 +107,8 @@ public function init(&$view, &$display, $options = NULL) { $changed = FALSE; // Make some modifications: - if (!isset($options) && isset($display->display_options)) { - $options = $display->display_options; + if (!isset($options) && isset($display['display_options'])) { + $options = $display['display_options']; } if ($this->isDefaultDisplay() && isset($options['defaults'])) { @@ -666,9 +666,9 @@ public function usesExposedFormInBlock() { return $this->hasPath(); } public function getLinkDisplay() { $display_id = $this->getOption('link_display'); // If unknown, pick the first one. - if (empty($display_id) || empty($this->view->display[$display_id])) { - foreach ($this->view->display as $display_id => $display) { - if (!empty($display->handler) && $display->handler->hasPath()) { + if (empty($display_id) || empty($this->view->displayHandlers[$display_id])) { + foreach ($this->view->displayHandlers as $display_id => $display) { + if (!empty($display) && $display->hasPath()) { return $display_id; } } @@ -691,8 +691,8 @@ public function getPath() { } $display_id = $this->getLinkDisplay(); - if ($display_id && !empty($this->view->display[$display_id]) && is_object($this->view->display[$display_id]->handler)) { - return $this->view->display[$display_id]->handler->getPath(); + if ($display_id && !empty($this->view->displayHandlers[$display_id]) && is_object($this->view->displayHandlers[$display_id])) { + return $this->view->displayHandlers[$display_id]->getPath(); } } @@ -800,10 +800,10 @@ public function getPlugin($type = 'style', $name = NULL) { return; } if ($type != 'query') { - $plugin->init($this->view, $this->display, $options); + $plugin->init($this->view, $this, $options); } else { - $display_id = $this->isDefaulted($option_name) ? $this->display->id : 'default'; + $display_id = $this->isDefaulted($option_name) ? $this->display['id'] : 'default'; if (!isset($this->base_field)) { $views_data = views_fetch_data($this->view->base_table); @@ -950,7 +950,7 @@ public function setOption($option, $value) { // Set this in two places: On the handler where we'll notice it // but also on the display object so it gets saved. This should // only be a temporary fix. - $this->display->display_options[$option] = $value; + $this->display['display_options'][$option] = $value; return $this->options[$option] = $value; } @@ -980,7 +980,7 @@ public function optionLink($text, $section, $class = '', $title = '') { $title = $text; } - return l($text, 'admin/structure/views/nojs/display/' . $this->view->name . '/' . $this->display->id . '/' . $section, array('attributes' => array('class' => 'views-ajax-link ' . $class, 'title' => $title, 'id' => drupal_html_id('views-' . $this->display->id . '-' . $section)), 'html' => TRUE)); + return l($text, 'admin/structure/views/nojs/display/' . $this->view->name . '/' . $this->display['id'] . '/' . $section, array('attributes' => array('class' => 'views-ajax-link ' . $class, 'title' => $title, 'id' => drupal_html_id('views-' . $this->display['id'] . '-' . $section)), 'html' => TRUE)); } /** @@ -1060,11 +1060,11 @@ public function optionsSummary(&$categories, &$options) { ), ); - if ($this->display->id != 'default') { + if ($this->display['id'] != 'default') { $options['display_id'] = array( 'category' => 'other', 'title' => t('Machine Name'), - 'value' => !empty($this->display->new_id) ? check_plain($this->display->new_id) : check_plain($this->display->id), + 'value' => !empty($this->display['new_id']) ? check_plain($this->display['new_id']) : check_plain($this->display['id']), 'desc' => t('Change the machine name of this display.'), ); } @@ -1266,7 +1266,7 @@ public function optionsSummary(&$categories, &$options) { if ($this->usesLinkDisplay()) { $display_id = $this->getLinkDisplay(); - $link_display = empty($this->view->display[$display_id]) ? t('None') : check_plain($this->view->display[$display_id]->display_title); + $link_display = empty($this->view->display[$display_id]) ? t('None') : check_plain($this->view->display[$display_id]['display_title']); $link_display = $this->getOption('link_display') == 'custom_url' ? t('Custom URL') : $link_display; $options['link_display'] = array( 'category' => 'other', @@ -1337,7 +1337,7 @@ public function buildOptionsForm(&$form, &$form_state) { if ($this->defaultableSections($form_state['section'])) { views_ui_standard_display_dropdown($form, $form_state, $form_state['section']); } - $form['#title'] = check_plain($this->display->display_title) . ': '; + $form['#title'] = check_plain($this->display['display_title']) . ': '; // Set the 'section' to hilite on the form. // If it's the item we're looking at is pulling from the default display, @@ -1347,7 +1347,7 @@ public function buildOptionsForm(&$form, &$form_state) { $form['#section'] = 'default-' . $form_state['section']; } else { - $form['#section'] = $this->display->id . '-' . $form_state['section']; + $form['#section'] = $this->display['id'] . '-' . $form_state['section']; } switch ($form_state['section']) { @@ -1356,7 +1356,7 @@ public function buildOptionsForm(&$form, &$form_state) { $form['display_id'] = array( '#type' => 'textfield', '#description' => t('This is machine name of the display.'), - '#default_value' => !empty($this->display->new_id) ? $this->display->new_id : $this->display->id, + '#default_value' => !empty($this->display['new_id']) ? $this->display['new_id'] : $this->display['id'], '#required' => TRUE, '#size' => 64, ); @@ -1367,7 +1367,7 @@ public function buildOptionsForm(&$form, &$form_state) { '#title' => t('Name'), '#type' => 'textfield', '#description' => t('This name will appear only in the administrative interface for the View.'), - '#default_value' => $this->display->display_title, + '#default_value' => $this->display['display_title'], ); $form['display_description'] = array( '#title' => t('Description'), @@ -1670,8 +1670,8 @@ public function buildOptionsForm(&$form, &$form_state) { case 'link_display': $form['#title'] .= t('Which display to use for path'); foreach ($this->view->display as $display_id => $display) { - if ($display->handler->hasPath()) { - $options[$display_id] = $display->display_title; + if ($this->view->displayHandlers[$display_id]->hasPath()) { + $options[$display_id] = $display['display_title']; } } $options['custom_url'] = t('Custom URL'); @@ -2128,7 +2128,7 @@ public function validateOptionsForm(&$form, &$form_state) { } foreach ($this->view->display as $id => $display) { - if ($id != $this->view->current_display && ($form_state['values']['display_id'] == $id || (isset($display->new_id) && $form_state['values']['display_id'] == $display->new_id))) { + if ($id != $this->view->current_display && ($form_state['values']['display_id'] == $id || (isset($display['new_id']) && $form_state['values']['display_id'] == $display['new_id']))) { form_error($form['display_id'], t('Display id should be unique.')); } } @@ -2194,11 +2194,11 @@ public function submitOptionsForm(&$form, &$form_state) { switch ($section) { case 'display_id': if (isset($form_state['values']['display_id'])) { - $this->display->new_id = $form_state['values']['display_id']; + $this->display['new_id'] = $form_state['values']['display_id']; } break; case 'display_title': - $this->display->display_title = $form_state['values']['display_title']; + $this->display['display_title'] = $form_state['values']['display_title']; $this->setOption('display_description', $form_state['values']['display_description']); break; case 'access': @@ -2209,7 +2209,7 @@ public function submitOptionsForm(&$form, &$form_state) { $access = array('type' => $form_state['values']['access']['type']); $this->setOption('access', $access); if ($plugin->usesOptions()) { - views_ui_add_form_to_stack('display', $this->view, $this->display->id, array('access_options')); + views_ui_add_form_to_stack('display', $this->view, $this->display['id'], array('access_options')); } } } @@ -2230,7 +2230,7 @@ public function submitOptionsForm(&$form, &$form_state) { $cache = array('type' => $form_state['values']['cache']['type']); $this->setOption('cache', $cache); if ($plugin->usesOptions()) { - views_ui_add_form_to_stack('display', $this->view, $this->display->id, array('cache_options')); + views_ui_add_form_to_stack('display', $this->view, $this->display['id'], array('cache_options')); } } } @@ -2288,7 +2288,7 @@ public function submitOptionsForm(&$form, &$form_state) { // send ajax form to options page if we use it. if ($plugin->usesOptions()) { - views_ui_add_form_to_stack('display', $this->view, $this->display->id, array('row_options')); + views_ui_add_form_to_stack('display', $this->view, $this->display['id'], array('row_options')); } } } @@ -2303,7 +2303,7 @@ public function submitOptionsForm(&$form, &$form_state) { $this->setOption('style_options', array()); // send ajax form to options page if we use it. if ($plugin->usesOptions()) { - views_ui_add_form_to_stack('display', $this->view, $this->display->id, array('style_options')); + views_ui_add_form_to_stack('display', $this->view, $this->display['id'], array('style_options')); } } } @@ -2329,7 +2329,7 @@ public function submitOptionsForm(&$form, &$form_state) { $exposed_form = array('type' => $form_state['values']['exposed_form']['type'], 'options' => array()); $this->setOption('exposed_form', $exposed_form); if ($plugin->usesOptions()) { - views_ui_add_form_to_stack('display', $this->view, $this->display->id, array('exposed_form_options')); + views_ui_add_form_to_stack('display', $this->view, $this->display['id'], array('exposed_form_options')); } } } @@ -2356,7 +2356,7 @@ public function submitOptionsForm(&$form, &$form_state) { $pager = array('type' => $form_state['values']['pager']['type'], 'options' => $plugin->options); $this->setOption('pager', $pager); if ($plugin->usesOptions()) { - views_ui_add_form_to_stack('display', $this->view, $this->display->id, array('pager_options')); + views_ui_add_form_to_stack('display', $this->view, $this->display['id'], array('pager_options')); } } } @@ -2410,15 +2410,15 @@ public function setOverride($section, $new_state = NULL) { if ($new_state) { // Revert to defaults. unset($this->options[$option]); - unset($this->display->display_options[$option]); + unset($this->display['display_options'][$option]); } else { // copy existing values into our display. $this->options[$option] = $this->getOption($option); - $this->display->display_options[$option] = $this->options[$option]; + $this->display['display_options'][$option] = $this->options[$option]; } $this->options['defaults'][$option] = $new_state; - $this->display->display_options['defaults'][$option] = $new_state; + $this->display['display_options']['defaults'][$option] = $new_state; } } @@ -2465,7 +2465,7 @@ public function renderMoreLink() { if (!empty($this->view->exposed_raw_input)) { $url_options['query'] = $this->view->exposed_raw_input; } - $theme = views_theme_functions('views_more', $this->view, $this->display); + $theme = views_theme_functions('views_more', $this->view, $this->view->display[$this->view->current_display]); $path = check_url(url($path, $url_options)); return theme($theme, array('more_url' => $path, 'link_text' => check_plain($this->useMoreText()), 'view' => $this->view)); @@ -2610,19 +2610,19 @@ public function validate() { } if (!$fields) { - $errors[] = t('Display "@display" uses fields but there are none defined for it or all are excluded.', array('@display' => $this->display->display_title)); + $errors[] = t('Display "@display" uses fields but there are none defined for it or all are excluded.', array('@display' => $this->display['display_title'])); } } if ($this->hasPath() && !$this->getOption('path')) { - $errors[] = t('Display "@display" uses a path but the path is undefined.', array('@display' => $this->display->display_title)); + $errors[] = t('Display "@display" uses a path but the path is undefined.', array('@display' => $this->display['display_title'])); } // Validate style plugin $name = $this->getOption('style_plugin'); $style = $this->getPlugin('style', $name); if (empty($style)) { - $errors[] = t('Display "@display" has an invalid style plugin.', array('@display' => $this->display->display_title)); + $errors[] = t('Display "@display" has an invalid style plugin.', array('@display' => $this->display['display_title'])); } else { $result = $style->validate(); @@ -2690,8 +2690,8 @@ public function getSpecialBlocks() { $blocks = array(); if ($this->usesExposedFormInBlock()) { - $delta = '-exp-' . $this->view->name . '-' . $this->display->id; - $desc = t('Exposed form: @view-@display_id', array('@view' => $this->view->name, '@display_id' => $this->display->id)); + $delta = '-exp-' . $this->view->name . '-' . $this->display['id']; + $desc = t('Exposed form: @view-@display_id', array('@view' => $this->view->name, '@display_id' => $this->display['id'])); $blocks[$delta] = array( 'info' => $desc, diff --git a/lib/Drupal/views/Plugin/views/display/Feed.php b/lib/Drupal/views/Plugin/views/display/Feed.php index 17568926509fd748a6a63850fd89686002625453..0050f940d8d70f0ce228db436912b9687aa4f736 100644 --- a/lib/Drupal/views/Plugin/views/display/Feed.php +++ b/lib/Drupal/views/Plugin/views/display/Feed.php @@ -153,7 +153,7 @@ public function optionsSummary(&$categories, &$options) { elseif (count($displays) == 1) { $display = array_shift($displays); if (!empty($this->view->display[$display])) { - $attach_to = check_plain($this->view->display[$display]->display_title); + $attach_to = check_plain($this->view->display[$display]['display_title']); } } @@ -196,8 +196,9 @@ public function buildOptionsForm(&$form, &$form_state) { $form['#title'] .= t('Attach to'); $displays = array(); foreach ($this->view->display as $display_id => $display) { - if (!empty($display->handler) && $display->handler->acceptAttachments()) { - $displays[$display_id] = $display->display_title; + // @todo The display plugin should have display_title and id as well. + if (!empty($this->view->displayHandlers[$display_id]) && $this->view->displayHandlers[$display_id]->acceptAttachments()) { + $displays[$display_id] = $display['display_title']; } } $form['displays'] = array( @@ -244,7 +245,7 @@ public function attachTo($display_id) { $plugin = $this->getPlugin('style', $name); if ($plugin) { $clone = $this->view->cloneView(); - $clone->setDisplay($this->display->id); + $clone->setDisplay($this->display['id']); $clone->buildTitle(); $plugin->attach_to($display_id, $this->getPath(), $clone->getTitle()); diff --git a/lib/Drupal/views/Plugin/views/display/Page.php b/lib/Drupal/views/Plugin/views/display/Page.php index 4a0285b48a65144b73279dc0796d9d3ec941cb31..e959f60a27ab03f7510c193ad936b4862ebd7938 100644 --- a/lib/Drupal/views/Plugin/views/display/Page.php +++ b/lib/Drupal/views/Plugin/views/display/Page.php @@ -80,7 +80,7 @@ public function executeHookMenu($callbacks) { // views_arg_load -- which lives in views.module $bits = explode('/', $this->getOption('path')); - $page_arguments = array($this->view->name, $this->display->id); + $page_arguments = array($this->view->name, $this->display['id']); $this->view->initHandlers(); $view_arguments = $this->view->argument; @@ -141,7 +141,7 @@ public function executeHookMenu($callbacks) { 'access callback' => 'views_access', 'access arguments' => $access_arguments, // Identify URL embedded arguments and correlate them to a handler - 'load arguments' => array($this->view->name, $this->display->id, '%index'), + 'load arguments' => array($this->view->name, $this->display['id'], '%index'), ); $menu = $this->getOption('menu'); if (empty($menu)) { @@ -202,7 +202,7 @@ public function executeHookMenu($callbacks) { 'access callback' => 'views_access', 'access arguments' => $access_arguments, // Identify URL embedded arguments and correlate them to a handler - 'load arguments' => array($this->view->name, $this->display->id, '%index'), + 'load arguments' => array($this->view->name, $this->display['id'], '%index'), 'title' => $tab_options['title'], 'description' => $tab_options['description'], 'menu_name' => $tab_options['name'], @@ -609,7 +609,7 @@ public function submitOptionsForm(&$form, &$form_state) { $this->setOption('menu', $form_state['values']['menu']); // send ajax form to options page if we use it. if ($form_state['values']['menu']['type'] == 'default tab') { - views_ui_add_form_to_stack('display', $this->view, $this->display->id, array('tab_options')); + views_ui_add_form_to_stack('display', $this->view, $this->display['id'], array('tab_options')); } break; case 'tab_options': @@ -623,13 +623,13 @@ public function validate() { $menu = $this->getOption('menu'); if (!empty($menu['type']) && $menu['type'] != 'none' && empty($menu['title'])) { - $errors[] = t('Display @display is set to use a menu but the menu link text is not set.', array('@display' => $this->display->display_title)); + $errors[] = t('Display @display is set to use a menu but the menu link text is not set.', array('@display' => $this->display['display_title'])); } if ($menu['type'] == 'default tab') { $tab_options = $this->getOption('tab_options'); if (!empty($tab_options['type']) && $tab_options['type'] != 'none' && empty($tab_options['title'])) { - $errors[] = t('Display @display is set to use a parent menu but the parent menu link text is not set.', array('@display' => $this->display->display_title)); + $errors[] = t('Display @display is set to use a parent menu but the parent menu link text is not set.', array('@display' => $this->display['display_title'])); } } diff --git a/lib/Drupal/views/Plugin/views/exposed_form/ExposedFormPluginBase.php b/lib/Drupal/views/Plugin/views/exposed_form/ExposedFormPluginBase.php index 323980ce0a8d580b6eee405ba728c5d659d7ab72..c630167bff581690fa6ae1654e8503920795a0a1 100644 --- a/lib/Drupal/views/Plugin/views/exposed_form/ExposedFormPluginBase.php +++ b/lib/Drupal/views/Plugin/views/exposed_form/ExposedFormPluginBase.php @@ -40,7 +40,7 @@ abstract class ExposedFormPluginBase extends PluginBase { public function init(&$view, &$display, $options = array()) { $this->setOptionDefaults($this->options, $this->defineOptions()); $this->view = &$view; - $this->display = &$display; + $this->displayHandler = &$display; $this->unpackOptions($this->options, $options); } diff --git a/lib/Drupal/views/Plugin/views/exposed_form/InputRequired.php b/lib/Drupal/views/Plugin/views/exposed_form/InputRequired.php index e0a5548c95d7c2f0e522c4e0ab5bbe7bb1856d3a..3baebe0fe3a874cabe05369929fef6d8c70b9d3f 100644 --- a/lib/Drupal/views/Plugin/views/exposed_form/InputRequired.php +++ b/lib/Drupal/views/Plugin/views/exposed_form/InputRequired.php @@ -85,10 +85,10 @@ function pre_render($values) { ); $handler = views_get_handler('views', 'area', 'area'); $handler->init($this->view, $options); - $this->display->handler->handlers['empty'] = array( + $this->displayHandler->handlers['empty'] = array( 'area' => $handler, ); - $this->display->handler->setOption('empty', array('text' => $options)); + $this->displayHandler->setOption('empty', array('text' => $options)); } } diff --git a/lib/Drupal/views/Plugin/views/field/FieldPluginBase.php b/lib/Drupal/views/Plugin/views/field/FieldPluginBase.php index 0726c28c900fc9f4cadccdeb3ad4c4ff20ba0682..5bc6f954b2f4bff877a3a6f6cb9ed48fd05a3a4e 100644 --- a/lib/Drupal/views/Plugin/views/field/FieldPluginBase.php +++ b/lib/Drupal/views/Plugin/views/field/FieldPluginBase.php @@ -1608,15 +1608,15 @@ public function themeFunctions() { $display = $this->view->display[$this->view->current_display]; if (!empty($display)) { - $themes[] = $hook . '__' . $this->view->name . '__' . $display->id . '__' . $this->options['id']; - $themes[] = $hook . '__' . $this->view->name . '__' . $display->id; - $themes[] = $hook . '__' . $display->id . '__' . $this->options['id']; - $themes[] = $hook . '__' . $display->id; - if ($display->id != $display->display_plugin) { - $themes[] = $hook . '__' . $this->view->name . '__' . $display->display_plugin . '__' . $this->options['id']; - $themes[] = $hook . '__' . $this->view->name . '__' . $display->display_plugin; - $themes[] = $hook . '__' . $display->display_plugin . '__' . $this->options['id']; - $themes[] = $hook . '__' . $display->display_plugin; + $themes[] = $hook . '__' . $this->view->name . '__' . $display['id'] . '__' . $this->options['id']; + $themes[] = $hook . '__' . $this->view->name . '__' . $display['id']; + $themes[] = $hook . '__' . $display['id'] . '__' . $this->options['id']; + $themes[] = $hook . '__' . $display['id']; + if ($display['id'] != $display['display_plugin']) { + $themes[] = $hook . '__' . $this->view->name . '__' . $display['display_plugin'] . '__' . $this->options['id']; + $themes[] = $hook . '__' . $this->view->name . '__' . $display['display_plugin']; + $themes[] = $hook . '__' . $display['display_plugin'] . '__' . $this->options['id']; + $themes[] = $hook . '__' . $display['display_plugin']; } } $themes[] = $hook . '__' . $this->view->name . '__' . $this->options['id']; diff --git a/lib/Drupal/views/Plugin/views/pager/Full.php b/lib/Drupal/views/Plugin/views/pager/Full.php index 0f6369c345b18ab723f109c623c5c6c37c64bda7..78f6b0954378ac3e4c5050290403dd6d33b8142a 100644 --- a/lib/Drupal/views/Plugin/views/pager/Full.php +++ b/lib/Drupal/views/Plugin/views/pager/Full.php @@ -67,7 +67,7 @@ protected function defineOptions() { */ public function buildOptionsForm(&$form, &$form_state) { parent::buildOptionsForm($form, $form_state); - $pager_text = $this->display->handler->getPagerText(); + $pager_text = $this->displayHandler->getPagerText(); $form['items_per_page'] = array( '#title' => $pager_text['items per page title'], '#type' => 'number', @@ -291,7 +291,7 @@ public function query() { } function render($input) { - $pager_theme = views_theme_functions('pager', $this->view, $this->display); + $pager_theme = views_theme_functions('pager', $this->view, $this->view->display[$this->view->current_display]); // The 0, 1, 3, 4 index are correct. See theme_pager documentation. $tags = array( 0 => $this->options['tags']['first'], diff --git a/lib/Drupal/views/Plugin/views/pager/Mini.php b/lib/Drupal/views/Plugin/views/pager/Mini.php index d3adb1a126e16fa5404cbf00e4e7f76df240b5a1..4b454b9136c2796b07a92b601d35802cbcdbd9b0 100644 --- a/lib/Drupal/views/Plugin/views/pager/Mini.php +++ b/lib/Drupal/views/Plugin/views/pager/Mini.php @@ -32,7 +32,7 @@ public function summaryTitle() { } function render($input) { - $pager_theme = views_theme_functions('views_mini_pager', $this->view, $this->display); + $pager_theme = views_theme_functions('views_mini_pager', $this->view, $this->view->display[$this->view->current_display]); return theme($pager_theme, array( 'parameters' => $input, 'element' => $this->options['id'])); } diff --git a/lib/Drupal/views/Plugin/views/pager/PagerPluginBase.php b/lib/Drupal/views/Plugin/views/pager/PagerPluginBase.php index ffd67d75f69f2bb4246433dc83eec5f89d5ef898..1500934a5a8fbd48f2fe5bf3f11b4355e9a2b559 100644 --- a/lib/Drupal/views/Plugin/views/pager/PagerPluginBase.php +++ b/lib/Drupal/views/Plugin/views/pager/PagerPluginBase.php @@ -45,7 +45,7 @@ abstract class PagerPluginBase extends PluginBase { public function init(&$view, &$display, $options = array()) { $this->setOptionDefaults($this->options, $this->defineOptions()); $this->view = &$view; - $this->display = &$display; + $this->displayHandler = &$display; $this->unpackOptions($this->options, $options); } diff --git a/lib/Drupal/views/Plugin/views/pager/Some.php b/lib/Drupal/views/Plugin/views/pager/Some.php index aa79b06f7d725d4979b0ff34b3340e7db095bca0..a917ed6f3d01562bce81bf175b56dae2f18c1813 100644 --- a/lib/Drupal/views/Plugin/views/pager/Some.php +++ b/lib/Drupal/views/Plugin/views/pager/Some.php @@ -44,7 +44,7 @@ protected function defineOptions() { */ public function buildOptionsForm(&$form, &$form_state) { parent::buildOptionsForm($form, $form_state); - $pager_text = $this->display->handler->getPagerText(); + $pager_text = $this->displayHandler->getPagerText(); $form['items_per_page'] = array( '#title' => $pager_text['items per page title'], '#type' => 'textfield', diff --git a/lib/Drupal/views/Plugin/views/relationship/GroupwiseMax.php b/lib/Drupal/views/Plugin/views/relationship/GroupwiseMax.php index e27dcc1d52bc8c4c8f7ca5da812f931c85da7fd3..5eb60da96e2dce2c96a8c32c025822fa4ef7adee 100644 --- a/lib/Drupal/views/Plugin/views/relationship/GroupwiseMax.php +++ b/lib/Drupal/views/Plugin/views/relationship/GroupwiseMax.php @@ -128,7 +128,7 @@ public function buildOptionsForm(&$form, &$form_state) { // Only get views that are suitable: // - base must the base that our relationship joins towards // - must have fields. - if ($view->base_table == $this->definition['base'] && !empty($view->display['default']->display_options['fields'])) { + if ($view->base_table == $this->definition['base'] && !empty($view->display['default']['display_options']['fields'])) { // TODO: check the field is the correct sort? // or let users hang themselves at this stage and check later? if ($view->type == 'Default') { @@ -195,7 +195,7 @@ function left_query($options) { if ($options['subquery_view']) { $temp_view = views_get_view($options['subquery_view']); // Remove all fields from default display - unset($temp_view->display['default']->display_options['fields']); + unset($temp_view->display['default']['display_options']['fields']); } else { // Create a new view object on the fly, which we use to generate a query diff --git a/lib/Drupal/views/Plugin/views/row/Fields.php b/lib/Drupal/views/Plugin/views/row/Fields.php index 673457e3362e48d036a0e97db936adbd10cb489b..842162bda9d2727cd037a0fc36e0e99975edcca1 100644 --- a/lib/Drupal/views/Plugin/views/row/Fields.php +++ b/lib/Drupal/views/Plugin/views/row/Fields.php @@ -50,7 +50,7 @@ protected function defineOptions() { */ public function buildOptionsForm(&$form, &$form_state) { parent::buildOptionsForm($form, $form_state); - $options = $this->display->handler->getFieldLabels(); + $options = $this->displayHandler->getFieldLabels(); if (empty($this->options['inline'])) { $this->options['inline'] = array(); diff --git a/lib/Drupal/views/Plugin/views/row/RowPluginBase.php b/lib/Drupal/views/Plugin/views/row/RowPluginBase.php index 042c3f75ccff6520c06f6b236d2066d8ba9360ca..b91079e6bf9fc8271f9652c0f465ef60a3af57d5 100644 --- a/lib/Drupal/views/Plugin/views/row/RowPluginBase.php +++ b/lib/Drupal/views/Plugin/views/row/RowPluginBase.php @@ -44,10 +44,10 @@ abstract class RowPluginBase extends PluginBase { public function init(&$view, &$display, $options = NULL) { $this->setOptionDefaults($this->options, $this->defineOptions()); $this->view = &$view; - $this->display = &$display; + $this->displayHandler = &$display; - // Overlay incoming options on top of defaults - $this->unpackOptions($this->options, isset($options) ? $options : $display->handler->getOption('row_options')); + // Overlay incoming options on top of defaults. + $this->unpackOptions($this->options, isset($options) ? $options : $display->getOption('row_options')); } /** diff --git a/lib/Drupal/views/Plugin/views/row/RssFields.php b/lib/Drupal/views/Plugin/views/row/RssFields.php index 03de8dd05e4597b607213bfd17cc4e1ff894544b..90e964b919bdbb934ea4b3ae024994c6ed59e16b 100644 --- a/lib/Drupal/views/Plugin/views/row/RssFields.php +++ b/lib/Drupal/views/Plugin/views/row/RssFields.php @@ -46,7 +46,7 @@ public function buildOptionsForm(&$form, &$form_state) { parent::buildOptionsForm($form, $form_state); $initial_labels = array('' => t('- None -')); - $view_fields_labels = $this->display->handler->getFieldLabels(); + $view_fields_labels = $this->displayHandler->getFieldLabels(); $view_fields_labels = array_merge($initial_labels, $view_fields_labels); $form['title_field'] = array( diff --git a/lib/Drupal/views/Plugin/views/style/Mapping.php b/lib/Drupal/views/Plugin/views/style/Mapping.php index fc3c8292fee819f546d9812d91c2f5826fc414ec..8e9649e948508868b771ba0faab6962878c9b185 100644 --- a/lib/Drupal/views/Plugin/views/style/Mapping.php +++ b/lib/Drupal/views/Plugin/views/style/Mapping.php @@ -80,7 +80,7 @@ public function buildOptionsForm(&$form, &$form_state) { $options = array_intersect_key($this->options['mapping'], $mapping); // Get the labels of the fields added to this display. - $field_labels = $this->display->handler->getFieldLabels(); + $field_labels = $this->displayHandler->getFieldLabels(); // Provide some default values. $defaults = array( diff --git a/lib/Drupal/views/Plugin/views/style/Rss.php b/lib/Drupal/views/Plugin/views/style/Rss.php index 987d9dd79eee2859d4968dd56ca43182c9d1fa24..e4d1e968c57686d3f98fb080be518bbe109ceff8 100644 --- a/lib/Drupal/views/Plugin/views/style/Rss.php +++ b/lib/Drupal/views/Plugin/views/style/Rss.php @@ -33,7 +33,7 @@ class Rss extends StylePluginBase { protected $usesRowPlugin = TRUE; function attach_to($display_id, $path, $title) { - $display = $this->view->display[$display_id]->handler; + $display = $this->view->displayHandlers[$display_id]; $url_options = array(); $input = $this->view->getExposedInput(); if ($input) { diff --git a/lib/Drupal/views/Plugin/views/style/StylePluginBase.php b/lib/Drupal/views/Plugin/views/style/StylePluginBase.php index bafe5137bd22ce2a54e07491bc9168bd0bbf92f2..4f94b234c36e5e9d045b4af8adc9177ea1d3e4a7 100644 --- a/lib/Drupal/views/Plugin/views/style/StylePluginBase.php +++ b/lib/Drupal/views/Plugin/views/style/StylePluginBase.php @@ -92,13 +92,13 @@ abstract class StylePluginBase extends PluginBase { public function init(&$view, &$display, $options = NULL) { $this->setOptionDefaults($this->options, $this->defineOptions()); $this->view = &$view; - $this->display = &$display; + $this->displayHandler = &$display; // Overlay incoming options on top of defaults - $this->unpackOptions($this->options, isset($options) ? $options : $display->handler->getOption('style_options')); + $this->unpackOptions($this->options, isset($options) ? $options : $display->getOption('style_options')); - if ($this->usesRowPlugin() && $display->handler->getOption('row_plugin')) { - $this->row_plugin = $display->handler->getPlugin('row'); + if ($this->usesRowPlugin() && $display->getOption('row_plugin')) { + $this->row_plugin = $display->getPlugin('row'); } $this->options += array( @@ -243,7 +243,7 @@ public function buildOptionsForm(&$form, &$form_state) { // @TODO: Document "usesGrouping" in docs.php when docs.php is written. if ($this->usesFields() && $this->usesGrouping()) { $options = array('' => t('- None -')); - $field_labels = $this->display->handler->getFieldLabels(TRUE); + $field_labels = $this->displayHandler->getFieldLabels(TRUE); $options += $field_labels; // If there are no fields, we can't group on them. if (count($options) > 1) { @@ -438,7 +438,7 @@ function render_grouping_sets($sets, $level = 0) { $row = reset($set['rows']); // Render as a grouping set. if (is_array($row) && isset($row['group'])) { - $output .= theme(views_theme_functions('views_view_grouping', $this->view, $this->display), + $output .= theme(views_theme_functions('views_view_grouping', $this->view, $this->view->display[$this->view->current_display]), array( 'view' => $this->view, 'grouping' => $this->options['grouping'][$level], @@ -662,8 +662,8 @@ public function validate() { $errors = parent::validate(); if ($this->usesRowPlugin()) { - $name = $this->display->handler->getOption('row_plugin'); - $plugin = $this->display->handler->getPlugin('row', $name); + $name = $this->displayHandler->getOption('row_plugin'); + $plugin = $this->displayHandler->getPlugin('row', $name); if (empty($plugin)) { $errors[] = t('Style @style requires a row style but the row plugin is invalid.', array('@style' => $this->definition['title'])); } diff --git a/lib/Drupal/views/Plugin/views/style/Table.php b/lib/Drupal/views/Plugin/views/style/Table.php index a5ff7d5b2292c64f62e22ef505d187c596fb7a0e..e3076b43c4c2b59b2c33a83ddb9d62edae834cc9 100644 --- a/lib/Drupal/views/Plugin/views/style/Table.php +++ b/lib/Drupal/views/Plugin/views/style/Table.php @@ -164,7 +164,7 @@ function build_sort_post() { function sanitize_columns($columns, $fields = NULL) { $sanitized = array(); if ($fields === NULL) { - $fields = $this->display->handler->getOption('fields'); + $fields = $this->displayHandler->getOption('fields'); } // Preconfigure the sanitized array so that the order is retained. foreach ($fields as $field => $info) { @@ -197,7 +197,7 @@ function sanitize_columns($columns, $fields = NULL) { */ public function buildOptionsForm(&$form, &$form_state) { parent::buildOptionsForm($form, $form_state); - $handlers = $this->display->handler->getHandlers('field'); + $handlers = $this->displayHandler->getHandlers('field'); if (empty($handlers)) { $form['error_markup'] = array( '#markup' => '<div class="error messages">' . t('You need at least one field before you can configure your table settings') . '</div>', @@ -233,7 +233,7 @@ public function buildOptionsForm(&$form, &$form_state) { $columns = $this->sanitize_columns($this->options['columns']); // Create an array of allowed columns from the data we know: - $field_names = $this->display->handler->getFieldLabels(); + $field_names = $this->displayHandler->getFieldLabels(); if (isset($this->options['default'])) { $default = $this->options['default']; diff --git a/lib/Drupal/views/Plugin/views/wizard/WizardPluginBase.php b/lib/Drupal/views/Plugin/views/wizard/WizardPluginBase.php index 3037525b459bf0e8b638ff8f9cbccecf270d6f2f..1593ced682111e6eed4f35025584559095656c0d 100644 --- a/lib/Drupal/views/Plugin/views/wizard/WizardPluginBase.php +++ b/lib/Drupal/views/Plugin/views/wizard/WizardPluginBase.php @@ -662,8 +662,7 @@ protected function addDisplays($view, $display_options, $form, $form_state) { * or a different row plugin. * * @return array - * Returns an array of display options, which are used in - * ViewDisplay::$display_options. + * Returns an array of display options. */ protected function default_display_options() { $display_options = array(); @@ -869,8 +868,7 @@ protected function default_display_sorts_user($form, $form_state) { * The current state of the wizard form. * * @return array - * Returns an array of display options, which are used in - * ViewDisplay::$display_options. + * Returns an array of display options. */ protected function page_display_options(array $form, array &$form_state) { $display_options = array(); @@ -916,8 +914,7 @@ protected function page_display_options(array $form, array &$form_state) { * The current state of the wizard form. * * @return array - * Returns an array of display options, which are used in - * ViewDisplay::$display_options. + * Returns an array of display options. */ protected function block_display_options(array $form, array &$form_state) { $display_options = array(); @@ -939,8 +936,7 @@ protected function block_display_options(array $form, array &$form_state) { * The current state of the wizard form. * * @return array - * Returns an array of display options, which are used in - * ViewDisplay::$display_options. + * Returns an array of display options. */ protected function page_feed_display_options($form, $form_state) { $display_options = array(); diff --git a/lib/Drupal/views/Tests/BasicTest.php b/lib/Drupal/views/Tests/BasicTest.php index b951e206f6412b0c2faaad24f126222e1ab8fb3d..b9c1d357e9e749f5f2daa02029c277d9f5142bfc 100644 --- a/lib/Drupal/views/Tests/BasicTest.php +++ b/lib/Drupal/views/Tests/BasicTest.php @@ -50,7 +50,7 @@ public function testSimpleFiltering() { $view = $this->getView(); // Add a filter. - $view->display['default']->handler->overrideOption('filters', array( + $view->displayHandlers['default']->overrideOption('filters', array( 'age' => array( 'operator' => '<', 'value' => array( @@ -108,7 +108,7 @@ public function testSimpleArgument() { $view = $this->getView(); // Add a argument. - $view->display['default']->handler->overrideOption('arguments', array( + $view->displayHandlers['default']->overrideOption('arguments', array( 'age' => array( 'default_action' => 'ignore', 'style_plugin' => 'default_summary', diff --git a/lib/Drupal/views/Tests/Field/HandlerFieldFieldTest.php b/lib/Drupal/views/Tests/Field/HandlerFieldFieldTest.php index eec576d3013c78c5e2f069604dfff5d844ec0d0b..2003e521054f011a1728514bd49b58a2d69ed4df 100644 --- a/lib/Drupal/views/Tests/Field/HandlerFieldFieldTest.php +++ b/lib/Drupal/views/Tests/Field/HandlerFieldFieldTest.php @@ -61,9 +61,9 @@ protected function setUp() { } foreach ($this->fields as $key => $field) { - $this->view->display_handler->display->display_options['fields'][$field['field_name']]['id'] = $field['field_name']; - $this->view->display_handler->display->display_options['fields'][$field['field_name']]['table'] = 'field_data_' . $field['field_name']; - $this->view->display_handler->display->display_options['fields'][$field['field_name']]['field'] = $field['field_name']; + $this->view->display_handler->display['display_options']['fields'][$field['field_name']]['id'] = $field['field_name']; + $this->view->display_handler->display['display_options']['fields'][$field['field_name']]['table'] = 'field_data_' . $field['field_name']; + $this->view->display_handler->display['display_options']['fields'][$field['field_name']]['field'] = $field['field_name']; } } @@ -100,8 +100,8 @@ public function _testSimpleFieldRender() { */ public function _testFormatterSimpleFieldRender() { $view = $this->getView(); - $view->display['default']->handler->options['fields'][$this->fields[0]['field_name']]['type'] = 'text_trimmed'; - $view->display['default']->handler->options['fields'][$this->fields[0]['field_name']]['settings'] = array( + $view->displayHandlers['default']->options['fields'][$this->fields[0]['field_name']]['type'] = 'text_trimmed'; + $view->displayHandlers['default']->options['fields'][$this->fields[0]['field_name']]['settings'] = array( 'trim_length' => 3, ); $this->executeView($view); @@ -118,8 +118,8 @@ public function _testMultipleFieldRender() { $view = $this->getView(); // Test delta limit. - $view->display['default']->handler->options['fields'][$this->fields[3]['field_name']]['group_rows'] = TRUE; - $view->display['default']->handler->options['fields'][$this->fields[3]['field_name']]['delta_limit'] = 3; + $view->displayHandlers['default']->options['fields'][$this->fields[3]['field_name']]['group_rows'] = TRUE; + $view->displayHandlers['default']->options['fields'][$this->fields[3]['field_name']]['delta_limit'] = 3; $this->executeView($view); for ($i = 0; $i < 3; $i++) { @@ -139,9 +139,9 @@ public function _testMultipleFieldRender() { $view->destroy(); // Test delta limit + offset - $view->display['default']->display_options['fields'][$this->fields[3]['field_name']]['group_rows'] = TRUE; - $view->display['default']->display_options['fields'][$this->fields[3]['field_name']]['delta_limit'] = 3; - $view->display['default']->display_options['fields'][$this->fields[3]['field_name']]['delta_offset'] = 1; + $view->display['default']['display_options']['fields'][$this->fields[3]['field_name']]['group_rows'] = TRUE; + $view->display['default']['display_options']['fields'][$this->fields[3]['field_name']]['delta_limit'] = 3; + $view->display['default']['display_options']['fields'][$this->fields[3]['field_name']]['delta_offset'] = 1; $this->executeView($view); for ($i = 0; $i < 3; $i++) { @@ -157,10 +157,10 @@ public function _testMultipleFieldRender() { $view->destroy(); // Test delta limit + reverse. - $view->display['default']->display_options['fields'][$this->fields[3]['field_name']]['delta_offset'] = 0; - $view->display['default']->display_options['fields'][$this->fields[3]['field_name']]['group_rows'] = TRUE; - $view->display['default']->display_options['fields'][$this->fields[3]['field_name']]['delta_limit'] = 3; - $view->display['default']->display_options['fields'][$this->fields[3]['field_name']]['delta_reversed'] = TRUE; + $view->display['default']['display_options']['fields'][$this->fields[3]['field_name']]['delta_offset'] = 0; + $view->display['default']['display_options']['fields'][$this->fields[3]['field_name']]['group_rows'] = TRUE; + $view->display['default']['display_options']['fields'][$this->fields[3]['field_name']]['delta_limit'] = 3; + $view->display['default']['display_options']['fields'][$this->fields[3]['field_name']]['delta_reversed'] = TRUE; $this->executeView($view); for ($i = 0; $i < 3; $i++) { @@ -177,10 +177,10 @@ public function _testMultipleFieldRender() { $view->destroy(); // Test delta first last. - $view->display['default']->display_options['fields'][$this->fields[3]['field_name']]['group_rows'] = TRUE; - $view->display['default']->display_options['fields'][$this->fields[3]['field_name']]['delta_limit'] = 0; - $view->display['default']->display_options['fields'][$this->fields[3]['field_name']]['delta_first_last'] = TRUE; - $view->display['default']->display_options['fields'][$this->fields[3]['field_name']]['delta_reversed'] = FALSE; + $view->display['default']['display_options']['fields'][$this->fields[3]['field_name']]['group_rows'] = TRUE; + $view->display['default']['display_options']['fields'][$this->fields[3]['field_name']]['delta_limit'] = 0; + $view->display['default']['display_options']['fields'][$this->fields[3]['field_name']]['delta_first_last'] = TRUE; + $view->display['default']['display_options']['fields'][$this->fields[3]['field_name']]['delta_reversed'] = FALSE; $this->executeView($view); for ($i = 0; $i < 3; $i++) { @@ -194,10 +194,10 @@ public function _testMultipleFieldRender() { $view->destroy(); // Test delta limit + custom seperator. - $view->display['default']->display_options['fields'][$this->fields[3]['field_name']]['delta_first_last'] = FALSE; - $view->display['default']->display_options['fields'][$this->fields[3]['field_name']]['delta_limit'] = 3; - $view->display['default']->display_options['fields'][$this->fields[3]['field_name']]['group_rows'] = TRUE; - $view->display['default']->display_options['fields'][$this->fields[3]['field_name']]['separator'] = ':'; + $view->display['default']['display_options']['fields'][$this->fields[3]['field_name']]['delta_first_last'] = FALSE; + $view->display['default']['display_options']['fields'][$this->fields[3]['field_name']]['delta_limit'] = 3; + $view->display['default']['display_options']['fields'][$this->fields[3]['field_name']]['group_rows'] = TRUE; + $view->display['default']['display_options']['fields'][$this->fields[3]['field_name']]['separator'] = ':'; $this->executeView($view); for ($i = 0; $i < 3; $i++) { diff --git a/lib/Drupal/views/Tests/Handler/AreaTextTest.php b/lib/Drupal/views/Tests/Handler/AreaTextTest.php index 998b15f2f36c48afe4bdfc9a1e705e6ccae5a140..6cda26e363cead3172ee3551dcbe7178fd467a47 100644 --- a/lib/Drupal/views/Tests/Handler/AreaTextTest.php +++ b/lib/Drupal/views/Tests/Handler/AreaTextTest.php @@ -33,7 +33,7 @@ public function testAreaText() { // add a text header $string = $this->randomName(); - $view->display['default']->handler->overrideOption('header', array( + $view->displayHandlers['default']->overrideOption('header', array( 'area' => array( 'id' => 'area', 'table' => 'views', diff --git a/lib/Drupal/views/Tests/Handler/ArgumentNullTest.php b/lib/Drupal/views/Tests/Handler/ArgumentNullTest.php index b884648403de1cb99a7640c14e21bf5a37366217..a5e26de0f0016824546b52aac0b222dc7249cbb4 100644 --- a/lib/Drupal/views/Tests/Handler/ArgumentNullTest.php +++ b/lib/Drupal/views/Tests/Handler/ArgumentNullTest.php @@ -39,7 +39,7 @@ public function testAreaText() { // Add a null argument. $string = $this->randomString(); - $view->display['default']->handler->overrideOption('arguments', array( + $view->displayHandlers['default']->overrideOption('arguments', array( 'null' => array( 'id' => 'null', 'table' => 'views', @@ -64,7 +64,7 @@ public function testAreaText() { // Add a argument, which has null as handler. $string = $this->randomString(); - $view->display['default']->handler->overrideOption('arguments', array( + $view->displayHandlers['default']->overrideOption('arguments', array( 'id' => array( 'id' => 'id', 'table' => 'views_test_data', diff --git a/lib/Drupal/views/Tests/Handler/FieldBooleanTest.php b/lib/Drupal/views/Tests/Handler/FieldBooleanTest.php index 45a6b3b2b77cb3f74b9142204ee0f36372406d68..b3d3599865dbbe3926f46d543abfcad810e2b80f 100644 --- a/lib/Drupal/views/Tests/Handler/FieldBooleanTest.php +++ b/lib/Drupal/views/Tests/Handler/FieldBooleanTest.php @@ -43,7 +43,7 @@ function viewsData() { public function testFieldBoolean() { $view = $this->getView(); - $view->display['default']->handler->overrideOption('fields', array( + $view->displayHandlers['default']->overrideOption('fields', array( 'age' => array( 'id' => 'age', 'table' => 'views_test_data', diff --git a/lib/Drupal/views/Tests/Handler/FieldCounterTest.php b/lib/Drupal/views/Tests/Handler/FieldCounterTest.php index d19850d7b2179647f1cad1cf34aaab28b547ca59..506de0305f2695da5a4e152cede47ff50cd28251 100644 --- a/lib/Drupal/views/Tests/Handler/FieldCounterTest.php +++ b/lib/Drupal/views/Tests/Handler/FieldCounterTest.php @@ -28,7 +28,7 @@ protected function setUp() { function testSimple() { $view = $this->getView(); - $view->display['default']->handler->overrideOption('fields', array( + $view->displayHandlers['default']->overrideOption('fields', array( 'counter' => array( 'id' => 'counter', 'table' => 'views', @@ -51,7 +51,7 @@ function testSimple() { $view = $this->getView(); $rand_start = rand(5, 10); - $view->display['default']->handler->overrideOption('fields', array( + $view->displayHandlers['default']->overrideOption('fields', array( 'counter' => array( 'id' => 'counter', 'table' => 'views', diff --git a/lib/Drupal/views/Tests/Handler/FieldCustomTest.php b/lib/Drupal/views/Tests/Handler/FieldCustomTest.php index a751fa790696dcc0daedb453e54921e7d786a683..4cc3291199d1cea784e7823784422b494d840424 100644 --- a/lib/Drupal/views/Tests/Handler/FieldCustomTest.php +++ b/lib/Drupal/views/Tests/Handler/FieldCustomTest.php @@ -37,7 +37,7 @@ public function testFieldCustom() { // Alter the text of the field to a random string. $random = $this->randomName(); - $view->display['default']->handler->overrideOption('fields', array( + $view->displayHandlers['default']->overrideOption('fields', array( 'name' => array( 'id' => 'name', 'table' => 'views_test_data', diff --git a/lib/Drupal/views/Tests/Handler/FieldDateTest.php b/lib/Drupal/views/Tests/Handler/FieldDateTest.php index 6df8450f0463e3580ca2ab36f08b6eab805b7a0f..6040d404a26991460e9f728e56aff3388c9939ce 100644 --- a/lib/Drupal/views/Tests/Handler/FieldDateTest.php +++ b/lib/Drupal/views/Tests/Handler/FieldDateTest.php @@ -35,7 +35,7 @@ function viewsData() { public function testFieldDate() { $view = $this->getView(); - $view->display['default']->handler->overrideOption('fields', array( + $view->displayHandlers['default']->overrideOption('fields', array( 'created' => array( 'id' => 'created', 'table' => 'views_test_data', diff --git a/lib/Drupal/views/Tests/Handler/FieldFileSizeTest.php b/lib/Drupal/views/Tests/Handler/FieldFileSizeTest.php index d9826f09d02d384b13ade803c4d89764dd6c925f..f8c0dde92fa3d12e56087056263ea2a60fe740da 100644 --- a/lib/Drupal/views/Tests/Handler/FieldFileSizeTest.php +++ b/lib/Drupal/views/Tests/Handler/FieldFileSizeTest.php @@ -48,7 +48,7 @@ function viewsData() { public function testFieldFileSize() { $view = $this->getView(); - $view->display['default']->handler->overrideOption('fields', array( + $view->displayHandlers['default']->overrideOption('fields', array( 'age' => array( 'id' => 'age', 'table' => 'views_test_data', diff --git a/lib/Drupal/views/Tests/Handler/FieldUrlTest.php b/lib/Drupal/views/Tests/Handler/FieldUrlTest.php index acab241c6f805f3ad360180010a91af375947fdf..0ffbed05954e4b757733e6ed10662aa2d8b170ee 100644 --- a/lib/Drupal/views/Tests/Handler/FieldUrlTest.php +++ b/lib/Drupal/views/Tests/Handler/FieldUrlTest.php @@ -35,7 +35,7 @@ function viewsData() { public function testFieldUrl() { $view = $this->getView(); - $view->display['default']->handler->overrideOption('fields', array( + $view->displayHandlers['default']->overrideOption('fields', array( 'name' => array( 'id' => 'name', 'table' => 'views_test_data', @@ -53,7 +53,7 @@ public function testFieldUrl() { $view->destroy(); $view = $this->getView(); - $view->display['default']->handler->overrideOption('fields', array( + $view->displayHandlers['default']->overrideOption('fields', array( 'name' => array( 'id' => 'name', 'table' => 'views_test_data', diff --git a/lib/Drupal/views/Tests/Handler/FieldXssTest.php b/lib/Drupal/views/Tests/Handler/FieldXssTest.php index 753d9196ac8a8f9ce05dae21f6a1291bbb8366cf..01f95cb12d58d459bf00cea9f941d00083cf9b84 100644 --- a/lib/Drupal/views/Tests/Handler/FieldXssTest.php +++ b/lib/Drupal/views/Tests/Handler/FieldXssTest.php @@ -49,7 +49,7 @@ function viewsData() { public function testFieldXss() { $view = $this->getView(); - $view->display['default']->handler->overrideOption('fields', array( + $view->displayHandlers['default']->overrideOption('fields', array( 'name' => array( 'id' => 'name', 'table' => 'views_test_data', diff --git a/lib/Drupal/views/Tests/Handler/FilterCombineTest.php b/lib/Drupal/views/Tests/Handler/FilterCombineTest.php index af9d612348c727ae4993cba9d95fc576520ae3d7..160fb5cdee9a2a629d32e9631657c655b311c98b 100644 --- a/lib/Drupal/views/Tests/Handler/FilterCombineTest.php +++ b/lib/Drupal/views/Tests/Handler/FilterCombineTest.php @@ -35,7 +35,7 @@ function setUp() { protected function getBasicView() { $view = parent::getBasicView(); - $view->display['default']->display_options['fields']['job'] = array( + $view->display['default']['display_options']['fields']['job'] = array( 'id' => 'job', 'table' => 'views_test_data', 'field' => 'job', @@ -48,7 +48,7 @@ public function testFilterCombineContains() { $view = $this->getView(); // Change the filtering. - $view->display['default']->handler->overrideOption('filters', array( + $view->displayHandlers['default']->overrideOption('filters', array( 'age' => array( 'id' => 'combine', 'table' => 'views', diff --git a/lib/Drupal/views/Tests/Handler/FilterEqualityTest.php b/lib/Drupal/views/Tests/Handler/FilterEqualityTest.php index 250e19a5ac8c64de8df8f3d81f4e12297766b02a..986937f0c22eba29587e85b220b03c0f5ff6ee3b 100644 --- a/lib/Drupal/views/Tests/Handler/FilterEqualityTest.php +++ b/lib/Drupal/views/Tests/Handler/FilterEqualityTest.php @@ -41,7 +41,7 @@ function testEqual() { $view = $this->getView(); // Change the filtering - $view->display['default']->handler->overrideOption('filters', array( + $view->displayHandlers['default']->overrideOption('filters', array( 'name' => array( 'id' => 'name', 'table' => 'views_test_data', @@ -68,7 +68,7 @@ public function testEqualGroupedExposed() { // Filter: Name, Operator: =, Value: Ringo $filters['name']['group_info']['default_group'] = 1; $view->setDisplay('page_1'); - $view->display['page_1']->handler->overrideOption('filters', $filters); + $view->displayHandlers['page_1']->overrideOption('filters', $filters); $this->executeView($view); $resultset = array( @@ -83,7 +83,7 @@ function testNotEqual() { $view = $this->getView(); // Change the filtering - $view->display['default']->handler->overrideOption('filters', array( + $view->displayHandlers['default']->overrideOption('filters', array( 'name' => array( 'id' => 'name', 'table' => 'views_test_data', @@ -119,7 +119,7 @@ public function testEqualGroupedNotExposed() { // Filter: Name, Operator: !=, Value: Ringo $filters['name']['group_info']['default_group'] = 2; $view->setDisplay('page_1'); - $view->display['page_1']->handler->overrideOption('filters', $filters); + $view->displayHandlers['page_1']->overrideOption('filters', $filters); $this->executeView($view); $resultset = array( diff --git a/lib/Drupal/views/Tests/Handler/FilterInOperatorTest.php b/lib/Drupal/views/Tests/Handler/FilterInOperatorTest.php index f4e84ccbf91b7979eb7281e0724967125eb2b2a2..6854592d546d0dfc149b4d2b883391e7503a1cdf 100644 --- a/lib/Drupal/views/Tests/Handler/FilterInOperatorTest.php +++ b/lib/Drupal/views/Tests/Handler/FilterInOperatorTest.php @@ -37,7 +37,7 @@ public function testFilterInOperatorSimple() { $view = $this->getView(); // Add a in_operator ordering. - $view->display['default']->handler->overrideOption('filters', array( + $view->displayHandlers['default']->overrideOption('filters', array( 'age' => array( 'id' => 'age', 'field' => 'age', @@ -69,7 +69,7 @@ public function testFilterInOperatorSimple() { $view = $this->getView(); // Add a in_operator ordering. - $view->display['default']->handler->overrideOption('filters', array( + $view->displayHandlers['default']->overrideOption('filters', array( 'age' => array( 'id' => 'age', 'field' => 'age', @@ -110,7 +110,7 @@ public function testFilterInOperatorGroupedExposedSimple() { // Filter: Age, Operator: in, Value: 26, 30 $filters['age']['group_info']['default_group'] = 1; $view->setDisplay('page_1'); - $view->display['page_1']->handler->overrideOption('filters', $filters); + $view->displayHandlers['page_1']->overrideOption('filters', $filters); $this->executeView($view); @@ -139,7 +139,7 @@ public function testFilterNotInOperatorGroupedExposedSimple() { // Filter: Age, Operator: in, Value: 26, 30 $filters['age']['group_info']['default_group'] = 2; $view->setDisplay('page_1'); - $view->display['page_1']->handler->overrideOption('filters', $filters); + $view->displayHandlers['page_1']->overrideOption('filters', $filters); $this->executeView($view); diff --git a/lib/Drupal/views/Tests/Handler/FilterNumericTest.php b/lib/Drupal/views/Tests/Handler/FilterNumericTest.php index 2f95a2a57a637233edb43ce4ee50f0f30deceff0..c43150e07fc9b6b16739adea2197f07b26a0277e 100644 --- a/lib/Drupal/views/Tests/Handler/FilterNumericTest.php +++ b/lib/Drupal/views/Tests/Handler/FilterNumericTest.php @@ -45,7 +45,7 @@ public function testFilterNumericSimple() { $view = $this->getView(); // Change the filtering - $view->display['default']->handler->overrideOption('filters', array( + $view->displayHandlers['default']->overrideOption('filters', array( 'age' => array( 'id' => 'age', 'table' => 'views_test_data', @@ -73,7 +73,7 @@ public function testFilterNumericExposedGroupedSimple() { // Filter: Age, Operator: =, Value: 28 $filters['age']['group_info']['default_group'] = 1; $view->setDisplay('page_1'); - $view->display['page_1']->handler->overrideOption('filters', $filters); + $view->displayHandlers['page_1']->overrideOption('filters', $filters); $this->executeView($view); $resultset = array( @@ -89,7 +89,7 @@ public function testFilterNumericBetween() { $view = $this->getView(); // Change the filtering - $view->display['default']->handler->overrideOption('filters', array( + $view->displayHandlers['default']->overrideOption('filters', array( 'age' => array( 'id' => 'age', 'table' => 'views_test_data', @@ -125,7 +125,7 @@ public function testFilterNumericBetween() { $view = $this->getView(); // Change the filtering - $view->display['default']->handler->overrideOption('filters', array( + $view->displayHandlers['default']->overrideOption('filters', array( 'age' => array( 'id' => 'age', 'table' => 'views_test_data', @@ -164,7 +164,7 @@ public function testFilterNumericExposedGroupedBetween() { // Filter: Age, Operator: between, Value: 26 and 29 $filters['age']['group_info']['default_group'] = 2; $view->setDisplay('page_1'); - $view->display['page_1']->handler->overrideOption('filters', $filters); + $view->displayHandlers['page_1']->overrideOption('filters', $filters); $this->executeView($view); @@ -192,7 +192,7 @@ public function testFilterNumericExposedGroupedNotBetween() { // Filter: Age, Operator: between, Value: 26 and 29 $filters['age']['group_info']['default_group'] = 3; $view->setDisplay('page_1'); - $view->display['page_1']->handler->overrideOption('filters', $filters); + $view->displayHandlers['page_1']->overrideOption('filters', $filters); $this->executeView($view); @@ -218,7 +218,7 @@ public function testFilterNumericEmpty() { $view = $this->getView(); // Change the filtering - $view->display['default']->handler->overrideOption('filters', array( + $view->displayHandlers['default']->overrideOption('filters', array( 'age' => array( 'id' => 'age', 'table' => 'views_test_data', @@ -237,7 +237,7 @@ public function testFilterNumericEmpty() { $view = $this->getView(); // Change the filtering - $view->display['default']->handler->overrideOption('filters', array( + $view->displayHandlers['default']->overrideOption('filters', array( 'age' => array( 'id' => 'age', 'table' => 'views_test_data', @@ -281,7 +281,7 @@ public function testFilterNumericExposedGroupedEmpty() { // Filter: Age, Operator: empty, Value: $filters['age']['group_info']['default_group'] = 4; $view->setDisplay('page_1'); - $view->display['page_1']->handler->overrideOption('filters', $filters); + $view->displayHandlers['page_1']->overrideOption('filters', $filters); $this->executeView($view); @@ -297,7 +297,7 @@ public function testFilterNumericExposedGroupedNotEmpty() { // Filter: Age, Operator: empty, Value: $filters['age']['group_info']['default_group'] = 5; $view->setDisplay('page_1'); - $view->display['page_1']->handler->overrideOption('filters', $filters); + $view->displayHandlers['page_1']->overrideOption('filters', $filters); $this->executeView($view); @@ -330,7 +330,7 @@ public function testFilterNumericExposedGroupedNotEmpty() { public function testAllowEmpty() { $view = $this->getView(); - $view->display['default']->handler->overrideOption('filters', array( + $view->displayHandlers['default']->overrideOption('filters', array( 'id' => array( 'id' => 'id', 'table' => 'views_test_data', diff --git a/lib/Drupal/views/Tests/Handler/FilterStringTest.php b/lib/Drupal/views/Tests/Handler/FilterStringTest.php index db5e77aa74cc370503a8606e3612246f9d6a4ea7..1ff40e079f6eae253fe29da4f7796be95e0dc6ce 100644 --- a/lib/Drupal/views/Tests/Handler/FilterStringTest.php +++ b/lib/Drupal/views/Tests/Handler/FilterStringTest.php @@ -69,7 +69,7 @@ protected function dataSet() { protected function getBasicView() { $view = parent::getBasicView(); - $view->display['default']->options['fields']['description'] = array( + $view->displayHandlers['default']->options['fields']['description'] = array( 'id' => 'description', 'table' => 'views_test_data', 'field' => 'description', @@ -82,7 +82,7 @@ function testFilterStringEqual() { $view = $this->getView(); // Change the filtering - $view->display['default']->handler->overrideOption('filters', array( + $view->displayHandlers['default']->overrideOption('filters', array( 'name' => array( 'id' => 'name', 'table' => 'views_test_data', @@ -109,7 +109,7 @@ function testFilterStringGroupedExposedEqual() { // Filter: Name, Operator: =, Value: Ringo $filters['name']['group_info']['default_group'] = 1; $view->setDisplay('page_1'); - $view->display['page_1']->handler->overrideOption('filters', $filters); + $view->displayHandlers['page_1']->overrideOption('filters', $filters); $this->executeView($view); @@ -126,7 +126,7 @@ function testFilterStringNotEqual() { $view = $this->getView(); // Change the filtering - $view->display['default']->handler->overrideOption('filters', array( + $view->displayHandlers['default']->overrideOption('filters', array( 'name' => array( 'id' => 'name', 'table' => 'views_test_data', @@ -163,7 +163,7 @@ function testFilterStringGroupedExposedNotEqual() { $filters['name']['group_info']['default_group'] = '2'; $view->setDisplay('page_1'); - $view->display['page_1']->handler->overrideOption('filters', $filters); + $view->displayHandlers['page_1']->overrideOption('filters', $filters); $this->executeView($view); @@ -189,7 +189,7 @@ function testFilterStringContains() { $view = $this->getView(); // Change the filtering - $view->display['default']->handler->overrideOption('filters', array( + $view->displayHandlers['default']->overrideOption('filters', array( 'name' => array( 'id' => 'name', 'table' => 'views_test_data', @@ -217,7 +217,7 @@ function testFilterStringGroupedExposedContains() { // Filter: Name, Operator: contains, Value: ing $filters['name']['group_info']['default_group'] = '3'; $view->setDisplay('page_1'); - $view->display['page_1']->handler->overrideOption('filters', $filters); + $view->displayHandlers['page_1']->overrideOption('filters', $filters); $this->executeView($view); @@ -235,7 +235,7 @@ function testFilterStringWord() { $view = $this->getView(); // Change the filtering - $view->display['default']->handler->overrideOption('filters', array( + $view->displayHandlers['default']->overrideOption('filters', array( 'description' => array( 'id' => 'description', 'table' => 'views_test_data', @@ -261,7 +261,7 @@ function testFilterStringWord() { $view = $this->getView(); // Change the filtering - $view->display['default']->handler->overrideOption('filters', array( + $view->displayHandlers['default']->overrideOption('filters', array( 'description' => array( 'id' => 'description', 'table' => 'views_test_data', @@ -289,7 +289,7 @@ function testFilterStringGroupedExposedWord() { // Filter: Name, Operator: contains, Value: ing $filters['name']['group_info']['default_group'] = '3'; $view->setDisplay('page_1'); - $view->display['page_1']->handler->overrideOption('filters', $filters); + $view->displayHandlers['page_1']->overrideOption('filters', $filters); $this->executeView($view); @@ -308,7 +308,7 @@ function testFilterStringGroupedExposedWord() { // Filter: Description, Operator: contains, Value: actor $filters['description']['group_info']['default_group'] = '1'; $view->setDisplay('page_1'); - $view->display['page_1']->handler->overrideOption('filters', $filters); + $view->displayHandlers['page_1']->overrideOption('filters', $filters); $this->executeView($view); $resultset = array( @@ -326,7 +326,7 @@ function testFilterStringStarts() { $view = $this->getView(); // Change the filtering - $view->display['default']->handler->overrideOption('filters', array( + $view->displayHandlers['default']->overrideOption('filters', array( 'description' => array( 'id' => 'description', 'table' => 'views_test_data', @@ -353,7 +353,7 @@ function testFilterStringGroupedExposedStarts() { // Filter: Name, Operator: starts, Value: George $filters['description']['group_info']['default_group'] = 2; $view->setDisplay('page_1'); - $view->display['page_1']->handler->overrideOption('filters', $filters); + $view->displayHandlers['page_1']->overrideOption('filters', $filters); $this->executeView($view); @@ -369,7 +369,7 @@ function testFilterStringNotStarts() { $view = $this->getView(); // Change the filtering - $view->display['default']->handler->overrideOption('filters', array( + $view->displayHandlers['default']->overrideOption('filters', array( 'description' => array( 'id' => 'description', 'table' => 'views_test_data', @@ -403,7 +403,7 @@ function testFilterStringGroupedExposedNotStarts() { // Filter: Name, Operator: not_starts, Value: George $filters['description']['group_info']['default_group'] = 3; $view->setDisplay('page_1'); - $view->display['page_1']->handler->overrideOption('filters', $filters); + $view->displayHandlers['page_1']->overrideOption('filters', $filters); $this->executeView($view); @@ -426,7 +426,7 @@ function testFilterStringEnds() { $view = $this->getView(); // Change the filtering - $view->display['default']->handler->overrideOption('filters', array( + $view->displayHandlers['default']->overrideOption('filters', array( 'description' => array( 'id' => 'description', 'table' => 'views_test_data', @@ -456,7 +456,7 @@ function testFilterStringGroupedExposedEnds() { // Filter: Descriptino, Operator: ends, Value: Beatles $filters['description']['group_info']['default_group'] = 4; $view->setDisplay('page_1'); - $view->display['page_1']->handler->overrideOption('filters', $filters); + $view->displayHandlers['page_1']->overrideOption('filters', $filters); $this->executeView($view); @@ -475,7 +475,7 @@ function testFilterStringNotEnds() { $view = $this->getView(); // Change the filtering - $view->display['default']->handler->overrideOption('filters', array( + $view->displayHandlers['default']->overrideOption('filters', array( 'description' => array( 'id' => 'description', 'table' => 'views_test_data', @@ -506,7 +506,7 @@ function testFilterStringGroupedExposedNotEnds() { // Filter: Description, Operator: not_ends, Value: Beatles $filters['description']['group_info']['default_group'] = 5; $view->setDisplay('page_1'); - $view->display['page_1']->handler->overrideOption('filters', $filters); + $view->displayHandlers['page_1']->overrideOption('filters', $filters); $this->executeView($view); @@ -526,7 +526,7 @@ function testFilterStringNot() { $view = $this->getView(); // Change the filtering - $view->display['default']->handler->overrideOption('filters', array( + $view->displayHandlers['default']->overrideOption('filters', array( 'description' => array( 'id' => 'description', 'table' => 'views_test_data', @@ -558,7 +558,7 @@ function testFilterStringGroupedExposedNot() { // Filter: Description, Operator: not (does not contains), Value: Beatles $filters['description']['group_info']['default_group'] = 6; $view->setDisplay('page_1'); - $view->display['page_1']->handler->overrideOption('filters', $filters); + $view->displayHandlers['page_1']->overrideOption('filters', $filters); $this->executeView($view); @@ -579,7 +579,7 @@ function testFilterStringShorter() { $view = $this->getView(); // Change the filtering - $view->display['default']->handler->overrideOption('filters', array( + $view->displayHandlers['default']->overrideOption('filters', array( 'name' => array( 'id' => 'name', 'table' => 'views_test_data', @@ -609,7 +609,7 @@ function testFilterStringGroupedExposedShorter() { // Filter: Name, Operator: shorterthan, Value: 5 $filters['name']['group_info']['default_group'] = 4; $view->setDisplay('page_1'); - $view->display['page_1']->handler->overrideOption('filters', $filters); + $view->displayHandlers['page_1']->overrideOption('filters', $filters); $this->executeView($view); $resultset = array( @@ -627,7 +627,7 @@ function testFilterStringLonger() { $view = $this->getView(); // Change the filtering - $view->display['default']->handler->overrideOption('filters', array( + $view->displayHandlers['default']->overrideOption('filters', array( 'name' => array( 'id' => 'name', 'table' => 'views_test_data', @@ -654,7 +654,7 @@ function testFilterStringGroupedExposedLonger() { // Filter: Name, Operator: longerthan, Value: 4 $filters['name']['group_info']['default_group'] = 5; $view->setDisplay('page_1'); - $view->display['page_1']->handler->overrideOption('filters', $filters); + $view->displayHandlers['page_1']->overrideOption('filters', $filters); $this->executeView($view); $resultset = array( @@ -670,7 +670,7 @@ function testFilterStringEmpty() { $view = $this->getView(); // Change the filtering - $view->display['default']->handler->overrideOption('filters', array( + $view->displayHandlers['default']->overrideOption('filters', array( 'description' => array( 'id' => 'description', 'table' => 'views_test_data', @@ -696,7 +696,7 @@ function testFilterStringGroupedExposedEmpty() { // Filter: Description, Operator: empty, Value: $filters['description']['group_info']['default_group'] = 7; $view->setDisplay('page_1'); - $view->display['page_1']->handler->overrideOption('filters', $filters); + $view->displayHandlers['page_1']->overrideOption('filters', $filters); $this->executeView($view); $resultset = array( diff --git a/lib/Drupal/views/Tests/Handler/HandlerAliasTest.php b/lib/Drupal/views/Tests/Handler/HandlerAliasTest.php index 6474f3c6037c13d9dadc79ad25745a300c9d24ab..6be08fa1ade38c68b1734726b15a9f6c9b066589 100644 --- a/lib/Drupal/views/Tests/Handler/HandlerAliasTest.php +++ b/lib/Drupal/views/Tests/Handler/HandlerAliasTest.php @@ -49,7 +49,7 @@ public function testPluginAliases() { $view->initDisplay(); // Change the filtering. - $view->display['default']->handler->overrideOption('filters', array( + $view->displayHandlers['default']->overrideOption('filters', array( 'test_filter' => array( 'id' => 'test_filter', 'table' => 'views_test_data_alias', diff --git a/lib/Drupal/views/Tests/Handler/RelationshipTest.php b/lib/Drupal/views/Tests/Handler/RelationshipTest.php index 68bb28a1c0306aa20e406ac3f812f45aa0d63dd5..e5a5a65122245cbbbf9d2ab95d39fcd6769aa5e3 100644 --- a/lib/Drupal/views/Tests/Handler/RelationshipTest.php +++ b/lib/Drupal/views/Tests/Handler/RelationshipTest.php @@ -93,7 +93,7 @@ public function testRelationshipQuery() { $view = $this->getBasicView(); - $view->display['default']->handler->overrideOption('relationships', array( + $view->displayHandlers['default']->overrideOption('relationships', array( 'uid' => array( 'id' => 'uid', 'table' => 'views_test_data', @@ -101,7 +101,7 @@ public function testRelationshipQuery() { ), )); - $view->display['default']->handler->overrideOption('filters', array( + $view->displayHandlers['default']->overrideOption('filters', array( 'uid' => array( 'id' => 'uid', 'table' => 'users', @@ -110,8 +110,8 @@ public function testRelationshipQuery() { ), )); - $fields = $view->display['default']->handler->getOption('fields'); - $view->display['default']->handler->overrideOption('fields', $fields + array( + $fields = $view->displayHandlers['default']->getOption('fields'); + $view->displayHandlers['default']->overrideOption('fields', $fields + array( 'uid' => array( 'id' => 'uid', 'table' => 'users', diff --git a/lib/Drupal/views/Tests/Handler/SortDateTest.php b/lib/Drupal/views/Tests/Handler/SortDateTest.php index dc2fb6edc51228161b83ae8062d21fcbbf0b960b..2861be3210b54f971774429ee22c252a9966223f 100644 --- a/lib/Drupal/views/Tests/Handler/SortDateTest.php +++ b/lib/Drupal/views/Tests/Handler/SortDateTest.php @@ -157,7 +157,7 @@ public function testDateOrdering() { $view = $this->getView(); // Change the fields. - $view->display['default']->handler->overrideOption('fields', array( + $view->displayHandlers['default']->overrideOption('fields', array( 'name' => array( 'id' => 'name', 'table' => 'views_test_data', @@ -173,7 +173,7 @@ public function testDateOrdering() { )); // Change the ordering - $view->display['default']->handler->overrideOption('sorts', array( + $view->displayHandlers['default']->overrideOption('sorts', array( 'created' => array( 'id' => 'created', 'table' => 'views_test_data', diff --git a/lib/Drupal/views/Tests/Handler/SortRandomTest.php b/lib/Drupal/views/Tests/Handler/SortRandomTest.php index fb3984e20e5dd4166502f0c80099c589992a8190..a6d2a2f68f51a561f671aef77d8cffa3515ee2ff 100644 --- a/lib/Drupal/views/Tests/Handler/SortRandomTest.php +++ b/lib/Drupal/views/Tests/Handler/SortRandomTest.php @@ -49,7 +49,7 @@ protected function getBasicRandomView() { $view = $this->getView(); // Add a random ordering. - $view->display['default']->handler->overrideOption('sorts', array( + $view->displayHandlers['default']->overrideOption('sorts', array( 'random' => array( 'id' => 'random', 'field' => 'random', diff --git a/lib/Drupal/views/Tests/Handler/SortTest.php b/lib/Drupal/views/Tests/Handler/SortTest.php index d30e38b2e7a19da3b5d24d63bff256586e6e98b8..351f769982f6437bac7c2d9d453e2ebda106fe59 100644 --- a/lib/Drupal/views/Tests/Handler/SortTest.php +++ b/lib/Drupal/views/Tests/Handler/SortTest.php @@ -33,7 +33,7 @@ public function testNumericOrdering() { $view = $this->getView(); // Change the ordering - $view->display['default']->handler->overrideOption('sorts', array( + $view->displayHandlers['default']->overrideOption('sorts', array( 'age' => array( 'order' => 'ASC', 'id' => 'age', @@ -56,7 +56,7 @@ public function testNumericOrdering() { $view = $this->getView(); // Reverse the ordering - $view->display['default']->handler->overrideOption('sorts', array( + $view->displayHandlers['default']->overrideOption('sorts', array( 'age' => array( 'order' => 'DESC', 'id' => 'age', @@ -84,7 +84,7 @@ public function testStringOrdering() { $view = $this->getView(); // Change the ordering - $view->display['default']->handler->overrideOption('sorts', array( + $view->displayHandlers['default']->overrideOption('sorts', array( 'name' => array( 'order' => 'ASC', 'id' => 'name', @@ -107,7 +107,7 @@ public function testStringOrdering() { $view = $this->getView(); // Reverse the ordering - $view->display['default']->handler->overrideOption('sorts', array( + $view->displayHandlers['default']->overrideOption('sorts', array( 'name' => array( 'order' => 'DESC', 'id' => 'name', diff --git a/lib/Drupal/views/Tests/Language/ArgumentLanguage.php b/lib/Drupal/views/Tests/Language/ArgumentLanguage.php index bc5b75a562e7f17edea995f4683ac0be9fe97fcf..73490af97e6a3c880baef59cee1a0c5949b99afd 100644 --- a/lib/Drupal/views/Tests/Language/ArgumentLanguage.php +++ b/lib/Drupal/views/Tests/Language/ArgumentLanguage.php @@ -27,7 +27,7 @@ public static function getInfo() { public function testFilter() { foreach (array('en' => 'John', 'xx-lolspeak' => 'George') as $langcode => $name) { $view = $this->getView(); - $view->display['default']->handler->overrideOption('arguments', array( + $view->displayHandlers['default']->overrideOption('arguments', array( 'langcode' => array( 'id' => 'langcode', 'table' => 'views_test_data', diff --git a/lib/Drupal/views/Tests/Language/FieldLanguage.php b/lib/Drupal/views/Tests/Language/FieldLanguage.php index d530cf5384764cd3e98422a0a31bcb21cb2b2ebd..0d282c608a27c36d37be73682d8ccb9721fa7a3b 100644 --- a/lib/Drupal/views/Tests/Language/FieldLanguage.php +++ b/lib/Drupal/views/Tests/Language/FieldLanguage.php @@ -26,7 +26,7 @@ public static function getInfo() { public function testField() { $view = $this->getView(); - $view->display['default']->handler->overrideOption('fields', array( + $view->displayHandlers['default']->overrideOption('fields', array( 'langcode' => array( 'id' => 'langcode', 'table' => 'views_test_data', diff --git a/lib/Drupal/views/Tests/Language/FilterLanguage.php b/lib/Drupal/views/Tests/Language/FilterLanguage.php index f9fb360b1026976a9bd4da7a6b82f3e07fd424ff..5d7b5487d21718b9d7788e1a1d1122c8239e4acb 100644 --- a/lib/Drupal/views/Tests/Language/FilterLanguage.php +++ b/lib/Drupal/views/Tests/Language/FilterLanguage.php @@ -27,7 +27,7 @@ public static function getInfo() { public function testFilter() { foreach (array('en' => 'John', 'xx-lolspeak' => 'George') as $langcode => $name) { $view = $this->getView(); - $view->display['default']->handler->overrideOption('filters', array( + $view->displayHandlers['default']->overrideOption('filters', array( 'langcode' => array( 'id' => 'langcode', 'table' => 'views_test_data', diff --git a/lib/Drupal/views/Tests/Plugin/AccessTest.php b/lib/Drupal/views/Tests/Plugin/AccessTest.php index 4f1cc30fe979364d626e2af08774c4a1c6f8933c..3eb899b9f1a605674a62685b21e916d0256393cb 100644 --- a/lib/Drupal/views/Tests/Plugin/AccessTest.php +++ b/lib/Drupal/views/Tests/Plugin/AccessTest.php @@ -69,7 +69,7 @@ function testAccessPerm() { function testAccessRole() { $view = $this->createViewFromConfig('test_access_role'); - $view->display['default']->handler->options['access']['role'] = array( + $view->displayHandlers['default']->options['access']['role'] = array( $this->normal_role => $this->normal_role, ); diff --git a/lib/Drupal/views/Tests/Plugin/ArgumentDefaultTest.php b/lib/Drupal/views/Tests/Plugin/ArgumentDefaultTest.php index 4ef6ca77df9257ab73a8cba18735893817083ffb..0c638cc9bba90b665cf35623ed783f7d8ca5db85 100644 --- a/lib/Drupal/views/Tests/Plugin/ArgumentDefaultTest.php +++ b/lib/Drupal/views/Tests/Plugin/ArgumentDefaultTest.php @@ -142,7 +142,7 @@ function testArgumentDefaultFixed() { */ protected function getBasicView() { $view = $this->createViewFromConfig('test_argument_default_fixed'); - $view->display['default']->display_options['arguments']['null']['default_argument_options']['argument'] = $this->random; + $view->display['default']['display_options']['arguments']['null']['default_argument_options']['argument'] = $this->random; return $view; } diff --git a/lib/Drupal/views/Tests/Plugin/ArgumentValidatorTest.php b/lib/Drupal/views/Tests/Plugin/ArgumentValidatorTest.php index fca3dad7568af330563fd14d0a82660b589be444..fa9541f540be177d8078d7c5c58e553560b23cfe 100644 --- a/lib/Drupal/views/Tests/Plugin/ArgumentValidatorTest.php +++ b/lib/Drupal/views/Tests/Plugin/ArgumentValidatorTest.php @@ -23,7 +23,7 @@ public static function getInfo() { function testArgumentValidatePhp() { $string = $this->randomName(); $view = $this->createViewFromConfig('test_view_argument_validate_php'); - $view->display['default']->handler->options['arguments']['null']['validate_options']['code'] = 'return $argument == \''. $string .'\';'; + $view->displayHandlers['default']->options['arguments']['null']['validate_options']['code'] = 'return $argument == \''. $string .'\';'; $view->preExecute(); $view->initHandlers(); diff --git a/lib/Drupal/views/Tests/Plugin/DisplayTest.php b/lib/Drupal/views/Tests/Plugin/DisplayTest.php index 6b6fc7c0df6c93f3d66095d3e6e7de672d1abfb5..425dabf514b957d63509abdade4272fb9467f8d3 100644 --- a/lib/Drupal/views/Tests/Plugin/DisplayTest.php +++ b/lib/Drupal/views/Tests/Plugin/DisplayTest.php @@ -7,7 +7,6 @@ namespace Drupal\views\Tests\Plugin; -use Drupal\views\ViewDisplay; use Drupal\views_test_data\Plugin\views\display\DisplayTest as DisplayTestPlugin; /** @@ -57,7 +56,7 @@ function testDisplayPlugin() { $this->assertTrue(isset($view->display['display_test_1']), 'Added display has been assigned to "display_test_1"'); - // Create an expected ViewDisplay and check that it's equal. + // Check the the display options are like expected. $options = array( 'display_options' => array(), 'display_plugin' => 'display_test', @@ -65,8 +64,7 @@ function testDisplayPlugin() { 'display_title' => 'Display test', 'position' => NULL, ); - $expected_display = new ViewDisplay($options); - $this->assertEqual($view->display['display_test_1'], $expected_display); + $this->assertEqual($view->display['display_test_1'], $options); $view->setDisplay('display_test_1'); @@ -110,9 +108,9 @@ public function testFilterGroupsOverriding() { $view->initDisplay(); // mark is as overridden, yes FALSE, means overridden. - $view->display['page']->handler->setOverride('filter_groups', FALSE); - $this->assertFalse($view->display['page']->handler->isDefaulted('filter_groups'), "Take sure that 'filter_groups' is marked as overridden."); - $this->assertFalse($view->display['page']->handler->isDefaulted('filters'), "Take sure that 'filters'' is marked as overridden."); + $view->displayHandlers['page']->setOverride('filter_groups', FALSE); + $this->assertFalse($view->displayHandlers['page']->isDefaulted('filter_groups'), "Take sure that 'filter_groups' is marked as overridden."); + $this->assertFalse($view->displayHandlers['page']->isDefaulted('filters'), "Take sure that 'filters'' is marked as overridden."); } } diff --git a/lib/Drupal/views/Tests/Plugin/FilterTest.php b/lib/Drupal/views/Tests/Plugin/FilterTest.php index ae30e8e524a6e5338a75f6b55124f7e13102d932..f200f06c4300eed83904e6ccba5828e68703a4cc 100644 --- a/lib/Drupal/views/Tests/Plugin/FilterTest.php +++ b/lib/Drupal/views/Tests/Plugin/FilterTest.php @@ -59,7 +59,7 @@ public function testFilterQuery() { $view->initDisplay(); // Change the filtering. - $view->display['default']->handler->overrideOption('filters', array( + $view->displayHandlers['default']->overrideOption('filters', array( 'test_filter' => array( 'id' => 'test_filter', 'table' => 'views_test_data', @@ -95,7 +95,7 @@ public function testFilterQuery() { $view->initDisplay(); // Change the filtering. - $view->display['default']->handler->overrideOption('filters', array( + $view->displayHandlers['default']->overrideOption('filters', array( 'test_filter' => array( 'id' => 'test_filter', 'table' => 'views_test_data', @@ -121,7 +121,7 @@ public function testFilterQuery() { // Set the test_enable option to FALSE. The 'where' clause should not be // added to the query. - $view->display['default']->handler->overrideOption('filters', array( + $view->displayHandlers['default']->overrideOption('filters', array( 'test_filter' => array( 'id' => 'test_filter', 'table' => 'views_test_data', diff --git a/lib/Drupal/views/Tests/Plugin/StyleMappingTest.php b/lib/Drupal/views/Tests/Plugin/StyleMappingTest.php index dea64539ae4cba35ed270d179053f7fcebef064a..97882922de5544721716860b20e18649c35a857d 100644 --- a/lib/Drupal/views/Tests/Plugin/StyleMappingTest.php +++ b/lib/Drupal/views/Tests/Plugin/StyleMappingTest.php @@ -36,7 +36,7 @@ public function testMappedOutput() { $this->assertTrue(strpos($output, 'job') === FALSE, 'The job field is added to the view but not in the mapping.'); $view = $this->getView(); - $view->display['default']->handler->options['style_options']['mapping']['name_field'] = 'job'; + $view->displayHandlers['default']->options['style_options']['mapping']['name_field'] = 'job'; $output = $this->mappedOutputHelper($view); $this->assertTrue(strpos($output, 'job') !== FALSE, 'The job field is added to the view and is in the mapping.'); } diff --git a/lib/Drupal/views/Tests/Plugin/StyleTest.php b/lib/Drupal/views/Tests/Plugin/StyleTest.php index ed0efd8c789be349cdfe246816a0c9926a93e324..a6fc58f97908fe72447e48a86c8aad863cefa9e5 100644 --- a/lib/Drupal/views/Tests/Plugin/StyleTest.php +++ b/lib/Drupal/views/Tests/Plugin/StyleTest.php @@ -49,7 +49,7 @@ public function testStyle() { $view->initStyle(); $view->style_plugin->setUsesRowPlugin(TRUE); // Reinitialize the style as it supports row plugins now. - $view->style_plugin->init($view, $view->display[$view->current_display], array()); + $view->style_plugin->init($view, $view->display_handler, array()); $this->assertTrue($view->style_plugin->row_plugin instanceof \Drupal\views_test_data\Plugin\views\row\RowTest, 'Make sure the right row plugin class is loaded.'); $random_text = $this->randomName(); @@ -71,13 +71,13 @@ function testGroupingLegacy() { // Reduce the amount of items to make the test a bit easier. // Set up the pager. - $view->display['default']->handler->overrideOption('pager', array( + $view->displayHandlers['default']->overrideOption('pager', array( 'type' => 'some', 'options' => array('items_per_page' => 3), )); // Add the job field . - $view->display['default']->handler->overrideOption('fields', array( + $view->displayHandlers['default']->overrideOption('fields', array( 'name' => array( 'id' => 'name', 'table' => 'views_test_data', @@ -170,13 +170,13 @@ function _testGrouping($stripped = FALSE) { // Reduce the amount of items to make the test a bit easier. // Set up the pager. - $view->display['default']->handler->overrideOption('pager', array( + $view->displayHandlers['default']->overrideOption('pager', array( 'type' => 'some', 'options' => array('items_per_page' => 3), )); // Add the job and age field. - $view->display['default']->handler->overrideOption('fields', array( + $view->displayHandlers['default']->overrideOption('fields', array( 'name' => array( 'id' => 'name', 'table' => 'views_test_data', diff --git a/lib/Drupal/views/Tests/QueryGroupByTest.php b/lib/Drupal/views/Tests/QueryGroupByTest.php index d3d2191b47b02c284ff5c0e4a7bcf7ee7369534e..cb5416be3092877ef05a83fd890b6bafe796a516 100644 --- a/lib/Drupal/views/Tests/QueryGroupByTest.php +++ b/lib/Drupal/views/Tests/QueryGroupByTest.php @@ -87,7 +87,7 @@ function GroupByTestHelper($group_by, $values) { $this->drupalCreateNode($node_2); $view = $this->createViewFromConfig('test_group_by_count'); - $view->display['default']->handler->options['fields']['nid']['group_type'] = $group_by; + $view->displayHandlers['default']->options['fields']['nid']['group_type'] = $group_by; $this->executeView($view); $this->assertEqual(count($view->result), 2, 'Make sure the count of items is right.'); diff --git a/lib/Drupal/views/Tests/User/ArgumentValidateTest.php b/lib/Drupal/views/Tests/User/ArgumentValidateTest.php index 73487ec105cbc1b6b3c427d23dd2bc29795a96e0..c699261a99b246ae9a852c6e68d7361bbd35c113 100644 --- a/lib/Drupal/views/Tests/User/ArgumentValidateTest.php +++ b/lib/Drupal/views/Tests/User/ArgumentValidateTest.php @@ -77,7 +77,7 @@ function testArgumentValidateUserEither() { function view_argument_validate_user($argtype) { $view = $this->createViewFromConfig('test_view_argument_validate_user'); - $view->display['default']->handler->options['arguments']['null']['validate_options']['type'] = $argtype; + $view->displayHandlers['default']->options['arguments']['null']['validate_options']['type'] = $argtype; $view->preExecute(); $view->initHandlers(); diff --git a/lib/Drupal/views/Tests/ViewExecutableTest.php b/lib/Drupal/views/Tests/ViewExecutableTest.php index c518f56e0e10fc92b1672d4a873b5b19591568c2..02eb4d97cc3d773d110f7aa9609bcf8494b564b2 100644 --- a/lib/Drupal/views/Tests/ViewExecutableTest.php +++ b/lib/Drupal/views/Tests/ViewExecutableTest.php @@ -72,4 +72,44 @@ public function testProperties() { $storage->human_name = $this->randomName(); $this->assertIdentical($view->human_name, $storage->human_name); } + + /** + * Tests the display related methods and properties. + */ + public function testDisplays() { + $view = views_get_view('test_executable_displays'); + + // Tests Drupal\views\ViewExecutable::initDisplay(). + $view->initDisplay(); + $count = count($view->displayHandlers); + $this->assertEqual($count, 3, format_string('Make sure all display handlers got instantiated (@count of @count_expected)', array('@count' => $count, '@count_expected' => 3))); + // Tests the classes of the instances. + $this->assertTrue($view->displayHandlers['default'] instanceof \Drupal\views\Plugin\views\display\DefaultDisplay); + $this->assertTrue($view->displayHandlers['page'] instanceof \Drupal\views\Plugin\views\display\Page); + $this->assertTrue($view->displayHandlers['page_2'] instanceof \Drupal\views\Plugin\views\display\Page); + + // After initializing the default display is the current used display. + $this->assertEqual($view->current_display, 'default'); + $this->assertEqual(spl_object_hash($view->display_handler), spl_object_hash($view->displayHandlers['default'])); + + // All handlers should have a reference to the default display. + $this->assertEqual(spl_object_hash($view->displayHandlers['page']->default_display), spl_object_hash($view->displayHandlers['default'])); + $this->assertEqual(spl_object_hash($view->displayHandlers['page_2']->default_display), spl_object_hash($view->displayHandlers['default'])); + + // Tests Drupal\views\ViewExecutable::setDisplay(). + $view->setDisplay(); + $this->assertEqual($view->current_display, 'default', 'If setDisplay is called with no parameter the default display should be used.'); + $this->assertEqual(spl_object_hash($view->display_handler), spl_object_hash($view->displayHandlers['default'])); + + // Set two different valid displays. + $view->setDisplay('page'); + $this->assertEqual($view->current_display, 'page', 'If setDisplay is called with a valid display id the appropriate display should be used.'); + $this->assertEqual(spl_object_hash($view->display_handler), spl_object_hash($view->displayHandlers['page'])); + + $view->setDisplay('page_2'); + $this->assertEqual($view->current_display, 'page_2', 'If setDisplay is called with a valid display id the appropriate display should be used.'); + $this->assertEqual(spl_object_hash($view->display_handler), spl_object_hash($view->displayHandlers['page_2'])); + + + } } diff --git a/lib/Drupal/views/Tests/ViewStorageTest.php b/lib/Drupal/views/Tests/ViewStorageTest.php index 6e300a7f859d3b9b4bbae1379b43b7f31a0320bf..186858cab6cb58edef2f0e202fde577c51a606ba 100644 --- a/lib/Drupal/views/Tests/ViewStorageTest.php +++ b/lib/Drupal/views/Tests/ViewStorageTest.php @@ -8,6 +8,7 @@ namespace Drupal\views\Tests; use Drupal\simpletest\WebTestBase; +use Drupal\views\ViewExecutable; use Drupal\views\ViewStorageController; use Drupal\views\ViewStorage; use Drupal\views\ViewDisplay; @@ -86,6 +87,9 @@ function testConfigurationEntityCRUD() { $this->deleteTests(); $this->displayTests(); $this->statusTests(); + + // Helper method tests + $this->displayMethodTests(); } /** @@ -109,14 +113,13 @@ protected function loadTests() { // Check each ViewDisplay object and confirm that it has the correct key and // property values. foreach ($view->display as $key => $display) { - $this->assertTrue($display instanceof ViewDisplay, format_string('Display: @display is instance of ViewDisplay.', array('@display' => $key))); - $this->assertEqual($key, $display->id, 'The display has the correct ID assigned.'); + $this->assertEqual($key, $display['id'], 'The display has the correct ID assigned.'); // Get original display data and confirm that the display options array // exists. $original_options = $data['display'][$key]; foreach ($original_options as $orig_key => $value) { - $this->assertIdentical($display->{$orig_key}, $value, format_string('@key is identical to saved data', array('@key' => $key))); + $this->assertIdentical($display[$orig_key], $value, format_string('@key is identical to saved data', array('@key' => $key))); } } @@ -174,7 +177,6 @@ protected function createTests() { // Test created displays. foreach ($created->display as $key => $display) { - $this->assertTrue($display instanceof ViewDisplay, format_string('Display @display is an instance of ViewDisplay.', array('@display' => $key))); } // Check the uuid of the loaded View. @@ -217,8 +219,8 @@ protected function saveTests() { $created_loaded = $this->loadView($created->id()); $values_loaded = config('views.view.archive')->get(); - $this->assertTrue(isset($created_loaded->display['default']->display_options), 'Make sure that the display options exist.'); - $this->assertEqual($created_loaded->display['default']->display_plugin, 'default', 'Make sure the right display plugin is set.'); + $this->assertTrue(isset($created_loaded->display['default']['display_options']), 'Make sure that the display options exist.'); + $this->assertEqual($created_loaded->display['default']['display_plugin'], 'default', 'Make sure the right display plugin is set.'); $this->assertEqual($values, $values_loaded, 'The loaded config is the same as the original loaded one.'); @@ -247,11 +249,10 @@ protected function displayTests() { $view->newDisplay('page', 'Test', 'test'); $new_display = $view->display['test']; - $this->assertTrue($new_display instanceof ViewDisplay, 'New page display "test" created.'); // Ensure the right display_plugin is created/instantiated. - $this->assertEqual($new_display->display_plugin, 'page', 'New page display "test" uses the right display plugin.'); - $this->assertTrue($new_display->handler instanceof Page, 'New page display "test" uses the right display plugin.'); + $this->assertEqual($new_display['display_plugin'], 'page', 'New page display "test" uses the right display plugin.'); + $this->assertTrue($view->executable->displayHandlers[$new_display['id']] instanceof Page, 'New page display "test" uses the right display plugin.'); $view->set('name', 'frontpage_new'); @@ -301,4 +302,135 @@ protected function loadView($view_name) { return reset($load); } + /** + * Tests the display related functions like getDisplaysList(). + */ + protected function displayMethodTests() { + $config['display'] = array( + 'page' => array( + 'display_options' => array('path' => 'test'), + 'display_plugin' => 'page', + 'id' => 'page_2', + 'display_title' => 'Page 2', + 'position' => 1 + ), + 'feed' => array( + 'display_options' => array('path' => 'test.xml'), + 'display_plugin' => 'feed', + 'id' => 'feed', + 'display_title' => 'Feed', + 'position' => 2 + ), + 'page_2' => array( + 'display_options' => array('path' => 'test/%/extra'), + 'display_plugin' => 'page', + 'id' => 'page_2', + 'display_title' => 'Page 2', + 'position' => 3 + ) + ); + $view = $this->controller->create($config); + + $this->assertEqual($view->getDisplaysList(), array('Feed', 'Page'), 'Make sure the display admin names are returns in alphabetic order.'); + + // Paths with a "%" shouldn't not be linked + $expected_paths = array(); + $expected_paths[] = l('/test', 'test'); + $expected_paths[] = l('/test.xml', 'test.xml'); + $expected_paths[] = '/test/%/extra'; + + $this->assertEqual($view->getPaths(), $expected_paths, 'Make sure the paths in the ui are generated as expected.'); + + // Tests Drupal\views\ViewStorage::addDisplay() + $view = $this->controller->create(array()); + $random_title = $this->randomName(); + + $id = $view->addDisplay('page', $random_title); + $this->assertEqual($id, 'page_1', format_string('Make sure the first display (%id_new) has the expected id (%id)', array('%id_new' => $id, '%id' => 'page_1'))); + $this->assertEqual($view->display[$id]['display_title'], $random_title); + + $random_title = $this->randomName(); + $id = $view->addDisplay('page', $random_title); + $this->assertEqual($id, 'page_2', format_string('Make sure the second display (%id_new) has the expected id (%id)', array('%id_new' => $id, '%id' => 'page_2'))); + $this->assertEqual($view->display[$id]['display_title'], $random_title); + + $id = $view->addDisplay('page'); + $this->assertEqual($view->display[$id]['display_title'], 'Page 3'); + + // Tests Drupal\views\ViewStorage::generateDisplayId(). + // @todo Sadly this method is not public so it cannot be tested. + // $view = $this->controller->create(array()); + // $this->assertEqual($view->generateDisplayId('default'), 'default', 'The plugin id for default is always default.'); + // $this->assertEqual($view->generateDisplayId('feed'), 'feed_1', 'The generated id for the first instance of a plugin type should have an suffix of _1.'); + // $view->addDisplay('feed', 'feed title'); + // $this->assertEqual($view->generateDisplayId('feed'), 'feed_2', 'The generated id for the first instance of a plugin type should have an suffix of _2.'); + + // Tests Drupal\views\ViewStorage::newDisplay(). + $view = $this->controller->create(array()); + $view->newDisplay('default'); + + $display = $view->newDisplay('page'); + $this->assertTrue($display instanceof \Drupal\views\Plugin\views\display\Page); + $this->assertTrue($view->executable->displayHandlers['page_1'] instanceof \Drupal\views\Plugin\views\display\Page); + $this->assertTrue($view->executable->displayHandlers['page_1']->default_display instanceof \Drupal\views\Plugin\views\display\DefaultDisplay); + + $display = $view->newDisplay('page'); + $this->assertTrue($display instanceof \Drupal\views\Plugin\views\display\Page); + $this->assertTrue($view->executable->displayHandlers['page_2'] instanceof \Drupal\views\Plugin\views\display\Page); + $this->assertTrue($view->executable->displayHandlers['page_2']->default_display instanceof \Drupal\views\Plugin\views\display\DefaultDisplay); + + $display = $view->newDisplay('feed'); + $this->assertTrue($display instanceof \Drupal\views\Plugin\views\display\Feed); + $this->assertTrue($view->executable->displayHandlers['feed_1'] instanceof \Drupal\views\Plugin\views\display\Feed); + $this->assertTrue($view->executable->displayHandlers['feed_1']->default_display instanceof \Drupal\views\Plugin\views\display\DefaultDisplay); + + // Tests item related methods(). + $view = $this->controller->create(array('base_table' => 'views_test_data')); + $executable = new ViewExecutable($view); + $view->addDisplay('default'); + + $display_id = 'default'; + $expected_items = array(); + // Tests addItem with getItem. + // Therefore add one item without any optioins and one item with some + // options. + $id1 = $view->addItem($display_id, 'field', 'views_test_data', 'id'); + $item1 = $view->getItem($display_id, 'field', 'id'); + $expected_items[$id1] = $expected_item = array( + 'id' => 'id', + 'table' => 'views_test_data', + 'field' => 'id' + ); + $this->assertEqual($item1, $expected_item); + + $options = array( + 'alter' => array( + 'text' => $this->randomName() + ) + ); + $id2 = $view->addItem($display_id, 'field', 'views_test_data', 'name', $options); + $item2 = $view->getItem($display_id, 'field', 'name'); + $expected_items[$id2] = $expected_item = array( + 'id' => 'name', + 'table' => 'views_test_data', + 'field' => 'name' + ) + $options; + $this->assertEqual($item2, $expected_item); + + // Tests the expected fields from the previous additions. + $this->assertEqual($view->getItems('field', $display_id), $expected_items); + + // Alter an existing item via setItem and check the result via getItem + // and getItems. + $item = array( + 'alter' => array( + 'text' => $this->randomName(), + ) + ) + $item1; + $expected_items[$id1] = $item; + $view->setItem($display_id, 'field', $id1, $item); + $this->assertEqual($view->getItem($display_id, 'field', 'id'), $item); + $this->assertEqual($view->getItems('field', $display_id), $expected_items); + } + } diff --git a/lib/Drupal/views/Tests/ViewTest.php b/lib/Drupal/views/Tests/ViewTest.php index 50801040674ba6e8fcd8d85b24755ae37e589d7f..ed27f4d9b3e422bf6c3ddef5bf7605cb728d20ef 100644 --- a/lib/Drupal/views/Tests/ViewTest.php +++ b/lib/Drupal/views/Tests/ViewTest.php @@ -50,8 +50,8 @@ function testDestroy() { } function assertViewDestroy($view) { - $this->assertFalse(isset($view->display['default']->handler), 'Make sure all displays are destroyed.'); - $this->assertFalse(isset($view->display['attachment_1']->handler), 'Make sure all displays are destroyed.'); + $this->assertFalse(isset($view->displayHandlers['default']), 'Make sure all displays are destroyed.'); + $this->assertFalse(isset($view->displayHandlers['attachment_1']), 'Make sure all displays are destroyed.'); $this->assertFalse(isset($view->filter), 'Make sure all handlers are destroyed'); $this->assertFalse(isset($view->field), 'Make sure all handlers are destroyed'); diff --git a/lib/Drupal/views/ViewDisplay.php b/lib/Drupal/views/ViewDisplay.php deleted file mode 100644 index bb38678bf171b21814684c8c2f6d43297c03aaa0..0000000000000000000000000000000000000000 --- a/lib/Drupal/views/ViewDisplay.php +++ /dev/null @@ -1,99 +0,0 @@ -<?php - -/** - * @file - * Definition of Drupal\views\ViewDisplay. - */ - -namespace Drupal\views; - -/** - * Defines a display type in a view. - * - * This is just the database storage mechanism, and isn't terribly important - * to the behavior of the display at all. - */ -class ViewDisplay { - - /** - * The display plugin ID. - * - * @var string - */ - public $display_plugin; - - /** - * The display handler itself, which has all the methods. - * - * @var Drupal\views\Plugin\views\display\DisplayPluginBase - */ - public $handler; - - /** - * The machine name of this display. - * - * @var string - */ - public $id; - - /** - * Stores all options of the display, like fields, filters etc. - * - * @var array - */ - public $display_options; - - /** - * The human-readable name of this display. - * - * @var string - */ - public $display_title; - - /** - * The position (weight) of the display. - * - * @var int - */ - public $position; - - /** - * Constructs a ViewDisplay object. - * - * @param array $values - * An array of display options to set, with the following keys: - * - display_options: (optional) An array of display configuration values. - * Defaults to an empty array. - * - display_plugin: (optional) The display plugin ID, if any. Defaults to - * NULL. - * - id: (optional) The ID of this ViewDisplay object. Defaults to NULL. - * - display_title: (optional) The human-readable label for the display. - * Defaults to an empty string. - * - position: (optional) The weight of the display. Defaults to NULL. - * - * @todo Determine behavior when values are empty and if these are actually - * optional. Does it make sense to construct a display without an ID or - * plugin? - * @todo Rename position to weight. - * @todo Rename display_plugin to plugin_id. - * @todo Do we actually want to pass these in as an array, or do we want - * explicit parameters or protected properties? (ID, type, array()) is the - * pattern core uses. - */ - public function __construct(array $values = array()) { - $values += array( - 'display_options' => array(), - 'display_plugin' => NULL, - 'id' => NULL, - 'display_title' => '', - 'position' => NULL, - ); - - $this->display_options = $values['display_options']; - $this->display_plugin = $values['display_plugin']; - $this->id = $values['id']; - $this->display_title = $values['display_title']; - $this->position = $values['position']; - } - -} diff --git a/lib/Drupal/views/ViewExecutable.php b/lib/Drupal/views/ViewExecutable.php index ef599dcd797baffc7744d2c5beaded53bb1f5d13..9914aecc314b77d771162381ec718424701eefc3 100644 --- a/lib/Drupal/views/ViewExecutable.php +++ b/lib/Drupal/views/ViewExecutable.php @@ -208,6 +208,16 @@ class ViewExecutable { */ public $display_handler; + /** + * The list of used displays of the view. + * + * An array containing Drupal\views\Plugin\views\display\DisplayPluginBase + * objects. + * + * @var array + */ + public $displayHandlers; + /** * The current used style plugin. * @@ -717,32 +727,22 @@ public function initDisplay($reset = FALSE) { // Instantiate all displays foreach (array_keys($this->display) as $id) { - // Correct for shallow cloning - // Often we'll have a cloned view so we don't mess up each other's - // displays, but the clone is pretty shallow and doesn't necessarily - // clone the displays. We can tell this by looking to see if a handler - // has already been set; if it has, but $this->current_display is not - // set, then something is dreadfully wrong. - if (!empty($this->display[$id]->handler)) { - $this->display[$id] = clone $this->display[$id]; - unset($this->display[$id]->handler); - } - $this->display[$id]->handler = views_get_plugin('display', $this->display[$id]->display_plugin); - if (!empty($this->display[$id]->handler)) { + $this->displayHandlers[$id] = views_get_plugin('display', $this->storage->display[$id]['display_plugin']); + if (!empty($this->displayHandlers[$id])) { // Initialize the new display handler with data. - $this->display[$id]->handler->init($this, $this->display[$id]); + $this->displayHandlers[$id]->init($this, $this->storage->display[$id]); // If this is NOT the default display handler, let it know which is // since it may well utilize some data from the default. // This assumes that the 'default' handler is always first. It always // is. Make sure of it. if ($id != 'default') { - $this->display[$id]->handler->default_display = &$this->display['default']->handler; + $this->displayHandlers[$id]->default_display =& $this->displayHandlers['default']; } } } $this->current_display = 'default'; - $this->display_handler = $this->storage->display['default']->handler; + $this->display_handler = $this->displayHandlers['default']; return TRUE; } @@ -750,8 +750,11 @@ public function initDisplay($reset = FALSE) { /** * Get the first display that is accessible to the user. * - * @param $displays + * @param array|string $displays * Either a single display id or an array of display ids. + * + * @return string + * The first accessible display id, at least default. */ public function chooseDisplay($displays) { if (!is_array($displays)) { @@ -761,7 +764,7 @@ public function chooseDisplay($displays) { $this->initDisplay(); foreach ($displays as $display_id) { - if ($this->display[$display_id]->handler->access()) { + if ($this->displayHandlers[$display_id]->access()) { return $display_id; } } @@ -807,12 +810,12 @@ public function setDisplay($display_id = NULL) { $this->current_display = $display_id; // Ensure requested display has a working handler. - if (empty($this->display[$display_id]->handler)) { + if (empty($this->displayHandlers[$display_id])) { return FALSE; } // Set a shortcut - $this->display_handler = $this->storage->display[$display_id]->handler; + $this->display_handler = $this->displayHandlers[$display_id]; return TRUE; } @@ -840,7 +843,7 @@ public function initStyle() { } // init the new style handler with data. - $this->style_plugin->init($this, $this->display[$this->current_display], $this->style_options); + $this->style_plugin->init($this, $this->display_handler, $this->style_options); return TRUE; } @@ -1315,7 +1318,7 @@ public function execute($display_id = NULL) { } // Don't allow to use deactivated displays, but display them on the live preview. - if (!$this->display[$this->current_display]->handler->getOption('enabled') && empty($this->live_preview)) { + if (!$this->display_handler->getOption('enabled') && empty($this->live_preview)) { $this->build_info['fail'] = TRUE; return FALSE; } @@ -1615,8 +1618,8 @@ public function attachDisplays() { $this->is_attachment = TRUE; // Give other displays an opportunity to attach to the view. foreach ($this->display as $id => $display) { - if (!empty($this->display[$id]->handler)) { - $this->display[$id]->handler->attachTo($this->current_display); + if (!empty($this->display[$id])) { + $this->displayHandlers[$id]->attachTo($this->current_display); } } $this->is_attachment = FALSE; @@ -1684,8 +1687,8 @@ public function access($displays = NULL, $account = NULL) { // calls this one. $displays = (array)$displays; foreach ($displays as $display_id) { - if (!empty($this->display[$display_id]->handler)) { - if ($this->display[$display_id]->handler->access($account)) { + if (!empty($this->displayHandlers[$display_id])) { + if ($this->displayHandlers[$display_id]->access($account)) { return TRUE; } } @@ -1972,7 +1975,7 @@ public function createDuplicate() { public function cloneView() { $clone = clone $this->storage; - $keys = array('current_display', 'display_handler', 'build_info', 'built', 'executed', 'attachment_before', 'attachment_after', 'field', 'argument', 'filter', 'sort', 'relationship', 'header', 'footer', 'empty', 'query', 'inited', 'style_plugin', 'plugin_name', 'exposed_data', 'exposed_input', 'exposed_widgets', 'many_to_one_tables', 'feed_icon'); + $keys = array('current_display', 'display_handler', 'displayHandlers', 'build_info', 'built', 'executed', 'attachment_before', 'attachment_after', 'field', 'argument', 'filter', 'sort', 'relationship', 'header', 'footer', 'empty', 'query', 'inited', 'style_plugin', 'plugin_name', 'exposed_data', 'exposed_input', 'exposed_widgets', 'many_to_one_tables', 'feed_icon'); foreach ($keys as $key) { unset($clone->$key); } @@ -1983,17 +1986,6 @@ public function cloneView() { $clone->attachment_after = ''; $clone->result = array(); - // Shallow cloning means that all the display objects *were not cloned*, so - // we must clone them ourselves. - $displays = array(); - foreach ($clone->display as $id => $display) { - $displays[$id] = clone $display; - if (isset($displays[$id]->handler)) { - unset($displays[$id]->handler); - } - } - $clone->display = $displays; - return $clone; } @@ -2002,10 +1994,10 @@ public function cloneView() { * collected. */ public function destroy() { - foreach (array_keys($this->display) as $display_id) { - if (isset($this->display[$display_id]->handler)) { - $this->display[$display_id]->handler->destroy(); - unset($this->display[$display_id]->handler); + foreach (array_keys($this->displayHandlers) as $display_id) { + if (isset($this->displayHandlers[$display_id])) { + $this->displayHandlers[$display_id]->destroy(); + unset($this->displayHandlers[$display_id]); } } @@ -2023,7 +2015,7 @@ public function destroy() { $this->style_plugin->destroy(); } - $keys = array('current_display', 'display_handler', 'field', 'argument', 'filter', 'sort', 'relationship', 'header', 'footer', 'empty', 'query', 'result', 'inited', 'style_plugin', 'plugin_name', 'exposed_data', 'exposed_input', 'many_to_one_tables'); + $keys = array('current_display', 'display_handler', 'displayHandlers', 'field', 'argument', 'filter', 'sort', 'relationship', 'header', 'footer', 'empty', 'query', 'result', 'inited', 'style_plugin', 'plugin_name', 'exposed_data', 'exposed_input', 'many_to_one_tables'); foreach ($keys as $key) { unset($this->$key); } @@ -2056,13 +2048,13 @@ public function validate() { $this->display_errors = NULL; $current_display = $this->current_display; - foreach ($this->display as $id => $display) { - if ($display->handler) { + foreach ($this->displayHandlers as $id => $display) { + if (!empty($display)) { if (!empty($display->deleted)) { continue; } - $result = $this->display[$id]->handler->validate(); + $result = $this->displayHandlers[$id]->validate(); if (!empty($result) && is_array($result)) { $errors = array_merge($errors, $result); // Mark this display as having validation errors. diff --git a/lib/Drupal/views/ViewStorage.php b/lib/Drupal/views/ViewStorage.php index 0471d697a77e05f2b2d6aad1ed26a3ed7ef9974f..512174f3a73458995480fe11da11b50a34b2603b 100644 --- a/lib/Drupal/views/ViewStorage.php +++ b/lib/Drupal/views/ViewStorage.php @@ -296,13 +296,12 @@ public function addDisplay($plugin_id = 'page', $title = NULL, $id = NULL) { 'display_plugin' => $plugin_id, 'id' => $id, 'display_title' => $title, + 'position' => NULL, + 'display_options' => array(), ); - // Create the new display object - $display = new ViewDisplay($display_options); - - // Add the new display object to the view. - $this->display[$id] = $display; + // Add the display options to the view. + $this->display[$id] = $display_options; return $id; } @@ -376,23 +375,24 @@ public function &newDisplay($plugin_id = 'page', $title = NULL, $id = NULL) { $id = $this->addDisplay($plugin_id, $title, $id); // Create a handler. - $this->display[$id]->handler = views_get_plugin('display', $this->display[$id]->display_plugin); - if (empty($this->display[$id]->handler)) { + $this->executable->displayHandlers[$id] = views_get_plugin('display', $this->display[$id]['display_plugin']); + if (empty($this->executable->displayHandlers[$id])) { // provide a 'default' handler as an emergency. This won't work well but // it will keep things from crashing. - $this->display[$id]->handler = views_get_plugin('display', 'default'); + $this->executable->displayHandlers[$id] = views_get_plugin('display', 'default'); } - if (!empty($this->display[$id]->handler)) { + if (!empty($this->executable->displayHandlers[$id])) { // Initialize the new display handler with data. - $this->display[$id]->handler->init($this, $this->display[$id]); + $this->executable->displayHandlers[$id]->init($this, $this->display[$id]); // If this is NOT the default display handler, let it know which is if ($id != 'default') { - $this->display[$id]->handler->default_display = &$this->display['default']->handler; + // @todo is the '&' still required in php5? + $this->executable->displayHandlers[$id]->default_display = &$this->executable->displayHandlers['default']; } } - return $this->display[$id]->handler; + return $this->executable->displayHandlers[$id]; } /** @@ -402,12 +402,12 @@ public function &newDisplay($plugin_id = 'page', $title = NULL, $id = NULL) { * An array of display types that this view includes. */ function getDisplaysList() { - $this->initDisplay(); - + $manager = drupal_container()->get('plugin.manager.views.display'); $displays = array(); foreach ($this->display as $display) { - if (!empty($display->handler->definition['admin'])) { - $displays[$display->handler->definition['admin']] = TRUE; + $definition = $manager->getDefinition($display['display_plugin']); + if (!empty($definition['admin'])) { + $displays[$definition['admin']] = TRUE; } } @@ -427,10 +427,9 @@ public function getPaths() { $all_paths[] = t('Edit this view to add a display.'); } else { - $this->initDisplay(); // Make sure all the handlers are set up foreach ($this->display as $display) { - if (!empty($display->handler) && $display->handler->hasPath()) { - $path = $display->handler->getOption('path'); + if (!empty($display['display_options']['path'])) { + $path = $display['display_options']['path']; if ($this->isEnabled() && strpos($path, '%') === FALSE) { $all_paths[] = l('/' . $path, $path); } @@ -470,7 +469,7 @@ public function addItem($display_id, $type, $table, $field, $options = array(), $types = ViewExecutable::viewsHandlerTypes(); $this->setDisplay($display_id); - $fields = $this->display[$display_id]->handler->getOption($types[$type]['plural']); + $fields = $this->executable->displayHandlers[$display_id]->getOption($types[$type]['plural']); if (empty($id)) { $id = $this->generateItemId($field, $fields); @@ -488,7 +487,7 @@ public function addItem($display_id, $type, $table, $field, $options = array(), 'field' => $field, ) + $options; - $this->display[$display_id]->handler->setOption($types[$type]['plural'], $fields); + $this->executable->displayHandlers[$display_id]->setOption($types[$type]['plural'], $fields); return $id; } @@ -514,7 +513,7 @@ public function getItems($type, $display_id = NULL) { // Get info about the types so we can get the right data. $types = ViewExecutable::viewsHandlerTypes(); - return $this->display[$display_id]->handler->getOption($types[$type]['plural']); + return $this->executable->displayHandlers[$display_id]->getOption($types[$type]['plural']); } /** @@ -538,7 +537,7 @@ public function getItem($display_id, $type, $id) { $this->setDisplay($display_id); // Get the existing configuration - $fields = $this->display[$display_id]->handler->getOption($types[$type]['plural']); + $fields = $this->executable->displayHandlers[$display_id]->getOption($types[$type]['plural']); return isset($fields[$id]) ? $fields[$id] : NULL; } @@ -564,7 +563,7 @@ public function setItem($display_id, $type, $id, $item) { $this->setDisplay($display_id); // Get the existing configuration. - $fields = $this->display[$display_id]->handler->getOption($types[$type]['plural']); + $fields = $this->executable->displayHandlers[$display_id]->getOption($types[$type]['plural']); if (isset($item)) { $fields[$id] = $item; } @@ -573,7 +572,7 @@ public function setItem($display_id, $type, $id, $item) { } // Store. - $this->display[$display_id]->handler->setOption($types[$type]['plural'], $fields); + $this->executable->displayHandlers[$display_id]->setOption($types[$type]['plural'], $fields); } /** diff --git a/lib/Drupal/views/ViewStorageController.php b/lib/Drupal/views/ViewStorageController.php index 744157c6ae11789fa2d78fc2718589bdb5c554d2..db8af0f1a277339d381ff14d65ccfbcaaebe38ec 100644 --- a/lib/Drupal/views/ViewStorageController.php +++ b/lib/Drupal/views/ViewStorageController.php @@ -103,11 +103,11 @@ public function save(EntityInterface $entity) { $displays = array(); foreach ($entity->display as $key => $display) { $displays[$key] = array( - 'display_options' => $display->display_options, - 'display_plugin' => $display->display_plugin, - 'id' => $display->id, - 'display_title' => $display->display_title, - 'position' => isset($display->position) ? $display->position : 0, + 'display_options' => $display['display_options'], + 'display_plugin' => $display['display_plugin'], + 'id' => $display['id'], + 'display_title' => $display['display_title'], + 'position' => isset($display['position']) ? $display['position'] : 0, ); } $config->set('display', $displays); @@ -162,7 +162,7 @@ public function create(array $values) { } /** - * Attaches an array of ViewDisplay objects to the view display property. + * Add defaults to the display options. * * @param Drupal\Core\Entity\EntityInterface $entity */ @@ -178,8 +178,8 @@ protected function attachDisplays(EntityInterface $entity) { 'display_title' => '', 'position' => NULL, ); - // Create a ViewDisplay object using the display options. - $displays[$key] = new ViewDisplay($options); + // Add the defaults for the display. + $displays[$key] = $options; } $entity->set('display', $displays); diff --git a/lib/Views/block/Plugin/views/display/Block.php b/lib/Views/block/Plugin/views/display/Block.php index d8ac831d17c0341ba4179243a96fccaeb9a91a74..69f25b67ba128f9acfb86d8f657e633937ccb029 100644 --- a/lib/Views/block/Plugin/views/display/Block.php +++ b/lib/Views/block/Plugin/views/display/Block.php @@ -52,15 +52,15 @@ protected function defineOptions() { * stuff with it. */ public function executeHookBlockList($delta = 0, $edit = array()) { - $delta = $this->view->name . '-' . $this->display->id; + $delta = $this->view->name . '-' . $this->display['id']; $desc = $this->getOption('block_description'); if (empty($desc)) { - if ($this->display->display_title == $this->definition['title']) { + if ($this->display['display_title'] == $this->definition['title']) { $desc = t('View: !view', array('!view' => $this->view->getHumanName())); } else { - $desc = t('View: !view: !display', array('!view' => $this->view->getHumanName(), '!display' => $this->display->display_title)); + $desc = t('View: !view: !display', array('!view' => $this->view->getHumanName(), '!display' => $this->display['display_title'])); } } return array( @@ -193,7 +193,7 @@ public function submitOptionsForm(&$form, &$form_state) { parent::submitOptionsForm($form, $form_state); switch ($form_state['section']) { case 'display_id': - $this->updateBlockBid($form_state['view']->name, $this->display->id, $this->display->new_id); + $this->updateBlockBid($form_state['view']->name, $this->display['id'], $this->display['new_id']); break; case 'block_description': $this->setOption('block_description', $form_state['values']['block_description']); diff --git a/modules/node.views.inc b/modules/node.views.inc index 0489146b8555c05b8e5c0ec071eddb70f5512ca7..ffddcdb27373b0dcdcd3062d3b013d8a13891372 100644 --- a/modules/node.views.inc +++ b/modules/node.views.inc @@ -694,13 +694,10 @@ function node_views_analyze($view) { $ret = array(); // Check for something other than the default display: if ($view->base_table == 'node') { - foreach ($view->display as $id => $display) { - if (empty($display->handler)) { - continue; - } - if (!$display->handler->isDefaulted('access') || !$display->handler->isDefaulted('filters')) { + foreach ($view->displayHandlers as $id => $display) { + if (!$display->isDefaulted('access') || !$display->isDefaulted('filters')) { // check for no access control - $access = $display->handler->getOption('access'); + $access = $display->getOption('access'); if (empty($access['type']) || $access['type'] == 'none') { $select = db_select('role', 'r'); $select->innerJoin('role_permission', 'p', 'r.rid = p.rid'); @@ -715,23 +712,23 @@ function node_views_analyze($view) { $roles[$role->rid] = $role; } if (!($roles['anonymous']->safe && $roles['authenticated']->safe)) { - $ret[] = Analyzer::formatMessage(t('Some roles lack permission to access content, but display %display has no access control.', array('%display' => $display->display_title)), 'warning'); + $ret[] = Analyzer::formatMessage(t('Some roles lack permission to access content, but display %display has no access control.', array('%display' => $display['display_title'])), 'warning'); } - $filters = $display->handler->getOption('filters'); + $filters = $display->getOption('filters'); foreach ($filters as $filter) { if ($filter['table'] == 'node' && ($filter['field'] == 'status' || $filter['field'] == 'status_extra')) { continue 2; } } - $ret[] = Analyzer::formatMessage(t('Display %display has no access control but does not contain a filter for published nodes.', array('%display' => $display->display_title)), 'warning'); + $ret[] = Analyzer::formatMessage(t('Display %display has no access control but does not contain a filter for published nodes.', array('%display' => $display['display_title'])), 'warning'); } } } } foreach ($view->display as $id => $display) { - if ($display->display_plugin == 'page') { - if ($display->handler->getOption('path') == 'node/%') { - $ret[] = Analyzer::formatMessage(t('Display %display has set node/% as path. This will not produce what you want. If you want to have multiple versions of the node view, use panels.', array('%display' => $display->display_title)), 'warning'); + if ($display->getPluginId() == 'page') { + if ($display->getOption('path') == 'node/%') { + $ret[] = Analyzer::formatMessage(t('Display %display has set node/% as path. This will not produce what you want. If you want to have multiple versions of the node view, use panels.', array('%display' => $display['display_title'])), 'warning'); } } } diff --git a/modules/node.views_template.inc b/modules/node.views_template.inc index fe1b2b925664c444324cdb20acdab56c704efeed..db4eebf08b8646b91d4d3cfb5cffddf409999b36 100644 --- a/modules/node.views_template.inc +++ b/modules/node.views_template.inc @@ -22,95 +22,95 @@ function node_views_templates() { /* Display: Defaults */ $handler = $view->newDisplay('default', 'Defaults', 'default'); - $handler->display->display_options['title'] = 'Image gallery'; - $handler->display->display_options['access']['type'] = 'perm'; - $handler->display->display_options['cache']['type'] = 'none'; - $handler->display->display_options['query']['type'] = 'views_query'; - $handler->display->display_options['exposed_form']['type'] = 'basic'; - $handler->display->display_options['pager']['type'] = 'full'; - $handler->display->display_options['pager']['options']['items_per_page'] = '24'; - $handler->display->display_options['pager']['options']['offset'] = '0'; - $handler->display->display_options['pager']['options']['id'] = '0'; - $handler->display->display_options['pager']['options']['expose']['items_per_page_options_all'] = 0; - $handler->display->display_options['style_plugin'] = 'grid'; - $handler->display->display_options['style_options']['fill_single_line'] = 1; - $handler->display->display_options['row_plugin'] = 'fields'; + $handler->display['display_options']['title'] = 'Image gallery'; + $handler->display['display_options']['access']['type'] = 'perm'; + $handler->display['display_options']['cache']['type'] = 'none'; + $handler->display['display_options']['query']['type'] = 'views_query'; + $handler->display['display_options']['exposed_form']['type'] = 'basic'; + $handler->display['display_options']['pager']['type'] = 'full'; + $handler->display['display_options']['pager']['options']['items_per_page'] = '24'; + $handler->display['display_options']['pager']['options']['offset'] = '0'; + $handler->display['display_options']['pager']['options']['id'] = '0'; + $handler->display['display_options']['pager']['options']['expose']['items_per_page_options_all'] = 0; + $handler->display['display_options']['style_plugin'] = 'grid'; + $handler->display['display_options']['style_options']['fill_single_line'] = 1; + $handler->display['display_options']['row_plugin'] = 'fields'; /* Field: Content: Image */ - $handler->display->display_options['fields']['field_image']['id'] = 'field_image'; - $handler->display->display_options['fields']['field_image']['table'] = 'field_data_field_image'; - $handler->display->display_options['fields']['field_image']['field'] = 'field_image'; - $handler->display->display_options['fields']['field_image']['label'] = ''; - $handler->display->display_options['fields']['field_image']['alter']['alter_text'] = 0; - $handler->display->display_options['fields']['field_image']['alter']['make_link'] = 0; - $handler->display->display_options['fields']['field_image']['alter']['absolute'] = 0; - $handler->display->display_options['fields']['field_image']['alter']['external'] = 0; - $handler->display->display_options['fields']['field_image']['alter']['trim'] = 0; - $handler->display->display_options['fields']['field_image']['alter']['nl2br'] = 0; - $handler->display->display_options['fields']['field_image']['alter']['word_boundary'] = 1; - $handler->display->display_options['fields']['field_image']['alter']['ellipsis'] = 1; - $handler->display->display_options['fields']['field_image']['alter']['strip_tags'] = 0; - $handler->display->display_options['fields']['field_image']['alter']['html'] = 0; - $handler->display->display_options['fields']['field_image']['element_label_colon'] = 1; - $handler->display->display_options['fields']['field_image']['element_default_classes'] = 1; - $handler->display->display_options['fields']['field_image']['hide_empty'] = 0; - $handler->display->display_options['fields']['field_image']['empty_zero'] = 0; - $handler->display->display_options['fields']['field_image']['click_sort_column'] = 'fid'; - $handler->display->display_options['fields']['field_image']['settings'] = array( + $handler->display['display_options']['fields']['field_image']['id'] = 'field_image'; + $handler->display['display_options']['fields']['field_image']['table'] = 'field_data_field_image'; + $handler->display['display_options']['fields']['field_image']['field'] = 'field_image'; + $handler->display['display_options']['fields']['field_image']['label'] = ''; + $handler->display['display_options']['fields']['field_image']['alter']['alter_text'] = 0; + $handler->display['display_options']['fields']['field_image']['alter']['make_link'] = 0; + $handler->display['display_options']['fields']['field_image']['alter']['absolute'] = 0; + $handler->display['display_options']['fields']['field_image']['alter']['external'] = 0; + $handler->display['display_options']['fields']['field_image']['alter']['trim'] = 0; + $handler->display['display_options']['fields']['field_image']['alter']['nl2br'] = 0; + $handler->display['display_options']['fields']['field_image']['alter']['word_boundary'] = 1; + $handler->display['display_options']['fields']['field_image']['alter']['ellipsis'] = 1; + $handler->display['display_options']['fields']['field_image']['alter']['strip_tags'] = 0; + $handler->display['display_options']['fields']['field_image']['alter']['html'] = 0; + $handler->display['display_options']['fields']['field_image']['element_label_colon'] = 1; + $handler->display['display_options']['fields']['field_image']['element_default_classes'] = 1; + $handler->display['display_options']['fields']['field_image']['hide_empty'] = 0; + $handler->display['display_options']['fields']['field_image']['empty_zero'] = 0; + $handler->display['display_options']['fields']['field_image']['click_sort_column'] = 'fid'; + $handler->display['display_options']['fields']['field_image']['settings'] = array( 'image_style' => 'thumbnail', 'image_link' => 'content', ); - $handler->display->display_options['fields']['field_image']['field_api_classes'] = 0; + $handler->display['display_options']['fields']['field_image']['field_api_classes'] = 0; /* Field: User: Name */ - $handler->display->display_options['fields']['name']['id'] = 'name'; - $handler->display->display_options['fields']['name']['table'] = 'users'; - $handler->display->display_options['fields']['name']['field'] = 'name'; - $handler->display->display_options['fields']['name']['label'] = 'Author'; - $handler->display->display_options['fields']['name']['alter']['alter_text'] = 0; - $handler->display->display_options['fields']['name']['alter']['make_link'] = 0; - $handler->display->display_options['fields']['name']['alter']['absolute'] = 0; - $handler->display->display_options['fields']['name']['alter']['external'] = 0; - $handler->display->display_options['fields']['name']['alter']['trim'] = 0; - $handler->display->display_options['fields']['name']['alter']['nl2br'] = 0; - $handler->display->display_options['fields']['name']['alter']['word_boundary'] = 1; - $handler->display->display_options['fields']['name']['alter']['ellipsis'] = 1; - $handler->display->display_options['fields']['name']['alter']['strip_tags'] = 0; - $handler->display->display_options['fields']['name']['alter']['html'] = 0; - $handler->display->display_options['fields']['name']['element_label_colon'] = 1; - $handler->display->display_options['fields']['name']['element_default_classes'] = 1; - $handler->display->display_options['fields']['name']['hide_empty'] = 0; - $handler->display->display_options['fields']['name']['empty_zero'] = 0; - $handler->display->display_options['fields']['name']['link_to_user'] = 1; - $handler->display->display_options['fields']['name']['overwrite_anonymous'] = 0; + $handler->display['display_options']['fields']['name']['id'] = 'name'; + $handler->display['display_options']['fields']['name']['table'] = 'users'; + $handler->display['display_options']['fields']['name']['field'] = 'name'; + $handler->display['display_options']['fields']['name']['label'] = 'Author'; + $handler->display['display_options']['fields']['name']['alter']['alter_text'] = 0; + $handler->display['display_options']['fields']['name']['alter']['make_link'] = 0; + $handler->display['display_options']['fields']['name']['alter']['absolute'] = 0; + $handler->display['display_options']['fields']['name']['alter']['external'] = 0; + $handler->display['display_options']['fields']['name']['alter']['trim'] = 0; + $handler->display['display_options']['fields']['name']['alter']['nl2br'] = 0; + $handler->display['display_options']['fields']['name']['alter']['word_boundary'] = 1; + $handler->display['display_options']['fields']['name']['alter']['ellipsis'] = 1; + $handler->display['display_options']['fields']['name']['alter']['strip_tags'] = 0; + $handler->display['display_options']['fields']['name']['alter']['html'] = 0; + $handler->display['display_options']['fields']['name']['element_label_colon'] = 1; + $handler->display['display_options']['fields']['name']['element_default_classes'] = 1; + $handler->display['display_options']['fields']['name']['hide_empty'] = 0; + $handler->display['display_options']['fields']['name']['empty_zero'] = 0; + $handler->display['display_options']['fields']['name']['link_to_user'] = 1; + $handler->display['display_options']['fields']['name']['overwrite_anonymous'] = 0; /* Contextual filter: Content: Has taxonomy term ID */ - $handler->display->display_options['arguments']['tid']['id'] = 'tid'; - $handler->display->display_options['arguments']['tid']['table'] = 'taxonomy_index'; - $handler->display->display_options['arguments']['tid']['field'] = 'tid'; - $handler->display->display_options['arguments']['tid']['default_action'] = 'summary'; - $handler->display->display_options['arguments']['tid']['default_argument_type'] = 'fixed'; - $handler->display->display_options['arguments']['tid']['default_argument_skip_url'] = 0; - $handler->display->display_options['arguments']['tid']['summary']['number_of_records'] = '1'; - $handler->display->display_options['arguments']['tid']['summary']['format'] = 'unformatted_summary'; - $handler->display->display_options['arguments']['tid']['summary_options']['items_per_page'] = '25'; - $handler->display->display_options['arguments']['tid']['summary_options']['inline'] = 0; - $handler->display->display_options['arguments']['tid']['break_phrase'] = 0; - $handler->display->display_options['arguments']['tid']['add_table'] = 0; - $handler->display->display_options['arguments']['tid']['require_value'] = 0; - $handler->display->display_options['arguments']['tid']['reduce_duplicates'] = 0; - $handler->display->display_options['arguments']['tid']['set_breadcrumb'] = 0; + $handler->display['display_options']['arguments']['tid']['id'] = 'tid'; + $handler->display['display_options']['arguments']['tid']['table'] = 'taxonomy_index'; + $handler->display['display_options']['arguments']['tid']['field'] = 'tid'; + $handler->display['display_options']['arguments']['tid']['default_action'] = 'summary'; + $handler->display['display_options']['arguments']['tid']['default_argument_type'] = 'fixed'; + $handler->display['display_options']['arguments']['tid']['default_argument_skip_url'] = 0; + $handler->display['display_options']['arguments']['tid']['summary']['number_of_records'] = '1'; + $handler->display['display_options']['arguments']['tid']['summary']['format'] = 'unformatted_summary'; + $handler->display['display_options']['arguments']['tid']['summary_options']['items_per_page'] = '25'; + $handler->display['display_options']['arguments']['tid']['summary_options']['inline'] = 0; + $handler->display['display_options']['arguments']['tid']['break_phrase'] = 0; + $handler->display['display_options']['arguments']['tid']['add_table'] = 0; + $handler->display['display_options']['arguments']['tid']['require_value'] = 0; + $handler->display['display_options']['arguments']['tid']['reduce_duplicates'] = 0; + $handler->display['display_options']['arguments']['tid']['set_breadcrumb'] = 0; /* Filter criterion: Content: Image (field_image) - fid */ - $handler->display->display_options['filters']['field_image_fid']['id'] = 'field_image_fid'; - $handler->display->display_options['filters']['field_image_fid']['table'] = 'field_data_field_image'; - $handler->display->display_options['filters']['field_image_fid']['field'] = 'field_image_fid'; - $handler->display->display_options['filters']['field_image_fid']['operator'] = 'not empty'; + $handler->display['display_options']['filters']['field_image_fid']['id'] = 'field_image_fid'; + $handler->display['display_options']['filters']['field_image_fid']['table'] = 'field_data_field_image'; + $handler->display['display_options']['filters']['field_image_fid']['field'] = 'field_image_fid'; + $handler->display['display_options']['filters']['field_image_fid']['operator'] = 'not empty'; /* Filter criterion: Content: Published */ - $handler->display->display_options['filters']['status']['id'] = 'status'; - $handler->display->display_options['filters']['status']['table'] = 'node'; - $handler->display->display_options['filters']['status']['field'] = 'status'; - $handler->display->display_options['filters']['status']['value'] = '1'; + $handler->display['display_options']['filters']['status']['id'] = 'status'; + $handler->display['display_options']['filters']['status']['table'] = 'node'; + $handler->display['display_options']['filters']['status']['field'] = 'status'; + $handler->display['display_options']['filters']['status']['value'] = '1'; /* Display: Gallery page */ $handler = $view->newDisplay('page', 'Gallery page', 'page_1'); - $handler->display->display_options['path'] = 'gallery'; + $handler->display['display_options']['path'] = 'gallery'; $translatables['image_gallery'] = array( t('Defaults'), t('Image gallery'), diff --git a/tests/views_test_config/config/views.view.test_executable_displays.yml b/tests/views_test_config/config/views.view.test_executable_displays.yml new file mode 100644 index 0000000000000000000000000000000000000000..8feb580c84fd1d40497865ad7dca8eced52d3975 --- /dev/null +++ b/tests/views_test_config/config/views.view.test_executable_displays.yml @@ -0,0 +1,24 @@ +api_version: '3.0' +base_table: views_test_data +core: '8' +description: '' +disabled: '0' +display: + default: + display_plugin: default + display_title: Master + id: default + position: '0' + page: + display_plugin: page + display_title: Page + id: page + position: '1' + page_2: + display_plugin: page + display_title: Page 2 + id: page_2 + position: '2' +human_name: '' +name: test_executable_displays +tag: '' diff --git a/theme/theme.inc b/theme/theme.inc index 8e5f80f48457c84994c822f6fe642e68c7b956cf..0a42b9ea75e048469aec3c426958994f24ab57e1 100644 --- a/theme/theme.inc +++ b/theme/theme.inc @@ -21,16 +21,16 @@ function _views_theme_functions($hook, $view, $display = NULL) { $themes = array(); if ($display) { - $themes[] = $hook . '__' . $view->name . '__' . $display->id; - $themes[] = $hook . '__' . $display->id; + $themes[] = $hook . '__' . $view->name . '__' . $display['id']; + $themes[] = $hook . '__' . $display['id']; // Add theme suggestions for each single tag. foreach (drupal_explode_tags($view->tag) as $tag) { $themes[] = $hook . '__' . preg_replace('/[^a-z0-9]/', '_', strtolower($tag)); } - if ($display->id != $display->display_plugin) { - $themes[] = $hook . '__' . $view->name . '__' . $display->display_plugin; - $themes[] = $hook . '__' . $display->display_plugin; + if ($display['id'] != $display['display_plugin']) { + $themes[] = $hook . '__' . $view->name . '__' . $display['display_plugin']; + $themes[] = $hook . '__' . $display['display_plugin']; } } $themes[] = $hook . '__' . $view->name; @@ -129,7 +129,7 @@ function template_preprocess_views_view(&$vars) { 'view_args' => check_plain(implode('/', $view->args)), 'view_path' => check_plain(current_path()), // Pass through URL to ensure we get e.g. language prefixes. -// 'view_base_path' => isset($view->display['page']) ? substr(url($view->display['page']->display_options['path']), strlen($base_path)) : '', +// 'view_base_path' => isset($view->display['page']) ? substr(url($view->display['page']['display_options']['path']), strlen($base_path)) : '', 'view_base_path' => $view->getPath(), 'view_dom_id' => $vars['dom_id'], // To fit multiple views on a page, the programmer may have @@ -867,7 +867,7 @@ function template_preprocess_views_view_rss(&$vars) { // one, use the global $base_url $link_display_id = $view->display_handler->getLinkDisplay(); if ($link_display_id && !empty($view->display[$link_display_id])) { - $path = $view->display[$link_display_id]->handler->getPath(); + $path = $view->displayHandlers[$link_display_id]->getPath(); } if ($path) { diff --git a/views.api.php b/views.api.php index a980bc1f3a19acc59c7a05efb7c10ab666c5b7f5..29666a4821f89833e02889ce22634907ce9a178b 100644 --- a/views.api.php +++ b/views.api.php @@ -678,56 +678,56 @@ function hook_views_default_views() { /* Display: Master */ $handler = $view->newDisplay('default', 'Master', 'default'); - $handler->display->display_options['access']['type'] = 'none'; - $handler->display->display_options['cache']['type'] = 'none'; - $handler->display->display_options['query']['type'] = 'views_query'; - $handler->display->display_options['query']['options']['query_comment'] = FALSE; - $handler->display->display_options['exposed_form']['type'] = 'basic'; - $handler->display->display_options['pager']['type'] = 'full'; - $handler->display->display_options['style_plugin'] = 'default'; - $handler->display->display_options['row_plugin'] = 'node'; + $handler->display['display_options']['access']['type'] = 'none'; + $handler->display['display_options']['cache']['type'] = 'none'; + $handler->display['display_options']['query']['type'] = 'views_query'; + $handler->display['display_options']['query']['options']['query_comment'] = FALSE; + $handler->display['display_options']['exposed_form']['type'] = 'basic'; + $handler->display['display_options']['pager']['type'] = 'full'; + $handler->display['display_options']['style_plugin'] = 'default'; + $handler->display['display_options']['row_plugin'] = 'node'; /* Sort criterion: Content: Sticky */ - $handler->display->display_options['sorts']['sticky']['id'] = 'sticky'; - $handler->display->display_options['sorts']['sticky']['table'] = 'node'; - $handler->display->display_options['sorts']['sticky']['field'] = 'sticky'; - $handler->display->display_options['sorts']['sticky']['order'] = 'DESC'; + $handler->display['display_options']['sorts']['sticky']['id'] = 'sticky'; + $handler->display['display_options']['sorts']['sticky']['table'] = 'node'; + $handler->display['display_options']['sorts']['sticky']['field'] = 'sticky'; + $handler->display['display_options']['sorts']['sticky']['order'] = 'DESC'; /* Sort criterion: Content: Post date */ - $handler->display->display_options['sorts']['created']['id'] = 'created'; - $handler->display->display_options['sorts']['created']['table'] = 'node'; - $handler->display->display_options['sorts']['created']['field'] = 'created'; - $handler->display->display_options['sorts']['created']['order'] = 'DESC'; + $handler->display['display_options']['sorts']['created']['id'] = 'created'; + $handler->display['display_options']['sorts']['created']['table'] = 'node'; + $handler->display['display_options']['sorts']['created']['field'] = 'created'; + $handler->display['display_options']['sorts']['created']['order'] = 'DESC'; /* Filter criterion: Content: Promoted to front page */ - $handler->display->display_options['filters']['promote']['id'] = 'promote'; - $handler->display->display_options['filters']['promote']['table'] = 'node'; - $handler->display->display_options['filters']['promote']['field'] = 'promote'; - $handler->display->display_options['filters']['promote']['value'] = '1'; - $handler->display->display_options['filters']['promote']['group'] = 0; - $handler->display->display_options['filters']['promote']['expose']['operator'] = FALSE; + $handler->display['display_options']['filters']['promote']['id'] = 'promote'; + $handler->display['display_options']['filters']['promote']['table'] = 'node'; + $handler->display['display_options']['filters']['promote']['field'] = 'promote'; + $handler->display['display_options']['filters']['promote']['value'] = '1'; + $handler->display['display_options']['filters']['promote']['group'] = 0; + $handler->display['display_options']['filters']['promote']['expose']['operator'] = FALSE; /* Filter criterion: Content: Published */ - $handler->display->display_options['filters']['status']['id'] = 'status'; - $handler->display->display_options['filters']['status']['table'] = 'node'; - $handler->display->display_options['filters']['status']['field'] = 'status'; - $handler->display->display_options['filters']['status']['value'] = '1'; - $handler->display->display_options['filters']['status']['group'] = 0; - $handler->display->display_options['filters']['status']['expose']['operator'] = FALSE; + $handler->display['display_options']['filters']['status']['id'] = 'status'; + $handler->display['display_options']['filters']['status']['table'] = 'node'; + $handler->display['display_options']['filters']['status']['field'] = 'status'; + $handler->display['display_options']['filters']['status']['value'] = '1'; + $handler->display['display_options']['filters']['status']['group'] = 0; + $handler->display['display_options']['filters']['status']['expose']['operator'] = FALSE; /* Display: Page */ $handler = $view->newDisplay('page', 'Page', 'page'); - $handler->display->display_options['path'] = 'frontpage'; + $handler->display['display_options']['path'] = 'frontpage'; /* Display: Feed */ $handler = $view->newDisplay('feed', 'Feed', 'feed'); - $handler->display->display_options['defaults']['title'] = FALSE; - $handler->display->display_options['title'] = 'Front page feed'; - $handler->display->display_options['pager']['type'] = 'some'; - $handler->display->display_options['style_plugin'] = 'rss'; - $handler->display->display_options['row_plugin'] = 'node_rss'; - $handler->display->display_options['path'] = 'rss.xml'; - $handler->display->display_options['displays'] = array( + $handler->display['display_options']['defaults']['title'] = FALSE; + $handler->display['display_options']['title'] = 'Front page feed'; + $handler->display['display_options']['pager']['type'] = 'some'; + $handler->display['display_options']['style_plugin'] = 'rss'; + $handler->display['display_options']['row_plugin'] = 'node_rss'; + $handler->display['display_options']['path'] = 'rss.xml'; + $handler->display['display_options']['displays'] = array( 'default' => 'default', 'page' => 'page', ); - $handler->display->display_options['sitename_title'] = '1'; + $handler->display['display_options']['sitename_title'] = '1'; // (Export ends here.) @@ -750,16 +750,16 @@ function hook_views_default_views() { * @code * $handler =& $view->display['DISPLAY_ID']->handler; * // Add the user name field to the view. - * $handler->display->display_options['fields']['name']['id'] = 'name'; - * $handler->display->display_options['fields']['name']['table'] = 'users'; - * $handler->display->display_options['fields']['name']['field'] = 'name'; - * $handler->display->display_options['fields']['name']['label'] = 'Author'; - * $handler->display->display_options['fields']['name']['link_to_user'] = 1; + * $handler->display['display_options']['fields']['name']['id'] = 'name'; + * $handler->display['display_options']['fields']['name']['table'] = 'users'; + * $handler->display['display_options']['fields']['name']['field'] = 'name'; + * $handler->display['display_options']['fields']['name']['label'] = 'Author'; + * $handler->display['display_options']['fields']['name']['link_to_user'] = 1; * @endcode */ function hook_views_default_views_alter(&$views) { if (isset($views['taxonomy_term'])) { - $views['taxonomy_term']->display['default']->display_options['title'] = 'Categories'; + $views['taxonomy_term']->display['default']['display_options']['title'] = 'Categories'; } } diff --git a/views.module b/views.module index 5e190e774159aa3c2bd18518bdd6591504d38a9a..7cd7ae65a94c1ee935591e4f327b06045194d929 100644 --- a/views.module +++ b/views.module @@ -347,14 +347,14 @@ function views_plugin_list() { foreach (views_get_enabled_views() as $view) { foreach ($view->display as $display_id => $display) { foreach ($plugin_data as $type => $info) { - if ($type == 'display' && isset($display->display_plugin)) { - $name = $display->display_plugin; + if ($type == 'display' && isset($display['display_plugin'])) { + $name = $display['display_plugin']; } - elseif (isset($display->display_options["{$type}_plugin"])) { - $name = $display->display_options["{$type}_plugin"]; + elseif (isset($display['display_options']["{$type}_plugin"])) { + $name = $display['display_options']["{$type}_plugin"]; } - elseif (isset($display->display_options[$type]['type'])) { - $name = $display->display_options[$type]['type']; + elseif (isset($display['display_options'][$type]['type'])) { + $name = $display['display_options'][$type]['type']; } else { continue; @@ -699,17 +699,17 @@ function views_block_info() { } $view->initDisplay(); - foreach ($view->display as $display_id => $display) { + foreach ($view->displayHandlers as $display) { - if (isset($display->handler) && !empty($display->handler->definition['uses_hook_block'])) { - $result = $display->handler->executeHookBlockList(); + if (isset($display) && !empty($display->definition['uses_hook_block'])) { + $result = $display->executeHookBlockList(); if (is_array($result)) { $items = array_merge($items, $result); } } - if (isset($display->handler) && $display->handler->getOption('exposed_block')) { - $result = $display->handler->getSpecialBlocks(); + if (isset($display) && $display->getOption('exposed_block')) { + $result = $display->getSpecialBlocks(); if (is_array($result)) { $items = array_merge($items, $result); } @@ -902,7 +902,7 @@ function views_add_contextual_links(&$render_element, $location, $view, $display // Also do not do anything if the display plugin has not defined any // contextual links that are intended to be displayed in the requested // location. - $plugin = views_get_plugin_definition('display', $view->display[$display_id]->display_plugin); + $plugin = views_get_plugin_definition('display', $view->display[$display_id]['display_plugin']); // If contextual_links_locations are not set, provide a sane default. (To // avoid displaying any contextual links at all, a display plugin can still // set 'contextual_links_locations' to, e.g., {""}.) @@ -1556,7 +1556,7 @@ function views_get_applicable_views($type) { // Loop on array keys because something seems to muck with $view->display // a bit in PHP4. foreach (array_keys($view->display) as $id) { - $plugin = views_get_plugin_definition('display', $view->display[$id]->display_plugin); + $plugin = views_get_plugin_definition('display', $view->display[$id]['display_plugin']); if (!empty($plugin[$type])) { // This view uses_hook_menu. Clone it so that different handlers // don't trip over each other, and add it to the list. @@ -1666,10 +1666,10 @@ function views_get_views_as_options($views_only = FALSE, $filter = 'all', $exclu foreach ($view->display as $display_id => $display) { if (!($view->name == $exclude_view_name && $display_id == $exclude_view_display)) { if ($optgroup) { - $options[$view->name][$view->name . ':' . $display->id] = t('@view : @display', array('@view' => $view->name, '@display' => $display->id)); + $options[$view->name][$view->name . ':' . $display['id']] = t('@view : @display', array('@view' => $view->name, '@display' => $display['id'])); } else { - $options[$view->name . ':' . $display->id] = t('View: @view - Display: @display', array('@view' => $view->name, '@display' => $display->id)); + $options[$view->name . ':' . $display['id']] = t('View: @view - Display: @display', array('@view' => $view->name, '@display' => $display['id'])); } } } @@ -2011,7 +2011,7 @@ function views_exposed_form($form, &$form_state) { $form['#action'] = url($view->display_handler->getUrl()); $form['#theme'] = views_theme_functions('views_exposed_form', $view, $display); - $form['#id'] = drupal_clean_css_identifier('views_exposed_form-' . check_plain($view->name) . '-' . check_plain($display->id)); + $form['#id'] = drupal_clean_css_identifier('views_exposed_form-' . check_plain($view->name) . '-' . check_plain($display['id'])); // $form['#attributes']['class'] = array('views-exposed-form'); // If using AJAX, we need the form plugin. diff --git a/views_ui.module b/views_ui.module index dd936d80f2b5cb42c286f36b1d50f7f38be12315..6253090aa5d0b33af8e4c8bc8e28f48fb6fa09ff 100644 --- a/views_ui.module +++ b/views_ui.module @@ -344,8 +344,7 @@ function views_ui_cache_set(&$view) { unset($view->default_display); $view->query = NULL; foreach (array_keys($view->display) as $id) { - unset($view->display[$id]->handler); - unset($view->display[$id]->default_display); + unset($view->displayHandlers[$id]); } views_temp_store()->set($view->name, $view); } @@ -476,13 +475,13 @@ function views_ui_view_preview_section_handler_links($view, $type, $title = FALS $field_name = $handler->adminLabel(TRUE); $links[$type . '-edit-' . $id] = array( 'title' => t('Edit @section', array('@section' => $field_name)), - 'href' => "admin/structure/views/nojs/config-item/$view->name/$display->id/$type/$id", + 'href' => "admin/structure/views/nojs/config-item/$view->name/{$display['id']}/$type/$id", 'attributes' => array('class' => array('views-ajax-link')), ); } $links[$type . '-add'] = array( 'title' => t('Add new'), - 'href' => "admin/structure/views/nojs/add-item/$view->name/$display->id/$type", + 'href' => "admin/structure/views/nojs/add-item/$view->name/{$display['id']}/$type", 'attributes' => array('class' => array('views-ajax-link')), ); @@ -497,7 +496,7 @@ function views_ui_view_preview_section_display_category_links($view, $type, $tit $links = array( $type . '-edit' => array( 'title' => t('Edit @section', array('@section' => $title)), - 'href' => "admin/structure/views/nojs/display/$view->name/$display->id/$type", + 'href' => "admin/structure/views/nojs/display/$view->name/{$display['id']}/$type", 'attributes' => array('class' => array('views-ajax-link')), ), );