diff --git a/lib/WebGUI.pm b/lib/WebGUI.pm index ffcd96126..b1e4d036d 100644 --- a/lib/WebGUI.pm +++ b/lib/WebGUI.pm @@ -23,7 +23,6 @@ use WebGUI::Session; use WebGUI::SQL; use WebGUI::Style; use WebGUI::Template; -use WebGUI::Template::Default; use WebGUI::URL; use WebGUI::Utility; @@ -88,6 +87,12 @@ sub _displayAdminBar { %hash ); } + if (WebGUI::Privilege::isInGroup(8,$session{user}{userId})) { + %hash = ( + WebGUI::URL::page('op=listTemplates')=>WebGUI::International::get(508), + %hash + ); + } %hash = ( WebGUI::URL::page('op=viewHelpIndex')=>WebGUI::International::get(13), %hash @@ -126,9 +131,6 @@ sub page { my ($debug, %contentHash, $w, $cmd, $pageEdit, $wobject, $wobjectOutput, $extra, $sth, $httpHeader, $header, $footer, $content, $operationOutput, $adminBar, %hash); WebGUI::Session::open($_[0],$_[1]); - # For some reason we have to pre-cache the templates when running under mod_perl - # so that's what we're doing with this next command. - WebGUI::Template::loadTemplates(); if ($session{form}{debug}==1 && WebGUI::Privilege::isInGroup(3)) { $debug = ''; while (my ($section, $hash) = each %session) { @@ -170,11 +172,11 @@ sub page { # $wobjectOutput = WebGUI::International::get(381); # bad error } if ($operationOutput ne "") { - $contentHash{A} = $operationOutput; - $content = WebGUI::Template::Default::generate(\%contentHash); + $contentHash{0} = $operationOutput; + $content = WebGUI::Template::generate(\%contentHash,1); } elsif ($wobjectOutput ne "") { - $contentHash{A} = $wobjectOutput; - $content = WebGUI::Template::Default::generate(\%contentHash); + $contentHash{0} = $wobjectOutput; + $content = WebGUI::Template::generate(\%contentHash,1); } else { if (WebGUI::Privilege::canViewPage()) { if ($session{var}{adminOn}) { @@ -213,13 +215,10 @@ sub page { } } $sth->finish; - $cmd = "use WebGUI::Template::".$session{page}{template}; - eval($cmd); - $cmd = "WebGUI::Template::".$session{page}{template}."::generate"; - $content = &$cmd(\%contentHash); + $content = WebGUI::Template::generate(\%contentHash,$session{page}{templateId}); } else { - $contentHash{A} = WebGUI::Privilege::noAccess(); - $content = WebGUI::Template::Default::generate(\%contentHash); + $contentHash{0} = WebGUI::Privilege::noAccess(); + $content = WebGUI::Template::generate(\%contentHash,1); } } if ($session{var}{adminOn}) { diff --git a/lib/WebGUI/Operation.pm b/lib/WebGUI/Operation.pm index 00fee0611..be0248e9e 100644 --- a/lib/WebGUI/Operation.pm +++ b/lib/WebGUI/Operation.pm @@ -24,6 +24,7 @@ use WebGUI::Operation::Search; use WebGUI::Operation::Settings; use WebGUI::Operation::Statistics; use WebGUI::Operation::Style; +use WebGUI::Operation::Template; use WebGUI::Operation::Trash; use WebGUI::Operation::User; diff --git a/lib/WebGUI/Operation/Page.pm b/lib/WebGUI/Operation/Page.pm index 1a7d7556b..2140640a9 100644 --- a/lib/WebGUI/Operation/Page.pm +++ b/lib/WebGUI/Operation/Page.pm @@ -139,7 +139,7 @@ sub www_editPage { $f = WebGUI::HTMLForm->new; if ($session{form}{npp} ne "") { %page = WebGUI::SQL->quickHash("select * from page where pageId=$session{form}{npp}"); - $page{templatePosition} = 'A'; + $page{templateId} = 1; $page{pageId} = "new"; $page{title} = $page{menuTitle} = $page{urlizedTitle} = $page{synopsis} = ''; $page{parentId} = $session{form}{npp}; @@ -158,10 +158,9 @@ sub www_editPage { $f->text("title",WebGUI::International::get(99),$page{title}); $f->text("menuTitle",WebGUI::International::get(411),$page{menuTitle}); $f->text("urlizedTitle",WebGUI::International::get(104),$page{urlizedTitle}); - %hash = sortHash(WebGUI::Template::getList()); - $f->select("template",\%hash,WebGUI::International::get(356),[$page{templatePosition}],'','', - 'onChange="updateTemplateImage(template.value)"', - '
'); + #%hash = WebGUI::Template::getList(); + #$f->select("templateId",\%hash,WebGUI::International::get(356),[$page{templateId}]); + $f->readOnly(WebGUI::Template::selectTemplate($page{templateId}),WebGUI::International::get(356)); $f->textarea("synopsis",WebGUI::International::get(412),$page{synopsis}); $f->textarea("metatags",WebGUI::International::get(100),$page{metaTags}); $f->yesNo("defaultMetaTags",WebGUI::International::get(307),$page{defaultMetaTags}); @@ -226,7 +225,7 @@ sub www_editPageSave { metaTags=".quote($session{form}{metaTags}).", urlizedTitle='$session{form}{urlizedTitle}', defaultMetaTags='$session{form}{defaultMetaTags}', - template='$session{form}{template}', + templateId='$session{form}{templateId}', menuTitle=".quote($session{form}{menuTitle}).", synopsis=".quote($session{form}{synopsis})." where pageId=$session{form}{pageId}"); diff --git a/lib/WebGUI/Operation/Style.pm b/lib/WebGUI/Operation/Style.pm index 654c522ff..9c1011062 100644 --- a/lib/WebGUI/Operation/Style.pm +++ b/lib/WebGUI/Operation/Style.pm @@ -123,8 +123,8 @@ sub www_listStyles { $output = helpIcon(9); $output .= '

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

'; $output .= '
'.WebGUI::International::get(158).'
'; - $sth = WebGUI::SQL->read("select styleId,name from style where name<>'Reserved' order by name"); + '">'.WebGUI::International::get(158).'

'; + $sth = WebGUI::SQL->read("select styleId,name from style order by name"); while (@data = $sth->array) { $row[$i] = '

' .deleteIcon('op=deleteStyle&sid='.$data[0]) diff --git a/lib/WebGUI/Template.pm b/lib/WebGUI/Template.pm index 6d113a8ae..46f6fc187 100644 --- a/lib/WebGUI/Template.pm +++ b/lib/WebGUI/Template.pm @@ -1,15 +1,5 @@ package WebGUI::Template; - - -##################################################################### -##################################################################### -# NOTICE: Use of this subsystem is depricated and is not recommended. -##################################################################### -##################################################################### - - - #------------------------------------------------------------------- # WebGUI is Copyright 2001-2002 Plain Black Software. #------------------------------------------------------------------- @@ -20,73 +10,108 @@ package WebGUI::Template; # http://www.plainblack.com info@plainblack.com #------------------------------------------------------------------- -use strict qw(vars subs); +use strict; use Tie::IxHash; use WebGUI::ErrorHandler; +use WebGUI::HTMLForm; use WebGUI::Session; - +use WebGUI::SQL; #------------------------------------------------------------------- -sub loadTemplates { - my ($templateDir, @files, $file, $use, @template, $i); - if ($^O =~ /Win/i) { - $templateDir = "\\lib\\WebGUI\\Template"; - } else { - $templateDir = "/lib/WebGUI/Template"; - } - opendir (DIR,$session{config}{webguiRoot}.$templateDir) or WebGUI::ErrorHandler::fatalError("Can't open template directory!"); - @files = readdir(DIR); - foreach $file (@files) { - if ($file =~ /(.*?)\.pm$/) { - $template[$i] = $1; - $use = "require WebGUI::Template::".$template[$i]; - eval($use); - if ($@) { - WebGUI::ErrorHandler::fatalError("Template load failed: ".$@); - } - $i++; - } - } - closedir(DIR); - return @template; -} - -#------------------------------------------------------------------- -sub calculatePositions { - my (%positions, $string); - $string = "A"; - $positions{A} = "A"; - while ($string ne $_[0]) { - $string = ++$string; - $positions{$string} = $string; - } - return %positions; +sub generate { + my ($output, $content, %template); + %template = WebGUI::SQL->quickHash("select * from template where templateId=".$_[1]); + $content = $template{template}; + $content =~ s/\^(\d+)\;/${$_[0]}{$1}/g; + return $content; } #------------------------------------------------------------------- sub getList { - my (@templates, $cmd, $template, $namespace, %list); - @templates = loadTemplates(); - foreach $template (@templates) { - #$cmd = "WebGUI::Template::".$template."::namespace"; - #$namespace = $$cmd; - $cmd = "WebGUI::Template::".$template."::name"; - $list{$template} = &$cmd(); - } + my (%list); + tie %list, 'Tie::IxHash'; + %list = WebGUI::SQL->buildHash("select templateId,name from template order by name"); return %list; } #------------------------------------------------------------------- sub getPositions { - my ($cmd, %hash); + my ($cmd, %hash, $template, $i); tie %hash, "Tie::IxHash"; - $cmd = "use WebGUI::Template::".$_[0]; - eval($cmd); - $cmd = "WebGUI::Template::".$_[0]."::getPositions"; - %hash = &$cmd; - return %hash; + ($template) = WebGUI::SQL->quickArray("select template from template where templateId=".$_[0]); + $i = 0; + while ($template =~ m/\^$i\;/) { + $hash{$i} = $i; + $i++; + } + return \%hash; } +#------------------------------------------------------------------- +sub selectTemplate { + my ($output, $f, %templates, $key); + tie %templates,'Tie::IxHash'; + $f = WebGUI::HTMLForm->new(1); + %templates = WebGUI::SQL->buildHash("select templateId,name from template order by name"); + $f->select("templateId",\%templates,'',[$_[0]],'','','onChange="changeTemplatePreview(this.form.templateId.value)"'); + %templates = WebGUI::SQL->buildHash("select templateId,template from template"); + $output = ' + '; + $output .= $f->printRowsOnly; + $output .= '
'; + return $output; +} 1; diff --git a/lib/WebGUI/Template/Default.pm b/lib/WebGUI/Template/Default.pm deleted file mode 100644 index 106094587..000000000 --- a/lib/WebGUI/Template/Default.pm +++ /dev/null @@ -1,51 +0,0 @@ -package WebGUI::Template::Default; - - - -##################################################################### -##################################################################### -# NOTICE: Use of this subsystem is depricated and is not recommended. -##################################################################### -##################################################################### - - -our $namespace = "Default"; - -#------------------------------------------------------------------- -# WebGUI is Copyright 2001-2002 Plain Black Software. -#------------------------------------------------------------------- -# Please read the legal notices (docs/legal.txt) and the license -# (docs/license.txt) that came with this distribution before using -# this software. -#------------------------------------------------------------------- -# http://www.plainblack.com info@plainblack.com -#------------------------------------------------------------------- - - -use strict; -use WebGUI::International; -use WebGUI::Template; - -#------------------------------------------------------------------- -sub generate { - my ($output, $content); - $content = $_[0]; - $output = ''; - $output .= '
'; - $output .= ${$content}{A}; - $output .= '
'; - return $output; -} - -#------------------------------------------------------------------- -sub name { - return WebGUI::International::get(355); -} - -#------------------------------------------------------------------- -sub getPositions { - return WebGUI::Template::calculatePositions('A'); -} - -1; - diff --git a/lib/WebGUI/Template/LeftColumn.pm b/lib/WebGUI/Template/LeftColumn.pm deleted file mode 100644 index 51cada922..000000000 --- a/lib/WebGUI/Template/LeftColumn.pm +++ /dev/null @@ -1,53 +0,0 @@ -package WebGUI::Template::LeftColumn; - - - -##################################################################### -##################################################################### -# NOTICE: Use of this subsystem is depricated and is not recommended. -##################################################################### -##################################################################### - - -our $namespace = "LeftColumn"; - -#------------------------------------------------------------------- -# WebGUI is Copyright 2001-2002 Plain Black Software. -#------------------------------------------------------------------- -# Please read the legal notices (docs/legal.txt) and the license -# (docs/license.txt) that came with this distribution before using -# this software. -#------------------------------------------------------------------- -# http://www.plainblack.com info@plainblack.com -#------------------------------------------------------------------- - - -use strict; -use WebGUI::International; - - -#------------------------------------------------------------------- -sub generate { - my ($output, $content); - $content = $_[0]; - $output = ''; - $output .= '
'; - $output .= ${$content}{A}; - $output .= ''; - $output .= ${$content}{B}; - $output .= '
'; - return $output; -} - -#------------------------------------------------------------------- -sub name { - return WebGUI::International::get(358); -} - -#------------------------------------------------------------------- -sub getPositions { - return WebGUI::Template::calculatePositions('B'); -} - -1; - diff --git a/lib/WebGUI/Template/News.pm b/lib/WebGUI/Template/News.pm deleted file mode 100644 index 0feb93583..000000000 --- a/lib/WebGUI/Template/News.pm +++ /dev/null @@ -1,53 +0,0 @@ -package WebGUI::Template::News; - - - -##################################################################### -##################################################################### -# NOTICE: Use of this subsystem is depricated and is not recommended. -##################################################################### -##################################################################### - - -our $namespace = "News"; - -#------------------------------------------------------------------- -# WebGUI is Copyright 2001-2002 Plain Black Software. -#------------------------------------------------------------------- -# Please read the legal notices (docs/legal.txt) and the license -# (docs/license.txt) that came with this distribution before using -# this software. -#------------------------------------------------------------------- -# http://www.plainblack.com info@plainblack.com -#------------------------------------------------------------------- - - -use strict; -use WebGUI::International; - - -#------------------------------------------------------------------- -sub generate { - my ($output, $content); - $content = $_[0]; - $output = ''; - $output .= ''; - $output .= ''; - $output .= ''; - $output .= ''; - $output .= '
'.${$content}{A}.'
'.${$content}{B}.''.${$content}{C}.'
'.${$content}{D}.'
'; - return $output; -} - -#------------------------------------------------------------------- -sub name { - return WebGUI::International::get(357); -} - -#------------------------------------------------------------------- -sub getPositions { - return WebGUI::Template::calculatePositions('D'); -} - -1; - diff --git a/lib/WebGUI/Template/OneOverThree.pm b/lib/WebGUI/Template/OneOverThree.pm deleted file mode 100644 index 89cfd0a45..000000000 --- a/lib/WebGUI/Template/OneOverThree.pm +++ /dev/null @@ -1,55 +0,0 @@ -package WebGUI::Template::OneOverThree; - - - -##################################################################### -##################################################################### -# NOTICE: Use of this subsystem is depricated and is not recommended. -##################################################################### -##################################################################### - - -our $namespace = "OneOverThree"; - -#------------------------------------------------------------------- -# WebGUI is Copyright 2001-2002 Plain Black Software. -#------------------------------------------------------------------- -# Please read the legal notices (docs/legal.txt) and the license -# (docs/license.txt) that came with this distribution before using -# this software. -#------------------------------------------------------------------- -# http://www.plainblack.com info@plainblack.com -#------------------------------------------------------------------- - - -use strict; -use WebGUI::International; - - -#------------------------------------------------------------------- -sub generate { - my ($output, $content); - $content = $_[0]; - $output = ''; - $output .= ''; - $output .= ''; - $output .= ''; - $output .= ''; - $output .= '
'; - $output .= ${$content}{A}; - $output .= '
'.${$content}{B}.''.${$content}{C}.''.${$content}{D}.'
'; - return $output; -} - -#------------------------------------------------------------------- -sub name { - return WebGUI::International::get(360); -} - -#------------------------------------------------------------------- -sub getPositions { - return WebGUI::Template::calculatePositions('D'); -} - -1; - diff --git a/lib/WebGUI/Template/RightColumn.pm b/lib/WebGUI/Template/RightColumn.pm deleted file mode 100644 index d034df52a..000000000 --- a/lib/WebGUI/Template/RightColumn.pm +++ /dev/null @@ -1,54 +0,0 @@ -package WebGUI::Template::RightColumn; - - - -##################################################################### -##################################################################### -# NOTICE: Use of this subsystem is depricated and is not recommended. -##################################################################### -##################################################################### - - -our $namespace = "RightColumn"; - -#------------------------------------------------------------------- -# WebGUI is Copyright 2001-2002 Plain Black Software. -#------------------------------------------------------------------- -# Please read the legal notices (docs/legal.txt) and the license -# (docs/license.txt) that came with this distribution before using -# this software. -#------------------------------------------------------------------- -# http://www.plainblack.com info@plainblack.com -#------------------------------------------------------------------- - - -use strict; -use WebGUI::International; - - -#------------------------------------------------------------------- -sub generate { - my ($output, $content); - $content = $_[0]; - $output = ''; - $output .= '
'; - $output .= ${$content}{A}; - $output .= ''; - $output .= ${$content}{B}; - $output .= '
'; - return $output; -} - -#------------------------------------------------------------------- -sub name { - return WebGUI::International::get(359); -} - -#------------------------------------------------------------------- -sub getPositions { - return WebGUI::Template::calculatePositions('B'); -} - - -1; - diff --git a/lib/WebGUI/Template/SideBySide.pm b/lib/WebGUI/Template/SideBySide.pm deleted file mode 100644 index 631916768..000000000 --- a/lib/WebGUI/Template/SideBySide.pm +++ /dev/null @@ -1,53 +0,0 @@ -package WebGUI::Template::SideBySide; - - - -##################################################################### -##################################################################### -# NOTICE: Use of this subsystem is depricated and is not recommended. -##################################################################### -##################################################################### - - -our $namespace = "SideBySide"; - -#------------------------------------------------------------------- -# WebGUI is Copyright 2001-2002 Plain Black Software. -#------------------------------------------------------------------- -# Please read the legal notices (docs/legal.txt) and the license -# (docs/license.txt) that came with this distribution before using -# this software. -#------------------------------------------------------------------- -# http://www.plainblack.com info@plainblack.com -#------------------------------------------------------------------- - - -use strict; -use WebGUI::International; - - -#------------------------------------------------------------------- -sub generate { - my ($output, $content); - $content = $_[0]; - $output = ''; - $output .= '
'; - $output .= ${$content}{A}; - $output .= ''; - $output .= ${$content}{B}; - $output .= '
'; - return $output; -} - -#------------------------------------------------------------------- -sub name { - return WebGUI::International::get(362); -} - -#------------------------------------------------------------------- -sub getPositions { - return WebGUI::Template::calculatePositions('B'); -} - -1; - diff --git a/lib/WebGUI/Template/ThreeOverOne.pm b/lib/WebGUI/Template/ThreeOverOne.pm deleted file mode 100644 index 032101e16..000000000 --- a/lib/WebGUI/Template/ThreeOverOne.pm +++ /dev/null @@ -1,53 +0,0 @@ -package WebGUI::Template::ThreeOverOne; - - - -##################################################################### -##################################################################### -# NOTICE: Use of this subsystem is depricated and is not recommended. -##################################################################### -##################################################################### - - -our $namespace = "ThreeOverOne"; - -#------------------------------------------------------------------- -# WebGUI is Copyright 2001-2002 Plain Black Software. -#------------------------------------------------------------------- -# Please read the legal notices (docs/legal.txt) and the license -# (docs/license.txt) that came with this distribution before using -# this software. -#------------------------------------------------------------------- -# http://www.plainblack.com info@plainblack.com -#------------------------------------------------------------------- - - -use strict; -use WebGUI::International; - - -#------------------------------------------------------------------- -sub generate { - my ($output, $content); - $content = $_[0]; - $output = ''; - $output .= ''; - $output .= ''; - $output .= ''; - $output .= ''; - $output .= '
'.${$content}{A}.''.${$content}{B}.''.${$content}{C}.'
'.${$content}{D}.'
'; - return $output; -} - -#------------------------------------------------------------------- -sub name { - return WebGUI::International::get(361); -} - -#------------------------------------------------------------------- -sub getPositions { - return WebGUI::Template::calculatePositions('D'); -} - -1; - diff --git a/lib/WebGUI/Wobject.pm b/lib/WebGUI/Wobject.pm index 2fe9c811d..7909fe6bd 100644 --- a/lib/WebGUI/Wobject.pm +++ b/lib/WebGUI/Wobject.pm @@ -71,14 +71,6 @@ sub _getNextSequenceNumber { return ($sequenceNumber+1); } -#------------------------------------------------------------------- -sub _getPositions { - my (%hash); - tie %hash, "Tie::IxHash"; - %hash = WebGUI::Template::getPositions($session{page}{template}); - return \%hash; -} - #------------------------------------------------------------------- =head2 description ( ) @@ -402,7 +394,7 @@ sub www_edit { $displayTitle = $_[0]->get("displayTitle"); } $title = $_[0]->get("title") || $_[0]->get("namespace"); - $templatePosition = $_[0]->get("templatePosition") || 'A'; + $templatePosition = $_[0]->get("templatePosition") || '0'; $endDate = $_[0]->get("endDate") || (time()+315360000); $f = WebGUI::HTMLForm->new; $f->hidden("wid",$_[0]->get("wobjectId")); @@ -413,7 +405,7 @@ sub www_edit { $f->text("title",WebGUI::International::get(99),$title); $f->yesNo("displayTitle",WebGUI::International::get(174),$displayTitle); $f->yesNo("processMacros",WebGUI::International::get(175),$_[0]->get("processMacros")); - $f->select("templatePosition",_getPositions(),WebGUI::International::get(363),[$templatePosition]); + $f->select("templatePosition",WebGUI::Template::getPositions($session{page}{templateId}),WebGUI::International::get(363),[$templatePosition]); $f->date("startDate",WebGUI::International::get(497),$_[0]->get("startDate")); $f->date("endDate",WebGUI::International::get(498),$endDate); $f->HTMLArea("description",WebGUI::International::get(85),$_[0]->get("description"));