Commit 73f6988e authored by damiankloip's avatar damiankloip Committed by tim.plunkett

Issue #1808670 by dawehner, damiankloip: Added Provide a way for area handlers...

Issue #1808670 by dawehner, damiankloip: Added Provide a way for area handlers to be available by area type.
parent 7f528634
......@@ -61,6 +61,11 @@ protected function viewsData() {
unset($data['views_test_data']['age']['filter']);
unset($data['views_test_data']['job']['sort']);
$data['views_test_data']['created']['area']['id'] = 'text';
$data['views_test_data']['age']['area']['id'] = 'text';
$data['views_test_data']['age']['area']['sub_type'] = 'header';
$data['views_test_data']['job']['area']['id'] = 'text';
$data['views_test_data']['job']['area']['sub_type'] = array('header', 'footer');
return $data;
}
......@@ -99,6 +104,17 @@ public function testViewsFetchFields() {
),
'area' => array(
'created',
'job',
'age'
),
'header' => array(
'created',
'job',
'age'
),
'footer' => array(
'created',
'job',
),
);
......@@ -110,6 +126,16 @@ public function testViewsFetchFields() {
});
$this->assertEqual($expected_keys, array_keys($fields), format_string('Handlers of type @handler_type are listed as expected.', array('@handler_type' => $handler_type)));
}
// Check for subtype filtering, so header and footer.
foreach (array('header', 'footer') as $sub_type) {
$fields = views_fetch_fields('views_test_data', 'area', FALSE, $sub_type);
$expected_keys = array_walk($expected[$sub_type], function(&$item) {
$item = "views_test_data.$item";
});
$this->assertEqual($expected_keys, array_keys($fields), format_string('Sub_type @sub_type is filtered as expected.', array('@sub_type' => $sub_type)));
}
}
}
......@@ -70,6 +70,7 @@ function views_views_data() {
'help' => t('Override the default view title for this view. This is useful to display an alternative title when a view is empty.'),
'area' => array(
'id' => 'title',
'sub_type' => 'empty',
),
);
......
......@@ -1549,7 +1549,7 @@ function views_ui_add_item_form($form, &$form_state) {
// Figure out all the base tables allowed based upon what the relationships provide.
$base_tables = $view->getBaseTables();
$options = views_fetch_fields(array_keys($base_tables), $type, $display->useGroupBy());
$options = views_fetch_fields(array_keys($base_tables), $type, $display->useGroupBy(), $form_state['type']);
if (!empty($options)) {
$form['options']['controls'] = array(
......@@ -2558,11 +2558,14 @@ function _views_sort_types($a, $b) {
* The handler type, for example field or filter.
* @param bool $grouping
* Should the result grouping by its 'group' label.
* @param string $sub_type
* An optional sub type. E.g. Allows making an area plugin available for
* header only, instead of header, footer, and empty regions.
*
* @return array
* A keyed array of in the form of 'base_table' => 'Description'.
*/
function views_fetch_fields($base, $type, $grouping = FALSE) {
function views_fetch_fields($base, $type, $grouping = FALSE, $sub_type = NULL) {
static $fields = array();
if (empty($fields)) {
$data = views_fetch_data();
......@@ -2597,6 +2600,9 @@ function views_fetch_fields($base, $type, $grouping = FALSE) {
if ($grouping && !empty($info[$key]['no group by'])) {
continue;
}
if ($sub_type && isset($info[$key]['sub_type']) && (!in_array($sub_type, (array) $info[$key]['sub_type']))) {
continue;
}
if (!empty($info[$key]['skip base'])) {
foreach ((array) $info[$key]['skip base'] as $base_name) {
$skip_bases[$field][$key][$base_name] = TRUE;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment