package WebGUI::Template; #------------------------------------------------------------------- # 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 Tie::IxHash; use WebGUI::ErrorHandler; use WebGUI::HTMLForm; use WebGUI::Session; use WebGUI::SQL; #------------------------------------------------------------------- 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 (%list); tie %list, 'Tie::IxHash'; %list = WebGUI::SQL->buildHash("select templateId,name from template order by name"); return %list; } #------------------------------------------------------------------- sub getPositions { my ($cmd, %hash, $template, $i); tie %hash, "Tie::IxHash"; ($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;