Merge branch 'master' into WebGUI8
This commit is contained in:
commit
2400f19099
797 changed files with 33894 additions and 27196 deletions
|
|
@ -162,7 +162,7 @@ sub toHtml {
|
|||
my $pubKey = $self->session->setting->get('recaptchaPublicKey');
|
||||
my $server = "http://api.recaptcha.net";
|
||||
if ($env->sslRequest) {
|
||||
$server = "http://api-secure.recaptcha.net";
|
||||
$server = "https://api-secure.recaptcha.net";
|
||||
}
|
||||
return
|
||||
'<script type="text/javascript" src="' . $server . '/challenge?k=' . $pubKey . '"></script>'
|
||||
|
|
@ -178,8 +178,9 @@ sub toHtml {
|
|||
my ($filename, $challenge) = $storage->addFileFromCaptcha;
|
||||
$self->set("size", 6);
|
||||
$self->set("maxlength", 6);
|
||||
$self->set("extras", 'class="wg-captchaForm"');
|
||||
$self->session->scratch->set("captcha_".$self->get("name"), $challenge);
|
||||
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>';
|
||||
return $self->SUPER::toHtml.'<img src="'.$storage->getUrl($filename).'" class="wg-captchaImage" alt="captcha" />';
|
||||
}
|
||||
|
||||
=head2 getErrorMessage ( )
|
||||
|
|
|
|||
|
|
@ -169,14 +169,19 @@ sub toHtml {
|
|||
$style->setScript($url->extras("yui/build/resize/resize-min.js"),{type=>"text/javascript"});
|
||||
$style->setScript($url->extras("yui/build/editor/editor-min.js"),{type=>"text/javascript"});
|
||||
$style->setScript($url->extras("yui-webgui/build/code-editor/code-editor.js"),{type=>"text/javascript"});
|
||||
#$style->setLink($url->extras("yui/build/logger/assets/logger.css"), {type=>"text/css", rel=>"stylesheet"});
|
||||
#$style->setLink($url->extras("yui/build/logger/assets/skins/sam/logger.css"), {type=>"text/css", rel=>"stylesheet"});
|
||||
#$style->setScript($url->extras("yui/build/logger/logger.js"),{type=>"text/javascript"});
|
||||
my $codeCss = $url->extras("yui-webgui/build/code-editor/code.css");
|
||||
my $out = <<"END_HTML";
|
||||
<textarea id="$id" name="$name" $extras rows="10" cols="60" style="font-family: monospace; $styleAttr; height: 100%; width: 100%; resize: none;">$value</textarea>
|
||||
<script type="text/javascript">
|
||||
(function(){
|
||||
YAHOO.util.Event.onDOMReady( function () {
|
||||
var myeditor = new YAHOO.widget.CodeEditor('${id}', { handleSubmit: true, css_url: '${codeCss}', height: '${height}px', width: '${width}px', status: true, resize: true });
|
||||
var myeditor = new YAHOO.widget.CodeEditor('${id}', { toggleButton: true, handleSubmit: true, css_url: '${codeCss}', height: '${height}px', width: '${width}px', status: true, resize: true });
|
||||
myeditor.render();
|
||||
|
||||
//var myLogReader = new YAHOO.widget.LogReader();
|
||||
} );
|
||||
}());
|
||||
</script>
|
||||
|
|
|
|||
|
|
@ -122,6 +122,7 @@ sub toHtml {
|
|||
my $options = $self->getOptions;
|
||||
$options->{''} = '['.$i18n->get(582).']';
|
||||
$options->{_new_} = $i18n->get(581).'->';
|
||||
$self->set('options', $options);
|
||||
return $self->SUPER::toHtml
|
||||
.WebGUI::Form::Text->new($self->session,
|
||||
size=>$self->session->setting->get("textBoxSize")-5,
|
||||
|
|
|
|||
|
|
@ -116,18 +116,18 @@ sub getCountries {
|
|||
'Cayman Islands', 'Central African Republic',
|
||||
'Chad', 'Chile',
|
||||
'China', 'Christmas Island',
|
||||
'Cocos (Keeling) Islands', 'Colombia',
|
||||
'Comoros', 'Congo',
|
||||
'Congo, the Democratic Republic of the', 'Cook Islands',
|
||||
'Costa Rica', 'Cote d\'Ivoire',
|
||||
'Croatia', 'Cyprus',
|
||||
'Czech Republic', 'Denmark',
|
||||
'Djibouti', 'Dominica',
|
||||
'Dominican Republic', 'East Timor',
|
||||
'Ecuador', 'Egypt',
|
||||
'El Salvador', 'England',
|
||||
'Equatorial Guinea', 'Eritrea',
|
||||
'Espana', 'Estonia',
|
||||
'Christmas Island (Kiribati)', 'Cocos (Keeling) Islands',
|
||||
'Colombia', 'Comoros',
|
||||
'Congo', 'Congo, the Democratic Republic of the',
|
||||
'Cook Islands', 'Costa Rica',
|
||||
'Cote d\'Ivoire', 'Croatia',
|
||||
'Cyprus', 'Czech Republic',
|
||||
'Denmark', 'Djibouti',
|
||||
'Dominica', 'Dominican Republic',
|
||||
'East Timor', 'Ecuador',
|
||||
'Egypt', 'El Salvador',
|
||||
'England', 'Equatorial Guinea',
|
||||
'Eritrea', 'Estonia',
|
||||
'Ethiopia', 'Falkland Islands',
|
||||
'Faroe Islands', 'Fiji',
|
||||
'Finland', 'France',
|
||||
|
|
|
|||
|
|
@ -107,7 +107,7 @@ sub getDataTableHtml {
|
|||
|
||||
### Prepare the columns data
|
||||
my %parsers = (
|
||||
date => "YAHOO.util.DataSource.parseDate",
|
||||
date => "YAHOO.lang.JSON.stringToDate",
|
||||
number => "YAHOO.util.DataSource.parseNumber",
|
||||
);
|
||||
|
||||
|
|
|
|||
|
|
@ -19,6 +19,8 @@ use base 'WebGUI::Form::Text';
|
|||
use WebGUI::Form::Hidden;
|
||||
use WebGUI::International;
|
||||
|
||||
my $isaEpoch = qr/^-?\d+$/;
|
||||
|
||||
=head1 NAME
|
||||
|
||||
Package WebGUI::Form::Date
|
||||
|
|
@ -80,7 +82,7 @@ sub definition {
|
|||
|
||||
push(@{$definition}, {
|
||||
defaultValue=>{
|
||||
defaultValue=>$session->datetime->time()
|
||||
defaultValue=>time()
|
||||
},
|
||||
maxlength=>{
|
||||
defaultValue=> 10
|
||||
|
|
@ -137,9 +139,9 @@ sub getValue {
|
|||
my $self = shift;
|
||||
# This should probably be rewritten as a cascading ternary
|
||||
my $value = $self->SUPER::getValue(@_);
|
||||
if (!$self->getDefaultValue || $self->getDefaultValue =~ m/^\d+$/) {
|
||||
if (!$self->getDefaultValue || $self->getDefaultValue =~ $isaEpoch) {
|
||||
# Epoch format
|
||||
if($value =~ /^\d+$/){
|
||||
if($value =~ $isaEpoch){
|
||||
return $value;
|
||||
}
|
||||
return $self->session->datetime->setToEpoch($value);
|
||||
|
|
@ -150,10 +152,7 @@ sub getValue {
|
|||
|
||||
# NOTE: Cannot fix time zone since we don't have a complete date/time
|
||||
|
||||
# MySQL format
|
||||
# YY(YY)?-MM-DD HH:MM:SS
|
||||
|
||||
if($value =~ /^\d+$/){
|
||||
if($value =~ $isaEpoch){
|
||||
return $self->session->datetime->epochToSet($value,$self->session->user->profileField( 'timeZone' ));
|
||||
}
|
||||
|
||||
|
|
@ -173,17 +172,17 @@ Return the date in a human readable format.
|
|||
=cut
|
||||
|
||||
sub getValueAsHtml {
|
||||
my ($self) = @_;
|
||||
my ($self) = @_;
|
||||
# This should probably be rewritten as a cascading ternary
|
||||
if (!$self->get("defaultValue")
|
||||
|| $self->get("defaultValue") =~ m/^\d+$/
|
||||
|| !$self->get("value")
|
||||
|| $self->get("value") =~ m/^\d+$/) {
|
||||
return $self->session->datetime->epochToHuman($self->getOriginalValue,"%z");
|
||||
}
|
||||
if ( !$self->get("defaultValue")
|
||||
|| $self->get("defaultValue") =~ $isaEpoch
|
||||
|| !$self->get("value")
|
||||
|| $self->get("value") =~ $isaEpoch) {
|
||||
return $self->session->datetime->epochToHuman($self->getOriginalValue, '%z');
|
||||
}
|
||||
else {
|
||||
# MySQL format
|
||||
my $value = $self->getOriginalValue;
|
||||
# MySQL format
|
||||
my $value = $self->getOriginalValue;
|
||||
return $value;
|
||||
}
|
||||
}
|
||||
|
|
@ -217,23 +216,15 @@ sub toHtml {
|
|||
# No default date
|
||||
$value = $self->set("value",'');
|
||||
}
|
||||
elsif (!$self->get("defaultValue")
|
||||
|| $self->get("defaultValue") =~ m/^\d+$/
|
||||
|| !$self->get("value")
|
||||
|| $self->get("value") =~ m/^\d+$/) {
|
||||
# Epoch format
|
||||
$value = $session->datetime->epochToSet($self->getOriginalValue);
|
||||
}
|
||||
else {
|
||||
# MySQL format
|
||||
$value = $self->getOriginalValue;
|
||||
# NOTE: Cannot fix time zone since we don't have a complete date/time
|
||||
$value = eval { WebGUI::DateTime->new($session, $self->getOriginalValue)->toMysqlDate; };
|
||||
$value = WebGUI::DateTime->new($session,0)->toMysqlDate if $value eq '';
|
||||
}
|
||||
|
||||
my $style = $session->style;
|
||||
my $url = $session->url;
|
||||
$style->setLink($url->extras('yui/build/calendar/assets/skins/sam/calendar.css'), { rel=>"stylesheet", type=>"text/css", media=>"all" });
|
||||
$style->setScript($url->extras('/yui/build/utilities/utilities.js'), { type => 'text/javascript' });
|
||||
$style->setScript($url->extras('yui/build/utilities/utilities.js'), { type => 'text/javascript' });
|
||||
$style->setScript($url->extras('yui/build/json/json-min.js'), { type => 'text/javascript' });
|
||||
$style->setScript($url->extras('yui/build/yahoo/yahoo-min.js'), { type => 'text/javascript' });
|
||||
$style->setScript($url->extras('yui/build/dom/dom-min.js'), { type => 'text/javascript' });
|
||||
|
|
@ -262,25 +253,13 @@ Renders the form field to HTML as a hidden field rather than whatever field type
|
|||
=cut
|
||||
|
||||
sub toHtmlAsHidden {
|
||||
my $self = shift;
|
||||
my $value;
|
||||
|
||||
# This should probably be rewritten as a cascading ternary
|
||||
if (!$self->get("defaultValue")
|
||||
|| $self->get("defaultValue") =~ m/^\d+$/
|
||||
|| !$self->get("value")
|
||||
|| $self->get("value") =~ m/^\d+$/) {
|
||||
$value = $self->session->datetime->epochToSet($self->getOriginalValue,"%z");
|
||||
} else {
|
||||
# MySQL format
|
||||
$value = $self->getOriginalValue;
|
||||
# NOTE: Cannot fix time zone since we don't have a complete date/time
|
||||
}
|
||||
|
||||
return WebGUI::Form::Hidden->new($self->session,
|
||||
name => $self->get("name"),
|
||||
value => $value,
|
||||
)->toHtmlAsHidden;
|
||||
my $self = shift;
|
||||
my $session = $self->session;
|
||||
my $value = WebGUI::DateTime->new($session, $self->getOriginalValue)->toMysqlDate;
|
||||
return WebGUI::Form::Hidden->new($session,
|
||||
name => $self->get("name"),
|
||||
value => $value,
|
||||
)->toHtmlAsHidden;
|
||||
}
|
||||
|
||||
1;
|
||||
|
|
|
|||
|
|
@ -20,6 +20,8 @@ use WebGUI::Form::Hidden;
|
|||
use WebGUI::International;
|
||||
use WebGUI::DateTime;
|
||||
|
||||
my $isaEpoch = qr/^-?\d+$/;
|
||||
|
||||
=head1 NAME
|
||||
|
||||
Package WebGUI::Form::DateTime
|
||||
|
|
@ -82,7 +84,7 @@ sub definition {
|
|||
my $definition = shift || [];
|
||||
push(@{$definition}, {
|
||||
defaultValue=>{
|
||||
defaultValue=>$session->datetime->time()
|
||||
defaultValue=>time()
|
||||
},
|
||||
maxlength=>{
|
||||
defaultValue=> 19
|
||||
|
|
@ -139,9 +141,9 @@ sub getValue {
|
|||
# This should probably be rewritten as a cascading ternary
|
||||
my $value = $self->SUPER::getValue(@_);
|
||||
|
||||
if (!$self->getDefaultValue || $self->getDefaultValue =~ m/^\d+$/) {
|
||||
if (!$self->getDefaultValue || $self->getDefaultValue =~ $isaEpoch) {
|
||||
# Epoch format
|
||||
if($value =~ /^\d+$/){
|
||||
if($value =~ $isaEpoch){
|
||||
return $value;
|
||||
}
|
||||
return $self->session->datetime->setToEpoch($value);
|
||||
|
|
@ -150,7 +152,7 @@ sub getValue {
|
|||
# MySQL format
|
||||
# YY(YY)?-MM-DD HH:MM:SS
|
||||
|
||||
if($value =~ /^\d+$/){
|
||||
if($value =~ $isaEpoch){
|
||||
return $self->session->datetime->epochToSet($value,$self->session->user->profileField( 'timeZone' ));
|
||||
}
|
||||
|
||||
|
|
@ -178,8 +180,10 @@ Return the date in a human readable format.
|
|||
sub getValueAsHtml {
|
||||
my ($self) = @_;
|
||||
# This should probably be rewritten as a cascading ternary
|
||||
my $formatValue = $self->getDefaultValue || $self->getOriginalValue;
|
||||
if (!$formatValue || $formatValue =~ m/^\d+$/) {
|
||||
if ( !$self->get("defaultValue")
|
||||
|| $self->get("defaultValue") =~ $isaEpoch
|
||||
|| !$self->get("value")
|
||||
|| $self->get("value") =~ $isaEpoch) {
|
||||
return $self->session->datetime->epochToHuman($self->getOriginalValue,"%z %Z");
|
||||
}
|
||||
else {
|
||||
|
|
@ -216,22 +220,10 @@ Renders a date picker control.
|
|||
sub toHtml {
|
||||
my $self = shift;
|
||||
my $session = $self->session;
|
||||
my $value;
|
||||
# This should probably be rewritten as a cascading ternary
|
||||
if (!$self->get("defaultValue")
|
||||
|| $self->get("defaultValue") =~ m/^\d+$/
|
||||
|| !$self->get("value")
|
||||
|| $self->get("value") =~ m/^\d+$/) {
|
||||
# Epoch format
|
||||
$value = $session->datetime->epochToSet($self->getOriginalValue,1);
|
||||
} else {
|
||||
# MySQL format
|
||||
$value = $self->getOriginalValue;
|
||||
# Fix time zone
|
||||
$value = WebGUI::DateTime->new($session, mysql => $value)
|
||||
->set_time_zone($self->get("timeZone"))
|
||||
->strftime("%Y-%m-%d %H:%M:%S");
|
||||
}
|
||||
my $value = eval { WebGUI::DateTime->new($session, $self->getOriginalValue); };
|
||||
$value = WebGUI::DateTime->new($session,0) if $value eq '';
|
||||
$value = $value->set_time_zone($self->get("timeZone"))->strftime("%Y-%m-%d %H:%M:%S");
|
||||
|
||||
my $style = $session->style;
|
||||
my $url = $session->url;
|
||||
$style->setLink($url->extras('yui/build/calendar/assets/skins/sam/calendar.css'), { rel=>"stylesheet", type=>"text/css", media=>"all" });
|
||||
|
|
@ -245,12 +237,12 @@ sub toHtml {
|
|||
$style->setScript($url->extras('yui-webgui/build/datepicker/datepicker.js'),{ type => 'text/javascript' });
|
||||
|
||||
return WebGUI::Form::Text->new($self->session,
|
||||
name=>$self->get("name"),
|
||||
value=>$value,
|
||||
size=>$self->get("size"),
|
||||
extras=>$self->get("extras") . ' onfocus="YAHOO.WebGUI.Form.DatePicker.display(this, true);"',
|
||||
id=>$self->get('id'),
|
||||
maxlength=>$self->get("maxlength")
|
||||
name => $self->get("name"),
|
||||
value => $value,
|
||||
size => $self->get("size"),
|
||||
extras => $self->get("extras") . ' onfocus="YAHOO.WebGUI.Form.DatePicker.display(this, true);"',
|
||||
id => $self->get('id'),
|
||||
maxlength => $self->get("maxlength")
|
||||
)->toHtml;
|
||||
}
|
||||
|
||||
|
|
@ -263,28 +255,15 @@ Renders the form field to HTML as a hidden field rather than whatever field type
|
|||
=cut
|
||||
|
||||
sub toHtmlAsHidden {
|
||||
my $self = shift;
|
||||
my $value;
|
||||
my $self = shift;
|
||||
my $value = WebGUI::DateTime->new($self->session, $self->getOriginalValue)
|
||||
->set_time_zone($self->get("timeZone"))
|
||||
->strftime("%Y-%m-%d %H:%M:%S");
|
||||
|
||||
# This should probably be rewritten as a cascading ternary
|
||||
if (!$self->get("defaultValue")
|
||||
|| $self->get("defaultValue") =~ m/^\d+$/
|
||||
|| !$self->get("value")
|
||||
|| $self->get("value") =~ m/^\d+$/) {
|
||||
$value = $self->session->datetime->epochToSet($self->getOriginalValue,1);
|
||||
} else {
|
||||
# MySQL format
|
||||
$value = $self->getOriginalValue;
|
||||
# Fix Time zone
|
||||
$value = WebGUI::DateTime->new($self->session, mysql => $value)
|
||||
->set_time_zone($self->get("timeZone"))
|
||||
->strftime("%Y-%m-%d %H:%M:%S");
|
||||
}
|
||||
|
||||
return WebGUI::Form::Hidden->new(
|
||||
name => $self->get("name"),
|
||||
value => $value,
|
||||
)->toHtmlAsHidden;
|
||||
return WebGUI::Form::Hidden->new($self->session,
|
||||
name => $self->get("name"),
|
||||
value => $value,
|
||||
)->toHtmlAsHidden;
|
||||
}
|
||||
|
||||
1;
|
||||
|
|
|
|||
114
lib/WebGUI/Form/Div.pm
Normal file
114
lib/WebGUI/Form/Div.pm
Normal file
|
|
@ -0,0 +1,114 @@
|
|||
package WebGUI::Form::Div;
|
||||
|
||||
=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::Control';
|
||||
use WebGUI::International;
|
||||
|
||||
=head1 NAME
|
||||
|
||||
Package WebGUI::Form::Div
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
dreates a HTML div element with contents provided by caller
|
||||
|
||||
=head1 SEE ALSO
|
||||
|
||||
This is a subclass of WebGUI::Form::Control.
|
||||
|
||||
=head1 METHODS
|
||||
|
||||
The following methods are specifically available from this class. Check the superclass for additional methods.
|
||||
|
||||
=cut
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 definition ( [ additionalTerms ] )
|
||||
|
||||
See the super class for additional details.
|
||||
|
||||
=head3 usage
|
||||
|
||||
$form->div({
|
||||
contentCallback => sub { $self->getDivContents(shift); }
|
||||
});
|
||||
|
||||
=head3 additionalTerms
|
||||
|
||||
The following additional parameters have been added via this sub class.
|
||||
|
||||
=head4 contentCallback
|
||||
|
||||
A code enclosure which returns the html text to insert into the div element. The divId is passed as parameter 0 when it is called. This function MUST return good html text, it is NOT processed here at all.
|
||||
|
||||
=cut
|
||||
|
||||
sub definition {
|
||||
my $class = shift;
|
||||
my $session = shift;
|
||||
my $definition = shift || [];
|
||||
push(@{$definition}, {
|
||||
contentCallback=>{
|
||||
defaultValue=> sub { return '' },
|
||||
},
|
||||
});
|
||||
return $class->SUPER::definition($session, $definition);
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getName ( session )
|
||||
|
||||
Returns the name of the form control.
|
||||
|
||||
=cut
|
||||
|
||||
sub getName {
|
||||
my ($class, $session) = @_;
|
||||
return WebGUI::International->new($session, "Form_Div")->get("topicName");
|
||||
}
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getValue ( [ value ] )
|
||||
|
||||
Does some special processing.
|
||||
|
||||
=cut
|
||||
|
||||
sub getValue {
|
||||
my $self = shift;
|
||||
return $self->get('contentCallback')->($self->get('id'));
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 toHtml ( )
|
||||
|
||||
Renders an input tag of type text.
|
||||
|
||||
=cut
|
||||
|
||||
sub toHtml {
|
||||
my $self = shift;
|
||||
return '<div id="'.$self->get('id').'" name="'.$self->get("name").'" '.$self->get("extras").'>' . $self->getValue . '</div>' ;
|
||||
}
|
||||
|
||||
1;
|
||||
#vim:ft=perl
|
||||
|
|
@ -172,7 +172,7 @@ sub toHtml {
|
|||
my $richEdit = eval { WebGUI::Asset::RichEdit->newById($self->session, $self->get("richEditId")); };
|
||||
if (! Exception::Class->caught() ) {
|
||||
$self->session->style->setScript($self->session->url->extras('textFix.js'),{ type=>'text/javascript' });
|
||||
$self->set("extras", $self->get('extras') . ' onblur="fixChars(this.form.'.$self->get("name").')" mce_editable="true" ');
|
||||
$self->set("extras", $self->get('extras') . q{ onblur="fixChars(this.form['}.$self->get("name").q{'])" mce_editable="true" });
|
||||
$self->set("resizable", 0);
|
||||
return $self->SUPER::toHtml.$richEdit->getRichEditor($self->get('id'));
|
||||
} else {
|
||||
|
|
@ -386,8 +386,8 @@ sub www_addFolderSave {
|
|||
title => $filename,
|
||||
menuTitle => $filename,
|
||||
url => $base->getUrl.'/'.$filename,
|
||||
groupIdEdit => $session->form->process('groupIdEdit') || $base->get('groupIdEdit'),
|
||||
groupIdView => $session->form->process('groupIdView') || $base->get('groupIdView'),
|
||||
groupIdEdit => $base->get('groupIdEdit'),
|
||||
groupIdView => $base->get('groupIdView'),
|
||||
ownerUserId => $session->user->userId,
|
||||
startDate => $base->get('startDate'),
|
||||
endDate => $base->get('endDate'),
|
||||
|
|
@ -410,6 +410,7 @@ sub www_addFolderSave {
|
|||
className => 'WebGUI::Asset::Wobject::Folder',
|
||||
#filename => $filename,
|
||||
});
|
||||
WebGUI::VersionTag->autoCommitWorkingIfEnabled($session, { allowComments => 0 });
|
||||
$session->http->setRedirect($base->getUrl('op=formHelper;class=HTMLArea;sub=imageTree'));
|
||||
return undef;
|
||||
}
|
||||
|
|
@ -495,6 +496,7 @@ sub www_addImageSave {
|
|||
$child->update({url => $child->fixUrl});
|
||||
$child->applyConstraints;
|
||||
}
|
||||
WebGUI::VersionTag->autoCommitWorkingIfEnabled($session, { allowComments => 0 });
|
||||
$session->http->setRedirect($base->getUrl('op=formHelper;class=HTMLArea;sub=imageTree'));
|
||||
return undef;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -95,6 +95,29 @@ sub getName {
|
|||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getUnitOptions ( )
|
||||
|
||||
Returns a hash with i18n labels and values for units of time.
|
||||
|
||||
=cut
|
||||
|
||||
sub getUnitOptions {
|
||||
my $self = shift;
|
||||
tie my %units, 'Tie::IxHash';
|
||||
my $i18n = WebGUI::International->new($self->session);
|
||||
%units = (seconds => $i18n->get(704),
|
||||
minutes => $i18n->get(705),
|
||||
hours => $i18n->get(706),
|
||||
days => $i18n->get(700),
|
||||
weeks => $i18n->get(701),
|
||||
months => $i18n->get(702),
|
||||
years => $i18n->get(703),
|
||||
);
|
||||
return %units;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getValue ( [ num_and_units ] )
|
||||
|
||||
Returns either the interval that was posted (in seconds) or if nothing comes back it returns 0.
|
||||
|
|
@ -165,17 +188,7 @@ Renders an interval control.
|
|||
|
||||
sub toHtml {
|
||||
my $self = shift;
|
||||
my %units;
|
||||
tie %units, 'Tie::IxHash';
|
||||
my $i18n = WebGUI::International->new($self->session);
|
||||
%units = (seconds => $i18n->get(704),
|
||||
minutes => $i18n->get(705),
|
||||
hours => $i18n->get(706),
|
||||
days => $i18n->get(700),
|
||||
weeks => $i18n->get(701),
|
||||
months => $i18n->get(702),
|
||||
years => $i18n->get(703),
|
||||
);
|
||||
my %units = $self->getUnitOptions();
|
||||
my %reverseUnits = reverse %units;
|
||||
my ($interval, $units) = $self->session->datetime->secondsToExactInterval($self->getOriginalValue);
|
||||
# not sure why, but these things need to be defined like this or
|
||||
|
|
@ -208,16 +221,20 @@ Returns the field as hidden controls rather than displayable controls.
|
|||
=cut
|
||||
|
||||
sub toHtmlAsHidden {
|
||||
my $self = shift;
|
||||
my ($interval, $units) = $self->session->datetime->secondsToExactInterval($self->getOriginalValue);
|
||||
return WebGUI::Form::Hidden->new($self->session,
|
||||
name=>$self->get("name").'_interval',
|
||||
value=>$interval
|
||||
)->toHtmlAsHidden
|
||||
.WebGUI::Form::Hidden->new($self->session,
|
||||
name=>$self->get("name").'_units',
|
||||
value=>$units
|
||||
)->toHtmlAsHidden;
|
||||
my $self = shift;
|
||||
my $session = $self->session;
|
||||
my %units = $self->getUnitOptions();
|
||||
my %reverseUnits = reverse %units;
|
||||
my ($interval, $units) = $session->datetime->secondsToExactInterval($self->getOriginalValue);
|
||||
my $unitVal = $reverseUnits{$units};
|
||||
return WebGUI::Form::Hidden->new($session,
|
||||
name => $self->get("name").'_interval',
|
||||
value => $interval,
|
||||
)->toHtmlAsHidden
|
||||
. WebGUI::Form::Hidden->new($session,
|
||||
name => $self->get("name").'_units',
|
||||
value => $unitVal,
|
||||
)->toHtmlAsHidden;
|
||||
}
|
||||
|
||||
1;
|
||||
|
|
|
|||
|
|
@ -104,6 +104,8 @@ sub toHtml {
|
|||
foreach ('text/html','text/css','text/javascript','text/plain','text/xml','application/xml') {
|
||||
$mimeTypes->{$_}=$_;
|
||||
}
|
||||
my $value = $self->getOriginalValue();
|
||||
$mimeTypes->{$value} = $value;
|
||||
$self->set("options", $mimeTypes);
|
||||
return $self->SUPER::toHtml();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -110,19 +110,6 @@ sub getDefaultValue {
|
|||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getOriginalValue( [ value ] )
|
||||
|
||||
See WebGUI::Form::Control::getOriginalValue()
|
||||
|
||||
=cut
|
||||
|
||||
sub getOriginalValue{
|
||||
my $self = shift;
|
||||
return $self->WebGUI::Form::Control::getOriginalValue(@_);
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 isDynamicCompatible ( )
|
||||
|
||||
A class method that returns a boolean indicating whether this control is compatible with the DynamicField control.
|
||||
|
|
|
|||
|
|
@ -123,7 +123,7 @@ Returns the form element used for manual input. You must overload this method.
|
|||
sub getInputElement {
|
||||
my $self = shift;
|
||||
|
||||
$self->session->errorHandler->fatal("Subclasses of WebGUI::Form::Session must overload getInputElement");
|
||||
$self->session->errorHandler->fatal("Subclasses of WebGUI::Form::Slider must overload getInputElement");
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
|
@ -174,7 +174,7 @@ from this class. For instance WebGUI::Form::SelectSlider.
|
|||
sub getOnChangeInputElement {
|
||||
my $self = shift;
|
||||
|
||||
$self->session->errorHandler->fatal("Subclasses of WebGUI::Form::Session must overload getOnChangeInputElement");
|
||||
$self->session->errorHandler->fatal("Subclasses of WebGUI::Form::Slider must overload getOnChangeInputElement");
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
|
@ -195,7 +195,7 @@ from this class. For instance WebGUI::Form::SelectSlider.
|
|||
sub getOnChangeSlider {
|
||||
my $self = shift;
|
||||
|
||||
$self->session->errorHandler->fatal("Subclasses of WebGUI::Form::Session must overload getOnChangeSlider");
|
||||
$self->session->errorHandler->fatal("Subclasses of WebGUI::Form::Slider must overload getOnChangeSlider");
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
|
|
|||
|
|
@ -95,6 +95,26 @@ sub isDynamicCompatible {
|
|||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 new ( )
|
||||
|
||||
Extend the base method to handle spaces in the value and/or default value.
|
||||
|
||||
=cut
|
||||
|
||||
sub new {
|
||||
my $class = shift;
|
||||
my $self = $class->SUPER::new(@_);
|
||||
my $value = $self->get('value');
|
||||
$value =~ tr/ /_/;
|
||||
$self->set('value', $value);
|
||||
my $defaultValue = $self->get('defaultValue');
|
||||
$defaultValue =~ tr/ /_/;
|
||||
$self->set('defaultValue', $defaultValue);
|
||||
return $self;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 toHtml ( )
|
||||
|
||||
Renders a database connection picker control.
|
||||
|
|
|
|||
127
lib/WebGUI/Form/Username.pm
Normal file
127
lib/WebGUI/Form/Username.pm
Normal file
|
|
@ -0,0 +1,127 @@
|
|||
package WebGUI::Form::Username;
|
||||
|
||||
=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;
|
||||
|
||||
=head1 NAME
|
||||
|
||||
Package WebGUI::Form::Username
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
Creates a text input box form field specifically for a user name.
|
||||
|
||||
=head1 SEE ALSO
|
||||
|
||||
This is a subclass of WebGUI::Form::Text.
|
||||
|
||||
=head1 METHODS
|
||||
|
||||
The following methods are specifically available from this class. Check the superclass for additional methods.
|
||||
|
||||
=cut
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 definition ( [ additionalTerms ] )
|
||||
|
||||
See the super class for additional details.
|
||||
|
||||
=head3 additionalTerms
|
||||
|
||||
The following additional parameters have been added via this sub class.
|
||||
|
||||
=head4 maxlength
|
||||
|
||||
Defaults to 255. Determines the maximum number of characters allowed in this field.
|
||||
|
||||
=head4 size
|
||||
|
||||
Defaults to the setting textBoxSize or 30 if that's not set. Specifies how big of a text box to display.
|
||||
|
||||
=cut
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getValue ( [ value ] )
|
||||
|
||||
Retrieves a value from a form GET or POST and returns it. If the value comes back as undef, this method will return the defaultValue instead. Strip newlines/carriage returns from the value.
|
||||
|
||||
=head3 value
|
||||
|
||||
An optional value to process, instead of POST input.
|
||||
|
||||
=cut
|
||||
|
||||
sub getValue {
|
||||
my $self = shift;
|
||||
my $value = $self->SUPER::getValue(@_);
|
||||
$value =~ tr/\r\n//d;
|
||||
return $value;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 toHtml ( )
|
||||
|
||||
Renders a user name field.
|
||||
|
||||
=cut
|
||||
|
||||
sub toHtml {
|
||||
my $self = shift;
|
||||
$self->session->style->setScript($self->session->url->extras('form/fieldCheck.js'),{ type=>'text/javascript' });
|
||||
$self->session->style->setScript($self->session->url->extras('yui/build/yahoo-dom-event/yahoo-dom-event.js'), {type=>'text/javascript'});
|
||||
$self->session->style->setScript($self->session->url->extras('yui/build/connection/connection-min.js'), {type => 'text/javascript'});
|
||||
$self->session->style->setScript($self->session->url->extras('yui/build/json/json-min.js'), {type=>'text/javascript'});
|
||||
$self->session->style->setScript($self->session->url->extras('yui/build/datasource/datasource-min.js'), {type=>'text/javascript'});
|
||||
$self->session->style->setScript($self->session->url->extras('yui-webgui/build/i18n/i18n.js'), {type=>'text/javascript'});
|
||||
my $value = $self->fixMacros($self->fixQuotes($self->fixSpecialCharacters(scalar $self->getOriginalValue)));
|
||||
$self->set("extras", $self->get('extras') . ' onblur="new WebGUI.FieldCheck(\''. $self->get("id").'\',\'Username\',1);"');
|
||||
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").' />';
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 www_check ($session)
|
||||
|
||||
www_check() is called by an Ajax call from the user registration page.
|
||||
|
||||
It checks whether a user name is free for registration. Returns a hash
|
||||
(error => $error)
|
||||
if the username is not free.
|
||||
|
||||
=cut
|
||||
|
||||
sub www_check {
|
||||
my $session = shift;
|
||||
my $input = $session->form->param('input');
|
||||
|
||||
$session->http->setMimeType( 'application/json' );
|
||||
my $i18n = WebGUI::International->new($session, 'Form_Username');
|
||||
|
||||
my $error = '';
|
||||
my ($existingUserId) = $session->db->quickArray("select userId from users where username=".$session->db->quote($input));
|
||||
$error = $i18n->get('username in use') if $existingUserId;
|
||||
|
||||
my %checkResults = (error => $error);
|
||||
return JSON::encode_json(\%checkResults);
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
|
|
@ -82,6 +82,7 @@ sub getName {
|
|||
=head2 getValue ( [ value ] )
|
||||
|
||||
Returns a validated form post result. If the result does not pass validation, it returns undef instead.
|
||||
Uppercases any lowercase letters.
|
||||
|
||||
=head3 value
|
||||
|
||||
|
|
@ -93,6 +94,7 @@ sub getValue {
|
|||
my $self = shift;
|
||||
my $value = $self->SUPER::getValue(@_);
|
||||
$value =~ tr/\r\n//d;
|
||||
$value =~ tr/a-z/A-Z/d;
|
||||
if ($value =~ /^[A-Z\d\s\-]+$/) {
|
||||
return $value;
|
||||
}
|
||||
|
|
@ -122,7 +124,7 @@ Renders a zip code field.
|
|||
sub toHtml {
|
||||
my $self = shift;
|
||||
$self->session->style->setScript($self->session->url->extras('inputCheck.js'),{ type=>'text/javascript' });
|
||||
$self->set("extras", $self->get('extras') . ' onkeyup="doInputCheck(document.getElementById(\''.$self->get("id").'\'),\'0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ- \')"');
|
||||
$self->set("extras", $self->get('extras') . ' onkeyup="doInputCheck(document.getElementById(\''.$self->get("id").'\'),\'0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz- \')"');
|
||||
return $self->SUPER::toHtml;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue