diff --git a/docs/changelog/6.x.x.txt b/docs/changelog/6.x.x.txt index 7a59cd8cc..cb6c13173 100644 --- a/docs/changelog/6.x.x.txt +++ b/docs/changelog/6.x.x.txt @@ -36,6 +36,15 @@ - Rmoved the httpHeader, httpRedirect, and setCookie subs from WebGUI::Session and created a new class called WebGUI::HTTP for them. See docs/migration.txt for details. + - The USS automatically adds an RSS feed link tag to the head of any page + it's on. + - Added a new API for dynamically adding javascript, css, xml, rss, and meta + information to the page. See WebGUI::Style for details. + - Fixed a long standing annoyance that javascripts used by the WebGUI::Form + would be loaded multiple times if there were multiple fields of the same + type in the same form. + - Sped up the page editing page by 50% by rearranging the javascript on the + page. 6.0.3 diff --git a/lib/WebGUI/Form.pm b/lib/WebGUI/Form.pm index 3d818a33c..2172960eb 100644 --- a/lib/WebGUI/Form.pm +++ b/lib/WebGUI/Form.pm @@ -20,6 +20,7 @@ use WebGUI::DateTime; use WebGUI::International; use WebGUI::Session; use WebGUI::SQL; +use WebGUI::Style; use WebGUI::Template; use WebGUI::URL; @@ -74,10 +75,6 @@ All of the functions in this package accept the input of a hash reference contai =cut -#------------------------------------------------------------------- -sub _cssFile { - return ''."\n"; -} #------------------------------------------------------------------- sub _fixMacros { @@ -108,10 +105,6 @@ sub _fixTags { return $value; } -#------------------------------------------------------------------- -sub _javascriptFile { - return ''."\n"; -} #------------------------------------------------------------------- @@ -394,18 +387,17 @@ By default a date is placed in the "value" field. Set this to "1" to turn off th sub date { my $value = epochToSet($_[0]->{value}) unless ($_[0]->{noDate} && $_[0]->{value} eq ''); my $size = $_[0]->{size} || 10; - my $output = _cssFile("calendar/calendar-win2k-1.css") - ._javascriptFile('calendar/calendar.js') - ._javascriptFile('calendar/lang/calendar-en.js') - ._javascriptFile('calendar/calendar-setup.js'); - $output .= text({ + WebGUI::Style::setScript($session{config}{extrasURL}.'/calendar/calendar.js',{ language=>'javascript' }); + WebGUI::Style::setScript($session{config}{extrasURL}.'/calendar/lang/calendar-en.js',{ language=>'javascript' }); + WebGUI::Style::setScript($session{config}{extrasURL}.'/calendar/calendar-setup.js',{ language=>'javascript' }); + WebGUI::Style::setLink($session{config}{extrasURL}.'/calendar/calendar-win2k-1.css', { rel=>"stylesheet", type=>"text/css", media=>"all" }); + return text({ name=>$_[0]->{name}, value=>$value, size=>$size, extras=>'id="'.$_[0]->{name}.'Id" '.$_[0]->{extras}, maxlength=>10 - }); - $output .= ''; - return $output; } @@ -445,18 +436,17 @@ Extra parameters to add to the date/time form element such as javascript or styl sub dateTime { my $value = epochToSet($_[0]->{value},1); - my $output = _cssFile("calendar/calendar-win2k-1.css") - ._javascriptFile('calendar/calendar.js') - ._javascriptFile('calendar/lang/calendar-en.js') - ._javascriptFile('calendar/calendar-setup.js'); - $output .= text({ + WebGUI::Style::setScript($session{config}{extrasURL}.'/calendar/calendar.js',{ language=>'javascript' }); + WebGUI::Style::setScript($session{config}{extrasURL}.'/calendar/lang/calendar-en.js',{ language=>'javascript' }); + WebGUI::Style::setScript($session{config}{extrasURL}.'/calendar/calendar-setup.js',{ language=>'javascript' }); + WebGUI::Style::setLink($session{config}{extrasURL}.'/calendar/calendar-win2k-1.css', { rel=>"stylesheet", type=>"text/css", media=>"all" }); + return text({ name=>$_[0]->{name}, value=>$value, size=>19, extras=>'id="'.$_[0]->{name}.'Id" '.$_[0]->{extras}, maxlength=>19 - }); - $output .= ''; - return $output; } @@ -505,9 +494,8 @@ The number of characters wide this form element should be. There should be no re =cut sub email { - my ($output); - $output = _javascriptFile('emailCheck.js');; - $output .= text({ + WebGUI::Style::setScript($session{config}{extrasURL}.'/emailCheck.js',{ language=>'javascript' }); + my $output .= text({ name=>$_[0]->{name}, value=>$_[0]->{value}, size=>$_[0]->{size}, @@ -771,15 +759,14 @@ The number of characters wide this form element should be. There should be no re sub float { my $value = $_[0]->{value} || 0; my $size = $_[0]->{size} || 11; - my $output = _javascriptFile('inputCheck.js'); - $output .= text({ + WebGUI::Style::setScript($session{config}{extrasURL}.'/inputCheck.js',{ language=>'javascript' }); + return text({ name=>$_[0]->{name}, value=>$value, size=>$size, extras=>'onKeyUp="doInputCheck(this.form.'.$_[0]->{name}.',\'0123456789.\')" '.$_[0]->{extras}, maxlength=>$_[0]->{maxlength} }); - return $output; } @@ -1030,18 +1017,16 @@ The number of characters wide this form element should be. There should be no re =cut sub integer { - my ($output, $size, $value); - $value = $_[0]->{value} || 0; - $size = $_[0]->{size} || 11; - $output = _javascriptFile('inputCheck.js'); - $output .= text({ + my $value = $_[0]->{value} || 0; + my $size = $_[0]->{size} || 11; + WebGUI::Style::setScript($session{config}{extrasURL}.'/inputCheck.js',{ language=>'javascript' }); + return text({ name=>$_[0]->{name}, value=>$value, size=>$size, extras=>'onKeyUp="doInputCheck(this.form.'.$_[0]->{name}.',\'0123456789-\')" '.$_[0]->{extras}, maxlength=>$_[0]->{maxlength} }); - return $output; } #------------------------------------------------------------------- @@ -1178,16 +1163,15 @@ The number of characters wide this form element should be. There should be no re =cut sub phone { - my $output = _javascriptFile('inputCheck.js'); + WebGUI::Style::setScript($session{config}{extrasURL}.'/inputCheck.js',{ language=>'javascript' }); my $maxLength = $_[0]->{maxLength} || 30; - $output .= text({ + return text({ name=>$_[0]->{name}, maxlength=>$maxLength, extras=>'onKeyUp="doInputCheck(this.form.'.$_[0]->{name}.',\'0123456789-()+ \')" '.$_[0]->{extras}, value=>$_[0]->{value}, size=>$_[0]->{size} }); - return $output; } #------------------------------------------------------------------- @@ -1540,8 +1524,8 @@ The number of characters wide this form element should be. There should be no re sub timeField { my $value = WebGUI::DateTime::secondsToTime($_[0]->{value}); - my $output = _javascriptFile('inputCheck.js'); - $output .= text({ + WebGUI::Style::setScript($session{config}{extrasURL}.'/inputCheck.js',{ language=>'javascript' }); + my $output = text({ name=>$_[0]->{name}, value=>$value, size=>$_[0]->{size} || 8, @@ -1591,15 +1575,14 @@ The number of characters wide this form element should be. There should be no re sub url { my $maxLength = $_[0]->{maxlength} || 2048; - my $output = _javascriptFile('addHTTP.js'); - $output .= text({ + WebGUI::Style::setScript($session{config}{extrasURL}.'/addHTTP.js',{ language=>'javascript' }); + return text({ name=>$_[0]->{name}, value=>$_[0]->{value}, extras=>$_[0]->{extras}.' onBlur="addHTTP(this.form.'.$_[0]->{name}.')"', size=>$_[0]->{size}, maxlength=>$maxLength }); - return $output; } #------------------------------------------------------------------- @@ -1730,16 +1713,15 @@ The number of characters wide this form element should be. There should be no re =cut sub zipcode { - my $output = _javascriptFile('inputCheck.js'); + WebGUI::Style::setScript($session{config}{extrasURL}.'/inputCheck.js',{ language=>'javascript' }); my $maxLength = $_[0]->{maxLength} || 10; - $output .= text({ + return text({ name=>$_[0]->{name}, maxlength=>$maxLength, extras=>'onKeyUp="doInputCheck(this.form.'.$_[0]->{name}.',\'0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ- \')" '.$_[0]->{extras}, value=>$_[0]->{value}, size=>$_[0]->{size} }); - return $output; } diff --git a/lib/WebGUI/Page.pm b/lib/WebGUI/Page.pm index cd1aa0395..e1ee3c191 100644 --- a/lib/WebGUI/Page.pm +++ b/lib/WebGUI/Page.pm @@ -18,6 +18,7 @@ use warnings; use HTML::Template; use strict; use Tie::IxHash; +use WebGUI::DateTime; use WebGUI::ErrorHandler; use WebGUI::Grouping; use WebGUI::HTMLForm; @@ -27,9 +28,9 @@ use WebGUI::Macro; use WebGUI::Persistent::Tree; use WebGUI::Session; use WebGUI::SQL; +use WebGUI::Style; use WebGUI::Template; use WebGUI::Utility; -use WebGUI::DateTime; our @ISA = qw(WebGUI::Persistent::Tree); @@ -388,6 +389,11 @@ Generates the content of the page. sub generate { return WebGUI::Privilege::noAccess() unless (canView()); my %var; + if ($session{page}{defaultMetaTags}) { + WebGUI::Style::setMeta({'http-equiv'=>"Keywords", name=>"Keywords", content=>join(",",$session{page}{title},$session{page}{menuTitle})}); + WebGUI::Style::setMeta({'http-equiv'=>"Description", name=>"Description", content=>$session{page}{synopsis}}) if ($session{page}{synopsis}); + } + WebGUI::Style::setRawHeadTags($session{page}{metaTags}); if ($session{page}{redirectURL} && !$session{var}{adminOn}) { WebGUI::HTTP::setRedirect(WebGUI::Macro::process($session{page}{redirectURL})); } diff --git a/lib/WebGUI/Style.pm b/lib/WebGUI/Style.pm index 01a17a942..5fa30d8b3 100644 --- a/lib/WebGUI/Style.pm +++ b/lib/WebGUI/Style.pm @@ -125,10 +125,10 @@ sub process { $var{'head.tags'} .= ' />'."\n"; } # generate additional javascript tags - foreach my $url (keys %{$session{page}{head}{javascript}}) { - $var{'head.tags'} .= '