Merge commit 'v7.10.15' into 8
Conflicts: docs/gotcha.txt docs/previousVersion.sql docs/templates.txt lib/WebGUI.pm lib/WebGUI/Asset.pm lib/WebGUI/Asset/Event.pm lib/WebGUI/Asset/File.pm lib/WebGUI/Asset/MapPoint.pm lib/WebGUI/Asset/RichEdit.pm lib/WebGUI/Asset/Sku/Product.pm lib/WebGUI/Asset/Snippet.pm lib/WebGUI/Asset/Story.pm lib/WebGUI/Asset/Template.pm lib/WebGUI/Asset/Template/TemplateToolkit.pm lib/WebGUI/Asset/Wobject/Calendar.pm lib/WebGUI/Asset/Wobject/Carousel.pm lib/WebGUI/Asset/Wobject/Collaboration.pm lib/WebGUI/Asset/Wobject/Dashboard.pm lib/WebGUI/Asset/Wobject/DataForm.pm lib/WebGUI/Asset/Wobject/Folder.pm lib/WebGUI/Asset/Wobject/Map.pm lib/WebGUI/Asset/Wobject/Search.pm lib/WebGUI/Asset/Wobject/Shelf.pm lib/WebGUI/Asset/Wobject/StockData.pm lib/WebGUI/Asset/Wobject/StoryTopic.pm lib/WebGUI/Asset/Wobject/SyndicatedContent.pm lib/WebGUI/Asset/Wobject/Thingy.pm lib/WebGUI/Asset/Wobject/WeatherData.pm lib/WebGUI/AssetClipboard.pm lib/WebGUI/AssetCollateral/DataForm/Entry.pm lib/WebGUI/AssetExportHtml.pm lib/WebGUI/AssetLineage.pm lib/WebGUI/AssetMetaData.pm lib/WebGUI/AssetTrash.pm lib/WebGUI/AssetVersioning.pm lib/WebGUI/Auth.pm lib/WebGUI/Cache/CHI.pm lib/WebGUI/Content/AssetManager.pm lib/WebGUI/Fork/ProgressBar.pm lib/WebGUI/Form/JsonTable.pm lib/WebGUI/Form/TimeField.pm lib/WebGUI/Form/Zipcode.pm lib/WebGUI/Group.pm lib/WebGUI/International.pm lib/WebGUI/Macro/AssetProxy.pm lib/WebGUI/Macro/FileUrl.pm lib/WebGUI/Operation/SSO.pm lib/WebGUI/Operation/User.pm lib/WebGUI/Role/Asset/Subscribable.pm lib/WebGUI/Shop/Cart.pm lib/WebGUI/Shop/Transaction.pm lib/WebGUI/Shop/TransactionItem.pm lib/WebGUI/Test.pm lib/WebGUI/URL/Content.pm lib/WebGUI/URL/Uploads.pm lib/WebGUI/User.pm lib/WebGUI/Workflow/Activity/ExtendCalendarRecurrences.pm lib/WebGUI/Workflow/Activity/SendNewsletters.pm lib/WebGUI/i18n/English/Asset.pm lib/WebGUI/i18n/English/WebGUI.pm sbin/installClass.pl sbin/rebuildLineage.pl sbin/search.pl sbin/testEnvironment.pl t/Asset/Asset.t t/Asset/AssetClipboard.t t/Asset/AssetLineage.t t/Asset/AssetMetaData.t t/Asset/Event.t t/Asset/File.t t/Asset/File/Image.t t/Asset/Post/notification.t t/Asset/Sku.t t/Asset/Story.t t/Asset/Template.t t/Asset/Wobject/Collaboration/templateVariables.t t/Asset/Wobject/Collaboration/unarchiveAll.t t/Asset/Wobject/Shelf.t t/Auth.t t/Macro/EditableToggle.t t/Macro/FilePump.t t/Shop/Cart.t t/Shop/Transaction.t t/Storage.t t/User.t t/Workflow.t
This commit is contained in:
commit
277faae8a1
783 changed files with 32041 additions and 25495 deletions
|
|
@ -40,7 +40,8 @@ These methods are available from this class:
|
|||
|
||||
=head2 addMetaDataField ( )
|
||||
|
||||
Adds a new field to the metadata system, or edit an existing one.
|
||||
Adds a new field to the metadata system, or edit an existing one. The id of
|
||||
the field is returned.
|
||||
|
||||
=head3 fieldId
|
||||
|
||||
|
|
@ -68,6 +69,10 @@ The form field type for metaData: selectBox, text, integer, or checkList, yesNo,
|
|||
For fields that provide options, the list of options. This is a string with
|
||||
newline separated values.
|
||||
|
||||
=head3 classes
|
||||
|
||||
An arrayref of classnames that this metadata field applies to
|
||||
|
||||
=cut
|
||||
|
||||
sub addMetaDataField {
|
||||
|
|
@ -79,18 +84,31 @@ sub addMetaDataField {
|
|||
my $description = shift || '';
|
||||
my $fieldType = shift;
|
||||
my $possibleValues = shift;
|
||||
my $classes = shift;
|
||||
my $db = $self->session->db;
|
||||
|
||||
if($fieldId eq 'new') {
|
||||
$fieldId = $self->session->id->generate();
|
||||
$self->session->db->write("insert into metaData_properties (fieldId, fieldName, defaultValue, description, fieldType, possibleValues) values (?,?,?,?,?,?)",
|
||||
$db->write("insert into metaData_properties (fieldId, fieldName, defaultValue, description, fieldType, possibleValues) values (?,?,?,?,?,?)",
|
||||
[ $fieldId, $fieldName, $defaultValue, $description, $fieldType, $possibleValues, ]
|
||||
);
|
||||
}
|
||||
else {
|
||||
$self->session->db->write("update metaData_properties set fieldName = ?, defaultValue = ?, description = ?, fieldType = ?, possibleValues = ? where fieldId = ?",
|
||||
$db->write("update metaData_properties set fieldName = ?, defaultValue = ?, description = ?, fieldType = ?, possibleValues = ? where fieldId = ?",
|
||||
[ $fieldName, $defaultValue, $description, $fieldType, $possibleValues, $fieldId, ]
|
||||
);
|
||||
$db->write('delete from metaData_classes where fieldId=?', [$fieldId]);
|
||||
}
|
||||
|
||||
if ($classes && @$classes) {
|
||||
my $qfid = $db->quote($fieldId);
|
||||
$db->write('insert into metaData_classes (fieldId, className) values '
|
||||
.join(', ',
|
||||
map { my $q = $db->quote($_); "($qfid, $q)" } @$classes
|
||||
));
|
||||
}
|
||||
|
||||
return $fieldId;
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -109,12 +127,57 @@ The fieldId to be deleted.
|
|||
sub deleteMetaDataField {
|
||||
my $self = shift;
|
||||
my $fieldId = shift;
|
||||
$self->session->db->beginTransaction;
|
||||
$self->session->db->write("delete from metaData_properties where fieldId = ?",[$fieldId]);
|
||||
$self->session->db->write("delete from metaData_values where fieldId = ?",[$fieldId]);
|
||||
$self->session->db->commit;
|
||||
my $db = $self->session->db;
|
||||
$db->beginTransaction;
|
||||
for my $table (map { "metaData_$_" } qw(properties values classes)) {
|
||||
$db->write("delete from $table where fieldId = ?", [ $fieldId ]);
|
||||
}
|
||||
$db->commit;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getMetaDataAsFormFields
|
||||
|
||||
Returns a hashref of metadata field names WebGUI::Form objects appropriate
|
||||
for use on edit forms.
|
||||
|
||||
=cut
|
||||
|
||||
sub getMetaDataAsFormFields {
|
||||
my $self = shift;
|
||||
my $session = $self->session;
|
||||
my $i18n = WebGUI::International->new($session, 'Asset');
|
||||
my $fields = $self->getMetaDataFields;
|
||||
my %hash;
|
||||
for my $fid (keys %$fields) {
|
||||
my $info = $fields->{$fid};
|
||||
my $type = lcfirst ($info->{fieldType} || 'text');
|
||||
my $name = $info->{fieldName};
|
||||
my $options = $info->{possibleValues};
|
||||
if($type eq 'selectBox') {
|
||||
my $label = $i18n->get('Select');
|
||||
$options = "|$label\n$options";
|
||||
}
|
||||
my $formClass = ucfirst $type;
|
||||
$hash{$name} = WebGUI::Pluggable::instanciate(
|
||||
"WebGUI::Form::$formClass",
|
||||
'new',
|
||||
[
|
||||
$session, {
|
||||
name => "metadata_$fid",
|
||||
label => $name,
|
||||
value => $info->{value},
|
||||
extras => qq'title="$info->{description}"',
|
||||
defaultValue => $info->{defaultValue},
|
||||
fieldType => $type,
|
||||
options => $options,
|
||||
}
|
||||
]
|
||||
)->toHtml;
|
||||
};
|
||||
\%hash;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
|
|
@ -140,21 +203,11 @@ sub getMetaDataAsTemplateVariables {
|
|||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getMetaDataFields ( [fieldId] )
|
||||
|
||||
Returns a hash reference containing all metadata field properties for this Asset.
|
||||
You can limit the output to a certain field by specifying a fieldId.
|
||||
|
||||
=head3 fieldId
|
||||
|
||||
If specified, the hashRef will contain only this field.
|
||||
|
||||
=cut
|
||||
|
||||
sub getMetaDataFields {
|
||||
sub _getMetaDataFieldsHelper {
|
||||
my $self = shift;
|
||||
my $fieldId = shift;
|
||||
my $session = $self->session;
|
||||
my $listAll = shift || $fieldId;
|
||||
my $db = $self->session->db;
|
||||
my $sql = "select
|
||||
f.fieldId,
|
||||
f.fieldName,
|
||||
|
|
@ -164,19 +217,76 @@ sub getMetaDataFields {
|
|||
f.possibleValues,
|
||||
d.value
|
||||
from metaData_properties f
|
||||
left join metaData_values d on f.fieldId=d.fieldId and d.assetId=".$session->db->quote($self->getId);
|
||||
$sql .= " where f.fieldId = ".$session->db->quote($fieldId) if ($fieldId);
|
||||
$sql .= " order by f.fieldName";
|
||||
if ($fieldId) {
|
||||
return $session->db->quickHashRef($sql);
|
||||
}
|
||||
else {
|
||||
tie my %hash, 'Tie::IxHash';
|
||||
%hash = %{ $session->db->buildHashRefOfHashRefs($sql, [], 'fieldId') };
|
||||
return \%hash;
|
||||
}
|
||||
left join metaData_values d
|
||||
on f.fieldId=d.fieldId
|
||||
and d.assetId=?
|
||||
and d.revisionDate = ?
|
||||
";
|
||||
|
||||
my @where;
|
||||
my @place = ($self->getId, $self->get('revisionDate'));
|
||||
unless ($listAll) {
|
||||
# Either there's no class info stored for this field or this class is
|
||||
# one of them.
|
||||
push @where, q{
|
||||
not exists (
|
||||
select * from metaData_classes where fieldId = f.fieldId
|
||||
)
|
||||
or exists (
|
||||
select *
|
||||
from metaData_classes
|
||||
where className = ?
|
||||
and fieldId = f.fieldId
|
||||
)
|
||||
};
|
||||
push @place, ref $self;
|
||||
}
|
||||
|
||||
if ($fieldId) {
|
||||
push @where, 'f.fieldId = ?';
|
||||
push @place, $fieldId;
|
||||
}
|
||||
|
||||
if (@where) {
|
||||
$sql .= 'where ' . join(' AND ', map { "($_)" } @where);
|
||||
}
|
||||
|
||||
my $hash = $db->buildHashRefOfHashRefs( $sql, \@place, 'fieldId' );
|
||||
|
||||
return $fieldId ? $hash->{$fieldId} : $hash;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getAllMetaDataFields
|
||||
|
||||
getMetaDataFields without bothering about whether they apply to this class.
|
||||
|
||||
=cut
|
||||
|
||||
sub getAllMetaDataFields {
|
||||
my $self = shift;
|
||||
return $self->_getMetaDataFieldsHelper(undef, 1);
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getMetaDataFields ( [fieldId] )
|
||||
|
||||
Returns a hash reference containing all metadata field properties for this Asset.
|
||||
You can limit the output to a certain field by specifying a fieldId.
|
||||
|
||||
=head3 fieldId
|
||||
|
||||
If specified, the hashRef will contain only this field. In this case, you will
|
||||
get that metadata field if it exists whether it applies to this asset or not.
|
||||
|
||||
=cut
|
||||
|
||||
sub getMetaDataFields {
|
||||
my ($self, $fieldId) = @_;
|
||||
return $self->_getMetaDataFieldsHelper($fieldId);
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
|
|
@ -198,17 +308,10 @@ sub updateMetaData {
|
|||
my $self = shift;
|
||||
my $fieldId = shift;
|
||||
my $value = shift;
|
||||
my $db = $self->session->db;
|
||||
my ($exists) = $db->quickArray("select count(*) from metaData_values where assetId = ? and fieldId = ?",[$self->getId, $fieldId]);
|
||||
if (!$exists && $value ne "") {
|
||||
$db->write("insert into metaData_values (fieldId, assetId) values (?,?)",[$fieldId, $self->getId]);
|
||||
}
|
||||
if ($value eq "") { # Keep it clean
|
||||
$db->write("delete from metaData_values where assetId = ? and fieldId = ?",[$self->getId, $fieldId]);
|
||||
}
|
||||
else {
|
||||
$db->write("update metaData_values set value = ? where assetId = ? and fieldId=?", [$value, $self->getId, $fieldId]);
|
||||
}
|
||||
$self->session->db->write(
|
||||
'replace into metaData_values (fieldId, assetId, revisionDate, value) values (?, ?, ?, ?)',
|
||||
[$fieldId, $self->getId, $self->get('revisionDate'), $value]
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -279,7 +382,49 @@ sub www_editMetaDataField {
|
|||
value=>$fieldInfo->{fieldType} || "text",
|
||||
types=> [ qw /text integer yesNo selectBox radioList checkList/ ]
|
||||
);
|
||||
$f->addField( "textarea",
|
||||
|
||||
my $default = ref WebGUI::Asset->assetName eq 'ARRAY'
|
||||
? WebGUI::International->new( $self->session )->get( @{WebGUI::Asset->assetName} )
|
||||
: WebGUI::Asset->assetName;
|
||||
my %classOptions;
|
||||
# usedNames maps a name to a class. If a name exists there, it has been
|
||||
# used. If it maps to a classname, that classname needs to be renamed.
|
||||
my %usedNames;
|
||||
for my $class (WebGUI::Pluggable::findAndLoad('WebGUI::Asset')) {
|
||||
next unless $class->isa('WebGUI::Asset');
|
||||
my $name = ref $class->assetName eq 'ARRAY'
|
||||
? WebGUI::International->new( $self->session )->get( @{$class->assetName} )
|
||||
: $class->assetName;
|
||||
next unless $name; # abstract classes (e.g. wobject) don't have names
|
||||
|
||||
# We don't want things named "Asset".
|
||||
if ($name eq $default) {
|
||||
$name = $class;
|
||||
}
|
||||
elsif (exists $usedNames{$name}) {
|
||||
if (my $rename = $usedNames{$name}) {
|
||||
$classOptions{$rename} = "$name ($rename)";
|
||||
undef $usedNames{$name};
|
||||
}
|
||||
$name = "$name ($class)";
|
||||
}
|
||||
$usedNames{$name} = $class;
|
||||
$classOptions{$class} = $name;
|
||||
}
|
||||
|
||||
$f->addField( "selectList",
|
||||
name => 'classes',
|
||||
label => $i18n->get('Allowed Classes'),
|
||||
hoverHelp => $i18n->get('Allowed Classes hoverHelp'),
|
||||
options => \%classOptions,
|
||||
defaultValue => $fid ne 'new' && $self->session->db->buildArrayRef(
|
||||
'select className from metaData_classes where fieldId = ?',
|
||||
[ $fid ]
|
||||
),
|
||||
sortByValue => 1,
|
||||
);
|
||||
|
||||
$f->addField( "textarea",
|
||||
name=>"possibleValues",
|
||||
label=>$i18n->get(487),
|
||||
hoverHelp=>$i18n->get('Possible Values description'),
|
||||
|
|
@ -332,6 +477,7 @@ sub www_editMetaDataFieldSave {
|
|||
$self->session->form->process("description") || '',
|
||||
$self->session->form->process("fieldType"),
|
||||
$self->session->form->process("possibleValues"),
|
||||
[ $self->session->form->process("classes") ],
|
||||
);
|
||||
|
||||
return $self->www_manageMetaData;
|
||||
|
|
@ -353,7 +499,7 @@ sub www_manageMetaData {
|
|||
my $i18n = WebGUI::International->new($self->session,"Asset");
|
||||
$ac->addSubmenuItem($self->getUrl('func=editMetaDataField'), $i18n->get("Add new field"));
|
||||
my $output;
|
||||
my $fields = $self->getMetaDataFields();
|
||||
my $fields = $self->getAllMetaDataFields;
|
||||
foreach my $fieldId (keys %{$fields}) {
|
||||
$output .= $self->session->icon->delete("func=deleteMetaDataField;fid=".$fieldId,$self->get("url"),$i18n->get('deleteConfirm'));
|
||||
$output .= $self->session->icon->edit("func=editMetaDataField;fid=".$fieldId,$self->get("url"));
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue