merge to 10219
This commit is contained in:
parent
ae28bf79c8
commit
4c1307e3d0
194 changed files with 8203 additions and 2134 deletions
190
lib/WebGUI/Form/AdSpace.pm
Normal file
190
lib/WebGUI/Form/AdSpace.pm
Normal file
|
|
@ -0,0 +1,190 @@
|
|||
package WebGUI::Form::AdSpace;
|
||||
|
||||
=head1 LEGAL
|
||||
|
||||
-------------------------------------------------------------------
|
||||
WebGUI is Copyright 2001-2009 Plain Black Corporation.
|
||||
-------------------------------------------------------------------
|
||||
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
|
||||
-------------------------------------------------------------------
|
||||
|
||||
=cut
|
||||
|
||||
use strict;
|
||||
use base 'WebGUI::Form::SelectList';
|
||||
use WebGUI::International;
|
||||
use WebGUI::SQL;
|
||||
|
||||
=head1 NAME
|
||||
|
||||
Package WebGUI::Form::AdSpace
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
Creates a group chooser field for AdSpace values.
|
||||
|
||||
=head1 SEE ALSO
|
||||
|
||||
This is a subclass of WebGUI::Form::SelectList.
|
||||
|
||||
=head1 METHODS
|
||||
|
||||
The following methods are specifically available from this class. Check the superclass for additional methods.
|
||||
|
||||
=cut
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 areOptionsSettable ( )
|
||||
|
||||
Returns 0.
|
||||
|
||||
=cut
|
||||
|
||||
sub areOptionsSettable {
|
||||
return 0;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 definition ( [ additionalTerms ] )
|
||||
|
||||
See the super class for additional details.
|
||||
|
||||
=head3 additionalTerms
|
||||
|
||||
The following additional parameters have been added via this sub class.
|
||||
|
||||
=head4 size
|
||||
|
||||
How many rows should be displayed at once? Defaults to 1.
|
||||
|
||||
=head4 defaultValue
|
||||
|
||||
This will be used if no value is specified. Should be passed as an array reference. Defaults to 1.
|
||||
|
||||
=cut
|
||||
|
||||
sub definition {
|
||||
my $class = shift;
|
||||
my $session = shift;
|
||||
my $definition = shift || [];
|
||||
push(@{$definition}, {
|
||||
size=>{
|
||||
defaultValue=>1
|
||||
},
|
||||
});
|
||||
return $class->SUPER::definition($session, $definition);
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getDatabaseFieldType ( )
|
||||
|
||||
Returns "CHAR(22) BINARY".
|
||||
|
||||
=cut
|
||||
|
||||
sub getDatabaseFieldType {
|
||||
return "CHAR(22) BINARY";
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getName ( session )
|
||||
|
||||
Returns the human readable name of this control.
|
||||
|
||||
=cut
|
||||
|
||||
sub getName {
|
||||
my ($self, $session) = @_;
|
||||
return WebGUI::International->new($session, 'WebGUI')->get('Ad Space control name');
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getValueAsHtml ( )
|
||||
|
||||
Formats as a name.
|
||||
|
||||
=cut
|
||||
|
||||
sub getValueAsHtml {
|
||||
my $self = shift;
|
||||
my $item = WebGUI::AdSpace->new($self->session, $self->getOriginalValue);
|
||||
if (defined $item) {
|
||||
return $item->name;
|
||||
}
|
||||
return undef;
|
||||
}
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 isDynamicCompatible ( )
|
||||
|
||||
A class method that returns a boolean indicating whether this control is compatible with the DynamicField control.
|
||||
|
||||
=cut
|
||||
|
||||
sub isDynamicCompatible {
|
||||
return 1;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 toHtml ( )
|
||||
|
||||
Returns a group pull-down field. A group pull down provides a select list that provides name value pairs for all the groups in the WebGUI system.
|
||||
|
||||
=cut
|
||||
|
||||
sub toHtml {
|
||||
my $self = shift;
|
||||
my $options = { map { $_->getId => $_->get('name') } ( @{ WebGUI::AdSpace->getAdSpaces($self->session) } ) };
|
||||
$self->set('defaultValue', ( keys %{$options} )[0] );
|
||||
$self->set('options', $options );
|
||||
return $self->SUPER::toHtml();
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 toHtmlAsHidden ( )
|
||||
|
||||
Creates a series of hidden fields representing the data in the list.
|
||||
|
||||
=cut
|
||||
|
||||
sub toHtmlAsHidden {
|
||||
my $self = shift;
|
||||
my $options = { map { $_->getId => $_->get('name') } ( @{ WebGUI::AdSpace->getAdSpaces($self->session) } ) };
|
||||
$self->set('defaultValue', ( keys %{$options} )[0] );
|
||||
$self->set('options', $options );
|
||||
return $self->SUPER::toHtmlAsHidden();
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 toHtmlWithWrapper ( )
|
||||
|
||||
Renders the form field to HTML as a table row complete with labels, subtext, hoverhelp, etc. Also adds a manage icon next to the field if the current user is in the admins group.
|
||||
|
||||
=cut
|
||||
|
||||
sub toHtmlWithWrapper {
|
||||
my $self = shift;
|
||||
if ($self->session->user->isAdmin) {
|
||||
my $subtext = $self->session->icon->manage("op=manageAdSpaces");
|
||||
$self->set("subtext",$subtext . $self->get("subtext"));
|
||||
}
|
||||
return $self->SUPER::toHtmlWithWrapper;
|
||||
}
|
||||
|
||||
|
||||
1;
|
||||
|
||||
|
|
@ -182,6 +182,12 @@ sub toHtml {
|
|||
return $self->SUPER::toHtml.'<p style="display:inline;vertical-align:middle;"><img src="'.$storage->getUrl($filename).'" style="border-style:none;vertical-align:middle;" alt="captcha" /></p>';
|
||||
}
|
||||
|
||||
=head2 getErrorMessage ( )
|
||||
|
||||
Returns an internationalized error message based on which kind of captcha is being used.
|
||||
|
||||
=cut
|
||||
|
||||
sub getErrorMessage {
|
||||
my $self = shift;
|
||||
my $session = $self->session;
|
||||
|
|
|
|||
|
|
@ -137,7 +137,7 @@ sub toHtml {
|
|||
my $output = "";
|
||||
|
||||
# Do our superclass's job
|
||||
my $value = $self->fixMacros($self->fixTags($self->fixSpecialCharacters($self->getOriginalValue)));
|
||||
my $value = $self->fixMacros($self->fixTags($self->fixSpecialCharacters(scalar $self->getOriginalValue)));
|
||||
my $width = $self->get('width') || 400;
|
||||
my $height = $self->get('height') || 150;
|
||||
my ($style, $url) = $self->session->quick(qw(style url));
|
||||
|
|
|
|||
|
|
@ -196,6 +196,9 @@ sub definition {
|
|||
idPrefix=>{
|
||||
defaultValue=>undef
|
||||
},
|
||||
allowEmpty=>{
|
||||
defaultValue => 0,
|
||||
},
|
||||
});
|
||||
return $definition;
|
||||
}
|
||||
|
|
@ -686,7 +689,7 @@ Renders the form field to HTML as a hidden field rather than whatever field type
|
|||
sub toHtmlAsHidden {
|
||||
my $self = shift;
|
||||
return '<input type="hidden" name="'.$self->get("name").'" value="'.
|
||||
$self->fixQuotes($self->fixMacros($self->fixSpecialCharacters($self->getOriginalValue()))).'" />'."\n";
|
||||
$self->fixQuotes($self->fixMacros($self->fixSpecialCharacters(scalar $self->getOriginalValue()))).'" />'."\n";
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
|
|
|||
173
lib/WebGUI/Form/Keywords.pm
Normal file
173
lib/WebGUI/Form/Keywords.pm
Normal file
|
|
@ -0,0 +1,173 @@
|
|||
package WebGUI::Form::Keywords;
|
||||
|
||||
=head1 LEGAL
|
||||
|
||||
-------------------------------------------------------------------
|
||||
WebGUI is Copyright 2001-2009 Plain Black Corporation.
|
||||
-------------------------------------------------------------------
|
||||
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
|
||||
-------------------------------------------------------------------
|
||||
|
||||
=cut
|
||||
|
||||
use strict;
|
||||
use base 'WebGUI::Form::Text';
|
||||
use WebGUI::International;
|
||||
use JSON ();
|
||||
use WebGUI::Keyword;
|
||||
|
||||
=head1 NAME
|
||||
|
||||
Package WebGUI::Form::Keywords
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
Creates a keywords chooser field with multiple select and autocomplete.
|
||||
|
||||
=head1 SEE ALSO
|
||||
|
||||
This is a subclass of WebGUI::Form::SelectList.
|
||||
|
||||
=head1 METHODS
|
||||
|
||||
The following methods are specifically available from this class. Check the superclass for additional methods.
|
||||
|
||||
=cut
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getDatabaseFieldType ( )
|
||||
|
||||
Returns "CHAR(22) BINARY".
|
||||
|
||||
=cut
|
||||
|
||||
sub getDatabaseFieldType {
|
||||
return "CHAR(255)";
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getName ( session )
|
||||
|
||||
Returns the human readable name of this control.
|
||||
|
||||
=cut
|
||||
|
||||
sub getName {
|
||||
my ($self, $session) = @_;
|
||||
return WebGUI::International->new($session, 'Asset')->get('keywords');
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 isDynamicCompatible ( )
|
||||
|
||||
A class method that returns a boolean indicating whether this control is compatible with the DynamicField control.
|
||||
|
||||
=cut
|
||||
|
||||
sub isDynamicCompatible {
|
||||
return 1;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 toHtml ( )
|
||||
|
||||
Returns a keyword pull-down field. A keyword pull down provides a select list that provides name value pairs for all the keywords in the WebGUI system.
|
||||
|
||||
=cut
|
||||
|
||||
sub toHtml {
|
||||
my $self = shift;
|
||||
my $session = $self->session;
|
||||
my $style = $session->style;
|
||||
my $url = $session->url;
|
||||
|
||||
$style->setLink($url->extras("yui/build/autocomplete/assets/skins/sam/autocomplete.css"), {rel=>"stylesheet", type=>"text/css"});
|
||||
$style->setScript($url->extras("yui/build/yahoo-dom-event/yahoo-dom-event.js"), {type=>"text/javascript"});
|
||||
$style->setScript($url->extras("yui/build/datasource/datasource-min.js"), {type=>"text/javascript"});
|
||||
$style->setScript($url->extras("yui/build/autocomplete/autocomplete-min.js"), {type=>"text/javascript"});
|
||||
$style->setRawHeadTags('<style type="text/css">.yui-skin-sam.webgui-keywords-autocomplete .yui-ac-input { position: static; width: auto }</style>');
|
||||
|
||||
my $name = $self->generateIdParameter($self->get('name'));
|
||||
my $autocompleteDiv = $self->privateName('autocomplete');
|
||||
my $pageUrl = $url->page;
|
||||
my $output
|
||||
= '<div class="yui-skin-sam webgui-keywords-autocomplete"><div>' . $self->SUPER::toHtml
|
||||
. '<div id="' . $autocompleteDiv . '"></div>'
|
||||
. '<script type="text/javascript">' . <<"END_SCRIPT" . '</script></div></div>';
|
||||
(function() {
|
||||
var oDS = new YAHOO.util.XHRDataSource('$pageUrl');
|
||||
oDS.responseType = YAHOO.util.XHRDataSource.TYPE_JSON;
|
||||
oDS.responseSchema = {
|
||||
resultsList : "keywords",
|
||||
};
|
||||
|
||||
var oAC = new YAHOO.widget.AutoComplete("$name", "$autocompleteDiv", oDS);
|
||||
oAC.queryDelay = 0.5;
|
||||
oAC.maxResultsDisplayed = 20;
|
||||
oAC.minQueryLength = 3;
|
||||
oAC.delimChar = [','];
|
||||
|
||||
oAC.generateRequest = function(sQuery) {
|
||||
return "?op=formHelper;class=Keywords;sub=searchAsJSON;search=" + sQuery ;
|
||||
};
|
||||
})();
|
||||
END_SCRIPT
|
||||
return $output;
|
||||
}
|
||||
|
||||
sub www_searchAsJSON {
|
||||
my $session = shift;
|
||||
my $search = $session->form->param('search');
|
||||
my $keyword = WebGUI::Keyword->new($session);
|
||||
|
||||
my $keywords = $keyword->findKeywords({search => $search, limit => 20});
|
||||
$session->http->setMimeType('application/json');
|
||||
|
||||
return JSON::to_json({keywords => $keywords});
|
||||
}
|
||||
|
||||
sub getDefaultValue {
|
||||
my $self = shift;
|
||||
return _formatKeywordsAsWanted($self->SUPER::getDefaultValue(@_));
|
||||
}
|
||||
|
||||
sub getOriginalValue {
|
||||
my $self = shift;
|
||||
return _formatKeywordsAsWanted($self->SUPER::getOriginalValue(@_));
|
||||
}
|
||||
|
||||
sub getValue {
|
||||
my $self = shift;
|
||||
return _formatKeywordsAsWanted($self->SUPER::getValue(@_));
|
||||
}
|
||||
|
||||
sub _formatKeywordsAsWanted {
|
||||
my @keywords;
|
||||
if (@_ == 1 && ref $_[0] eq 'ARRAY') {
|
||||
@keywords = @{ $_[0] };
|
||||
}
|
||||
else {
|
||||
for my $param (@_) {
|
||||
for my $keyword (split /,/, $param) {
|
||||
$keyword =~ s/^\s+//;
|
||||
$keyword =~ s/\s+$//;
|
||||
push @keywords, $keyword;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (wantarray) {
|
||||
return @keywords;
|
||||
}
|
||||
return join(', ', @keywords);
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
|
|
@ -220,7 +220,7 @@ sub getValue {
|
|||
@values = $self->session->form->param($self->get("name"));
|
||||
}
|
||||
}
|
||||
if (scalar @values < 1) {
|
||||
if (scalar @values < 1 && ! $self->get('allowEmpty')) {
|
||||
@values = $self->getDefaultValue;
|
||||
}
|
||||
return wantarray ? @values : join("\n",@values);
|
||||
|
|
@ -262,18 +262,17 @@ Returns the either the "value" ore "defaultValue" passed in to the object in tha
|
|||
sub getOriginalValue {
|
||||
my $self = shift;
|
||||
my @values = ();
|
||||
foreach my $value ($self->get("value")) {
|
||||
if (scalar @values < 1 && defined $value) {
|
||||
if (ref $value eq "ARRAY") {
|
||||
@values = @{$value};
|
||||
}
|
||||
else {
|
||||
$value =~ s/\r//g;
|
||||
@values = split "\n", $value;
|
||||
}
|
||||
my $value = $self->get("value");
|
||||
if (defined $value) {
|
||||
if (ref $value eq "ARRAY") {
|
||||
@values = @{$value};
|
||||
}
|
||||
else {
|
||||
$value =~ s/\r//g;
|
||||
@values = split "\n", $value;
|
||||
}
|
||||
}
|
||||
if (@values) {
|
||||
if (@values || ($self->get('allowEmpty') && defined $value) ) {
|
||||
return wantarray ? @values : join("\n",@values);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -116,7 +116,7 @@ sub isDynamicCompatible {
|
|||
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
=head2 new
|
||||
=head2 getOptions
|
||||
|
||||
Create a new WebGUI::Form::SelectRichEditor object and populate it with all
|
||||
the available Rich Text Editor assets.
|
||||
|
|
|
|||
|
|
@ -85,7 +85,7 @@ Renders the form field to HTML as a table row. The row is not displayed because
|
|||
|
||||
sub toHtmlWithWrapper {
|
||||
my $self = shift;
|
||||
my $value = $self->fixMacros($self->fixQuotes($self->fixSpecialCharacters($self->getOriginalValue))) || '';
|
||||
my $value = $self->fixMacros($self->fixQuotes($self->fixSpecialCharacters(scalar $self->getOriginalValue))) || '';
|
||||
if ($value) {
|
||||
my $manageButton = $self->session->icon->manage("op=editGroup;gid=".$value);
|
||||
$self->set("subtext",$manageButton . $self->get("subtext"));
|
||||
|
|
|
|||
|
|
@ -125,7 +125,7 @@ Renders an input tag of type text.
|
|||
|
||||
sub toHtml {
|
||||
my $self = shift;
|
||||
my $value = $self->fixMacros($self->fixQuotes($self->fixSpecialCharacters($self->getOriginalValue)));
|
||||
my $value = $self->fixMacros($self->fixQuotes($self->fixSpecialCharacters(scalar $self->getOriginalValue)));
|
||||
return '<input id="'.$self->get('id').'" type="text" name="'.$self->get("name").'" value="'.$value.'" size="'.$self->get("size").'" maxlength="'.$self->get("maxlength").'" '.$self->get("extras").' />';
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -139,7 +139,7 @@ Renders an input tag of type text.
|
|||
|
||||
sub toHtml {
|
||||
my $self = shift;
|
||||
my $value = $self->fixMacros($self->fixTags($self->fixSpecialCharacters($self->getOriginalValue)));
|
||||
my $value = $self->fixMacros($self->fixTags($self->fixSpecialCharacters(scalar $self->getOriginalValue)));
|
||||
my $width = $self->get('width') || 400;
|
||||
my $height = $self->get('height') || 150;
|
||||
my ($style, $url) = $self->session->quick(qw(style url));
|
||||
|
|
@ -195,6 +195,14 @@ sub toHtml {
|
|||
return $out;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getValueAsHtml
|
||||
|
||||
Returns the form value as text, encoding HTML entities.
|
||||
|
||||
=cut
|
||||
|
||||
sub getValueAsHtml {
|
||||
my $self = shift;
|
||||
my $value = $self->SUPER::getValueAsHtml(@_);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue