Merge commit '4635b91554' into WebGUI8. Syntax clean up to 7.10.2

This commit is contained in:
Colin Kuskie 2010-10-27 15:59:33 -07:00
commit 87326192a3
46 changed files with 956 additions and 969 deletions

View file

@ -1440,7 +1440,7 @@ override processEditForm => sub {
my $assetId = $self->getId;
my $revisionDate = $self->revisionDate;
$session->db->write("UPDATE Event SET sequenceNumber =? WHERE assetId = ? AND revisionDate =?",[($form->param('sequenceNumber') || $top_val), $assetId, $revisionDate]);
$session->db->write("UPDATE Event SET sequenceNumber =? WHERE assetId = ? AND revisionDate =?",[(scalar($form->param('sequenceNumber')) || $top_val), $assetId, $revisionDate]);
# Pre-process Related Links and manage changes

View file

@ -90,6 +90,9 @@ sub _drawQueryBuilder {
"!=" => $i18n->get("isnt")
};
}
$operator{checkList} = {
"+~" => $i18n->get("contains"),
};
$operator{integer} = {
"=" => $i18n->get("equal to"),
"!=" => $i18n->get("not equal to"),
@ -145,6 +148,8 @@ sub _drawQueryBuilder {
# The value select field
my $valFieldName = "val_field".$i;
my $options = $fields->{$field}{possibleValues};
##Only allow one at a time to be selected, and work with current JS for choosing which one.
$fieldType = 'radioList' if $fieldType eq 'checkList';
my $valueField = WebGUI::Form::dynamicField($session,
fieldType=>$fieldType,
name=>$valFieldName,
@ -374,7 +379,6 @@ sub getFieldsList {
foreach my $field (@{WebGUI::ProfileField->getFields($session)}) {
my $fieldId = $field->getId;
next if $fieldId =~ /contentPositions/;
$session->log->warn($fieldId);
$fieldNames{$fieldId} = $field->getLabel.' ['.$fieldId.']';
}
$output .= '<table cellspacing="0" cellpadding="3" border="1"><tr><td><table cellspacing="0" cellpadding="3" border="0">';
@ -388,8 +392,6 @@ sub getFieldsList {
-vertical=>1,
-uiLevel=>9
);
$session->log->warn($list->get('uiLevel'));
$session->log->warn($list->passUiLevelCheck);
$output .= $list->toHtmlWithWrapper;
$output .= '</table></td><td><table cellspacing="0" cellpadding="3" border="0">';
my @prefFieldsToImport = $self->getPrefFieldsToImport;
@ -601,8 +603,8 @@ sub getShortcutByCriteria {
# | | |
# |- $field |_ $operator |- $value
# |_ $attribute |_ $attribute
my $operator = qr/<>|!=|=|>=|<=|>|<|like/i;
my $attribute = qr/['"][^()|=><!]+['"]|[^()|=><!\s]+/i;
my $operator = qr/<>|!=|=|>=|<=|>|<|like|\+~/i;
my $attribute = qr/['"][^()|=><!]+['"]|[^()|=><!\s]+/i;
my $constraint = $criteria;
@ -610,6 +612,7 @@ sub getShortcutByCriteria {
my $db = $self->session->db;
my $counter = "b";
my @joins = ();
##Transform the expression into valid SQL
foreach my $expression ($criteria =~ /($attribute\s*$operator\s*$attribute)/gi) {
# $expression will match "State = Wisconsin"
@ -617,9 +620,10 @@ sub getShortcutByCriteria {
# We need it later.
push(@joins," left join metaData_values ".$counter."_v on a.assetId=".$counter."_v.assetId ");
# Get the field (State) and the value (Wisconsin) from the $expression.
$expression =~ /($attribute)\s*$operator\s*($attribute)/gi;
$expression =~ /($attribute)\s*($operator)\s*($attribute)/gi;
my $field = $1;
my $value = $2;
my $current_operator = $2;
my $value = $3;
# quote the field / value variables.
my $quotedField = $field;
@ -627,18 +631,21 @@ sub getShortcutByCriteria {
unless ($field =~ /^\s*['"].*['"]\s*/) {
$quotedField = $db->quote($field);
}
unless ($value =~ /^\s*['"].*['"]\s*/) {
$quotedValue = $db->quote($value);
}
unless ($value =~ /^\s*['"].*['"]\s*/) {
$quotedValue = $db->quote($value);
}
# transform replacement from "State = Wisconsin" to
# "(fieldname=State and value = Wisconsin)"
my $clause = "(".$counter."_p.fieldName=".$quotedField." and ".$counter."_v.value ";
$replacement =~ s/\Q$field/$clause/;
$replacement =~ s/\Q$value/$quotedValue )/i;
$replacement =~ s/\Q$field/$clause/;
$replacement =~ s/\Q$value/$quotedValue )/i;
# replace $expression with the new $replacement in $constraint.
$constraint =~ s/\Q$expression/$replacement/;
$constraint =~ s/\Q$expression/$replacement/;
if ($current_operator eq '+~') {
$constraint =~ s/and ${counter}_v\.value\s*\+~\s*$quotedValue/and FIND_IN_SET($quotedValue, REPLACE(${counter}_v.value,"\\n",","))/;
}
push (@joins, " left join metaData_properties ".$counter."_p on ".$counter."_p.fieldId=".$counter."_v.fieldId ");
$counter++;
}

View file

@ -2023,7 +2023,7 @@ sub www_importEvents {
-label => $i18n->get('ignore first line'),
-name => 'ignore_first_line',
-hoverHelp => $i18n->get('import hoverhelp first line'),
-defaultValue => $form->param('ignore_first_line'),
-defaultValue => scalar $form->param('ignore_first_line'),
);
# create the std & meta fields part of the form
@ -2040,7 +2040,7 @@ sub www_importEvents {
name => 'fieldsToImport',
defaultValue => \@defaultImportableFields,
options => \%importableFields,
value => $form->get('fieldsToImport'),
value => scalar $form->get('fieldsToImport'),
);
$f->submit(-value=>$i18n->get('import events'));

View file

@ -2610,7 +2610,7 @@ sub www_editThingDataSaveViaAjax {
return '{}';
}
else {
warn "thingId not found in thingProperties\n";
$session->log->warn("thingId ".$thingProperties->{thingId}." not found in thingProperties");
$session->http->setStatus(404);
return JSON->new->encode({message => "The thingId you requested can not be found."});
}

View file

@ -196,6 +196,7 @@ use WebGUI::International;
use HTML::Parser;
use URI::Escape;
use WebGUI::Form;
use WebGUI::Search;
use Clone qw/clone/;
#-------------------------------------------------------------------
@ -993,7 +994,7 @@ sub www_search {
mostPopularUrl=>$self->getUrl("func=mostPopular"),
mostPopularLabel=>$i18n->get("mostPopularLabel"),
wikiHomeUrl=>$self->getUrl,
addPageUrl=>$self->getUrl("func=add;class=WebGUI::Asset::WikiPage;title=".$queryString),
addPageUrl=>$self->getUrl("func=add;class=WebGUI::Asset::WikiPage;title=".$self->session->url->escape($queryString)),
};
$self->appendSearchBoxVars($var, $queryString);
if (length $queryString) {