diff --git a/handlers/yql_views_query_handler_argument.inc b/handlers/yql_views_query_handler_argument.inc
deleted file mode 100644
index ca3078b..0000000
--- a/handlers/yql_views_query_handler_argument.inc
+++ /dev/null
@@ -1,16 +0,0 @@
-options['field_name'])) {
- return '';
- }
- return $this->options['field_name'];
- }
-
- function admin_summary() {
- return $this->field_name();
- }
-}
diff --git a/handlers/yql_views_query_handler_argument_column.inc b/handlers/yql_views_query_handler_argument_column.inc
deleted file mode 100644
index 7f5be15..0000000
--- a/handlers/yql_views_query_handler_argument_column.inc
+++ /dev/null
@@ -1,131 +0,0 @@
- 'none');
- $options['path_case'] = array('default' => 'none');
- $options['transform_dash'] = array('default' => FALSE);
- $options['field_name'] = array('default' => '');
-
- return $options;
- }
-
- function options_form(&$form, &$form_state) {
- parent::options_form($form, $form_state);
-
- $form['case'] = array(
- '#type' => 'select',
- '#title' => t('Case'),
- '#description' => t('When printing the argument result, how to transform the case.'),
- '#options' => array(
- 'none' => t('No transform'),
- 'upper' => t('Upper case'),
- 'lower' => t('Lower case'),
- 'ucfirst' => t('Capitalize first letter'),
- 'ucwords' => t('Capitalize each word'),
- ),
- '#default_value' => $this->options['case'],
- );
-
- $form['path_case'] = array(
- '#type' => 'select',
- '#title' => t('Case in path'),
- '#description' => t('When printing url paths, how to transform the case of the argument. Do not use this unless with Postgres as it uses case sensitive comparisons.'),
- '#options' => array(
- 'none' => t('No transform'),
- 'upper' => t('Upper case'),
- 'lower' => t('Lower case'),
- 'ucfirst' => t('Capitalize first letter'),
- 'ucwords' => t('Capitalize each word'),
- ),
- '#default_value' => $this->options['path_case'],
- );
-
- $form['transform_dash'] = array(
- '#type' => 'checkbox',
- '#title' => t('Transform spaces to dashes in URL'),
- '#default_value' => $this->options['transform_dash'],
- );
-
- $form['field_name'] = array(
- '#title' => t('Field name'),
- '#description' => t('The field name that will receive this argument. Example: Rating.AverageRating'),
- '#type' => 'textfield',
- '#default_value' => $this->options['field_name'],
- '#required' => TRUE,
- );
-
- }
-
- /**
- * Build the summary query based on a string
- */
- function summary_query() {
- $this->base_alias = $this->name_alias = $this->query->add_field($this->table_alias, $this->real_field);
- $this->query->set_count_field($this->table_alias, $this->real_field);
-
- return $this->summary_basics(FALSE);
- }
-
- /**
- * Build the query based upon the formula
- */
- function query() {
- $argument = $this->argument;
- if (!empty($this->options['transform_dash'])) {
- $argument = strtr($argument, '-', ' ');
- }
-
- $field = $this->options['field_name'];
- $this->query->add_where(0, "$field = '$argument'", $field, $argument);
- }
-
- function summary_argument($data) {
- $value = $this->case_transform($data->{$this->base_alias}, 'path_case');
- if (!empty($this->options['transform_dash'])) {
- $value = strtr($value, ' ', '-');
- }
-
- return $value;
- }
-
- function case_transform($string, $option) {
- global $multibyte;
-
- switch ($this->options[$option]) {
- default:
- return $string;
- case 'upper':
- return drupal_strtoupper($string);
- case 'lower':
- return drupal_strtolower($string);
- case 'ucfirst':
- return drupal_strtoupper(drupal_substr($string, 0, 1)) . drupal_substr($string, 1);
- case 'ucwords':
- if ($multibyte == UNICODE_MULTIBYTE) {
- return mb_convert_case($string, MB_CASE_TITLE);
- }
- else {
- return ucwords($string);
- }
- }
- }
-
- function title() {
- $title = $this->case_transform($this->argument, 'case');
- if (!empty($this->options['transform_dash'])) {
- $title = strtr($title, '-', ' ');
- }
-
- return check_plain($title);
- }
-
- function summary_name($data) {
- return $this->case_transform(parent::summary_name($data), 'case');
- }
-}
diff --git a/handlers/yql_views_query_handler_field.inc b/handlers/yql_views_query_handler_field.inc
deleted file mode 100644
index b11b2c5..0000000
--- a/handlers/yql_views_query_handler_field.inc
+++ /dev/null
@@ -1,16 +0,0 @@
-ensure_my_table();
- // Add the field.
- // $this->field_alias = $this->query->add_field($this->table_alias, $this->real_field);
- // $this->add_additional_fields();
-
- // $this->field_alias = $this->real_field;
- }
-}
diff --git a/handlers/yql_views_query_handler_field_column.inc b/handlers/yql_views_query_handler_field_column.inc
deleted file mode 100644
index ec82715..0000000
--- a/handlers/yql_views_query_handler_field_column.inc
+++ /dev/null
@@ -1,75 +0,0 @@
-format = isset($this->definition['format']) ? $this->format : NULL;
-
- $this->additional_fields = array();
- if (is_array($this->format)) {
- $this->additional_fields['format'] = $this->format;
- }
- }
-
- function render($values) {
- // Parse YQL result and output the appropriate value.
- $field_names = explode('.', $this->field_alias);
- // Traverse into multi-leveled array to get value based on array of key names.
- // Credits: http://stackoverflow.com/q/28616752/55075
- $value = (array)$values;
- while ($key = array_shift($field_names)) {
- $value = $value[$key];
- }
- $value = is_string($value) ? $value : $value['content'];
- $format = isset($this->format) ? $this->format : filter_fallback_format();
- //if ($value) {
- return check_markup($value, $format);
- //}
- }
-
- function element_type($none_supported = FALSE, $default_empty = FALSE, $inline = FALSE) {
- if (isset($this->definition['element type'])) {
- return $this->definition['element type'];
- }
-
- return 'div';
- }
-
- function option_definition() {
- $options = parent::option_definition();
- $options['field_name'] = array('default' => '');
- return $options;
- }
-
- function options_form(&$form, &$form_state) {
- parent::options_form($form, $form_state);
- $form['field_name'] = array(
- '#title' => t('Field name'),
- '#description' => t('The field name that wants to be included into the view. Example: Rating.AverageRating'),
- '#type' => 'textfield',
- '#default_value' => $this->options['field_name'],
- '#required' => TRUE,
- );
- }
-
- /**
- * Called to add the field to a query.
- */
- function query() {
- //$this->ensure_my_table();
- // Add the field.
- $this->field_alias = $this->query->add_field($this->table_alias, $this->options['field_name']);
- $this->add_additional_fields();
- }
-
- /**
- * Provide extra data to the administration form
- */
- function admin_summary() {
- return $this->label();
- }
-}
diff --git a/handlers/yql_views_query_handler_filter.inc b/handlers/yql_views_query_handler_filter.inc
deleted file mode 100644
index 7ceacb1..0000000
--- a/handlers/yql_views_query_handler_filter.inc
+++ /dev/null
@@ -1,5 +0,0 @@
- TRUE);
- $options['field_name'] = array('default' => '');
-
- return $options;
- }
-
- /**
- * This kind of construct makes it relatively easy for a child class
- * to add or remove functionality by overriding this function and
- * adding/removing items from this array.
- */
- function operators() {
- $operators = array(
- '=' => array(
- 'title' => t('Is equal to'),
- 'short' => t('='),
- 'method' => 'op_equal',
- 'values' => 1,
- ),
- '!=' => array(
- 'title' => t('Is not equal to'),
- 'short' => t('!='),
- 'method' => 'op_equal',
- 'values' => 1,
- ),
- 'contains' => array(
- 'title' => t('Contains'),
- 'short' => t('contains'),
- 'method' => 'op_contains',
- 'values' => 1,
- ),
- 'word' => array(
- 'title' => t('Contains any word'),
- 'short' => t('has word'),
- 'method' => 'op_word',
- 'values' => 1,
- ),
- 'allwords' => array(
- 'title' => t('Contains all words'),
- 'short' => t('has all'),
- 'method' => 'op_word',
- 'values' => 1,
- ),
- 'starts' => array(
- 'title' => t('Starts with'),
- 'short' => t('begins'),
- 'method' => 'op_starts',
- 'values' => 1,
- ),
- 'not_starts' => array(
- 'title' => t('Does not start with'),
- 'short' => t('not_begins'),
- 'method' => 'op_not_starts',
- 'values' => 1,
- ),
- 'ends' => array(
- 'title' => t('Ends with'),
- 'short' => t('ends'),
- 'method' => 'op_ends',
- 'values' => 1,
- ),
- 'not_ends' => array(
- 'title' => t('Does not end with'),
- 'short' => t('not_ends'),
- 'method' => 'op_not_ends',
- 'values' => 1,
- ),
- 'not' => array(
- 'title' => t('Does not contain'),
- 'short' => t('!has'),
- 'method' => 'op_not',
- 'values' => 1,
- ),
- 'shorterthan' => array(
- 'title' => t('Length is shorter than'),
- 'short' => t('shorter than'),
- 'method' => 'op_shorter',
- 'values' => 1,
- ),
- 'longerthan' => array(
- 'title' => t('Length is longer than'),
- 'short' => t('longer than'),
- 'method' => 'op_longer',
- 'values' => 1,
- ),
- );
- // if the definition allows for the empty operator, add it.
- if (!empty($this->definition['allow empty'])) {
- $operators += array(
- 'empty' => array(
- 'title' => t('Is empty (NULL)'),
- 'method' => 'op_empty',
- 'short' => t('empty'),
- 'values' => 0,
- ),
- 'not empty' => array(
- 'title' => t('Is not empty (NOT NULL)'),
- 'method' => 'op_empty',
- 'short' => t('not empty'),
- 'values' => 0,
- ),
- );
- }
-
- return $operators;
- }
-
- /**
- * Build strings from the operators() for 'select' options
- */
- function operator_options($which = 'title') {
- $options = array();
- foreach ($this->operators() as $id => $info) {
- $options[$id] = $info[$which];
- }
-
- return $options;
- }
-
- function admin_summary() {
- $output = check_plain($this->options['field_name']);
-
- if (!empty($this->options['exposed'])) {
- return $output . ', ' . t('exposed');
- }
-
- $options = $this->operator_options('short');
- $output = $output . ' ' . check_plain($options[$this->operator]);
- if (in_array($this->operator, $this->operator_values(1))) {
- $output .= ' ' . check_plain($this->value);
- }
- return $output;
- }
-
- function options_form(&$form, &$form_state) {
- parent::options_form($form, $form_state);
- $form['case'] = array(
- '#type' => 'checkbox',
- '#title' => t('Case sensitive'),
- '#default_value' => $this->options['case'],
- '#description' => t('Case sensitive filters may be faster. MySQL might ignore case sensitivity.'),
- );
-
- $form['field_name'] = array(
- '#type' => 'textfield',
- '#title' => 'Field name',
- '#description' => t('The field name in the table that will be used as the filter.'),
- '#default_value' => $this->options['field_name'],
- '#required' => TRUE,
- );
- }
-
- function operator_values($values = 1) {
- $options = array();
- foreach ($this->operators() as $id => $info) {
- if (isset($info['values']) && $info['values'] == $values) {
- $options[] = $id;
- }
- }
-
- return $options;
- }
-
- /**
- * Provide a simple textfield for equality
- */
- function value_form(&$form, &$form_state) {
- // We have to make some choices when creating this as an exposed
- // filter form. For example, if the operator is locked and thus
- // not rendered, we can't render dependencies; instead we only
- // render the form items we need.
- $which = 'all';
- if (!empty($form['operator'])) {
- $source = ($form['operator']['#type'] == 'radios') ? 'radio:options[operator]' : 'edit-options-operator';
- }
- if (!empty($form_state['exposed'])) {
- $identifier = $this->options['expose']['identifier'];
-
- if (empty($this->options['expose']['use_operator']) || empty($this->options['expose']['operator'])) {
- // exposed and locked.
- $which = in_array($this->operator, $this->operator_values(1)) ? 'value' : 'none';
- }
- else {
- $source = 'edit-' . drupal_clean_css_identifier($this->options['expose']['operator']);
- }
- }
-
- if ($which == 'all' || $which == 'value') {
- $form['value'] = array(
- '#type' => 'textfield',
- '#title' => t('Value'),
- '#size' => 30,
- '#default_value' => $this->value,
- );
- if (!empty($form_state['exposed']) && !isset($form_state['input'][$identifier])) {
- $form_state['input'][$identifier] = $this->value;
- }
-
- if ($which == 'all') {
- $form['value'] += array(
- '#process' => array('ctools_dependent_process'),
- '#dependency' => array($source => $this->operator_values(1)),
- );
- }
- }
-
- if (!isset($form['value'])) {
- // Ensure there is something in the 'value'.
- $form['value'] = array(
- '#type' => 'value',
- '#value' => NULL,
- );
- }
- }
-
- /**
- * Add this filter to the query.
- *
- * Due to the nature of fapi, the value and the operator have an unintended
- * level of indirection. You will find them in $this->operator
- * and $this->value respectively.
- */
- function query() {
- //$this->ensure_my_table();
- $field = $this->options['field_name'];
-
- $info = $this->operators();
- if (!empty($info[$this->operator]['method'])) {
- $this->{$info[$this->operator]['method']}($field);
- }
- }
-
- function op_equal($field) {
- // operator is either = or !=
- $value = is_array($this->value) ? $this->value[0] : $this->value;
- $this->query->add_where($this->options['group'], "$field $this->operator '$value'", $field, $this->value);
- }
-
- function op_contains($field) {
- $this->query->add_where($this->options['group'], "$field LIKE '%%$this->value%%'", $field, $this->value);
- }
-
- function op_word($field) {
- $where = array();
- preg_match_all('/ (-?)("[^"]+"|[^" ]+)/i', ' ' . $this->value, $matches, PREG_SET_ORDER);
- foreach ($matches as $match) {
- $phrase = false;
- // Strip off phrase quotes
- if ($match[2]{0} == '"') {
- $match[2] = substr($match[2], 1, -1);
- $phrase = true;
- }
- $words = trim($match[2], ',?!();:-');
- $words = $phrase ? array($words) : preg_split('/ /', $words, -1, PREG_SPLIT_NO_EMPTY);
- foreach ($words as $word) {
- $where[] = "$field LIKE '%%$word%%'";
- $values[] = $field;
- $values[] = trim($word, " ,!?");
- }
- }
-
- if (!$where) {
- return;
- }
-
- if ($this->operator == 'word') {
- $where = '(' . implode(' OR ', $where) . ')';
- }
- else {
- $where = implode(' AND ', $where);
- }
- // previously this was a call_user_func_array but that's unnecessary
- // as views will unpack an array that is a single arg.
- $this->query->add_where($this->options['group'], $where, $values);
- }
-
- function op_starts($field) {
- $this->query->add_where($this->options['group'], "$field LIKE '$this->value%%'", $field, $this->value);
- }
-
- function op_not_starts($field) {
- $this->query->add_where($this->options['group'], "$field NOT LIKE '$this->value%%'", $field, $this->value);
- }
-
- function op_ends($field) {
- $this->query->add_where($this->options['group'], "$field LIKE '%%$this->value'", $field, $this->value);
- }
-
- function op_not_ends($field) {
- $this->query->add_where($this->options['group'], "$field NOT LIKE '%%$this->value'", $field, $this->value);
- }
-
- function op_not($field) {
- $this->query->add_where($this->options['group'], "$field NOT LIKE '%%$this->value%%'", $field, $this->value);
- }
-
- function op_empty($field) {
- if ($this->operator == 'empty') {
- $operator = "IS NULL";
- }
- else {
- $operator = "IS NOT NULL";
- }
-
- $this->query->add_where($this->options['group'], "$field $operator");
- }
-}
diff --git a/handlers/yql_views_query_handler_sort.inc b/handlers/yql_views_query_handler_sort.inc
deleted file mode 100644
index e13f98d..0000000
--- a/handlers/yql_views_query_handler_sort.inc
+++ /dev/null
@@ -1,2 +0,0 @@
- '');
-
- return $options;
- }
-
- function options_form(&$form, &$form_state) {
- parent::options_form($form, $form_state);
-
- $form['field_name'] = array(
- '#type' => 'textfield',
- '#title' => t('Field name'),
- '#description' => t('The field name that the sorting will be done from. NOTE: Only the first field name in the sort handler that will be taken for sorting.'),
- '#default_value' => $this->options['field_name'],
- '#required' => TRUE,
- );
- }
-
- /**
- * Called to add the sort to a query.
- */
- function query() {
- $this->query->add_orderby($this->table_alias, $this->options['field_name'], $this->options['order']);
- }
-
- /**
- * Display whether or not the sort order is ascending or descending
- */
- function admin_summary() {
- $field = $this->options['field_name'];
-
- if (!empty($this->options['exposed'])) {
- return $field . ' ' . t('Exposed');
- }
- switch ($this->options['order']) {
- case 'ASC':
- case 'asc':
- default:
- return $field . ' ' . t('asc');
- break;
- case 'DESC':
- case 'desc':
- return $field . ' ' . t('desc');
- break;
- }
- }
-}
diff --git a/src/Plugin/views/argument/Column.php b/src/Plugin/views/argument/Column.php
new file mode 100644
index 0000000..5c6b7e5
--- /dev/null
+++ b/src/Plugin/views/argument/Column.php
@@ -0,0 +1,150 @@
+ 'none');
+ $options['path_case'] = array('default' => 'none');
+ $options['transform_dash'] = array('default' => FALSE);
+ $options['field_name'] = array('default' => '');
+
+ return $options;
+ }
+
+ function buildOptionsForm(&$form, FormStateInterface $form_state)
+ {
+ parent::buildOptionsForm($form, $form_state);
+
+ $form['case'] = array(
+ '#type' => 'select',
+ '#title' => t('Case'),
+ '#description' => t('When printing the argument result, how to transform the case.'),
+ '#options' => array(
+ 'none' => t('No transform'),
+ 'upper' => t('Upper case'),
+ 'lower' => t('Lower case'),
+ 'ucfirst' => t('Capitalize first letter'),
+ 'ucwords' => t('Capitalize each word'),
+ ),
+ '#default_value' => $this->options['case'],
+ );
+
+ $form['path_case'] = array(
+ '#type' => 'select',
+ '#title' => t('Case in path'),
+ '#description' => t('When printing url paths, how to transform the case of the argument. Do not use this unless with Postgres as it uses case sensitive comparisons.'),
+ '#options' => array(
+ 'none' => t('No transform'),
+ 'upper' => t('Upper case'),
+ 'lower' => t('Lower case'),
+ 'ucfirst' => t('Capitalize first letter'),
+ 'ucwords' => t('Capitalize each word'),
+ ),
+ '#default_value' => $this->options['path_case'],
+ );
+
+ $form['transform_dash'] = array(
+ '#type' => 'checkbox',
+ '#title' => t('Transform spaces to dashes in URL'),
+ '#default_value' => $this->options['transform_dash'],
+ );
+
+ $form['field_name'] = array(
+ '#title' => t('Field name'),
+ '#description' => t('The field name that will receive this argument. Example: Rating.AverageRating'),
+ '#type' => 'textfield',
+ '#default_value' => $this->options['field_name'],
+ '#required' => TRUE,
+ );
+ }
+
+ /**
+ * Build the summary query based on a string
+ */
+ function summaryQuery()
+ {
+ $this->base_alias = $this->name_alias = $this->query->addField($this->tableAlias, $this->realField);
+ $this->query->set_count_field($this->tableAlias, $this->realField);
+
+ return $this->summaryBasics(FALSE);
+ }
+
+ function query()
+ {
+ $argument = $this->argument;
+ if (!empty($this->options['transform_dash']))
+ {
+ $argument = strtr($argument, '-', ' ');
+ }
+
+ $field = $this->options['field_name'];
+ $this->query->addWhere(0, "$field = '$argument'", $field, $argument);
+ }
+
+ function summaryArgument($data)
+ {
+ $value = $this->case_transform($data->{$this->base_alias}, 'path_case');
+ if (!empty($this->options['transform_dash']))
+ {
+ $value = strtr($value, ' ', '-');
+ }
+
+ return $value;
+ }
+
+ function case_transform($string, $option)
+ {
+ global $multibyte;
+
+ switch ($this->options[$option])
+ {
+ default:
+ return $string;
+ case 'upper':
+ return drupal_strtoupper($string);
+ case 'lower':
+ return drupal_strtolower($string);
+ case 'ucfirst':
+ return drupal_strtoupper(drupal_substr($string, 0, 1)) . drupal_substr($string, 1);
+ case 'ucwords':
+ if ($multibyte == UNICODE_MULTIBYTE)
+ {
+ return mb_convert_case($string, MB_CASE_TITLE);
+ }
+ else {
+ return ucwords($string);
+ }
+ }
+ }
+
+ function title() {
+ $title = $this->case_transform($this->argument, 'case');
+ if (!empty($this->options['transform_dash']))
+ {
+ $title = strtr($title, '-', ' ');
+ }
+
+ return check_plain($title);
+ }
+
+ function summaryName($data)
+ {
+ return $this->case_transform(parent::summaryName($data), 'case');
+ }
+}
diff --git a/src/Plugin/views/field/Column.php b/src/Plugin/views/field/Column.php
new file mode 100644
index 0000000..e014e2d
--- /dev/null
+++ b/src/Plugin/views/field/Column.php
@@ -0,0 +1,97 @@
+format = isset($this->definition['format']) ? $this->format : NULL;
+
+ $this->additional_fields = array();
+
+ if (is_array($this->format))
+ {
+ $this->additional_fields['format'] = $this->format;
+ }
+ }
+
+ function render(ResultRow $values)
+ {
+ $field_names = explode('.', $this->field_alias);
+ $value = (array) $values;
+
+ while ($key = array_shift($field_names))
+ {
+ $value = $value[$key];
+ }
+
+ $value = is_string($value) ? $value : $value['content'];
+ $format = isset($this->format) ? $this->format : filter_fallback_format();
+
+ return check_markup($value, $format);
+ }
+
+ function elementType($none_supported = FALSE, $default_empty = FALSE, $inline = FALSE)
+ {
+ if (isset($this->definition['element type']))
+ {
+ return $this->definition['element type'];
+ }
+
+ return 'div';
+ }
+
+ function defineOptions()
+ {
+ $options = parent::defineOptions();
+ $options['field_name'] = array('default' => '');
+ return $options;
+ }
+
+ function buildOptionsForm(&$form, FormStateInterface $form_state)
+ {
+ parent::buildOptionsForm($form, $form_state);
+
+ $form['field_name'] = array(
+ '#title' => $this->t('Field name'),
+ '#description' => t('The field name that wants to be included into the view. Example: Rating.AverageRating'),
+ '#type' => 'textfield',
+ '#default_value' => $this->options['field_name'],
+ '#required' => TRUE,
+ );
+ }
+
+ /**
+ * Called to add the field to a query.
+ */
+ function query()
+ {
+ $this->field_alias = $this->query->add_field($this->tableAlias, $this->options['field_name']);
+ $this->addAdditionalFields();
+ }
+
+ /**
+ * Provide extra data to the administration form
+ */
+ function adminSummary()
+ {
+ return $this->label();
+ }
+}
diff --git a/src/Plugin/views/filter/Column.php b/src/Plugin/views/filter/Column.php
new file mode 100644
index 0000000..00c4707
--- /dev/null
+++ b/src/Plugin/views/filter/Column.php
@@ -0,0 +1,314 @@
+ TRUE);
+ $options['field_name'] = array('default' => '');
+
+ return $options;
+ }
+
+ function operators()
+ {
+ $operators = array(
+ '=' => array(
+ 'title' => t('Is equal to'),
+ 'short' => t('='),
+ 'method' => 'op_equal',
+ 'values' => 1,
+ ),
+ '!=' => array(
+ 'title' => t('Is not equal to'),
+ 'short' => t('!='),
+ 'method' => 'op_equal',
+ 'values' => 1,
+ ),
+ 'contains' => array(
+ 'title' => t('Contains'),
+ 'short' => t('contains'),
+ 'method' => 'op_contains',
+ 'values' => 1,
+ ),
+ 'word' => array(
+ 'title' => t('Contains any word'),
+ 'short' => t('has word'),
+ 'method' => 'op_word',
+ 'values' => 1,
+ ),
+ 'allwords' => array(
+ 'title' => t('Contains all words'),
+ 'short' => t('has all'),
+ 'method' => 'op_word',
+ 'values' => 1,
+ ),
+ 'starts' => array(
+ 'title' => t('Starts with'),
+ 'short' => t('begins'),
+ 'method' => 'op_starts',
+ 'values' => 1,
+ ),
+ 'not_starts' => array(
+ 'title' => t('Does not start with'),
+ 'short' => t('not_begins'),
+ 'method' => 'op_not_starts',
+ 'values' => 1,
+ ),
+ 'ends' => array(
+ 'title' => t('Ends with'),
+ 'short' => t('ends'),
+ 'method' => 'op_ends',
+ 'values' => 1,
+ ),
+ 'not_ends' => array(
+ 'title' => t('Does not end with'),
+ 'short' => t('not_ends'),
+ 'method' => 'op_not_ends',
+ 'values' => 1,
+ ),
+ 'not' => array(
+ 'title' => t('Does not contain'),
+ 'short' => t('!has'),
+ 'method' => 'op_not',
+ 'values' => 1,
+ ),
+ 'shorterthan' => array(
+ 'title' => t('Length is shorter than'),
+ 'short' => t('shorter than'),
+ 'method' => 'op_shorter',
+ 'values' => 1,
+ ),
+ 'longerthan' => array(
+ 'title' => t('Length is longer than'),
+ 'short' => t('longer than'),
+ 'method' => 'op_longer',
+ 'values' => 1,
+ ),
+ );
+ // if the definition allows for the empty operator, add it.
+ if (!empty($this->definition['allow empty'])) {
+ $operators += array(
+ 'empty' => array(
+ 'title' => t('Is empty (NULL)'),
+ 'method' => 'op_empty',
+ 'short' => t('empty'),
+ 'values' => 0,
+ ),
+ 'not empty' => array(
+ 'title' => t('Is not empty (NOT NULL)'),
+ 'method' => 'op_empty',
+ 'short' => t('not empty'),
+ 'values' => 0,
+ ),
+ );
+ }
+
+ return $operators;
+ }
+
+ /**
+ * Build strings from the operators() for 'select' options
+ */
+ function operatorOptions($which = 'title')
+ {
+ $options = array();
+ foreach ($this->operators() as $id => $info)
+ {
+ $options[$id] = $info[$which];
+ }
+
+ return $options;
+ }
+
+ function adminSummary()
+ {
+ $output = SafeMarkup::checkPlain($this->options['field_name']);
+
+ if (!empty($this->options['exposed']))
+ {
+ return $output . ', ' . t('exposed');
+ }
+
+ $options = $this->operatorOptions('short');
+ $output = $output . ' ' . SafeMarkup::checkPlain($options[$this->operator]);
+ if (in_array($this->operator, $this->operator_values(1)))
+ {
+ $output .= ' ' . SafeMarkup::checkPlain($this->value);
+ }
+ return $output;
+ }
+
+ public function buildOptionsForm(&$form, FormStateInterface $form_state)
+ {
+ parent::buildOptionsForm($form, $form_state);
+
+ $form['case'] = array(
+ '#type' => 'checkbox',
+ '#title' => t('Case sensitive'),
+ '#default_value' => $this->options['case'],
+ '#description' => t('Case sensitive filters may be faster. MySQL might ignore case sensitivity.'),
+ );
+
+ $form['field_name'] = array(
+ '#type' => 'textfield',
+ '#title' => 'Field name',
+ '#description' => t('The field name in the table that will be used as the filter.'),
+ '#default_value' => $this->options['field_name'],
+ '#required' => TRUE,
+ );
+ }
+
+ function operator_values($values = 1)
+ {
+ $options = array();
+ foreach ($this->operators() as $id => $info)
+ {
+ if (isset($info['values']) && $info['values'] == $values)
+ {
+ $options[] = $id;
+ }
+ }
+
+ return $options;
+ }
+
+ /**
+ * Provide a simple textfield for equality
+ */
+ protected function valueForm(&$form, FormStateInterface $form_state)
+ {
+ $form['value'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Value'),
+ '#size' => 30
+ );
+ }
+
+ /**
+ * Add this filter to the query.
+ *
+ * Due to the nature of fapi, the value and the operator have an unintended
+ * level of indirection. You will find them in $this->operator
+ * and $this->value respectively.
+ */
+ function query()
+ {
+ //$this->ensure_my_table();
+ $field = $this->options['field_name'];
+
+ $info = $this->operators();
+ if (!empty($info[$this->operator]['method']))
+ {
+ $this->{$info[$this->operator]['method']}($field);
+ }
+ }
+
+ function op_equal($field)
+ {
+ // operator is either = or !=
+ $value = is_array($this->value) ? $this->value[0] : $this->value;
+ $this->query->add_where($this->options['group'], "$field $this->operator '$value'", $field, $this->value);
+ }
+
+ function op_contains($field)
+ {
+ $this->query->add_where($this->options['group'], "$field LIKE '%%$this->value%%'", $field, $this->value);
+ }
+
+ function op_word($field) {
+ $where = array();
+ preg_match_all('/ (-?)("[^"]+"|[^" ]+)/i', ' ' . $this->value, $matches, PREG_SET_ORDER);
+ foreach ($matches as $match)
+ {
+ $phrase = false;
+ // Strip off phrase quotes
+ if ($match[2]{0} == '"')
+ {
+ $match[2] = substr($match[2], 1, -1);
+ $phrase = true;
+ }
+ $words = trim($match[2], ',?!();:-');
+ $words = $phrase ? array($words) : preg_split('/ /', $words, -1, PREG_SPLIT_NO_EMPTY);
+ foreach ($words as $word)
+ {
+ $where[] = "$field LIKE '%%$word%%'";
+ $values[] = $field;
+ $values[] = trim($word, " ,!?");
+ }
+ }
+
+ if (!$where)
+ {
+ return;
+ }
+
+ if ($this->operator == 'word')
+ {
+ $where = '(' . implode(' OR ', $where) . ')';
+ }
+ else
+ {
+ $where = implode(' AND ', $where);
+ }
+ // previously this was a call_user_func_array but that's unnecessary
+ // as views will unpack an array that is a single arg.
+ $this->query->add_where($this->options['group'], $where, $values);
+ }
+
+ function op_starts($field)
+ {
+ $this->query->add_where($this->options['group'], "$field LIKE '$this->value%%'", $field, $this->value);
+ }
+
+ function op_not_starts($field)
+ {
+ $this->query->add_where($this->options['group'], "$field NOT LIKE '$this->value%%'", $field, $this->value);
+ }
+
+ function op_ends($field)
+ {
+ $this->query->add_where($this->options['group'], "$field LIKE '%%$this->value'", $field, $this->value);
+ }
+
+ function op_not_ends($field)
+ {
+ $this->query->add_where($this->options['group'], "$field NOT LIKE '%%$this->value'", $field, $this->value);
+ }
+
+ function op_not($field)
+ {
+ $this->query->add_where($this->options['group'], "$field NOT LIKE '%%$this->value%%'", $field, $this->value);
+ }
+
+ function op_empty($field)
+ {
+ if ($this->operator == 'empty')
+ {
+ $operator = "IS NULL";
+ }
+ else
+ {
+ $operator = "IS NOT NULL";
+ }
+
+ $this->query->add_where($this->options['group'], "$field $operator");
+ }
+}
diff --git a/src/Plugin/views/query/Column.php b/src/Plugin/views/query/Column.php
new file mode 100644
index 0000000..2a972f7
--- /dev/null
+++ b/src/Plugin/views/query/Column.php
@@ -0,0 +1,552 @@
+api_url = !empty($this->options['api_url']) ? $this->options['api_url'] : 'http://query.yahooapis.com/v1/public/yql';
+ $this->api_method = isset($this->options['api_method']) ? $this->options['api_method'] : 'json';
+ $this->yql_base_table = isset($this->options['yql_base_table']) ? $this->options['yql_base_table'] : '';
+ }
+
+ /**
+ * Construct the "WHERE" or "HAVING" part of the query.
+ *
+ * @param $where
+ * 'where' or 'having'.
+ */
+ function condition_query($where = 'where')
+ {
+ $clauses = array();
+ foreach ($this->$where as $group => $info) {
+ if (empty($info['clauses']))
+ {
+ continue;
+ }
+ $clause = implode(") " . $info['type'] . " (", $info['clauses']);
+ if (count($info['clauses']) > 1)
+ {
+ $clause = '(' . $clause . ')';
+ }
+ $clauses[] = $clause;
+ }
+
+ if ($clauses)
+ {
+ $keyword = Unicode::strtoupper($where);
+ if (count($clauses) > 1)
+ {
+ return "$keyword (" . implode(")\n " . $this->group_operator . ' (', array_filter($clauses)) . ")\n";
+ }
+ else
+ {
+ return "$keyword " . array_shift($clauses) . "\n";
+ }
+ }
+ return "";
+ }
+
+ function use_pager()
+ {
+ return FALSE;
+ }
+
+ /**
+ * Generate a query and a countquery from all of the information supplied
+ * to the object.
+ *
+ * @param $get_count
+ * Provide a countquery if this is true, otherwise provide a normal query.
+ */
+ function query($get_count = FALSE)
+ {
+ $query = '';
+
+ // Add the where clauses
+ $where = ' ' . $this->condition_query();
+
+ // Add the field clauses
+ $fields = '';
+ $fields_array = $this->fields;
+ foreach ($fields_array as $alias => $field)
+ {
+ if (!empty($fields))
+ {
+ $fields .= ', ';
+ }
+ $fields .= $field['field'];
+ }
+ // Add the base table
+ $from = $this->yql_base_table;
+
+ // Add sort function
+ if (isset($this->orderby) && $this->orderby) {
+ // Only get the first orderby
+ $orderby_field = current($this->orderby);
+ $orderby = " | sort(field=\"" . $orderby_field['field'] . "\")";
+
+ switch ($orderby_field['order']) {
+ case 'ASC':
+ case 'asc':
+ // Do nothing. This is added only for clarity.
+ break;
+
+ case 'DESC':
+ case 'desc':
+ $orderby = $orderby . ' | reverse()';
+ break;
+
+ default:
+ break;
+ }
+ }
+
+ // Build the query string
+ $query = "SELECT $fields FROM $from";
+ if (!empty($where)) {
+ $query = "$query $where";
+ }
+
+ // Add table definitions
+ if (!empty($this->options['yql_custom_tables'])) {
+ $query = $this->options['yql_custom_tables'] . $query;
+ }
+
+ // Add sort definitions
+ if (!empty($orderby))
+ {
+ $query = $query . $orderby;
+ }
+ return $query;
+ }
+
+
+ /**
+ * Get the arguments attached to the WHERE and HAVING clauses of this query.
+ */
+ function get_where_args()
+ {
+ $args = array();
+ foreach ($this->where as $group => $where)
+ {
+ $args = array_merge($args, $where['args']);
+ }
+
+ if (isset($this->having) && $this->having)
+ {
+ foreach ($this->having as $group => $having)
+ {
+ $args = array_merge($args, $having['args']);
+ }
+ }
+ return $args;
+ }
+
+ function add_param($param, $value = '')
+ {
+ $this->params[$param] = $value;
+ }
+
+ function add_where($group, $clause)
+ {
+ $args = func_get_args();
+ array_shift($args); // ditch $group
+ array_shift($args); // ditch $clause
+
+ // Expand an array of args if it came in.
+ if (count($args) == 1 && is_array(reset($args)))
+ {
+ $args = current($args);
+ }
+
+ // Ensure all variants of 0 are actually 0. Thus '', 0 and NULL are all
+ // the default group.
+ if (empty($group))
+ {
+ $group = 0;
+ }
+
+ // Check for a group.
+ if (!isset($this->where[$group]))
+ {
+ $this->set_where_group('AND', $group);
+ }
+
+ // Add the clause and the args.
+ if (is_array($args))
+ {
+ $this->where[$group]['clauses'][] = $clause;
+ // we use array_values() here to prevent array_merge errors as keys from multiple
+ // sources occasionally collide.
+ $this->where[$group]['args'] = array_merge($this->where[$group]['args'], array_values($args));
+ }
+ }
+
+ /**
+ * Let modules modify the query just prior to finalizing it.
+ */
+ public function alter(ViewExecutable $view)
+ {
+ foreach (Drupal::moduleHandler()->getImplementations('yql_views_query_query_alter') as $module)
+ {
+ $function = $module . '_yql_views_query_query_alter';
+ $function($view, $this);
+ }
+ }
+
+ /**
+ * Builds the necessary info to execute the query.
+ */
+ public function build(ViewExecutable $view)
+ {
+ $view->initPager($view);
+
+ $this->pager = $view->getPager();
+
+ if($this->pager)
+ {
+ $this->pager->query();
+ }
+
+ $view->build_info['query'] = $this->query($view);
+ //$view->build_info['count_query'] = $this->query($view, TRUE);
+ $view->build_info['count_query'] = '';
+ $view->build_info['query_args'] = $this->get_where_args();
+ }
+
+ /**
+ * Alter the query for paging settings. This should only be called
+ * if the view is using pager.
+ * @param $query
+ * The query to be altered
+ * @param $limit
+ * The number of items limit
+ * @param $offset
+ * The offset from the first item
+ */
+ function _query_alter_limit(&$query, $limit, $offset)
+ {
+ $base_table = $this->options['yql_base_table'];
+ // $total_aggregate_items = $offset + $limit;
+
+ // @todo if there is a better way, fix this!
+ $total_aggregate_items = $this->options['num_items'];
+
+ $query = str_replace('FROM ' . $base_table, 'FROM ' . $base_table . '(0,' . $total_aggregate_items . ')', $query);
+
+ /*
+ // If sort function is specified, the limit and offset should be put
+ // before the sort function
+ if ($sort_found = strpos($query, '|')) {
+ $query = substr($query, 0, $sort_found -1) . "limit $limit offset $offset " . substr($query, $sort_found);
+ }
+ else {
+ $query .= " limit $limit offset $offset";
+ }
+ */
+
+ $current_tail = $offset + $limit;
+ $query = $query . " | truncate(count=$current_tail) | tail(count=$limit)";
+ }
+
+ /**
+ * Executes the query and fills the associated view object with according
+ * values.
+ *
+ * Values to set: $view->result, $view->total_rows, $view->execute_time,
+ * $view->pager['current_page'].
+ */
+ public function execute(ViewExecutable $view)
+ {
+ $query = $view->build_info['query'];
+ $args = $view->build_info['query_args'];
+
+ if ($query)
+ {
+ // Initialize, alter and set the pager settings before executing
+ if ($this->pager && $this->pager->usePager())
+ {
+ $this->pager->total_items = $this->options['num_items'];
+ $view->total_rows = $this->options['num_items'];
+
+ if (!empty($this->pager->options['offset']))
+ {
+ $this->pager->total_items -= $this->pager->options['offset'];
+ }
+ $this->pager->updatePageInfo();
+ }
+
+ // We can't have an offset without a limit, so provide an upperbound limit instead.
+ $limit = intval(!empty($this->limit) ? $this->limit : $this->options['num_items']);
+ $offset = intval(!empty($this->offset) ? $this->offset : 0);
+ $this->_query_alter_limit($query, $limit, $offset);
+
+ // Let the pager modify the query to add limits.
+ $this->pager->preExecute($query, $args);
+
+ $replacements = \Drupal::moduleHandler()->invokeAll('views_query_substitutions', [$view]);
+ $query = str_replace(array_keys($replacements), $replacements, $query);
+
+ // Encode the query into URL friendly format
+ $query = urlencode($query);
+ $format_string = $this->api_method == 'json' ? '&format=json' : '&format=xml';
+ $url = $this->api_url . '?q=' . $query . $format_string;
+
+ $start = $this->float_microtime();
+
+ try
+ {
+ $client = \Drupal::httpClient();
+ $results = $client->get($url);
+
+
+ }
+ catch (BadResponseException $exception)
+ {
+ $response = $exception->getResponse();
+ drupal_set_message(t('Failed to fetch file due to HTTP error "%error"', array('%error' => $response->getStatusCode() . ' ' . $response->getReasonPhrase())), 'error');
+
+ if ($response->getBody())
+ {
+ $yql_error = json_decode($response->getBody(), TRUE);
+ drupal_set_message("YQL query error: " . $yql_error['error']['description'], 'error');
+ }
+
+ return;
+ }
+ catch (RequestException $exception)
+ {
+ drupal_set_message(t('Failed to fetch file due to error "%error"', array('%error' => $exception->getMessage())), 'error');
+ return;
+ }
+
+ switch ($this->api_method)
+ {
+ case 'xml':
+ // Not supported yet.
+ return;
+ case 'json':
+ default:
+ $results = json_decode($results->getBody(), TRUE);
+ break;
+ }
+
+ if ($results['query']['results'])
+ {
+ // If the base object is specified, use that. Otherwise use the first object.
+ if (!empty($this->options['yql_base_object']) && isset($results['query']['results'][$this->options['yql_base_object']]))
+ {
+ $result_array = $results['query']['results'][$this->options['yql_base_object']];
+ }
+ else
+ {
+ $result_array = current($results['query']['results']);
+ }
+
+ $view->result = $result_array;
+
+ foreach ($view->result as $key => $value)
+ {
+ $view->result[$key] = new ResultRow($value);
+ }
+
+ // Save the metadata into the object
+ unset($results['query']['results']);
+ foreach ($results as $key => $value)
+ {
+ $this->$key = $value;
+ }
+ }
+ else
+ {
+ drupal_set_message('No results', 'error');
+ }
+
+ drupal_set_message("SQL: " . urldecode($query), 'status');
+
+ $this->pager->postExecute($view->result);
+ }
+ //dpm($url);
+ $view->execute_time = $this->float_microtime() - $start;
+ }
+
+ function float_microtime()
+ {
+ list($usec, $sec) = explode(' ', microtime());
+ return (float) $sec + (float) $usec;
+ }
+
+ function add_signature(&$view)
+ {
+ //$view->query->add_field(NULL, "'" . $view->name . ':' . $view->current_display . "'", 'view_name');
+ }
+
+ function defineOptions()
+ {
+ $options = parent::defineOptions();
+ $options['api_url'] = array('default' => 'http://query.yahooapis.com/v1/public/yql');
+ $options['api_method'] = array('default' => 'json');
+ $options['yql_base_table'] = array('default' => '');
+ $options['yql_custom_tables'] = array('default' => '');
+ $options['yql_base_object'] = array('default' => '');
+
+ $options['num_items'] = array('default' => 10);
+
+ return $options;
+ }
+
+ function buildOptionsForm(&$form, FormStateInterface $form_state)
+ {
+ $form['api_url'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Alternate API URL'),
+ '#default_value' => $this->options['api_url'],
+ '#description' => t("The URL YQL will be queried from (default: Yahoo! YQL Engine)."),
+ );
+
+ $form['api_method'] = array(
+ '#type' => 'select',
+ '#title' => t('API method'),
+ '#description' => t("The format of the data returned by YQL."),
+ '#default_value' => 'json',
+ '#options' => array(
+ 'json' => 'JSON',
+ ),
+ '#required' => TRUE,
+ );
+
+ $form['yql_base_table'] = array(
+ '#type' => 'textfield',
+ '#title' => t('YQL base table'),
+ '#default_value' => $this->options['yql_base_table'],
+ '#description' => t("A base table that view will be querying by using YQL to. Example: flickr.photos.recent"),
+ '#required' => TRUE,
+ );
+
+ $form['num_items'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Number of items'),
+ '#required' => TRUE,
+ '#description' => t('The number of items to be fetched from the base table. The number must be lesser than the remote limit of the base table, To get the remote limit of a table, see: ') . \Drupal::l('YQL Guide: Paging', \Drupal\Core\Url::fromUri('http://developer.yahoo.com/yql/guide/paging.html')) . '. NOTE: This amount of item will be fetched on every page of the view, so it might affect the performance of your site',
+ '#default_value' => $this->options['num_items'],
+ );
+
+ // @todo: add validation for custom open table.
+ $form['yql_custom_tables'] = array(
+ '#type' => 'textarea',
+ '#title' => t('Custom open tables.'),
+ '#default_value' => $this->options['yql_custom_tables'],
+ '#description' => t("Add custom table into the YQL Query.
Example:" . 'USE \'http://www.datatables.org/delicious/delicious.feeds.popular.xml\' AS delicious.feeds.popular;'),
+ );
+
+ $form['yql_base_object'] = array(
+ '#type' => 'textfield',
+ '#title' => t('YQL base object'),
+ '#default_value' => $this->options['yql_base_object'],
+ '#description' => t('The base object YQL will be querying from. If this is left empty, the first object in the result set will be taken as the base object'),
+ );
+ }
+
+ /**
+ * Add a field to the query table, possibly with an alias. This will
+ * automatically call ensure_table to make sure the required table
+ * exists, *unless* $table is unset.
+ *
+ * @param $table
+ * The table this field is attached to. If NULL, it is assumed this will
+ * be a formula; otherwise, ensure_table is used to make sure the
+ * table exists.
+ * @param $field
+ * The name of the field to add. This may be a real field or a formula.
+ * @param $alias
+ * The alias to create. If not specified, the alias will be $table_$field
+ * unless $table is NULL. When adding formulae, it is recommended that an
+ * alias be used.
+ * @param $params
+ * An array of parameters additional to the field that will control items
+ * such as aggregation functions and DISTINCT.
+ *
+ * @return $name
+ * The name that this field can be referred to as. Usually this is the alias.
+ */
+ function add_field($table, $field, $alias = '', $params = array())
+ {
+ // We can't use any alias in YQL query, so just use the real field name.
+ $alias = $field;
+
+ // Create a field info array.
+ $field_info = array(
+ 'field' => $field,
+ 'table' => $table,
+ 'alias' => $alias,
+ ) + $params;
+
+ if (empty($this->fields[$alias]))
+ {
+ $this->fields[$alias] = $field_info;
+ }
+
+ return $alias;
+ }
+
+ /**
+ * Add an ORDER BY clause to the query.
+ *
+ * @param $table
+ * The table this field is part of. If a formula, enter NULL.
+ * @param $field
+ * The field or formula to sort on. If already a field, enter NULL
+ * and put in the alias.
+ * @param $order
+ * Either ASC or DESC.
+ * @param $alias
+ * The alias to add the field as. In SQL, all fields in the order by
+ * must also be in the SELECT portion. If an $alias isn't specified
+ * one will be generated for from the $field; however, if the
+ * $field is a formula, this alias will likely fail.
+ * @param $params
+ * Any params that should be passed through to the add_field.
+ */
+ function add_orderby($table, $field, $order, $alias = '', $params = array())
+ {
+ // We can't use any alias in YQL query, so just use the real field name.
+ $as = $alias = $field;
+
+ if ($field)
+ {
+ $as = $this->add_field($table, $field, $as, $params);
+ }
+
+ $orderby = array(
+ 'field' => $as,
+ 'order' => $order,
+ );
+
+ $this->orderby[] = $orderby;
+ }
+}
diff --git a/src/Plugin/views/sort/Column.php b/src/Plugin/views/sort/Column.php
new file mode 100644
index 0000000..c1d9ec6
--- /dev/null
+++ b/src/Plugin/views/sort/Column.php
@@ -0,0 +1,67 @@
+ '');
+
+ return $options;
+ }
+
+ public function buildOptionsForm(&$form, FormStateInterface $form_state)
+ {
+ parent::buildOptionsForm($form, $form_state);
+
+ $form['field_name'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Field name'),
+ '#description' => t('The field name that the sorting will be done from. NOTE: Only the first field name in the sort handler that will be taken for sorting.'),
+ '#default_value' => $this->options['field_name'],
+ '#required' => TRUE,
+ );
+ }
+
+ function query()
+ {
+ $this->query->add_orderby($this->table_alias, $this->options['field_name'], $this->options['order']);
+ }
+
+ function adminSummary()
+ {
+ $field = $this->options['field_name'];
+
+ if (!empty($this->options['exposed']))
+ {
+ return $field . ' ' . t('Exposed');
+ }
+
+ switch ($this->options['order'])
+ {
+ case 'ASC':
+ case 'asc':
+ default:
+ return $field . ' ' . t('asc');
+ break;
+ case 'DESC':
+ case 'desc':
+ return $field . ' ' . t('desc');
+ break;
+ }
+ }
+}
diff --git a/yql_views_query.info b/yql_views_query.info
deleted file mode 100644
index 44d8bd7..0000000
--- a/yql_views_query.info
+++ /dev/null
@@ -1,15 +0,0 @@
-name = YQL Views Query Backend
-description = Enables Views to query Yahoo Query Language (YQL).
-package = Views
-dependencies[] = views
-core = 7.x
-
-files[] = yql_views_query_plugin_query_yql.inc
-files[] = handlers/yql_views_query_handler_argument.inc
-files[] = handlers/yql_views_query_handler_argument_column.inc
-files[] = handlers/yql_views_query_handler_field.inc
-files[] = handlers/yql_views_query_handler_field_column.inc
-files[] = handlers/yql_views_query_handler_filter.inc
-files[] = handlers/yql_views_query_handler_filter_column.inc
-files[] = handlers/yql_views_query_handler_sort.inc
-files[] = handlers/yql_views_query_handler_sort_column.inc
diff --git a/yql_views_query.info.yml b/yql_views_query.info.yml
new file mode 100644
index 0000000..fc54f54
--- /dev/null
+++ b/yql_views_query.info.yml
@@ -0,0 +1,7 @@
+name: 'YQL Views Query Backend'
+description: 'Enables Views to query Yahoo Query Language (YQL).'
+package: Views
+dependencies:
+ - views
+core: 8.x
+type: module
diff --git a/yql_views_query.module b/yql_views_query.module
deleted file mode 100644
index ceef16d..0000000
--- a/yql_views_query.module
+++ /dev/null
@@ -1,15 +0,0 @@
- 3,
- 'path' => drupal_get_path('module', 'yql_views_query'),
- );
-}
diff --git a/yql_views_query.views.inc b/yql_views_query.views.inc
index 4a92944..9aaed33 100644
--- a/yql_views_query.views.inc
+++ b/yql_views_query.views.inc
@@ -8,87 +8,38 @@
* @todo Please document this function.
* @see http://drupal.org/node/1354
*/
-function yql_views_query_views_data() {
- $data['yql']['table']['group'] = t('YQL');
+function yql_views_query_views_data ()
+{
+ $data = array();
+
+ $data['yql']['table']['group'] = t('YQL');
- $data['yql']['table']['base'] = array(
- 'title' => t('YQL Query: Flexible'),
- 'help' => t('Flexible querying from YQL endpoint.'),
- 'query class' => 'yql_query',
- );
+ $data['yql']['table']['base'] = array(
+ 'title' => t('YQL Query: Flexible'),
+ 'help' => t('Flexible querying from YQL endpoint.'),
+ 'query_id' => 'column',
+ );
- $data['yql']['column'] = array(
- 'title' => t('Column'),
- 'help' => t('Add/filter the value of a column in the table.'),
- 'field' => array(
- 'handler' => 'yql_views_query_handler_field_column',
- ),
- 'filter' => array(
- 'handler' => 'yql_views_query_handler_filter_column',
- ),
- 'sort' => array(
- 'handler' => 'yql_views_query_handler_sort_column',
- ),
- 'argument' => array(
- 'handler' => 'yql_views_query_handler_argument_column',
- ),
- );
+ $data['yql']['column'] = array(
+ 'title' => t('Column'),
+ 'help' => t('Add/filter the value of a column in the table.'),
+ 'field' => array(
+ 'title' => t('Column'),
+ 'id' => 'column',
+ ),
+ 'filter' => array(
+ 'title' => t('Column'),
+ 'id' => 'column',
+ ),
+ 'sort' => array(
+ 'title' => t('Column'),
+ 'id' => 'column',
+ ),
+ 'argument' => array(
+ 'title' => t('Column'),
+ 'id' => 'column',
+ ),
+ );
- return $data;
-}
-
-/**
- * Implements hook_views_handlers().
- */
-function yql_views_query_views_handlers() {
- return array(
- 'info' => array(
- 'path' => drupal_get_path('module', 'yql_views_query') . '/handlers',
- ),
- 'handlers' => array(
- // Fields
- 'yql_views_query_handler_field' => array(
- 'parent' => 'views_handler_field',
- ),
- 'yql_views_query_handler_field_column' => array(
- 'parent' => 'yql_views_query_handler_field',
- ),
- // Filters
- 'yql_views_query_handler_filter' => array(
- 'parent' => 'views_handler_filter',
- ),
- 'yql_views_query_handler_filter_column' => array(
- 'parent' => 'yql_views_query_handler_filter',
- ),
- // Sort handlers
- 'yql_views_query_handler_sort' => array(
- 'parent' => 'views_handler_sort',
- ),
- 'yql_views_query_handler_sort_column' => array(
- 'parent' => 'yql_views_query_handler_sort',
- ),
- // Argument handlers
- 'yql_views_query_handler_argument' => array(
- 'parent' => 'views_handler_argument',
- ),
- 'yql_views_query_handler_argument_column' => array(
- 'parent' => 'yql_views_query_handler_argument',
- ),
- ),
- );
-}
-
-/**
- * Implements hook_views_plugins().
- */
-function yql_views_query_views_plugins() {
- return array(
- 'query' => array(
- 'yql_query' => array(
- 'title' => t('YQL Query'),
- 'help' => t('Query will be generated and run using YQL.'),
- 'handler' => 'yql_views_query_plugin_query_yql',
- ),
- ),
- );
-}
+ return $data;
+}
\ No newline at end of file
diff --git a/yql_views_query.views_default.inc b/yql_views_query.views_default.inc
deleted file mode 100644
index 87a6606..0000000
--- a/yql_views_query.views_default.inc
+++ /dev/null
@@ -1,403 +0,0 @@
-name = 'yql_flickr_photos_recent';
- $view->description = 'YQL Example: List out the latest photos from Flickr with YQL';
- $view->tag = 'YQL demo';
- $view->view_php = '';
- $view->base_table = 'yql';
- $view->is_cacheable = FALSE;
- $view->api_version = '3.0-alpha1';
- $view->disabled = TRUE; /* Edit this to true to make a default view disabled initially */
-
- /* Display: Defaults */
- $handler = $view->new_display('default', 'Defaults', 'default');
- $handler->display->display_options['title'] = 'Example YQL Views Page: Flickr Recent Photos';
- $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']['api_url'] = '';
- $handler->display->display_options['query']['options']['yql_base_table'] = 'flickr.photos.recent';
- $handler->display->display_options['query']['options']['num_items'] = '10';
- $handler->display->display_options['exposed_form']['type'] = 'basic';
- $handler->display->display_options['pager']['type'] = 'full';
- $handler->display->display_options['style_plugin'] = 'table';
- $handler->display->display_options['style_options']['columns'] = array(
- 'column' => 'column',
- 'column_2' => 'column_2',
- 'column_1' => 'column_1',
- 'nothing' => 'nothing',
- );
- $handler->display->display_options['style_options']['default'] = '-1';
- $handler->display->display_options['style_options']['info'] = array(
- 'column' => array(
- 'align' => '',
- 'separator' => '',
- ),
- 'column_2' => array(
- 'align' => '',
- 'separator' => '',
- ),
- 'column_1' => array(
- 'align' => '',
- 'separator' => '',
- ),
- 'nothing' => array(
- 'align' => '',
- 'separator' => '',
- ),
- );
- $handler->display->display_options['style_options']['override'] = 1;
- $handler->display->display_options['style_options']['sticky'] = 0;
- /* Field: YQL: Column */
- $handler->display->display_options['fields']['column']['id'] = 'column';
- $handler->display->display_options['fields']['column']['table'] = 'yql';
- $handler->display->display_options['fields']['column']['field'] = 'column';
- $handler->display->display_options['fields']['column']['label'] = 'title';
- $handler->display->display_options['fields']['column']['alter']['alter_text'] = 0;
- $handler->display->display_options['fields']['column']['alter']['make_link'] = 0;
- $handler->display->display_options['fields']['column']['alter']['absolute'] = 0;
- $handler->display->display_options['fields']['column']['alter']['trim'] = 0;
- $handler->display->display_options['fields']['column']['alter']['word_boundary'] = 1;
- $handler->display->display_options['fields']['column']['alter']['ellipsis'] = 1;
- $handler->display->display_options['fields']['column']['alter']['strip_tags'] = 0;
- $handler->display->display_options['fields']['column']['alter']['html'] = 0;
- $handler->display->display_options['fields']['column']['hide_empty'] = 0;
- $handler->display->display_options['fields']['column']['empty_zero'] = 0;
- $handler->display->display_options['fields']['column']['field_name'] = 'title';
- /* Field: YQL: Column */
- $handler->display->display_options['fields']['column_2']['id'] = 'column_2';
- $handler->display->display_options['fields']['column_2']['table'] = 'yql';
- $handler->display->display_options['fields']['column_2']['field'] = 'column';
- $handler->display->display_options['fields']['column_2']['label'] = 'owner';
- $handler->display->display_options['fields']['column_2']['alter']['alter_text'] = 0;
- $handler->display->display_options['fields']['column_2']['alter']['make_link'] = 0;
- $handler->display->display_options['fields']['column_2']['alter']['absolute'] = 0;
- $handler->display->display_options['fields']['column_2']['alter']['trim'] = 0;
- $handler->display->display_options['fields']['column_2']['alter']['word_boundary'] = 1;
- $handler->display->display_options['fields']['column_2']['alter']['ellipsis'] = 1;
- $handler->display->display_options['fields']['column_2']['alter']['strip_tags'] = 0;
- $handler->display->display_options['fields']['column_2']['alter']['html'] = 0;
- $handler->display->display_options['fields']['column_2']['hide_empty'] = 0;
- $handler->display->display_options['fields']['column_2']['empty_zero'] = 0;
- $handler->display->display_options['fields']['column_2']['field_name'] = 'owner';
- /* Field: YQL: Column */
- $handler->display->display_options['fields']['column_1']['id'] = 'column_1';
- $handler->display->display_options['fields']['column_1']['table'] = 'yql';
- $handler->display->display_options['fields']['column_1']['field'] = 'column';
- $handler->display->display_options['fields']['column_1']['label'] = 'id';
- $handler->display->display_options['fields']['column_1']['alter']['alter_text'] = 0;
- $handler->display->display_options['fields']['column_1']['alter']['make_link'] = 0;
- $handler->display->display_options['fields']['column_1']['alter']['absolute'] = 0;
- $handler->display->display_options['fields']['column_1']['alter']['trim'] = 0;
- $handler->display->display_options['fields']['column_1']['alter']['word_boundary'] = 1;
- $handler->display->display_options['fields']['column_1']['alter']['ellipsis'] = 1;
- $handler->display->display_options['fields']['column_1']['alter']['strip_tags'] = 0;
- $handler->display->display_options['fields']['column_1']['alter']['html'] = 0;
- $handler->display->display_options['fields']['column_1']['hide_empty'] = 0;
- $handler->display->display_options['fields']['column_1']['empty_zero'] = 0;
- $handler->display->display_options['fields']['column_1']['field_name'] = 'id';
- /* Field: Global: Custom text */
- $handler->display->display_options['fields']['nothing']['id'] = 'nothing';
- $handler->display->display_options['fields']['nothing']['table'] = 'views';
- $handler->display->display_options['fields']['nothing']['field'] = 'nothing';
- $handler->display->display_options['fields']['nothing']['label'] = 'See in Flickr';
- $handler->display->display_options['fields']['nothing']['alter']['text'] = 'Link';
- $handler->display->display_options['fields']['nothing']['alter']['make_link'] = 1;
- $handler->display->display_options['fields']['nothing']['alter']['path'] = 'http://flickr.com/photos/[column_2]/[column_1]/';
- $handler->display->display_options['fields']['nothing']['alter']['absolute'] = 1;
- $handler->display->display_options['fields']['nothing']['alter']['trim'] = 0;
- $handler->display->display_options['fields']['nothing']['alter']['word_boundary'] = 1;
- $handler->display->display_options['fields']['nothing']['alter']['ellipsis'] = 1;
- $handler->display->display_options['fields']['nothing']['alter']['strip_tags'] = 0;
- $handler->display->display_options['fields']['nothing']['alter']['html'] = 0;
- $handler->display->display_options['fields']['nothing']['hide_empty'] = 0;
- $handler->display->display_options['fields']['nothing']['empty_zero'] = 0;
-
- /* Display: Page */
- $handler = $view->new_display('page', 'Page', 'page_1');
- $handler->display->display_options['path'] = 'yql_flickr_photos_recent';
- $views[$view->name] = $view;
-
- /*
- * View 'yql_sushi'
- */
- $view = new view;
- $view->name = 'yql_sushi';
- $view->description = 'YQL Example: List out sushi restaurant in a location with YQL';
- $view->tag = 'YQL demo';
- $view->view_php = '';
- $view->base_table = 'yql';
- $view->is_cacheable = FALSE;
- $view->api_version = '3.0-alpha1';
- $view->disabled = TRUE; /* Edit this to true to make a default view disabled initially */
-
- /* Display: Defaults */
- $handler = $view->new_display('default', 'Defaults', 'default');
- $handler->display->display_options['title'] = 'Example YQL Views Page: \'Sushi\' Restaurant';
- $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']['api_url'] = '';
- $handler->display->display_options['query']['options']['yql_base_table'] = 'local.search';
- $handler->display->display_options['query']['options']['num_items'] = '30';
- $handler->display->display_options['exposed_form']['type'] = 'basic';
- $handler->display->display_options['pager']['type'] = 'full';
- $handler->display->display_options['style_plugin'] = 'table';
- $handler->display->display_options['style_options']['columns'] = array(
- 'column' => 'column',
- 'column_1' => 'column_1',
- );
- $handler->display->display_options['style_options']['default'] = '-1';
- $handler->display->display_options['style_options']['info'] = array(
- 'column' => array(
- 'align' => '',
- 'separator' => '',
- ),
- 'column_1' => array(
- 'align' => '',
- 'separator' => '',
- ),
- );
- $handler->display->display_options['style_options']['override'] = 1;
- $handler->display->display_options['style_options']['sticky'] = 0;
- /* Field: YQL: Column */
- $handler->display->display_options['fields']['column']['id'] = 'column';
- $handler->display->display_options['fields']['column']['table'] = 'yql';
- $handler->display->display_options['fields']['column']['field'] = 'column';
- $handler->display->display_options['fields']['column']['label'] = 'Title';
- $handler->display->display_options['fields']['column']['alter']['alter_text'] = 0;
- $handler->display->display_options['fields']['column']['alter']['make_link'] = 0;
- $handler->display->display_options['fields']['column']['alter']['trim'] = 0;
- $handler->display->display_options['fields']['column']['alter']['word_boundary'] = 1;
- $handler->display->display_options['fields']['column']['alter']['ellipsis'] = 1;
- $handler->display->display_options['fields']['column']['alter']['strip_tags'] = 0;
- $handler->display->display_options['fields']['column']['alter']['html'] = 0;
- $handler->display->display_options['fields']['column']['hide_empty'] = 0;
- $handler->display->display_options['fields']['column']['empty_zero'] = 0;
- $handler->display->display_options['fields']['column']['field_name'] = 'Title';
- /* Field: YQL: Column */
- $handler->display->display_options['fields']['column_2']['id'] = 'column_2';
- $handler->display->display_options['fields']['column_2']['table'] = 'yql';
- $handler->display->display_options['fields']['column_2']['field'] = 'column';
- $handler->display->display_options['fields']['column_2']['label'] = 'Address';
- $handler->display->display_options['fields']['column_2']['alter']['alter_text'] = 0;
- $handler->display->display_options['fields']['column_2']['alter']['make_link'] = 0;
- $handler->display->display_options['fields']['column_2']['alter']['trim'] = 0;
- $handler->display->display_options['fields']['column_2']['alter']['word_boundary'] = 1;
- $handler->display->display_options['fields']['column_2']['alter']['ellipsis'] = 1;
- $handler->display->display_options['fields']['column_2']['alter']['strip_tags'] = 0;
- $handler->display->display_options['fields']['column_2']['alter']['html'] = 0;
- $handler->display->display_options['fields']['column_2']['hide_empty'] = 0;
- $handler->display->display_options['fields']['column_2']['empty_zero'] = 0;
- $handler->display->display_options['fields']['column_2']['field_name'] = 'Address';
- /* Field: YQL: Column */
- $handler->display->display_options['fields']['column_1']['id'] = 'column_1';
- $handler->display->display_options['fields']['column_1']['table'] = 'yql';
- $handler->display->display_options['fields']['column_1']['field'] = 'column';
- $handler->display->display_options['fields']['column_1']['label'] = 'Rating.AverageRating';
- $handler->display->display_options['fields']['column_1']['alter']['alter_text'] = 0;
- $handler->display->display_options['fields']['column_1']['alter']['make_link'] = 0;
- $handler->display->display_options['fields']['column_1']['alter']['trim'] = 0;
- $handler->display->display_options['fields']['column_1']['alter']['word_boundary'] = 1;
- $handler->display->display_options['fields']['column_1']['alter']['ellipsis'] = 1;
- $handler->display->display_options['fields']['column_1']['alter']['strip_tags'] = 0;
- $handler->display->display_options['fields']['column_1']['alter']['html'] = 0;
- $handler->display->display_options['fields']['column_1']['hide_empty'] = 0;
- $handler->display->display_options['fields']['column_1']['empty_zero'] = 0;
- $handler->display->display_options['fields']['column_1']['field_name'] = 'Rating.AverageRating';
- /* Sort criterion: YQL: Column */
- $handler->display->display_options['sorts']['column']['id'] = 'column';
- $handler->display->display_options['sorts']['column']['table'] = 'yql';
- $handler->display->display_options['sorts']['column']['field'] = 'column';
- $handler->display->display_options['sorts']['column']['order'] = 'DESC';
- $handler->display->display_options['sorts']['column']['field_name'] = 'Rating.AverageRating';
- /* Filter: YQL: Column */
- $handler->display->display_options['filters']['column']['id'] = 'column';
- $handler->display->display_options['filters']['column']['table'] = 'yql';
- $handler->display->display_options['filters']['column']['field'] = 'column';
- $handler->display->display_options['filters']['column']['value'] = 'sushi';
- $handler->display->display_options['filters']['column']['case'] = 1;
- $handler->display->display_options['filters']['column']['field_name'] = 'query';
- /* Filter: YQL: Column */
- $handler->display->display_options['filters']['column_1']['id'] = 'column_1';
- $handler->display->display_options['filters']['column_1']['table'] = 'yql';
- $handler->display->display_options['filters']['column_1']['field'] = 'column';
- $handler->display->display_options['filters']['column_1']['value'] = 'san fransisco, ca';
- $handler->display->display_options['filters']['column_1']['exposed'] = TRUE;
- $handler->display->display_options['filters']['column_1']['expose']['operator'] = 'column_1_op';
- $handler->display->display_options['filters']['column_1']['expose']['label'] = 'Location';
- $handler->display->display_options['filters']['column_1']['expose']['use_operator'] = 0;
- $handler->display->display_options['filters']['column_1']['expose']['identifier'] = 'column_1';
- $handler->display->display_options['filters']['column_1']['case'] = 1;
- $handler->display->display_options['filters']['column_1']['field_name'] = 'location';
-
- /* Display: Page */
- $handler = $view->new_display('page', 'Page', 'page_1');
- $handler->display->display_options['path'] = 'yql_sushi';
- $views[$view->name] = $view;
-
-
- /*
- * View 'yql_tables'
- */
- $view = new view;
- $view->name = 'yql_tables';
- $view->description = 'YQL Example: A demonstration list with some tables accessible with YQL, and some help text';
- $view->tag = 'YQL demo';
- $view->view_php = '';
- $view->base_table = 'yql';
- $view->is_cacheable = FALSE;
- $view->api_version = '3.0-alpha1';
- $view->disabled = TRUE; /* Edit this to true to make a default view disabled initially */
-
- /* Display: YQL tables */
- $handler = $view->new_display('default', 'YQL tables', 'default');
- $handler->display->display_options['title'] = 'Example YQL Views page';
- $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']['api_url'] = '';
- $handler->display->display_options['query']['options']['yql_base_table'] = 'yql.tables';
- $handler->display->display_options['query']['options']['num_items'] = '50';
- $handler->display->display_options['exposed_form']['type'] = 'basic';
- $handler->display->display_options['pager']['type'] = 'full';
- $handler->display->display_options['style_plugin'] = 'table';
- $handler->display->display_options['style_options']['columns'] = array(
- 'counter' => 'counter',
- 'column_3' => 'column_3',
- 'column' => 'column',
- );
- $handler->display->display_options['style_options']['default'] = '-1';
- $handler->display->display_options['style_options']['info'] = array(
- 'counter' => array(
- 'align' => '',
- 'separator' => '',
- ),
- 'column_3' => array(
- 'align' => '',
- 'separator' => '',
- ),
- 'column' => array(
- 'align' => '',
- 'separator' => '',
- ),
- );
- $handler->display->display_options['style_options']['override'] = 1;
- $handler->display->display_options['style_options']['sticky'] = 0;
- /* Header: Global: Text area */
- $handler->display->display_options['header']['area']['id'] = 'area';
- $handler->display->display_options['header']['area']['table'] = 'views';
- $handler->display->display_options['header']['area']['field'] = 'area';
- $handler->display->display_options['header']['area']['label'] = 'Help text';
- $handler->display->display_options['header']['area']['empty'] = TRUE;
- $handler->display->display_options['header']['area']['content'] = 'This view displays the first 50 of the tables available with Yahoo! Query Language. The full list can be viewed in the YQL Console at the Yahoo! Developer Network.';
- $handler->display->display_options['header']['area']['format'] = '1';
- /* Footer: Global: Text area */
- $handler->display->display_options['footer']['area']['id'] = 'area';
- $handler->display->display_options['footer']['area']['table'] = 'views';
- $handler->display->display_options['footer']['area']['field'] = 'area';
- $handler->display->display_options['footer']['area']['label'] = 'More help text';
- $handler->display->display_options['footer']['area']['empty'] = TRUE;
- $handler->display->display_options['footer']['area']['content'] = 'Note that many YQL statements use different source tables than the default YQL table. These source tables can be viewed in the YQL console at the Yahoo! developer network. Any non-standard source table should be entered in the query settings (under advanced settings) using the form USE \'http://www.datatables.org/arxiv/arxiv.search.xml\' AS arxiv.search;.
-
- Any queries should be added as filters, on the form where field name = value.';
- $handler->display->display_options['footer']['area']['format'] = '1';
- /* Field: YQL: Column */
- $handler->display->display_options['fields']['column']['id'] = 'column';
- $handler->display->display_options['fields']['column']['table'] = 'yql';
- $handler->display->display_options['fields']['column']['field'] = 'column';
- $handler->display->display_options['fields']['column']['label'] = 'Table name';
- $handler->display->display_options['fields']['column']['alter']['alter_text'] = 0;
- $handler->display->display_options['fields']['column']['alter']['make_link'] = 0;
- $handler->display->display_options['fields']['column']['alter']['absolute'] = 0;
- $handler->display->display_options['fields']['column']['alter']['trim'] = 0;
- $handler->display->display_options['fields']['column']['alter']['word_boundary'] = 1;
- $handler->display->display_options['fields']['column']['alter']['ellipsis'] = 1;
- $handler->display->display_options['fields']['column']['alter']['strip_tags'] = 0;
- $handler->display->display_options['fields']['column']['alter']['html'] = 0;
- $handler->display->display_options['fields']['column']['hide_empty'] = 0;
- $handler->display->display_options['fields']['column']['empty_zero'] = 0;
- $handler->display->display_options['fields']['column']['field_name'] = 'name';
- /* Field: YQL: Column */
- $handler->display->display_options['fields']['column_1']['id'] = 'column_1';
- $handler->display->display_options['fields']['column_1']['table'] = 'yql';
- $handler->display->display_options['fields']['column_1']['field'] = 'column';
- $handler->display->display_options['fields']['column_1']['label'] = 'Access';
- $handler->display->display_options['fields']['column_1']['alter']['alter_text'] = 0;
- $handler->display->display_options['fields']['column_1']['alter']['make_link'] = 0;
- $handler->display->display_options['fields']['column_1']['alter']['absolute'] = 0;
- $handler->display->display_options['fields']['column_1']['alter']['trim'] = 0;
- $handler->display->display_options['fields']['column_1']['alter']['word_boundary'] = 1;
- $handler->display->display_options['fields']['column_1']['alter']['ellipsis'] = 1;
- $handler->display->display_options['fields']['column_1']['alter']['strip_tags'] = 0;
- $handler->display->display_options['fields']['column_1']['alter']['html'] = 0;
- $handler->display->display_options['fields']['column_1']['hide_empty'] = 0;
- $handler->display->display_options['fields']['column_1']['empty_zero'] = 0;
- $handler->display->display_options['fields']['column_1']['field_name'] = 'security';
- /* Field: YQL: Column */
- $handler->display->display_options['fields']['column_2']['id'] = 'column_2';
- $handler->display->display_options['fields']['column_2']['table'] = 'yql';
- $handler->display->display_options['fields']['column_2']['field'] = 'column';
- $handler->display->display_options['fields']['column_2']['label'] = '';
- $handler->display->display_options['fields']['column_2']['exclude'] = TRUE;
- $handler->display->display_options['fields']['column_2']['alter']['alter_text'] = 0;
- $handler->display->display_options['fields']['column_2']['alter']['make_link'] = 0;
- $handler->display->display_options['fields']['column_2']['alter']['absolute'] = 0;
- $handler->display->display_options['fields']['column_2']['alter']['trim'] = 0;
- $handler->display->display_options['fields']['column_2']['alter']['word_boundary'] = 1;
- $handler->display->display_options['fields']['column_2']['alter']['ellipsis'] = 1;
- $handler->display->display_options['fields']['column_2']['alter']['strip_tags'] = 0;
- $handler->display->display_options['fields']['column_2']['alter']['html'] = 0;
- $handler->display->display_options['fields']['column_2']['hide_empty'] = 0;
- $handler->display->display_options['fields']['column_2']['empty_zero'] = 0;
- $handler->display->display_options['fields']['column_2']['field_name'] = 'meta.documentation';
- /* Field: YQL: Column */
- $handler->display->display_options['fields']['column_3']['id'] = 'column_3';
- $handler->display->display_options['fields']['column_3']['table'] = 'yql';
- $handler->display->display_options['fields']['column_3']['field'] = 'column';
- $handler->display->display_options['fields']['column_3']['label'] = '';
- $handler->display->display_options['fields']['column_3']['alter']['alter_text'] = 1;
- $handler->display->display_options['fields']['column_3']['alter']['text'] = 'Description: [column_3]
- Documentation link: [column_2]';
- $handler->display->display_options['fields']['column_3']['alter']['make_link'] = 0;
- $handler->display->display_options['fields']['column_3']['alter']['absolute'] = 0;
- $handler->display->display_options['fields']['column_3']['alter']['trim'] = 0;
- $handler->display->display_options['fields']['column_3']['alter']['word_boundary'] = 1;
- $handler->display->display_options['fields']['column_3']['alter']['ellipsis'] = 1;
- $handler->display->display_options['fields']['column_3']['alter']['strip_tags'] = 0;
- $handler->display->display_options['fields']['column_3']['alter']['html'] = 0;
- $handler->display->display_options['fields']['column_3']['hide_empty'] = 0;
- $handler->display->display_options['fields']['column_3']['empty_zero'] = 0;
- $handler->display->display_options['fields']['column_3']['field_name'] = 'description';
- /* Field: YQL: Column */
- $handler->display->display_options['fields']['column_4']['id'] = 'column_4';
- $handler->display->display_options['fields']['column_4']['table'] = 'yql';
- $handler->display->display_options['fields']['column_4']['field'] = 'column';
- $handler->display->display_options['fields']['column_4']['label'] = 'Sample query';
- $handler->display->display_options['fields']['column_4']['alter']['alter_text'] = 0;
- $handler->display->display_options['fields']['column_4']['alter']['make_link'] = 0;
- $handler->display->display_options['fields']['column_4']['alter']['absolute'] = 0;
- $handler->display->display_options['fields']['column_4']['alter']['trim'] = 0;
- $handler->display->display_options['fields']['column_4']['alter']['word_boundary'] = 1;
- $handler->display->display_options['fields']['column_4']['alter']['ellipsis'] = 1;
- $handler->display->display_options['fields']['column_4']['alter']['strip_tags'] = 0;
- $handler->display->display_options['fields']['column_4']['alter']['html'] = 0;
- $handler->display->display_options['fields']['column_4']['hide_empty'] = 0;
- $handler->display->display_options['fields']['column_4']['empty_zero'] = 0;
- $handler->display->display_options['fields']['column_4']['field_name'] = 'sampleQuery';
-
- /* Display: YQL tables (Page) */
- $handler = $view->new_display('page', 'YQL tables (Page)', 'page_1');
- $handler->display->display_options['defaults']['filters'] = FALSE;
- $handler->display->display_options['path'] = 'yql_tables';
- $views[$view->name] = $view;
-
- return $views;
-}
diff --git a/yql_views_query_plugin_query_yql.inc b/yql_views_query_plugin_query_yql.inc
deleted file mode 100644
index a04ba53..0000000
--- a/yql_views_query_plugin_query_yql.inc
+++ /dev/null
@@ -1,468 +0,0 @@
-api_url = !empty($this->options['api_url']) ? $this->options['api_url'] : 'http://query.yahooapis.com/v1/public/yql';
- $this->api_method = $this->options['api_method'] ? $this->options['api_method'] : 'json';
- $this->yql_base_table = $this->options['yql_base_table'];
- }
-
- /**
- * Construct the "WHERE" or "HAVING" part of the query.
- *
- * @param $where
- * 'where' or 'having'.
- */
- function condition_query($where = 'where') {
- $clauses = array();
- foreach ($this->$where as $group => $info) {
- if (empty($info['clauses'])) {
- continue;
- }
- $clause = implode(") " . $info['type'] . " (", $info['clauses']);
- if (count($info['clauses']) > 1) {
- $clause = '(' . $clause . ')';
- }
- $clauses[] = $clause;
- }
-
- if ($clauses) {
- $keyword = drupal_strtoupper($where);
- if (count($clauses) > 1) {
- return "$keyword (" . implode(")\n " . $this->group_operator . ' (', array_filter($clauses)) . ")\n";
- }
- else {
- return "$keyword " . array_shift($clauses) . "\n";
- }
- }
- return "";
- }
-
- function use_pager() {
- return FALSE;
- }
-
- /**
- * Generate a query and a countquery from all of the information supplied
- * to the object.
- *
- * @param $get_count
- * Provide a countquery if this is true, otherwise provide a normal query.
- */
- function query($get_count = FALSE) {
- $query = '';
-
- // Add the where clauses
- $where = ' ' . $this->condition_query();
-
- // Add the field clauses
- $fields = '';
- $fields_array = $this->fields;
- foreach ($fields_array as $alias => $field) {
- if (!empty($fields)) {
- $fields .= ', ';
- }
- $fields .= $field['field'];
- }
- // Add the base table
- $from = $this->yql_base_table;
-
- // Add sort function
- if (isset($this->orderby) && $this->orderby) {
- // Only get the first orderby
- $orderby_field = current($this->orderby);
- $orderby = " | sort(field=\"" . $orderby_field['field'] . "\")";
-
- switch ($orderby_field['order']) {
- case 'ASC':
- case 'asc':
- // Do nothing. This is added only for clarity.
- break;
-
- case 'DESC':
- case 'desc':
- $orderby = $orderby . ' | reverse()';
- break;
-
- default:
- break;
- }
- }
-
- // Build the query string
- $query = "SELECT $fields FROM $from";
- if (!empty($where)) {
- $query = "$query $where";
- }
- // Add table definitions
- if (!empty($this->options['yql_custom_tables'])) {
- $query = $this->options['yql_custom_tables'] . $query;
- }
-
- // Add sort definitions
- if (!empty($orderby)) {
- $query = $query . $orderby;
- }
- return $query;
- }
-
-
- /**
- * Get the arguments attached to the WHERE and HAVING clauses of this query.
- */
- function get_where_args() {
- $args = array();
- foreach ($this->where as $group => $where) {
- $args = array_merge($args, $where['args']);
- }
-
- if (isset($this->having) && $this->having) {
- foreach ($this->having as $group => $having) {
- $args = array_merge($args, $having['args']);
- }
- }
- return $args;
- }
-
- function add_param($param, $value = '') {
- $this->params[$param] = $value;
- }
-
- function add_where($group, $clause) {
- $args = func_get_args();
- array_shift($args); // ditch $group
- array_shift($args); // ditch $clause
-
- // Expand an array of args if it came in.
- if (count($args) == 1 && is_array(reset($args))) {
- $args = current($args);
- }
-
- // Ensure all variants of 0 are actually 0. Thus '', 0 and NULL are all
- // the default group.
- if (empty($group)) {
- $group = 0;
- }
-
- // Check for a group.
- if (!isset($this->where[$group])) {
- $this->set_where_group('AND', $group);
- }
-
- // Add the clause and the args.
- if (is_array($args)) {
- $this->where[$group]['clauses'][] = $clause;
- // we use array_values() here to prevent array_merge errors as keys from multiple
- // sources occasionally collide.
- $this->where[$group]['args'] = array_merge($this->where[$group]['args'], array_values($args));
- }
- }
-
- /**
- * Let modules modify the query just prior to finalizing it.
- */
- function alter(&$view) {
- foreach (module_implements('yql_views_query_query_alter') as $module) {
- $function = $module . '_yql_views_query_query_alter';
- $function($view, $this);
- }
- }
-
- /**
- * Builds the necessary info to execute the query.
- */
- function build(&$view) {
- $view->init_pager($view);
-
- // Let the pager modify the query to add limits.
- $this->pager->query();
-
- $view->build_info['query'] = $this->query($view);
- //$view->build_info['count_query'] = $this->query($view, TRUE);
- $view->build_info['count_query'] = '';
- $view->build_info['query_args'] = $this->get_where_args();
- }
-
- /**
- * Alter the query for paging settings. This should only be called
- * if the view is using pager.
- * @param $query
- * The query to be altered
- * @param $limit
- * The number of items limit
- * @param $offset
- * The offset from the first item
- */
- function _query_alter_limit(&$query, $limit, $offset) {
- $base_table = $this->options['yql_base_table'];
- // $total_aggregate_items = $offset + $limit;
-
- // @todo if there is a better way, fix this!
- $total_aggregate_items = $this->options['num_items'];
-
- $query = str_replace('FROM ' . $base_table, 'FROM ' . $base_table . '(0,' . $total_aggregate_items . ')', $query);
-
- /*
- // If sort function is specified, the limit and offset should be put
- // before the sort function
- if ($sort_found = strpos($query, '|')) {
- $query = substr($query, 0, $sort_found -1) . "limit $limit offset $offset " . substr($query, $sort_found);
- }
- else {
- $query .= " limit $limit offset $offset";
- }
- */
-
- $current_tail = $offset + $limit;
- $query = $query . " | truncate(count=$current_tail) | tail(count=$limit)";
- }
-
- /**
- * Executes the query and fills the associated view object with according
- * values.
- *
- * Values to set: $view->result, $view->total_rows, $view->execute_time,
- * $view->pager['current_page'].
- */
- function execute(&$view) {
- $query = $view->build_info['query'];
- $args = $view->build_info['query_args'];
-
- if ($query) {
- // Initialize, alter and set the pager settings before executing
- if ($this->pager->use_pager()) {
- $this->pager->total_items = $this->options['num_items'];
- $view->total_rows = $this->options['num_items'];
-
- if (!empty($this->pager->options['offset'])) {
- $this->pager->total_items -= $this->pager->options['offset'];
- }
- $this->pager->update_page_info();
- }
-
- // We can't have an offset without a limit, so provide an upperbound limit instead.
- $limit = intval(!empty($this->limit) ? $this->limit : $this->options['num_items']);
- $offset = intval(!empty($this->offset) ? $this->offset : 0);
- $this->_query_alter_limit($query, $limit, $offset);
-
- // Let the pager modify the query to add limits.
- $this->pager->pre_execute($query, $args);
-
- $replacements = module_invoke_all('views_query_substitutions', $view);
- $query = str_replace(array_keys($replacements), $replacements, $query);
-
- // Encode the query into URL friendly format
- $query = urlencode($query);
- $format_string = $this->api_method == 'json' ? '&format=json' : '&format=xml';
- $url = $this->api_url . '?q=' . $query . $format_string;
-
- $start = $this->float_microtime();
-
- $results = drupal_http_request($url, array('headers' => array()));
-
- // There is an error in the HTTP request
- if (isset($results->error)) {
- // If the error comes from YQL query, print the YQL error details.
- if (isset($results->data)) {
- $yql_error = json_decode($results->data, TRUE);
- drupal_set_message("YQL query error: " . $yql_error['error']['description'], 'error');
- }
- // Otherwise, the error comes from HTTP request error.
- else {
- drupal_set_message("HTTP request error: " . $results->error, 'error');
- }
- return;
- }
-
- switch ($this->api_method) {
- case 'xml':
- // Not supported yet.
- return;
- case 'json':
- default:
- $results = json_decode($results->data, TRUE);
- break;
- }
-
- if ($results['query']['results']) {
- // If the base object is specified, use that. Otherwise use the first object.
- if (!empty($this->options['yql_base_object']) && isset($results['query']['results'][$this->options['yql_base_object']])) {
- $result_array = $results['query']['results'][$this->options['yql_base_object']];
- }
- else {
- $result_array = current($results['query']['results']);
- }
-
- $view->result = $result_array;
-
- foreach ($view->result as $key => $value) {
- $view->result[$key] = (object) $value;
- }
-
- // Save the metadata into the object
- unset($results['query']['results']);
- foreach ($results as $key => $value) {
- $this->$key = $value;
- }
- }
- $this->pager->post_execute($view->result);
- }
- //dpm($url);
- $view->execute_time = $this->float_microtime() - $start;
- }
-
- function float_microtime() {
- list($usec, $sec) = explode(' ', microtime());
- return (float) $sec + (float) $usec;
- }
-
- function add_signature(&$view) {
- //$view->query->add_field(NULL, "'" . $view->name . ':' . $view->current_display . "'", 'view_name');
- }
-
- function option_definition() {
- $options = parent::option_definition();
- $options['api_url'] = array('default' => 'http://query.yahooapis.com/v1/public/yql');
- $options['api_method'] = array('default' => 'json');
- $options['yql_base_table'] = array('default' => '');
- $options['yql_custom_tables'] = array('default' => '');
- $options['yql_base_object'] = array('default' => '');
-
- $options['num_items'] = array('default' => 10);
-
- return $options;
- }
-
- function options_form(&$form, &$form_state) {
- $form['api_url'] = array(
- '#type' => 'textfield',
- '#title' => t('Alternate API URL'),
- '#default_value' => $this->options['api_url'],
- '#description' => t("The URL YQL will be queried from (default: Yahoo! YQL Engine)."),
- );
-
- $form['api_method'] = array(
- '#type' => 'select',
- '#title' => t('API method'),
- '#description' => t("The format of the data returned by YQL."),
- '#default_value' => 'json',
- '#options' => array(
- 'json' => 'JSON',
- ),
- '#required' => TRUE,
- );
-
- $form['yql_base_table'] = array(
- '#type' => 'textfield',
- '#title' => t('YQL base table'),
- '#default_value' => $this->options['yql_base_table'],
- '#description' => t("A base table that view will be querying by using YQL to. Example: flickr.photos.recent"),
- '#required' => TRUE,
- );
-
- $form['num_items'] = array(
- '#type' => 'textfield',
- '#title' => t('Number of items'),
- '#required' => TRUE,
- '#description' => t('The number of items to be fetched from the base table. The number must be lesser than the remote limit of the base table, To get the remote limit of a table, see: ') . l('YQL Guide: Paging', 'http://developer.yahoo.com/yql/guide/paging.html') . '. NOTE: This amount of item will be fetched on every page of the view, so it might affect the performance of your site',
- '#default_value' => $this->options['num_items'],
- );
-
- // @todo: add validation for custom open table.
- $form['yql_custom_tables'] = array(
- '#type' => 'textarea',
- '#title' => t('Custom open tables.'),
- '#default_value' => $this->options['yql_custom_tables'],
- '#description' => t("Add custom table into the YQL Query.
Example:" . 'USE \'http://www.datatables.org/delicious/delicious.feeds.popular.xml\' AS delicious.feeds.popular;'),
- );
-
- $form['yql_base_object'] = array(
- '#type' => 'textfield',
- '#title' => t('YQL base object'),
- '#default_value' => $this->options['yql_base_object'],
- '#description' => t('The base object YQL will be querying from. If this is left empty, the first object in the result set will be taken as the base object'),
- );
- }
-
- /**
- * Add a field to the query table, possibly with an alias. This will
- * automatically call ensure_table to make sure the required table
- * exists, *unless* $table is unset.
- *
- * @param $table
- * The table this field is attached to. If NULL, it is assumed this will
- * be a formula; otherwise, ensure_table is used to make sure the
- * table exists.
- * @param $field
- * The name of the field to add. This may be a real field or a formula.
- * @param $alias
- * The alias to create. If not specified, the alias will be $table_$field
- * unless $table is NULL. When adding formulae, it is recommended that an
- * alias be used.
- * @param $params
- * An array of parameters additional to the field that will control items
- * such as aggregation functions and DISTINCT.
- *
- * @return $name
- * The name that this field can be referred to as. Usually this is the alias.
- */
- function add_field($table, $field, $alias = '', $params = array()) {
- // We can't use any alias in YQL query, so just use the real field name.
- $alias = $field;
-
- // Create a field info array.
- $field_info = array(
- 'field' => $field,
- 'table' => $table,
- 'alias' => $alias,
- ) + $params;
-
- if (empty($this->fields[$alias])) {
- $this->fields[$alias] = $field_info;
- }
-
- return $alias;
- }
-
- /**
- * Add an ORDER BY clause to the query.
- *
- * @param $table
- * The table this field is part of. If a formula, enter NULL.
- * @param $field
- * The field or formula to sort on. If already a field, enter NULL
- * and put in the alias.
- * @param $order
- * Either ASC or DESC.
- * @param $alias
- * The alias to add the field as. In SQL, all fields in the order by
- * must also be in the SELECT portion. If an $alias isn't specified
- * one will be generated for from the $field; however, if the
- * $field is a formula, this alias will likely fail.
- * @param $params
- * Any params that should be passed through to the add_field.
- */
- function add_orderby($table, $field, $order, $alias = '', $params = array()) {
- // We can't use any alias in YQL query, so just use the real field name.
- $as = $alias = $field;
-
- if ($field) {
- $as = $this->add_field($table, $field, $as, $params);
- }
-
- $orderby = array(
- 'field' => $as,
- 'order' => $order,
- );
-
- $this->orderby[] = $orderby;
- }
-
-
-}