summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJon Peck2013-01-29 20:10:43 (GMT)
committer Jon Peck2013-01-29 20:10:43 (GMT)
commit1688521cc1644c6bbc0eff19ba3031e1b3dbee20 (patch)
tree2019758c94b80779f00617ab48bec324a5067f54
parent649c1ebab23f951ff129590cded20ef037cccc0e (diff)
Don't duplicate values; don't render empty fields like media, text, caption; coding cleanup.
-rw-r--r--plugins/date_sources/date_field.inc25
-rw-r--r--views_timelinejs_plugin_style_timelinejs.inc28
2 files changed, 32 insertions, 21 deletions
diff --git a/plugins/date_sources/date_field.inc b/plugins/date_sources/date_field.inc
index f23073c..5697fd1 100644
--- a/plugins/date_sources/date_field.inc
+++ b/plugins/date_sources/date_field.inc
@@ -27,26 +27,33 @@ function views_timelinejs_date_source_date_field_conversion($date, $output_forma
$timezone = date_get_timezone($tz_handling);
$db_timezone = date_get_timezone_db($tz_handling);
switch ($output_format) {
- case 'iso8601':
+ case 'iso8601':{
$ret['value'] = views_timelinejs_convert_to_iso($date['value'], $input_format, $timezone, $db_timezone);
if (isset($date['value2'])) {
$ret['value2'] = views_timelinejs_convert_to_iso($date['value2'], $input_format, $timezone, $db_timezone);
}
- return $ret;
-
- case 'gregorian':
+ break;
+ }
+ case 'gregorian':{
$ret['value'] = views_timelinejs_convert_to_gregorian($date['value'], $input_format, $timezone, $db_timezone);
if (isset($date['value2'])) {
$ret['value2'] = views_timelinejs_convert_to_gregorian($date['value2'], $input_format, $timezone, $db_timezone);
}
- return $ret;
-
- case 'timestamp':
+ break;
+ }
+ case 'timestamp':{
$ret['value'] = views_timelinejs_convert_to_timestamp($date['value'], $input_format, $timezone, $db_timezone);
if (isset($date['value2'])) {
$ret['value2'] = views_timelinejs_convert_to_timestamp($date['value2'], $input_format, $timezone, $db_timezone);
}
- return $ret;
-
+ break;
+ }
}
+
+ // If times are the same, don't duplicate.
+ if (isset($ret['value2']) && $ret['value'] == $ret['value2']) {
+ unset($ret['value2']);
+ }
+
+ return $ret;
}
diff --git a/views_timelinejs_plugin_style_timelinejs.inc b/views_timelinejs_plugin_style_timelinejs.inc
index 869becc..43f8bbd 100644
--- a/views_timelinejs_plugin_style_timelinejs.inc
+++ b/views_timelinejs_plugin_style_timelinejs.inc
@@ -291,16 +291,16 @@ class views_timelinejs_plugin_style_timelinejs extends views_plugin_style {
// Body - plain text input, optionally append "read more" entity link.
if ($target_field == 'text') {
$v_text = strip_tags($view->style_plugin->rendered_fields[$count][$this->options['timeline_fields'][$source_field]]);
-
- $rows[$count][$target_field] = $v_text;
-
- if (isset($this->options['timeline_config']['link_text_enabled']) && $this->options['timeline_config']['link_text_enabled'] && isset($row->uri['path'])) {
- $rows[$count][$target_field] .= theme('views_timelinejs_link_to_entity',
- array(
- 'uri' => $row->uri['path'],
- 'link_text' => check_plain($link_text),
- )
- );
+ if ($v_text) {
+ $rows[$count][$target_field] = $v_text;
+ if (isset($this->options['timeline_config']['link_text_enabled']) && $this->options['timeline_config']['link_text_enabled'] && isset($row->uri['path'])) {
+ $rows[$count][$target_field] .= theme('views_timelinejs_link_to_entity',
+ array(
+ 'uri' => $row->uri['path'],
+ 'link_text' => check_plain($link_text),
+ )
+ );
+ }
}
}
@@ -368,7 +368,9 @@ class views_timelinejs_plugin_style_timelinejs extends views_plugin_style {
$media['formatted'] = call_user_func($conversion_callback, $value, array('field' => $tmp));
}
- $rows[$count]['asset'][$target_field] = check_plain($media['formatted']);
+ if ($media['formatted']) {
+ $rows[$count]['asset'][$target_field] = check_plain($media['formatted']);
+ }
}
// Media Caption, Media Credit - both plain text.
@@ -381,7 +383,9 @@ class views_timelinejs_plugin_style_timelinejs extends views_plugin_style {
if (!is_string($v_text)) {
$v_text = $v_text['value'];
}
- $rows[$count]['asset'][$target_field] = check_plain($v_text);
+ if ($v_text) {
+ $rows[$count]['asset'][$target_field] = check_plain($v_text);
+ }
}
}
}