diff --git a/CHANGELOG.txt b/CHANGELOG.txt index d83fa51c776c9b34a606a40b9eedcec6c0f1599e..38d9e817fe0d79c76cacefb6b56d5249ef343749 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -34,6 +34,7 @@ Views 2.x o #408180 by joachim: Allow taxonomy term parent argument. o #469456 by dereine: Automatically give .info file during views bulk export. o #424460 by thePanz: Customizable breadcrumb title for arguments. + o #436398 by Pasqualle: Support for aggregator category table. Views 2.5 Bugs fixed: diff --git a/modules/aggregator.views.inc b/modules/aggregator.views.inc index e61d1772013491c01d7a2ecb149c6f79d3ff8de2..d24076af8581599c66cae2aefd797b92cf99d4ce 100644 --- a/modules/aggregator.views.inc +++ b/modules/aggregator.views.inc @@ -261,6 +261,66 @@ function aggregator_views_data() { ), ); + // ---------------------------------------------------------------------- + // Aggregator category feed table + + $data['aggregator_category_feed']['table']['join'] = array( + 'aggregator_item' => array( + 'left_field' => 'fid', + 'field' => 'fid', + ), + ); + + // ---------------------------------------------------------------------- + // Aggregator category table + + $data['aggregator_category']['table']['group'] = t('Aggregator category'); + + $data['aggregator_category']['table']['join'] = array( + 'aggregator_item' => array( + 'left_table' => 'aggregator_category_feed', + 'left_field' => 'cid', + 'field' => 'cid', + ), + ); + + // cid + $data['aggregator_category']['cid'] = array( + 'title' => t('Category ID'), + 'help' => t('The unique ID of the aggregator category.'), + 'field' => array( + 'handler' => 'views_handler_field_numeric', + 'click sortable' => TRUE, + ), + 'argument' => array( + 'handler' => 'views_handler_argument_aggregator_category_cid', + 'name field' => 'title', + 'numeric' => TRUE, + ), + 'filter' => array( + 'handler' => 'views_handler_filter_aggregator_category_cid', + ), + 'sort' => array( + 'handler' => 'views_handler_sort', + ), + ); + + // title + $data['aggregator_category']['title'] = array( + 'title' => t('Category'), + 'help' => t('The title of the aggregator category.'), + 'field' => array( + 'handler' => 'views_handler_field_aggregator_category', + 'click sortable' => TRUE, + ), + 'sort' => array( + 'handler' => 'views_handler_sort', + ), + 'filter' => array( + 'handler' => 'views_handler_filter_string', + ), + ); + return $data; } @@ -274,15 +334,26 @@ function aggregator_views_handlers() { 'path' => drupal_get_path('module', 'views') . '/modules/aggregator', ), 'handlers' => array( - // field handler + // field handlers 'views_handler_field_aggregator_title_link' => array( 'parent' => 'views_handler_field', ), + 'views_handler_field_aggregator_category' => array( + 'parent' => 'views_handler_field', + ), // argument handlers 'views_handler_argument_aggregator_fid' => array( 'parent' => 'views_handler_argument_numeric', ), + 'views_handler_argument_aggregator_category_cid' => array( + 'parent' => 'views_handler_argument_numeric', + ), + + // filter handlers + 'views_handler_filter_aggregator_category_cid' => array( + 'parent' => 'views_handler_filter_in_operator', + ), ), ); } diff --git a/modules/aggregator/views_handler_argument_aggregator_category_cid.inc b/modules/aggregator/views_handler_argument_aggregator_category_cid.inc new file mode 100644 index 0000000000000000000000000000000000000000..1565e7f8414d176be31754603ff2a5f9e6c96ebd --- /dev/null +++ b/modules/aggregator/views_handler_argument_aggregator_category_cid.inc @@ -0,0 +1,21 @@ +value), '%d')); + + $result = db_query("SELECT c.title FROM {aggregator_category} c WHERE c.cid IN ($placeholders)", $this->value); + while ($term = db_fetch_object($result)) { + $titles[] = check_plain($term->title); + } + return $titles; + } +} diff --git a/modules/aggregator/views_handler_field_aggregator_category.inc b/modules/aggregator/views_handler_field_aggregator_category.inc new file mode 100644 index 0000000000000000000000000000000000000000..a13b48304b0b588fb5de9f567dc840d2e1f63c36 --- /dev/null +++ b/modules/aggregator/views_handler_field_aggregator_category.inc @@ -0,0 +1,53 @@ +additional_fields['cid'] = 'cid'; + } + + function option_definition() { + $options = parent::option_definition(); + $options['link_to_category'] = array('default' => FALSE); + return $options; + } + + /** + * Provide link to category option + */ + function options_form(&$form, &$form_state) { + parent::options_form($form, $form_state); + $form['link_to_category'] = array( + '#title' => t('Link this field to its aggregator category page'), + '#description' => t('This will override any other link you have set.'), + '#type' => 'checkbox', + '#default_value' => !empty($this->options['link_to_category']), + ); + } + + /** + * Render whatever the data is as a link to the category. + * + * Data should be made XSS safe prior to calling this function. + */ + function render_link($data, $values) { + if (!empty($this->options['link_to_category']) && !empty($values->{$this->aliases['cid']}) && $data !== NULL && $data !== '') { + $cid = $values->{$this->aliases['cid']}; + $this->options['alter']['make_link'] = TRUE; + $this->options['alter']['path'] = "aggregator/category/$cid"; + } + return $data; + } + + function render($values) { + return $this->render_link(check_plain($values->{$this->field_alias}), $values); + } +} diff --git a/modules/aggregator/views_handler_filter_aggregator_category_cid.inc b/modules/aggregator/views_handler_filter_aggregator_category_cid.inc new file mode 100644 index 0000000000000000000000000000000000000000..0b4c8a7bfb7474cb0ca015b229dda93e49ffd731 --- /dev/null +++ b/modules/aggregator/views_handler_filter_aggregator_category_cid.inc @@ -0,0 +1,20 @@ +value_options)) { + return; + } + + $this->value_options = array(); + + $result = db_query('SELECT * FROM {aggregator_category} ORDER BY title'); + while ($category = db_fetch_object($result)) { + $this->value_options[$category->cid] = check_plain($category->title); + } + } +}