From 4b17c88300b89918b9316cec8d41239946ecc9b0 Mon Sep 17 00:00:00 2001 From: JT Smith Date: Wed, 1 Sep 2004 19:14:00 +0000 Subject: [PATCH] loading templates faster --- docs/changelog/6.x.x.txt | 5 +- docs/upgrades/upgrade_6.1.1-6.2.0.sql | 14 +++++ etc/WebGUI.conf.original | 3 ++ lib/WebGUI.pm | 3 +- lib/WebGUI/Macro/JavaScript.pm | 27 ++++++++++ lib/WebGUI/Macro/RawHeadTags.pm | 27 ++++++++++ lib/WebGUI/Macro/StyleSheet.pm | 30 +++++++++++ lib/WebGUI/Style.pm | 74 +++++++++++++++++---------- lib/WebGUI/Wobject/DataForm.pm | 34 ++++++++---- lib/WebGUI/i18n/English/WebGUI.pm | 21 ++++++-- www/extras/textFix.js | 4 ++ 11 files changed, 198 insertions(+), 44 deletions(-) create mode 100644 lib/WebGUI/Macro/JavaScript.pm create mode 100644 lib/WebGUI/Macro/RawHeadTags.pm create mode 100644 lib/WebGUI/Macro/StyleSheet.pm create mode 100644 www/extras/textFix.js diff --git a/docs/changelog/6.x.x.txt b/docs/changelog/6.x.x.txt index 02dbfeba8..09a368be8 100644 --- a/docs/changelog/6.x.x.txt +++ b/docs/changelog/6.x.x.txt @@ -87,7 +87,10 @@ - RFE [ 718739 ]. USS Submission Start/End Dates (Thanks to Roy Johnson). - bugfix [ 1008039 ] When adding javascript to description, the script is doubled - + - bugfix [ 1007970 ] Fixed: DataForm duplicate doesn't copy tabs (Harry Waye) + - Added JavaScript RawHeadTags, and StyleSheet macros. + - Changed navigation, page, macro, and rich editor templates to load more + quickly. 6.1.1 - bugfix [ 991313 ] Manage Translations doesn't work diff --git a/docs/upgrades/upgrade_6.1.1-6.2.0.sql b/docs/upgrades/upgrade_6.1.1-6.2.0.sql index 2d9038d06..b4e6b8cdd 100644 --- a/docs/upgrades/upgrade_6.1.1-6.2.0.sql +++ b/docs/upgrades/upgrade_6.1.1-6.2.0.sql @@ -280,3 +280,17 @@ alter table USS_submission add startDate int(11) default 946710000; alter table USS_submission add endDate int(11) default 2114406000; update template set template = '

' where templateId=1 and namespace = 'USS/SubmissionForm'; update template set template = '

·
()
* ()

