[MKDoc-commit] [1.6] added methods for automagic categorisation of document audience

bruno at mkdoc.demon.co.uk bruno at mkdoc.demon.co.uk
Wed Feb 2 16:49:46 GMT 2005


Log Message:
-----------
[1.6] added methods for automagic categorisation of document audience properties.

Tags:
----
mkdoc-1-6

Modified Files:
--------------
    mkd/flo/plugin/Admin:
        Properties.pm

-------------- next part --------------
Index: Properties.pm
===================================================================
RCS file: /var/spool/cvs/mkd/flo/plugin/Admin/Properties.pm,v
retrieving revision 1.1.2.7
retrieving revision 1.1.2.8
diff -Lflo/plugin/Admin/Properties.pm -Lflo/plugin/Admin/Properties.pm -u -r1.1.2.7 -r1.1.2.8
--- flo/plugin/Admin/Properties.pm
+++ flo/plugin/Admin/Properties.pm
@@ -252,6 +252,57 @@
 
 
 ##
+# $self->audience_categories();
+# ------------------------------------
+#   Returns a sorted list of all audience categories.
+#   Categories are implicit when a 'label' has ':' in it.
+#   Otherwise items will be in category ''.
+##
+sub audience_categories
+{
+    my $self = shift;
+
+    my $categories;
+    for my $audience (@{$self->audiences})
+    {
+        $categories->{$audience->category} = undef;
+    }
+
+    my @audience_categories;
+    for (keys %{$categories}) { push @audience_categories, $_ };
+
+    @audience_categories = sort { $a cmp $b } @audience_categories;
+
+    return wantarray ? @audience_categories : [@audience_categories];
+}
+
+
+##
+# $self->audiences_by_category ('Fruit');
+# ------------------------
+#   Returns a list of all flo::Record::Audience objects available
+#   to be set that match the specified category, ordered by label, or undef on error.
+##
+sub audiences_by_category
+{
+    my $self = shift;
+    my $category = shift;
+
+    my @AUDIENCES;
+    my @AUDIENCE_BY_CATEGORY;
+
+    my @auds   = $self->audiences;
+    @AUDIENCES = sort { $a->label cmp $b->label } @auds;
+    for (@AUDIENCES)
+    {
+        push @AUDIENCE_BY_CATEGORY, $_ if $_->category eq $category;
+    }
+
+    return wantarray ? @AUDIENCE_BY_CATEGORY : [@AUDIENCE_BY_CATEGORY];
+}
+
+
+##
 # $self->activate;
 # ----------------
 #   Returns TRUE if this plugin can be activated, FALSE


More information about the MKDoc-commit mailing list