Merge branch 'master' of git@github.com:plainblack/webgui

This commit is contained in:
daviddelikat 2009-10-19 22:09:13 -05:00
commit 9805541a6e
168 changed files with 8536 additions and 3809 deletions

View file

@ -326,7 +326,7 @@ sub checkView {
return "chunked";
}
elsif ($var->isAdminOn && $self->get("state") =~ /^clipboard/) { # show em clipboard
my $queryFrag = "func=manageTrash";
my $queryFrag = "func=manageClipboard";
if ($self->session->form->process('revision')) {
$queryFrag .= ";revision=".$self->session->form->process('revision');
}

View file

@ -94,25 +94,28 @@ sub definition {
hoverHelp => $i18n->get("startZoom description"),
},
templateIdEditPoint => {
tab => "display",
fieldType => "template",
namespace => "MapPoint/Edit",
label => $i18n->get("templateIdEditPoint label"),
hoverHelp => $i18n->get("templateIdEditPoint description"),
tab => "display",
fieldType => "template",
defaultValue => "oHh0UqAJeY7u2n--WD-BAA",
namespace => "MapPoint/Edit",
label => $i18n->get("templateIdEditPoint label"),
hoverHelp => $i18n->get("templateIdEditPoint description"),
},
templateIdView => {
tab => "display",
fieldType => "template",
namespace => "Map/View",
label => $i18n->get("templateIdView label"),
hoverHelp => $i18n->get("templateIdView description"),
tab => "display",
fieldType => "template",
defaultValue => "9j0_Z1j3Jd0QBbY2akb6qw",
namespace => "Map/View",
label => $i18n->get("templateIdView label"),
hoverHelp => $i18n->get("templateIdView description"),
},
templateIdViewPoint => {
tab => "display",
fieldType => "template",
namespace => "MapPoint/View",
label => $i18n->get("templateIdViewPoint label"),
hoverHelp => $i18n->get("templateIdViewPoint description"),
tab => "display",
fieldType => "template",
defaultValue => "u9vfx33XDk5la1-QC5FK7g",
namespace => "MapPoint/View",
label => $i18n->get("templateIdViewPoint label"),
hoverHelp => $i18n->get("templateIdViewPoint description"),
},
workflowIdPoint => {
tab => "security",
@ -309,6 +312,8 @@ sub loadMapApiTags {
my $style = $self->session->style;
my $url = $self->session->url;
$style->setLink($url->extras('yui/build/container/assets/skins/sam/container.css'),{type=>'text/css',rel=>'stylesheet'});
$style->setLink($url->extras('yui/build/button/assets/skins/sam/button.css'),{type=>'text/css',rel=>'stylesheet'});
$style->setScript("http://www.google.com/jsapi?key=" . $self->get('mapApiKey'),{type=>"text/javascript"});
$style->setRawHeadTags(<<'ENDHTML');
<script type="text/javascript">
@ -318,6 +323,10 @@ ENDHTML
$style->setScript('http://gmaps-utility-library.googlecode.com/svn/trunk/markermanager/release/src/markermanager.js', {type=>"text/javascript"});
$style->setScript($url->extras('yui/build/yahoo-dom-event/yahoo-dom-event.js'),{type=>'text/javascript'});
$style->setScript($url->extras('yui/build/connection/connection-min.js'),{type=>'text/javascript'});
$style->setScript($url->extras('yui/build/dragdrop/dragdrop-min.js'),{type=>'text/javascript'});
$style->setScript($url->extras('yui/build/element/element-min.js'),{type=>'text/javascript'});
$style->setScript($url->extras('yui/build/button/button-min.js'),{type=>'text/javascript'});
$style->setScript($url->extras('yui/build/container/container-min.js'),{type=>'text/javascript'});
$style->setScript($url->extras('yui/build/json/json-min.js'),{type=>'text/javascript'});
$style->setScript($url->extras('yui-webgui/build/map/map.js'),{type=>'text/javascript'});
@ -373,7 +382,7 @@ sub view {
;
# The script to load the map into the container
$mapHtml .= sprintf <<'ENDHTML', $self->getId, $self->getUrl, $self->get('startLatitude'), $self->get('startLongitude'), $self->get('startZoom');
$mapHtml .= sprintf <<'ENDHTML', $self->getId, $self->getUrl, $self->get('startLatitude'), $self->get('startLongitude'), $self->get('startZoom'), $session->url->extras;
<script type="text/javascript">
google.setOnLoadCallback( function() {
var mapId = "%s";
@ -381,6 +390,7 @@ sub view {
var map = new GMap2( document.getElementById("map_" + mapId) );
map.setCenter(new GLatLng(%s, %s), %s);
map.setUIToDefault();
map.extrasUrl = "%s";
var markermanager = new MarkerManager(map, {trackMarkers: true});
ENDHTML
@ -404,7 +414,7 @@ ENDHTML
}
$mapHtml .= <<'ENDHTML';
markermanager.addMarkers( WebGUI.Map.preparePoints(map, markermanager, mapUrl, points), 1 );
markermanager.addMarkers( WebGUI.Map.preparePoints(map, markermanager, mapUrl, points), 0 );
ENDHTML
}

View file

@ -60,6 +60,13 @@ sub definition {
label => $i18n->get('Survey Exit URL'),
hoverHelp => $i18n->get('Survey Exit URL help'),
},
maxResponsesPerUser => {
fieldType => 'integer',
tab => 'properties',
defaultValue => 1,
label => $i18n->get('Max user responses'),
hoverHelp => $i18n->get('Max user responses help'),
},
timeLimit => {
fieldType => 'integer',
defaultValue => 0,
@ -236,13 +243,6 @@ sub definition {
label => $i18n->get('Group to view reports'),
hoverHelp => $i18n->get('Group to view reports help'),
},
maxResponsesPerUser => {
fieldType => 'integer',
tab => 'security',
defaultValue => 1,
label => $i18n->get('Max user responses'),
hoverHelp => $i18n->get('Max user responses help'),
},
# Other
surveyJSON => {
@ -2300,6 +2300,9 @@ END_SQL
}
$var->{response_loop} = \@responseloop;
$paginator->appendTemplateVars($var);
# Clean up
$self->clearTempReportTable;
my $out = $self->processTemplate( $var, $self->get('gradebookTemplateId') );
return $self->processStyle($out);
@ -2390,6 +2393,9 @@ sub www_viewStatisticalOverview {
$var->{question_loop} = \@questionloop;
$paginator->appendTemplateVars($var);
# Clean up
$self->clearTempReportTable;
my $out = $self->processTemplate( $var, $self->get('overviewTemplateId') );
return $self->processStyle($out);
@ -2445,6 +2451,9 @@ sub export {
$content = $self->session->db->$method( $opts{sql}, $opts{sqlParams} );
}
# Clean up
$self->clearTempReportTable;
my $filename = $self->session->url->escape( $self->get("title") . "_$opts{name}.$format" );
$self->session->http->setFilename($filename,"text/$format");
return $content;
@ -2585,6 +2594,21 @@ END_HTML
#-------------------------------------------------------------------
=head2 clearTempReportTable
Clears the Survey_tempReport table
Typically called after L<loadTempReportTable> has been used
=cut
sub clearTempReportTable {
my $self = shift;
$self->session->db->write( 'delete from Survey_tempReport where assetId = ?', [ $self->getId() ] );
}
#-------------------------------------------------------------------
=head2 loadTempReportTable
Loads the responses from the survey into the Survey_tempReport table, so that other or custom reports can be ran against this data.
@ -2607,7 +2631,7 @@ sub loadTempReportTable {
my %opts = validate(@_, { ignoreRevisionDate => 0 });
# Remove old temp report data
$self->session->db->write( 'delete from Survey_tempReport where assetId = ?', [ $self->getId() ] );
$self->clearTempReportTable;
# Build the sql that will select all responses
my $sql = 'select * from Survey_response where assetId = ?';

View file

@ -133,7 +133,7 @@ sub generateFeed {
my $limit = shift || $self->get('maxHeadlines');
my $feed = XML::FeedPP::Atom->new();
my $log = $self->session->log;
# build one feed out of many
my $newlyCached = 0;
foreach my $url (split(/\s+/, $self->get('rssUrl'))) {
@ -154,35 +154,45 @@ sub generateFeed {
utf8::downgrade($value, 1);
eval {
my $singleFeed = XML::FeedPP->new($value, utf8_flag => 1, -type => 'string');
$feed->merge($singleFeed);
$feed->merge_channel($singleFeed);
$feed->merge_item($singleFeed);
};
if ($@) {
$log->error("Syndicated Content asset (".$self->getId.") has a bad feed URL (".$url."). Failed with ".$@);
}
}
# build a new feed that matches the term the user is interested in
if ($self->get('hasTerms') ne '') {
my @terms = split /,\s*/, $self->get('hasTerms'); # get the list of terms
my $termRegex = join("|", map quotemeta($_), @terms); # turn the terms into a regex string
my @items = $feed->match_item(title => qr/$termRegex/msi);
push @items, $feed->match_item(description => qr/$termRegex/msi);
$feed->clear_item;
$feed->uniq_item;
foreach my $item (@items) {
$feed->add_item($item);
}
$feed->clear_item;
ITEM: foreach my $item (@items) {
$feed->add_item($item);
}
}
my %seen = {};
my @items = $feed->get_item;
$feed->clear_item;
ITEM: foreach my $item (@items) {
my $key = join "\n", $item->link, $item->pubDate, $item->description, $item->title;
next ITEM if $seen{$key}++;
$feed->add_item($item);
}
# sort them by date and remove any duplicate from the OR based term matching above
$feed->normalize();
$feed->sort_item();
# limit the feed to the maximum number of headlines (or the feed generator limit).
$feed->limit_item($limit);
# mark this asset as updated
$self->update({}) if ($newlyCached);
return $feed;
}

View file

@ -41,12 +41,13 @@ always taken from the field hashref.
sub addField {
my $self = shift;
my $field = shift;
my $isImport = shift;
my $self = shift;
my $field = shift;
my $isImport = shift;
my $dbDataType = shift || $self->_getDbDataType($field->{fieldType});
my $db = $self->session->db;
my $error = $self->session->errorHandler;
my $session = $self->session;
my $db = $session->db;
my $error = $session->errorHandler;
my ($oldFieldId, $newFieldId,$useAssetId,$useSequence);
$error->info("Adding Field, label: ".$field->{label}.", fieldId: ".$field->{fieldId}.",thingId: ".$field->{thingId});
@ -970,14 +971,14 @@ sub getFormPlugin {
my $i18n = WebGUI::International->new($session,"Asset_Thingy");
$param{name} = "field_".$data->{fieldId};
my $name = $param{name};
my $name = $param{name};
$name =~ s/\^.*?\;//xgs ; # remove macro's from user input
$param{value} = $data->{value} || $data->{defaultValue};
$param{size} = $data->{size};
$param{height} = $data->{height};
$param{width} = $data->{width};
$param{extras} = $data->{extras};
$param{vertical} = $data->{vertical};
$param{value} = $data->{value} || $data->{defaultValue};
$param{size} = $data->{size};
$param{height} = $data->{height};
$param{width} = $data->{width};
$param{extras} = $data->{extras};
$param{vertical} = $data->{vertical};
$param{fieldType} = $data->{fieldType};
if ($data->{fieldType} eq "Checkbox") {
@ -1034,14 +1035,14 @@ sub getFormPlugin {
}
if ($data->{fieldType} =~ m/^otherThing/x){
my $otherThingId = $data->{fieldType};
$otherThingId =~ s/^otherThing_(.*)/$1/x;
$param{fieldType} = "SelectList";
$class = 'WebGUI::Form::'. $param{fieldType};
my $otherThingId = $data->{fieldType};
$otherThingId =~ s/^otherThing_(.*)/$1/x;
$param{fieldType} = "SelectList";
$class = 'WebGUI::Form::'. $param{fieldType};
my $options = ();
my $tableName = 'Thingy_'.$otherThingId;
my $fieldName = 'field_'.$data->{fieldInOtherThingId};
my $tableName = 'Thingy_'.$otherThingId;
my $fieldName = 'field_'.$data->{fieldInOtherThingId};
my $errorMessage = $self->badOtherThing($tableName, $fieldName);
return $errorMessage if $errorMessage;
@ -1060,10 +1061,10 @@ sub getFormPlugin {
.$dbh->quote_identifier($fieldName)
.' from '.$dbh->quote_identifier($tableName)
.' where thingDataId = ?',[$value]);
$param{size} = 1;
$param{size} = 1;
$param{multiple} = 0;
$param{options} = $options;
$param{value} = $data->{value} || $data->{defaultValue};
$param{options} = $options;
$param{value} = $data->{value} || $data->{defaultValue};
}
my $formElement = eval { WebGUI::Pluggable::instanciate($class, "new", [$session, \%param ])};
@ -2220,53 +2221,53 @@ Processes and saves a field. Returns the edited/added fieldId and the inner html
sub www_editFieldSave {
my $self = shift;
my $self = shift;
my $session = $self->session;
return $session->privilege->insufficient() unless $self->canEdit;
my ($fieldId, $fieldTypeChanged, $newFieldId, $formClass, $dbDataType, $thingyTableName, $columnName);
my (%properties,$listItemHTML,$formElement);
my $i18n = WebGUI::International->new($self->session, "Asset_Thingy");
my $label = $session->form->process("label");
my $thingId = $self->session->form->process("thingId");
my $error = $self->session->errorHandler;
my $i18n = WebGUI::International->new($session, "Asset_Thingy");
my $label = $session->form->process("label");
my $thingId = $session->form->process("thingId");
my $log = $session->log;
my $defaultValue = $session->form->process("defaultValue");
my $fieldType = $session->form->process("fieldType") || "ReadOnly";
my $fieldType = $session->form->process("fieldType") || "ReadOnly";
if ($fieldType =~ m/^otherThing/){
$defaultValue = $session->form->process("defaultFieldInThing");
}
$fieldId = $self->session->form->process("fieldId");
$fieldId = $session->form->process("fieldId");
%properties = (
fieldId=>$fieldId,
thingId=>$thingId,
label=>$label,
fieldType=>$fieldType,
defaultValue=>$defaultValue,
possibleValues=>$self->session->form->process("possibleValues"),
pretext=>$self->session->form->process("pretext"),
subtext=>$self->session->form->process("subtext"),
status=>$self->session->form->process("status"),
size=>$self->session->form->process("size"),
width=>$self->session->form->process("width"),
height=>$self->session->form->process("height"),
vertical=>$self->session->form->process("vertical"),
extras=>$self->session->form->process("extras"),
display=>$self->session->form->process("display") || 1,
viewScreenTitle=>$self->session->form->process("viewScreenTitle") || 0,
fieldInOtherThingId=>$session->form->process("fieldInOtherThingId") || "",
fieldId => $fieldId,
thingId => $thingId,
label => $label,
fieldType => $fieldType,
defaultValue => $defaultValue,
possibleValues => $session->form->process("possibleValues"),
pretext => $session->form->process("pretext"),
subtext => $session->form->process("subtext"),
status => $session->form->process("status"),
size => $session->form->process("size"),
width => $session->form->process("width"),
height => $session->form->process("height"),
vertical => $session->form->process("vertical"),
extras => $session->form->process("extras"),
display => $session->form->process("display") || 1,
viewScreenTitle => $session->form->process("viewScreenTitle") || 0,
fieldInOtherThingId => $session->form->process("fieldInOtherThingId") || "",
);
# Get the field's data type
$dbDataType = $self->_getDbDataType($properties{fieldType});
if ($fieldId eq "new") {
$properties{dateCreated} = time();
$properties{createdBy} = $self->session->user->userId;
$properties{createdBy} = $session->user->userId;
$newFieldId = $self->addField(\%properties,0,$dbDataType);
}
else{
$properties{dateUpdated} = time();
$properties{updatedBy} = $self->session->user->userId;
$properties{updatedBy} = $session->user->userId;
# Check if column has to be altered for existing fields.
$self->_updateFieldType($fieldType,$fieldId,$thingId,$self->get('assetId'),$dbDataType);
$newFieldId = $self->setCollateral("Thingy_fields","fieldId",\%properties,1,1,"thingId",$thingId);
@ -2290,13 +2291,13 @@ sub www_editFieldSave {
$listItemHTML = "<table>\n<tr>\n<td style='width:100px;' valign='top' class='formDescription'>".$label."</td>\n"
."<td style='width:370px;'>".$formElement."</td>\n"
."<td style='width:120px;' valign='top'> <input onClick=\"editListItem('".$self->session->url->page()
."<td style='width:120px;' valign='top'> <input onClick=\"editListItem('".$session->url->page()
."?func=editField;fieldId=".$newFieldId.";thingId=".$properties{thingId}."','".$newFieldId."')\" value='".$i18n->get('Edit','Icon')."' type='button'>"
."<input onClick=\"deleteListItem('".$self->session->url->page()."','".$newFieldId
."<input onClick=\"deleteListItem('".$session->url->page()."','".$newFieldId
."','".$properties{thingId}."')\" value='".$i18n->get('Delete','Icon')."' type='button'></td>\n</tr>\n</table>";
# Make sure we send debug information along with the field.
$session->log->preventDebugOutput;
$log->preventDebugOutput;
$session->output->print($newFieldId.$listItemHTML);
return "chunked";

View file

@ -594,23 +594,27 @@ sub _splitMysql
@hash{ qw( year month day hour minute second ) }
= $string =~ m{
(\d+) # Year
^
\D*
(\d+) # Month
\D*
(\d+) # Day
(?: \D*
(\d+) # Hours
\D*
(\d+) # Minutes
\D*
(\d+) # Seconds
(\d{1,4}) # Year
\D+
(\d{1,2}) # Month
\D+
(\d{1,2}) # Day
(?: \D+
(\d{1,2}) # Hours
\D+
(\d{1,2}) # Minutes
\D+
(\d{1,2}) # Seconds
)?
\D*
$
}x;
foreach my $unit (qw/hour minute second/) {
$hash{$unit} = 0 if ($hash{$unit} eq '');
}
$hash{ hour } ||= 0;
$hash{ minute } ||= 0;
$hash{ second } ||= 0;
return %hash;
}

View file

@ -217,13 +217,14 @@ sub toHtml {
$value = $self->set("value",'');
}
else {
$value = WebGUI::DateTime->new($session, $self->getOriginalValue)->toMysqlDate;
$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' });

View file

@ -220,9 +220,9 @@ Renders a date picker control.
sub toHtml {
my $self = shift;
my $session = $self->session;
my $value = WebGUI::DateTime->new($session, $self->getOriginalValue)
->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;

View file

@ -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;
}

View file

@ -265,7 +265,8 @@ The status of this item. The default is 'NotShipped'. Other statuses include: Ca
sub update {
my ($self, $newProperties) = @_;
my $id = id $self;
my $session = $self->transaction->session;
my $transaction = $self->transaction;
my $session = $transaction->session;
my $taxDriver = WebGUI::Shop::Tax->getDriver( $session );
if (exists $newProperties->{item}) {
@ -296,7 +297,7 @@ sub update {
$newProperties->{ taxConfiguration } =
to_json( $taxDriver->getTransactionTaxData( $sku, $address ) || '{}' );
unless ($sku->isShippingRequired) {
if (!$sku->isShippingRequired && $transaction->get('isSuccessful')) {
$newProperties->{orderStatus} = 'Shipped';
}
}
@ -310,7 +311,7 @@ sub update {
if (exists $newProperties->{options} && ref($newProperties->{options}) eq "HASH") {
$properties{$id}{options} = JSON->new->encode($newProperties->{options});
}
$properties{$id}{lastUpdated} = WebGUI::DateTime->new($self->transaction->session,time())->toDatabase;
$properties{$id}{lastUpdated} = WebGUI::DateTime->new($session,time())->toDatabase;
$self->transaction->session->db->setRow("transactionItem","itemId",$properties{$id});
}

View file

@ -159,6 +159,7 @@ Factored out into a separate subroutine for the sake of testability.
sub getSql {
# Use a left outer join on userProfileData so that we still get back responses for users that have been deleted
return <<END_SQL;
select
r.Survey_responseId, r.username, r.userId, r.startDate,
@ -166,7 +167,7 @@ select
s.timeLimit, s.doAfterTimeLimit,
ad.title, ad.url
from
Survey_response r, Survey s, assetData ad, userProfileData upd
Survey_response r left outer join userProfileData upd on r.userId = upd.userId, Survey s, assetData ad
where
r.isComplete = 0
and s.timeLimit > 0
@ -175,7 +176,6 @@ where
and ad.assetId = s.assetId
and ad.revisionDate = s.revisionDate
and s.revisionDate = r.revisionDate
and upd.userId = r.userId
END_SQL
}

View file

@ -9,8 +9,8 @@ our $I18N = {
},
'allow attachments help' => {
lastUpdated => 0,
message => q|?|,
context => "The number of attachments that are allowed to be placed on each wiki page."
message => q|The number of attachments that are allowed to be placed on each wiki page.|,
context => "Hover help for edit form.",
},
'assetName' => { lastUpdated => 1160157064, message => 'Wiki' },
'asset description' => { lastUpdated => 1160157064, message => q|A wiki is a collaborative content publishing mechanism. Traditionally wiki's use the wiki markup language, but that's generally not much easier to deal with than HTML, so WebGUI's wiki instead just uses a rich editor to help users publish rich great looking content.| },

View file

@ -621,6 +621,12 @@ our $I18N = {
context => q|field label|
},
'Status' => {
message => q|Status|,
lastUpdated => 0,
context => q|Whether a transaction was successful, or not.|
},
'payment method' => {
message => q|Payment Method|,
lastUpdated => 0,
@ -1695,6 +1701,17 @@ our $I18N = {
context => q|commerce setting help|
},
'Success' => {
message => q|Success|,
lastUpdated => 0,
context => q|commerce setting help|
},
'Failed' => {
message => q|Failure|,
lastUpdated => 0,
context => q|commerce setting help|
},
};