diff --git a/docs/changelog/6.x.x.txt b/docs/changelog/6.x.x.txt
index 5d2af9146..4c6c1b059 100644
--- a/docs/changelog/6.x.x.txt
+++ b/docs/changelog/6.x.x.txt
@@ -66,7 +66,8 @@
the master database. This will have no effect on single database users, but
can add a tremendous amount of scalability on large WebGUI sites that use
database replication.
-
+ - Templated the EditableToggle, a, and AdminToggle macros. Thanks to Colin
+ Kuskie.
6.0.3
- Fixed a recursive style change bug.
diff --git a/docs/credits.txt b/docs/credits.txt
index 07ca18380..a67fce453 100644
--- a/docs/credits.txt
+++ b/docs/credits.txt
@@ -10,6 +10,7 @@ WebGUI Core..........................JT Smith / Plain Black
Contributing Developers..............Peter Beardsley / Appropriate Solutions
Leendert Bottelberghs
Richard Caelius / 100 World
+ Irving Carrion
Richard Clark
Doug Collinge
Flavio Curti
@@ -21,13 +22,13 @@ Contributing Developers..............Peter Beardsley / Appropriate Solutions
Greg Fast / WDI
Chris Gebhardt / OpenServe
Andy Grundman
- Irving Carrion
Chris Jackson
Koen de Jonge / ProcoliX
Martin Kamerbeek / ProcoliX
Christian Kocourek
John W. Krahn
Len Kranendonk
+ Colin Kuskie
Christophe Marcant
Tony Mountifield
Tavis Parker / ParkerOne Consulting
diff --git a/docs/upgrades/upgrade_6.0.3-6.1.0.sql b/docs/upgrades/upgrade_6.0.3-6.1.0.sql
index 540b93e69..dd1c552bc 100644
--- a/docs/upgrades/upgrade_6.0.3-6.1.0.sql
+++ b/docs/upgrades/upgrade_6.0.3-6.1.0.sql
@@ -4,4 +4,7 @@ drop table international;
drop table help;
alter table WSClient add sharedCache tinyint unsigned not null default '0';
alter table WSClient add cacheTTL smallint(5) unsigned NOT NULL default '60';
+INSERT INTO template VALUES (1,'Default Account','','Macro/a_account',1,1);
+INSERT INTO template VALUES (1,'Default Editable Toggle','','Macro/EditableToggle',1,1);
+INSERT INTO template VALUES (1,'Default Admin Toggle','','Macro/AdminToggle',1,1);
diff --git a/lib/WebGUI/Macro/AdminToggle.pm b/lib/WebGUI/Macro/AdminToggle.pm
index ba64a0c72..d15b3c55c 100644
--- a/lib/WebGUI/Macro/AdminToggle.pm
+++ b/lib/WebGUI/Macro/AdminToggle.pm
@@ -15,22 +15,40 @@ use WebGUI::Grouping;
use WebGUI::International;
use WebGUI::Macro;
use WebGUI::Session;
+use WebGUI::Template;
use WebGUI::URL;
#-------------------------------------------------------------------
sub process {
- my ($temp, @param, $turnOn, $turnOff);
- if (WebGUI::Grouping::isInGroup(12)) {
- @param = WebGUI::Macro::getParams($_[0]);
- if ($session{var}{adminOn}) {
- $turnOff = $param[1] || WebGUI::International::get(517);
- $temp = ''.$turnOff.'';
- } else {
- $turnOn = $param[0] || WebGUI::International::get(516);
- $temp = ''.$turnOn.'';
- }
- }
- return $temp;
+ if (WebGUI::Grouping::isInGroup(12)) {
+ my %var;
+ my @param = WebGUI::Macro::getParams($_[0]);
+ my $templateId = 1; ##Set default template in the namespace
+ ##1 param means use my template with default text
+ my ($turnOff, $turnOn) = (WebGUI::International::get(517),WebGUI::International::get(516));
+ if (@param == 1) {
+ $templateId = WebGUI::Template::getIdByName($param[0],"Macro/AdminToggle");
+ }
+ ##2 params means use my text with the default template
+ elsif (@param == 2) {
+ ($turnOff, $turnOn) = @param;
+ }
+ ##3 or more params means use my text and template, other args ignored
+ elsif (@param >= 3) {
+ ($turnOff, $turnOn) = @param[1,2];
+ $templateId = WebGUI::Template::getIdByName($param[0],"Macro/AdminToggle");
+ }
+ if ($session{var}{adminOn}) {
+ $var{'toggle.url'} = WebGUI::URL::page('op=switchOffAdmin');
+ $var{'toggle.text'} = $turnOff;
+ } else {
+ $var{'toggle.url'} = WebGUI::URL::page('op=switchOnAdmin');
+ $var{'toggle.text'} = $turnOn;
+ }
+ $templateId = 1 if $templateId == 0;
+ return WebGUI::Template::process($templateId,"Macro/AdminToggle",\%var);
+ }
+ return "";
}
1;
diff --git a/lib/WebGUI/Macro/EditableToggle.pm b/lib/WebGUI/Macro/EditableToggle.pm
index 35af0a25f..584898e49 100644
--- a/lib/WebGUI/Macro/EditableToggle.pm
+++ b/lib/WebGUI/Macro/EditableToggle.pm
@@ -16,22 +16,39 @@ use WebGUI::International;
use WebGUI::Macro;
use WebGUI::Page;
use WebGUI::Session;
+use WebGUI::Template;
use WebGUI::URL;
#-------------------------------------------------------------------
sub process {
- my ($temp, @param, $turnOn, $turnOff);
- if (WebGUI::Page::canEdit() && WebGUI::Grouping::isInGroup(12)) {
- @param = WebGUI::Macro::getParams($_[0]);
- if ($session{var}{adminOn}) {
- $turnOff = $param[1] || WebGUI::International::get(517);
- $temp = ''.$turnOff.'';
- } else {
- $turnOn = $param[0] || WebGUI::International::get(516);
- $temp = ''.$turnOn.'';
- }
+ if (WebGUI::Page::canEdit() && WebGUI::Grouping::isInGroup(12)) {
+ my %var;
+ my @param = WebGUI::Macro::getParams($_[0]);
+ my $templateId = 1; ##Set default template in the namespace
+ my ($turnOff, $turnOn) = (WebGUI::International::get(517),WebGUI::International::get(516));
+ ##1 param means use my template with default text
+ if (@param == 1) {
+ $templateId = WebGUI::Template::getIdByName($param[0],"Macro/EditableToggle");
+ }
+ ##2 params means use my text with the default template
+ elsif (@param == 2) {
+ ($turnOff, $turnOn) = @param;
+ }
+ ##3 or more params means use my text and template, other args ignored
+ elsif (@param >= 3) {
+ ($turnOff, $turnOn) = @param[1,2];
+ }
+ if ($session{var}{adminOn}) {
+ $var{'toggle.url'} = WebGUI::URL::page('op=switchOffAdmin');
+ $var{'toggle.text'} = $turnOff;
+ } else {
+ $var{'toggle.url'} = WebGUI::URL::page('op=switchOnAdmin');
+ $var{'toggle.text'} = $turnOn;
+ }
+ $templateId = 1 if $templateId == 0;
+ return WebGUI::Template::process($templateId,"Macro/EditableToggle",\%var);
}
- return $temp;
+ return "";
}
1;
diff --git a/lib/WebGUI/Macro/a_account.pm b/lib/WebGUI/Macro/a_account.pm
index d24287bdd..2b221cc95 100644
--- a/lib/WebGUI/Macro/a_account.pm
+++ b/lib/WebGUI/Macro/a_account.pm
@@ -14,23 +14,25 @@ use strict;
use WebGUI::International;
use WebGUI::Macro;
use WebGUI::Session;
+use WebGUI::Template;
use WebGUI::URL;
#-------------------------------------------------------------------
sub process {
- my (@param, $temp);
- @param = WebGUI::Macro::getParams($_[0]);
- $temp = WebGUI::URL::page('op=displayAccount');
- if ($param[0] ne "linkonly") {
- $temp = '';
- if ($param[0] ne "") {
- $temp .= $param[0];
- } else {
- $temp .= WebGUI::International::get(46);
- }
- $temp .= '';
- }
- return $temp;
+ my %var;
+ my @param = WebGUI::Macro::getParams($_[0]);
+ $var{'account.url'} = WebGUI::URL::page('op=displayAccount');
+ my $templateId = 1; ##Set default template in the namespace
+ $var{'account.text'} = WebGUI::International::get(46);
+ if (@param == 1) {
+ $var{'account.text'} = $param[0] if $param[0];
+ }
+ elsif (@param == 2) {
+ $var{'account.text'} = $param[0] if $param[0];
+ $templateId = WebGUI::Template::getIdByName($param[1],"Macro/a_account");
+ $templateId = 1 if $templateId == 0;
+ }
+ return WebGUI::Template::process($templateId,"Macro/a_account",\%var);
}
diff --git a/lib/WebGUI/Template.pm b/lib/WebGUI/Template.pm
index 06622057e..0e353f1a2 100644
--- a/lib/WebGUI/Template.pm
+++ b/lib/WebGUI/Template.pm
@@ -38,6 +38,7 @@ This package contains utility methods for WebGUI's template system.
use WebGUI::Template;
$hashRef = WebGUI::Template::get($templateId, $namespace);
$hashRef = WebGUI::Template::getList($namespace);
+ $templateId = WebGUI::Template::getIdByName($name,$namespace);
$html = WebGUI::Template::process($templateId, $namespace, $vars);
$templateId = WebGUI::Template::set(\%data);
@@ -134,6 +135,35 @@ sub getList {
}
+#-------------------------------------------------------------------
+
+=head2 getIdByName ( name, namespace ) {
+
+Returns a template ID by looking up the name for it.
+
+=over
+
+=item name
+
+The name to look up.
+
+=item namespace
+
+The namespace to focus on when searching.
+
+=back
+
+=cut
+
+sub getIdByName {
+ my $name = shift;
+ my $namespace = shift;
+ my ($templateId) = WebGUI::SQL->quickArray("select templateId from template where namespace=".quote($namespace)." and name=".quote($name),WebGUI::SQL->getSlave);
+ return $templateId;
+}
+
+
+
#-------------------------------------------------------------------
=head2 process ( templateId, namespace, vars )