Issue #1719188 by aspilicious: Coder cleanup.

8.0.x
aspilicious 2012-08-12 13:37:59 +02:00 committed by Tim Plunkett
parent 18bb81596d
commit e42f0d8c93
30 changed files with 176 additions and 173 deletions

View File

@ -909,8 +909,7 @@ class views_handler_argument extends views_handler {
// Add the number of nodes counter
$distinct = ($this->view->display_handler->get_option('distinct') && empty($this->query->no_distinct));
$count_alias = $this->query->add_field($this->query->base_table, $this->query->base_field, 'num_records',
array('count' => TRUE, 'distinct' => $distinct));
$count_alias = $this->query->add_field($this->query->base_table, $this->query->base_field, 'num_records', array('count' => TRUE, 'distinct' => $distinct));
$this->query->add_groupby($this->name_alias);
if ($count_field) {

View File

@ -1530,7 +1530,8 @@ If you would like to have the characters \'[\' and \']\' please use the html ent
foreach ($array as $param => $val) {
if (is_array($val)) {
// Copy parent_keys array, so we don't afect other elements of this iteration.
// Copy parent_keys array, so we don't affect other elements of this
// iteration.
$child_parent_keys = $parent_keys;
$child_parent_keys[] = $param;
// Get the child tokens.

View File

@ -269,11 +269,11 @@ class views_handler_filter_string extends views_handler_filter {
preg_match_all('/ (-?)("[^"]+"|[^" ]+)/i', ' ' . $this->value, $matches, PREG_SET_ORDER);
foreach ($matches as $match) {
$phrase = false;
$phrase = FALSE;
// Strip off phrase quotes
if ($match[2]{0} == '"') {
$match[2] = substr($match[2], 1, -1);
$phrase = true;
$phrase = TRUE;
}
$words = trim($match[2], ',?!();:-');
$words = $phrase ? array($words) : preg_split('/ /', $words, -1, PREG_SPLIT_NO_EMPTY);

View File

@ -1187,7 +1187,7 @@ function views_ui_preview_form($form, &$form_state, $view, $display_id = 'defaul
$form_state['no_cache'] = TRUE;
$form_state['view'] = $view;
$form['#attributes'] = array('class' => array('clearfix',));
$form['#attributes'] = array('class' => array('clearfix'));
// Add a checkbox controlling whether or not this display auto-previews.
$form['live_preview'] = array(
@ -1555,29 +1555,29 @@ function views_ui_get_display_tab_details($view, $display) {
$display_title = views_ui_get_display_label($view, $display->id, FALSE);
$build = array(
'#theme_wrappers' => array('container'),
'#attributes' => array('id' => 'edit-display-settings-details',),
'#attributes' => array('id' => 'edit-display-settings-details'),
);
$plugin = views_fetch_plugin_data('display', $view->display[$display->id]->display_plugin);
// The following is for display purposes only. We need to determine if there is more than one button and wrap
// the buttons in a .ctools-dropbutton class if more than one is present. Otherwise, we'll just wrap the
// actions in the .ctools-button class.
$isDisplayDeleted = !empty($display->deleted);
$isDeletable = empty($plugin['no remove']);
$is_display_deleted = !empty($display->deleted);
$is_deletable = empty($plugin['no remove']);
// The master display cannot be cloned.
$isDefault = $display->id == 'default';
$is_default = $display->id == 'default';
// @todo: Figure out why get_option doesn't work here.
$isEnabled = $display->handler->get_option('enabled');
$is_enabled = $display->handler->get_option('enabled');
if (!$isDisplayDeleted && $isDeletable && !$isDefault) {
if (!$is_display_deleted && $is_deletable && !$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">';
$suffix = '</ul></div></div>';
$itemElement = 'li';
$item_element = 'li';
}
else {
$prefix = '<div class="ctools-button"><div class="ctools-content"><ul class="horizontal right actions">';
$suffix = '</ul></div></div>';
$itemElement = 'li';
$item_element = 'li';
}
if ($display->id != 'default') {
@ -1591,15 +1591,15 @@ function views_ui_get_display_tab_details($view, $display) {
'#suffix' => $suffix,
);
if (!$isDisplayDeleted) {
if (!$isEnabled) {
if (!$is_display_deleted) {
if (!$is_enabled) {
$build['top']['actions']['enable'] = array(
'#type' => 'submit',
'#value' => t('enable @display_title', array('@display_title' => $display_title)),
'#limit_validation_errors' => array(),
'#submit' => array('views_ui_edit_form_submit_enable_display', 'views_ui_edit_form_submit_delay_destination'),
'#prefix' => '<' . $itemElement . ' class="enable">',
"#suffix" => '</' . $itemElement . '>',
'#prefix' => '<' . $item_element . ' class="enable">',
"#suffix" => '</' . $item_element . '>',
);
}
// Add a link to view the page.
@ -1611,39 +1611,39 @@ function views_ui_get_display_tab_details($view, $display) {
'#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' => '<' . $itemElement . ' class="view">',
"#suffix" => '</' . $itemElement . '>',
'#prefix' => '<' . $item_element . ' class="view">',
"#suffix" => '</' . $item_element . '>',
);
}
}
if (!$isDefault) {
if (!$is_default) {
$build['top']['actions']['duplicate'] = array(
'#type' => 'submit',
'#value' => t('clone @display_title', array('@display_title' => $display_title)),
'#limit_validation_errors' => array(),
'#submit' => array('views_ui_edit_form_submit_duplicate_display', 'views_ui_edit_form_submit_delay_destination'),
'#prefix' => '<' . $itemElement . ' class="duplicate">',
"#suffix" => '</' . $itemElement . '>',
'#prefix' => '<' . $item_element . ' class="duplicate">',
"#suffix" => '</' . $item_element . '>',
);
}
if ($isDeletable) {
if ($is_deletable) {
$build['top']['actions']['delete'] = array(
'#type' => 'submit',
'#value' => t('delete @display_title', array('@display_title' => $display_title)),
'#limit_validation_errors' => array(),
'#submit' => array('views_ui_edit_form_submit_delete_display', 'views_ui_edit_form_submit_delay_destination'),
'#prefix' => '<' . $itemElement . ' class="delete">',
"#suffix" => '</' . $itemElement . '>',
'#prefix' => '<' . $item_element . ' class="delete">',
"#suffix" => '</' . $item_element . '>',
);
}
if ($isEnabled) {
if ($is_enabled) {
$build['top']['actions']['disable'] = array(
'#type' => 'submit',
'#value' => t('disable @display_title', array('@display_title' => $display_title)),
'#limit_validation_errors' => array(),
'#submit' => array('views_ui_edit_form_submit_disable_display', 'views_ui_edit_form_submit_delay_destination'),
'#prefix' => '<' . $itemElement . ' class="disable">',
"#suffix" => '</' . $itemElement . '>',
'#prefix' => '<' . $item_element . ' class="disable">',
"#suffix" => '</' . $item_element . '>',
);
}
}
@ -1653,8 +1653,8 @@ function views_ui_get_display_tab_details($view, $display) {
'#value' => t('undo delete of @display_title', array('@display_title' => $display_title)),
'#limit_validation_errors' => array(),
'#submit' => array('views_ui_edit_form_submit_undo_delete_display', 'views_ui_edit_form_submit_delay_destination'),
'#prefix' => '<' . $itemElement . ' class="undo-delete">',
"#suffix" => '</' . $itemElement . '>',
'#prefix' => '<' . $item_element . ' class="undo-delete">',
"#suffix" => '</' . $item_element . '>',
);
}
@ -1668,7 +1668,7 @@ function views_ui_get_display_tab_details($view, $display) {
$build['columns'] = array();
$build['columns']['#theme_wrappers'] = array('container');
$build['columns']['#attributes'] = array('id' => 'edit-display-settings-main', 'class' => array('clearfix', 'views-display-columns'),);
$build['columns']['#attributes'] = array('id' => 'edit-display-settings-main', 'class' => array('clearfix', 'views-display-columns'));
$build['columns']['first']['#theme_wrappers'] = array('container');
$build['columns']['first']['#attributes'] = array('class' => array('views-display-column', 'first'));
@ -1693,9 +1693,9 @@ function views_ui_get_display_tab_details($view, $display) {
if (!config('views.settings')->get('views_ui_show_advanced_column')) {
$build['columns']['third']['#attributes']['class'][] = 'ctools-collapsed';
}
$build['columns']['third']['advanced'] = array('#markup' => '<h3 class="ctools-collapsible-handle"><a href="">' . t('Advanced') . '</a></h3>',);
$build['columns']['third']['advanced'] = array('#markup' => '<h3 class="ctools-collapsible-handle"><a href="">' . t('Advanced') . '</a></h3>');
$build['columns']['third']['collapse']['#theme_wrappers'] = array('container');
$build['columns']['third']['collapse']['#attributes'] = array('class' => array('ctools-collapsible-content',),);
$build['columns']['third']['collapse']['#attributes'] = array('class' => array('ctools-collapsible-content'));
// Each option (e.g. title, access, display as grid/table/list) fits into one
// of several "buckets," or boxes (Format, Fields, Sort, and so on).
@ -2347,11 +2347,11 @@ function views_ui_edit_form_get_bucket($type, $view, $display) {
}
if ($display->handler->use_group_by() && $handler->use_group_by()) {
$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));
$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->has_extra_options()) {
$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) {
@ -3801,7 +3801,7 @@ function theme_views_ui_rearrange_filter_form(&$vars) {
$form['filters'][$id]['group']['#attributes']['class'] = array('views-group-select views-group-select-' . $group_id);
$row[] = drupal_render($form['filters'][$id]['group']);
$form['filters'][$id]['removed']['#attributes']['class'][] = 'js-hide';
$row[] = drupal_render($form['filters'][$id]['removed']) . l('<span>' . t('Remove') . '</span>', 'javascript:void()', array('attributes' => array('id' => 'views-remove-link-' . $id, 'class' => array('views-hidden', 'views-button-remove', 'views-groups-remove-link', 'views-remove-link'), 'alt' => t('Remove this item'), 'title' => t('Remove this item')), 'html' => true));
$row[] = drupal_render($form['filters'][$id]['removed']) . l('<span>' . t('Remove') . '</span>', 'javascript:void()', array('attributes' => array('id' => 'views-remove-link-' . $id, 'class' => array('views-hidden', 'views-button-remove', 'views-groups-remove-link', 'views-remove-link'), 'alt' => t('Remove this item'), 'title' => t('Remove this item')), 'html' => TRUE));
$row = array('data' => $row, 'class' => array('draggable'), 'id' => 'views-row-' . $id);
if ($group_id !== 'ungroupable') {

View File

@ -1185,7 +1185,7 @@ function views_get_timezone() {
db_query("SET @@session.time_zone = '$offset'");
}
$already_set = true;
$already_set = TRUE;
}
}
@ -1357,42 +1357,44 @@ function views_date_sql_extract($extract_type, $field, $field_type = 'int', $set
// Note there is no space after FROM to avoid db_rewrite problems
// see http://drupal.org/node/79904.
switch ($extract_type) {
case('DATE'):
case 'DATE':
return $field;
case('YEAR'):
case 'YEAR':
return "EXTRACT(YEAR FROM($field))";
case('MONTH'):
case 'MONTH':
return "EXTRACT(MONTH FROM($field))";
case('DAY'):
case 'DAY':
return "EXTRACT(DAY FROM($field))";
case('HOUR'):
case 'HOUR':
return "EXTRACT(HOUR FROM($field))";
case('MINUTE'):
case 'MINUTE':
return "EXTRACT(MINUTE FROM($field))";
case('SECOND'):
case 'SECOND':
return "EXTRACT(SECOND FROM($field))";
case('WEEK'): // ISO week number for date
// ISO week number for date
case 'WEEK':
switch ($db_type) {
case('mysql'):
// WEEK using arg 3 in mysql should return the same value as postgres EXTRACT
case 'mysql':
// WEEK using arg 3 in mysql should return the same value as postgres
// EXTRACT.
return "WEEK($field, 3)";
case('pgsql'):
case 'pgsql':
return "EXTRACT(WEEK FROM($field))";
}
case('DOW'):
case 'DOW':
switch ($db_type) {
case('mysql'):
// mysql returns 1 for Sunday through 7 for Saturday
// php date functions and postgres use 0 for Sunday and 6 for Saturday
case 'mysql':
// mysql returns 1 for Sunday through 7 for Saturday php date
// functions and postgres use 0 for Sunday and 6 for Saturday.
return "INTEGER(DAYOFWEEK($field) - 1)";
case('pgsql'):
case 'pgsql':
return "EXTRACT(DOW FROM($field))";
}
case('DOY'):
case 'DOY':
switch ($db_type) {
case('mysql'):
case 'mysql':
return "DAYOFYEAR($field)";
case('pgsql'):
case 'pgsql':
return "EXTRACT(DOY FROM($field))";
}
}

View File

@ -65,16 +65,16 @@ class PluginStyleTest extends ViewsSqlTest {
$expected = array();
// Use Job: as label, so be sure that the label is used for groupby as well.
$expected['Job: Singer'] = array();
$expected['Job: Singer'][0] = new StdClass();
$expected['Job: Singer'][0] = new stdClass();
$expected['Job: Singer'][0]->views_test_name = 'John';
$expected['Job: Singer'][0]->views_test_job = 'Singer';
$expected['Job: Singer'][0]->views_test_id = '1';
$expected['Job: Singer'][1] = new StdClass();
$expected['Job: Singer'][1] = new stdClass();
$expected['Job: Singer'][1]->views_test_name = 'George';
$expected['Job: Singer'][1]->views_test_job = 'Singer';
$expected['Job: Singer'][1]->views_test_id = '2';
$expected['Job: Drummer'] = array();
$expected['Job: Drummer'][2] = new StdClass();
$expected['Job: Drummer'][2] = new stdClass();
$expected['Job: Drummer'][2]->views_test_name = 'Ringo';
$expected['Job: Drummer'][2]->views_test_job = 'Drummer';
$expected['Job: Drummer'][2]->views_test_id = '3';
@ -84,17 +84,17 @@ class PluginStyleTest extends ViewsSqlTest {
$expected = array();
$expected['Job: Singer'] = array();
$expected['Job: Singer']['group'] = 'Job: Singer';
$expected['Job: Singer']['rows'][0] = new StdClass();
$expected['Job: Singer']['rows'][0] = new stdClass();
$expected['Job: Singer']['rows'][0]->views_test_name = 'John';
$expected['Job: Singer']['rows'][0]->views_test_job = 'Singer';
$expected['Job: Singer']['rows'][0]->views_test_id = '1';
$expected['Job: Singer']['rows'][1] = new StdClass();
$expected['Job: Singer']['rows'][1] = new stdClass();
$expected['Job: Singer']['rows'][1]->views_test_name = 'George';
$expected['Job: Singer']['rows'][1]->views_test_job = 'Singer';
$expected['Job: Singer']['rows'][1]->views_test_id = '2';
$expected['Job: Drummer'] = array();
$expected['Job: Drummer']['group'] = 'Job: Drummer';
$expected['Job: Drummer']['rows'][2] = new StdClass();
$expected['Job: Drummer']['rows'][2] = new stdClass();
$expected['Job: Drummer']['rows'][2]->views_test_name = 'Ringo';
$expected['Job: Drummer']['rows'][2]->views_test_job = 'Drummer';
$expected['Job: Drummer']['rows'][2]->views_test_id = '3';
@ -169,14 +169,14 @@ class PluginStyleTest extends ViewsSqlTest {
$expected['Job: Singer']['group'] = 'Job: Singer';
$expected['Job: Singer']['rows']['Age: 25'] = array();
$expected['Job: Singer']['rows']['Age: 25']['group'] = 'Age: 25';
$expected['Job: Singer']['rows']['Age: 25']['rows'][0] = new StdClass();
$expected['Job: Singer']['rows']['Age: 25']['rows'][0] = new stdClass();
$expected['Job: Singer']['rows']['Age: 25']['rows'][0]->views_test_name = 'John';
$expected['Job: Singer']['rows']['Age: 25']['rows'][0]->views_test_job = 'Singer';
$expected['Job: Singer']['rows']['Age: 25']['rows'][0]->views_test_age = '25';
$expected['Job: Singer']['rows']['Age: 25']['rows'][0]->views_test_id = '1';
$expected['Job: Singer']['rows']['Age: 27'] = array();
$expected['Job: Singer']['rows']['Age: 27']['group'] = 'Age: 27';
$expected['Job: Singer']['rows']['Age: 27']['rows'][1] = new StdClass();
$expected['Job: Singer']['rows']['Age: 27']['rows'][1] = new stdClass();
$expected['Job: Singer']['rows']['Age: 27']['rows'][1]->views_test_name = 'George';
$expected['Job: Singer']['rows']['Age: 27']['rows'][1]->views_test_job = 'Singer';
$expected['Job: Singer']['rows']['Age: 27']['rows'][1]->views_test_age = '27';
@ -185,7 +185,7 @@ class PluginStyleTest extends ViewsSqlTest {
$expected['Job: Drummer']['group'] = 'Job: Drummer';
$expected['Job: Drummer']['rows']['Age: 28'] = array();
$expected['Job: Drummer']['rows']['Age: 28']['group'] = 'Age: 28';
$expected['Job: Drummer']['rows']['Age: 28']['rows'][2] = new StdClass();
$expected['Job: Drummer']['rows']['Age: 28']['rows'][2] = new stdClass();
$expected['Job: Drummer']['rows']['Age: 28']['rows'][2]->views_test_name = 'Ringo';
$expected['Job: Drummer']['rows']['Age: 28']['rows'][2]->views_test_job = 'Drummer';
$expected['Job: Drummer']['rows']['Age: 28']['rows'][2]->views_test_age = '28';

View File

@ -6,7 +6,7 @@
*/
/**
* Implementation of hook_views_default_views()
* Implements hook_views_default_views().
*/
function comment_views_default_views() {
$views = array();

View File

@ -6,7 +6,7 @@
*/
/**
* Implementation of hook_views_default_views()
* Implements of hook_views_default_views().
*/
function statistics_views_default_views() {
$views = array();

View File

@ -63,7 +63,7 @@ class views_plugin_display_feed extends views_plugin_display_page {
}
function defaultable_sections($section = NULL) {
if (in_array($section, array('style_options', 'style_plugin', 'row_options', 'row_plugin',))) {
if (in_array($section, array('style_options', 'style_plugin', 'row_options', 'row_plugin'))) {
return FALSE;
}

View File

@ -225,7 +225,8 @@ class views_plugin_exposed_form extends views_plugin {
);
if (isset($form_state['input']['sort_by']) && isset($this->view->sort[$form_state['input']['sort_by']])) {
$default_sort_order = $this->view->sort[$form_state['input']['sort_by']]->options['order'];
} else {
}
else {
$first_sort = reset($this->view->sort);
$default_sort_order = $first_sort->options['order'];
}

View File

@ -89,7 +89,7 @@ class ViewsUiBaseViewsWizard implements ViewsWizardInterface {
$form['displays']['page'] = array(
'#type' => 'fieldset',
'#attributes' => array('class' => array('views-attachment', 'fieldset-no-legend'),),
'#attributes' => array('class' => array('views-attachment', 'fieldset-no-legend')),
'#tree' => TRUE,
);
$form['displays']['page']['create'] = array(
@ -104,7 +104,7 @@ class ViewsUiBaseViewsWizard implements ViewsWizardInterface {
// can be hidden en masse when the "Create a page" checkbox is unchecked.
$form['displays']['page']['options'] = array(
'#type' => 'container',
'#attributes' => array('class' => array('options-set'),),
'#attributes' => array('class' => array('options-set')),
'#states' => array(
'visible' => array(
':input[name="page[create]"]' => array('checked' => TRUE),
@ -232,7 +232,7 @@ class ViewsUiBaseViewsWizard implements ViewsWizardInterface {
$form['displays']['block'] = array(
'#type' => 'fieldset',
'#attributes' => array('class' => array('views-attachment', 'fieldset-no-legend'),),
'#attributes' => array('class' => array('views-attachment', 'fieldset-no-legend')),
'#tree' => TRUE,
);
$form['displays']['block']['create'] = array(
@ -246,7 +246,7 @@ class ViewsUiBaseViewsWizard implements ViewsWizardInterface {
// can be hidden en masse when the "Create a block" checkbox is unchecked.
$form['displays']['block']['options'] = array(
'#type' => 'container',
'#attributes' => array('class' => array('options-set'),),
'#attributes' => array('class' => array('options-set')),
'#states' => array(
'visible' => array(
':input[name="block[create]"]' => array('checked' => TRUE),