[wellwell-devel] [SCM] Interchange wellwell catalog branch, master, updated. d7753a16692758831cf65a92e4e959d212e5c5e0

Stefan Hornburg racke at rt.icdevgroup.org
Mon Oct 19 13:12:09 UTC 2009


       via  d7753a16692758831cf65a92e4e959d212e5c5e0 (commit)
       via  ae7ab4db565ecb9b09d44d829dddafe703723228 (commit)
       via  d7744e119fcb4eef8453cf4d491dcff6750deeec (commit)
       via  df440d4e41f66711b7633f7da7c58c3fcc8c4329 (commit)
      from  c2771d106d30694fd6c8c0f70a198b07593db99d (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 d7753a16692758831cf65a92e4e959d212e5c5e0
Author: Stefan Hornburg (Racke) <racke at linuxia.de>
Date:   Mon Oct 19 15:11:38 2009 +0200

    menu administration added to backend plugin

commit ae7ab4db565ecb9b09d44d829dddafe703723228
Author: Stefan Hornburg (Racke) <racke at linuxia.de>
Date:   Mon Oct 19 14:07:44 2009 +0200

    removed debug message

commit d7744e119fcb4eef8453cf4d491dcff6750deeec
Author: Stefan Hornburg (Racke) <racke at linuxia.de>
Date:   Mon Oct 19 14:01:21 2009 +0200

    pass hooks parameter to [menu-display]

commit df440d4e41f66711b7633f7da7c58c3fcc8c4329
Author: Stefan Hornburg (Racke) <racke at linuxia.de>
Date:   Mon Oct 19 13:59:57 2009 +0200

    add option to retrieve menu entries by calling plugin hooks

-----------------------------------------------------------------------

Summary of changes and diff:
 catalog.cfg                                        |    1 +
 code/call_hooks.tag                                |    1 -
 code/menu_display.tag                              |   17 +++++++++++++-
 components/menu                                    |    2 +-
 plugins/backend/code/backend.sub                   |   23 +++++++++++++++++++-
 plugins/backend/code/backend_menu.sub              |   22 +++++++++++++++++++
 plugins/backend/code/form_menus_load.sub           |   20 +++++++++++++++++
 plugins/backend/code/form_menus_save.sub           |   20 +++++++++++++++++
 plugins/backend/components/backend_menus           |   17 ++++++++++++++
 plugins/backend/components/backend_menus_menu      |   15 +++++++++++++
 .../{categories/edit.html => menus/edit.itl}       |    7 ++---
 plugins/backend/pages/backend/menus/list.itl       |   13 +++++++++++
 plugins/backend/pages/backend/menus/menu.itl       |   13 +++++++++++
 plugins/backend/profiles/menus.profile             |    3 ++
 14 files changed, 166 insertions(+), 8 deletions(-)
 create mode 100644 plugins/backend/code/backend_menu.sub
 create mode 100644 plugins/backend/code/form_menus_load.sub
 create mode 100644 plugins/backend/code/form_menus_save.sub
 create mode 100644 plugins/backend/components/backend_menus
 create mode 100644 plugins/backend/components/backend_menus_menu
 copy plugins/backend/pages/backend/{categories/edit.html => menus/edit.itl} (51%)
 create mode 100644 plugins/backend/pages/backend/menus/list.itl
 create mode 100644 plugins/backend/pages/backend/menus/menu.itl
 create mode 100644 plugins/backend/profiles/menus.profile

diff --git a/catalog.cfg b/catalog.cfg
index 33c133b..18604b8 100644
--- a/catalog.cfg
+++ b/catalog.cfg
@@ -39,6 +39,7 @@ DatabaseAuto __SQLDSN__
 NoImportExternal Yes
 
 Database images AUTO_SEQUENCE images_code_seq
+Database menus AUTO_SEQUENCE menus_code_seq
 Database product_images AUTO_SEQUENCE product_images_code_seq
 Database users KEY uid
 Database users AUTO_SEQUENCE users_uid_seq
diff --git a/code/call_hooks.tag b/code/call_hooks.tag
index 7843455..4ab7dc3 100644
--- a/code/call_hooks.tag
+++ b/code/call_hooks.tag
@@ -8,7 +8,6 @@ sub {
 	@plugins = split(/,/, $Variable->{PLUGINS});
 
 	for my $plugin (@plugins) {
-		Log("Checkin for function ${plugin}_$name");
 		if ($sub = $Config->{Sub}->{"${plugin}_$name"}) {
 			push(@ret, $sub->($opt));
 		}
diff --git a/code/menu_display.tag b/code/menu_display.tag
index fa1a63f..827ee13 100644
--- a/code/menu_display.tag
+++ b/code/menu_display.tag
@@ -37,6 +37,21 @@ sub {
 		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
\ No newline at end of file
+EOR
diff --git a/components/menu b/components/menu
index f5c5044..a84bbc8 100644
--- a/components/menu
+++ b/components/menu
@@ -1 +1 @@
-[menu-display __NAME__]
\ No newline at end of file
+[menu-display name="__NAME__" hooks="__HOOKS__"]
diff --git a/plugins/backend/code/backend.sub b/plugins/backend/code/backend.sub
index 6d274cc..a412beb 100644
--- a/plugins/backend/code/backend.sub
+++ b/plugins/backend/code/backend.sub
@@ -3,7 +3,7 @@ sub {
 	my ($name, @args) = split(/\//, shift);
 	my (@fields, @values, $rowref);
 
-	unless ($Tag->acl('check')) {
+	unless ($Tag->acl('check', 'backend')) {
 		$Tag->error({name => 'backend',
 			set => 'Access denied'});
 		$CGI->{mv_nextpage} = 'login';
@@ -43,6 +43,27 @@ sub {
 			$CGI->{mv_nextpage} = 'backend/categories/list';
 			return 1;
 		}
+	} elsif ($args[0] eq 'menus') {
+		if ($args[1]) {
+			# specific menu
+			if ($args[2] eq 'add') {
+				$CGI->{menu_name} = $args[1];
+				$CGI->{mv_nextpage} = 'backend/menus/edit';
+			}
+			elsif ($args[3] eq 'edit' && $args[2] =~ /^(\d+)$/) {
+				$CGI->{menu_name} = $args[1];
+				$CGI->{menu_code} = $args[2];
+				$CGI->{mv_nextpage} = 'backend/menus/edit';
+			}
+			else {
+				$CGI->{menu} = $args[1];
+				$CGI->{mv_nextpage} = 'backend/menus/menu';
+			}
+		}
+		else {
+			$CGI->{mv_nextpage} = 'backend/menus/list';
+		}
+		return 1;
 	} else {
 		$Tag->perl({tables => 'categories'});
 		$CGI->{mv_nextpage} = 'backend/products/list';
diff --git a/plugins/backend/code/backend_menu.sub b/plugins/backend/code/backend_menu.sub
new file mode 100644
index 0000000..312777a
--- /dev/null
+++ b/plugins/backend/code/backend_menu.sub
@@ -0,0 +1,22 @@
+Sub backend_menu <<EOS
+sub {
+	my ($name, $opt) = @_;
+	my (@entries);
+
+	if ($name eq 'backend') {
+		push(@entries, {name => 'Menus', url => 'backend/menus'});		
+		return @entries;
+	}
+
+	if ($name eq 'backend_menus') {
+	    my $link;
+
+		push(@entries, {name => $CGI->{menu}});
+
+		$link = $Tag->area({href => "backend/menus/$CGI->{menu}/add"});
+
+		push(@entries, {name => 'Add item', url => $link});
+		return @entries;
+	}
+}
+EOS
\ No newline at end of file
diff --git a/plugins/backend/code/form_menus_load.sub b/plugins/backend/code/form_menus_load.sub
new file mode 100644
index 0000000..aab836d
--- /dev/null
+++ b/plugins/backend/code/form_menus_load.sub
@@ -0,0 +1,20 @@
+Sub form_menus_load <<EOS
+sub {
+	my $menu_ref;
+
+	$Tag->perl({tables => 'menus'});
+
+	# load data for menu entry
+	$menu_ref = $Db{menus}->row_hash($CGI->{menu_code});
+
+	unless ($menu_ref) {
+		return {page => "backend/menus/$menu{menu_name}"};
+	}
+
+	$Values->{menu_code} = $menu_ref->{code};
+	$Values->{name} = $menu_ref->{name};
+	$Values->{url} = $menu_ref->{url};
+
+	return;
+}
+EOS
\ No newline at end of file
diff --git a/plugins/backend/code/form_menus_save.sub b/plugins/backend/code/form_menus_save.sub
new file mode 100644
index 0000000..8b18097
--- /dev/null
+++ b/plugins/backend/code/form_menus_save.sub
@@ -0,0 +1,20 @@
+Sub form_menus_save <<EOS
+sub {
+	my %menu;
+
+	$Tag->perl({tables => 'menus'});
+
+	$menu{menu_name} = $CGI->{menu_name};
+	$menu{name} = $CGI->{name};
+	$menu{url} = $CGI->{url};
+
+	if ($CGI->{menu_code}) {
+		$ret = $Db{menus}->set_slice([{dml => 'update'}, $CGI->{menu_code}], %menu);
+	}
+	else {
+		$ret = $Db{menus}->set_slice([{dml => 'insert'}], %menu);
+	}
+		
+	return {page => "backend/menus/$menu{menu_name}"};
+}
+EOS
diff --git a/plugins/backend/components/backend_menus b/plugins/backend/components/backend_menus
new file mode 100644
index 0000000..3fdf11b
--- /dev/null
+++ b/plugins/backend/components/backend_menus
@@ -0,0 +1,17 @@
+<div class="oneThirdGrad">
+<h2>[L]Menus[/L]</h2>
+[query sql="select distinct menu_name from menus" list=1]
+[on-match]
+<table>
+[/on-match]
+[list]
+<tr><td><a href="[area backend/menus/[sql-code]]">[sql-code]</a></td></tr>
+[/list]
+[on-match]
+</table>
+[/on-match]
+[no-match]
+[L]No menus found.[/L]
+[/no-match]
+[/query]
+</div>
\ No newline at end of file
diff --git a/plugins/backend/components/backend_menus_menu b/plugins/backend/components/backend_menus_menu
new file mode 100644
index 0000000..8784d48
--- /dev/null
+++ b/plugins/backend/components/backend_menus_menu
@@ -0,0 +1,15 @@
+<div class="oneThirdGrad">
+[query sql="select * from menus where menu_name = '[cgi menu]'" list=1]
+[on-match]
+<table>
+<tr><th>Name</th><th>URL</th><th></th></tr>
+[/on-match]
+[list]
+<tr><td>[sql-param name]</td><td>[sql-param url]</td>
+<td><a href="[area href="backend/menus/[cgi menu]/[sql-code]/edit"]">Edit</a></td></tr>
+[/list]
+[on-match]
+</table>
+[/on-match]
+[/query]
+</div>
\ No newline at end of file
diff --git a/plugins/backend/pages/backend/categories/edit.html b/plugins/backend/pages/backend/menus/edit.itl
similarity index 51%
copy from plugins/backend/pages/backend/categories/edit.html
copy to plugins/backend/pages/backend/menus/edit.itl
index 7acec46..6ffb1d9 100644
--- a/plugins/backend/pages/backend/categories/edit.html
+++ b/plugins/backend/pages/backend/menus/edit.itl
@@ -3,10 +3,9 @@
     attributes.menu.name="backend"
     components.right="login"
 
-	components.body="backend_edit"
+	components.body="backend_menus_add"
+	forms.backend_menus_add.name="[if cgi menu_code]menus_entry_edit[else]menus_entry_add[/else][/if]"
 
 	attributes.htmlhead.title="Well Well Backend"
 
-    attributes.backend_edit.subject="categories"
-    attributes.backend_edit.key=`$CGI->{category}`
-/]
+/]
\ No newline at end of file
diff --git a/plugins/backend/pages/backend/menus/list.itl b/plugins/backend/pages/backend/menus/list.itl
new file mode 100644
index 0000000..6f7e04f
--- /dev/null
+++ b/plugins/backend/pages/backend/menus/list.itl
@@ -0,0 +1,13 @@
+[compose
+	components.left="menu"
+    attributes.menu.name="backend"
+    components.right="login"
+
+	components.body="menu=menu_left backend_menus"
+	attributes.menu_left.name="backend"
+	attributes.menu_left.hooks=1
+
+	attributes.htmlhead.title="Well Well Backend"
+
+    attributes.backend_list.subject="menus"
+/]
\ No newline at end of file
diff --git a/plugins/backend/pages/backend/menus/menu.itl b/plugins/backend/pages/backend/menus/menu.itl
new file mode 100644
index 0000000..2e03b56
--- /dev/null
+++ b/plugins/backend/pages/backend/menus/menu.itl
@@ -0,0 +1,13 @@
+[compose
+	components.left="menu"
+    attributes.menu.name="backend"
+    components.right="login"
+
+	components.body="menu=menu_left backend_menus_menu"
+	attributes.menu_left.name="backend_menus"
+	attributes.menu_left.hooks=1
+
+	attributes.htmlhead.title="Well Well Backend"
+
+    attributes.backend_list.subject="menus"
+/]
diff --git a/plugins/backend/profiles/menus.profile b/plugins/backend/profiles/menus.profile
new file mode 100644
index 0000000..725dc94
--- /dev/null
+++ b/plugins/backend/profiles/menus.profile
@@ -0,0 +1,3 @@
+__NAME__ menus
+name=required
+__END__
\ No newline at end of file


hooks/post-receive
-- 
Interchange wellwell catalog



More information about the wellwell-devel mailing list