' where templateId=1 and namespace='USS'; +delete from template where templateId>=1 and templateId<=6 and namespace='richEditor'; +delete from template where templateId=6 and namespace='Navigation'; +INSERT INTO template (templateId, name, template, namespace, isEditable, showInForms) VALUES ('6','dtree','^StyleSheet(\"/Navigation/dtree/dtree.css\");\r\n^JavaScript(\"/Navigation/dtree/dtree.js\");\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n
\r\n\r\n\r\n
','Navigation',1,1); +delete from template where templateId=7 and namespace='Navigation'; +delete from template where templateId=2 and namespace='Macro/AdminBar'; +INSERT INTO template (templateId, name, template, namespace, isEditable, showInForms) VALUES ('2','DHTML Admin Bar','^JavaScript(\"/coolmenus/coolmenus4.js\");\r\n\r\n\r\n\r\n','Macro/AdminBar',1,1); +INSERT INTO template (templateId, name, template, namespace, isEditable, showInForms) VALUES ('7','Cool Menus','\r\n\r\n\r\n\r\n\r\n\r\n \r\n\r\n^JavaScript(\"/coolmenus/coolmenus4.js\");\r\n','Navigation',1,1); +INSERT INTO template (templateId, name, template, namespace, isEditable, showInForms) VALUES ('3','Midas','^JavaScript(\"/textFix.js\");\r\n\r\n\r\n \r\n \r\n\r\n\r\n\r\n','richEditor',1,1); +INSERT INTO template (templateId, name, template, namespace, isEditable, showInForms) VALUES ('4','Classic','^JavaScript(\"/textFix.js\");\r\n\r\n\r\n \r\n \r\n\r\n\r\n\r\n','richEditor',1,1); +INSERT INTO template (templateId, name, template, namespace, isEditable, showInForms) VALUES ('2','EditOnPro2','^JavaScript(\"/textFix.js\");\r\n\r\n','richEditor',1,1); +INSERT INTO template (templateId, name, template, namespace, isEditable, showInForms) VALUES ('6','HTMLArea 3 (Mozilla / IE)','^JavaScript(\"/textFix.js\");\r\n \r\n^RawHeadTags(\"\n \n\");\r\n^JavaScript(\"/htmlArea3/htmlarea.js\"); \r\n^RawHeadTags(\"\n\n\");\n \r\n \r\n\r\n ','richEditor',1,1); +INSERT INTO template (templateId, name, template, namespace, isEditable, showInForms) VALUES ('5','lastResort','^JavaScript(\"/textFix.js\");\r\n\r\n\r\n\r\n\r\n\r\n','richEditor',1,1); +INSERT INTO template (templateId, name, template, namespace, isEditable, showInForms) VALUES ('1','HTMLArea','^JavaScript(\"/textFix.js\");\r\n\r\n \r\n \r\n \r\n ^JavaScript(\"/htmlArea/editor.js\");\r\n \r\n \r\n\r\n\r\n\r\n\r\n\r\n \r\n\r\n','richEditor',1,1); + diff --git a/etc/WebGUI.conf.original b/etc/WebGUI.conf.original index 0159bb47f..8e10043c9 100644 --- a/etc/WebGUI.conf.original +++ b/etc/WebGUI.conf.original @@ -52,6 +52,7 @@ macros = a => a_account, \ H => H_homeLink, \ i => i_imageNoTags, \ I => I_imageWithTags, \ + JavaScript => JavaScript, \ L => L_loginBox, \ LastModified => LastModified, \ LoginToggle => LoginToggle, \ @@ -59,12 +60,14 @@ macros = a => a_account, \ PageTitle => PageTitle, \ RandomImage => RandomImage, \ RandomSnippet => RandomSnippet, \ + RawHeadTags => RawHeadTags, \ RootTitle => RootTitle, \ r => r_printable, \ / => Slash_gatewayUrl, \ Snippet => Snippet, \ Spacer => Spacer, \ SI => SI_scaledImage, \ + StyleSheet => StyleSheet, \ ThumbnailLinker => ThumbnailLinker, \ Thumbnail => Thumbnail, \ u => u_companyUrl diff --git a/lib/WebGUI.pm b/lib/WebGUI.pm index ef9fcc205..63f2dc71d 100644 --- a/lib/WebGUI.pm +++ b/lib/WebGUI.pm @@ -19,7 +19,6 @@ use WebGUI::ErrorHandler; use WebGUI::Grouping; use WebGUI::HTTP; use WebGUI::International; -use WebGUI::Macro; use WebGUI::Operation; use WebGUI::Privilege; use WebGUI::Session; @@ -40,7 +39,7 @@ sub _generatePage { ".quote($session{env}{HTTP_REFERER}).", ".$session{page}{pageId}.", ".quote($session{page}{title}).", ".quote($session{form}{wid}).", ".quote($session{form}{func}).")"); } - my $output = WebGUI::Macro::process(WebGUI::Style::process($content)); + my $output = WebGUI::Style::process($content); if ($session{setting}{showDebug} || ($session{form}{debug}==1 && WebGUI::Grouping::isInGroup(3))) { $output .= WebGUI::ErrorHandler::showDebug(); } diff --git a/lib/WebGUI/Macro/JavaScript.pm b/lib/WebGUI/Macro/JavaScript.pm new file mode 100644 index 000000000..68f3e5e0d --- /dev/null +++ b/lib/WebGUI/Macro/JavaScript.pm @@ -0,0 +1,27 @@ +package WebGUI::Macro::JavaScript; + +#------------------------------------------------------------------- +# WebGUI is Copyright 2001-2004 Plain Black LLC. +#------------------------------------------------------------------- +# 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::Macro; +use WebGUI::Session; +use WebGUI::Style; + +#------------------------------------------------------------------- +sub process { + my ($script) = WebGUI::Macro::getParams(shift); + WebGUI::Style::setScript($script,{type=>'text/javascript'}); + return ""; +} + +1; + + diff --git a/lib/WebGUI/Macro/RawHeadTags.pm b/lib/WebGUI/Macro/RawHeadTags.pm new file mode 100644 index 000000000..6e01232a3 --- /dev/null +++ b/lib/WebGUI/Macro/RawHeadTags.pm @@ -0,0 +1,27 @@ +package WebGUI::Macro::RawHeadTags; + +#------------------------------------------------------------------- +# WebGUI is Copyright 2001-2004 Plain Black LLC. +#------------------------------------------------------------------- +# 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::Macro; +use WebGUI::Session; +use WebGUI::Style; + +#------------------------------------------------------------------- +sub process { + my ($html) = WebGUI::Macro::getParams(shift); + WebGUI::Style::setRawHeadTags($html); + return ""; +} + +1; + + diff --git a/lib/WebGUI/Macro/StyleSheet.pm b/lib/WebGUI/Macro/StyleSheet.pm new file mode 100644 index 000000000..33776e8b3 --- /dev/null +++ b/lib/WebGUI/Macro/StyleSheet.pm @@ -0,0 +1,30 @@ +package WebGUI::Macro::StyleSheet; + +#------------------------------------------------------------------- +# WebGUI is Copyright 2001-2004 Plain Black LLC. +#------------------------------------------------------------------- +# 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::Macro; +use WebGUI::Session; +use WebGUI::Style; + +#------------------------------------------------------------------- +sub process { + my ($file) = WebGUI::Macro::getParams(shift); + WebGUI::Style::setLink($file,{ + type=>'text/css', + rel=>'stylesheet' + }); + return ""; +} + +1; + + diff --git a/lib/WebGUI/Style.pm b/lib/WebGUI/Style.pm index 462b0a4d2..9fd842a74 100644 --- a/lib/WebGUI/Style.pm +++ b/lib/WebGUI/Style.pm @@ -18,6 +18,7 @@ package WebGUI::Style; use strict; use Tie::CPHash; use WebGUI::International; +use WebGUI::Macro; use WebGUI::Session; use WebGUI::Template; use WebGUI::URL; @@ -36,6 +37,7 @@ This package contains utility methods for WebGUI's style system. $template = WebGUI::Style::getTemplate(); $html = WebGUI::Style::process($content); + $html = generateAdditionalHeadTags(); setLink($url,\%params); setMeta(\%params); setRawHeadTags($html); @@ -47,6 +49,44 @@ These subroutines are available from this package: =cut +#------------------------------------------------------------------- + +=head2 generateAdditionalHeadTags ( ) + +Creates tags that were set using setLink, setMeta, setScript, and setRawHeadTags. + +=cut + +sub generateAdditionalHeadTags { + # generate additional raw tags + my $tags = $session{page}{head}{raw}; + # generate additional link tags + foreach my $url (keys %{$session{page}{head}{link}}) { + $tags .= ' - '.$session{page}{head}{raw}.' '; - # generate additional link tags - foreach my $url (keys %{$session{page}{head}{link}}) { - $var{'head.tags'} .= '/$macroHeadTags/; + return $output; } diff --git a/lib/WebGUI/Wobject/DataForm.pm b/lib/WebGUI/Wobject/DataForm.pm index 96766ba96..31c059e1c 100644 --- a/lib/WebGUI/Wobject/DataForm.pm +++ b/lib/WebGUI/Wobject/DataForm.pm @@ -116,16 +116,30 @@ sub _createTabInit { #------------------------------------------------------------------- sub duplicate { - my ($w, %data, $sth); - tie %data, 'Tie::CPHash'; - $w = $_[0]->SUPER::duplicate($_[1]); - $w = WebGUI::Wobject::DataForm->new({wobjectId=>$w,namespace=>$_[0]->get("namespace")}); - $sth = WebGUI::SQL->read("select * from DataForm_field where wobjectId=".quote($_[0]->get("wobjectId"))); - while (%data = $sth->hash) { - $data{DataForm_fieldId} = "new"; - $w->setCollateral("DataForm_field","DataForm_fieldId",\%data); - } - $sth->finish; + my ($w, %dataField, %dataTab, $sthField, $sthTab, $newTabId); + tie %dataTab, 'Tie::CPHash'; + tie %dataField, 'Tie::CPHash'; + $w = $_[0]->SUPER::duplicate($_[1]); + $w = WebGUI::Wobject::DataForm->new({wobjectId=>$w,namespace=>$_[0]->get("namespace")}); + $sthTab = WebGUI::SQL->read("select * from DataForm_tab where wobjectId=".$_[0]->get("wobjectId")); + while (%dataTab = $sthTab->hash) { + $sthField = WebGUI::SQL->read("select * from DataForm_field where wobjectId=".$_[0]->get("wobjectId")." AND DataForm_tabId=".$dataTab{DataForm_tabId}); + $dataTab{DataForm_tabId} = "new"; + $newTabId = $w->setCollateral("DataForm_tab","DataForm_tabId",\%dataTab); + while (%dataField = $sthField->hash) { + $dataField{DataForm_fieldId} = "new"; + $dataField{DataForm_tabId} = $newTabId; + $w->setCollateral("DataForm_field","DataForm_fieldId",\%dataField); + } + $sthField->finish; + } + $sthField = WebGUI::SQL->read("select * from DataForm_field where wobjectId=".$_[0]->get("wobjectId")." AND DataForm_tabId=0"); + while (%dataField = $sthField->hash) { + $dataField{DataForm_fieldId} = "new"; + $w->setCollateral("DataForm_field","DataForm_fieldId",\%dataField); + } + $sthField->finish; + $sthTab->finish; } #------------------------------------------------------------------- diff --git a/lib/WebGUI/i18n/English/WebGUI.pm b/lib/WebGUI/i18n/English/WebGUI.pm index b9563fe59..5d01f16f0 100644 --- a/lib/WebGUI/i18n/English/WebGUI.pm +++ b/lib/WebGUI/i18n/English/WebGUI.pm @@ -169,6 +169,10 @@ The email address for your company specified in the settings by your Administrat Returns the path to the WebGUI "extras" folder, which contains things like WebGUI icons.

