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

[email protected]
Newsgroups perl.cvs.p5ee
Message-ID <[email protected]>
Author: spadkins
Date: Mon Oct 16 11:31:03 2006
New Revision: 7951

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

Log:
enhance to allow Label to display a decoded form of a value or list of values

Modified: p5ee/trunk/App-Widget/lib/App/Widget/Label.pm
==============================================================================
--- p5ee/trunk/App-Widget/lib/App/Widget/Label.pm	(original)
+++ p5ee/trunk/App-Widget/lib/App/Widget/Label.pm	Mon Oct 16 11:31:03 2006
@@ -65,8 +65,36 @@
 
 sub html {
     my $self = shift;
-    my $html = $self->label();
-    $html;
+    my ($html);
+    if ($self->{values} || $self->{domain}) {
+        my ($values, $labels) = $self->values_labels();
+        my $value = $self->get_value();
+
+        if ($value =~ /,/) {
+            $html = "";
+            foreach my $val (split(/,/,$value)) {
+                $html .= ", " if ($html);
+                if (exists $labels->{$val}) {
+                    $html .= $labels->{$val};
+                }
+                else {
+                    $html .= "";
+                }
+            }
+        }
+        else {
+            if (exists $labels->{$value}) {
+                $html = $labels->{$value};
+            }
+            else {
+                $html = "";
+            }
+        }
+    }
+    else {
+        $html = $self->label();
+    }
+    return($html);
 }
 
 1;
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.