[svn:p5ee] r8082 - p5ee/trunk/App-Widget/lib/App

[email protected]
Newsgroups perl.cvs.p5ee
Message-ID <[email protected]>
Author: spadkins
Date: Fri Nov 17 20:29:43 2006
New Revision: 8082

Modified:
   p5ee/trunk/App-Widget/lib/App/Widget.pm

Log:
format() handles undef values better

Modified: p5ee/trunk/App-Widget/lib/App/Widget.pm
==============================================================================
--- p5ee/trunk/App-Widget/lib/App/Widget.pm	(original)
+++ p5ee/trunk/App-Widget/lib/App/Widget.pm	Fri Nov 17 20:29:43 2006
@@ -520,28 +520,33 @@
 
     my $formatted_value = $value;
 
-    if ($format_options->{scale_factor}) {
-        $formatted_value *= $format_options->{scale_factor};
+    if (! defined $formatted_value) {
+        $formatted_value = " ";
     }
-    if ($format_options->{format}) {
-        $formatted_value = sprintf($format_options->{format}, $formatted_value);
-    }
-    elsif ($format_options->{date_format}) {
-        if (defined $format_options->{date_suffix}) {
-            $formatted_value .= $format_options->{date_suffix};
+    else {
+        if ($format_options->{scale_factor}) {
+            $formatted_value *= $format_options->{scale_factor};
+        }
+        if ($format_options->{format}) {
+            $formatted_value = sprintf($format_options->{format}, $formatted_value);
+        }
+        elsif ($format_options->{date_format}) {
+            if (defined $format_options->{date_suffix}) {
+                $formatted_value .= $format_options->{date_suffix};
+            }
+            $formatted_value = time2str($format_options->{date_format}, str2time($formatted_value));
+        }
+        elsif ($format_options->{labels}) {
+            $formatted_value = $format_options->{labels}{$value};
+            $formatted_value = $value if (!defined $formatted_value);
+        }
+        elsif ($format_options->{domain}) {
+            my $context = App->context();
+            my $value_domain = $context->value_domain($format_options->{domain});
+            my $labels = $value_domain->labels();
+            $formatted_value = $labels->{$value};
+            $formatted_value = $value if (!defined $formatted_value);
         }
-        $formatted_value = time2str($format_options->{date_format}, str2time($formatted_value));
-    }
-    elsif ($format_options->{labels}) {
-        $formatted_value = $format_options->{labels}{$value};
-        $formatted_value = $value if (!defined $formatted_value);
-    }
-    elsif ($format_options->{domain}) {
-        my $context = App->context();
-        my $value_domain = $context->value_domain($format_options->{domain});
-        my $labels = $value_domain->labels();
-        $formatted_value = $labels->{$value};
-        $formatted_value = $value if (!defined $formatted_value);
     }
 
     &App::sub_exit($formatted_value) if ($App::trace);
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.