+^JavaScript();
+This macro allows you to set a javascript in the head section of the page. Just pass in the URL to the javascript file. +

+ ^LastModified; or ^LastModified();
Displays the date that the current page was last modified based upon the wobjects on the page. The date is defaultly displayed based upon the user's date preferences. Optionally, it can take two parameters. The first is text to display before the date. The second is a date format string (see the D (date) macro for details.

@@ -215,20 +219,27 @@ The translated label for the printable link, or the text that you supply to the Returns the title of the root of the current page. For instance, the main root in WebGUI is the "Home" page. Many advanced sites have many roots and thus need a way to display to the user which root they are in.

-^u; - Company URL
-The URL for your company specified in the settings by your Administrator. +^StyleSheet();
+This macro allows you to set a cascading style sheet in the head section of the page. Just pass in the URL to the CSS file.

- - ^Spacer();
Create a spacer in your layout. Great for creating blocks of color with divs and tables. It takes two parameters, width and height.

Example: ^Spacer("100","50");

+^RawHeadTags();
+This macro allows you to set some arbitrary tags in the head section of the page. Just pass in the text. +

+ +^u; - Company URL
+The URL for your company specified in the settings by your Administrator. +

+ + |, - lastUpdated => 1078243435 + lastUpdated => 1094053549 }, '634' => { diff --git a/www/extras/textFix.js b/www/extras/textFix.js new file mode 100644 index 000000000..e63eaaa0c --- /dev/null +++ b/www/extras/textFix.js @@ -0,0 +1,4 @@ +function fixChars(element) { + element.value = element.value.replace(/-/mg,"-"); +} +