first run on new asset system
This commit is contained in:
parent
f7dd3b0577
commit
382ced9ffe
27 changed files with 785 additions and 374 deletions
|
|
@ -4,16 +4,23 @@ use strict;
|
|||
use WebGUI::Grouping;
|
||||
use WebGUI::International;
|
||||
use WebGUI::Session;
|
||||
use WebGUI::Style;
|
||||
use WebGUI::Template;
|
||||
use WebGUI::URL;
|
||||
|
||||
sub _formatFunction {
|
||||
my $self = shift;
|
||||
my $function = shift;
|
||||
my $url;
|
||||
if (exists $function->{func}) {
|
||||
$url = WebGUI::URL::page("func=".$function->{func});
|
||||
} else {
|
||||
$url = WebGUI::URL::page("op=".$function->{op});
|
||||
}
|
||||
return {
|
||||
title=>WebGUI::International::get($function->{title}{id}, $function->{title}{namespace}),
|
||||
icon=>$session{config}{extrasURL}."/adminConsole/".$function->{icon},
|
||||
url=>WebGUI::URL::page("op=".$function->{op}),
|
||||
url=>$url,
|
||||
canUse=>WebGUI::Grouping::isInGroup($function->{group})
|
||||
};
|
||||
}
|
||||
|
|
@ -46,7 +53,7 @@ sub getAdminFunction {
|
|||
namespace=>"Asset"
|
||||
},
|
||||
icon=>"assets.gif",
|
||||
op=>"manageAssets",
|
||||
func=>"manageAssets",
|
||||
group=>"12"
|
||||
},
|
||||
"users"=>{
|
||||
|
|
@ -267,8 +274,7 @@ sub render {
|
|||
$var{"console.icon"} = $acParams->{icon};
|
||||
$var{"help.url"} = $self->{_helpUrl};
|
||||
$var{"application_loop"} = $self->getAdminFunction;
|
||||
$session{page}{useAdminStyle} = 1;
|
||||
return WebGUI::Template::process($session{setting}{AdminConsoleTemplate}, "AdminConsole", \%var);
|
||||
return WebGUI::Style::process(WebGUI::Template::process($session{setting}{AdminConsoleTemplate}, "AdminConsole", \%var),"adminConsole");
|
||||
}
|
||||
|
||||
sub setHelp {
|
||||
|
|
@ -278,5 +284,13 @@ sub setHelp {
|
|||
$self->{_helpUrl} = WebGUI::URL::page('op=viewHelp&hid='.$id.'&namespace='.$namespace) if ($id);
|
||||
}
|
||||
|
||||
sub setIcon {
|
||||
my $self = shift;
|
||||
my $icon = shift;
|
||||
if ($icon) {
|
||||
$self->{_function}{icon} = $icon;
|
||||
}
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
|
|
|
|||
|
|
@ -3,8 +3,14 @@ package WebGUI::Asset;
|
|||
#needs documentation
|
||||
|
||||
use strict;
|
||||
use Tie::IxHash;
|
||||
use WebGUI::Clipboard;
|
||||
use WebGUI::DateTime;
|
||||
use WebGUI::ErrorHandler;
|
||||
use WebGUI::Form;
|
||||
use WebGUI::Grouping;
|
||||
use WebGUI::HTTP;
|
||||
use WebGUI::Icon;
|
||||
use WebGUI::Id;
|
||||
use WebGUI::Privilege;
|
||||
use WebGUI::Session;
|
||||
|
|
@ -22,14 +28,13 @@ sub addChild {
|
|||
values (".quote($id).",".quote($self->getId).", ".quote($lineage).",
|
||||
'published', ".quote($properties->{className}).", ".quote($id).",
|
||||
997995720, 9223372036854775807)");
|
||||
foreach my $definition (@{$self->{definition}}) {
|
||||
foreach my $definition (@{$self->definition}) {
|
||||
unless ($definition->{tableName} eq "asset") {
|
||||
WebGUI::SQL->write("insert into ".$definition->{tableName}." (assetId) values (".quote($id).")");
|
||||
}
|
||||
}
|
||||
WebGUI::SQL->commit;
|
||||
my $className = $properties->{className};
|
||||
my $newAsset = $className->new($id);
|
||||
my $newAsset = WebGUI::Asset->newByDynamicClass($id, $properties->{className});
|
||||
$newAsset->update($properties);
|
||||
return $newAsset;
|
||||
}
|
||||
|
|
@ -46,9 +51,10 @@ sub canEdit {
|
|||
sub canView {
|
||||
my $self = shift;
|
||||
my $userId = shift || $session{user}{userId};
|
||||
return 0 unless ($self->get("state") eq "published");
|
||||
if ($userId eq $self->get("ownerUserId")) {
|
||||
return 1;
|
||||
} elsif ($self->get("startDate") < time() &&
|
||||
} elsif ( $self->get("startDate") < time() &&
|
||||
$self->get("endDate") > time() &&
|
||||
WebGUI::Grouping::isInGroup($self->get("groupIdView"),$userId)) {
|
||||
return 1;
|
||||
|
|
@ -75,8 +81,9 @@ sub cut {
|
|||
|
||||
sub definition {
|
||||
my $class = shift;
|
||||
my $definition = shift;
|
||||
push(@{$definition}, {
|
||||
my $definition = shift || [];
|
||||
my @newDef = @{$definition};
|
||||
push(@newDef, {
|
||||
tableName=>'asset',
|
||||
className=>'WebGUI::Asset',
|
||||
properties=>{
|
||||
|
|
@ -117,18 +124,13 @@ sub definition {
|
|||
fieldType=>'dateTime',
|
||||
defaultValue=>undef
|
||||
},
|
||||
assetSize=>{
|
||||
fieldType=>'hidden',
|
||||
defaultValue=>0
|
||||
}
|
||||
}
|
||||
});
|
||||
return $definition;
|
||||
}
|
||||
|
||||
sub delete {
|
||||
my $self = shift;
|
||||
WebGUI::SQL->beginTransaction;
|
||||
WebGUI::SQL->write("update asset set state='limbo' where lineage like ".quote($self->get("lineage").'%'));
|
||||
WebGUI::SQL->write("update asset set state='trash' where assetId=".quote($self->getId));
|
||||
WebGUI::SQL->commit;
|
||||
$self->{_properties}{state} = "trash";
|
||||
return \@newDef;
|
||||
}
|
||||
|
||||
sub demote {
|
||||
|
|
@ -148,6 +150,7 @@ sub duplicate {
|
|||
return $newAsset;
|
||||
}
|
||||
|
||||
|
||||
sub fixUrl {
|
||||
my $self = shift;
|
||||
my $url = WebGUI::URL::urlize(shift);
|
||||
|
|
@ -197,9 +200,33 @@ sub getAdminConsole {
|
|||
unless (exists $self->{_adminConsole}) {
|
||||
$self->{_adminConsole} = WebGUI::AdminConsole->new("assets");
|
||||
}
|
||||
$self->{_adminConsole}->setIcon($self->getIcon);
|
||||
return $self->{_adminConsole};
|
||||
}
|
||||
|
||||
sub getAssetAdderLinks {
|
||||
my $self = shift;
|
||||
my @links;
|
||||
foreach my $class (@{$session{config}{assets}}) {
|
||||
my $load = "use ".$class;
|
||||
eval ($load);
|
||||
if ($@) {
|
||||
WebGUI::ErrorHandler::warn("Couldn't compile ".$class." because ".$@);
|
||||
} else {
|
||||
my $label = eval{$class->getName()};
|
||||
if ($@) {
|
||||
WebGUI::ErrorHandler::warn("Couldn't get the name of ".$class." because ".$@);
|
||||
} else {
|
||||
push(@links, {
|
||||
label=>$label,
|
||||
url=>$self->getUrl("func=add&class=".$class)
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
return \@links;
|
||||
}
|
||||
|
||||
sub getEditForm {
|
||||
my $self = shift;
|
||||
my $tabform = WebGUI::TabForm->new();
|
||||
|
|
@ -213,7 +240,13 @@ sub getEditForm {
|
|||
value=>"1"
|
||||
});
|
||||
}
|
||||
$tabform->add("properties",WebGUI::International::get("properties","Asset"));
|
||||
if ($session{form}{afterEdit}) {
|
||||
$tabform->hidden({
|
||||
name=>"afterEdit",
|
||||
value=>$session{form}{afterEdit}
|
||||
});
|
||||
}
|
||||
$tabform->addTab("properties",WebGUI::International::get("properties","Asset"));
|
||||
$tabform->getTab("properties")->readOnly(
|
||||
-label=>WebGUI::International::get("asset id","Asset"),
|
||||
-value=>$self->get("assetId")
|
||||
|
|
@ -259,7 +292,7 @@ sub getEditForm {
|
|||
-value=>$self->get("synopsis"),
|
||||
-uiLevel=>3
|
||||
);
|
||||
$tabform->add("privileges",WebGUI::International::get(107),6);
|
||||
$tabform->addTab("privileges",WebGUI::International::get(107),6);
|
||||
$tabform->getTab("privileges")->dateTime(
|
||||
-name=>"startDate",
|
||||
-label=>WebGUI::International::get(497),
|
||||
|
|
@ -287,7 +320,7 @@ sub getEditForm {
|
|||
$clause = "userId=".quote($self->get("ownerUserId"));
|
||||
}
|
||||
my $users = WebGUI::SQL->buildHashRef("select userId,username from users where $clause order by username");
|
||||
$tabform->getTab("privileges")->select(
|
||||
$tabform->getTab("privileges")->selectList(
|
||||
-name=>"ownerUserId",
|
||||
-options=>$users,
|
||||
-label=>WebGUI::International::get(108),
|
||||
|
|
@ -311,6 +344,15 @@ sub getEditForm {
|
|||
return $tabform;
|
||||
}
|
||||
|
||||
|
||||
sub getIcon {
|
||||
my $self = shift;
|
||||
my $small = shift;
|
||||
return $session{config}{extrasURL}.'/adminConsole/small/assets.gif' if ($small);
|
||||
return $session{config}{extrasURL}.'/adminConsole/assets.gif';
|
||||
}
|
||||
|
||||
|
||||
sub getId {
|
||||
my $self = shift;
|
||||
return $self->get("assetId");
|
||||
|
|
@ -329,28 +371,19 @@ sub getIndexerParams {
|
|||
}
|
||||
|
||||
|
||||
sub getName {
|
||||
return WebGUI::International::get('asset','Asset');
|
||||
}
|
||||
|
||||
sub getNextChildRank {
|
||||
my $self = shift;
|
||||
my ($lineage) = WebGUI::SQL->quickArray("select max(lineage) from asset where parentId=".quote($self->getId));
|
||||
my $rank;
|
||||
if (defined $lineage) {
|
||||
$rank = $self->getRank($lineage);
|
||||
$rank++;
|
||||
} else {
|
||||
$rank = 1;
|
||||
}
|
||||
return $self->formatRank($rank);
|
||||
}
|
||||
|
||||
sub getLineage {
|
||||
my $self = shift;
|
||||
my $relatives = shift;
|
||||
my $rules = shift;
|
||||
my $lineage = $self->get("lineage");
|
||||
my $whereExclusion = " and state='published'";
|
||||
if (exists $rules->{excludeClasses}) {
|
||||
my @set;
|
||||
foreach my $className (@{$rules->{excludeClasses}}) {
|
||||
push(@set,"className <> ".quote($className));
|
||||
}
|
||||
$whereExclusion .= 'and ('.join(" and ",@set).')';
|
||||
}
|
||||
my $whereSiblings;
|
||||
if (isIn("siblings",@{$relatives})) {
|
||||
$whereSiblings = "(parentId=".quote($self->get("parentId"))." and assetId<>".quote($self->getId).")";
|
||||
|
|
@ -379,15 +412,17 @@ sub getLineage {
|
|||
if ($whereSiblings ne "" || $whereExact ne "") {
|
||||
$whereDescendants = " or ";
|
||||
}
|
||||
my $lineageLength = length($lineage);
|
||||
$whereDescendants .= "lineage like ".quote($lineage.'%')." and length(lineage)> ".$lineageLength;
|
||||
$whereDescendants .= "lineage like ".quote($lineage.'%')." and lineage<>".quote($lineage);
|
||||
if (exists $rules->{endingLineageLength}) {
|
||||
$whereDescendants .= " and length(lineage) <= ".($rules->{endingLineageLength}*6);
|
||||
}
|
||||
}
|
||||
my $sql = "select assetId from asset where $whereSiblings $whereExact $whereDescendants order by lineage";
|
||||
my $sql = "select assetId,className from asset where $whereSiblings $whereExact $whereDescendants $whereExclusion order by lineage";
|
||||
my @lineage;
|
||||
my $sth = WebGUI::SQL->read($sql);
|
||||
while (my ($assetId) = $sth->array) {
|
||||
if ($rules->{returnOjbects}) {
|
||||
push(@lineage,WebGUI::Asset->new($assetId);
|
||||
while (my ($assetId,$className) = $sth->array) {
|
||||
if ($rules->{returnObjects}) {
|
||||
push(@lineage,WebGUI::Asset->newByDynamicClass($assetId, $className));
|
||||
} else {
|
||||
push(@lineage,$assetId);
|
||||
}
|
||||
|
|
@ -396,9 +431,31 @@ sub getLineage {
|
|||
return \@lineage;
|
||||
}
|
||||
|
||||
sub getLineageLength {
|
||||
my $self = shift;
|
||||
return length($self->get("lineage"))/6;
|
||||
}
|
||||
|
||||
sub getName {
|
||||
return WebGUI::International::get('asset','Asset');
|
||||
}
|
||||
|
||||
sub getNextChildRank {
|
||||
my $self = shift;
|
||||
my ($lineage) = WebGUI::SQL->quickArray("select max(lineage) from asset where parentId=".quote($self->getId));
|
||||
my $rank;
|
||||
if (defined $lineage) {
|
||||
$rank = $self->getRank($lineage);
|
||||
$rank++;
|
||||
} else {
|
||||
$rank = 1;
|
||||
}
|
||||
return $self->formatRank($rank);
|
||||
}
|
||||
|
||||
sub getParent {
|
||||
my $self = shift;
|
||||
return WebGUI::Asset->new($self->get("parentId"));
|
||||
return WebGUI::Asset->newByDynamicClass($self->get("parentId"));
|
||||
}
|
||||
|
||||
sub getParentLineage {
|
||||
|
|
@ -421,6 +478,12 @@ sub getUiLevel {
|
|||
return 0;
|
||||
}
|
||||
|
||||
sub getUrl {
|
||||
my $self = shift;
|
||||
my $params = shift;
|
||||
return WebGUI::URL::gateway($self->get("url"),$params);
|
||||
}
|
||||
|
||||
sub getValue {
|
||||
my $self = shift;
|
||||
my $key = shift;
|
||||
|
|
@ -437,6 +500,12 @@ sub getValue {
|
|||
return undef;
|
||||
}
|
||||
|
||||
sub hasChildren {
|
||||
my $self = shift;
|
||||
my ($hasChildren) = WebGUI::SQL->read("select count(*) from asset where parentId=".quote($self->getId));
|
||||
return $hasChildren;
|
||||
}
|
||||
|
||||
sub new {
|
||||
my $class = shift;
|
||||
my $assetId = shift;
|
||||
|
|
@ -457,23 +526,75 @@ sub new {
|
|||
$sql .= " where asset.assetId=".quote($assetId);
|
||||
$properties = WebGUI::SQL->quickHashRef($sql);
|
||||
return undef unless (exists $properties->{assetId});
|
||||
foreach my $property (keys %{$overrideProperties}) {
|
||||
unless (isIn($property, qw(assetId className parentId lineage state))) {
|
||||
$properties->{$property} = $overrideProperties->{$property};
|
||||
}
|
||||
}
|
||||
}
|
||||
if (defined $overrideProperties) {
|
||||
foreach my $definition (@{$class->definition}) {
|
||||
foreach my $property (keys %{$definition->{properties}}) {
|
||||
if (exists $overrideProperties->{$property}) {
|
||||
$properties->{$property} = $overrideProperties->{$property};
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (defined $properties) {
|
||||
return bless { _properties=>$properties }, $class;
|
||||
my $object = { _properties => $properties };
|
||||
bless $object, $class;
|
||||
return $object;
|
||||
}
|
||||
return undef;
|
||||
}
|
||||
|
||||
|
||||
sub newByDynamicClass {
|
||||
my $class = shift;
|
||||
my $assetId = shift;
|
||||
my $className = shift;
|
||||
unless (defined $className) {
|
||||
($className) = WebGUI::SQL->quickArray("select className from asset where assetId=".quote($assetId));
|
||||
}
|
||||
if ($className eq "") {
|
||||
WebGUI::HTTP::setStatus('404',"Page Not Found");
|
||||
WebGUI::ErrorHandler::fatalError("The page not found page doesn't exist.") if ($assetId eq $session{setting}{notFoundPage});
|
||||
return WebGUI::Asset->newByDynamicClass($session{setting}{notFoundPage});
|
||||
}
|
||||
my $cmd = "use ".$className;
|
||||
eval ($cmd);
|
||||
WebGUI::ErrorHandler::fatalError("Couldn't compile asset package: ".$className.". Root cause: ".$@) if ($@);
|
||||
my $assetObject = eval{$className->new($assetId)};
|
||||
WebGUI::ErrorHandler::fatalError("Couldn't create asset instance for ".$assetId.". Root cause: ".$@) if ($@);
|
||||
return $assetObject;
|
||||
}
|
||||
|
||||
|
||||
sub newByUrl {
|
||||
my $class = shift;
|
||||
my $url = shift || $session{env}{PATH_INFO};
|
||||
$url = lc($url);
|
||||
$url =~ s/\/$//;
|
||||
$url =~ s/^\///;
|
||||
$url =~ s/\'//;
|
||||
$url =~ s/\"//;
|
||||
my $asset;
|
||||
if ($url ne "") {
|
||||
$asset = WebGUI::SQL->quickHashRef("select assetId, className from asset where url=".quote($url));
|
||||
return WebGUI::Asset->newByDynamicClass($asset->{assetId}, $asset->{className});
|
||||
}
|
||||
return $class->newByDynamicClass($session{setting}{defaultPage});
|
||||
}
|
||||
|
||||
|
||||
sub republish {
|
||||
my $self = shift;
|
||||
WebGUI::SQL->write("update asset set state='published' where lineage like ".quote($self->get("lineage").'%'));
|
||||
$self->{_properties}{state} = "published";
|
||||
}
|
||||
|
||||
sub paste {
|
||||
my $self = shift;
|
||||
my $newParentId = shift;
|
||||
if ($self->setParent($newParentId)) {
|
||||
WebGUI::SQL->write("update asset set state='published' where lineage like ".quote($self->get("lineage").'%'));
|
||||
my $assetId = shift;
|
||||
my $pastedAsset = WebGUI::Asset->new($assetId);
|
||||
if ($self->getId eq $pastedAsset->get("parentId") || $pastedAsset->setParent($self->getId)) {
|
||||
$pastedAsset->republish;
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
|
|
@ -508,6 +629,7 @@ sub setParent {
|
|||
my $self = shift;
|
||||
my $newParentId = shift;
|
||||
return 0 if ($newParentId eq $self->get("parentId")); # don't move it to where it already is
|
||||
return 0 if ($newParentId eq $self->getId); # don't move it to itself
|
||||
my $parent = WebGUI::Asset->new($newParentId);
|
||||
if (defined $parent) {
|
||||
my $oldLineage = $self->get("lineage");
|
||||
|
|
@ -549,6 +671,16 @@ sub setRank {
|
|||
return 1;
|
||||
}
|
||||
|
||||
sub setSize {
|
||||
my $self = shift;
|
||||
my $extra = shift;
|
||||
my $sizetest;
|
||||
foreach my $key (keys %{$self->get}) {
|
||||
$sizetest .= $self->get($key);
|
||||
}
|
||||
WebGUI::SQL->write("update asset set assetSize=".(length($sizetest)+$extra)." where assetId=".quote($self->getId));
|
||||
}
|
||||
|
||||
sub swapRank {
|
||||
my $self = shift;
|
||||
my $second = shift;
|
||||
|
|
@ -563,17 +695,30 @@ sub swapRank {
|
|||
}
|
||||
|
||||
|
||||
sub trash {
|
||||
my $self = shift;
|
||||
WebGUI::SQL->beginTransaction;
|
||||
WebGUI::SQL->write("update asset set state='limbo' where lineage like ".quote($self->get("lineage").'%'));
|
||||
WebGUI::SQL->write("update asset set state='trash' where assetId=".quote($self->getId));
|
||||
WebGUI::SQL->commit;
|
||||
$self->{_properties}{state} = "trash";
|
||||
}
|
||||
|
||||
sub update {
|
||||
my $self = shift;
|
||||
my $properties = shift;
|
||||
WebGUI::SQL->beginTransaction;
|
||||
foreach my $definition (@{$self->definition}) {
|
||||
my @setPairs;
|
||||
if ($definition->{tableName} eq "asset") {
|
||||
push(@setPairs,"lastUpdated=".time());
|
||||
}
|
||||
foreach my $property (keys %{$definition->{properties}}) {
|
||||
my $value = $properties->{$property} || $definition->{properties}{$property}{defaultValue};
|
||||
if (defined $value) {
|
||||
if (exists $definition->{properties}{$property}{filter}) {
|
||||
$value = $self->$definition->{properties}{$property}{filter}($value);
|
||||
my $filter = $definition->{properties}{$property}{filter};
|
||||
$value = $self->$filter($value);
|
||||
}
|
||||
$self->{_properties}{$property} = $value;
|
||||
push(@setPairs, $property."=".quote($value));
|
||||
|
|
@ -583,6 +728,7 @@ sub update {
|
|||
WebGUI::SQL->write("update ".$definition->{tableName}." set ".join(",",@setPairs)." where assetId=".quote($self->getId));
|
||||
}
|
||||
}
|
||||
$self->setSize;
|
||||
WebGUI::SQL->commit;
|
||||
return 1;
|
||||
}
|
||||
|
|
@ -596,18 +742,57 @@ sub www_copy {
|
|||
return "";
|
||||
}
|
||||
|
||||
sub www_copyList {
|
||||
my $self = shift;
|
||||
return WebGUI::Privilege::insufficient() unless $self->canEdit;
|
||||
my $newAsset = $self->duplicate;
|
||||
$newAsset->cut;
|
||||
foreach my $assetId ($session{cgi}->param("assetId")) {
|
||||
my $asset = WebGUI::Asset->newByDynamicClass($assetId);
|
||||
if ($asset->canEdit) {
|
||||
my $newAsset = $asset->duplicate;
|
||||
$newAsset->cut;
|
||||
}
|
||||
}
|
||||
return $self->manageAssets();
|
||||
}
|
||||
|
||||
sub www_cut {
|
||||
my $self = shift;
|
||||
return WebGUI::Privilege::insufficient() unless $self->canEdit;
|
||||
$self->cut;
|
||||
return "";
|
||||
return $self->getParent->www_view;
|
||||
}
|
||||
|
||||
sub www_cutList {
|
||||
my $self = shift;
|
||||
return WebGUI::Privilege::insufficient() unless $self->canEdit;
|
||||
foreach my $assetId ($session{cgi}->param("assetId")) {
|
||||
my $asset = WebGUI::Asset->newByDynamicClass($assetId);
|
||||
if ($asset->canEdit) {
|
||||
$asset->cut;
|
||||
}
|
||||
}
|
||||
return $self->manageAssets();
|
||||
}
|
||||
|
||||
sub www_delete {
|
||||
my $self = shift;
|
||||
return WebGUI::Privilege::insufficient() unless $self->canEdit;
|
||||
$self->delete;
|
||||
return "";
|
||||
$self->trash;
|
||||
return $self->getParent->www_view;
|
||||
}
|
||||
|
||||
sub www_deleteList {
|
||||
my $self = shift;
|
||||
return WebGUI::Privilege::insufficient() unless $self->canEdit;
|
||||
foreach my $assetId ($session{cgi}->param("assetId")) {
|
||||
my $asset = WebGUI::Asset->newByDynamicClass($assetId);
|
||||
if ($asset->canEdit) {
|
||||
$asset->trash;
|
||||
}
|
||||
}
|
||||
return $self->manageAssets();
|
||||
}
|
||||
|
||||
sub www_demote {
|
||||
|
|
@ -620,7 +805,7 @@ sub www_demote {
|
|||
sub www_edit {
|
||||
my $self = shift;
|
||||
return WebGUI::Privilege::insufficient() unless $self->canEdit;
|
||||
return $self->getAdminConsole->render($self->getEditForm);
|
||||
return $self->getAdminConsole->render($self->getEditForm->print);
|
||||
}
|
||||
|
||||
sub www_editSave {
|
||||
|
|
@ -628,7 +813,7 @@ sub www_editSave {
|
|||
my %data;
|
||||
foreach my $definition (@{$self->definition}) {
|
||||
foreach my $property (keys %{$definition->{properties}}) {
|
||||
my $data{$property} = WebGUI::FormProcessor::process(
|
||||
$data{$property} = WebGUI::FormProcessor::process(
|
||||
$property,
|
||||
$definition->{properties}{fieldType},
|
||||
$definition->{properties}{defaultValue}
|
||||
|
|
@ -636,16 +821,135 @@ sub www_editSave {
|
|||
}
|
||||
}
|
||||
$self->update(\%data);
|
||||
return $self->www_manageAssets if ($session{form}{afterEdit} eq "assetManager");
|
||||
return "";
|
||||
}
|
||||
|
||||
sub www_editTree {
|
||||
return "not yet implemented";
|
||||
}
|
||||
|
||||
sub www_editTreeSave {
|
||||
return "not yet implemented";
|
||||
}
|
||||
|
||||
sub www_manageAssets {
|
||||
my $self = shift;
|
||||
return WebGUI::Privilege::insufficient() unless $self->canEdit;
|
||||
WebGUI::Style::setLink($session{config}{extrasURL}.'/assetManager/ActiveWidgets/runtime/styles/xp/grid.css', {rel=>"stylesheet",type=>"text/css"});
|
||||
WebGUI::Style::setLink($session{config}{extrasURL}.'/assetManager/assetManager.css', {rel=>"stylesheet",type=>"text/css"});
|
||||
WebGUI::Style::setScript($session{config}{extrasURL}.'/assetManager/ActiveWidgets/source/lib/grid.js', {type=>"text/javascript"});
|
||||
WebGUI::Style::setScript($session{config}{extrasURL}.'/assetManager/Tools.js', {type=>"text/javascript"});
|
||||
WebGUI::Style::setScript($session{config}{extrasURL}.'/assetManager/ContextMenu.js', {type=>"text/javascript"});
|
||||
WebGUI::Style::setScript($session{config}{extrasURL}.'/assetManager/Asset.js', {type=>"text/javascript"});
|
||||
WebGUI::Style::setScript($session{config}{extrasURL}.'/assetManager/Display.js', {type=>"text/javascript"});
|
||||
WebGUI::Style::setScript($session{config}{extrasURL}.'/assetManager/EventManager.js', {type=>"text/javascript"});
|
||||
WebGUI::Style::setScript($session{config}{extrasURL}.'/assetManager/AssetManager.js', {type=>"text/javascript"});
|
||||
my $children = $self->getLineage(["descendants"],{returnObjects=>1, endingLineageLength=>$self->getLineageLength+1});
|
||||
my $output;
|
||||
$output = '
|
||||
<div id="contextMenu" class="contextMenu"></div>
|
||||
<div id="propertiesWindow" class="propertiesWindow"></div>
|
||||
<div id="crumbtrail"></div>
|
||||
<div id="workspace" style="height: 200px;">Retrieving Assets...</div>
|
||||
<div id="dragImage" class="dragIdentifier">hello</div>
|
||||
';
|
||||
$output .= "<script>\n";
|
||||
$output .= "/* assetId, url, title */\nvar crumbtrail = [\n";
|
||||
my $ancestors = $self->getLineage(["self","ancestors"],{returnObjects=>1});
|
||||
foreach my $ancestor (@{$ancestors}) {
|
||||
$output .= '[';
|
||||
$output .= "'".$ancestor->getId."',";
|
||||
$output .= "'".$ancestor->getUrl."',";
|
||||
my $title = $ancestor->get("title");
|
||||
$title =~ s/\'/\\\'/g;
|
||||
$output .= "'".$title."'";
|
||||
$output .= "],\n";
|
||||
}
|
||||
$output .= "];\n";
|
||||
$output .= "var columnHeadings = ['Rank','Title','Type','Last Updated','Size'];\n";
|
||||
$output .= "/*rank, title, type, lastUpdate, size, url, assetId, icon */\nvar assets = [\n";
|
||||
foreach my $child (@{$children}) {
|
||||
$output .= '[';
|
||||
$output .= $child->getRank.",";
|
||||
my $title = $child->get("title");
|
||||
$title =~ s/\'/\\\'/g;
|
||||
$output .= "'".$title."',";
|
||||
$output .= "'".$child->getName."',";
|
||||
$output .= "'".WebGUI::DateTime::epochToHuman($child->get("lastUpdated"))."',";
|
||||
$output .= "'".formatBytes($child->get("assetSize"))."',";
|
||||
#my $hasChildren = "false";
|
||||
$output .= "'".$child->getUrl."',";
|
||||
$output .= "'".$child->getId."',";
|
||||
$output .= "'".$child->getIcon(1)."'";
|
||||
#$hasChildren = "true" if ($child->hasChildren);
|
||||
#$output .= $hasChildren;
|
||||
$output .= "],\n";
|
||||
}
|
||||
$output .= "];\n var labels = new Array();\n";
|
||||
$output .= "labels['edit'] = 'Edit';\n";
|
||||
$output .= "labels['cut'] = 'Cut';\n";
|
||||
$output .= "labels['copy'] = 'Copy';\n";
|
||||
$output .= "labels['move'] = 'Move';\n";
|
||||
$output .= "labels['view'] = 'View';\n";
|
||||
$output .= "labels['delete'] = 'Delete';\n";
|
||||
$output .= "labels['go'] = 'Go';\n";
|
||||
$output .= "labels['properties'] = 'Properties';\n";
|
||||
$output .= "labels['editTree'] = 'Edit Tree';\n";
|
||||
$output .= "var manager = new AssetManager(assets,columnHeadings,labels,crumbtrail); manager.renderAssets();\n</script>\n";
|
||||
$output .= '<div style="font-size: 18px;">'.WebGUI::International::get(1).'
|
||||
<div class="adminConsoleSpacer">
|
||||
|
||||
</div>
|
||||
<div style="float: left; padding-right: 30px; font-size: 14px;"><b>'.WebGUI::International::get(1083).'</b><br />';
|
||||
foreach my $link (@{$self->getAssetAdderLinks}) {
|
||||
$output .= '<a href="'.$link->{url}.'">'.$link->{label}.'</a><br />';
|
||||
}
|
||||
$output .= '</div>';
|
||||
my $clipboard = WebGUI::Clipboard::getAssetsInClipboard();
|
||||
my %options;
|
||||
tie %options, 'Tie::IxHash';
|
||||
my $hasClips = 0;
|
||||
foreach my $item (@{$clipboard}) {
|
||||
$options{$item->{assetId}} = $item->{title};
|
||||
$hasClips = 1;
|
||||
}
|
||||
if ($hasClips) {
|
||||
$output .= '<div style="float: left; padding-right: 30px; font-size: 14px;"><b>'.WebGUI::International::get(1082).'</b><br />'
|
||||
.WebGUI::Form::formHeader()
|
||||
.WebGUI::Form::hidden({name=>"func",value=>"pasteList"})
|
||||
.WebGUI::Form::checkList({name=>"assetId",options=>\%options})
|
||||
.'<br />'
|
||||
.WebGUI::Form::submit({value=>"Paste"})
|
||||
.WebGUI::Form::formFooter()
|
||||
.' </div> ';
|
||||
}
|
||||
$output .= '
|
||||
<div class="adminConsoleSpacer">
|
||||
|
||||
</div>
|
||||
</div>
|
||||
';
|
||||
return $self->getAdminConsole->render($output);
|
||||
}
|
||||
|
||||
|
||||
sub www_paste {
|
||||
my $self = shift;
|
||||
return WebGUI::Privilege::insufficient() unless $self->canEdit;
|
||||
$self->paste($session{form}{newParentId});
|
||||
$self->paste($session{form}{assetId});
|
||||
return "";
|
||||
}
|
||||
|
||||
sub www_pasteList {
|
||||
my $self = shift;
|
||||
return WebGUI::Privilege::insufficient() unless $self->canEdit;
|
||||
foreach my $clipId ($session{cgi}->param("assetId")) {
|
||||
$self->paste($clipId);
|
||||
}
|
||||
return $self->manageAssets();
|
||||
}
|
||||
|
||||
sub www_promote {
|
||||
my $self = shift;
|
||||
return WebGUI::Privilege::insufficient() unless $self->canEdit;
|
||||
|
|
@ -653,10 +957,29 @@ sub www_promote {
|
|||
return "";
|
||||
}
|
||||
|
||||
sub www_view {
|
||||
sub www_setParent {
|
||||
my $self = shift;
|
||||
return WebGUI::Privilege::insufficient() unless $self->canEdit;
|
||||
return "No view has been defined for this asset.";
|
||||
my $newParent = shift;
|
||||
$self->setParent($newParent) if (defined $newParent);
|
||||
return $self->www_manageAssets();
|
||||
|
||||
}
|
||||
|
||||
sub www_setRank {
|
||||
my $self = shift;
|
||||
return WebGUI::Privilege::insufficient() unless $self->canEdit;
|
||||
my $newRank = $session{form}{rank};
|
||||
$self->setRank($newRank) if (defined $newRank);
|
||||
return $self->www_manageAssets();
|
||||
}
|
||||
|
||||
sub www_view {
|
||||
my $self = shift;
|
||||
return WebGUI::Privilege::noAccess() unless $self->canView;
|
||||
return "No view has been implemented for this asset.";
|
||||
}
|
||||
|
||||
|
||||
1;
|
||||
|
||||
|
|
|
|||
|
|
@ -108,6 +108,18 @@ sub getEditForm {
|
|||
}
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub getIcon {
|
||||
my $self = shift;
|
||||
my $small = shift;
|
||||
if ($small) {
|
||||
my $storage = WebGUI::Storage->new($self->get("storageId"));
|
||||
return $storage->getFileIconUrl($self->get("filename"));
|
||||
}
|
||||
return $session{config}{extrasURL}.'/assets/file.gif';
|
||||
}
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getName
|
||||
|
|
@ -151,26 +163,26 @@ Gathers data from www_edit and persists it.
|
|||
|
||||
sub www_editSave {
|
||||
my $self = shift;
|
||||
$self->SUPER::www_editSave();
|
||||
my $output = $self->SUPER::www_editSave();
|
||||
my $storage = WebGUI::Storage->create;
|
||||
my $filename = $storage->addFileFromFormPost("file");
|
||||
if (defined $filename) {
|
||||
my $oldVersions;
|
||||
if ($self->get($filename)) { # do file versioning
|
||||
my @old = split("\n",$self->get("olderVersions"));
|
||||
push(@old,$self->get{"storageId")."|".$self->get("filename"));
|
||||
push(@old,$self->get("storageId")."|".$self->get("filename"));
|
||||
$oldVersions = join("\n",@old);
|
||||
}
|
||||
$self->update({
|
||||
filename=>$filename,
|
||||
storageId=>$storage->getId,
|
||||
fileSize=>$storage->getFileSize,
|
||||
olderVersions=>$oldVersions
|
||||
});
|
||||
$self->setSize($storage->getFileSize($filename));
|
||||
} else {
|
||||
$storage->delete;
|
||||
}
|
||||
return "";
|
||||
return $output;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -98,16 +98,16 @@ sub generateThumbnail {
|
|||
}
|
||||
if ($self->getValue("filename") && $hasImageMagick) {
|
||||
my $storage = WebGUI::Storage->new($self->get("storageId"));
|
||||
$image = Image::Magick->new;
|
||||
$error = $image->Read($storage->getPath($storage->get("filename")));
|
||||
my $image = Image::Magick->new;
|
||||
my $error = $image->Read($storage->getPath($storage->get("filename")));
|
||||
if ($error) {
|
||||
$self->_addError("Couldn't read image for thumnail creation: ".$error);
|
||||
return 0;
|
||||
}
|
||||
($x, $y) = $image->Get('width','height');
|
||||
$n = $self->get("thumbnailSize");
|
||||
my ($x, $y) = $image->Get('width','height');
|
||||
my $n = $self->get("thumbnailSize");
|
||||
if ($x > $n || $y > $n) {
|
||||
$r = $x>$y ? $x / $n : $y / $n;
|
||||
my $r = $x>$y ? $x / $n : $y / $n;
|
||||
$image->Scale(width=>($x/$r),height=>($y/$r));
|
||||
}
|
||||
if (isIn($storage->getFileExtension($self->get("filename")), qw(tif tiff bmp))) {
|
||||
|
|
@ -152,6 +152,15 @@ sub getEditForm {
|
|||
}
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub getIcon {
|
||||
my $self = shift;
|
||||
my $small = shift;
|
||||
return $session{config}{extrasURL}.'/assets/image.gif' unless ($small);
|
||||
$self->SUPER::getIcon(1);
|
||||
}
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getName
|
||||
|
|
|
|||
|
|
@ -92,6 +92,15 @@ sub getEditForm {
|
|||
}
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub getIcon {
|
||||
my $self = shift;
|
||||
my $small = shift;
|
||||
return $session{config}{extrasURL}.'/assets/small/redirect.gif' if ($small);
|
||||
return $session{config}{extrasURL}.'/assets/redirect.gif';
|
||||
}
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getUiLevel ()
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@ use CGI::Util qw(rearrange);
|
|||
use DBI;
|
||||
use strict qw(subs vars);
|
||||
use Tie::IxHash;
|
||||
use WebGUI::Asset;
|
||||
use WebGUI::AdminConsole;
|
||||
use WebGUI::DateTime;
|
||||
use WebGUI::FormProcessor;
|
||||
|
|
@ -32,6 +33,7 @@ use WebGUI::Node;
|
|||
use WebGUI::Page;
|
||||
use WebGUI::Privilege;
|
||||
use WebGUI::Session;
|
||||
use WebGUI::Style;
|
||||
use WebGUI::SQL;
|
||||
use WebGUI::TabForm;
|
||||
use WebGUI::Template;
|
||||
|
|
@ -40,9 +42,11 @@ use WebGUI::Utility;
|
|||
use WebGUI::MetaData;
|
||||
use WebGUI::Wobject::WobjectProxy;
|
||||
|
||||
our @ISA = qw(WebGUI::Asset);
|
||||
|
||||
=head1 NAME
|
||||
|
||||
Package WebGUI::Wobject
|
||||
Package WebGUI::Asset::Wobject
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
|
|
@ -83,7 +87,19 @@ sub definition {
|
|||
cacheTimeoutVisitor=>{
|
||||
fieldType=>'interval',
|
||||
defaultValue=>600
|
||||
}
|
||||
},
|
||||
templateId=>{
|
||||
fieldType=>'template',
|
||||
defaultValue=>undef
|
||||
},
|
||||
styleTemplateId=>{
|
||||
fieldType=>'template',
|
||||
defaultValue=>undef
|
||||
},
|
||||
printableStyleTemplateId=>{
|
||||
fieldType=>'template',
|
||||
defaultValue=>undef
|
||||
}
|
||||
}
|
||||
});
|
||||
return $class->SUPER::definition($definition);
|
||||
|
|
@ -115,7 +131,7 @@ A comparison expression to be used when checking whether the action should be al
|
|||
|
||||
sub confirm {
|
||||
return WebGUI::Privilege::vitalComponent() if ($_[4]);
|
||||
my $noURL = $_[3] || WebGUI::URL::page();
|
||||
my $noURL = $_[3] || $_[0]->getUrl;
|
||||
my $output = '<h1>'.WebGUI::International::get(42).'</h1>';
|
||||
$output .= $_[1].'<p>';
|
||||
$output .= '<div align="center"><a href="'.$_[2].'">'.WebGUI::International::get(44).'</a>';
|
||||
|
|
@ -174,24 +190,24 @@ sub getEditForm {
|
|||
$tabform->getTab("layout")->template(
|
||||
-name=>"styleTemplateId",
|
||||
-label=>WebGUI::International::get(1073),
|
||||
-value=>($page{styleId} || 2),
|
||||
-value=>$self->getValue("styleTemplateId"),
|
||||
-namespace=>'style',
|
||||
-afterEdit=>'op=editPage&npp='.$session{form}{npp}
|
||||
);
|
||||
$tabform->getTab("layout")->template(
|
||||
-name=>"printableStyleTemplateId",
|
||||
-label=>WebGUI::International::get(1079),
|
||||
-value=>($page{printableStyleId} || 3),
|
||||
-value=>$self->getValue("printableStyleTemplateId"),
|
||||
-namespace=>'style',
|
||||
-afterEdit=>'op=editPage&npp='.$session{form}{npp}
|
||||
);
|
||||
if ($childCount) {
|
||||
# if ($childCount) {
|
||||
$tabform->getTab("layout")->yesNo(
|
||||
-name=>"recurseStyle",
|
||||
-subtext=>' '.WebGUI::International::get(106),
|
||||
-uiLevel=>9
|
||||
);
|
||||
}
|
||||
# }
|
||||
$tabform->getTab("properties")->HTMLArea(
|
||||
-name=>"description",
|
||||
-label=>WebGUI::International::get(85),
|
||||
|
|
@ -209,6 +225,7 @@ sub getEditForm {
|
|||
-value=>$self->getValue("cacheTimeoutVisitor"),
|
||||
-uiLevel=>8
|
||||
);
|
||||
return $tabform;
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -237,7 +254,20 @@ Logs the view of the wobject to the passive profiling mechanism.
|
|||
|
||||
sub logView {
|
||||
my $self = shift;
|
||||
WebGUI::PassiveProfiling::add($self->get("assetId"));
|
||||
if ($session{setting}{passiveProfilingEnabled}) {
|
||||
WebGUI::PassiveProfiling::add($self->get("assetId"));
|
||||
# not sure what this will do in the new model
|
||||
# WebGUI::PassiveProfiling::addPage(); # add wobjects on asset to passive profile log
|
||||
}
|
||||
# disabled for the time being because it's dangerous
|
||||
# if ($session{form}{op} eq "" && $session{setting}{trackPageStatistics} && $session{form}{wid} ne "new") {
|
||||
# WebGUI::SQL->write("insert into pageStatistics (dateStamp, userId, username, ipAddress, userAgent, referer,
|
||||
# assetId, assetTitle, wobjectId, wobjectFunction) values (".time().",".quote($session{user}{userId})
|
||||
# .",".quote($session{user}{username}).",
|
||||
# ".quote($session{env}{REMOTE_ADDR}).", ".quote($session{env}{HTTP_USER_AGENT}).",
|
||||
# ".quote($session{env}{HTTP_REFERER}).", ".quote($session{asset}{assetId}).",
|
||||
# ".quote($session{asset}{title}).", ".quote($session{form}{wid}).", ".quote($session{form}{func}).")");
|
||||
# }
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -261,16 +291,10 @@ sub processMacros {
|
|||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 processTemplate ( templateId, vars [ , namespace ] )
|
||||
=head2 processTemplate ( vars, namespace [ , templateId ] )
|
||||
|
||||
Returns the content generated from this template.
|
||||
|
||||
B<NOTE:> Only for use in wobjects that support templates.
|
||||
|
||||
=head3 templateId
|
||||
|
||||
An id referring to a particular template in the templates table.
|
||||
|
||||
=head3 hashRef
|
||||
|
||||
A hash reference containing variables and loops to pass to the template engine.
|
||||
|
|
@ -279,27 +303,41 @@ A hash reference containing variables and loops to pass to the template engine.
|
|||
|
||||
A namespace to use for the template. Defaults to the wobject's namespace.
|
||||
|
||||
=head3 templateId
|
||||
|
||||
An id referring to a particular template in the templates table. Defaults to $self->get("templateId").
|
||||
|
||||
=cut
|
||||
|
||||
sub processTemplate {
|
||||
my $self = shift;
|
||||
my $templateId = shift;
|
||||
my $var = shift;
|
||||
my $namespace = shift || $self->get("namespace");
|
||||
if ($self->{_useMetaData}) {
|
||||
my $meta = WebGUI::MetaData::getMetaDataFields($self->get("wobjectId"));
|
||||
foreach my $field (keys %$meta) {
|
||||
$var->{$meta->{$field}{fieldName}} = $meta->{$field}{value};
|
||||
}
|
||||
my $namespace = shift;
|
||||
my $templateId = shift || $self->get("templateId");
|
||||
my $meta = WebGUI::MetaData::getMetaDataFields($self->get("wobjectId"));
|
||||
foreach my $field (keys %$meta) {
|
||||
$var->{$meta->{$field}{fieldName}} = $meta->{$field}{value};
|
||||
}
|
||||
my $wobjectToolbar = deleteIcon('func=delete',$self->get("url"),WebGUI::International::get(43))
|
||||
.editIcon('func=edit',$self->get("url"))
|
||||
.moveUpIcon('func=promote',$self->get("url"))
|
||||
.moveDownIcon('func=demote',$self->get("url"))
|
||||
# .moveTopIcon('func=moveTop&wid='.${$wobject}{wobjectId})
|
||||
# .moveBottomIcon('func=moveBottom&wid='.${$wobject}{wobjectId})
|
||||
.cutIcon('func=cut',$self->get("url"))
|
||||
.copyIcon('func=copy',$self->get("url"));
|
||||
# if (${$wobject}{namespace} ne "WobjectProxy" && isIn("WobjectProxy",@{$session{config}{wobjects}})) {
|
||||
# $wobjectToolbar .= shortcutIcon('func=createShortcut');
|
||||
#}
|
||||
$var->{'controls'} = $wobjectToolbar;
|
||||
my %vars = (
|
||||
%{$self->{_property}},
|
||||
%{$self->{_properties}},
|
||||
%{$var}
|
||||
);
|
||||
if (defined $self->get("_WobjectProxy")) {
|
||||
$vars{isShortcut} = 1;
|
||||
my ($originalPageURL) = WebGUI::SQL->quickArray("select urlizedTitle from page where pageId=".quote($self->get("pageId")),WebGUI::SQL->getSlave);
|
||||
$vars{originalURL} = WebGUI::URL::gateway($originalPageURL."#".$self->get("wobjectId"));
|
||||
my ($originalPageURL) = WebGUI::SQL->quickArray("select url from asset where assetId=".quote($self->getId),WebGUI::SQL->getSlave);
|
||||
$vars{originalURL} = WebGUI::URL::gateway($originalPageURL."#".$self->getId);
|
||||
}
|
||||
return WebGUI::Template::process($templateId,$namespace, \%vars);
|
||||
}
|
||||
|
|
@ -320,6 +358,14 @@ sub purge {
|
|||
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
sub view {
|
||||
my $self = shift;
|
||||
return "No view has been created for this wobject.";
|
||||
}
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 www_createShortcut ( )
|
||||
|
|
@ -360,12 +406,47 @@ B<NOTE:> This method should only need to be extended if you need to do some spec
|
|||
|
||||
sub www_editSave {
|
||||
my $self = shift;
|
||||
$self->SUPER::www_editSave();
|
||||
my $output = $self->SUPER::www_editSave();
|
||||
WebGUI::MetaData::metaDataSave($self->getId);
|
||||
return "";
|
||||
return $output;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
sub www_view {
|
||||
my $self = shift;
|
||||
$self->logView();
|
||||
return WebGUI::Privilege::noAccess() unless $self->canView;
|
||||
my $cache;
|
||||
my $output;
|
||||
my $useCache = (
|
||||
$session{form}{op} eq "" &&
|
||||
(
|
||||
( $self->get("cacheTimeout") > 10 && $session{user}{userId} !=1) ||
|
||||
( $self->get("cacheTimeoutVisitor") > 10 && $session{user}{userId} == 1)
|
||||
) &&
|
||||
not $session{var}{adminOn}
|
||||
);
|
||||
# if ($useCache) {
|
||||
# $cache = WebGUI::Cache->new("asset_".$self->getId."_".$session{user}{userId});
|
||||
# $output = $cache->get;
|
||||
# }
|
||||
unless ($output) {
|
||||
$output = $self->view;
|
||||
my $ttl;
|
||||
if ($session{user}{userId} == 1) {
|
||||
$ttl = $self->get("cacheTimeoutVisitor");
|
||||
} else {
|
||||
$ttl = $self->get("cacheTimeout");
|
||||
}
|
||||
# $cache->set($output, $ttl) if ($useCache && !WebGUI::HTTP::isRedirect());
|
||||
}
|
||||
return WebGUI::Style::process($output,$self->get("styleTemplateId"));
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
|
|
|
|||
|
|
@ -22,8 +22,7 @@ use WebGUI::International;
|
|||
use WebGUI::Paginator;
|
||||
use WebGUI::Privilege;
|
||||
use WebGUI::Session;
|
||||
use WebGUI::URL;
|
||||
use WebGUI::Wobject;
|
||||
use WebGUI::Asset::Wobject;
|
||||
|
||||
our @ISA = qw(WebGUI::Asset::Wobject);
|
||||
|
||||
|
|
@ -61,21 +60,21 @@ sub getEditForm {
|
|||
my $tabform = $self->SUPER::getEditForm();
|
||||
$tabform->getTab("properties")->text(
|
||||
-name=>"linkTitle",
|
||||
-label=>WebGUI::International::get(7,$self->get("namespace")),
|
||||
-label=>WebGUI::International::get(7,"Article"),
|
||||
-value=>$self->getValue("linkTitle"),
|
||||
-uiLevel=>3
|
||||
);
|
||||
$tabform->getTab("properties")->url(
|
||||
-name=>"linkURL",
|
||||
-label=>WebGUI::International::get(8,$self->get("namespace")),
|
||||
-label=>WebGUI::International::get(8,"Article"),
|
||||
-value=>$self->getValue("linkURL"),
|
||||
-uiLevel=>3
|
||||
);
|
||||
$tabform->getTab("layout")->yesNo(
|
||||
-name=>"convertCarriageReturns",
|
||||
-label=>WebGUI::International::get(10,$_[0]->get("namespace")),
|
||||
-value=>$_[0]->getValue("convertCarriageReturns"),
|
||||
-subtext=>' <span style="font-size: 8pt;">'.WebGUI::International::get(11,$_[0]->get("namespace")).'</span>',
|
||||
-label=>WebGUI::International::get(10,"Article"),
|
||||
-value=>$self->getValue("convertCarriageReturns"),
|
||||
-subtext=>' <span style="font-size: 8pt;">'.WebGUI::International::get(11,"Article").'</span>',
|
||||
-uiLevel=>5,
|
||||
-defaultValue=>0
|
||||
);
|
||||
|
|
@ -83,6 +82,15 @@ sub getEditForm {
|
|||
}
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub getIcon {
|
||||
my $self = shift;
|
||||
my $small = shift;
|
||||
return $session{config}{extrasURL}.'/assets/small/article.gif' if ($small);
|
||||
return $session{config}{extrasURL}.'/assets/article.gif';
|
||||
}
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub getName {
|
||||
return WebGUI::International::get(1,"Article");
|
||||
|
|
@ -90,31 +98,8 @@ sub getName {
|
|||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_edit {
|
||||
my $self = shift;
|
||||
return WebGUI::Privilege::insufficient() unless $self->canEdit;
|
||||
$self->getAdminConsole->setHelp("article add/edit");
|
||||
return $self->getAdminConsole->render($self->getEditForm,WebGUI::International::get("12","Article"));
|
||||
}
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_editSave {
|
||||
my ($image, $attachment, %property);
|
||||
$_[0]->SUPER::www_editSave() if ($_[0]->get("wobjectId") eq "new");
|
||||
$image = WebGUI::Attachment->new("",$_[0]->get("wobjectId"));
|
||||
$image->save("image");
|
||||
$attachment = WebGUI::Attachment->new("",$_[0]->get("wobjectId"));
|
||||
$attachment->save("attachment");
|
||||
$property{image} = $image->getFilename if ($image->getFilename ne "");
|
||||
$property{attachment} = $attachment->getFilename if ($attachment->getFilename ne "");
|
||||
return $_[0]->SUPER::www_editSave(\%property);
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_view {
|
||||
sub view {
|
||||
my $self = shift;
|
||||
$self->logView() if ($session{setting}{passiveProfilingEnabled});
|
||||
my ($file, %var);
|
||||
if ($self->get("image") ne "") {
|
||||
$file = WebGUI::Attachment->new($self->get("image"),$self->get("wobjectId"));
|
||||
|
|
@ -125,7 +110,7 @@ sub www_view {
|
|||
if ($self->get("convertCarriageReturns")) {
|
||||
$var{description} =~ s/\n/\<br\>\n/g;
|
||||
}
|
||||
$var{"new.template"} = WebGUI::URL::page("wid=".$self->get("wobjectId")."&func=view")."&overrideTemplateId=";
|
||||
$var{"new.template"} = $self->getUrl("wid=".$self->get("wobjectId")."&func=view")."&overrideTemplateId=";
|
||||
$var{"description.full"} = $var{description};
|
||||
$var{"description.full"} =~ s/\^\-\;//g;
|
||||
$var{"description.first.100words"} = $var{"description.full"};
|
||||
|
|
@ -150,7 +135,7 @@ sub www_view {
|
|||
$var{"description.first.2sentences"} =~ s/^((.*?\.){2}).*/$1/s;
|
||||
$var{"description.first.sentence"} = $var{"description.first.2sentences"};
|
||||
$var{"description.first.sentence"} =~ s/^(.*?\.).*/$1/s;
|
||||
my $p = WebGUI::Paginator->new(WebGUI::URL::page("wid=".$self->get("wobjectId")."&func=view"),1);
|
||||
my $p = WebGUI::Paginator->new($self->getUrl("wid=".$self->get("wobjectId")."&func=view"),1);
|
||||
if ($session{form}{makePrintable} || $var{description} eq "") {
|
||||
$var{description} =~ s/\^\-\;//g;
|
||||
$p->setDataByArrayRef([$var{description}]);
|
||||
|
|
@ -167,7 +152,7 @@ sub www_view {
|
|||
$var{"attachment.url"} = $file->getURL;
|
||||
$var{"attachment.name"} = $file->getFilename;
|
||||
}
|
||||
my $callback = WebGUI::URL::page("func=view&wid=".$self->get("wobjectId"));
|
||||
my $callback = $self->getUrl("func=view&wid=".$self->get("wobjectId"));
|
||||
if ($self->get("allowDiscussion")) {
|
||||
my $forum = WebGUI::Forum->new($self->get("forumId"));
|
||||
$var{"replies.count"} = ($forum->get("replies") + $forum->get("threads"));
|
||||
|
|
@ -188,10 +173,20 @@ sub www_view {
|
|||
forumId=>$self->get("forumId")
|
||||
});
|
||||
} else {
|
||||
return $self->processTemplate($templateId,\%var);
|
||||
return $self->processTemplate(\%var, "Article", $templateId);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_edit {
|
||||
my $self = shift;
|
||||
return WebGUI::Privilege::insufficient() unless $self->canEdit;
|
||||
$self->getAdminConsole->setHelp("article add/edit");
|
||||
return $self->getAdminConsole->render($self->getEditForm->print,WebGUI::International::get("12","Article"));
|
||||
}
|
||||
|
||||
|
||||
|
||||
1;
|
||||
|
||||
|
|
|
|||
|
|
@ -101,7 +101,7 @@ The URL to any page. Defaults to the current page.
|
|||
|
||||
sub copyIcon {
|
||||
my ($output, $pageURL);
|
||||
$pageURL = $_[1] || $session{page}{urlizedTitle};
|
||||
$pageURL = $_[1] || $session{env}{PATH_INFO};
|
||||
$output = '<a href="'.WebGUI::URL::gateway($pageURL,$_[0]).'">';
|
||||
$output .= '<img src="'._getBaseURL().'copy.gif" align="middle" border="0" alt="Copy" title="Copy" /></a>';
|
||||
return $output;
|
||||
|
|
@ -125,7 +125,7 @@ The URL to any page. Defaults to the current page.
|
|||
|
||||
sub cutIcon {
|
||||
my ($output, $pageURL);
|
||||
$pageURL = $_[1] || $session{page}{urlizedTitle};
|
||||
$pageURL = $_[1] || $session{env}{PATH_INFO};
|
||||
$output = '<a href="'.WebGUI::URL::gateway($pageURL,$_[0]).'">';
|
||||
$output .= '<img src="'._getBaseURL().'cut.gif" align="middle" border="0" alt="Cut" title="Cut" /></a>';
|
||||
return $output;
|
||||
|
|
@ -158,7 +158,7 @@ sub deleteIcon {
|
|||
$confirmText = qq| onclick="return confirm('$confirmText')" |;
|
||||
}
|
||||
|
||||
$pageURL = $_[1] || $session{page}{urlizedTitle};
|
||||
$pageURL = $_[1] || $session{env}{PATH_INFO};
|
||||
|
||||
$output = '<a href="'.WebGUI::URL::gateway($pageURL,$_[0]).'" '.$confirmText.'>';
|
||||
$output .= '<img src="'._getBaseURL().'delete.gif" align="middle" border="0" alt="Delete" title="Delete" /></a>';
|
||||
|
|
@ -195,7 +195,7 @@ The URL to any page. Defaults to the current page.
|
|||
|
||||
sub editIcon {
|
||||
my ($output, $pageURL);
|
||||
$pageURL = $_[1] || $session{page}{urlizedTitle};
|
||||
$pageURL = $_[1] || $session{env}{PATH_INFO};
|
||||
$output = '<a href="'.WebGUI::URL::gateway($pageURL,$_[0]).'">';
|
||||
$output .= '<img src="'._getBaseURL().'edit.gif" align="middle" border="0" alt="Edit" title="Edit" /></a>';
|
||||
return $output;
|
||||
|
|
@ -219,7 +219,7 @@ The URL to any page. Defaults to the current page.
|
|||
|
||||
sub exportIcon {
|
||||
my ($output, $pageURL);
|
||||
$pageURL = $_[1] || $session{page}{urlizedTitle};
|
||||
$pageURL = $_[1] || $session{env}{PATH_INFO};
|
||||
$output = '<a href="'.WebGUI::URL::gateway($pageURL,$_[0]).'">';
|
||||
# TODO Change icon to Jeffs export icon
|
||||
$output .= '<img src="'._getBaseURL().'export.gif" align="middle" border="0" alt="Export" title="Export" /></a>';
|
||||
|
|
@ -292,7 +292,7 @@ The URL to any page. Defaults to the current page.
|
|||
|
||||
sub manageIcon {
|
||||
my ($output, $pageURL);
|
||||
$pageURL = $_[1] || $session{page}{urlizedTitle};
|
||||
$pageURL = $_[1] || $session{env}{PATH_INFO};
|
||||
$output = '<a href="'.WebGUI::URL::gateway($pageURL,$_[0]).'">';
|
||||
$output .= '<img src="'._getBaseURL().'manage.gif" align="middle" border="0" alt="Manage" title="Manage" /></a>';
|
||||
return $output;
|
||||
|
|
@ -316,7 +316,7 @@ The URL to any page. Defaults to the current page.
|
|||
|
||||
sub moveBottomIcon {
|
||||
my ($output, $pageURL);
|
||||
$pageURL = $_[1] || $session{page}{urlizedTitle};
|
||||
$pageURL = $_[1] || $session{env}{PATH_INFO};
|
||||
$output = '<a href="'.WebGUI::URL::gateway($pageURL,$_[0]).'">';
|
||||
$output .= '<img src="'._getBaseURL().'moveBottom.gif" align="middle" border="0" alt="Move To Bottom" title="Move To Bottom" /></a>';
|
||||
return $output;
|
||||
|
|
@ -340,7 +340,7 @@ The URL to any page. Defaults to the current page.
|
|||
|
||||
sub moveDownIcon {
|
||||
my ($output, $pageURL);
|
||||
$pageURL = $_[1] || $session{page}{urlizedTitle};
|
||||
$pageURL = $_[1] || $session{env}{PATH_INFO};
|
||||
$output = '<a href="'.WebGUI::URL::gateway($pageURL,$_[0]).'">';
|
||||
$output .= '<img src="'._getBaseURL().'moveDown.gif" align="middle" border="0" alt="Move Down" title="Move Down" /></a>';
|
||||
return $output;
|
||||
|
|
@ -364,7 +364,7 @@ The URL to any page. Defaults to the current page.
|
|||
|
||||
sub moveLeftIcon {
|
||||
my ($output, $pageURL);
|
||||
$pageURL = $_[1] || $session{page}{urlizedTitle};
|
||||
$pageURL = $_[1] || $session{env}{PATH_INFO};
|
||||
$output = '<a href="'.WebGUI::URL::gateway($pageURL,$_[0]).'">';
|
||||
$output .= '<img src="'._getBaseURL().'moveLeft.gif" align="middle" border="0" alt="Move Left" title="Move Left" /></a>';
|
||||
return $output;
|
||||
|
|
@ -388,7 +388,7 @@ The URL to any page. Defaults to the current page.
|
|||
|
||||
sub moveRightIcon {
|
||||
my ($output, $pageURL);
|
||||
$pageURL = $_[1] || $session{page}{urlizedTitle};
|
||||
$pageURL = $_[1] || $session{env}{PATH_INFO};
|
||||
$output = '<a href="'.WebGUI::URL::gateway($pageURL,$_[0]).'">';
|
||||
$output .= '<img src="'._getBaseURL().'moveRight.gif" align="middle" border="0" alt="Move Right" title="Move Right" /></a>';
|
||||
return $output;
|
||||
|
|
@ -412,7 +412,7 @@ The URL to any page. Defaults to the current page.
|
|||
|
||||
sub moveTopIcon {
|
||||
my ($output, $pageURL);
|
||||
$pageURL = $_[1] || $session{page}{urlizedTitle};
|
||||
$pageURL = $_[1] || $session{env}{PATH_INFO};
|
||||
$output = '<a href="'.WebGUI::URL::gateway($pageURL,$_[0]).'">';
|
||||
$output .= '<img src="'._getBaseURL().'moveTop.gif" align="middle" border="0" alt="Move To Top" title="Move To Top" /></a>';
|
||||
return $output;
|
||||
|
|
@ -436,7 +436,7 @@ The URL to any page. Defaults to the current page.
|
|||
|
||||
sub moveUpIcon {
|
||||
my ($output, $pageURL);
|
||||
$pageURL = $_[1] || $session{page}{urlizedTitle};
|
||||
$pageURL = $_[1] || $session{env}{PATH_INFO};
|
||||
$output = '<a href="'.WebGUI::URL::gateway($pageURL,$_[0]).'">';
|
||||
$output .= '<img src="'._getBaseURL().'moveUp.gif" align="middle" border="0" alt="Move Up" title="Move Up" /></a>';
|
||||
return $output;
|
||||
|
|
@ -472,7 +472,7 @@ The URL to any page. Defaults to the current page.
|
|||
|
||||
sub pasteIcon {
|
||||
my ($output, $pageURL);
|
||||
$pageURL = $_[1] || $session{page}{urlizedTitle};
|
||||
$pageURL = $_[1] || $session{env}{PATH_INFO};
|
||||
$output = '<a href="'.WebGUI::URL::gateway($pageURL,$_[0]).'">';
|
||||
$output .= '<img src="'._getBaseURL().'paste.gif" align="middle" border="0" alt="Paste" title="Paste" /></a>';
|
||||
return $output;
|
||||
|
|
@ -496,7 +496,7 @@ The URL to any page. Defaults to the current page.
|
|||
|
||||
sub shortcutIcon {
|
||||
my ($output, $pageURL);
|
||||
$pageURL = $_[1] || $session{page}{urlizedTitle};
|
||||
$pageURL = $_[1] || $session{env}{PATH_INFO};
|
||||
$output = '<a href="'.WebGUI::URL::gateway($pageURL,$_[0]).'">';
|
||||
$output .= '<img src="'._getBaseURL().'shortcut.gif" align="middle" border="0" alt="Shortcut" title="Create Shortcut" /></a>';
|
||||
return $output;
|
||||
|
|
@ -520,7 +520,7 @@ The URL to any page. Defaults to the current page.
|
|||
|
||||
sub viewIcon {
|
||||
my ($output, $pageURL);
|
||||
$pageURL = $_[1] || $session{page}{urlizedTitle};
|
||||
$pageURL = $_[1] || $session{env}{PATH_INFO};
|
||||
$output = '<a href="'.WebGUI::URL::gateway($pageURL,$_[0]).'">';
|
||||
$output .= '<img src="'._getBaseURL().'view.gif" align="middle" border="0" alt="View" title="View" /></a>';
|
||||
return $output;
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@ use strict qw(refs vars);
|
|||
use Tie::CPHash;
|
||||
use Tie::IxHash;
|
||||
use WebGUI::AdminConsole;
|
||||
use WebGUI::Clipboard;
|
||||
use WebGUI::Grouping;
|
||||
use WebGUI::International;
|
||||
use WebGUI::Macro;
|
||||
|
|
@ -37,18 +38,18 @@ sub process {
|
|||
$var{'packages.label'} = WebGUI::International::get(376);
|
||||
my @packages;
|
||||
my $i;
|
||||
my $sth = WebGUI::SQL->read("select pageId,title from page where parentId='5'");
|
||||
while (my %data = $sth->hash) {
|
||||
$data{title} =~ s/'//g;
|
||||
push(@packages, {
|
||||
'package.url'=>WebGUI::URL::page('op=deployPackage&pid='.$data{pageId}),
|
||||
'package.label'=>$data{title},
|
||||
'package.count'=>$i
|
||||
});
|
||||
$i++;
|
||||
}
|
||||
$sth->finish;
|
||||
$var{package_loop} = \@packages;
|
||||
# my $sth = WebGUI::SQL->read("select pageId,title from page where parentId='5'");
|
||||
# while (my %data = $sth->hash) {
|
||||
# $data{title} =~ s/'//g;
|
||||
# push(@packages, {
|
||||
# 'package.url'=>WebGUI::URL::page('op=deployPackage&pid='.$data{pageId}),
|
||||
# 'package.label'=>$data{title},
|
||||
# 'package.count'=>$i
|
||||
# });
|
||||
# $i++;
|
||||
# }
|
||||
# $sth->finish;
|
||||
# $var{package_loop} = \@packages;
|
||||
#--contenttypes adder
|
||||
$var{'contentTypes.label'} = WebGUI::International::get(1083);
|
||||
foreach my $namespace (@{$session{config}{wobjects}}) {
|
||||
|
|
@ -81,64 +82,18 @@ sub process {
|
|||
$var{'addpage.label'} = WebGUI::International::get(2);
|
||||
#--clipboard paster
|
||||
$var{'clipboard.label'} = WebGUI::International::get(1082);
|
||||
%hash2 = ();
|
||||
|
||||
# get pages and store in array of arrays in order to integrate with wobjects and sort by buffer date
|
||||
if ($session{setting}{sharedClipboard} eq "1") {
|
||||
$query = "select bufferDate,pageId,title from page where parentId='2' order by bufferDate";
|
||||
} else {
|
||||
$query = "select bufferDate,pageId,title from page where parentId='2' "
|
||||
." and bufferUserId=".quote($session{user}{userId})
|
||||
." order by bufferDate";
|
||||
}
|
||||
$r = WebGUI::SQL->read($query);
|
||||
while (%cphash = $r->hash) {
|
||||
$cphash{title} =~ s/'//g;
|
||||
push @item, [ $cphash{bufferDate},
|
||||
WebGUI::URL::page('op=pastePage&pageId='.$cphash{pageId}),
|
||||
$cphash{title} . ' ('. WebGUI::International::get(2) .')' ];
|
||||
}
|
||||
$r->finish;
|
||||
|
||||
# get wobjects and store in array of arrays in order to integrate with pages and sort by buffer date
|
||||
if ($session{setting}{sharedClipboard} eq "1") {
|
||||
$query = "select bufferDate,wobjectId,title,namespace from wobject where pageId='2' "
|
||||
." order by bufferDate";
|
||||
} else {
|
||||
$query = "select bufferDate,wobjectId,title,namespace from wobject where pageId='2' "
|
||||
." and bufferUserId=".quote($session{user}{userId})
|
||||
." order by bufferDate";
|
||||
}
|
||||
$r = WebGUI::SQL->read($query);
|
||||
while (%cphash = $r->hash) {
|
||||
$cphash{title} =~ s/'//g;
|
||||
push @item, [ $cphash{bufferDate},
|
||||
WebGUI::URL::page('func=paste&wid='.$cphash{wobjectId}),
|
||||
$cphash{title} . ' ('. $cphash{namespace} .')' ];
|
||||
}
|
||||
$r->finish;
|
||||
|
||||
# Reverse sort by bufferDate and and create hash from list values
|
||||
my @sorted_item = sort {$b->[0] <=> $a->[0]} @item;
|
||||
@item = ();
|
||||
for $i ( 0 .. $#sorted_item ) {
|
||||
$hash2{ $sorted_item[$i][1] } = $sorted_item[$i][2];
|
||||
}
|
||||
@sorted_item = ();
|
||||
my @clipboard;
|
||||
$i = 0;
|
||||
foreach my $key (keys %hash2) {
|
||||
push(@clipboard,{
|
||||
'clipboard.url'=>$key,
|
||||
'clipboard.label'=>$hash2{$key},
|
||||
'clipboard.count'=>$i
|
||||
my $clipboard = WebGUI::Clipboard::getAssetsInClipboard();
|
||||
foreach my $item (@{$clipboard}) {
|
||||
my $title = $item->{title};
|
||||
$title =~ s/'//g; # stops it from breaking the javascript menus
|
||||
push(@{$var{clipboard_loop}}, {
|
||||
'clipboard.label'=>$title,
|
||||
'clipboard.url'=>WebGUI::URL::page("func=paste&assetId=".$item->{assetId})
|
||||
});
|
||||
$i++;
|
||||
}
|
||||
$var{'clipboard_loop'} = \@clipboard;
|
||||
#--admin functions
|
||||
%hash = (
|
||||
'http://validator.w3.org/check?uri='.WebGUI::URL::escape(WebGUI::URL::page())=>WebGUI::International::get(399),
|
||||
'http://validator.w3.org/check?uri=referer'=>WebGUI::International::get(399),
|
||||
);
|
||||
my $acParams = WebGUI::AdminConsole->getAdminConsoleParams;
|
||||
$hash{$acParams->{url}} = $acParams->{title} if ($acParams->{canUse});
|
||||
|
|
|
|||
|
|
@ -22,9 +22,9 @@ use WebGUI::URL;
|
|||
sub process {
|
||||
if (WebGUI::Grouping::isInGroup(12)) {
|
||||
my %var;
|
||||
my @param = WebGUI::Macro::getParams($_[0]);
|
||||
my $turnOn = $param[0] || WebGUI::International::get(516);
|
||||
my $turnOff = $param[1] || WebGUI::International::get(517);
|
||||
my ($turnOn,$turnOff,$templateName) = WebGUI::Macro::getParams($_[0]);
|
||||
$turnOn |= WebGUI::International::get(516);
|
||||
$turnOff |= WebGUI::International::get(517);
|
||||
if ($session{var}{adminOn}) {
|
||||
$var{'toggle.url'} = WebGUI::URL::page('op=switchOffAdmin');
|
||||
$var{'toggle.text'} = $turnOff;
|
||||
|
|
@ -32,7 +32,7 @@ sub process {
|
|||
$var{'toggle.url'} = WebGUI::URL::page('op=switchOnAdmin');
|
||||
$var{'toggle.text'} = $turnOn;
|
||||
}
|
||||
return WebGUI::Template::process(WebGUI::Template::getIdByName($param[2],"Macro/AdminToggle"),"Macro/AdminToggle",\%var);
|
||||
return WebGUI::Template::process(WebGUI::Template::getIdByName($templateName,"Macro/AdminToggle")||1,"Macro/AdminToggle",\%var);
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,7 +16,9 @@ use WebGUI::URL;
|
|||
|
||||
#-------------------------------------------------------------------
|
||||
sub process {
|
||||
return WebGUI::URL::getScriptURL().$session{page}{urlizedTitle};
|
||||
my $pathinfo = $session{env}{PATH_INFO};
|
||||
$pathinfo =~ s/^\/(.*)/$1/;
|
||||
return WebGUI::URL::getScriptURL().$pathinfo;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ sub process {
|
|||
if ($session{setting}{defaultPage} eq $session{page}{pageId}) {
|
||||
$temp = $session{page}{urlizedTitle};
|
||||
} else {
|
||||
($temp) = WebGUI::SQL->quickArray("select urlizedTitle from page where pageId=".quote($session{setting}{defaultPage}),WebGUI::SQL->getSlave);
|
||||
($temp) = WebGUI::SQL->quickArray("select url from asset where assetId=".quote($session{setting}{defaultPage}),WebGUI::SQL->getSlave);
|
||||
}
|
||||
$temp = WebGUI::URL::gateway($temp);
|
||||
if ($param[0] ne "linkonly") {
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ sub process {
|
|||
$var{'toggle.url'} = WebGUI::URL::page('op=logout');
|
||||
$var{'toggle.text'} = $logout;
|
||||
}
|
||||
return WebGUI::Template::process(WebGUI::Template::getIdByName($param[3],"Macro/LoginToggle"), "Macro/LoginToggle", \%var);
|
||||
return WebGUI::Template::process(WebGUI::Template::getIdByName($param[3],"Macro/LoginToggle")||1, "Macro/LoginToggle", \%var);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -217,7 +217,6 @@ sub buildHashRef {
|
|||
%hash = $_[0]->buildHash($_[1],$_[2]);
|
||||
return \%hash;
|
||||
}
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
|
|
|
|||
|
|
@ -88,7 +88,7 @@ The error message to add to the object.
|
|||
sub _addError {
|
||||
my $self = shift;
|
||||
my $errorMessage = shift;
|
||||
push(@$self->{_errors},$errorMessage);
|
||||
push(@{$self->{_errors}},$errorMessage);
|
||||
WebGUI::ErrorHandler::warn($errorMessage);
|
||||
}
|
||||
|
||||
|
|
@ -375,7 +375,7 @@ sub get {
|
|||
my $class = shift;
|
||||
my $id = shift;
|
||||
my $parts = _getStorageParts($id);
|
||||
bless {_id => $id, _part1 => $part->[0], _part2 => $part->[1]}, $class;
|
||||
bless {_id => $id, _part1 => $parts->[0], _part2 => $parts->[1]}, $class;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
|
@ -473,18 +473,8 @@ Returns the size of this file.
|
|||
sub getFileSize {
|
||||
my $self = shift;
|
||||
my $filename = shift;
|
||||
my ($size);
|
||||
my (@attributes) = stat($self->getPath($filename));
|
||||
if ($attributes[7] > 1048576) {
|
||||
$size = round($attributes[7]/1048576);
|
||||
$size .= 'MB';
|
||||
} elsif ($attributes[7] > 1024) {
|
||||
$size = round($attributes[7]/1024);
|
||||
$size .= 'kB';
|
||||
} else {
|
||||
$size = $attributes[7].'B';
|
||||
}
|
||||
return $size;
|
||||
return $attributes[7];
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -108,7 +108,7 @@ sub getTemplate {
|
|||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 process ( content [ , templateId ] )
|
||||
=head2 process ( content, templateId )
|
||||
|
||||
Returns a parsed style with content based upon the current WebGUI session information.
|
||||
|
||||
|
|
@ -118,19 +118,16 @@ The content to be parsed into the style. Usually generated by WebGUI::Page::gene
|
|||
|
||||
=head3 templateId
|
||||
|
||||
The unique identifier for the template to retrieve. Defaults to the style template tied to the current page.
|
||||
The unique identifier for the template to retrieve.
|
||||
|
||||
=cut
|
||||
|
||||
sub process {
|
||||
my %var;
|
||||
$var{'body.content'} = shift;
|
||||
my $templateId = shift || $session{page}{styleId};
|
||||
my $templateId = shift;
|
||||
if ($session{page}{makePrintable}) {
|
||||
$templateId = $session{page}{printableStyleId};
|
||||
} elsif ($session{page}{useAdminStyle}) {
|
||||
#$templateId = $session{setting}{adminStyleId};
|
||||
$templateId = "adminConsole";
|
||||
} elsif ($session{scratch}{personalStyleId} ne "") {
|
||||
$templateId = $session{scratch}{personalStyleId};
|
||||
} elsif ($session{page}{useEmptyStyle}) {
|
||||
|
|
|
|||
|
|
@ -96,17 +96,17 @@ Returns a hash reference containing all of the template parameters.
|
|||
|
||||
=head3 templateId
|
||||
|
||||
Defaults to "1". Specify the templateId of the template to retrieve.
|
||||
Specify the templateId of the template to retrieve.
|
||||
|
||||
=head3 namespace
|
||||
|
||||
Defaults to "page". Specify the namespace of the template to retrieve.
|
||||
Specify the namespace of the template to retrieve.
|
||||
|
||||
=cut
|
||||
|
||||
sub get {
|
||||
my $templateId = shift || 1;
|
||||
my $namespace = shift || "page";
|
||||
my $templateId = shift;
|
||||
my $namespace = shift;
|
||||
return WebGUI::SQL->quickHashRef("select * from template where templateId=".quote($templateId)." and namespace=".quote($namespace),WebGUI::SQL->getSlave);
|
||||
}
|
||||
|
||||
|
|
@ -162,11 +162,11 @@ Evaluate a template replacing template commands for HTML.
|
|||
|
||||
=head3 templateId
|
||||
|
||||
Defaults to "1". Specify the templateId of the template to retrieve.
|
||||
Specify the templateId of the template to retrieve.
|
||||
|
||||
=head3 namespace
|
||||
|
||||
Defaults to "page". Specify the namespace of the template to retrieve.
|
||||
Specify the namespace of the template to retrieve.
|
||||
|
||||
=head3 vars
|
||||
|
||||
|
|
@ -175,8 +175,8 @@ A hash reference containing template variables and loops. Automatically includes
|
|||
=cut
|
||||
|
||||
sub process {
|
||||
my $templateId = shift || 1;
|
||||
my $namespace = shift || "page";
|
||||
my $templateId = shift;
|
||||
my $namespace = shift;
|
||||
my $vars = shift;
|
||||
my $file = _getTemplateFile($templateId,$namespace);
|
||||
my $fileCacheDir = $session{config}{uploadsPath}.$session{os}{slash}."temp".$session{os}{slash}."templatecache";
|
||||
|
|
@ -202,7 +202,8 @@ sub process {
|
|||
}
|
||||
}
|
||||
if ($session{config}{templateCacheType} eq "file" && not $error) {
|
||||
$params{file_cache} = 1;
|
||||
# disabled until we can figure out what's wrong with it
|
||||
# $params{file_cache} = 1;
|
||||
} elsif ($session{config}{templateCacheType} eq "memory") {
|
||||
$params{cache} = 1;
|
||||
} elsif ($session{config}{templateCacheType} eq "ipc") {
|
||||
|
|
|
|||
|
|
@ -121,12 +121,12 @@ Name value pairs to add to the URL in the form of:
|
|||
|
||||
sub gateway {
|
||||
my $url = getScriptURL().$_[0];
|
||||
if ($_[1]) {
|
||||
$url = append($url,$_[1]);
|
||||
}
|
||||
if ($session{setting}{preventProxyCache} == 1) {
|
||||
$url = append($url,"noCache=".randint(0,1000).';'.time());
|
||||
}
|
||||
if ($_[1]) {
|
||||
$url = append($url,$_[1]);
|
||||
}
|
||||
return $url;
|
||||
}
|
||||
|
||||
|
|
@ -258,13 +258,15 @@ sub page {
|
|||
} else {
|
||||
$url = getScriptURL();
|
||||
}
|
||||
$url .= $session{page}{urlizedTitle};
|
||||
if ($pairs) {
|
||||
$url = append($url,$pairs);
|
||||
}
|
||||
my $pathinfo = $session{env}{PATH_INFO};
|
||||
$pathinfo =~ s/^\/(.*)/$1/;
|
||||
$url .= $pathinfo;
|
||||
if ($session{setting}{preventProxyCache} == 1) {
|
||||
$url = append($url,"noCache=".randint(0,1000).';'.time());
|
||||
}
|
||||
if ($pairs) {
|
||||
$url = append($url,$pairs);
|
||||
}
|
||||
return $url;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ use Tie::IxHash;
|
|||
|
||||
our @ISA = qw(Exporter);
|
||||
our @EXPORT = qw(&isBetween &makeTabSafe &makeArrayTabSafe &randomizeHash &commify &randomizeArray
|
||||
&sortHashDescending &sortHash &isIn &makeCommaSafe &makeArrayCommaSafe &randint &round);
|
||||
&formatBytes &sortHashDescending &sortHash &isIn &makeCommaSafe &makeArrayCommaSafe &randint &round);
|
||||
|
||||
|
||||
=head1 NAME
|
||||
|
|
@ -37,6 +37,7 @@ This package provides miscellaneous but useful utilities to the WebGUI programme
|
|||
|
||||
use WebGUI::Utility;
|
||||
$string = commify($integer);
|
||||
$size = formatBytes($integer);
|
||||
$boolean = isIn($value, @array);
|
||||
makeArrayCommaSafe(\@array);
|
||||
makeArrayTabSafe(\@array);
|
||||
|
|
@ -73,6 +74,32 @@ sub commify {
|
|||
return scalar reverse $text;
|
||||
}
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 formatBytes ( integer )
|
||||
|
||||
Returns a formatted file size like "3MB" or "44kB".
|
||||
|
||||
=head3 integer
|
||||
|
||||
An integer representing the number of bytes to format.
|
||||
|
||||
=cut
|
||||
|
||||
sub formatBytes {
|
||||
my $size = shift;
|
||||
if ($size > 1048576) {
|
||||
return round($size/1048576).'MB';
|
||||
} elsif ($size > 1024) {
|
||||
return round($size/1024).'kB';
|
||||
} else {
|
||||
return $size.'B';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 isBetween ( value, first, second )
|
||||
|
|
|
|||
|
|
@ -2075,10 +2075,6 @@ Choose which group can view this page. If you want both visitors and registered
|
|||
Choose the group that can edit this page. The group assigned editing rights can also always view the page.
|
||||
<p>
|
||||
|
||||
<b>Wobject privileges?</b><br>
|
||||
Allows content managers to specify view/edit privileges on a per wobject basis rather than relying on the privileges on the page.
|
||||
<p>
|
||||
|
||||
<b>Recursively set privileges?</b><br>
|
||||
You can optionally give the privileges of this page to all pages under this page.
|
||||
<p>
|
||||
|
|
@ -4018,11 +4014,6 @@ The toolbar for manipulating the properties of the page.
|
|||
lastUpdated => 1031514049
|
||||
},
|
||||
|
||||
'1003' => {
|
||||
message => q|Wobject privileges?|,
|
||||
lastUpdated => 1056041703
|
||||
},
|
||||
|
||||
'555' => {
|
||||
message => q|Edit this user's karma.|,
|
||||
lastUpdated => 1031514049
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue