Commit 206cd481 authored by dawehner's avatar dawehner Committed by tim.plunkett

Issue #1778148 by dawehner: Added Rename view::viewsObjectTypes to view::viewsHandlerTypes.

parent b88ea073
......@@ -2021,7 +2021,7 @@ function views_ui_import_validate($form, &$form_state) {
}
}
foreach (View::viewsObjectTypes() as $type => $info) {
foreach (View::viewsHandlerTypes() as $type => $info) {
$handlers = $display->handler->getHandlers($type);
if ($handlers) {
foreach ($handlers as $id => $handler) {
......@@ -2149,7 +2149,7 @@ function views_ui_edit_form_get_bucket($type, $view, $display) {
$build = array(
'#theme_wrappers' => array('views_ui_display_tab_bucket'),
);
$types = View::viewsObjectTypes();
$types = View::viewsHandlerTypes();
$build['#overridden'] = FALSE;
$build['#defaulted'] = FALSE;
......@@ -3272,7 +3272,7 @@ function views_ui_config_type_form($form, &$form_state) {
$display_id = $form_state['display_id'];
$type = $form_state['type'];
$types = View::viewsObjectTypes();
$types = View::viewsHandlerTypes();
if (!$view->setDisplay($display_id)) {
views_ajax_error(t('Invalid display id @display', array('@display' => $display_id)));
}
......@@ -3304,7 +3304,7 @@ function views_ui_config_type_form($form, &$form_state) {
* Submit handler for type configuration form
*/
function views_ui_config_type_form_submit($form, &$form_state) {
$types = View::viewsObjectTypes();
$types = View::viewsHandlerTypes();
$display = &$form_state['view']->display[$form_state['display_id']];
// Store in cache
......@@ -3319,7 +3319,7 @@ function views_ui_rearrange_form($form, &$form_state) {
$display_id = $form_state['display_id'];
$type = $form_state['type'];
$types = View::viewsObjectTypes();
$types = View::viewsHandlerTypes();
if (!$view->setDisplay($display_id)) {
views_ajax_error(t('Invalid display id @display', array('@display' => $display_id)));
}
......@@ -3551,7 +3551,7 @@ function theme_views_ui_build_group_filter_form($variables) {
* Submit handler for rearranging form.
*/
function views_ui_rearrange_form_submit($form, &$form_state) {
$types = View::viewsObjectTypes();
$types = View::viewsHandlerTypes();
$display = &$form_state['view']->display[$form_state['display_id']];
$old_fields = $display->handler->getOption($types[$form_state['type']]['plural']);
......@@ -3587,7 +3587,7 @@ function views_ui_rearrange_filter_form($form, &$form_state) {
$display_id = $form_state['display_id'];
$type = $form_state['type'];
$types = View::viewsObjectTypes();
$types = View::viewsHandlerTypes();
if (!$view->setDisplay($display_id)) {
views_ajax_render(t('Invalid display id @display', array('@display' => $display_id)));
}
......@@ -3853,7 +3853,7 @@ function theme_views_ui_rearrange_filter_form(&$vars) {
* Submit handler for rearranging form
*/
function views_ui_rearrange_filter_form_submit($form, &$form_state) {
$types = View::viewsObjectTypes();
$types = View::viewsHandlerTypes();
$display = &$form_state['view']->display[$form_state['display_id']];
$remember_groups = array();
......@@ -3976,7 +3976,7 @@ function views_ui_add_item_form($form, &$form_state) {
}
$display = &$view->display[$display_id];
$types = View::viewsObjectTypes();
$types = View::viewsHandlerTypes();
$ltitle = $types[$type]['ltitle'];
$section = $types[$type]['plural'];
......@@ -4092,7 +4092,7 @@ function views_ui_add_item_form($form, &$form_state) {
*/
function views_ui_add_item_form_submit($form, &$form_state) {
$type = $form_state['type'];
$types = View::viewsObjectTypes();
$types = View::viewsHandlerTypes();
$section = $types[$type]['plural'];
// Handle the override select.
......@@ -4219,7 +4219,7 @@ function views_ui_config_item_form($form, &$form_state) {
$form['markup'] = array('#markup' => t("Error: handler for @table > @field doesn't exist!", array('@table' => $item['table'], '@field' => $item['field'])));
}
else {
$types = View::viewsObjectTypes();
$types = View::viewsHandlerTypes();
// If this item can come from the default display, show a dropdown
// that lets the user choose which display the changes should apply to.
......@@ -4339,7 +4339,7 @@ function views_ui_config_item_form_submit_temporary($form, &$form_state) {
// Run it through the handler's submit function.
$form_state['handler']->submitOptionsForm($form['options'], $form_state);
$item = $form_state['handler']->options;
$types = View::viewsObjectTypes();
$types = View::viewsHandlerTypes();
// For footer/header $handler_type is area but $type is footer/header.
// For all other handle types it's the same.
......@@ -4393,7 +4393,7 @@ function views_ui_config_item_form_submit($form, &$form_state) {
// Run it through the handler's submit function.
$form_state['handler']->submitOptionsForm($form['options'], $form_state);
$item = $form_state['handler']->options;
$types = View::viewsObjectTypes();
$types = View::viewsHandlerTypes();
// For footer/header $handler_type is area but $type is footer/header.
// For all other handle types it's the same.
......@@ -4469,7 +4469,7 @@ function views_ui_config_item_group_form($type, &$form_state) {
}
else {
$handler->init($view, $item);
$types = View::viewsObjectTypes();
$types = View::viewsHandlerTypes();
$form['#title'] = t('Configure group settings for @type %item', array('@type' => $types[$type]['lstitle'], '%item' => $handler->adminLabel()));
......@@ -4570,7 +4570,7 @@ function views_ui_config_item_extra_form($form, &$form_state) {
}
else {
$handler->init($view, $item);
$types = View::viewsObjectTypes();
$types = View::viewsHandlerTypes();
$form['#title'] = t('Configure extra settings for @type %item', array('@type' => $types[$type]['lstitle'], '%item' => $handler->adminLabel()));
......@@ -4641,7 +4641,7 @@ function views_ui_config_style_form($form, &$form_state) {
}
else {
$handler->init($view, $item);
$types = View::viewsObjectTypes();
$types = View::viewsHandlerTypes();
$form['#title'] = t('Configure summary style for @type %item', array('@type' => $types[$type]['lstitle'], '%item' => $handler->adminLabel()));
......@@ -5367,7 +5367,7 @@ function views_ui_field_list() {
foreach ($views as $view) {
foreach ($view->display as $display_id => $display) {
if ($view->setDisplay($display_id)) {
foreach (View::viewsObjectTypes() as $type => $info) {
foreach (View::viewsHandlerTypes() as $type => $info) {
foreach ($view->getItems($type, $display_id) as $item) {
$data = views_fetch_data($item['table']);
if (isset($data[$item['field']]) && isset($data[$item['field']][$type])
......
......@@ -104,7 +104,7 @@ public function init(&$view, &$options) {
$options['field'] = $this->actual_field;
}
$types = View::viewsObjectTypes();
$types = View::viewsHandlerTypes();
$plural = $this->plugin_type;
if (isset($types[$this->plugin_type]['plural'])) {
$plural = $types[$this->plugin_type]['plural'];
......@@ -324,7 +324,7 @@ public function usesGroupBy() {
public function buildGroupByForm(&$form, &$form_state) {
$view = &$form_state['view'];
$display_id = $form_state['display_id'];
$types = View::viewsObjectTypes();
$types = View::viewsHandlerTypes();
$type = $form_state['type'];
$id = $form_state['id'];
......
......@@ -866,7 +866,7 @@ public function &getHandler($type, $id) {
public function getHandlers($type) {
if (!isset($this->handlers[$type])) {
$this->handlers[$type] = array();
$types = View::viewsObjectTypes();
$types = View::viewsHandlerTypes();
$plural = $types[$type]['plural'];
foreach ($this->getOption($plural) as $id => $info) {
......@@ -2665,7 +2665,7 @@ public function validate() {
}
// Validate handlers
foreach (View::viewsObjectTypes() as $type => $info) {
foreach (View::viewsHandlerTypes() as $type => $info) {
foreach ($this->getHandlers($type) as $handler) {
$result = $handler->validate();
if (!empty($result) && is_array($result)) {
......@@ -2690,7 +2690,7 @@ public function validate() {
*
*/
public function isIdentifierUnique($id, $identifier) {
foreach (View::viewsObjectTypes() as $type => $info) {
foreach (View::viewsHandlerTypes() as $type => $info) {
foreach ($this->getHandlers($type) as $key => $handler) {
if ($handler->canExpose() && $handler->isExposed()) {
if ($handler->isAGroup()) {
......@@ -2794,7 +2794,7 @@ public function exportHandler($indent, $prefix, $storage, $option, $definition,
else {
$type = $option;
}
$types = View::viewsObjectTypes();
$types = View::viewsHandlerTypes();
foreach ($storage[$option] as $id => $info) {
if (!empty($types[$type]['type'])) {
$handler_type = $types[$type]['type'];
......@@ -2952,7 +2952,7 @@ public function unpackHandler(&$translatable, $storage, $option, $definition, $p
else {
$type = $option;
}
$types = View::viewsObjectTypes();
$types = View::viewsHandlerTypes();
foreach ($storage[$option] as $id => $info) {
if (!empty($types[$type]['type'])) {
$handler_type = $types[$type]['type'];
......
......@@ -7,6 +7,8 @@
namespace Drupal\views\Tests;
use Drupal\views\View;
/**
* Views class tests.
*/
......@@ -68,6 +70,25 @@ function assertViewDestroy($view) {
$this->assertEqual($view->attachment_after, '');
}
/**
* Tests view::viewsHandlerTypes().
*/
public function testViewshandlerTypes() {
$types = View::viewsHandlerTypes();
foreach (array('field', 'filter', 'argument', 'sort', 'header', 'footer', 'empty') as $type) {
$this->assertTrue(isset($types[$type]));
// @todo The key on the display should be footers, headers and empties
// or something similar instead of the singular, but so long check for
// this special case.
if (isset($types[$type]['type']) && $types[$type]['type'] == 'area') {
$this->assertEqual($types[$type]['plural'], $type);
}
else {
$this->assertEqual($types[$type]['plural'], $type . 's');
}
}
}
function testValidate() {
// Test a view with multiple displays.
// Validating a view shouldn't change the active display.
......
......@@ -742,7 +742,7 @@ public function fixMissingRelationships() {
$base_tables = array_keys($base_tables);
$missing_base_tables = array();
$types = View::viewsObjectTypes();
$types = View::viewsHandlerTypes();
foreach ($types as $key => $info) {
foreach ($this->display_handler->getOption($info['plural']) as $id => $options) {
$options['table'] = views_move_table($options['table']);
......@@ -801,7 +801,7 @@ public function fixMissingRelationships() {
public function initHandlers() {
if (empty($this->inited)) {
$this->fixMissingRelationships();
foreach (View::viewsObjectTypes() as $key => $info) {
foreach (View::viewsHandlerTypes() as $key => $info) {
$this->_initHandler($key, $info);
}
$this->inited = TRUE;
......@@ -865,7 +865,7 @@ public function getBaseTables() {
* Run the preQuery() on all active handlers.
*/
protected function _preQuery() {
foreach (View::viewsObjectTypes() as $key => $info) {
foreach (View::viewsHandlerTypes() as $key => $info) {
$handlers = &$this->$key;
$position = 0;
foreach ($handlers as $id => $handler) {
......@@ -880,7 +880,7 @@ protected function _preQuery() {
* Run the postExecute() on all active handlers.
*/
protected function _postExecute() {
foreach (View::viewsObjectTypes() as $key => $info) {
foreach (View::viewsHandlerTypes() as $key => $info) {
$handlers = &$this->$key;
foreach ($handlers as $id => $handler) {
$handlers[$id]->postExecute($this->result);
......@@ -894,7 +894,7 @@ protected function _postExecute() {
* @param $key
* One of 'argument', 'field', 'sort', 'filter', 'relationship'
* @param $info
* The $info from viewsObjectTypes for this object.
* The $info from viewsHandlerTypes for this object.
*/
protected function _initHandler($key, $info) {
// Load the requested items from the display onto the object.
......@@ -1973,7 +1973,7 @@ public function destroy() {
}
}
foreach (View::viewsObjectTypes() as $type => $info) {
foreach (View::viewsHandlerTypes() as $type => $info) {
if (isset($this->$type)) {
$handlers = &$this->$type;
foreach ($handlers as $id => $item) {
......@@ -2124,10 +2124,20 @@ public function processLocaleStrings($op) {
}
/**
* Providea a list of views object types used in a view, with some information
* Provide a list of views handler types used in a view, with some information
* about them.
*/
public static function viewsObjectTypes() {
*
* @return array
* An array of associative arrays containing:
* - title: The title of the handler type.
* - ltitle: The lowercase title of the handler type.
* - stitle: A singular title of the handler type.
* - lstitle: A singular lowercase title of the handler type.
* - plural: Plural version of the handler type.
* - (optional) type: The actual internal used handler type. This key is
* just used for header,footer,empty to link to the internal type: area.
*/
public static function viewsHandlerTypes() {
static $retval = NULL;
// Statically cache this so t() doesn't run a bajillion times.
......
......@@ -217,7 +217,7 @@ public function &newDisplay($plugin_id = 'page', $title = NULL, $id = NULL) {
* The unique ID for this handler instance.
*/
public function addItem($display_id, $type, $table, $field, $options = array(), $id = NULL) {
$types = View::viewsObjectTypes();
$types = View::viewsHandlerTypes();
$this->setDisplay($display_id);
$fields = $this->display[$display_id]->handler->getOption($types[$type]['plural']);
......@@ -263,7 +263,7 @@ public function getItems($type, $display_id = NULL) {
}
// Get info about the types so we can get the right data.
$types = View::viewsObjectTypes();
$types = View::viewsHandlerTypes();
return $this->display[$display_id]->handler->getOption($types[$type]['plural']);
}
......@@ -283,7 +283,7 @@ public function getItems($type, $display_id = NULL) {
*/
public function getItem($display_id, $type, $id) {
// Get info about the types so we can get the right data.
$types = View::viewsObjectTypes();
$types = View::viewsHandlerTypes();
// Initialize the display
$this->setDisplay($display_id);
......@@ -309,7 +309,7 @@ public function getItem($display_id, $type, $id) {
*/
public function setItem($display_id, $type, $id, $item) {
// Get info about the types so we can get the right data.
$types = View::viewsObjectTypes();
$types = View::viewsHandlerTypes();
// Initialize the display.
$this->setDisplay($display_id);
......
......@@ -476,7 +476,7 @@ function views_ui_view_preview_section_handler_links($view, $type, $title = FALS
$handlers = $view->display_handler->getHandlers($type);
$links = array();
$types = View::viewsObjectTypes();
$types = View::viewsHandlerTypes();
if ($title) {
$links[$type . '-title'] = array(
'title' => $types[$type]['title'],
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment