summaryrefslogtreecommitdiff
path: root/kolab.org/www/drupal-7.15/sites/all/modules/views/handlers
diff options
context:
space:
mode:
authorTorsten Grote <grote@kolabsys.com>2012-08-27 12:47:35 (GMT)
committerTorsten Grote <grote@kolabsys.com>2012-08-27 12:47:35 (GMT)
commit7b5e4a2b04e4fb38485bc12965e07794388d0224 (patch)
tree42031777dcb7476a63e9d6080ab9b8eef8ebb6f0 /kolab.org/www/drupal-7.15/sites/all/modules/views/handlers
parentee39408867ae52c2321036a67c472e684c1e1108 (diff)
downloadkolab.org-www-7b5e4a2b04e4fb38485bc12965e07794388d0224.tar.gz
updated ctools, ldap and views modules
Diffstat (limited to 'kolab.org/www/drupal-7.15/sites/all/modules/views/handlers')
-rw-r--r--kolab.org/www/drupal-7.15/sites/all/modules/views/handlers/views_handler_area.inc24
-rw-r--r--kolab.org/www/drupal-7.15/sites/all/modules/views/handlers/views_handler_area_result.inc13
-rw-r--r--kolab.org/www/drupal-7.15/sites/all/modules/views/handlers/views_handler_area_text.inc14
-rw-r--r--kolab.org/www/drupal-7.15/sites/all/modules/views/handlers/views_handler_area_text_custom.inc56
-rw-r--r--kolab.org/www/drupal-7.15/sites/all/modules/views/handlers/views_handler_area_view.inc7
-rw-r--r--kolab.org/www/drupal-7.15/sites/all/modules/views/handlers/views_handler_argument.inc42
-rw-r--r--kolab.org/www/drupal-7.15/sites/all/modules/views/handlers/views_handler_argument_date.inc9
-rw-r--r--kolab.org/www/drupal-7.15/sites/all/modules/views/handlers/views_handler_argument_formula.inc6
-rw-r--r--kolab.org/www/drupal-7.15/sites/all/modules/views/handlers/views_handler_argument_group_by_numeric.inc5
-rw-r--r--kolab.org/www/drupal-7.15/sites/all/modules/views/handlers/views_handler_argument_many_to_one.inc12
-rw-r--r--kolab.org/www/drupal-7.15/sites/all/modules/views/handlers/views_handler_argument_null.inc8
-rw-r--r--kolab.org/www/drupal-7.15/sites/all/modules/views/handlers/views_handler_argument_numeric.inc7
-rw-r--r--kolab.org/www/drupal-7.15/sites/all/modules/views/handlers/views_handler_argument_string.inc33
-rw-r--r--kolab.org/www/drupal-7.15/sites/all/modules/views/handlers/views_handler_field.inc183
-rw-r--r--kolab.org/www/drupal-7.15/sites/all/modules/views/handlers/views_handler_field_boolean.inc5
-rw-r--r--kolab.org/www/drupal-7.15/sites/all/modules/views/handlers/views_handler_field_contextual_links.inc55
-rw-r--r--kolab.org/www/drupal-7.15/sites/all/modules/views/handlers/views_handler_field_counter.inc5
-rw-r--r--kolab.org/www/drupal-7.15/sites/all/modules/views/handlers/views_handler_field_custom.inc9
-rw-r--r--kolab.org/www/drupal-7.15/sites/all/modules/views/handlers/views_handler_field_date.inc26
-rw-r--r--kolab.org/www/drupal-7.15/sites/all/modules/views/handlers/views_handler_field_entity.inc6
-rw-r--r--kolab.org/www/drupal-7.15/sites/all/modules/views/handlers/views_handler_field_machine_name.inc7
-rw-r--r--kolab.org/www/drupal-7.15/sites/all/modules/views/handlers/views_handler_field_markup.inc5
-rw-r--r--kolab.org/www/drupal-7.15/sites/all/modules/views/handlers/views_handler_field_math.inc10
-rw-r--r--kolab.org/www/drupal-7.15/sites/all/modules/views/handlers/views_handler_field_numeric.inc10
-rw-r--r--kolab.org/www/drupal-7.15/sites/all/modules/views/handlers/views_handler_field_prerender_list.inc7
-rw-r--r--kolab.org/www/drupal-7.15/sites/all/modules/views/handlers/views_handler_field_serialized.inc5
-rw-r--r--kolab.org/www/drupal-7.15/sites/all/modules/views/handlers/views_handler_field_time_interval.inc6
-rw-r--r--kolab.org/www/drupal-7.15/sites/all/modules/views/handlers/views_handler_field_url.inc12
-rw-r--r--kolab.org/www/drupal-7.15/sites/all/modules/views/handlers/views_handler_filter.inc774
-rw-r--r--kolab.org/www/drupal-7.15/sites/all/modules/views/handlers/views_handler_filter_boolean_operator.inc9
-rw-r--r--kolab.org/www/drupal-7.15/sites/all/modules/views/handlers/views_handler_filter_boolean_operator_string.inc6
-rw-r--r--kolab.org/www/drupal-7.15/sites/all/modules/views/handlers/views_handler_filter_combine.inc137
-rw-r--r--kolab.org/www/drupal-7.15/sites/all/modules/views/handlers/views_handler_filter_date.inc33
-rw-r--r--kolab.org/www/drupal-7.15/sites/all/modules/views/handlers/views_handler_filter_entity_bundle.inc122
-rw-r--r--kolab.org/www/drupal-7.15/sites/all/modules/views/handlers/views_handler_filter_equality.inc6
-rw-r--r--kolab.org/www/drupal-7.15/sites/all/modules/views/handlers/views_handler_filter_group_by_numeric.inc5
-rw-r--r--kolab.org/www/drupal-7.15/sites/all/modules/views/handlers/views_handler_filter_in_operator.inc11
-rw-r--r--kolab.org/www/drupal-7.15/sites/all/modules/views/handlers/views_handler_filter_many_to_one.inc5
-rw-r--r--kolab.org/www/drupal-7.15/sites/all/modules/views/handlers/views_handler_filter_numeric.inc8
-rw-r--r--kolab.org/www/drupal-7.15/sites/all/modules/views/handlers/views_handler_filter_string.inc10
-rw-r--r--kolab.org/www/drupal-7.15/sites/all/modules/views/handlers/views_handler_relationship.inc7
-rw-r--r--kolab.org/www/drupal-7.15/sites/all/modules/views/handlers/views_handler_relationship_groupwise_max.inc39
-rw-r--r--kolab.org/www/drupal-7.15/sites/all/modules/views/handlers/views_handler_sort.inc16
-rw-r--r--kolab.org/www/drupal-7.15/sites/all/modules/views/handlers/views_handler_sort_date.inc5
-rw-r--r--kolab.org/www/drupal-7.15/sites/all/modules/views/handlers/views_handler_sort_group_by_numeric.inc6
-rw-r--r--kolab.org/www/drupal-7.15/sites/all/modules/views/handlers/views_handler_sort_menu_hierarchy.inc37
-rw-r--r--kolab.org/www/drupal-7.15/sites/all/modules/views/handlers/views_handler_sort_random.inc5
47 files changed, 1662 insertions, 166 deletions
diff --git a/kolab.org/www/drupal-7.15/sites/all/modules/views/handlers/views_handler_area.inc b/kolab.org/www/drupal-7.15/sites/all/modules/views/handlers/views_handler_area.inc
index 295e14d..9fed11c 100644
--- a/kolab.org/www/drupal-7.15/sites/all/modules/views/handlers/views_handler_area.inc
+++ b/kolab.org/www/drupal-7.15/sites/all/modules/views/handlers/views_handler_area.inc
@@ -1,17 +1,37 @@
<?php
+
/**
* @file
* Views area handlers.
*/
/**
- * @defgroup views_area_handlers Views' area handlers
+ * @defgroup views_area_handlers Views area handlers
* @{
* Handlers to tell Views what can display in header, footer
* and empty text in a view.
*/
+/**
+ * Base class for area handlers.
+ *
+ * @ingroup views_area_handlers
+ */
class views_handler_area extends views_handler {
+
+ /**
+ * Overrides views_handler::init().
+ *
+ * Make sure that no result area handlers are set to be shown when the result
+ * is empty.
+ */
+ function init(&$view, &$options) {
+ parent::init($view, $options);
+ if ($this->handler_type == 'empty') {
+ $this->options['empty'] = TRUE;
+ }
+ }
+
/**
* Get this field's label.
*/
@@ -28,7 +48,7 @@ class views_handler_area extends views_handler {
$this->definition['field'] = !empty($this->definition['field']) ? $this->definition['field'] : '';
$label = !empty($this->definition['label']) ? $this->definition['label'] : $this->definition['field'];
$options['label'] = array('default' => $label, 'translatable' => TRUE);
- $options['empty'] = array('default' => 0, 'bool' => TRUE);
+ $options['empty'] = array('default' => FALSE, 'bool' => TRUE);
return $options;
}
diff --git a/kolab.org/www/drupal-7.15/sites/all/modules/views/handlers/views_handler_area_result.inc b/kolab.org/www/drupal-7.15/sites/all/modules/views/handlers/views_handler_area_result.inc
index a52aa8c..86b1849 100644
--- a/kolab.org/www/drupal-7.15/sites/all/modules/views/handlers/views_handler_area_result.inc
+++ b/kolab.org/www/drupal-7.15/sites/all/modules/views/handlers/views_handler_area_result.inc
@@ -2,13 +2,13 @@
/**
* @file
- * Contains views_handler_area_result handler.
+ * Definition of views_handler_area_result.
*/
/**
* Views area handler to display some configurable result summary.
*
- * @ingroup views_area_handlers Views' area handlers
+ * @ingroup views_area_handlers
*/
class views_handler_area_result extends views_handler_area {
@@ -33,6 +33,7 @@ class views_handler_area_result extends views_handler_area {
'@name -- the human-readable name of the view',
'@per_page -- the number of items per page',
'@current_page -- the current page number',
+ '@current_record_count -- the current page record count',
'@page_count -- the total page count',
),
);
@@ -61,7 +62,9 @@ class views_handler_area_result extends views_handler_area {
$current_page = (int) $this->view->get_current_page() + 1;
$per_page = (int) $this->view->get_items_per_page();
$count = count($this->view->result);
- $total = $this->view->total_rows;
+ // @TODO: Maybe use a possible is views empty functionality.
+ // Not every view has total_rows set, use view->result instead.
+ $total = isset($this->view->total_rows) ? $this->view->total_rows : count($this->view->result);
$name = check_plain($this->view->human_name);
if ($per_page === 0) {
$page_count = 1;
@@ -77,8 +80,9 @@ class views_handler_area_result extends views_handler_area {
$start = ($current_page - 1) * $per_page + 1;
$end = $total_count;
}
+ $current_record_count = ($end - $start) + 1;
// Get the search information.
- $items = array('start', 'end', 'total', 'name', 'per_page', 'current_page', 'page_count');
+ $items = array('start', 'end', 'total', 'name', 'per_page', 'current_page', 'current_record_count', 'page_count');
$replacements = array();
foreach ($items as $item) {
$replacements["@$item"] = ${$item};
@@ -90,4 +94,3 @@ class views_handler_area_result extends views_handler_area {
return $output;
}
}
-
diff --git a/kolab.org/www/drupal-7.15/sites/all/modules/views/handlers/views_handler_area_text.inc b/kolab.org/www/drupal-7.15/sites/all/modules/views/handlers/views_handler_area_text.inc
index 2b9adb3..d772786 100644
--- a/kolab.org/www/drupal-7.15/sites/all/modules/views/handlers/views_handler_area_text.inc
+++ b/kolab.org/www/drupal-7.15/sites/all/modules/views/handlers/views_handler_area_text.inc
@@ -2,20 +2,21 @@
/**
* @file
- * Contains views_handler_area_text handler.
+ * Definition of views_handler_area_text.
*/
/**
* Views area text handler.
- * @ingroup views_area_handlers Views' area handlers
-*/
+ *
+ * @ingroup views_area_handlers
+ */
class views_handler_area_text extends views_handler_area {
function option_definition() {
$options = parent::option_definition();
$options['content'] = array('default' => '', 'translatable' => TRUE, 'format_key' => 'format');
$options['format'] = array('default' => NULL);
- $options['tokenize'] = array('default' => FALSE);
+ $options['tokenize'] = array('default' => FALSE, 'bool' => TRUE);
return $options;
}
@@ -30,7 +31,7 @@ class views_handler_area_text extends views_handler_area {
'#wysiwyg' => FALSE,
);
-
+ // @TODO: Refactor token handling into a base class.
$form['tokenize'] = array(
'#type' => 'checkbox',
'#title' => t('Use replacement tokens from the first row'),
@@ -50,7 +51,7 @@ class views_handler_area_text extends views_handler_area {
}
if (!empty($options)) {
- $output = '<p>' . t('The following tokens are available. If you would like to have the characters %5B and %5D please use the html entity codes \'%5B\' or \'%5D\' or they will get replaced with empty space.)' . '</p>');
+ $output = '<p>' . t('The following tokens are available. If you would like to have the characters \'[\' and \']\' please use the html entity codes \'%5B\' or \'%5D\' or they will get replaced with empty space.' . '</p>');
foreach (array_keys($options) as $type) {
if (!empty($options[$type])) {
$items = array();
@@ -106,5 +107,4 @@ class views_handler_area_text extends views_handler_area {
return check_markup($value, $format, '', FALSE);
}
}
-
}
diff --git a/kolab.org/www/drupal-7.15/sites/all/modules/views/handlers/views_handler_area_text_custom.inc b/kolab.org/www/drupal-7.15/sites/all/modules/views/handlers/views_handler_area_text_custom.inc
new file mode 100644
index 0000000..3627f0c
--- /dev/null
+++ b/kolab.org/www/drupal-7.15/sites/all/modules/views/handlers/views_handler_area_text_custom.inc
@@ -0,0 +1,56 @@
+<?php
+
+/**
+ * @file
+ * Definition of views_handler_area_text_custom.
+ */
+
+/**
+ * Views area text custom handler.
+ *
+ * @ingroup views_area_handlers
+ */
+class views_handler_area_text_custom extends views_handler_area_text {
+
+ function option_definition() {
+ $options = parent::option_definition();
+ unset($options['format']);
+ return $options;
+ }
+
+ function options_form(&$form, &$form_state) {
+ parent::options_form($form, $form_state);
+
+ // Alter the form element, to be a regular text area.
+ $form['content']['#type'] = 'textarea';
+ unset($form['content']['#format']);
+ unset($form['content']['#wysiwyg']);
+
+ // @TODO: Use the token refactored base class.
+ }
+
+ // Empty, so we don't inherit options_submit from the parent.
+ function options_submit(&$form, &$form_state) {
+ }
+
+ function render($empty = FALSE) {
+ if (!$empty || !empty($this->options['empty'])) {
+ return $this->render_textarea_custom($this->options['content']);
+ }
+
+ return '';
+ }
+
+ /**
+ * Render a text area with filter_xss_admin.
+ */
+ function render_textarea_custom($value) {
+ if ($value) {
+ if ($this->options['tokenize']) {
+ $value = $this->view->style_plugin->tokenize_value($value, 0);
+ }
+ return $this->sanitize_value($value, 'xss_admin');
+ }
+ }
+
+}
diff --git a/kolab.org/www/drupal-7.15/sites/all/modules/views/handlers/views_handler_area_view.inc b/kolab.org/www/drupal-7.15/sites/all/modules/views/handlers/views_handler_area_view.inc
index b8fad3f..45ea499 100644
--- a/kolab.org/www/drupal-7.15/sites/all/modules/views/handlers/views_handler_area_view.inc
+++ b/kolab.org/www/drupal-7.15/sites/all/modules/views/handlers/views_handler_area_view.inc
@@ -2,8 +2,9 @@
/**
* @file
- * Contains views_handler_area_view handler.
+ * Definition of views_handler_area_view.
*/
+
/**
* Views area handlers. Insert a view inside of an area.
*
@@ -15,7 +16,7 @@ class views_handler_area_view extends views_handler_area {
$options = parent::option_definition();
$options['view_to_insert'] = array('default' => '');
- $options['inherit_arguments'] = array('default' => FALSE, 'boolean' => TRUE);
+ $options['inherit_arguments'] = array('default' => FALSE, 'bool' => TRUE);
return $options;
}
@@ -29,7 +30,7 @@ class views_handler_area_view extends views_handler_area {
$view_display = $this->view->name . ':' . $this->view->current_display;
$options = array('' => t('-Select-'));
- $options += views_get_views_as_options(FALSE, 'all', $view_display);
+ $options += views_get_views_as_options(FALSE, 'all', $view_display, FALSE, TRUE);
$form['view_to_insert'] = array(
'#type' => 'select',
'#title' => t('View to insert'),
diff --git a/kolab.org/www/drupal-7.15/sites/all/modules/views/handlers/views_handler_argument.inc b/kolab.org/www/drupal-7.15/sites/all/modules/views/handlers/views_handler_argument.inc
index 72c07e2..42617e7 100644
--- a/kolab.org/www/drupal-7.15/sites/all/modules/views/handlers/views_handler_argument.inc
+++ b/kolab.org/www/drupal-7.15/sites/all/modules/views/handlers/views_handler_argument.inc
@@ -1,7 +1,13 @@
<?php
/**
- * @defgroup views_argument_handlers Handlers for arguments
+ * @file
+ * @todo.
+ */
+
+/**
+ * @defgroup views_argument_handlers Views argument handlers
+ * Handlers to tell Views how to contextually filter queries.
* @{
*/
@@ -79,6 +85,9 @@ class views_handler_argument extends views_handler {
$this->options['summary']['format'] = $options['style_plugin'];
}
+ // Setup default value.
+ $options['style_options'] = isset($options['style_options']) ? $options['style_options'] : array();
+
if (!isset($options['summary']['sort_order']) && !empty($options['default_action']) && $options['default_action'] == 'summary asc') {
$this->options['default_action'] = 'summary';
$this->options['summary']['sort_order'] = 'asc';
@@ -173,17 +182,17 @@ class views_handler_argument extends views_handler {
$options['exception'] = array(
'contains' => array(
'value' => array('default' => 'all'),
- 'title_enable' => array('default' => 0),
- 'title' => array('default' => t('All'), 'translatable' => TRUE),
+ 'title_enable' => array('default' => FALSE, 'bool' => TRUE),
+ 'title' => array('default' => 'All', 'translatable' => TRUE),
),
);
- $options['title_enable'] = array('default' => 0);
+ $options['title_enable'] = array('default' => FALSE, 'bool' => TRUE);
$options['title'] = array('default' => '', 'translatable' => TRUE);
- $options['breadcrumb_enable'] = array('default' => 0);
+ $options['breadcrumb_enable'] = array('default' => FALSE, 'bool' => TRUE);
$options['breadcrumb'] = array('default' => '', 'translatable' => TRUE);
$options['default_argument_type'] = array('default' => 'fixed', 'export' => 'export_plugin');
$options['default_argument_options'] = array('default' => array(), 'export' => FALSE);
- $options['default_argument_skip_url'] = array('default' => FALSE);
+ $options['default_argument_skip_url'] = array('default' => FALSE, 'bool' => TRUE);
$options['summary_options'] = array('default' => array(), 'export' => FALSE);
$options['summary'] = array(
'contains' => array(
@@ -192,7 +201,7 @@ class views_handler_argument extends views_handler {
'format' => array('default' => 'default_summary', 'export' => 'export_summary'),
),
);
- $options['specify_validation'] = array('default' => 0);
+ $options['specify_validation'] = array('default' => FALSE, 'bool' => TRUE);
$options['validate'] = array(
'contains' => array(
'type' => array('default' => 'none', 'export' => 'export_validation'),
@@ -371,6 +380,7 @@ class views_handler_argument extends views_handler {
'#prefix' => '<div id="edit-options-validate-options-' . $id . '-wrapper">',
'#suffix' => '</div>',
'#type' => 'item',
+ // Even if the plugin has no options add the key to the form_state.
'#input' => TRUE, // trick it into checking input to make #process run
'#dependency' => array(
'edit-options-specify-validation' => array('1'),
@@ -507,6 +517,11 @@ class views_handler_argument extends views_handler {
'method' => 'default_empty',
'breadcrumb' => TRUE, // generate a breadcrumb to here
),
+ 'access denied' => array(
+ 'title' => t('Display "Access Denied"'),
+ 'method' => 'default_access_denied',
+ 'breadcrumb' => FALSE, // generate a breadcrumb to here
+ ),
);
if ($this->view->display_handler->has_path()) {
@@ -565,6 +580,8 @@ class views_handler_argument extends views_handler {
'#suffix' => '</div>',
'#id' => 'edit-options-argument-default-options-' . $id,
'#type' => 'item',
+ // Even if the plugin has no options add the key to the form_state.
+ '#input' => TRUE,
'#dependency' => array(
'radio:options[default_action]' => array('default'),
'edit-options-default-argument-type' => array($id)
@@ -707,6 +724,17 @@ class views_handler_argument extends views_handler {
}
/**
+ * Default action: access denied.
+ *
+ * If an argument was expected and was not given, in this case, report
+ * the view as 'access denied'.
+ */
+ function default_access_denied() {
+ $this->view->build_info['denied'] = TRUE;
+ return FALSE;
+ }
+
+ /**
* Default action: empty
*
* If an argument was expected and was not given, in this case, display
diff --git a/kolab.org/www/drupal-7.15/sites/all/modules/views/handlers/views_handler_argument_date.inc b/kolab.org/www/drupal-7.15/sites/all/modules/views/handlers/views_handler_argument_date.inc
index 7ed4b03..6803c36 100644
--- a/kolab.org/www/drupal-7.15/sites/all/modules/views/handlers/views_handler_argument_date.inc
+++ b/kolab.org/www/drupal-7.15/sites/all/modules/views/handlers/views_handler_argument_date.inc
@@ -1,4 +1,10 @@
<?php
+
+/**
+ * @file
+ * Definition of views_handler_argument_date.
+ */
+
/**
* Abstract argument handler for dates.
*
@@ -12,7 +18,8 @@
* - many to one: If true, the "many to one" helper will be used.
* - invalid input: A string to give to the user for obviously invalid input.
* This is deprecated in favor of argument validators.
- * @see views_many_to_one_helper
+ *
+ * @see views_many_to_one_helper()
*
* @ingroup views_argument_handlers
*/
diff --git a/kolab.org/www/drupal-7.15/sites/all/modules/views/handlers/views_handler_argument_formula.inc b/kolab.org/www/drupal-7.15/sites/all/modules/views/handlers/views_handler_argument_formula.inc
index c4287be..76f5991 100644
--- a/kolab.org/www/drupal-7.15/sites/all/modules/views/handlers/views_handler_argument_formula.inc
+++ b/kolab.org/www/drupal-7.15/sites/all/modules/views/handlers/views_handler_argument_formula.inc
@@ -1,4 +1,10 @@
<?php
+
+/**
+ * @file
+ * Definition of views_handler_argument_formula.
+ */
+
/**
* Abstract argument handler for simple formulae.
*
diff --git a/kolab.org/www/drupal-7.15/sites/all/modules/views/handlers/views_handler_argument_group_by_numeric.inc b/kolab.org/www/drupal-7.15/sites/all/modules/views/handlers/views_handler_argument_group_by_numeric.inc
index 2ecccaf..aa522ea 100644
--- a/kolab.org/www/drupal-7.15/sites/all/modules/views/handlers/views_handler_argument_group_by_numeric.inc
+++ b/kolab.org/www/drupal-7.15/sites/all/modules/views/handlers/views_handler_argument_group_by_numeric.inc
@@ -1,6 +1,11 @@
<?php
/**
+ * @file
+ * Definition of views_handler_argument_group_by_numeric.
+ */
+
+/**
* Simple handler for arguments using group by.
*
* @ingroup views_argument_handlers
diff --git a/kolab.org/www/drupal-7.15/sites/all/modules/views/handlers/views_handler_argument_many_to_one.inc b/kolab.org/www/drupal-7.15/sites/all/modules/views/handlers/views_handler_argument_many_to_one.inc
index 1f5229e..3446760 100644
--- a/kolab.org/www/drupal-7.15/sites/all/modules/views/handlers/views_handler_argument_many_to_one.inc
+++ b/kolab.org/www/drupal-7.15/sites/all/modules/views/handlers/views_handler_argument_many_to_one.inc
@@ -1,4 +1,10 @@
<?php
+
+/**
+ * @file
+ * Definition of views_handler_argument_many_to_one.
+ */
+
/**
* An argument handler for use in fields that have a many to one relationship
* with the table(s) to the left. This adds a bunch of options that are
@@ -26,11 +32,11 @@ class views_handler_argument_many_to_one extends views_handler_argument {
$options = parent::option_definition();
if (!empty($this->definition['numeric'])) {
- $options['break_phrase'] = array('default' => FALSE);
+ $options['break_phrase'] = array('default' => FALSE, 'bool' => TRUE);
}
- $options['add_table'] = array('default' => FALSE);
- $options['require_value'] = array('default' => FALSE);
+ $options['add_table'] = array('default' => FALSE, 'bool' => TRUE);
+ $options['require_value'] = array('default' => FALSE, 'bool' => TRUE);
if (isset($this->helper)) {
$this->helper->option_definition($options);
diff --git a/kolab.org/www/drupal-7.15/sites/all/modules/views/handlers/views_handler_argument_null.inc b/kolab.org/www/drupal-7.15/sites/all/modules/views/handlers/views_handler_argument_null.inc
index e4804dc..5b42728 100644
--- a/kolab.org/www/drupal-7.15/sites/all/modules/views/handlers/views_handler_argument_null.inc
+++ b/kolab.org/www/drupal-7.15/sites/all/modules/views/handlers/views_handler_argument_null.inc
@@ -1,4 +1,10 @@
<?php
+
+/**
+ * @file
+ * Definition of views_handler_argument_null.
+ */
+
/**
* Argument handler that ignores the argument.
*
@@ -7,7 +13,7 @@
class views_handler_argument_null extends views_handler_argument {
function option_definition() {
$options = parent::option_definition();
- $options['must_not_be'] = array('default' => FALSE);
+ $options['must_not_be'] = array('default' => FALSE, 'bool' => TRUE);
return $options;
}
diff --git a/kolab.org/www/drupal-7.15/sites/all/modules/views/handlers/views_handler_argument_numeric.inc b/kolab.org/www/drupal-7.15/sites/all/modules/views/handlers/views_handler_argument_numeric.inc
index 5b91232..8f36b21 100644
--- a/kolab.org/www/drupal-7.15/sites/all/modules/views/handlers/views_handler_argument_numeric.inc
+++ b/kolab.org/www/drupal-7.15/sites/all/modules/views/handlers/views_handler_argument_numeric.inc
@@ -1,7 +1,8 @@
<?php
+
/**
* @file
- * Contains the numeric argument handler.
+ * Definition of views_handler_argument_numeric.
*/
/**
@@ -26,8 +27,8 @@ class views_handler_argument_numeric extends views_handler_argument {
function option_definition() {
$options = parent::option_definition();
- $options['break_phrase'] = array('default' => FALSE);
- $options['not'] = array('default' => FALSE);
+ $options['break_phrase'] = array('default' => FALSE, 'bool' => TRUE);
+ $options['not'] = array('default' => FALSE, 'bool' => TRUE);
return $options;
}
diff --git a/kolab.org/www/drupal-7.15/sites/all/modules/views/handlers/views_handler_argument_string.inc b/kolab.org/www/drupal-7.15/sites/all/modules/views/handlers/views_handler_argument_string.inc
index 45bdbab..dbb98fe 100644
--- a/kolab.org/www/drupal-7.15/sites/all/modules/views/handlers/views_handler_argument_string.inc
+++ b/kolab.org/www/drupal-7.15/sites/all/modules/views/handlers/views_handler_argument_string.inc
@@ -1,6 +1,11 @@
<?php
/**
+ * @file
+ * Definition of views_handler_argument_string.
+ */
+
+/**
* Basic argument handler to implement string arguments that may have length
* limits.
*
@@ -21,16 +26,16 @@ class views_handler_argument_string extends views_handler_argument {
function option_definition() {
$options = parent::option_definition();
- $options['glossary'] = array('default' => FALSE);
+ $options['glossary'] = array('default' => FALSE, 'bool' => TRUE);
$options['limit'] = array('default' => 0);
$options['case'] = array('default' => 'none');
$options['path_case'] = array('default' => 'none');
- $options['transform_dash'] = array('default' => FALSE);
- $options['break_phrase'] = array('default' => FALSE);
+ $options['transform_dash'] = array('default' => FALSE, 'bool' => TRUE);
+ $options['break_phrase'] = array('default' => FALSE, 'bool' => TRUE);
if (!empty($this->definition['many to one'])) {
- $options['add_table'] = array('default' => FALSE);
- $options['require_value'] = array('default' => FALSE);
+ $options['add_table'] = array('default' => FALSE, 'bool' => TRUE);
+ $options['require_value'] = array('default' => FALSE, 'bool' => TRUE);
}
return $options;
@@ -124,7 +129,6 @@ class views_handler_argument_string extends views_handler_argument {
* Build the summary query based on a string
*/
function summary_query() {
- $this->placeholder_length = $this->placeholder();
if (empty($this->definition['many to one'])) {
$this->ensure_my_table();
}
@@ -140,13 +144,7 @@ class views_handler_argument_string extends views_handler_argument {
else {
// Add the field.
$formula = $this->get_formula();
- $params = array(
- 'placeholders' => array(
- $this->placeholder_length => intval($this->options['limit']),
- ),
- );
-
- $this->base_alias = $this->query->add_field(NULL, $formula, $this->field . '_truncated', $params);
+ $this->base_alias = $this->query->add_field(NULL, $formula, $this->field . '_truncated');
$this->query->set_count_field(NULL, $formula, $this->field, $this->field . '_truncated');
}
@@ -160,7 +158,7 @@ class views_handler_argument_string extends views_handler_argument {
* $this->ensure_my_table() MUST have been called prior to this.
*/
function get_formula() {
- return "SUBSTRING($this->table_alias.$this->real_field, 1, $this->placeholder_length)";
+ return "SUBSTRING($this->table_alias.$this->real_field, 1, " . intval($this->options['limit']) . ")";
}
/**
@@ -171,7 +169,6 @@ class views_handler_argument_string extends views_handler_argument {
if (!empty($this->options['transform_dash'])) {
$argument = strtr($argument, '-', ' ');
}
- $this->placeholder_length = $this->placeholder();
if (!empty($this->options['break_phrase'])) {
views_break_phrase_string($argument, $this);
@@ -186,8 +183,6 @@ class views_handler_argument_string extends views_handler_argument {
$this->helper->formula = TRUE;
}
$this->helper->ensure_my_table();
-
- $this->helper->placeholders = array($this->placeholder_length => intval($this->options['limit']));
$this->helper->add_filter();
return;
}
@@ -212,7 +207,6 @@ class views_handler_argument_string extends views_handler_argument {
if ($formula) {
$placeholder = $this->placeholder();
- $placeholder_length = $this->placeholder_length;
if ($operator == 'IN') {
$field .= " IN($placeholder)";
}
@@ -220,7 +214,6 @@ class views_handler_argument_string extends views_handler_argument {
$field .= ' = ' . $placeholder;
}
$placeholders = array(
- $placeholder_length => intval($this->options['limit']),
$placeholder => $argument,
);
$this->query->add_where_expression(0, $field, $placeholders);
@@ -231,7 +224,7 @@ class views_handler_argument_string extends views_handler_argument {
}
function summary_argument($data) {
- $value = $this->case_transform($data->{$this->base_alias}, 'path_case');
+ $value = $this->case_transform($data->{$this->base_alias}, $this->options['path_case']);
if (!empty($this->options['transform_dash'])) {
$value = strtr($value, ' ', '-');
}
diff --git a/kolab.org/www/drupal-7.15/sites/all/modules/views/handlers/views_handler_field.inc b/kolab.org/www/drupal-7.15/sites/all/modules/views/handlers/views_handler_field.inc
index ff2c32d..c687575 100644
--- a/kolab.org/www/drupal-7.15/sites/all/modules/views/handlers/views_handler_field.inc
+++ b/kolab.org/www/drupal-7.15/sites/all/modules/views/handlers/views_handler_field.inc
@@ -1,13 +1,19 @@
<?php
+
+/**
+ * @file
+ * @todo.
+ */
+
/**
- * @defgroup views_field_handlers Views' field handlers
+ * @defgroup views_field_handlers Views field handlers
* @{
* Handlers to tell Views how to build and display fields.
*
*/
/**
- * Indicator of the render_text() mehtod for rendering a single item.
+ * Indicator of the render_text() method for rendering a single item.
* (If no render_item() is present).
*/
define('VIEWS_HANDLER_RENDER_TEXT_PHASE_SINGLE_ITEM', 0);
@@ -33,12 +39,21 @@ define('VIEWS_HANDLER_RENDER_TEXT_PHASE_EMPTY', 2);
* 'field' => fieldname); as many fields as are necessary
* may be in this array.
* - click sortable: If TRUE, this field may be click sorted.
+ *
+ * @ingroup views_field_handlers
*/
class views_handler_field extends views_handler {
var $field_alias = 'unknown';
var $aliases = array();
/**
+ * The field value prior to any rewriting.
+ *
+ * @var mixed
+ */
+ public $original_value = NULL;
+
+ /**
* @var array
* Stores additional fields which get's added to the query.
* The generated aliases are stored in $aliases.
@@ -363,6 +378,17 @@ class views_handler_field extends views_handler {
}
}
+ /**
+ * Determines if this field will be available as an option to group the result
+ * by in the style settings.
+ *
+ * @return bool
+ * TRUE if this field handler is groupable, otherwise FALSE.
+ */
+ function use_string_group_by() {
+ return TRUE;
+ }
+
function option_definition() {
$options = parent::option_definition();
@@ -370,32 +396,32 @@ class views_handler_field extends views_handler {
$options['exclude'] = array('default' => FALSE, 'bool' => TRUE);
$options['alter'] = array(
'contains' => array(
- 'alter_text' => array('default' => FALSE),
+ 'alter_text' => array('default' => FALSE, 'bool' => TRUE),
'text' => array('default' => '', 'translatable' => TRUE),
- 'make_link' => array('default' => FALSE),
- 'path' => array('default' => '', 'translatable' => TRUE),
- 'absolute' => array('default' => '', 'translatable' => FALSE),
- 'external' => array('default' => '', 'translatable' => FALSE),
- 'replace_spaces' => array('default' => '', 'translatable' => FALSE),
+ 'make_link' => array('default' => FALSE, 'bool' => TRUE),
+ 'path' => array('default' => ''),
+ 'absolute' => array('default' => FALSE, 'bool' => TRUE),
+ 'external' => array('default' => FALSE, 'bool' => TRUE),
+ 'replace_spaces' => array('default' => FALSE, 'bool' => TRUE),
'path_case' => array('default' => 'none', 'translatable' => FALSE),
- 'trim_whitespace' => array('default' => FALSE),
+ 'trim_whitespace' => array('default' => FALSE, 'bool' => TRUE),
'alt' => array('default' => '', 'translatable' => TRUE),
'rel' => array('default' => ''),
'link_class' => array('default' => ''),
'prefix' => array('default' => '', 'translatable' => TRUE),
'suffix' => array('default' => '', 'translatable' => TRUE),
'target' => array('default' => '', 'translatable' => TRUE),
- 'nl2br' => array('default' => FALSE),
+ 'nl2br' => array('default' => FALSE, 'bool' => TRUE),
'max_length' => array('default' => ''),
- 'word_boundary' => array('default' => TRUE),
- 'ellipsis' => array('default' => TRUE),
- 'more_link' => array('default' => FALSE),
+ 'word_boundary' => array('default' => TRUE, 'bool' => TRUE),
+ 'ellipsis' => array('default' => TRUE, 'bool' => TRUE),
+ 'more_link' => array('default' => FALSE, 'bool' => TRUE),
'more_link_text' => array('default' => '', 'translatable' => TRUE),
'more_link_path' => array('default' => ''),
- 'strip_tags' => array('default' => FALSE),
- 'trim' => array('default' => FALSE),
+ 'strip_tags' => array('default' => FALSE, 'bool' => TRUE),
+ 'trim' => array('default' => FALSE, 'bool' => TRUE),
'preserve_tags' => array('default' => ''),
- 'html' => array('default' => FALSE),
+ 'html' => array('default' => FALSE, 'bool' => TRUE),
),
);
$options['element_type'] = array('default' => '');
@@ -403,17 +429,17 @@ class views_handler_field extends views_handler {
$options['element_label_type'] = array('default' => '');
$options['element_label_class'] = array('default' => '');
- $options['element_label_colon'] = array('default' => TRUE);
+ $options['element_label_colon'] = array('default' => TRUE, 'bool' => TRUE);
$options['element_wrapper_type'] = array('default' => '');
$options['element_wrapper_class'] = array('default' => '');
- $options['element_default_classes'] = array('default' => TRUE);
+ $options['element_default_classes'] = array('default' => TRUE, 'bool' => TRUE);
$options['empty'] = array('default' => '', 'translatable' => TRUE);
- $options['hide_empty'] = array('default' => FALSE);
- $options['empty_zero'] = array('default' => FALSE);
- $options['hide_alter_empty'] = array('default' => TRUE);
+ $options['hide_empty'] = array('default' => FALSE, 'bool' => TRUE);
+ $options['empty_zero'] = array('default' => FALSE, 'bool' => TRUE);
+ $options['hide_alter_empty'] = array('default' => TRUE, 'bool' => TRUE);
return $options;
}
@@ -783,7 +809,7 @@ class views_handler_field extends views_handler {
// We have some options, so make a list.
if (!empty($options)) {
$output = t('<p>The following tokens are available for this field. Note that due to rendering order, you cannot use fields that come after this field; if you need a field not listed here, rearrange your fields.
-If you would like to have the characters %5B and %5D please use the html entity codes \'%5B\' or \'%5D\' or they will get replaced with empty space.</p>');
+If you would like to have the characters \'[\' and \']\' please use the html entity codes \'%5B\' or \'%5D\' or they will get replaced with empty space.</p>');
foreach (array_keys($options) as $type) {
if (!empty($options[$type])) {
$items = array();
@@ -1006,6 +1032,10 @@ If you would like to have the characters %5B and %5D please use the html entity
function advanced_render($values) {
if ($this->allow_advanced_render() && method_exists($this, 'render_item')) {
$raw_items = $this->get_items($values);
+ // If there are no items, set the original value to NULL.
+ if (empty($raw_items)) {
+ $this->original_value = NULL;
+ }
}
else {
$value = $this->render($values);
@@ -1049,7 +1079,7 @@ If you would like to have the characters %5B and %5D please use the html entity
}
if (empty($this->last_render)) {
- if (($this->last_render !== 0 && $this->last_render !== '0') || !empty($this->options['empty_zero'])) {
+ if ($this->is_value_empty($this->last_render, $this->options['empty_zero'], FALSE)) {
$alter = $this->options['alter'];
$alter['alter_text'] = 1;
$alter['text'] = $this->options['empty'];
@@ -1062,6 +1092,33 @@ If you would like to have the characters %5B and %5D please use the html entity
}
/**
+ * Checks if a field value is empty.
+ *
+ * @param $value
+ * The field value.
+ * @param bool $empty_zero
+ * Whether or not this field is configured to consider 0 as empty.
+ * @param bool $no_skip_empty
+ * Whether or not to use empty() to check the value.
+ *
+ * @return bool
+ * TRUE if the value is considered empty, FALSE otherwise.
+ */
+ function is_value_empty($value, $empty_zero, $no_skip_empty = TRUE) {
+ if (!isset($value)) {
+ $empty = TRUE;
+ }
+ else {
+ $empty = ($empty_zero || ($value !== 0 && $value !== '0'));
+ }
+
+ if ($no_skip_empty) {
+ $empty = empty($value) && $empty;
+ }
+ return $empty;
+ }
+
+ /**
* Perform an advanced text render for the item.
*
* This is separated out as some fields may render lists, and this allows
@@ -1080,15 +1137,14 @@ If you would like to have the characters %5B and %5D please use the html entity
}
// Check if there should be no further rewrite for empty values.
- $no_rewrite_for_empty = $this->options['hide_alter_empty'] && empty($this->original_value);
+ $no_rewrite_for_empty = $this->options['hide_alter_empty'] && $this->is_value_empty($this->original_value, $this->options['empty_zero']);
// Check whether the value is empty and return nothing, so the field isn't rendered.
// First check whether the field should be hidden if the value(hide_alter_empty = TRUE) /the rewrite is empty (hide_alter_empty = FALSE).
// For numeric values you can specify whether "0"/0 should be empty.
if ((($this->options['hide_empty'] && empty($value))
|| ($alter['phase'] != VIEWS_HANDLER_RENDER_TEXT_PHASE_EMPTY && $no_rewrite_for_empty))
- && (($value !== 0 && $value !== '0')
- || $this->options['empty_zero'])) {
+ && $this->is_value_empty($value, $this->options['empty_zero'], FALSE)) {
return '';
}
// Only in empty phase.
@@ -1120,7 +1176,7 @@ If you would like to have the characters %5B and %5D please use the html entity
$more_link_path = drupal_substr($more_link_path, drupal_strlen($base_path));
}
- $more_link = l($more_link_text, $more_link_path);
+ $more_link = l($more_link_text, $more_link_path, array('attributes' => array('class' => array('views-more-link'))));
$suffix .= " " . $more_link;
}
@@ -1230,7 +1286,15 @@ If you would like to have the characters %5B and %5D please use the html entity
if (isset($url['query'])) {
$path = strtr($path, array('?' . $url['query'] => ''));
- $options['query'] = drupal_get_query_array($url['query']);
+ $query = drupal_get_query_array($url['query']);
+ // Remove query parameters that were assigned a query string replacement
+ // token for which there is no value available.
+ foreach ($query as $param => $val) {
+ if ($val == '%' . $param) {
+ unset($query[$param]);
+ }
+ }
+ $options['query'] = $query;
}
if (isset($url['fragment'])) {
$path = strtr($path, array('#' . $url['fragment'] => ''));
@@ -1333,6 +1397,9 @@ If you would like to have the characters %5B and %5D please use the html entity
$tokens['!' . $count] = isset($this->view->args[$count - 1]) ? strip_tags(decode_entities($this->view->args[$count - 1])) : '';
}
+ // Get flattened set of tokens for any array depth in $_GET parameters.
+ $tokens += $this->get_token_values_recursive($_GET);
+
// Now add replacements for our fields.
foreach ($this->view->display_handler->get_handlers('field') as $field => $handler) {
if (isset($handler->last_render)) {
@@ -1354,6 +1421,64 @@ If you would like to have the characters %5B and %5D please use the html entity
// Store the tokens for the row so we can reference them later if necessary.
$this->view->style_plugin->render_tokens[$this->view->row_index] = $tokens;
$this->last_tokens = $tokens;
+
+ return $tokens;
+ }
+
+ /**
+ * Recursive function to add replacements for nested query string parameters.
+ *
+ * E.g. if you pass in the following array:
+ * array(
+ * 'foo' => array(
+ * 'a' => 'value',
+ * 'b' => 'value',
+ * ),
+ * 'bar' => array(
+ * 'a' => 'value',
+ * 'b' => array(
+ * 'c' => value,
+ * ),
+ * ),
+ * );
+ *
+ * Would yield the following array of tokens:
+ * array(
+ * '%foo_a' => 'value'
+ * '%foo_b' => 'value'
+ * '%bar_a' => 'value'
+ * '%bar_b_c' => 'value'
+ * );
+ *
+ * @param $array
+ * An array of values.
+ *
+ * @param $parent_keys
+ * An array of parent keys. This will represent the array depth.
+ *
+ * @return
+ * An array of available tokens, with nested keys representative of the array structure.
+ */
+ function get_token_values_recursive(array $array, array $parent_keys = array()) {
+ $tokens = array();
+
+ foreach ($array as $param => $val) {
+ if (is_array($val)) {
+ // Copy parent_keys array, so we don't afect other elements of this iteration.
+ $child_parent_keys = $parent_keys;
+ $child_parent_keys[] = $param;
+ // Get the child tokens.
+ $child_tokens = $this->get_token_values_recursive($val, $child_parent_keys);
+ // Add them to the current tokens array.
+ $tokens += $child_tokens;
+ }
+ else {
+ // Create a token key based on array element structure.
+ $token_string = !empty($parent_keys) ? implode('_', $parent_keys) . '_' . $param : $param;
+ $tokens['%' . $token_string] = strip_tags(decode_entities($val));
+ }
+ }
+
return $tokens;
}
@@ -1373,7 +1498,7 @@ If you would like to have the characters %5B and %5D please use the html entity
/**
* Document any special tokens this field might use for itself.
*
- * @see add_self_tokens() for details.
+ * @see add_self_tokens()
*/
function document_self_tokens(&$tokens) { }
diff --git a/kolab.org/www/drupal-7.15/sites/all/modules/views/handlers/views_handler_field_boolean.inc b/kolab.org/www/drupal-7.15/sites/all/modules/views/handlers/views_handler_field_boolean.inc
index c388d4f..13fff07 100644
--- a/kolab.org/www/drupal-7.15/sites/all/modules/views/handlers/views_handler_field_boolean.inc
+++ b/kolab.org/www/drupal-7.15/sites/all/modules/views/handlers/views_handler_field_boolean.inc
@@ -1,6 +1,11 @@
<?php
/**
+ * @file
+ * Definition of views_handler_field_boolean.
+ */
+
+/**
* A handler to provide proper displays for booleans.
*
* Allows for display of true/false, yes/no, on/off, enabled/disabled.
diff --git a/kolab.org/www/drupal-7.15/sites/all/modules/views/handlers/views_handler_field_contextual_links.inc b/kolab.org/www/drupal-7.15/sites/all/modules/views/handlers/views_handler_field_contextual_links.inc
index a55ac58..faeeedc 100644
--- a/kolab.org/www/drupal-7.15/sites/all/modules/views/handlers/views_handler_field_contextual_links.inc
+++ b/kolab.org/www/drupal-7.15/sites/all/modules/views/handlers/views_handler_field_contextual_links.inc
@@ -1,11 +1,21 @@
<?php
+/**
+ * @file
+ * Definition of views_handler_field_contextual_links.
+ */
+
+/**
+ * Provides a handler that adds contextual links.
+ *
+ * @ingroup views_field_handlers
+ */
class views_handler_field_contextual_links extends views_handler_field {
function option_definition() {
$options = parent::option_definition();
$options['fields'] = array('default' => array());
- $options['destination'] = array('default' => 1);
+ $options['destination'] = array('default' => TRUE, 'bool' => TRUE);
return $options;
}
@@ -22,13 +32,9 @@ class views_handler_field_contextual_links extends views_handler_field {
'#default_value' => $this->options['fields'],
);
$form['destination'] = array(
- '#type' => 'select',
+ '#type' => 'checkbox',
'#title' => t('Include destination'),
'#description' => t('Include a "destination" parameter in the link to return the user to the original view upon completing the contextual action.'),
- '#options' => array(
- '0' => t('No'),
- '1' => t('Yes'),
- ),
'#default_value' => $this->options['destination'],
);
}
@@ -50,7 +56,7 @@ class views_handler_field_contextual_links extends views_handler_field {
function render($values) {
$links = array();
foreach ($this->options['fields'] as $field) {
- if (empty($this->view->field[$field]->last_render_text)) {
+ if (empty($this->view->style_plugin->rendered_fields[$this->view->row_index][$field])) {
continue;
}
$title = $this->view->field[$field]->last_render_text;
@@ -58,7 +64,11 @@ class views_handler_field_contextual_links extends views_handler_field {
if (!empty($this->view->field[$field]->options['alter']['path'])) {
$path = $this->view->field[$field]->options['alter']['path'];
}
- if (!empty($title)) {
+ if (!empty($title) && !empty($path)) {
+ // Make sure that tokens are replaced for this paths as well.
+ $tokens = $this->get_render_tokens(array());
+ $path = strip_tags(decode_entities(strtr($path, $tokens)));
+
$links[$field] = array(
'href' => $path,
'title' => $title,
@@ -68,19 +78,24 @@ class views_handler_field_contextual_links extends views_handler_field {
}
}
}
- $build = array(
- '#prefix' => '<div class="contextual-links-wrapper">',
- '#suffix' => '</div>',
- '#theme' => 'links__contextual',
- '#links' => $links,
- '#attributes' => array('class' => array('contextual-links')),
- '#attached' => array(
- 'library' => array(array('contextual', 'contextual-links')),
- ),
- '#access' => user_access('access contextual links'),
- );
- return drupal_render($build);
+ if (!empty($links)) {
+ $build = array(
+ '#prefix' => '<div class="contextual-links-wrapper">',
+ '#suffix' => '</div>',
+ '#theme' => 'links__contextual',
+ '#links' => $links,
+ '#attributes' => array('class' => array('contextual-links')),
+ '#attached' => array(
+ 'library' => array(array('contextual', 'contextual-links')),
+ ),
+ '#access' => user_access('access contextual links'),
+ );
+ return drupal_render($build);
+ }
+ else {
+ return '';
+ }
}
function query() { }
diff --git a/kolab.org/www/drupal-7.15/sites/all/modules/views/handlers/views_handler_field_counter.inc b/kolab.org/www/drupal-7.15/sites/all/modules/views/handlers/views_handler_field_counter.inc
index d4e52fc..76213a6 100644
--- a/kolab.org/www/drupal-7.15/sites/all/modules/views/handlers/views_handler_field_counter.inc
+++ b/kolab.org/www/drupal-7.15/sites/all/modules/views/handlers/views_handler_field_counter.inc
@@ -1,6 +1,11 @@
<?php
/**
+ * @file
+ * Definition of views_handler_field_counter.
+ */
+
+/**
* Field handler to show a counter of the current row.
*
* @ingroup views_field_handlers
diff --git a/kolab.org/www/drupal-7.15/sites/all/modules/views/handlers/views_handler_field_custom.inc b/kolab.org/www/drupal-7.15/sites/all/modules/views/handlers/views_handler_field_custom.inc
index 92b5d7c..66586de 100644
--- a/kolab.org/www/drupal-7.15/sites/all/modules/views/handlers/views_handler_field_custom.inc
+++ b/kolab.org/www/drupal-7.15/sites/all/modules/views/handlers/views_handler_field_custom.inc
@@ -1,6 +1,11 @@
<?php
/**
+ * @file
+ * Definition of views_handler_field_custom.
+ */
+
+/**
* A handler to provide a field that is completely custom by the administrator.
*
* @ingroup views_field_handlers
@@ -14,8 +19,8 @@ class views_handler_field_custom extends views_handler_field {
$options = parent::option_definition();
// Override the alter text option to always alter the text.
- $options['alter']['contains']['alter_text'] = array('default' => TRUE);
- $options['hide_alter_empty'] = array('default' => FALSE);
+ $options['alter']['contains']['alter_text'] = array('default' => TRUE, 'bool' => TRUE);
+ $options['hide_alter_empty'] = array('default' => FALSE, 'bool' => TRUE);
return $options;
}
diff --git a/kolab.org/www/drupal-7.15/sites/all/modules/views/handlers/views_handler_field_date.inc b/kolab.org/www/drupal-7.15/sites/all/modules/views/handlers/views_handler_field_date.inc
index b122b66..8517f0b 100644
--- a/kolab.org/www/drupal-7.15/sites/all/modules/views/handlers/views_handler_field_date.inc
+++ b/kolab.org/www/drupal-7.15/sites/all/modules/views/handlers/views_handler_field_date.inc
@@ -1,4 +1,10 @@
<?php
+
+/**
+ * @file
+ * Definition of views_handler_field_date.
+ */
+
/**
* A handler to provide proper displays for dates.
*
@@ -10,6 +16,7 @@ class views_handler_field_date extends views_handler_field {
$options['date_format'] = array('default' => 'small');
$options['custom_date_format'] = array('default' => '');
+ $options['timezone'] = array('default' => '');
return $options;
}
@@ -19,7 +26,7 @@ class views_handler_field_date extends views_handler_field {
$date_formats = array();
$date_types = system_get_date_types();
foreach ($date_types as $key => $value) {
- $date_formats[$value['type']] = check_plain(t($value['title'] . ' format')) . ': ' . format_date(REQUEST_TIME, $value['type']);
+ $date_formats[$value['type']] = t('@date_format format', array('@date_format' => $value['title'])) . ': ' . format_date(REQUEST_TIME, $value['type']);
}
$form['date_format'] = array(
@@ -40,10 +47,18 @@ class views_handler_field_date extends views_handler_field {
$form['custom_date_format'] = array(
'#type' => 'textfield',
'#title' => t('Custom date format'),
- '#description' => t('If "Custom", see <a href="http://us.php.net/manual/en/function.date.php" target="_blank">the PHP docs</a> for date formats. Otherwise, enter the number of different time units to display, which defaults to 2.'),
+ '#description' => t('If "Custom", see the <a href="@url" target="_blank">PHP manual</a> for date formats. Otherwise, enter the number of different time units to display, which defaults to 2.', array('@url' => 'http://php.net/manual/function.date.php')),
'#default_value' => isset($this->options['custom_date_format']) ? $this->options['custom_date_format'] : '',
'#dependency' => array('edit-options-date-format' => array('custom', 'raw time ago', 'time ago', 'raw time hence', 'time hence', 'raw time span', 'time span', 'raw time span', 'inverse time span', 'time span')),
);
+ $form['timezone'] = array(
+ '#type' => 'select',
+ '#title' => t('Timezone'),
+ '#description' => t('Timezone to be used for date output.'),
+ '#options' => array('' => t('- Default site/user timezone -')) + system_time_zones(FALSE),
+ '#default_value' => $this->options['timezone'],
+ '#dependency' => array('edit-options-date-format' => array_merge(array('custom'), array_keys($date_formats))),
+ );
parent::options_form($form, $form_state);
}
@@ -56,6 +71,7 @@ class views_handler_field_date extends views_handler_field {
}
if ($value) {
+ $timezone = !empty($this->options['timezone']) ? $this->options['timezone'] : NULL;
$time_diff = REQUEST_TIME - $value; // will be positive for a datetime in the past (ago), and negative for a datetime in the future (hence)
switch ($format) {
case 'raw time ago':
@@ -74,11 +90,11 @@ class views_handler_field_date extends views_handler_field {
return t(($time_diff < 0 ? '%time hence' : '%time ago'), array('%time' => format_interval(abs($time_diff), is_numeric($custom_format) ? $custom_format : 2)));
case 'custom':
if ($custom_format == 'r') {
- return format_date($value, $format, $custom_format, null, 'en');
+ return format_date($value, $format, $custom_format, $timezone, 'en');
}
- return format_date($value, $format, $custom_format);
+ return format_date($value, $format, $custom_format, $timezone);
default:
- return format_date($value, $format);
+ return format_date($value, $format, '', $timezone);
}
}
}
diff --git a/kolab.org/www/drupal-7.15/sites/all/modules/views/handlers/views_handler_field_entity.inc b/kolab.org/www/drupal-7.15/sites/all/modules/views/handlers/views_handler_field_entity.inc
index 0e13b23..d8aaba4 100644
--- a/kolab.org/www/drupal-7.15/sites/all/modules/views/handlers/views_handler_field_entity.inc
+++ b/kolab.org/www/drupal-7.15/sites/all/modules/views/handlers/views_handler_field_entity.inc
@@ -1,4 +1,10 @@
<?php
+
+/**
+ * @file
+ * Definition of views_handler_field_entity.
+ */
+
/**
* A handler to display data from entity objects.
*
diff --git a/kolab.org/www/drupal-7.15/sites/all/modules/views/handlers/views_handler_field_machine_name.inc b/kolab.org/www/drupal-7.15/sites/all/modules/views/handlers/views_handler_field_machine_name.inc
index 96a0cf7..9f3587f 100644
--- a/kolab.org/www/drupal-7.15/sites/all/modules/views/handlers/views_handler_field_machine_name.inc
+++ b/kolab.org/www/drupal-7.15/sites/all/modules/views/handlers/views_handler_field_machine_name.inc
@@ -1,6 +1,11 @@
<?php
/**
+ * @file
+ * Definition of views_handler_field_machine_name.
+ */
+
+/**
* Field handler whichs allows to show machine name content as human name.
* @ingroup views_field_handlers
*
@@ -34,7 +39,7 @@ class views_handler_field_machine_name extends views_handler_field {
function option_definition() {
$options = parent::option_definition();
- $options['machine_name'] = array('default' => FALSE);
+ $options['machine_name'] = array('default' => FALSE, 'bool' => TRUE);
return $options;
}
diff --git a/kolab.org/www/drupal-7.15/sites/all/modules/views/handlers/views_handler_field_markup.inc b/kolab.org/www/drupal-7.15/sites/all/modules/views/handlers/views_handler_field_markup.inc
index 10444d5..b0f1cea 100644
--- a/kolab.org/www/drupal-7.15/sites/all/modules/views/handlers/views_handler_field_markup.inc
+++ b/kolab.org/www/drupal-7.15/sites/all/modules/views/handlers/views_handler_field_markup.inc
@@ -1,6 +1,11 @@
<?php
/**
+ * @file
+ * Definition of views_handler_field_markup.
+ */
+
+/**
* A handler to run a field through check_markup, using a companion
* format field.
*
diff --git a/kolab.org/www/drupal-7.15/sites/all/modules/views/handlers/views_handler_field_math.inc b/kolab.org/www/drupal-7.15/sites/all/modules/views/handlers/views_handler_field_math.inc
index 9df9987..08fba06 100644
--- a/kolab.org/www/drupal-7.15/sites/all/modules/views/handlers/views_handler_field_math.inc
+++ b/kolab.org/www/drupal-7.15/sites/all/modules/views/handlers/views_handler_field_math.inc
@@ -1,10 +1,16 @@
<?php
+
+/**
+ * @file
+ * Definition of views_handler_field_math.
+ */
+
/**
* Render a mathematical expression as a numeric value
*
* Definition terms:
* - float: If true this field contains a decimal value. If unset this field
- * will be assumed to be integer.
+ * will be assumed to be integer.
*
* @ingroup views_field_handlers
*/
@@ -20,7 +26,7 @@ class views_handler_field_math extends views_handler_field_numeric {
$form['expression'] = array(
'#type' => 'textarea',
'#title' => t('Expression'),
- '#description' => t('Enter mathematical expressions such as 2 + 2 or sqrt(5). You my assign variables and create mathematical functions and evaluate them. Use the ; to separate these. For example: f(x) = x + 2; f(2).'),
+ '#description' => t('Enter mathematical expressions such as 2 + 2 or sqrt(5). You may assign variables and create mathematical functions and evaluate them. Use the ; to separate these. For example: f(x) = x + 2; f(2).'),
'#default_value' => $this->options['expression'],
);
diff --git a/kolab.org/www/drupal-7.15/sites/all/modules/views/handlers/views_handler_field_numeric.inc b/kolab.org/www/drupal-7.15/sites/all/modules/views/handlers/views_handler_field_numeric.inc
index 5f7f450..d10d3d0 100644
--- a/kolab.org/www/drupal-7.15/sites/all/modules/views/handlers/views_handler_field_numeric.inc
+++ b/kolab.org/www/drupal-7.15/sites/all/modules/views/handlers/views_handler_field_numeric.inc
@@ -1,4 +1,10 @@
<?php
+
+/**
+ * @file
+ * Definition of views_handler_field_numeric.
+ */
+
/**
* Render a field as a numeric value
*
@@ -12,11 +18,11 @@ class views_handler_field_numeric extends views_handler_field {
function option_definition() {
$options = parent::option_definition();
- $options['set_precision'] = array('default' => FALSE);
+ $options['set_precision'] = array('default' => FALSE, 'bool' => TRUE);
$options['precision'] = array('default' => 0);
$options['decimal'] = array('default' => '.', 'translatable' => TRUE);
$options['separator'] = array('default' => ',', 'translatable' => TRUE);
- $options['format_plural'] = array('default' => FALSE);
+ $options['format_plural'] = array('default' => FALSE, 'bool' => TRUE);
$options['format_plural_singular'] = array('default' => '1');
$options['format_plural_plural'] = array('default' => '@count');
$options['prefix'] = array('default' => '', 'translatable' => TRUE);
diff --git a/kolab.org/www/drupal-7.15/sites/all/modules/views/handlers/views_handler_field_prerender_list.inc b/kolab.org/www/drupal-7.15/sites/all/modules/views/handlers/views_handler_field_prerender_list.inc
index 16b30b6..00a571a 100644
--- a/kolab.org/www/drupal-7.15/sites/all/modules/views/handlers/views_handler_field_prerender_list.inc
+++ b/kolab.org/www/drupal-7.15/sites/all/modules/views/handlers/views_handler_field_prerender_list.inc
@@ -1,6 +1,11 @@
<?php
/**
+ * @file
+ * Definition of views_handler_field_prerender_list.
+ */
+
+/**
* Field handler to provide a list of items.
*
* The items are expected to be loaded by a child object during pre_render,
@@ -84,7 +89,7 @@ class views_handler_field_prerender_list extends views_handler_field {
function render_items($items) {
if (!empty($items)) {
if ($this->options['type'] == 'separator') {
- return implode($this->sanitize_value($this->options['separator']), $items);
+ return implode($this->sanitize_value($this->options['separator'], 'xss_admin'), $items);
}
else {
return theme('item_list',
diff --git a/kolab.org/www/drupal-7.15/sites/all/modules/views/handlers/views_handler_field_serialized.inc b/kolab.org/www/drupal-7.15/sites/all/modules/views/handlers/views_handler_field_serialized.inc
index 01dd0c0..1579fce 100644
--- a/kolab.org/www/drupal-7.15/sites/all/modules/views/handlers/views_handler_field_serialized.inc
+++ b/kolab.org/www/drupal-7.15/sites/all/modules/views/handlers/views_handler_field_serialized.inc
@@ -1,6 +1,11 @@
<?php
/**
+ * @file
+ * Definition of views_handler_field_serialized.
+ */
+
+/**
* Field handler to show data of serialized fields.
*
* @ingroup views_field_handlers
diff --git a/kolab.org/www/drupal-7.15/sites/all/modules/views/handlers/views_handler_field_time_interval.inc b/kolab.org/www/drupal-7.15/sites/all/modules/views/handlers/views_handler_field_time_interval.inc
index ca50885..e6063af 100644
--- a/kolab.org/www/drupal-7.15/sites/all/modules/views/handlers/views_handler_field_time_interval.inc
+++ b/kolab.org/www/drupal-7.15/sites/all/modules/views/handlers/views_handler_field_time_interval.inc
@@ -1,4 +1,10 @@
<?php
+
+/**
+ * @file
+ * Definition of views_handler_field_time_interval.
+ */
+
/**
* A handler to provide proper displays for time intervals.
*
diff --git a/kolab.org/www/drupal-7.15/sites/all/modules/views/handlers/views_handler_field_url.inc b/kolab.org/www/drupal-7.15/sites/all/modules/views/handlers/views_handler_field_url.inc
index 2491f35..4a76548 100644
--- a/kolab.org/www/drupal-7.15/sites/all/modules/views/handlers/views_handler_field_url.inc
+++ b/kolab.org/www/drupal-7.15/sites/all/modules/views/handlers/views_handler_field_url.inc
@@ -1,6 +1,11 @@
<?php
/**
+ * @file
+ * Definition of views_handler_field_url.
+ */
+
+/**
* Field handler to provide simple renderer that turns a URL into a clickable link.
*
* @ingroup views_field_handlers
@@ -9,7 +14,7 @@ class views_handler_field_url extends views_handler_field {
function option_definition() {
$options = parent::option_definition();
- $options['display_as_link'] = array('default' => TRUE);
+ $options['display_as_link'] = array('default' => TRUE, 'bool' => TRUE);
return $options;
}
@@ -29,7 +34,10 @@ class views_handler_field_url extends views_handler_field {
function render($values) {
$value = $this->get_value($values);
if (!empty($this->options['display_as_link'])) {
- return l($this->sanitize_value($value), $value, array('html' => TRUE));
+ $this->options['alter']['make_link'] = TRUE;
+ $this->options['alter']['path'] = $value;
+ $text = !empty($this->options['text']) ? $this->sanitize_value($this->options['text']) : $this->sanitize_value($value, 'url');
+ return $text;
}
else {
return $this->sanitize_value($value, 'url');
diff --git a/kolab.org/www/drupal-7.15/sites/all/modules/views/handlers/views_handler_filter.inc b/kolab.org/www/drupal-7.15/sites/all/modules/views/handlers/views_handler_filter.inc
index b267976..f5db70f 100644
--- a/kolab.org/www/drupal-7.15/sites/all/modules/views/handlers/views_handler_filter.inc
+++ b/kolab.org/www/drupal-7.15/sites/all/modules/views/handlers/views_handler_filter.inc
@@ -1,6 +1,12 @@
<?php
+
/**
- * @defgroup views_filter_handlers Views' filter handlers
+ * @file
+ * @todo.
+ */
+
+/**
+ * @defgroup views_filter_handlers Views filter handlers
* @{
* Handlers to tell Views how to filter queries.
*
@@ -22,6 +28,8 @@
/**
* Base class for filters.
+ *
+ * @ingroup views_filter_handlers
*/
class views_handler_filter extends views_handler {
/**
@@ -36,6 +44,11 @@ class views_handler_filter extends views_handler {
var $operator = '=';
/**
+ * Contains the information of the selected item in a gruped filter.
+ */
+ var $group_info = NULL;
+
+ /**
* @var bool
* Disable the possibility to force a single value.
*/
@@ -64,6 +77,7 @@ class views_handler_filter extends views_handler {
$this->operator = $this->options['operator'];
$this->value = $this->options['value'];
+ $this->group_info = $this->options['group_info']['default_group'];
// Compatibility: The new UI changed several settings.
if (!empty($options['exposed']) && !empty($options['expose']['optional']) && !isset($options['expose']['required'])) {
@@ -76,6 +90,11 @@ class views_handler_filter extends views_handler {
$this->options['expose']['operator_id'] = $options['expose']['operator_id'] = $options['expose']['operator'];
}
+ if ($this->multiple_exposed_input()) {
+ $this->group_info = array_filter($options['group_info']['default_group_multiple']);
+ $this->options['expose']['multiple'] = TRUE;
+ }
+
// If there are relationships in the view, allow empty should be true
// so that we can do IS NULL checks on items. Not all filters respect
// allow empty, but string and numeric do and that covers enough.
@@ -90,17 +109,45 @@ class views_handler_filter extends views_handler {
$options['operator'] = array('default' => '=');
$options['value'] = array('default' => '');
$options['group'] = array('default' => '1');
- $options['exposed'] = array('default' => FALSE);
+ $options['exposed'] = array('default' => FALSE, 'bool' => TRUE);
$options['expose'] = array(
'contains' => array(
'operator_id' => array('default' => FALSE),
'label' => array('default' => '', 'translatable' => TRUE),
- 'use_operator' => array('default' => 0),
+ 'description' => array('default' => '', 'translatable' => TRUE),
+ 'use_operator' => array('default' => FALSE, 'bool' => TRUE),
'operator' => array('default' => ''),
'identifier' => array('default' => ''),
- 'required' => array('default' => 0),
+ 'required' => array('default' => FALSE, 'bool' => TRUE),
+ 'remember' => array('default' => FALSE, 'bool' => TRUE),
+ 'multiple' => array('default' => FALSE, 'bool' => TRUE),
+ 'remember_roles' => array('default' => array(
+ DRUPAL_AUTHENTICATED_RID => DRUPAL_AUTHENTICATED_RID,
+ )),
+ ),
+ );
+
+ // A group is a combination of a filter, an operator and a value
+ // operating like a single filter.
+ // Users can choose from a select box which group they want to apply.
+ // Views will filter the view according to the defined values.
+ // Because it acts as a standard filter, we have to define
+ // an identifier and other settings like the widget and the label.
+ // This settings are saved in another array to allow users to switch
+ // between a normal filter and a group of filters with a single click.
+ $options['is_grouped'] = array('default' => FALSE, 'bool' => TRUE);
+ $options['group_info'] = array(
+ 'contains' => array(
+ 'label' => array('default' => '', 'translatable' => TRUE),
+ 'description' => array('default' => '', 'translatable' => TRUE),
+ 'identifier' => array('default' => ''),
+ 'optional' => array('default' => TRUE, 'bool' => TRUE),
+ 'widget' => array('default' => 'select'),
+ 'multiple' => array('default' => FALSE, 'bool' => TRUE),
'remember' => array('default' => 0),
- 'multiple' => array('default' => 0),
+ 'default_group' => array('default' => 'All'),
+ 'default_group_multiple' => array('default' => array()),
+ 'group_items' => array('default' => array()),
),
);
@@ -120,6 +167,21 @@ class views_handler_filter extends views_handler {
function can_expose() { return TRUE; }
/**
+ * Determine if a filter can be converted into a group.
+ * Only exposed filters with operators available can be converted into groups.
+ */
+ function can_build_group() {
+ return $this->is_exposed() && (count($this->operator_options()) > 0);
+ }
+
+ /**
+ * Returns TRUE if the exposed filter works like a grouped filter.
+ */
+ function is_a_group() {
+ return $this->is_exposed() && !empty($this->options['is_grouped']);
+ }
+
+ /**
* Provide the basic form which calls through to subforms.
* If overridden, it is best to call through to the parent,
* or to at least make sure all of the functions in this form
@@ -130,19 +192,36 @@ class views_handler_filter extends views_handler {
if ($this->can_expose()) {
$this->show_expose_button($form, $form_state);
}
+ if ($this->can_build_group()) {
+ $this->show_build_group_button($form, $form_state);
+ }
$form['clear_markup_start'] = array(
'#markup' => '<div class="clearfix">',
);
- // Add the subform from operator_form().
- $this->show_operator_form($form, $form_state);
- // Add the subform from value_form().
- $this->show_value_form($form, $form_state);
- $form['clear_markup_end'] = array(
- '#markup' => '</div>',
- );
- if ($this->can_expose()) {
- // Add the subform from expose_form().
- $this->show_expose_form($form, $form_state);
+ if ($this->is_a_group()) {
+ if ($this->can_build_group()) {
+ $form['clear_markup_start'] = array(
+ '#markup' => '<div class="clearfix">',
+ );
+ // Render the build group form.
+ $this->show_build_group_form($form, $form_state);
+ $form['clear_markup_end'] = array(
+ '#markup' => '</div>',
+ );
+ }
+ }
+ else {
+ // Add the subform from operator_form().
+ $this->show_operator_form($form, $form_state);
+ // Add the subform from value_form().
+ $this->show_value_form($form, $form_state);
+ $form['clear_markup_end'] = array(
+ '#markup' => '</div>',
+ );
+ if ($this->can_expose()) {
+ // Add the subform from expose_form().
+ $this->show_expose_form($form, $form_state);
+ }
}
}
@@ -152,9 +231,12 @@ class views_handler_filter extends views_handler {
function options_validate(&$form, &$form_state) {
$this->operator_validate($form, $form_state);
$this->value_validate($form, $form_state);
- if (!empty($this->options['exposed'])) {
+ if (!empty($this->options['exposed']) && !$this->is_a_group()) {
$this->expose_validate($form, $form_state);
}
+ if ($this->is_a_group()) {
+ $this->build_group_validate($form, $form_state);
+ }
}
/**
@@ -162,11 +244,17 @@ class views_handler_filter extends views_handler {
*/
function options_submit(&$form, &$form_state) {
unset($form_state['values']['expose_button']); // don't store this.
- $this->operator_submit($form, $form_state);
- $this->value_submit($form, $form_state);
+ unset($form_state['values']['group_button']); // don't store this.
+ if (!$this->is_a_group()) {
+ $this->operator_submit($form, $form_state);
+ $this->value_submit($form, $form_state);
+ }
if (!empty($this->options['exposed'])) {
$this->expose_submit($form, $form_state);
}
+ if ($this->is_a_group()) {
+ $this->build_group_submit($form, $form_state);
+ }
}
/**
@@ -184,7 +272,7 @@ class views_handler_filter extends views_handler {
* This may be overridden by child classes, and it must
* define $form['operator'];
*
- * @see options_form().
+ * @see options_form()
*/
function operator_form(&$form, &$form_state) {
$options = $this->operator_options();
@@ -232,7 +320,7 @@ class views_handler_filter extends views_handler {
* This should be overridden by all child classes and it must
* define $form['value']
*
- * @see options_form().
+ * @see options_form()
*/
function value_form(&$form, &$form_state) { $form['value'] = array(); }
@@ -248,6 +336,78 @@ class views_handler_filter extends views_handler {
function value_submit($form, &$form_state) { }
/**
+ * Shortcut to display the exposed options form.
+ */
+ function show_build_group_form(&$form, &$form_state) {
+ if (empty($this->options['is_grouped'])) {
+ return;
+ }
+
+ $this->build_group_form($form, $form_state);
+
+ // When we click the expose button, we add new gadgets to the form but they
+ // have no data in $_POST so their defaults get wiped out. This prevents
+ // these defaults from getting wiped out. This setting will only be TRUE
+ // during a 2nd pass rerender.
+ if (!empty($form_state['force_build_group_options'])) {
+ foreach (element_children($form['group_info']) as $id) {
+ if (isset($form['group_info'][$id]['#default_value']) && !isset($form['group_info'][$id]['#value'])) {
+ $form['group_info'][$id]['#value'] = $form['group_info'][$id]['#default_value'];
+ }
+ }
+ }
+ }
+
+ /**
+ * Shortcut to display the build_group/hide button.
+ */
+ function show_build_group_button(&$form, &$form_state) {
+
+ $form['group_button'] = array(
+ '#prefix' => '<div class="views-grouped clearfix">',
+ '#suffix' => '</div>',
+ // Should always come after the description and the relationship.
+ '#weight' => -190,
+ );
+
+ $grouped_description = t('Grouped filters allow a choice between predefined operator|value pairs.');
+ $form['group_button']['radios'] = array(
+ '#theme_wrappers' => array('container'),
+ '#attributes' => array('class' => array('js-only')),
+ );
+ $form['group_button']['radios']['radios'] = array(
+ '#title' => t('Filter type to expose'),
+ '#description' => $grouped_description,
+ '#type' => 'radios',
+ '#options' => array(
+ t('Single filter'),
+ t('Grouped filters'),
+ ),
+ );
+
+ if (empty($this->options['is_grouped'])) {
+ $form['group_button']['markup'] = array(
+ '#markup' => '<div class="description grouped-description">' . $grouped_description . '</div>',
+ );
+ $form['group_button']['button'] = array(
+ '#limit_validation_errors' => array(),
+ '#type' => 'submit',
+ '#value' => t('Grouped filters'),
+ '#submit' => array('views_ui_config_item_form_build_group'),
+ );
+ $form['group_button']['radios']['radios']['#default_value'] = 0;
+ }
+ else {
+ $form['group_button']['button'] = array(
+ '#limit_validation_errors' => array(),
+ '#type' => 'submit',
+ '#value' => t('Single filter'),
+ '#submit' => array('views_ui_config_item_form_build_group'),
+ );
+ $form['group_button']['radios']['radios']['#default_value'] = 1;
+ }
+ }
+ /**
* Shortcut to display the expose/hide button.
*/
function show_expose_button(&$form, &$form_state) {
@@ -299,7 +459,7 @@ class views_handler_filter extends views_handler {
/**
* Options form subform for exposed filter options.
*
- * @see options_form().
+ * @see options_form()
*/
function expose_form(&$form, &$form_state) {
$form['#theme'] = 'views_ui_expose_filter_form';
@@ -330,6 +490,13 @@ class views_handler_filter extends views_handler {
'#size' => 40,
);
+ $form['expose']['description'] = array(
+ '#type' => 'textfield',
+ '#default_value' => $this->options['expose']['description'],
+ '#title' => t('Description'),
+ '#size' => 60,
+ );
+
if (!empty($form['operator']['#type'])) {
// Increase the width of the left (operator) column.
$form['operator']['#prefix'] = '<div class="views-group-box views-left-40">';
@@ -377,6 +544,18 @@ class views_handler_filter extends views_handler {
'#default_value' => $this->options['expose']['remember'],
);
+ $role_options = array_map('check_plain', user_roles());
+ $form['expose']['remember_roles'] = array(
+ '#type' => 'checkboxes',
+ '#title' => t('User roles'),
+ '#description' => t('Remember exposed selection only for the selected user role(s). If you select no roles, the exposed data will never be stored.'),
+ '#default_value' => $this->options['expose']['remember_roles'],
+ '#options' => $role_options,
+ '#dependency' => array(
+ 'edit-options-expose-remember' => array(1),
+ ),
+ );
+
$form['expose']['identifier'] = array(
'#type' => 'textfield',
'#default_value' => $this->options['expose']['identifier'],
@@ -404,6 +583,83 @@ class views_handler_filter extends views_handler {
}
}
+ /**
+ * Validate the build group options form.
+ */
+ function build_group_validate($form, &$form_state) {
+ if (!empty($form_state['values']['options']['group_info'])) {
+ if (empty($form_state['values']['options']['group_info']['identifier'])) {
+ form_error($form['group_info']['identifier'], t('The identifier is required if the filter is exposed.'));
+ }
+
+ if (!empty($form_state['values']['options']['group_info']['identifier']) && $form_state['values']['options']['group_info']['identifier'] == 'value') {
+ form_error($form['group_info']['identifier'], t('This identifier is not allowed.'));
+ }
+
+ if (!$this->view->display_handler->is_identifier_unique($form_state['id'], $form_state['values']['options']['group_info']['identifier'])) {
+ form_error($form['group_info']['identifier'], t('This identifier is used by another handler.'));
+ }
+ }
+
+ if (!empty($form_state['values']['options']['group_info']['group_items'])) {
+ foreach ($form_state['values']['options']['group_info']['group_items'] as $id => $group) {
+ if (empty($group['remove'])) {
+
+ // Check if the title is defined but value wasn't defined.
+ if (!empty($group['title'])) {
+ if ((!is_array($group['value']) && trim($group['value']) == "") ||
+ (is_array($group['value']) && count(array_filter($group['value'], '_views_array_filter_zero')) == 0)) {
+ form_error($form['group_info']['group_items'][$id]['value'],
+ t('The value is required if title for this item is defined.'));
+ }
+ }
+
+ // Check if the value is defined but title wasn't defined.
+ if ((!is_array($group['value']) && trim($group['value']) != "") ||
+ (is_array($group['value']) && count(array_filter($group['value'], '_views_array_filter_zero')) > 0)) {
+ if (empty($group['title'])) {
+ form_error($form['group_info']['group_items'][$id]['title'],
+ t('The title is required if value for this item is defined.'));
+ }
+ }
+ }
+ }
+ }
+ }
+
+ /**
+ * Save new group items, re-enumerates and remove groups marked to delete.
+ */
+ function build_group_submit($form, &$form_state) {
+ $groups = array();
+ uasort($form_state['values']['options']['group_info']['group_items'], 'drupal_sort_weight');
+ // Filter out removed items.
+
+ // Start from 1 to avoid problems with #default_value in the widget.
+ $new_id = 1;
+ $new_default = 'All';
+ foreach ($form_state['values']['options']['group_info']['group_items'] as $id => $group) {
+ if (empty($group['remove'])) {
+ // Don't store this.
+ unset($group['remove']);
+ unset($group['weight']);
+ $groups[$new_id] = $group;
+
+ if ($form_state['values']['options']['group_info']['default_group'] === $id) {
+ $new_default = $new_id;
+ }
+ }
+ $new_id++;
+ }
+ if ($new_default != 'All') {
+ $form_state['values']['options']['group_info']['default_group'] = $new_default;
+ }
+ $filter_default_multiple = array_filter($form_state['values']['options']['group_info']['default_group_multiple']);
+ $form_state['values']['options']['group_info']['default_group_multiple'] = $filter_default_multiple;
+
+ $form_state['values']['options']['group_info']['group_items'] = $groups;
+ }
+
/**
* Provide default options for exposed filters.
*/
@@ -413,12 +669,76 @@ class views_handler_filter extends views_handler {
'operator' => $this->options['id'] . '_op',
'identifier' => $this->options['id'],
'label' => $this->definition['title'],
+ 'description' => NULL,
'remember' => FALSE,
'multiple' => FALSE,
'required' => FALSE,
);
}
+ /**
+ * Provide default options for exposed filters.
+ */
+ function build_group_options() {
+ $this->options['group_info'] = array(
+ 'label' => $this->definition['title'],
+ 'description' => NULL,
+ 'identifier' => $this->options['id'],
+ 'optional' => TRUE,
+ 'widget' => 'select',
+ 'multiple' => FALSE,
+ 'remember' => FALSE,
+ 'default_group' => 'All',
+ 'default_group_multiple' => array(),
+ 'group_items' => array(),
+ );
+ }
+
+ /**
+ * Build a form containing a group of operator | values to apply as a
+ * single filter.
+ */
+ function group_form(&$form, &$form_state) {
+ if (!empty($this->options['group_info']['optional']) && !$this->multiple_exposed_input()) {
+
+ $old_any = $this->options['group_info']['widget'] == 'select' ? '<Any>' : '&lt;Any&gt;';
+ $any_label = variable_get('views_exposed_filter_any_label', 'new_any') == 'old_any' ? $old_any : t('- Any -');
+ $groups = array('All' => $any_label);
+ }
+ foreach ($this->options['group_info']['group_items'] as $id => $group) {
+ if (!empty($group['title'])) {
+ $groups[$id] = $id != 'All' ? t($group['title']) : $group['title'];
+ }
+ }
+
+ if (count($groups)) {
+ $value = $this->options['group_info']['identifier'];
+
+ $form[$value] = array(
+ '#type' => $this->options['group_info']['widget'],
+ '#default_value' => $this->group_info,
+ '#options' => $groups,
+ );
+ if (!empty($this->options['group_info']['multiple'])) {
+ if (count($groups) < 5) {
+ $form[$value]['#type'] = 'checkboxes';
+ }
+ else {
+ $form[$value]['#type'] = 'select';
+ $form[$value]['#size'] = 5;
+ $form[$value]['#multiple'] = TRUE;
+ }
+ unset($form[$value]['#default_value']);
+ if (empty($form_state['input'])) {
+ $form_state['input'][$value] = $this->group_info;
+ }
+ }
+
+ $this->options['expose']['label'] = '';
+ }
+ }
+
+
/**
* Render our chunk of the exposed filter form when selecting
*
@@ -471,6 +791,254 @@ class views_handler_filter extends views_handler {
}
/**
+ * Build the form to let users create the group of exposed filters.
+ * This form is displayed when users click on button 'Build group'
+ */
+ function build_group_form(&$form, &$form_state) {
+ if (empty($this->options['exposed']) || empty($this->options['is_grouped'])) {
+ return;
+ }
+ $form['#theme'] = 'views_ui_build_group_filter_form';
+
+ // #flatten will move everything from $form['group_info'][$key] to $form[$key]
+ // prior to rendering. That's why the pre_render for it needs to run first,
+ // so that when the next pre_render (the one for fieldsets) runs, it gets
+ // the flattened data.
+ array_unshift($form['#pre_render'], 'views_ui_pre_render_flatten_data');
+ $form['group_info']['#flatten'] = TRUE;
+
+ if (!empty($this->options['group_info']['identifier'])) {
+ $identifier = $this->options['group_info']['identifier'];
+ }
+ else {
+ $identifier = 'group_' . $this->options['expose']['identifier'];
+ }
+ $form['group_info']['identifier'] = array(
+ '#type' => 'textfield',
+ '#default_value' => $identifier,
+ '#title' => t('Filter identifier'),
+ '#size' => 40,
+ '#description' => t('This will appear in the URL after the ? to identify this filter. Cannot be blank.'),
+ '#fieldset' => 'more',
+ );
+ $form['group_info']['label'] = array(
+ '#type' => 'textfield',
+ '#default_value' => $this->options['group_info']['label'],
+ '#title' => t('Label'),
+ '#size' => 40,
+ );
+
+ $form['group_info']['optional'] = array(
+ '#type' => 'checkbox',
+ '#title' => t('Optional'),
+ '#description' => t('This exposed filter is optional and will have added options to allow it not to be set.'),
+ '#default_value' => $this->options['group_info']['optional'],
+ );
+ $form['group_info']['multiple'] = array(
+ '#type' => 'checkbox',
+ '#title' => t('Allow multiple selections'),
+ '#description' => t('Enable to allow users to select multiple items.'),
+ '#default_value' => $this->options['group_info']['multiple'],
+ );
+ $form['group_info']['widget'] = array(
+ '#type' => 'radios',
+ '#default_value' => $this->options['group_info']['widget'],
+ '#title' => t('Widget type'),
+ '#options' => array(
+ 'radios' => t('Radios'),
+ 'select' => t('Select'),
+ ),
+ '#description' => t('Select which kind of widget will be used to render the group of filters'),
+ );
+ $form['group_info']['remember'] = array(
+ '#type' => 'checkbox',
+ '#title' => t('Remember'),
+ '#description' => t('Remember the last setting the user gave this filter.'),
+ '#default_value' => $this->options['group_info']['remember'],
+ );
+
+ if (!empty($this->options['group_info']['identifier'])) {
+ $identifier = $this->options['group_info']['identifier'];
+ }
+ else {
+ $identifier = 'group_' . $this->options['expose']['identifier'];
+ }
+ $form['group_info']['identifier'] = array(
+ '#type' => 'textfield',
+ '#default_value' => $identifier,
+ '#title' => t('Filter identifier'),
+ '#size' => 40,
+ '#description' => t('This will appear in the URL after the ? to identify this filter. Cannot be blank.'),
+ '#fieldset' => 'more',
+ );
+ $form['group_info']['label'] = array(
+ '#type' => 'textfield',
+ '#default_value' => $this->options['group_info']['label'],
+ '#title' => t('Label'),
+ '#size' => 40,
+ );
+ $form['group_info']['description'] = array(
+ '#type' => 'textfield',
+ '#default_value' => $this->options['group_info']['description'],
+ '#title' => t('Description'),
+ '#size' => 60,
+ );
+ $form['group_info']['optional'] = array(
+ '#type' => 'checkbox',
+ '#title' => t('Optional'),
+ '#description' => t('This exposed filter is optional and will have added options to allow it not to be set.'),
+ '#default_value' => $this->options['group_info']['optional'],
+ );
+ $form['group_info']['widget'] = array(
+ '#type' => 'radios',
+ '#default_value' => $this->options['group_info']['widget'],
+ '#title' => t('Widget type'),
+ '#options' => array(
+ 'radios' => t('Radios'),
+ 'select' => t('Select'),
+ ),
+ '#description' => t('Select which kind of widget will be used to render the group of filters'),
+ );
+ $form['group_info']['remember'] = array(
+ '#type' => 'checkbox',
+ '#title' => t('Remember'),
+ '#description' => t('Remember the last setting the user gave this filter.'),
+ '#default_value' => $this->options['group_info']['remember'],
+ );
+
+ $groups = array('All' => '- Any -'); // The string '- Any -' will not be rendered see @theme_views_ui_build_group_filter_form
+
+ // Provide 3 options to start when we are in a new group.
+ if (count($this->options['group_info']['group_items']) == 0) {
+ $this->options['group_info']['group_items'] = array_fill(1, 3, array());
+ }
+
+ // After the general settings, comes a table with all the existent groups.
+ $default_weight = 0;
+ foreach ($this->options['group_info']['group_items'] as $item_id => $item) {
+ if (!empty($form_state['values']['options']['group_info']['group_items'][$item_id]['remove'])) {
+ continue;
+ }
+ // Each rows contains three widgets:
+ // a) The title, where users define how they identify a pair of operator | value
+ // b) The operator
+ // c) The value (or values) to use in the filter with the selected operator
+
+ // In each row, we have to display the operator form and the value from
+ // $row acts as a fake form to render each widget in a row.
+ $row = array();
+ $groups[$item_id] = '';
+ $this->operator_form($row, $form_state);
+ // Force the operator form to be a select box. Some handlers uses
+ // radios and they occupy a lot of space in a table row.
+ $row['operator']['#type'] = 'select';
+ $row['operator']['#title'] = '';
+ $this->value_form($row, $form_state);
+
+ // Fix the dependencies to update value forms when operators
+ // changes. This is needed because forms are inside a new form and
+ // their ids changes. Dependencies are used when operator changes
+ // from to 'Between', 'Not Between', etc, and two or more widgets
+ // are displayed.
+ $without_children = TRUE;
+ foreach (element_children($row['value']) as $children) {
+ if (isset($row['value'][$children]['#dependency']['edit-options-operator'])) {
+ $row['value'][$children]['#dependency']["edit-options-group-info-group-items-$item_id-operator"] = $row['value'][$children]['#dependency']['edit-options-operator'];
+ unset($row['value'][$children]['#dependency']['edit-options-operator']);
+ $row['value'][$children]['#title'] = '';
+
+ if (!empty($this->options['group_info']['group_items'][$item_id]['value'][$children])) {
+ $row['value'][$children]['#default_value'] = $this->options['group_info']['group_items'][$item_id]['value'][$children];
+ }
+ }
+ $without_children = FALSE;
+ }
+
+ if ($without_children) {
+ if (!empty($this->options['group_info']['group_items'][$item_id]['value'])) {
+ $row['value']['#default_value'] = $this->options['group_info']['group_items'][$item_id]['value'];
+ }
+ }
+
+ if (!empty($this->options['group_info']['group_items'][$item_id]['operator'])) {
+ $row['operator']['#default_value'] = $this->options['group_info']['group_items'][$item_id]['operator'];
+ }
+
+ $default_title = '';
+ if (!empty($this->options['group_info']['group_items'][$item_id]['title'])) {
+ $default_title = $this->options['group_info']['group_items'][$item_id]['title'];
+ }
+
+ // Per item group, we have a title that identifies it.
+ $form['group_info']['group_items'][$item_id] = array(
+ 'title' => array(
+ '#type' => 'textfield',
+ '#size' => 20,
+ '#default_value' => $default_title,
+ ),
+ 'operator' => $row['operator'],
+ 'value' => $row['value'],
+ 'remove' => array(
+ '#type' => 'checkbox',
+ '#id' => 'views-removed-' . $item_id,
+ '#attributes' => array('class' => array('views-remove-checkbox')),
+ '#default_value' => 0,
+ ),
+ 'weight' => array(
+ '#type' => 'weight',
+ '#delta' => 10,
+ '#default_value' => $default_weight++,
+ '#attributes' => array('class' => array('weight')),
+ ),
+ );
+ }
+ // From all groups, let chose which is the default.
+ $form['group_info']['default_group'] = array(
+ '#type' => 'radios',
+ '#options' => $groups,
+ '#default_value' => $this->options['group_info']['default_group'],
+ '#required' => TRUE,
+ '#attributes' => array(
+ 'class' => array('default-radios'),
+ )
+ );
+ // From all groups, let chose which is the default.
+ $form['group_info']['default_group_multiple'] = array(
+ '#type' => 'checkboxes',
+ '#options' => $groups,
+ '#default_value' => $this->options['group_info']['default_group_multiple'],
+ '#attributes' => array(
+ 'class' => array('default-checkboxes'),
+ )
+ );
+
+ $form['group_info']['add_group'] = array(
+ '#prefix' => '<div class="views-build-group clear-block">',
+ '#suffix' => '</div>',
+ '#type' => 'submit',
+ '#value' => t('Add another item'),
+ '#submit' => array('views_ui_config_item_form_add_group'),
+ );
+
+ $js = array();
+ $js['tableDrag']['views-filter-groups']['weight'][0] = array(
+ 'target' => 'weight',
+ 'source' => NULL,
+ 'relationship' => 'sibling',
+ 'action' => 'order',
+ 'hidden' => TRUE,
+ 'limit' => 0,
+ );
+ if (!empty($form_state['js settings']) && is_array($js)) {
+ $form_state['js settings'] = array_merge($form_state['js settings'], $js);
+ }
+ else {
+ $form_state['js settings'] = $js;
+ }
+ }
+
+
+ /**
* Make some translations to a form item to make it more suitable to
* exposing.
*/
@@ -496,6 +1064,11 @@ class views_handler_filter extends views_handler {
$form['#size'] = NULL;
}
+ // Cleanup in case the translated element's (radios or checkboxes) display value contains html.
+ if ($form['#type'] == 'select') {
+ $this->prepare_filter_select_options($form['#options']);
+ }
+
if ($type == 'value' && empty($this->always_required) && empty($this->options['expose']['required']) && $form['#type'] == 'select' && empty($form['#multiple'])) {
$any_label = variable_get('views_exposed_filter_any_label', 'new_any') == 'old_any' ? t('<Any>') : t('- Any -');
$form['#options'] = array('All' => $any_label) + $form['#options'];
@@ -507,28 +1080,168 @@ class views_handler_filter extends views_handler {
}
}
+
+
+ /**
+ * Sanitizes the HTML select element's options.
+ *
+ * The function is recursive to support optgroups.
+ */
+ function prepare_filter_select_options(&$options) {
+ foreach ($options as $value => $label) {
+ // Recurse for optgroups.
+ if (is_array($label)) {
+ $this->prepare_filter_select_options($options[$value]);
+ }
+ // FAPI has some special value to allow hierarchy.
+ // @see _form_options_flatten
+ elseif (is_object($label)) {
+ $this->prepare_filter_select_options($options[$value]->option);
+ }
+ else {
+ $options[$value] = strip_tags(decode_entities($label));
+ }
+ }
+ }
+
/**
* Tell the renderer about our exposed form. This only needs to be
* overridden for particularly complex forms. And maybe not even then.
*
* @return array|null
- * An array with the following keys:
+ * For standard exposed filters. An array with the following keys:
* - operator: The $form key of the operator. Set to NULL if no operator.
* - value: The $form key of the value. Set to NULL if no value.
* - label: The label to use for this piece.
+ * For grouped exposed filters. An array with the following keys:
+ * - value: The $form key of the value. Set to NULL if no value.
+ * - label: The label to use for this piece.
*/
function exposed_info() {
if (empty($this->options['exposed'])) {
return;
}
+ if ($this->is_a_group()) {
+ return array(
+ 'value' => $this->options['group_info']['identifier'],
+ 'label' => $this->options['group_info']['label'],
+ 'description' => $this->options['group_info']['description'],
+ );
+ }
+
return array(
'operator' => $this->options['expose']['operator_id'],
'value' => $this->options['expose']['identifier'],
'label' => $this->options['expose']['label'],
+ 'description' => $this->options['expose']['description'],
);
}
+ /*
+ * Transform the input from a grouped filter into a standard filter.
+ *
+ * When a filter is a group, find the set of operator and values
+ * that the choosed item represents, and inform views that a normal
+ * filter was submitted by telling the operator and the value selected.
+ *
+ * The param $selected_group_id is only passed when the filter uses the
+ * checkboxes widget, and this function will be called for each item
+ * choosed in the checkboxes.
+ */
+ function convert_exposed_input(&$input, $selected_group_id = NULL) {
+ if ($this->is_a_group()) {
+ // If it is already defined the selected group, use it. Only valid
+ // when the filter uses checkboxes for widget.
+ if (!empty($selected_group_id)) {
+ $selected_group = $selected_group_id;
+ }
+ else {
+ $selected_group = $input[$this->options['group_info']['identifier']];
+ }
+ if ($selected_group == 'All' && !empty($this->options['group_info']['optional'])) {
+ return NULL;
+ }
+ if ($selected_group != 'All' && empty($this->options['group_info']['group_items'][$selected_group])) {
+ return FALSE;
+ }
+ if (isset($selected_group) && isset($this->options['group_info']['group_items'][$selected_group])) {
+ $input[$this->options['expose']['operator']] = $this->options['group_info']['group_items'][$selected_group]['operator'];
+
+ // Value can be optional, For example for 'empty' and 'not empty' filters.
+ if (!empty($this->options['group_info']['group_items'][$selected_group]['value'])) {
+ $input[$this->options['expose']['identifier']] = $this->options['group_info']['group_items'][$selected_group]['value'];
+ }
+ $this->options['expose']['use_operator'] = TRUE;
+
+ $this->group_info = $input[$this->options['group_info']['identifier']];
+ return TRUE;
+ }
+ else {
+ return FALSE;
+ }
+ }
+ }
+
+ /**
+ * Returns the options available for a grouped filter that users checkboxes
+ * as widget, and therefore has to be applied several times, one per
+ * item selected.
+ */
+ function group_multiple_exposed_input(&$input) {
+ if (!empty($input[$this->options['group_info']['identifier']])) {
+ return array_filter($input[$this->options['group_info']['identifier']]);
+ }
+ return array();
+ }
+
+ /**
+ * Returns TRUE if users can select multiple groups items of a
+ * grouped exposed filter.
+ */
+ function multiple_exposed_input() {
+ return $this->is_a_group() && !empty($this->options['group_info']['multiple']);
+ }
+
+ /**
+ * If set to remember exposed input in the session, store it there.
+ * This function is similar to store_exposed_input but modified to
+ * work properly when the filter is a group.
+ */
+ function store_group_input($input, $status) {
+ if (!$this->is_a_group() || empty($this->options['group_info']['identifier'])) {
+ return TRUE;
+ }
+
+ if (empty($this->options['group_info']['remember'])) {
+ return;
+ }
+
+ // Figure out which display id is responsible for the filters, so we
+ // know where to look for session stored values.
+ $display_id = ($this->view->display_handler->is_defaulted('filters')) ? 'default' : $this->view->current_display;
+
+ // false means that we got a setting that means to recuse ourselves,
+ // so we should erase whatever happened to be there.
+ if ($status === FALSE && isset($_SESSION['views'][$this->view->name][$display_id])) {
+ $session = &$_SESSION['views'][$this->view->name][$display_id];
+
+ if (isset($session[$this->options['group_info']['identifier']])) {
+ unset($session[$this->options['group_info']['identifier']]);
+ }
+ }
+
+ if ($status !== FALSE) {
+ if (!isset($_SESSION['views'][$this->view->name][$display_id])) {
+ $_SESSION['views'][$this->view->name][$display_id] = array();
+ }
+
+ $session = &$_SESSION['views'][$this->view->name][$display_id];
+
+ $session[$this->options['group_info']['identifier']] = $input[$this->options['group_info']['identifier']];
+ }
+ }
+
/**
* Check to see if input from the exposed filters should change
* the behavior of this filter.
@@ -587,6 +1300,14 @@ class views_handler_filter extends views_handler {
return;
}
+ // Check if we store exposed value for current user.
+ global $user;
+ $allowed_rids = empty($this->options['expose']['remember_roles']) ? array() : array_filter($this->options['expose']['remember_roles']);
+ $intersect_rids = array_intersect_key($allowed_rids, $user->roles);
+ if (empty($intersect_rids)) {
+ return;
+ }
+
// Figure out which display id is responsible for the filters, so we
// know where to look for session stored values.
$display_id = ($this->view->display_handler->is_defaulted('filters')) ? 'default' : $this->view->current_display;
@@ -674,6 +1395,15 @@ class views_handler_filter_broken extends views_handler_filter {
function broken() { return TRUE; }
}
+/**
+ * Filter by no empty values, though allow to use "0".
+ * @param $var
+ * @return bool
+ */
+function _views_array_filter_zero($var) {
+ return trim($var) != "";
+}
+
/**
* @}
diff --git a/kolab.org/www/drupal-7.15/sites/all/modules/views/handlers/views_handler_filter_boolean_operator.inc b/kolab.org/www/drupal-7.15/sites/all/modules/views/handlers/views_handler_filter_boolean_operator.inc
index f795b9f..56365e1 100644
--- a/kolab.org/www/drupal-7.15/sites/all/modules/views/handlers/views_handler_filter_boolean_operator.inc
+++ b/kolab.org/www/drupal-7.15/sites/all/modules/views/handlers/views_handler_filter_boolean_operator.inc
@@ -1,4 +1,10 @@
<?php
+
+/**
+ * @file
+ * Definition of views_handler_filter_boolean_operator.
+ */
+
/**
* Simple filter to handle matching of boolean values
*
@@ -123,6 +129,9 @@ class views_handler_filter_boolean_operator extends views_handler_filter {
}
function admin_summary() {
+ if ($this->is_a_group()) {
+ return t('grouped');
+ }
if (!empty($this->options['exposed'])) {
return t('exposed');
}
diff --git a/kolab.org/www/drupal-7.15/sites/all/modules/views/handlers/views_handler_filter_boolean_operator_string.inc b/kolab.org/www/drupal-7.15/sites/all/modules/views/handlers/views_handler_filter_boolean_operator_string.inc
index b27cae4..b49dde9 100644
--- a/kolab.org/www/drupal-7.15/sites/all/modules/views/handlers/views_handler_filter_boolean_operator_string.inc
+++ b/kolab.org/www/drupal-7.15/sites/all/modules/views/handlers/views_handler_filter_boolean_operator_string.inc
@@ -1,4 +1,10 @@
<?php
+
+/**
+ * @file
+ * Definition of views_handler_filter_boolean_operator_string.
+ */
+
/**
* Simple filter to handle matching of boolean values.
*
diff --git a/kolab.org/www/drupal-7.15/sites/all/modules/views/handlers/views_handler_filter_combine.inc b/kolab.org/www/drupal-7.15/sites/all/modules/views/handlers/views_handler_filter_combine.inc
new file mode 100644
index 0000000..c9def53
--- /dev/null
+++ b/kolab.org/www/drupal-7.15/sites/all/modules/views/handlers/views_handler_filter_combine.inc
@@ -0,0 +1,137 @@
+<?php
+
+/**
+ * @file
+ * Definition of views_handler_filter_combine.
+ */
+
+/**
+ * Filter handler which allows to search on multiple fields.
+ *
+ * @ingroup views_field_handlers
+ */
+class views_handler_filter_combine extends views_handler_filter_string {
+ /**
+ * @var views_plugin_query_default
+ */
+ var $query;
+
+ function option_definition() {
+ $options = parent::option_definition();
+ $options['fields'] = array('default' => array());
+
+ return $options;
+ }
+
+ function options_form(&$form, &$form_state) {
+ parent::options_form($form, $form_state);
+ $this->view->init_style();
+
+ // Allow to choose all fields as possible
+ if ($this->view->style_plugin->uses_fields()) {
+ $options = array();
+ foreach ($this->view->display_handler->get_handlers('field') as $name => $field) {
+ $options[$name] = $field->ui_name(TRUE);
+ }
+ if ($options) {
+ $form['fields'] = array(
+ '#type' => 'select',
+ '#title' => t('Choose fields to combine for filtering'),
+ '#description' => t("This filter doesn't work for very special field handlers."),
+ '#multiple' => TRUE,
+ '#options' => $options,
+ '#default_value' => $this->options['fields'],
+ );
+ }
+ else {
+ form_set_error('', t('You have to add some fields to be able to use this filter.'));
+ }
+ }
+ }
+
+ function query() {
+ $this->view->_build('field');
+ $fields = array();
+ // Only add the fields if they have a proper field and table alias.
+ foreach ($this->options['fields'] as $id) {
+ $field = $this->view->field[$id];
+ // Always add the table of the selected fields to be sure a table alias exists.
+ $field->ensure_my_table();
+ if (!empty($field->field_alias) && !empty($field->field_alias)) {
+ $fields[] = "$field->table_alias.$field->real_field";
+ }
+ }
+ if ($fields) {
+ $count = count($fields);
+ $seperated_fields = array();
+ foreach ($fields as $key => $field) {
+ $seperated_fields[] = $field;
+ if ($key < $count-1) {
+ $seperated_fields[] = "' '";
+ }
+ }
+ $expression = implode(', ', $seperated_fields);
+ $expression = "CONCAT_WS(' ', $expression)";
+
+ $info = $this->operators();
+ if (!empty($info[$this->operator]['method'])) {
+ $this->{$info[$this->operator]['method']}($expression);
+ }
+ }
+ }
+
+ // By default things like op_equal uses add_where, that doesn't support
+ // complex expressions, so override all operators.
+
+ function op_equal($field) {
+ $placeholder = $this->placeholder();
+ $operator = $this->operator();
+ $this->query->add_where_expression($this->options['group'], "$field $operator $placeholder", array($placeholder => $this->value));
+ }
+
+ function op_contains($field) {
+ $placeholder = $this->placeholder();
+ $this->query->add_where_expression($this->options['group'], "$field LIKE $placeholder", array($placeholder => '%' . db_like($this->value) . '%'));
+ }
+
+ function op_starts($field) {
+ $placeholder = $this->placeholder();
+ $this->query->add_where_expression($this->options['group'], "$field LIKE $placeholder", array($placeholder => db_like($this->value) . '%'));
+ }
+
+ function op_not_starts($field) {
+ $placeholder = $this->placeholder();
+ $this->query->add_where_expression($this->options['group'], "$field NOT LIKE $placeholder", array($placeholder => db_like($this->value) . '%'));
+ }
+
+ function op_ends($field) {
+ $placeholder = $this->placeholder();
+ $this->query->add_where_expression($this->options['group'], "$field LIKE $placeholder", array($placeholder => '%' . db_like($this->value)));
+ }
+
+ function op_not_ends($field) {
+ $placeholder = $this->placeholder();
+ $this->query->add_where_expression($this->options['group'], "$field NOT LIKE $placeholder", array($placeholder => '%' . db_like($this->value)));
+ }
+
+ function op_not($field) {
+ $placeholder = $this->placeholder();
+ $this->query->add_where_expression($this->options['group'], "$field NOT LIKE $placeholder", array($placeholder => '%' . db_like($this->value) . '%'));
+ }
+
+ function op_regex($field) {
+ $placeholder = $this->placeholder();
+ $this->query->add_where_expression($this->options['group'], "$field RLIKE $placeholder", array($placeholder => $this->value));
+ }
+
+ function op_empty($field) {
+ if ($this->operator == 'empty') {
+ $operator = "IS NULL";
+ }
+ else {
+ $operator = "IS NOT NULL";
+ }
+
+ $this->query->add_where_expression($this->options['group'], "$field $operator");
+ }
+}
diff --git a/kolab.org/www/drupal-7.15/sites/all/modules/views/handlers/views_handler_filter_date.inc b/kolab.org/www/drupal-7.15/sites/all/modules/views/handlers/views_handler_filter_date.inc
index b89d003..4ef61b4 100644
--- a/kolab.org/www/drupal-7.15/sites/all/modules/views/handlers/views_handler_filter_date.inc
+++ b/kolab.org/www/drupal-7.15/sites/all/modules/views/handlers/views_handler_filter_date.inc
@@ -1,6 +1,11 @@
<?php
/**
+ * @file
+ * Definition of views_handler_filter_date.
+ */
+
+/**
* Filter to handle dates stored as a timestamp.
*
* @ingroup views_filter_handlers
@@ -90,6 +95,34 @@ class views_handler_filter_date extends views_handler_filter_numeric {
}
}
+ /**
+ * Validate the build group options form.
+ */
+ function build_group_validate($form, &$form_state) {
+ // Special case to validate grouped date filters, this is because the
+ // $group['value'] array contains the type of filter (date or offset)
+ // and therefore the number of items the comparission has to be done
+ // against 'one' instead of 'zero'.
+ foreach ($form_state['values']['options']['group_info']['group_items'] as $id => $group) {
+ if (empty($group['remove'])) {
+ // Check if the title is defined but value wasn't defined.
+ if (!empty($group['title'])) {
+ if ((!is_array($group['value']) && empty($group['value'])) || (is_array($group['value']) && count(array_filter($group['value'])) == 1)) {
+ form_error($form['group_info']['group_items'][$id]['value'], t('The value is required if title for this item is defined.'));
+ }
+ }
+
+ // Check if the value is defined but title wasn't defined.
+ if ((!is_array($group['value']) && !empty($group['value'])) || (is_array($group['value']) && count(array_filter($group['value'])) > 1)) {
+ if (empty($group['title'])) {
+ form_error($form['group_info']['group_items'][$id]['title'], t('The title is required if value for this item is defined.'));
+ }
+ }
+ }
+ }
+ }
+
+
function accept_exposed_input($input) {
if (empty($this->options['exposed'])) {
return TRUE;
diff --git a/kolab.org/www/drupal-7.15/sites/all/modules/views/handlers/views_handler_filter_entity_bundle.inc b/kolab.org/www/drupal-7.15/sites/all/modules/views/handlers/views_handler_filter_entity_bundle.inc
new file mode 100644
index 0000000..c46cd0b
--- /dev/null
+++ b/kolab.org/www/drupal-7.15/sites/all/modules/views/handlers/views_handler_filter_entity_bundle.inc
@@ -0,0 +1,122 @@
+<?php
+
+/**
+ * @file
+ * Definition of views_handler_filter_entity_bundle
+ */
+
+/**
+ * Filter class which allows to filter by certain bundles of an entity.
+ *
+ * This class provides workarounds for taxonomy and comment.
+ *
+ * @ingroup views_filter_handlers
+ */
+class views_handler_filter_entity_bundle extends views_handler_filter_in_operator {
+ /**
+ * Stores the entity type on which the filter filters.
+ *
+ * @var string
+ */
+ public $entity_type;
+
+ function init(&$view, &$options) {
+ parent::init($view, $options);
+
+ $this->get_entity_type();
+ }
+
+ /**
+ * Set and returns the entity_type.
+ *
+ * @return string
+ * The entity type on the filter.
+ */
+ function get_entity_type() {
+ if (!isset($this->entity_type)) {
+ $data = views_fetch_data($this->table);
+ if (isset($data['table']['entity type'])) {
+ $this->entity_type = $data['table']['entity type'];
+ }
+
+ // If the current filter is under a relationship you can't be sure that the
+ // entity type of the view is the entity type of the current filter
+ // For example a filter from a node author on a node view does have users as entity type.
+ if (!empty($this->options['relationship']) && $this->options['relationship'] != 'none') {
+ $relationships = $this->view->display_handler->get_option('relationships');
+ if (!empty($relationships[$this->options['relationship']])) {
+ $options = $relationships[$this->options['relationship']];
+ $data = views_fetch_data($options['table']);
+ $this->entity_type = $data['table']['entity type'];
+ }
+ }
+ }
+
+ return $this->entity_type;
+ }
+
+
+ function get_value_options() {
+ if (!isset($this->value_options)) {
+ $info = entity_get_info($this->entity_type);
+ $types = $info['bundles'];
+ $this->value_title = t('@entity types', array('@entity' => $info['label']));
+
+ $options = array();
+ foreach ($types as $type => $info) {
+ $options[$type] = t($info['label']);
+ }
+ asort($options);
+ $this->value_options = $options;
+ }
+ }
+
+ /**
+ * All entity types beside comment and taxonomy terms have a proper implement
+ * bundle, though these two need an additional join to node/vocab table
+ * to work as required.
+ */
+ function query() {
+ $this->ensure_my_table();
+
+ // Adjust the join for the comment case.
+ if ($this->entity_type == 'comment') {
+ $join = new views_join();
+ $def = array(
+ 'table' => 'node',
+ 'field' => 'nid',
+ 'left_table' => $this->table_alias,
+ 'left_field' => 'nid',
+ );
+ $join->definition = $def;
+ $join->construct();
+ $join->adjusted = TRUE;
+ $this->table_alias = $this->query->add_table('node', $this->relationship, $join);
+ $this->real_field = 'type';
+
+ // Replace the value to match the node type column.
+ foreach ($this->value as &$value) {
+ $value = str_replace('comment_node_', '', $value);
+ }
+ }
+ elseif ($this->entity_type == 'taxonomy_term') {
+ $join = new views_join();
+ $def = array(
+ 'table' => 'taxonomy_vocabulary',
+ 'field' => 'vid',
+ 'left_table' => $this->table_alias,
+ 'left_field' => 'vid',
+ );
+ $join->definition = $def;
+ $join->construct();
+ $join->adjusted = TRUE;
+ $this->table_alias = $this->query->add_table('taxonomy_vocabulary', $this->relationship, $join);
+ $this->real_field = 'machine_name';
+ }
+ else {
+ $entity_info = entity_get_info($this->entity_type);
+ $this->real_field = $entity_info['bundle keys']['bundle'];
+ }
+ parent::query();
+ }
+}
diff --git a/kolab.org/www/drupal-7.15/sites/all/modules/views/handlers/views_handler_filter_equality.inc b/kolab.org/www/drupal-7.15/sites/all/modules/views/handlers/views_handler_filter_equality.inc
index dfe2445..e045c7e 100644
--- a/kolab.org/www/drupal-7.15/sites/all/modules/views/handlers/views_handler_filter_equality.inc
+++ b/kolab.org/www/drupal-7.15/sites/all/modules/views/handlers/views_handler_filter_equality.inc
@@ -1,4 +1,10 @@
<?php
+
+/**
+ * @file
+ * Definition of views_handler_filter_equality.
+ */
+
/**
* Simple filter to handle equal to / not equal to filters
*
diff --git a/kolab.org/www/drupal-7.15/sites/all/modules/views/handlers/views_handler_filter_group_by_numeric.inc b/kolab.org/www/drupal-7.15/sites/all/modules/views/handlers/views_handler_filter_group_by_numeric.inc
index 2332d39..2b265be 100644
--- a/kolab.org/www/drupal-7.15/sites/all/modules/views/handlers/views_handler_filter_group_by_numeric.inc
+++ b/kolab.org/www/drupal-7.15/sites/all/modules/views/handlers/views_handler_filter_group_by_numeric.inc
@@ -1,6 +1,11 @@
<?php
/**
+ * @file
+ * Definition of views_handler_filter_group_by_numeric.
+ */
+
+/**
* Simple filter to handle greater than/less than filters
*
* @ingroup views_filter_handlers
diff --git a/kolab.org/www/drupal-7.15/sites/all/modules/views/handlers/views_handler_filter_in_operator.inc b/kolab.org/www/drupal-7.15/sites/all/modules/views/handlers/views_handler_filter_in_operator.inc
index 8054542..fc2700b 100644
--- a/kolab.org/www/drupal-7.15/sites/all/modules/views/handlers/views_handler_filter_in_operator.inc
+++ b/kolab.org/www/drupal-7.15/sites/all/modules/views/handlers/views_handler_filter_in_operator.inc
@@ -1,4 +1,10 @@
<?php
+
+/**
+ * @file
+ * Definition of views_handler_filter_in_operator.
+ */
+
/**
* Simple filter to handle matching of multiple options selectable via checkboxes
*
@@ -74,7 +80,7 @@ class views_handler_filter_in_operator extends views_handler_filter {
$options['operator']['default'] = 'in';
$options['value']['default'] = array();
- $options['expose']['contains']['reduce'] = array('default' => FALSE);
+ $options['expose']['contains']['reduce'] = array('default' => FALSE, 'bool' => TRUE);
return $options;
}
@@ -284,6 +290,9 @@ class views_handler_filter_in_operator extends views_handler_filter {
}
function admin_summary() {
+ if ($this->is_a_group()) {
+ return t('grouped');
+ }
if (!empty($this->options['exposed'])) {
return t('exposed');
}
diff --git a/kolab.org/www/drupal-7.15/sites/all/modules/views/handlers/views_handler_filter_many_to_one.inc b/kolab.org/www/drupal-7.15/sites/all/modules/views/handlers/views_handler_filter_many_to_one.inc
index c6d6d20..f384796 100644
--- a/kolab.org/www/drupal-7.15/sites/all/modules/views/handlers/views_handler_filter_many_to_one.inc
+++ b/kolab.org/www/drupal-7.15/sites/all/modules/views/handlers/views_handler_filter_many_to_one.inc
@@ -1,6 +1,11 @@
<?php
/**
+ * @file
+ * Definition of views_handler_filter_many_to_one.
+ */
+
+/**
* Complex filter to handle filtering for many to one relationships,
* such as terms (many terms per node) or roles (many roles per user).
*
diff --git a/kolab.org/www/drupal-7.15/sites/all/modules/views/handlers/views_handler_filter_numeric.inc b/kolab.org/www/drupal-7.15/sites/all/modules/views/handlers/views_handler_filter_numeric.inc
index 71d8b9e..982abd8 100644
--- a/kolab.org/www/drupal-7.15/sites/all/modules/views/handlers/views_handler_filter_numeric.inc
+++ b/kolab.org/www/drupal-7.15/sites/all/modules/views/handlers/views_handler_filter_numeric.inc
@@ -1,6 +1,11 @@
<?php
/**
+ * @file
+ * Definition of views_handler_filter_numeric.
+ */
+
+/**
* Simple filter to handle greater than/less than filters
*
* @ingroup views_filter_handlers
@@ -257,6 +262,9 @@ class views_handler_filter_numeric extends views_handler_filter {
}
function admin_summary() {
+ if ($this->is_a_group()) {
+ return t('grouped');
+ }
if (!empty($this->options['exposed'])) {
return t('exposed');
}
diff --git a/kolab.org/www/drupal-7.15/sites/all/modules/views/handlers/views_handler_filter_string.inc b/kolab.org/www/drupal-7.15/sites/all/modules/views/handlers/views_handler_filter_string.inc
index eec7a07..c50eff4 100644
--- a/kolab.org/www/drupal-7.15/sites/all/modules/views/handlers/views_handler_filter_string.inc
+++ b/kolab.org/www/drupal-7.15/sites/all/modules/views/handlers/views_handler_filter_string.inc
@@ -1,6 +1,11 @@
<?php
/**
+ * @file
+ * Definition of views_handler_filter_string.
+ */
+
+/**
* Basic textfield filter to handle string filtering commands
* including equality, like, not like, etc.
*
@@ -13,7 +18,7 @@ class views_handler_filter_string extends views_handler_filter {
function option_definition() {
$options = parent::option_definition();
- $options['expose']['contains']['required'] = array('default' => FALSE);
+ $options['expose']['contains']['required'] = array('default' => FALSE, 'bool' => TRUE);
return $options;
}
@@ -143,6 +148,9 @@ class views_handler_filter_string extends views_handler_filter {
}
function admin_summary() {
+ if ($this->is_a_group()) {
+ return t('grouped');
+ }
if (!empty($this->options['exposed'])) {
return t('exposed');
}
diff --git a/kolab.org/www/drupal-7.15/sites/all/modules/views/handlers/views_handler_relationship.inc b/kolab.org/www/drupal-7.15/sites/all/modules/views/handlers/views_handler_relationship.inc
index 18f21f8..695082b 100644
--- a/kolab.org/www/drupal-7.15/sites/all/modules/views/handlers/views_handler_relationship.inc
+++ b/kolab.org/www/drupal-7.15/sites/all/modules/views/handlers/views_handler_relationship.inc
@@ -1,11 +1,12 @@
<?php
+
/**
* @file
* Views' relationship handlers.
*/
/**
- * @defgroup views_relationship_handlers Views' relationship handlers
+ * @defgroup views_relationship_handlers Views relationship handlers
* @{
* Handlers to tell Views how to create alternate relationships.
*/
@@ -31,6 +32,8 @@
* - label: The default label to provide for this relationship, which is
* shown in parentheses next to any field/sort/filter/argument that uses
* the relationship.
+ *
+ * @ingroup views_relationship_handlers
*/
class views_handler_relationship extends views_handler {
/**
@@ -72,7 +75,7 @@ class views_handler_relationship extends views_handler {
}
$options['label'] = array('default' => $label, 'translatable' => TRUE);
- $options['required'] = array('default' => FALSE);
+ $options['required'] = array('default' => FALSE, 'bool' => TRUE);
return $options;
}
diff --git a/kolab.org/www/drupal-7.15/sites/all/modules/views/handlers/views_handler_relationship_groupwise_max.inc b/kolab.org/www/drupal-7.15/sites/all/modules/views/handlers/views_handler_relationship_groupwise_max.inc
index b027357..23198c6 100644
--- a/kolab.org/www/drupal-7.15/sites/all/modules/views/handlers/views_handler_relationship_groupwise_max.inc
+++ b/kolab.org/www/drupal-7.15/sites/all/modules/views/handlers/views_handler_relationship_groupwise_max.inc
@@ -1,6 +1,6 @@
<?php
-// $Id$
-/*
+
+/**
* @file
* Relationship for groupwise maximum handler.
*/
@@ -64,7 +64,7 @@ class views_handler_relationship_groupwise_max extends views_handler_relationshi
$options['subquery_sort'] = array('default' => NULL);
// Descending more useful.
$options['subquery_order'] = array('default' => 'DESC');
- $options['subquery_regenerate'] = array('default' => FALSE);
+ $options['subquery_regenerate'] = array('default' => FALSE, 'bool' => TRUE);
$options['subquery_view'] = array('default' => FALSE);
$options['subquery_namespace'] = array('default' => FALSE);
@@ -148,21 +148,6 @@ class views_handler_relationship_groupwise_max extends views_handler_relationshi
}
/**
- * Perform any necessary changes to the form values prior to storage.
- * There is no need for this function to actually store the data.
- *
- * Generate the subquery string when the user submits the options, and store
- * it. This saves the expense of generating it when the view is run.
- */
- function options_submit(&$form, &$form_state) {
- // Get the new user options from the form values.
- $new_options = $form_state['values']['options'];
- $subquery = $this->left_query($new_options);
- // Add the subquery string to the options we're about to store.
- $this->options['subquery_string'] = $subquery;
- }
-
- /**
* Helper function to create a pseudo view.
*
* We use this to obtain our subquery SQL.
@@ -177,6 +162,14 @@ class views_handler_relationship_groupwise_max extends views_handler_relationshi
}
/**
+ * When the form is submitted, take sure to clear the subquery string cache.
+ */
+ function options_form_submit(&$form, &$form_state) {
+ $cid = 'views_relationship_groupwise_max:' . $this->view->name . ':' . $this->view->current_display . ':' . $this->options['id'];
+ cache_clear_all($cid, 'cache_views_data');
+ }
+
+ /**
* Generate a subquery given the user options, as set in the options.
* These are passed in rather than picked up from the object because we
* generate the subquery when the options are saved, rather than when the view
@@ -359,7 +352,15 @@ class views_handler_relationship_groupwise_max extends views_handler_relationshi
}
else {
// Get the stored subquery SQL string.
- $def['left_query'] = $this->options['subquery_string'];
+ $cid = 'views_relationship_groupwise_max:' . $this->view->name . ':' . $this->view->current_display . ':' . $this->options['id'];
+ $cache = cache_get($cid, 'cache_views_data');
+ if (isset($cache->data)) {
+ $def['left_query'] = $cache->data;
+ }
+ else {
+ $def['left_query'] = $this->left_query($this->options);
+ cache_set($cid, $def['left_query'], 'cache_views_data');
+ }
}
if (!empty($def['join_handler']) && class_exists($def['join_handler'])) {
diff --git a/kolab.org/www/drupal-7.15/sites/all/modules/views/handlers/views_handler_sort.inc b/kolab.org/www/drupal-7.15/sites/all/modules/views/handlers/views_handler_sort.inc
index 3587290..99574e4 100644
--- a/kolab.org/www/drupal-7.15/sites/all/modules/views/handlers/views_handler_sort.inc
+++ b/kolab.org/www/drupal-7.15/sites/all/modules/views/handlers/views_handler_sort.inc
@@ -1,12 +1,20 @@
<?php
+
+/**
+ * @file
+ * @todo.
+ */
+
/**
- * @defgroup views_sort_handlers Views' sort handlers
+ * @defgroup views_sort_handlers Views sort handlers
* @{
- * Handlers to tell Views how to sort queries
+ * Handlers to tell Views how to sort queries.
*/
/**
- * Base sort handler that has no options and performs a simple sort
+ * Base sort handler that has no options and performs a simple sort.
+ *
+ * @ingroup views_sort_handlers
*/
class views_handler_sort extends views_handler {
@@ -28,7 +36,7 @@ class views_handler_sort extends views_handler {
$options = parent::option_definition();
$options['order'] = array('default' => 'ASC');
- $options['exposed'] = array('default' => FALSE);
+ $options['exposed'] = array('default' => FALSE, 'bool' => TRUE);
$options['expose'] = array(
'contains' => array(
'label' => array('default' => '', 'translatable' => TRUE),
diff --git a/kolab.org/www/drupal-7.15/sites/all/modules/views/handlers/views_handler_sort_date.inc b/kolab.org/www/drupal-7.15/sites/all/modules/views/handlers/views_handler_sort_date.inc
index 8101482..b37cc41 100644
--- a/kolab.org/www/drupal-7.15/sites/all/modules/views/handlers/views_handler_sort_date.inc
+++ b/kolab.org/www/drupal-7.15/sites/all/modules/views/handlers/views_handler_sort_date.inc
@@ -1,6 +1,11 @@
<?php
/**
+ * @file
+ * Definition of views_handler_sort_date.
+ */
+
+/**
* Basic sort handler for dates.
*
* This handler enables granularity, which is the ability to make dates
diff --git a/kolab.org/www/drupal-7.15/sites/all/modules/views/handlers/views_handler_sort_group_by_numeric.inc b/kolab.org/www/drupal-7.15/sites/all/modules/views/handlers/views_handler_sort_group_by_numeric.inc
index 1d1be41..4a521c1 100644
--- a/kolab.org/www/drupal-7.15/sites/all/modules/views/handlers/views_handler_sort_group_by_numeric.inc
+++ b/kolab.org/www/drupal-7.15/sites/all/modules/views/handlers/views_handler_sort_group_by_numeric.inc
@@ -1,4 +1,10 @@
<?php
+
+/**
+ * @file
+ * Definition of views_handler_sort_group_by_numeric.
+ */
+
/**
* Handler for GROUP BY on simple numeric fields.
*
diff --git a/kolab.org/www/drupal-7.15/sites/all/modules/views/handlers/views_handler_sort_menu_hierarchy.inc b/kolab.org/www/drupal-7.15/sites/all/modules/views/handlers/views_handler_sort_menu_hierarchy.inc
index 294b3c4..dacb1fe 100644
--- a/kolab.org/www/drupal-7.15/sites/all/modules/views/handlers/views_handler_sort_menu_hierarchy.inc
+++ b/kolab.org/www/drupal-7.15/sites/all/modules/views/handlers/views_handler_sort_menu_hierarchy.inc
@@ -1,18 +1,53 @@
<?php
/**
+ * @file
+ * Definition of views_handler_sort_menu_hierarchy.
+ */
+
+/**
* Sort in menu hierarchy order.
*
- * Given a field name of 'p' this produces an ORDER BY on p1, p2, ..., p9.
+ * Given a field name of 'p' this produces an ORDER BY on p1, p2, ..., p9;
+ * and optionally injects multiple joins to {menu_links} to sort by weight
+ * and title as well.
+ *
* This is only really useful for the {menu_links} table.
*
* @ingroup views_sort_handlers
*/
class views_handler_sort_menu_hierarchy extends views_handler_sort {
+ function option_definition() {
+ $options = parent::option_definition();
+ $options['sort_within_level'] = array('default' => FALSE);
+ return $options;
+ }
+
+ function options_form(&$form, &$form_state) {
+ parent::options_form($form, $form_state);
+ $form['sort_within_level'] = array(
+ '#type' => 'checkbox',
+ '#title' => t('Sort within each hierarchy level'),
+ '#description' => t('Enable this to sort the items within each level of the hierarchy by weight and title. Warning: this may produce a slow query.'),
+ '#default_value' => $this->options['sort_within_level'],
+ );
+ }
+
function query() {
$this->ensure_my_table();
$max_depth = isset($this->definition['max depth']) ? $this->definition['max depth'] : MENU_MAX_DEPTH;
for ($i = 1; $i <= $max_depth; ++$i) {
+ if ($this->options['sort_within_level']) {
+ $join = new views_join();
+ $join->construct('menu_links', $this->table_alias, $this->field . $i, 'mlid');
+ $menu_links = $this->query->add_table('menu_links', NULL, $join);
+ $this->query->add_orderby($menu_links, 'weight', $this->options['order']);
+ $this->query->add_orderby($menu_links, 'link_title', $this->options['order']);
+ }
+
+ // We need this even when also sorting by weight and title, to make sure
+ // that children of two parents with the same weight and title are
+ // correctly separated.
$this->query->add_orderby($this->table_alias, $this->field . $i, $this->options['order']);
}
}
diff --git a/kolab.org/www/drupal-7.15/sites/all/modules/views/handlers/views_handler_sort_random.inc b/kolab.org/www/drupal-7.15/sites/all/modules/views/handlers/views_handler_sort_random.inc
index 75f3153..eaaaf79 100644
--- a/kolab.org/www/drupal-7.15/sites/all/modules/views/handlers/views_handler_sort_random.inc
+++ b/kolab.org/www/drupal-7.15/sites/all/modules/views/handlers/views_handler_sort_random.inc
@@ -1,6 +1,11 @@
<?php
/**
+ * @file
+ * Definition of views_handler_sort_random.
+ */
+
+/**
* Handle a random sort.
*
* @ingroup views_sort_handlers