head tag improvements
This commit is contained in:
parent
f18f408efb
commit
eab5fc8f15
5 changed files with 156 additions and 65 deletions
|
|
@ -36,6 +36,15 @@
|
||||||
- Rmoved the httpHeader, httpRedirect, and setCookie subs from
|
- Rmoved the httpHeader, httpRedirect, and setCookie subs from
|
||||||
WebGUI::Session and created a new class called WebGUI::HTTP for them. See
|
WebGUI::Session and created a new class called WebGUI::HTTP for them. See
|
||||||
docs/migration.txt for details.
|
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
|
6.0.3
|
||||||
|
|
|
||||||
|
|
@ -20,6 +20,7 @@ use WebGUI::DateTime;
|
||||||
use WebGUI::International;
|
use WebGUI::International;
|
||||||
use WebGUI::Session;
|
use WebGUI::Session;
|
||||||
use WebGUI::SQL;
|
use WebGUI::SQL;
|
||||||
|
use WebGUI::Style;
|
||||||
use WebGUI::Template;
|
use WebGUI::Template;
|
||||||
use WebGUI::URL;
|
use WebGUI::URL;
|
||||||
|
|
||||||
|
|
@ -74,10 +75,6 @@ All of the functions in this package accept the input of a hash reference contai
|
||||||
|
|
||||||
=cut
|
=cut
|
||||||
|
|
||||||
#-------------------------------------------------------------------
|
|
||||||
sub _cssFile {
|
|
||||||
return '<link rel="stylesheet" type="text/css" media="all" href="'.$session{config}{extrasURL}.'/'.$_[0].'" />'."\n";
|
|
||||||
}
|
|
||||||
|
|
||||||
#-------------------------------------------------------------------
|
#-------------------------------------------------------------------
|
||||||
sub _fixMacros {
|
sub _fixMacros {
|
||||||
|
|
@ -108,10 +105,6 @@ sub _fixTags {
|
||||||
return $value;
|
return $value;
|
||||||
}
|
}
|
||||||
|
|
||||||
#-------------------------------------------------------------------
|
|
||||||
sub _javascriptFile {
|
|
||||||
return '<script language="JavaScript" src="'.$session{config}{extrasURL}.'/'.$_[0].'"></script>'."\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 {
|
sub date {
|
||||||
my $value = epochToSet($_[0]->{value}) unless ($_[0]->{noDate} && $_[0]->{value} eq '');
|
my $value = epochToSet($_[0]->{value}) unless ($_[0]->{noDate} && $_[0]->{value} eq '');
|
||||||
my $size = $_[0]->{size} || 10;
|
my $size = $_[0]->{size} || 10;
|
||||||
my $output = _cssFile("calendar/calendar-win2k-1.css")
|
WebGUI::Style::setScript($session{config}{extrasURL}.'/calendar/calendar.js',{ language=>'javascript' });
|
||||||
._javascriptFile('calendar/calendar.js')
|
WebGUI::Style::setScript($session{config}{extrasURL}.'/calendar/lang/calendar-en.js',{ language=>'javascript' });
|
||||||
._javascriptFile('calendar/lang/calendar-en.js')
|
WebGUI::Style::setScript($session{config}{extrasURL}.'/calendar/calendar-setup.js',{ language=>'javascript' });
|
||||||
._javascriptFile('calendar/calendar-setup.js');
|
WebGUI::Style::setLink($session{config}{extrasURL}.'/calendar/calendar-win2k-1.css', { rel=>"stylesheet", type=>"text/css", media=>"all" });
|
||||||
$output .= text({
|
return text({
|
||||||
name=>$_[0]->{name},
|
name=>$_[0]->{name},
|
||||||
value=>$value,
|
value=>$value,
|
||||||
size=>$size,
|
size=>$size,
|
||||||
extras=>'id="'.$_[0]->{name}.'Id" '.$_[0]->{extras},
|
extras=>'id="'.$_[0]->{name}.'Id" '.$_[0]->{extras},
|
||||||
maxlength=>10
|
maxlength=>10
|
||||||
});
|
}) . '<script type="text/javascript">
|
||||||
$output .= '<script type="text/javascript">
|
|
||||||
Calendar.setup({
|
Calendar.setup({
|
||||||
inputField : "'.$_[0]->{name}.'Id",
|
inputField : "'.$_[0]->{name}.'Id",
|
||||||
ifFormat : "%Y-%m-%d",
|
ifFormat : "%Y-%m-%d",
|
||||||
|
|
@ -414,7 +406,6 @@ sub date {
|
||||||
mondayFirst : false
|
mondayFirst : false
|
||||||
});
|
});
|
||||||
</script>';
|
</script>';
|
||||||
return $output;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -445,18 +436,17 @@ Extra parameters to add to the date/time form element such as javascript or styl
|
||||||
|
|
||||||
sub dateTime {
|
sub dateTime {
|
||||||
my $value = epochToSet($_[0]->{value},1);
|
my $value = epochToSet($_[0]->{value},1);
|
||||||
my $output = _cssFile("calendar/calendar-win2k-1.css")
|
WebGUI::Style::setScript($session{config}{extrasURL}.'/calendar/calendar.js',{ language=>'javascript' });
|
||||||
._javascriptFile('calendar/calendar.js')
|
WebGUI::Style::setScript($session{config}{extrasURL}.'/calendar/lang/calendar-en.js',{ language=>'javascript' });
|
||||||
._javascriptFile('calendar/lang/calendar-en.js')
|
WebGUI::Style::setScript($session{config}{extrasURL}.'/calendar/calendar-setup.js',{ language=>'javascript' });
|
||||||
._javascriptFile('calendar/calendar-setup.js');
|
WebGUI::Style::setLink($session{config}{extrasURL}.'/calendar/calendar-win2k-1.css', { rel=>"stylesheet", type=>"text/css", media=>"all" });
|
||||||
$output .= text({
|
return text({
|
||||||
name=>$_[0]->{name},
|
name=>$_[0]->{name},
|
||||||
value=>$value,
|
value=>$value,
|
||||||
size=>19,
|
size=>19,
|
||||||
extras=>'id="'.$_[0]->{name}.'Id" '.$_[0]->{extras},
|
extras=>'id="'.$_[0]->{name}.'Id" '.$_[0]->{extras},
|
||||||
maxlength=>19
|
maxlength=>19
|
||||||
});
|
}) . '<script type="text/javascript">
|
||||||
$output .= '<script type="text/javascript">
|
|
||||||
Calendar.setup({
|
Calendar.setup({
|
||||||
inputField : "'.$_[0]->{name}.'Id",
|
inputField : "'.$_[0]->{name}.'Id",
|
||||||
ifFormat : "%Y-%m-%d %H:%M:%S",
|
ifFormat : "%Y-%m-%d %H:%M:%S",
|
||||||
|
|
@ -465,7 +455,6 @@ sub dateTime {
|
||||||
mondayFirst : false
|
mondayFirst : false
|
||||||
});
|
});
|
||||||
</script>';
|
</script>';
|
||||||
return $output;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -505,9 +494,8 @@ The number of characters wide this form element should be. There should be no re
|
||||||
=cut
|
=cut
|
||||||
|
|
||||||
sub email {
|
sub email {
|
||||||
my ($output);
|
WebGUI::Style::setScript($session{config}{extrasURL}.'/emailCheck.js',{ language=>'javascript' });
|
||||||
$output = _javascriptFile('emailCheck.js');;
|
my $output .= text({
|
||||||
$output .= text({
|
|
||||||
name=>$_[0]->{name},
|
name=>$_[0]->{name},
|
||||||
value=>$_[0]->{value},
|
value=>$_[0]->{value},
|
||||||
size=>$_[0]->{size},
|
size=>$_[0]->{size},
|
||||||
|
|
@ -771,15 +759,14 @@ The number of characters wide this form element should be. There should be no re
|
||||||
sub float {
|
sub float {
|
||||||
my $value = $_[0]->{value} || 0;
|
my $value = $_[0]->{value} || 0;
|
||||||
my $size = $_[0]->{size} || 11;
|
my $size = $_[0]->{size} || 11;
|
||||||
my $output = _javascriptFile('inputCheck.js');
|
WebGUI::Style::setScript($session{config}{extrasURL}.'/inputCheck.js',{ language=>'javascript' });
|
||||||
$output .= text({
|
return text({
|
||||||
name=>$_[0]->{name},
|
name=>$_[0]->{name},
|
||||||
value=>$value,
|
value=>$value,
|
||||||
size=>$size,
|
size=>$size,
|
||||||
extras=>'onKeyUp="doInputCheck(this.form.'.$_[0]->{name}.',\'0123456789.\')" '.$_[0]->{extras},
|
extras=>'onKeyUp="doInputCheck(this.form.'.$_[0]->{name}.',\'0123456789.\')" '.$_[0]->{extras},
|
||||||
maxlength=>$_[0]->{maxlength}
|
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
|
=cut
|
||||||
|
|
||||||
sub integer {
|
sub integer {
|
||||||
my ($output, $size, $value);
|
my $value = $_[0]->{value} || 0;
|
||||||
$value = $_[0]->{value} || 0;
|
my $size = $_[0]->{size} || 11;
|
||||||
$size = $_[0]->{size} || 11;
|
WebGUI::Style::setScript($session{config}{extrasURL}.'/inputCheck.js',{ language=>'javascript' });
|
||||||
$output = _javascriptFile('inputCheck.js');
|
return text({
|
||||||
$output .= text({
|
|
||||||
name=>$_[0]->{name},
|
name=>$_[0]->{name},
|
||||||
value=>$value,
|
value=>$value,
|
||||||
size=>$size,
|
size=>$size,
|
||||||
extras=>'onKeyUp="doInputCheck(this.form.'.$_[0]->{name}.',\'0123456789-\')" '.$_[0]->{extras},
|
extras=>'onKeyUp="doInputCheck(this.form.'.$_[0]->{name}.',\'0123456789-\')" '.$_[0]->{extras},
|
||||||
maxlength=>$_[0]->{maxlength}
|
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
|
=cut
|
||||||
|
|
||||||
sub phone {
|
sub phone {
|
||||||
my $output = _javascriptFile('inputCheck.js');
|
WebGUI::Style::setScript($session{config}{extrasURL}.'/inputCheck.js',{ language=>'javascript' });
|
||||||
my $maxLength = $_[0]->{maxLength} || 30;
|
my $maxLength = $_[0]->{maxLength} || 30;
|
||||||
$output .= text({
|
return text({
|
||||||
name=>$_[0]->{name},
|
name=>$_[0]->{name},
|
||||||
maxlength=>$maxLength,
|
maxlength=>$maxLength,
|
||||||
extras=>'onKeyUp="doInputCheck(this.form.'.$_[0]->{name}.',\'0123456789-()+ \')" '.$_[0]->{extras},
|
extras=>'onKeyUp="doInputCheck(this.form.'.$_[0]->{name}.',\'0123456789-()+ \')" '.$_[0]->{extras},
|
||||||
value=>$_[0]->{value},
|
value=>$_[0]->{value},
|
||||||
size=>$_[0]->{size}
|
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 {
|
sub timeField {
|
||||||
my $value = WebGUI::DateTime::secondsToTime($_[0]->{value});
|
my $value = WebGUI::DateTime::secondsToTime($_[0]->{value});
|
||||||
my $output = _javascriptFile('inputCheck.js');
|
WebGUI::Style::setScript($session{config}{extrasURL}.'/inputCheck.js',{ language=>'javascript' });
|
||||||
$output .= text({
|
my $output = text({
|
||||||
name=>$_[0]->{name},
|
name=>$_[0]->{name},
|
||||||
value=>$value,
|
value=>$value,
|
||||||
size=>$_[0]->{size} || 8,
|
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 {
|
sub url {
|
||||||
my $maxLength = $_[0]->{maxlength} || 2048;
|
my $maxLength = $_[0]->{maxlength} || 2048;
|
||||||
my $output = _javascriptFile('addHTTP.js');
|
WebGUI::Style::setScript($session{config}{extrasURL}.'/addHTTP.js',{ language=>'javascript' });
|
||||||
$output .= text({
|
return text({
|
||||||
name=>$_[0]->{name},
|
name=>$_[0]->{name},
|
||||||
value=>$_[0]->{value},
|
value=>$_[0]->{value},
|
||||||
extras=>$_[0]->{extras}.' onBlur="addHTTP(this.form.'.$_[0]->{name}.')"',
|
extras=>$_[0]->{extras}.' onBlur="addHTTP(this.form.'.$_[0]->{name}.')"',
|
||||||
size=>$_[0]->{size},
|
size=>$_[0]->{size},
|
||||||
maxlength=>$maxLength
|
maxlength=>$maxLength
|
||||||
});
|
});
|
||||||
return $output;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#-------------------------------------------------------------------
|
#-------------------------------------------------------------------
|
||||||
|
|
@ -1730,16 +1713,15 @@ The number of characters wide this form element should be. There should be no re
|
||||||
=cut
|
=cut
|
||||||
|
|
||||||
sub zipcode {
|
sub zipcode {
|
||||||
my $output = _javascriptFile('inputCheck.js');
|
WebGUI::Style::setScript($session{config}{extrasURL}.'/inputCheck.js',{ language=>'javascript' });
|
||||||
my $maxLength = $_[0]->{maxLength} || 10;
|
my $maxLength = $_[0]->{maxLength} || 10;
|
||||||
$output .= text({
|
return text({
|
||||||
name=>$_[0]->{name},
|
name=>$_[0]->{name},
|
||||||
maxlength=>$maxLength,
|
maxlength=>$maxLength,
|
||||||
extras=>'onKeyUp="doInputCheck(this.form.'.$_[0]->{name}.',\'0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ- \')" '.$_[0]->{extras},
|
extras=>'onKeyUp="doInputCheck(this.form.'.$_[0]->{name}.',\'0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ- \')" '.$_[0]->{extras},
|
||||||
value=>$_[0]->{value},
|
value=>$_[0]->{value},
|
||||||
size=>$_[0]->{size}
|
size=>$_[0]->{size}
|
||||||
});
|
});
|
||||||
return $output;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,7 @@ use warnings;
|
||||||
use HTML::Template;
|
use HTML::Template;
|
||||||
use strict;
|
use strict;
|
||||||
use Tie::IxHash;
|
use Tie::IxHash;
|
||||||
|
use WebGUI::DateTime;
|
||||||
use WebGUI::ErrorHandler;
|
use WebGUI::ErrorHandler;
|
||||||
use WebGUI::Grouping;
|
use WebGUI::Grouping;
|
||||||
use WebGUI::HTMLForm;
|
use WebGUI::HTMLForm;
|
||||||
|
|
@ -27,9 +28,9 @@ use WebGUI::Macro;
|
||||||
use WebGUI::Persistent::Tree;
|
use WebGUI::Persistent::Tree;
|
||||||
use WebGUI::Session;
|
use WebGUI::Session;
|
||||||
use WebGUI::SQL;
|
use WebGUI::SQL;
|
||||||
|
use WebGUI::Style;
|
||||||
use WebGUI::Template;
|
use WebGUI::Template;
|
||||||
use WebGUI::Utility;
|
use WebGUI::Utility;
|
||||||
use WebGUI::DateTime;
|
|
||||||
|
|
||||||
our @ISA = qw(WebGUI::Persistent::Tree);
|
our @ISA = qw(WebGUI::Persistent::Tree);
|
||||||
|
|
||||||
|
|
@ -388,6 +389,11 @@ Generates the content of the page.
|
||||||
sub generate {
|
sub generate {
|
||||||
return WebGUI::Privilege::noAccess() unless (canView());
|
return WebGUI::Privilege::noAccess() unless (canView());
|
||||||
my %var;
|
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}) {
|
if ($session{page}{redirectURL} && !$session{var}{adminOn}) {
|
||||||
WebGUI::HTTP::setRedirect(WebGUI::Macro::process($session{page}{redirectURL}));
|
WebGUI::HTTP::setRedirect(WebGUI::Macro::process($session{page}{redirectURL}));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -125,10 +125,10 @@ sub process {
|
||||||
$var{'head.tags'} .= ' />'."\n";
|
$var{'head.tags'} .= ' />'."\n";
|
||||||
}
|
}
|
||||||
# generate additional javascript tags
|
# generate additional javascript tags
|
||||||
foreach my $url (keys %{$session{page}{head}{javascript}}) {
|
foreach my $tag (@{$session{page}{head}{javascript}}) {
|
||||||
$var{'head.tags'} .= '<script src="'.$url.'"';
|
$var{'head.tags'} .= '<script';
|
||||||
foreach my $name (keys %{$session{page}{head}{javascript}{$url}}) {
|
foreach my $name (keys %{$tag}) {
|
||||||
$var{'head.tags'} .= ' '.$name.'="'.$session{page}{head}{javascript}{$url}{$name}.'"';
|
$var{'head.tags'} .= ' '.$name.'="'.$tag->{$name}.'"';
|
||||||
}
|
}
|
||||||
$var{'head.tags'} .= '></script>'."\n";
|
$var{'head.tags'} .= '></script>'."\n";
|
||||||
}
|
}
|
||||||
|
|
@ -140,7 +140,6 @@ sub process {
|
||||||
}
|
}
|
||||||
$var{'head.tags'} .= ' />'."\n";
|
$var{'head.tags'} .= ' />'."\n";
|
||||||
}
|
}
|
||||||
$var{'head.tags'} .= $session{page}{metaTags};
|
|
||||||
if ($session{var}{adminOn}) {
|
if ($session{var}{adminOn}) {
|
||||||
# This "triple incantation" panders to the delicate tastes of various browsers for reliable cache suppression.
|
# This "triple incantation" panders to the delicate tastes of various browsers for reliable cache suppression.
|
||||||
$var{'head.tags'} .= '
|
$var{'head.tags'} .= '
|
||||||
|
|
@ -149,20 +148,113 @@ sub process {
|
||||||
<meta http-equiv="Expires" content="0" />
|
<meta http-equiv="Expires" content="0" />
|
||||||
';
|
';
|
||||||
}
|
}
|
||||||
if ($session{page}{defaultMetaTags}) {
|
|
||||||
$var{'head.tags'} .= '
|
|
||||||
<meta http-equiv="Keywords" name="Keywords" content="'.$session{page}{title}.', '.$session{setting}{companyName}.'" />
|
|
||||||
';
|
|
||||||
if ($session{page}{synopsis}) {
|
|
||||||
$var{'head.tags'} .= '
|
|
||||||
<meta http-equiv="Description" name="Description" content="'.$session{page}{synopsis}.'" />
|
|
||||||
';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return WebGUI::Template::process($templateId,"style",\%var);
|
return WebGUI::Template::process($templateId,"style",\%var);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#-------------------------------------------------------------------
|
||||||
|
|
||||||
|
=head2 setLink ( url, params )
|
||||||
|
|
||||||
|
Sets a <link> tag into the <head> of this rendered page for this page view. This is typically used for dynamically adding references to CSS and RSS documents.
|
||||||
|
|
||||||
|
=over
|
||||||
|
|
||||||
|
=item url
|
||||||
|
|
||||||
|
The URL to the document you are linking.
|
||||||
|
|
||||||
|
=item params
|
||||||
|
|
||||||
|
A hash reference containing the other parameters to be included in the link tag, such as "rel" and "type".
|
||||||
|
|
||||||
|
=back
|
||||||
|
|
||||||
|
=cut
|
||||||
|
|
||||||
|
sub setLink {
|
||||||
|
my $url = shift;
|
||||||
|
my $params = shift;
|
||||||
|
$session{page}{head}{link}{$url} = $params;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#-------------------------------------------------------------------
|
||||||
|
|
||||||
|
=head2 setMeta ( params )
|
||||||
|
|
||||||
|
Sets a <meta> tag into the <head> of this rendered page for this page view.
|
||||||
|
|
||||||
|
=over
|
||||||
|
|
||||||
|
=item params
|
||||||
|
|
||||||
|
A hash reference containing the parameters of the meta tag.
|
||||||
|
|
||||||
|
=back
|
||||||
|
|
||||||
|
=cut
|
||||||
|
|
||||||
|
sub setMeta {
|
||||||
|
my $params = shift;
|
||||||
|
push(@{$session{page}{head}{meta}},$params);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#-------------------------------------------------------------------
|
||||||
|
|
||||||
|
=head2 setRawHeadTags ( tags )
|
||||||
|
|
||||||
|
Sets data to be output into the <head> of the current rendered page for this page view.
|
||||||
|
|
||||||
|
=over
|
||||||
|
|
||||||
|
=item tags
|
||||||
|
|
||||||
|
A raw string containing tags. This is just a raw string so you must actually pass in the full tag to use this call.
|
||||||
|
|
||||||
|
=back
|
||||||
|
|
||||||
|
=cut
|
||||||
|
|
||||||
|
sub setRawHeadTags {
|
||||||
|
my $tags = shift;
|
||||||
|
$session{page}{head}{raw} .= $tags;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#-------------------------------------------------------------------
|
||||||
|
|
||||||
|
=head2 setScript ( url, params )
|
||||||
|
|
||||||
|
Sets a <script> tag into the <head> of this rendered page for this page view. This is typically used for dynamically adding references to Javascript or ECMA script.
|
||||||
|
|
||||||
|
=over
|
||||||
|
|
||||||
|
=item url
|
||||||
|
|
||||||
|
The URL to your script.
|
||||||
|
|
||||||
|
=item params
|
||||||
|
|
||||||
|
A hash reference containing the additional parameters to include in the script tag, such as "type" and "language".
|
||||||
|
|
||||||
|
=back
|
||||||
|
|
||||||
|
=cut
|
||||||
|
|
||||||
|
sub setScript {
|
||||||
|
my $url = shift;
|
||||||
|
my $params = shift;
|
||||||
|
$params->{src} = $url;
|
||||||
|
my $found = 0;
|
||||||
|
foreach my $script (@{$session{page}{head}{javascript}}) {
|
||||||
|
$found = 1 if ($script->{src} eq $url);
|
||||||
|
}
|
||||||
|
push(@{$session{page}{head}{javascript}},$params) unless ($found);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
1;
|
1;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -27,8 +27,9 @@ use WebGUI::Operation;
|
||||||
use WebGUI::Paginator;
|
use WebGUI::Paginator;
|
||||||
use WebGUI::Privilege;
|
use WebGUI::Privilege;
|
||||||
use WebGUI::Session;
|
use WebGUI::Session;
|
||||||
use WebGUI::Template;
|
|
||||||
use WebGUI::SQL;
|
use WebGUI::SQL;
|
||||||
|
use WebGUI::Style;
|
||||||
|
use WebGUI::Template;
|
||||||
use WebGUI::URL;
|
use WebGUI::URL;
|
||||||
use WebGUI::User;
|
use WebGUI::User;
|
||||||
use WebGUI::Utility;
|
use WebGUI::Utility;
|
||||||
|
|
@ -657,6 +658,7 @@ sub www_view {
|
||||||
$var{"search.Form"} = WebGUI::Search::form({wid=>$_[0]->get("wobjectId"),func=>'view',search=>1});
|
$var{"search.Form"} = WebGUI::Search::form({wid=>$_[0]->get("wobjectId"),func=>'view',search=>1});
|
||||||
$var{"search.url"} = WebGUI::Search::toggleURL("wid=".$_[0]->get("wobjectId")."&func=view");
|
$var{"search.url"} = WebGUI::Search::toggleURL("wid=".$_[0]->get("wobjectId")."&func=view");
|
||||||
$var{"rss.url"} = WebGUI::URL::page('func=viewRSS&wid='.$_[0]->get("wobjectId"));
|
$var{"rss.url"} = WebGUI::URL::page('func=viewRSS&wid='.$_[0]->get("wobjectId"));
|
||||||
|
WebGUI::Style::setLink($var{"rss.url"},{ rel=>'alternate', type=>'application/rss+xml', title=>'RSS' });
|
||||||
if ($session{scratch}{search}) {
|
if ($session{scratch}{search}) {
|
||||||
$numResults = $session{scratch}{numResults};
|
$numResults = $session{scratch}{numResults};
|
||||||
$constraints = WebGUI::Search::buildConstraints([qw(username title content)]);
|
$constraints = WebGUI::Search::buildConstraints([qw(username title content)]);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue