[svn:p5ee] r9385 - p5ee/trunk/App-Repository/lib/App/ValueDomain

[email protected]
Newsgroups perl.cvs.p5ee
Message-ID <[email protected]>
Author: spadkins
Date: Mon Apr  9 11:30:34 2007
New Revision: 9385

Modified:
   p5ee/trunk/App-Repository/lib/App/ValueDomain/RepositoryTableColumns.pm

Log:
now can get value_domains from column lists based on params

Modified: p5ee/trunk/App-Repository/lib/App/ValueDomain/RepositoryTableColumns.pm
==============================================================================
--- p5ee/trunk/App-Repository/lib/App/ValueDomain/RepositoryTableColumns.pm	(original)
+++ p5ee/trunk/App-Repository/lib/App/ValueDomain/RepositoryTableColumns.pm	Mon Apr  9 11:30:34 2007
@@ -87,7 +87,33 @@
     elsif ($self->{sort}) {
         @$values = sort { $labels->{$a} cmp $labels->{$b} } @$values;
     }
-    if (defined $self->{is_key}) {
+    if (defined $self->{params}) {
+        my $params = $self->{params};
+        my @params = (keys %$params);
+        my ($param, $paramvalue, $ok, $column_def);
+        my @values = ();
+        foreach my $col (@$values) {
+            $ok = 1;
+            foreach $param (@params) {
+                $column_def = $column_defs->{$col};
+                if (!$params->{$param}) {
+                    if ($column_def->{$param}) {
+                        $ok = 0;
+                        last;
+                    }
+                }
+                else {
+                    if (!$column_def->{$param} || $column_def->{$param} ne $params->{$param}) {
+                        $ok = 0;
+                        last;
+                    }
+                }
+            }
+            push(@values, $col) if ($ok);
+        }
+        $values = \@values;
+    }
+    elsif (defined $self->{is_key}) {
         my $is_key = $self->{is_key};
         my @values = ();
         foreach my $col (@$values) {
@@ -97,23 +123,23 @@
             }
         }
         $values = \@values;
-        if ($self->{extra_values}) {
-            my $key;
-            my @each = @$values;
-            my $extra_values = $self->{extra_values};
-            my $extra_labels = $self->{extra_labels} || {};
-
-            for (my $i = $#$extra_values; $i >= 0; $i--) {
-                if ($extra_values->[$i] eq "EACH") {
-                    $key = join(",", @each) || -99999;
-                    unshift(@$values, $key);
-                    $labels->{$key} = $extra_labels->{EACH};
-                }
-                else {
-                    $key = $extra_values->[$i];
-                    unshift(@$values, $key);
-                    $labels->{$key} = $extra_labels->{$key};
-                }
+    }
+    if ($self->{extra_values}) {
+        my $key;
+        my @each = @$values;
+        my $extra_values = $self->{extra_values};
+        my $extra_labels = $self->{extra_labels} || {};
+
+        for (my $i = $#$extra_values; $i >= 0; $i--) {
+            if ($extra_values->[$i] eq "EACH") {
+                $key = join(",", @each) || -99999;
+                unshift(@$values, $key);
+                $labels->{$key} = $extra_labels->{EACH};
+            }
+            else {
+                $key = $extra_values->[$i];
+                unshift(@$values, $key);
+                $labels->{$key} = $extra_labels->{$key};
             }
         }
     }
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.