Issue #2002880 by jeroen12345, toddtomlinson: Rename Views method is_value_empty() to isValueEmpty().

8.0.x
Alex Pott 2013-06-05 07:45:09 +01:00
parent 176968cb82
commit 3888a2be9d
3 changed files with 15 additions and 15 deletions

View File

@ -1158,7 +1158,7 @@ If you would like to have the characters \'[\' and \']\' use the html entity cod
} }
if (empty($this->last_render)) { if (empty($this->last_render)) {
if ($this->is_value_empty($this->last_render, $this->options['empty_zero'], FALSE)) { if ($this->isValueEmpty($this->last_render, $this->options['empty_zero'], FALSE)) {
$alter = $this->options['alter']; $alter = $this->options['alter'];
$alter['alter_text'] = 1; $alter['alter_text'] = 1;
$alter['text'] = $this->options['empty']; $alter['text'] = $this->options['empty'];
@ -1183,7 +1183,7 @@ If you would like to have the characters \'[\' and \']\' use the html entity cod
* @return bool * @return bool
* TRUE if the value is considered empty, FALSE otherwise. * TRUE if the value is considered empty, FALSE otherwise.
*/ */
function is_value_empty($value, $empty_zero, $no_skip_empty = TRUE) { public function isValueEmpty($value, $empty_zero, $no_skip_empty = TRUE) {
if (!isset($value)) { if (!isset($value)) {
$empty = TRUE; $empty = TRUE;
} }
@ -1216,14 +1216,14 @@ If you would like to have the characters \'[\' and \']\' use the html entity cod
} }
// Check if there should be no further rewrite for empty values. // Check if there should be no further rewrite for empty values.
$no_rewrite_for_empty = $this->options['hide_alter_empty'] && $this->is_value_empty($this->original_value, $this->options['empty_zero']); $no_rewrite_for_empty = $this->options['hide_alter_empty'] && $this->isValueEmpty($this->original_value, $this->options['empty_zero']);
// Check whether the value is empty and return nothing, so the field isn't rendered. // 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). // 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. // For numeric values you can specify whether "0"/0 should be empty.
if ((($this->options['hide_empty'] && empty($value)) if ((($this->options['hide_empty'] && empty($value))
|| ($alter['phase'] != VIEWS_HANDLER_RENDER_TEXT_PHASE_EMPTY && $no_rewrite_for_empty)) || ($alter['phase'] != VIEWS_HANDLER_RENDER_TEXT_PHASE_EMPTY && $no_rewrite_for_empty))
&& $this->is_value_empty($value, $this->options['empty_zero'], FALSE)) { && $this->isValueEmpty($value, $this->options['empty_zero'], FALSE)) {
return ''; return '';
} }
// Only in empty phase. // Only in empty phase.

View File

@ -499,25 +499,25 @@ class FieldUnitTest extends ViewUnitTestBase {
} }
/** /**
* Tests views_handler_field::is_value_empty(). * Tests views_handler_field::isValueEmpty().
*/ */
function testIsValueEmpty() { function testIsValueEmpty() {
$view = views_get_view('test_view'); $view = views_get_view('test_view');
$view->initHandlers(); $view->initHandlers();
$field = $view->field['name']; $field = $view->field['name'];
$this->assertFalse($field->is_value_empty("not empty", TRUE), 'A normal string is not empty.'); $this->assertFalse($field->isValueEmpty("not empty", TRUE), 'A normal string is not empty.');
$this->assertTrue($field->is_value_empty("not empty", TRUE, FALSE), 'A normal string which skips empty() can be seen as empty.'); $this->assertTrue($field->isValueEmpty("not empty", TRUE, FALSE), 'A normal string which skips empty() can be seen as empty.');
$this->assertTrue($field->is_value_empty("", TRUE), '"" is considered as empty.'); $this->assertTrue($field->isValueEmpty("", TRUE), '"" is considered as empty.');
$this->assertTrue($field->is_value_empty('0', TRUE), '"0" is considered as empty if empty_zero is TRUE.'); $this->assertTrue($field->isValueEmpty('0', TRUE), '"0" is considered as empty if empty_zero is TRUE.');
$this->assertTrue($field->is_value_empty(0, TRUE), '0 is considered as empty if empty_zero is TRUE.'); $this->assertTrue($field->isValueEmpty(0, TRUE), '0 is considered as empty if empty_zero is TRUE.');
$this->assertFalse($field->is_value_empty('0', FALSE), '"0" is considered not as empty if empty_zero is FALSE.'); $this->assertFalse($field->isValueEmpty('0', FALSE), '"0" is considered not as empty if empty_zero is FALSE.');
$this->assertFalse($field->is_value_empty(0, FALSE), '0 is considered not as empty if empty_zero is FALSE.'); $this->assertFalse($field->isValueEmpty(0, FALSE), '0 is considered not as empty if empty_zero is FALSE.');
$this->assertTrue($field->is_value_empty(NULL, TRUE, TRUE), 'Null should be always seen as empty, regardless of no_skip_empty.'); $this->assertTrue($field->isValueEmpty(NULL, TRUE, TRUE), 'Null should be always seen as empty, regardless of no_skip_empty.');
$this->assertTrue($field->is_value_empty(NULL, TRUE, FALSE), 'Null should be always seen as empty, regardless of no_skip_empty.'); $this->assertTrue($field->isValueEmpty(NULL, TRUE, FALSE), 'Null should be always seen as empty, regardless of no_skip_empty.');
} }
/** /**

View File

@ -209,7 +209,7 @@ function template_preprocess_views_view_fields(&$vars) {
foreach ($view->field as $id => $field) { foreach ($view->field as $id => $field) {
// render this even if set to exclude so it can be used elsewhere. // render this even if set to exclude so it can be used elsewhere.
$field_output = $view->style_plugin->get_field($view->row_index, $id); $field_output = $view->style_plugin->get_field($view->row_index, $id);
$empty = $field->is_value_empty($field_output, $field->options['empty_zero']); $empty = $field->isValueEmpty($field_output, $field->options['empty_zero']);
if (empty($field->options['exclude']) && (!$empty || (empty($field->options['hide_empty']) && empty($vars['options']['hide_empty'])))) { if (empty($field->options['exclude']) && (!$empty || (empty($field->options['hide_empty']) && empty($vars['options']['hide_empty'])))) {
$object = new stdClass(); $object = new stdClass();
$object->handler = &$view->field[$id]; $object->handler = &$view->field[$id];