[prev in list] [next in list] [prev in thread] [next in thread] 

List:       bricolage-commits
Subject:    [Bricolage-Commits] Fixes for get_data() and get_container() in Container.pm.
From:       David Wheeler <wheeler () users ! sourceforge ! net>
Date:       2002-08-30 18:06:57
[Download RAW message or body]

Log Message:
-----------
Fixes for get_data() and get_container() in Container.pm. You can now pass a
date format string argument to the get_data() method and, if the data is of
the "date" type, it will be returned in that format. Also, get_data() will
ignore container elements when looking for datat elements to return, and
get_conainer() will ignore data elements when looking for container elements
to return.

Modified Files:
--------------
    /cvsroot/bricolage/bricolage/lib/Bric:
        Changes.pod
    /cvsroot/bricolage/bricolage/lib/Bric/Biz/Asset/Business/Parts/Tile:
        Container.pm
["wheeler-200283018657-diff.txt" (wheeler-200283018657-diff.txt)]

Index: Changes.pod
===================================================================
RCS file: /cvsroot/bricolage/bricolage/lib/Bric/Changes.pod,v
retrieving revision 1.153
retrieving revision 1.154
diff -u -w -d -r1.153 -r1.154
--- Changes.pod	30 Aug 2002 01:28:05 -0000	1.153
+++ Changes.pod	30 Aug 2002 18:06:55 -0000	1.154
@@ -33,6 +33,14 @@
 
 Added README.MacOSX. [David]
 
+=item *
+
+You can now pass a date format string argument to the C<get_data()> method of
+container elements in templates (and elsewhere, for that matter). This is
+useful if the data you're retrieving is of the "date" type, and you don't want
+the date to be formatted in the format specified in the "Date Format"
+preference. [David]
+
 =back
 
 =head2 Bug Fixes
@@ -95,6 +103,12 @@
 =item *
 
 Corrected a bunch of spelling errors in this file. [David]
+
+=item *
+
+Calling C<get_data()> on a container element in templates (or elsewhere, for
+that matter) now properly ignores container subelements. Likewise for
+C<get_container()>, whicn how properly ignores data subelements. [David]
 
 =back
 
Index: Container.pm
===================================================================
RCS file: /cvsroot/bricolage/bricolage/lib/Bric/Biz/Asset/Business/Parts/Tile/Container.pm,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -w -d -r1.15 -r1.16
--- Container.pm	17 Jun 2002 17:26:17 -0000	1.15
+++ Container.pm	30 Aug 2002 18:06:55 -0000	1.16
@@ -869,8 +869,13 @@
 
 =item $string = $tile->get_data( $name, $obj_order)
 
-this will search the contained tiles for one with the coresponding name ane
-object order field.   It will then return the string that coresponds
+=item $string = $tile->get_data($name, $obj_order, $date_format)
+
+This method will search the contained tiles for one with the coresponding name
+ane object order field. It will then return the data from that data tile. Pass
+in the optional C<$date_format> argument if you expect the data returned from
+C<$name> to be of the date type, and you'd like a format other than that set
+in the "Date Format" preference.
 
 B<Throws:>
 
@@ -887,16 +892,14 @@
 =cut
 
 sub get_data {
-    my ($self, $name, $obj_order) = @_;
-    my $tiles  = $self->_get_tiles();
+    my ($self, $name, $obj_order, $dt_fmt) = @_;
     $obj_order = 1 unless defined $obj_order;
 
-    foreach (@$tiles) {
-	if ($_->has_name($name) && ($_->get_object_order == $obj_order)) {
-	    return $_->get_data()
-	}
+    foreach my $t ($self->_get_tiles) {
+        return $t->get_data($dt_fmt) if not $t->is_container
+          and $t->has_name($name) and $t->get_object_order == $obj_order;
     }
-    # well I suppose that there were no matches
+    # Well, I suppose that there were no matches.
     return;
 }
 
@@ -904,8 +907,8 @@
 
 =item $contained = $container->get_container($name, $obj_order)
 
-Similar to get data this will return a container object that matches the 
-given name field and onbject order description.
+Similar to get data this will return a container object that matches the given
+name field and object order description.
 
 B<Throws:>
 
@@ -923,15 +926,13 @@
 
 sub get_container {
     my ($self, $name, $obj_order) = @_;
-    my $tiles  = $self->_get_tiles();
     $obj_order = 1 unless defined $obj_order;
 
-    foreach (@$tiles) {
-	if ($_->has_name($name) && ($_->get_object_order == $obj_order)) {
-	    return $_;
-	}
+    foreach my $t ($self->_get_tiles) {
+        return $t if $t->is_container and $t->has_name($name)
+          and $t->get_object_order == $obj_order;
     }
-    # well I suppose that there were no matches
+    # Well, I suppose that there were no matches.
     return;
 }
 
-------------------------------------------------------
This sf.net email is sponsored by: OSDN - Tired of that same old
cell phone?  Get a new here for FREE!
https://www.inphonic.com/r.asp?r=sourceforge1&refcode1=vs3390
_______________________________________________
Bricolage-Commits mailing list
Bricolage-Commits@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bricolage-commits

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic