From 044b024011726968488ab2ba34180fb1c14fcdd7 Mon Sep 17 00:00:00 2001 From: JT Smith Date: Sun, 22 Feb 2004 18:10:14 +0000 Subject: [PATCH] added an empty style template and the ability to hide templates from forms and editing --- docs/upgrades/upgrade_5.9.9-6.0.0.sql | 9 +++++++++ lib/WebGUI/Operation/Template.pm | 4 ++-- lib/WebGUI/Operation/WebGUI.pm | 4 ++-- lib/WebGUI/Style.pm | 2 ++ lib/WebGUI/Template.pm | 2 +- 5 files changed, 16 insertions(+), 5 deletions(-) diff --git a/docs/upgrades/upgrade_5.9.9-6.0.0.sql b/docs/upgrades/upgrade_5.9.9-6.0.0.sql index 29bbc612d..cf1766c95 100644 --- a/docs/upgrades/upgrade_5.9.9-6.0.0.sql +++ b/docs/upgrades/upgrade_5.9.9-6.0.0.sql @@ -523,3 +523,12 @@ INSERT INTO template VALUES (2,'Events List','\r\n

INSERT INTO template VALUES (3,'Calendar Month (Small)','\r\n

\r\n
\r\n\r\n\r\n

\r\n\r\n\r\n\r\n \">\r\n

\r\n\r\n\r\n\n\n\n\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n

 
HeaderData\" width=\"28\" valign=\"top\" align=\"left\">

\n \n \">\n \n \n \n

 
\n
\n\n\n\n

\n · · \n
\n
\n','EventsCalendar'); INSERT INTO template VALUES (1,'Calendar Month (Big)','\r\n

\r\n
\r\n\r\n\r\n

\r\n\r\n\r\n\r\n \">\r\n

\r\n\r\n\r\n\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n

 
HeaderData\" width=\"14%\" valign=\"top\" align=\"left\">

\n \n \n ·\">
\n
\n
\n
 
\n
\n\n\n\n

\n · · \n
\n
\n','EventsCalendar'); +alter table template add column isEditable int not null default 1; +alter table template add column showInForms int not null default 1; +update template set showInForms=0 where namespace='style' and templateId=10; +update template set isEditable=0, showInForms=0 where namespace='style' and templateId in (1,2,4,5); +insert into template (templateId, name, template, namespace, isEditable, showInForms) values (6,'Empty','','style',0,0); + + + + diff --git a/lib/WebGUI/Operation/Template.pm b/lib/WebGUI/Operation/Template.pm index dd7befa8c..e08f49e8b 100644 --- a/lib/WebGUI/Operation/Template.pm +++ b/lib/WebGUI/Operation/Template.pm @@ -187,10 +187,10 @@ sub www_editTemplateSave { sub www_listTemplates { my ($output, $sth, @data, @row, $i, $p, $where); if (WebGUI::Privilege::isInGroup(8)) { - $where = "where namespace=".quote($session{form}{namespace}) if ($session{form}{namespace}); + $where = "and namespace=".quote($session{form}{namespace}) if ($session{form}{namespace}); $output = helpIcon(33); $output .= '

'.WebGUI::International::get(506).'

'; - $sth = WebGUI::SQL->read("select templateId,name,namespace from template $where order by namespace,name"); + $sth = WebGUI::SQL->read("select templateId,name,namespace from template where isEditable=1 $where order by namespace,name"); while (@data = $sth->array) { $row[$i] = '' .deleteIcon('op=deleteTemplate&tid='.$data[0].'&namespace='.$data[2]) diff --git a/lib/WebGUI/Operation/WebGUI.pm b/lib/WebGUI/Operation/WebGUI.pm index ef2abc958..1406cec9a 100644 --- a/lib/WebGUI/Operation/WebGUI.pm +++ b/lib/WebGUI/Operation/WebGUI.pm @@ -19,7 +19,7 @@ our @EXPORT = qw(&www_theWg &www_genesis); #------------------------------------------------------------------- sub www_genesis { - $session{page}{styleId} = 2; + $session{page}{useEmptyStyle} = 1; my $output = 'About WebGUI @@ -37,7 +37,7 @@ sub www_genesis { #------------------------------------------------------------------- sub www_theWg { - $session{page}{styleId} = 2; + $session{page}{useEmptyStyle} = 1; my $output = 'WebGUI
packageWebGUI;our$VERSION="5.5.0";usestrictqw(varssubs);useTie::CPHash;useW diff --git a/lib/WebGUI/Style.pm b/lib/WebGUI/Style.pm index 7a34a9b12..3908fa7d1 100644 --- a/lib/WebGUI/Style.pm +++ b/lib/WebGUI/Style.pm @@ -95,6 +95,8 @@ sub process { $templateId = $session{setting}{adminStyleId}; } elsif ($session{scratch}{personalStyleId} ne "") { $templateId = $session{scratch}{personalStyleId}; + } elsif ($session{page}{useEmptyStyle}) { + $templateId = 6; } my $type = lc($session{setting}{siteicon}); $type =~ s/.*\.(.*?)$/$1/; diff --git a/lib/WebGUI/Template.pm b/lib/WebGUI/Template.pm index b83b8d48b..829316e4e 100644 --- a/lib/WebGUI/Template.pm +++ b/lib/WebGUI/Template.pm @@ -93,7 +93,7 @@ Defaults to "Page". Specify the namespace to build the list for. sub getList { my $namespace = $_[0] || "Page"; - return WebGUI::SQL->buildHashRef("select templateId,name from template where namespace=".quote($namespace)." order by name"); + return WebGUI::SQL->buildHashRef("select templateId,name from template where namespace=".quote($namespace)." and showInForms=1 order by name"); }