[wellwell-devel] [SCM] Interchange wellwell catalog branch, master, updated. 88021014d605e1683fee1f03466c7e05813fe287
Stefan Hornburg
racke at rt.icdevgroup.org
Mon Oct 19 17:06:04 UTC 2009
via 88021014d605e1683fee1f03466c7e05813fe287 (commit)
from 5e30020708a5775c5cff854271d4be6c61f798b0 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit 88021014d605e1683fee1f03466c7e05813fe287
Author: Stefan Hornburg (Racke) <racke at linuxia.de>
Date: Mon Oct 19 19:05:40 2009 +0200
move [menu-display] into a Perl module
-----------------------------------------------------------------------
Summary of changes and diff:
code/menu_display.tag | 57 -------------------------------
global/wellwell.cfg | 2 +
lib/WellWell/Menu.pm | 88 +++++++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 90 insertions(+), 57 deletions(-)
delete mode 100644 code/menu_display.tag
create mode 100644 global/wellwell.cfg
create mode 100644 lib/WellWell/Menu.pm
diff --git a/code/menu_display.tag b/code/menu_display.tag
deleted file mode 100644
index 827ee13..0000000
--- a/code/menu_display.tag
+++ /dev/null
@@ -1,57 +0,0 @@
-UserTag menu_display Order name
-UserTag menu_display AddAttr
-UserTag menu_display Routine <<EOR
-sub {
- my ($name, $opt) = @_;
- my ($set, $uri, @entries, $name_qtd, @fields, $fstr, $base_url, $selected);
-
- $Tag->perl({tables => 'menus'});
-
- $name_qtd = $Db{menus}->quote($name);
-
- @fields = qw/code name url parent permission/;
-
- $fstr = join(',', @fields);
-
- $set = $Db{menus}->query({sql => qq{select $fstr from menus where menu_name = $name_qtd order by parent asc, weight desc, code}, hashref => 1});
-
- if ($opt->{selected}) {
- $base_url = $Session->{last_url};
- $base_url =~ s%^/%%;
- }
-
- for (@$set) {
- next unless $Tag->acl('check', $_->{permission});
-
- if ($opt->{selected}) {
- if (index($base_url, $_->{url}) == 0) {
- $selected = qq{ class="$opt->{selected}"};
- }
- else {
- $selected = '';
- }
- }
-
- $uri = $Tag->area($_->{url});
-
- push(@entries, qq{<li$selected><a href="$uri">$_->{name}</a></li>});
- }
-
- if ($opt->{hooks}) {
- my @hook_entries = $Tag->call_hooks('menu', 'collect', $name, $opt);
-
- for (@hook_entries) {
- next unless ref($_) eq 'HASH';
- if ($_->{url}) {
- $uri = $Tag->area($_->{url});
- push(@entries, qq{<li><a href="$uri">$_->{name}</a></li>});
- }
- else {
- push(@entries, qq{<li>$_->{name}</li>});
- }
- }
- }
-
- return q{<ul>} . join('', @entries) . q{</ul>};
-}
-EOR
diff --git a/global/wellwell.cfg b/global/wellwell.cfg
new file mode 100644
index 0000000..34acd01
--- /dev/null
+++ b/global/wellwell.cfg
@@ -0,0 +1,2 @@
+Message Loading WellWell::Menu module
+require module WellWell::Menu lib
\ No newline at end of file
diff --git a/lib/WellWell/Menu.pm b/lib/WellWell/Menu.pm
new file mode 100644
index 0000000..b54908d
--- /dev/null
+++ b/lib/WellWell/Menu.pm
@@ -0,0 +1,88 @@
+# WellWell::Menu - WellWell Menu Functions/Tags
+#
+# Copyright (C) 2009 Stefan Hornburg (Racke) <racke at linuxia.de>.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public
+# License along with this program; if not, write to the Free
+# Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+# MA 02110-1301, USA.
+
+package WellWell::Menu;
+
+use strict;
+use warnings;
+
+use Vend::Config;
+use Vend::Tags;
+use Vend::Data;
+
+Vend::Config::parse_tag('UserTag', 'menu_display Order name');
+Vend::Config::parse_tag('UserTag', 'menu_display AddAttr');
+Vend::Config::parse_tag('UserTag', 'menu_display MapRoutine WellWell::Menu::display');
+
+sub display {
+ my ($name, $opt) = @_;
+ my ($set, $uri, @entries, $name_qtd, @fields, $fstr, $base_url, $selected);
+ my ($db_menus);
+
+ $db_menus = database_exists_ref('menus');
+
+ $name_qtd = $db_menus->quote($name);
+
+ @fields = qw/code name url parent permission/;
+
+ $fstr = join(',', @fields);
+
+ $set = $db_menus->query({sql => qq{select $fstr from menus where menu_name = $name_qtd order by parent asc, weight desc, code}, hashref => 1});
+
+ if ($opt->{selected}) {
+ $base_url = $Vend::Session->{last_url};
+ $base_url =~ s%^/%%;
+ }
+
+ for (@$set) {
+ next unless Vend::Tags->acl('check', $_->{permission});
+
+ if ($opt->{selected}) {
+ if (index($base_url, $_->{url}) == 0) {
+ $selected = qq{ class="$opt->{selected}"};
+ }
+ else {
+ $selected = '';
+ }
+ }
+
+ $uri = Vend::Tags->area($_->{url});
+
+ push(@entries, qq{<li$selected><a href="$uri">$_->{name}</a></li>});
+ }
+
+ if ($opt->{hooks}) {
+ my @hook_entries = Vend::Tags->call_hooks('menu', 'collect', $name, $opt);
+
+ for (@hook_entries) {
+ next unless ref($_) eq 'HASH';
+ if ($_->{url}) {
+ $uri = Vend::Tags->area($_->{url});
+ push(@entries, qq{<li><a href="$uri">$_->{name}</a></li>});
+ }
+ else {
+ push(@entries, qq{<li>$_->{name}</li>});
+ }
+ }
+ }
+
+ return q{<ul>} . join('', @entries) . q{</ul>};
+}
+
+1;
hooks/post-receive
--
Interchange wellwell catalog
More information about the wellwell-devel
mailing list