Commit 3888a2be authored by alexpott's avatar alexpott

Issue #2002880 by jeroen12345, toddtomlinson: Rename Views method...

Issue #2002880 by jeroen12345, toddtomlinson: Rename Views method is_value_empty() to isValueEmpty().
parent 176968cb
......@@ -1158,7 +1158,7 @@ public function advancedRender($values) {
}
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['alter_text'] = 1;
$alter['text'] = $this->options['empty'];
......@@ -1183,7 +1183,7 @@ public function advancedRender($values) {
* @return bool
* 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)) {
$empty = TRUE;
}
......@@ -1216,14 +1216,14 @@ public function renderText($alter) {
}
// 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.
// 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))
&& $this->is_value_empty($value, $this->options['empty_zero'], FALSE)) {
&& $this->isValueEmpty($value, $this->options['empty_zero'], FALSE)) {
return '';
}
// Only in empty phase.
......
......@@ -499,25 +499,25 @@ function _testEmptyText() {
}
/**
* Tests views_handler_field::is_value_empty().
* Tests views_handler_field::isValueEmpty().
*/
function testIsValueEmpty() {
$view = views_get_view('test_view');
$view->initHandlers();
$field = $view->field['name'];
$this->assertFalse($field->is_value_empty("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->assertFalse($field->isValueEmpty("not empty", TRUE), 'A normal string is not 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->is_value_empty(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->is_value_empty(0, FALSE), '0 is considered not as empty if empty_zero is FALSE.');
$this->assertTrue($field->isValueEmpty('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->isValueEmpty('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->is_value_empty(NULL, TRUE, FALSE), '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->isValueEmpty(NULL, TRUE, FALSE), 'Null should be always seen as empty, regardless of no_skip_empty.');
}
/**
......
......@@ -209,7 +209,7 @@ function template_preprocess_views_view_fields(&$vars) {
foreach ($view->field as $id => $field) {
// render this even if set to exclude so it can be used elsewhere.
$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'])))) {
$object = new stdClass();
$object->handler = &$view->field[$id];
......
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