Commit 601c922f authored by aspilicious's avatar aspilicious Committed by tim.plunkett

Issue #1772098 by aspilicious: Camelcase plugin/handler properties.

parent cabaa7bd
......@@ -34,11 +34,11 @@ <h3>Ctools dependency</h3>
<h3>Changed add_where api</h3>
If your field is a plain sql field:
<pre>
$this->query->add_where($this->options['group'], "$this->table_alias.$this->real_field " . $this->operator . " '%s'", $this->value);
$this->query->add_where($this->options['group'], "$this->tableAlias.$this->realField " . $this->operator . " '%s'", $this->value);
</pre>
has to be converted to
<pre>
$this->query->add_where($this->options['group'], "$this->table_alias.$this->real_field", $this->value, $this->operator);
$this->query->add_where($this->options['group'], "$this->tableAlias.$this->realField", $this->value, $this->operator);
</pre>
If your field is a complex where condition:
<pre>
......
......@@ -51,7 +51,7 @@ public function getField() {
return $this->handler->get_formula();
}
else {
return $this->handler->table_alias . '.' . $this->handler->real_field;
return $this->handler->tableAlias . '.' . $this->handler->realField;
}
}
......@@ -138,7 +138,7 @@ function summary_join() {
foreach ($view->many_to_one_tables[$field] as $value) {
$join->extra = array(
array(
'field' => $this->handler->real_field,
'field' => $this->handler->realField,
'operator' => '!=',
'value' => $value,
'numeric' => !empty($this->definition['numeric']),
......@@ -155,7 +155,7 @@ function summary_join() {
* The operator actually has influence over joining.
*/
public function ensureMyTable() {
if (!isset($this->handler->table_alias)) {
if (!isset($this->handler->tableAlias)) {
// Case 1: Operator is an 'or' and we're not reducing duplicates.
// We hence get the absolute simplest:
$field = $this->handler->relationship . '_' . $this->handler->table . '.' . $this->handler->field;
......@@ -167,7 +167,7 @@ public function ensureMyTable() {
if (isset($join)) {
$join->type = 'INNER';
}
$this->handler->table_alias = $this->handler->query->ensure_table($this->handler->table, $this->handler->relationship, $join);
$this->handler->tableAlias = $this->handler->query->ensure_table($this->handler->table, $this->handler->relationship, $join);
$this->handler->view->many_to_one_tables[$field] = $this->handler->value;
}
else {
......@@ -177,7 +177,7 @@ public function ensureMyTable() {
foreach ($this->handler->view->many_to_one_tables[$field] as $value) {
$join->extra = array(
array(
'field' => $this->handler->real_field,
'field' => $this->handler->realField,
'operator' => '!=',
'value' => $value,
'numeric' => !empty($this->handler->definition['numeric']),
......@@ -186,17 +186,17 @@ public function ensureMyTable() {
}
}
$this->handler->table_alias = $this->add_table($join);
$this->handler->tableAlias = $this->add_table($join);
}
return $this->handler->table_alias;
return $this->handler->tableAlias;
}
// Case 2: it's an 'and' or an 'or'.
// We do one join per selected value.
if ($this->handler->operator != 'not') {
// Clone the join for each table:
$this->handler->table_aliases = array();
$this->handler->tableAliases = array();
foreach ($this->handler->value as $value) {
$join = $this->getJoin();
if ($this->handler->operator == 'and') {
......@@ -204,7 +204,7 @@ public function ensureMyTable() {
}
$join->extra = array(
array(
'field' => $this->handler->real_field,
'field' => $this->handler->realField,
'value' => $value,
'numeric' => !empty($this->handler->definition['numeric']),
),
......@@ -218,11 +218,11 @@ public function ensureMyTable() {
}
$this->handler->view->many_to_one_aliases[$field][$value] = $this->handler->table . '_value_' . ($this->handler->view->many_to_one_count[$this->handler->table]++);
}
$alias = $this->handler->table_aliases[$value] = $this->add_table($join, $this->handler->view->many_to_one_aliases[$field][$value]);
$alias = $this->handler->tableAliases[$value] = $this->add_table($join, $this->handler->view->many_to_one_aliases[$field][$value]);
// and set table_alias to the first of these.
if (empty($this->handler->table_alias)) {
$this->handler->table_alias = $alias;
if (empty($this->handler->tableAlias)) {
$this->handler->tableAlias = $alias;
}
}
}
......@@ -236,16 +236,16 @@ public function ensureMyTable() {
$join->extra_type = 'OR';
foreach ($this->handler->value as $value) {
$join->extra[] = array(
'field' => $this->handler->real_field,
'field' => $this->handler->realField,
'value' => $value,
'numeric' => !empty($this->handler->definition['numeric']),
);
}
$this->handler->table_alias = $this->add_table($join);
$this->handler->tableAlias = $this->add_table($join);
}
}
return $this->handler->table_alias;
return $this->handler->tableAlias;
}
/**
......@@ -310,9 +310,9 @@ function add_filter() {
}
if ($add_condition) {
$field = $this->handler->real_field;
$field = $this->handler->realField;
$clause = $operator == 'or' ? db_or() : db_and();
foreach ($this->handler->table_aliases as $value => $alias) {
foreach ($this->handler->tableAliases as $value => $alias) {
$clause->condition("$alias.$field", $value);
}
......
......@@ -32,14 +32,14 @@ abstract class HandlerBase extends PluginBase {
*
* @var string
*/
public $table_alias;
public $tableAlias;
/**
* When a table has been moved this property is set.
*
* @var string
*/
public $actual_table;
public $actualTable;
/**
* The actual field in the database table, maybe different
......@@ -47,10 +47,10 @@ abstract class HandlerBase extends PluginBase {
*
* @var string
*/
public $real_field;
public $realField;
/**
* With field you can override the real_field if the real field is not set.
* With field you can override the realField if the real field is not set.
*
* @var string
*/
......@@ -61,7 +61,7 @@ abstract class HandlerBase extends PluginBase {
*
* @var string
*/
public $actual_field;
public $actualField;
/**
* The relationship used for this field.
......@@ -96,18 +96,18 @@ public function init(&$view, &$options) {
// option is stored as the plural.
// If the 'moved to' keyword moved our handler, let's fix that now.
if (isset($this->actual_table)) {
$options['table'] = $this->actual_table;
if (isset($this->actualTable)) {
$options['table'] = $this->actualTable;
}
if (isset($this->actual_field)) {
$options['field'] = $this->actual_field;
if (isset($this->actualField)) {
$options['field'] = $this->actualField;
}
$types = View::viewsHandlerTypes();
$plural = $this->plugin_type;
if (isset($types[$this->plugin_type]['plural'])) {
$plural = $types[$this->plugin_type]['plural'];
$plural = $this->pluginType;
if (isset($types[$this->pluginType]['plural'])) {
$plural = $types[$this->pluginType]['plural'];
}
if ($this->view->display_handler->isDefaulted($plural)) {
$display_id = 'default';
......@@ -121,17 +121,17 @@ public function init(&$view, &$options) {
}
if (isset($this->definition['real field'])) {
$this->real_field = $this->definition['real field'];
$this->realField = $this->definition['real field'];
}
if (isset($this->definition['field'])) {
$this->real_field = $this->definition['field'];
$this->realField = $this->definition['field'];
}
if (isset($options['field'])) {
$this->field = $options['field'];
if (!isset($this->real_field)) {
$this->real_field = $options['field'];
if (!isset($this->realField)) {
$this->realField = $options['field'];
}
}
......@@ -176,7 +176,7 @@ public function getField($field = NULL) {
$field = $this->get_formula();
}
else {
$field = $this->table_alias . '.' . $this->real_field;
$field = $this->tableAlias . '.' . $this->realField;
}
}
......@@ -528,10 +528,10 @@ public function setRelationship() {
* a lot.
*/
public function ensureMyTable() {
if (!isset($this->table_alias)) {
$this->table_alias = $this->query->ensure_table($this->table, $this->relationship);
if (!isset($this->tableAlias)) {
$this->tableAlias = $this->query->ensure_table($this->table, $this->relationship);
}
return $this->table_alias;
return $this->tableAlias;
}
/**
......
......@@ -36,7 +36,7 @@ abstract class PluginBase extends ComponentPluginBase {
/**
* The plugin type of this plugin, for example style or query.
*/
public $plugin_type = NULL;
public $pluginType = NULL;
/**
* Denotes whether the plugin has an additional options form.
......@@ -53,12 +53,12 @@ public function __construct(array $configuration, $plugin_id, DiscoveryInterface
$this->definition = $this->discovery->getDefinition($plugin_id) + $configuration;
// @todo Change calls to $this->plugin_type to use the definition directly.
$this->plugin_type = $this->definition['plugin_type'];
// @todo Change calls to $this->pluginType to use the definition directly.
$this->pluginType = $this->definition['plugin_type'];
// @todo Change calls to $this->real_field to use the definition directly.
if (isset($this->definition['field'])) {
$this->real_field = $this->definition['field'];
$this->realField = $this->definition['field'];
}
$this->construct();
......
......@@ -804,7 +804,7 @@ function default_summary() {
function summary_query() {
$this->ensureMyTable();
// Add the field.
$this->base_alias = $this->query->add_field($this->table_alias, $this->real_field);
$this->base_alias = $this->query->add_field($this->tableAlias, $this->realField);
$this->summary_name_field();
return $this->summary_basics();
......@@ -821,11 +821,11 @@ function summary_name_field() {
if (isset($this->name_table)) {
// if the alias is different then we're probably added, not ensured,
// so look up the join and add it instead.
if ($this->table_alias != $this->name_table) {
if ($this->tableAlias != $this->name_table) {
$j = views_get_table_join($this->name_table, $this->table);
if ($j) {
$join = clone $j;
$join->left_table = $this->table_alias;
$join->left_table = $this->tableAlias;
$this->name_table_alias = $this->query->add_table($this->name_table, $this->relationship, $join);
}
}
......@@ -834,7 +834,7 @@ function summary_name_field() {
}
}
else {
$this->name_table_alias = $this->table_alias;
$this->name_table_alias = $this->tableAlias;
}
if (isset($this->name_field)) {
......@@ -857,7 +857,7 @@ function summary_basics($count_field = TRUE) {
$this->query->add_groupby($this->name_alias);
if ($count_field) {
$this->query->set_count_field($this->table_alias, $this->real_field);
$this->query->set_count_field($this->tableAlias, $this->realField);
}
$this->count_alias = $count_alias;
......@@ -908,7 +908,7 @@ function summary_name($data) {
*/
public function query($group_by = FALSE) {
$this->ensureMyTable();
$this->query->add_where(0, "$this->table_alias.$this->real_field", $this->argument);
$this->query->add_where(0, "$this->tableAlias.$this->realField", $this->argument);
}
/**
......
......@@ -39,7 +39,7 @@ public function construct() {
}
function get_formula() {
return str_replace('***table***', $this->table_alias, $this->formula);
return str_replace('***table***', $this->tableAlias, $this->formula);
}
/**
......
......@@ -111,7 +111,7 @@ public function query($group_by = FALSE) {
}
if ($empty) {
parent::ensureMyTable();
$this->query->add_where(0, "$this->table_alias.$this->real_field", NULL, 'IS NULL');
$this->query->add_where(0, "$this->tableAlias.$this->realField", NULL, 'IS NULL');
return;
}
......@@ -166,14 +166,14 @@ function summary_query() {
}
if (empty($this->options['add_table']) || empty($this->view->many_to_one_tables[$field])) {
$this->table_alias = $this->query->ensure_table($this->table, $this->relationship, $join);
$this->tableAlias = $this->query->ensure_table($this->table, $this->relationship, $join);
}
else {
$this->table_alias = $this->helper->summary_join();
$this->tableAlias = $this->helper->summary_join();
}
// Add the field.
$this->base_alias = $this->query->add_field($this->table_alias, $this->real_field);
$this->base_alias = $this->query->add_field($this->tableAlias, $this->realField);
$this->summary_name_field();
......
......@@ -107,15 +107,15 @@ public function query($group_by = FALSE) {
}
$placeholder = $this->placeholder();
$null_check = empty($this->options['not']) ? '' : "OR $this->table_alias.$this->real_field IS NULL";
$null_check = empty($this->options['not']) ? '' : "OR $this->tableAlias.$this->realField IS NULL";
if (count($this->value) > 1) {
$operator = empty($this->options['not']) ? 'IN' : 'NOT IN';
$this->query->add_where_expression(0, "$this->table_alias.$this->real_field $operator($placeholder) $null_check", array($placeholder => $this->value));
$this->query->add_where_expression(0, "$this->tableAlias.$this->realField $operator($placeholder) $null_check", array($placeholder => $this->value));
}
else {
$operator = empty($this->options['not']) ? '=' : '!=';
$this->query->add_where_expression(0, "$this->table_alias.$this->real_field $operator $placeholder $null_check", array($placeholder => $this->argument));
$this->query->add_where_expression(0, "$this->tableAlias.$this->realField $operator $placeholder $null_check", array($placeholder => $this->argument));
}
}
......
......@@ -147,13 +147,13 @@ function summary_query() {
$this->ensureMyTable();
}
else {
$this->table_alias = $this->helper->summary_join();
$this->tableAlias = $this->helper->summary_join();
}
if (empty($this->options['glossary'])) {
// Add the field.
$this->base_alias = $this->query->add_field($this->table_alias, $this->real_field);
$this->query->set_count_field($this->table_alias, $this->real_field);
$this->base_alias = $this->query->add_field($this->tableAlias, $this->realField);
$this->query->set_count_field($this->tableAlias, $this->realField);
}
else {
// Add the field.
......@@ -172,7 +172,7 @@ function summary_query() {
* $this->ensureMyTable() MUST have been called prior to this.
*/
function get_formula() {
return "SUBSTRING($this->table_alias.$this->real_field, 1, " . intval($this->options['limit']) . ")";
return "SUBSTRING($this->tableAlias.$this->realField, 1, " . intval($this->options['limit']) . ")";
}
/**
......@@ -204,7 +204,7 @@ public function query($group_by = FALSE) {
$this->ensureMyTable();
$formula = FALSE;
if (empty($this->options['glossary'])) {
$field = "$this->table_alias.$this->real_field";
$field = "$this->tableAlias.$this->realField";
}
else {
$formula = TRUE;
......
......@@ -99,7 +99,7 @@ public function query() {
$this->ensureMyTable();
// Add the field.
$params = $this->options['group_type'] != 'group' ? array('function' => $this->options['group_type']) : array();
$this->field_alias = $this->query->add_field($this->table_alias, $this->real_field, NULL, $params);
$this->field_alias = $this->query->add_field($this->tableAlias, $this->realField, NULL, $params);
$this->add_additional_fields();
}
......@@ -137,7 +137,7 @@ function add_additional_fields($fields = NULL) {
$table_alias = $this->query->ensure_table($info['table'], $this->relationship);
}
else {
$table_alias = $this->table_alias;
$table_alias = $this->tableAlias;
}
if (empty($table_alias)) {
......@@ -155,7 +155,7 @@ function add_additional_fields($fields = NULL) {
$this->aliases[$identifier] = $this->query->add_field($table_alias, $info['field'], NULL, $params);
}
else {
$this->aliases[$info] = $this->query->add_field($this->table_alias, $info, NULL, $group_params);
$this->aliases[$info] = $this->query->add_field($this->tableAlias, $info, NULL, $group_params);
}
}
}
......
......@@ -163,7 +163,7 @@ public function defaultExposeOptions() {
public function query() {
$this->ensureMyTable();
$field = "$this->table_alias.$this->real_field";
$field = "$this->tableAlias.$this->realField";
if (empty($this->value)) {
if ($this->accept_null) {
......
......@@ -28,12 +28,12 @@ class BooleanOperatorString extends BooleanOperator {
public function query() {
$this->ensureMyTable();
$where = "$this->table_alias.$this->real_field ";
$where = "$this->tableAlias.$this->realField ";
if (empty($this->value)) {
$where .= "= ''";
if ($this->accept_null) {
$where = '(' . $where . " OR $this->table_alias.$this->real_field IS NULL)";
$where = '(' . $where . " OR $this->tableAlias.$this->realField IS NULL)";
}
}
else {
......
......@@ -67,7 +67,7 @@ public function query() {
// Always add the table of the selected fields to be sure a table alias exists.
$field->ensureMyTable();
if (!empty($field->field_alias) && !empty($field->field_alias)) {
$fields[] = "$field->table_alias.$field->real_field";
$fields[] = "$field->tableAlias.$field->realField";
}
}
if ($fields) {
......
......@@ -1369,7 +1369,7 @@ public function storeExposedInput($input, $status) {
*/
public function query() {
$this->ensureMyTable();
$this->query->add_where($this->options['group'], "$this->table_alias.$this->real_field", $this->value, $this->operator);
$this->query->add_where($this->options['group'], "$this->tableAlias.$this->realField", $this->value, $this->operator);
}
/**
......
......@@ -380,7 +380,7 @@ function op_simple() {
// We use array_values() because the checkboxes keep keys and that can cause
// array addition problems.
$this->query->add_where($this->options['group'], "$this->table_alias.$this->real_field", array_values($this->value), $this->operator);
$this->query->add_where($this->options['group'], "$this->tableAlias.$this->realField", array_values($this->value), $this->operator);
}
function op_empty() {
......@@ -392,7 +392,7 @@ function op_empty() {
$operator = "IS NOT NULL";
}
$this->query->add_where($this->options['group'], "$this->table_alias.$this->real_field", NULL, $operator);
$this->query->add_where($this->options['group'], "$this->tableAlias.$this->realField", NULL, $operator);
}
public function validate() {
......
......@@ -245,7 +245,7 @@ function value_form(&$form, &$form_state) {
public function query() {
$this->ensureMyTable();
$field = "$this->table_alias.$this->real_field";
$field = "$this->tableAlias.$this->realField";
$info = $this->operators();
if (!empty($info[$this->operator]['method'])) {
......
......@@ -254,7 +254,7 @@ function operator() {
*/
public function query() {
$this->ensureMyTable();
$field = "$this->table_alias.$this->real_field";
$field = "$this->tableAlias.$this->realField";
$info = $this->operators();
if (!empty($info[$this->operator]['method'])) {
......
......@@ -348,7 +348,7 @@ public function query() {
$def = $this->definition;
$def['table'] = $this->definition['base'];
$def['field'] = $base_field;
$def['left_table'] = $this->table_alias;
$def['left_table'] = $this->tableAlias;
$def['left_field'] = $this->field;
if (!empty($this->options['required'])) {
$def['type'] = 'INNER';
......
......@@ -54,9 +54,9 @@ public function init(&$view, &$options) {
$this->table = $this->definition['relationship table'];
}
if (isset($this->definition['relationship field'])) {
// Set both real_field and field so custom handler
// can rely on the old field value.
$this->real_field = $this->field = $this->definition['relationship field'];
// Set both realField and field so custom handler can rely on the old
// field value.
$this->realField = $this->field = $this->definition['relationship field'];
}
}
......@@ -123,8 +123,8 @@ public function query() {
$def = $this->definition;
$def['table'] = $this->definition['base'];
$def['field'] = $base_field;
$def['left_table'] = $this->table_alias;
$def['left_field'] = $this->real_field;
$def['left_table'] = $this->tableAlias;
$def['left_field'] = $this->realField;
if (!empty($this->options['required'])) {
$def['type'] = 'INNER';
}
......
......@@ -56,27 +56,27 @@ public function query() {
switch ($this->options['granularity']) {
case 'second':
default:
$this->query->add_orderby($this->table_alias, $this->real_field, $this->options['order']);
$this->query->add_orderby($this->tableAlias, $this->realField, $this->options['order']);
return;
case 'minute':
$formula = views_date_sql_format('YmdHi', "$this->table_alias.$this->real_field");
$formula = views_date_sql_format('YmdHi', "$this->tableAlias.$this->realField");
break;
case 'hour':
$formula = views_date_sql_format('YmdH', "$this->table_alias.$this->real_field");
$formula = views_date_sql_format('YmdH', "$this->tableAlias.$this->realField");
break;
case 'day':
$formula = views_date_sql_format('Ymd', "$this->table_alias.$this->real_field");
$formula = views_date_sql_format('Ymd', "$this->tableAlias.$this->realField");
break;
case 'month':
$formula = views_date_sql_format('Ym', "$this->table_alias.$this->real_field");
$formula = views_date_sql_format('Ym', "$this->tableAlias.$this->realField");
break;
case 'year':
$formula = views_date_sql_format('Y', "$this->table_alias.$this->real_field");
$formula = views_date_sql_format('Y', "$this->tableAlias.$this->realField");
break;
}
// Add the field.
$this->query->add_orderby(NULL, $formula, $this->options['order'], $this->table_alias . '_' . $this->field . '_' . $this->options['granularity']);
$this->query->add_orderby(NULL, $formula, $this->options['order'], $this->tableAlias . '_' . $this->field . '_' . $this->options['granularity']);
}
}
......@@ -36,7 +36,7 @@ public function query() {
'function' => $this->options['group_type'],
);
$this->query->add_orderby($this->table_alias, $this->real_field, $this->options['order'], NULL, $params);
$this->query->add_orderby($this->tableAlias, $this->realField, $this->options['order'], NULL, $params);
}