Merge branch 'master' into WebGUI8
This commit is contained in:
commit
2400f19099
797 changed files with 33894 additions and 27196 deletions
|
|
@ -189,7 +189,7 @@ sub canEdit {
|
|||
my $album = $self->getParent;
|
||||
|
||||
return 1 if $userId eq $self->ownerUserId;
|
||||
return $album->canEdit($userId);
|
||||
return $album && $album->canEdit($userId);
|
||||
}
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
|
|
@ -224,7 +224,7 @@ sub canView {
|
|||
my $userId = shift || $self->session->user->userId;
|
||||
|
||||
my $album = $self->getParent;
|
||||
return 0 unless $album->canView($userId);
|
||||
return 0 unless $album && $album->canView($userId);
|
||||
|
||||
if ($self->isFriendsOnly && $userId ne $self->ownerUserId ) {
|
||||
my $owner = WebGUI::User->new( $self->session, $self->ownerUserId );
|
||||
|
|
@ -401,7 +401,14 @@ override getParent => sub {
|
|||
return $album;
|
||||
}
|
||||
# Only get the pending version if we're allowed to see this photo in its pending status
|
||||
elsif ( $self->getGallery->canEdit || $self->ownerUserId eq $self->session->user->userId ) {
|
||||
my $gallery
|
||||
= $self->getLineage( ['ancestors'], {
|
||||
includeOnlyClasses => [ 'WebGUI::Asset::Wobject::Gallery' ],
|
||||
returnObjects => 1,
|
||||
statusToInclude => [ 'pending', 'approved' ],
|
||||
invertTree => 1,
|
||||
} )->[ 0 ];
|
||||
if ( ($gallery && $gallery->canEdit) || $self->ownerUserId eq $self->session->user->userId ) {
|
||||
my $album
|
||||
= $self->getLineage( ['ancestors'], {
|
||||
includeOnlyClasses => [ 'WebGUI::Asset::Wobject::GalleryAlbum' ],
|
||||
|
|
@ -411,10 +418,81 @@ override getParent => sub {
|
|||
} )->[ 0 ];
|
||||
return $album;
|
||||
}
|
||||
return undef;
|
||||
};
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
=head2 getFirstFile ( )
|
||||
|
||||
Get the first file in the GalleryAlbum. Returns an instance of a GalleryFile
|
||||
or undef if there is no first file.
|
||||
|
||||
=cut
|
||||
|
||||
sub getFirstFile {
|
||||
my $self = shift;
|
||||
my $allFileIds = $self->getParent->getFileIds;
|
||||
|
||||
return undef unless @{ $allFileIds };
|
||||
return WebGUI::Asset->newByDynamicClass( $self->session, shift @{ $allFileIds });
|
||||
}
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
=head2 getLastFile ( )
|
||||
|
||||
Get the last file in the GalleryAlbum. Returns an instance of a GalleryFile
|
||||
or undef if there is no last file.
|
||||
|
||||
=cut
|
||||
|
||||
sub getLastFile {
|
||||
my $self = shift;
|
||||
my $allFileIds = $self->getParent->getFileIds;
|
||||
|
||||
return undef unless @{ $allFileIds };
|
||||
return WebGUI::Asset->newByDynamicClass( $self->session, pop @{ $allFileIds });
|
||||
}
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
=head2 getNextFile ( )
|
||||
|
||||
Get the next file in the GalleryAlbum. Returns an instance of a GalleryFile,
|
||||
or undef if there is no next file.
|
||||
|
||||
=cut
|
||||
|
||||
sub getNextFile {
|
||||
my $self = shift;
|
||||
return $self->{_nextFile} if $self->{_nextFile};
|
||||
my $nextId = $self->getParent->getNextFileId( $self->getId );
|
||||
return undef unless $nextId;
|
||||
$self->{_nextFile} = WebGUI::Asset->newByDynamicClass( $self->session, $nextId );
|
||||
return $self->{_nextFile};
|
||||
}
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
=head2 getPreviousFile ( )
|
||||
|
||||
Get the previous file in the GalleryAlbum. Returns an instance of a GalleryFile,
|
||||
or undef if there is no previous file.
|
||||
|
||||
=cut
|
||||
|
||||
sub getPreviousFile {
|
||||
my $self = shift;
|
||||
return $self->{_previousFile} if $self->{_previousFile};
|
||||
my $previousId = $self->getParent->getPreviousFileId( $self->getId );
|
||||
return undef unless $previousId;
|
||||
$self->{_previousFile} = WebGUI::Asset->newByDynamicClass( $self->session, $previousId );
|
||||
return $self->{_previousFile};
|
||||
}
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
=head2 getThumbnailUrl ( )
|
||||
|
||||
Gets the URL to the thumbnail for this GalleryFile. This should probably be
|
||||
|
|
@ -489,10 +567,30 @@ sub getTemplateVars {
|
|||
= $self->getGallery->getUrl('func=listFilesForUser;userId=' . $self->ownerUserId);
|
||||
$var->{ url_promote } = $self->getUrl('func=promote');
|
||||
|
||||
if ( my $firstFile = $self->getFirstFile ) {
|
||||
$var->{ firstFile_url } = $firstFile->getUrl;
|
||||
$var->{ firstFile_title } = $firstFile->get( "title" );
|
||||
$var->{ firstFile_thumbnailUrl } = $firstFile->getThumbnailUrl;
|
||||
}
|
||||
if ( my $nextFile = $self->getNextFile ) {
|
||||
$var->{ nextFile_url } = $nextFile->getUrl;
|
||||
$var->{ nextFile_title } = $nextFile->get( "title" );
|
||||
$var->{ nextFile_thumbnailUrl } = $nextFile->getThumbnailUrl;
|
||||
}
|
||||
if ( my $prevFile = $self->getPreviousFile ) {
|
||||
$var->{ previousFile_url } = $prevFile->getUrl;
|
||||
$var->{ previousFile_title } = $prevFile->get( "title" );
|
||||
$var->{ previousFile_thumbnailUrl } = $prevFile->getThumbnailUrl;
|
||||
}
|
||||
if ( my $lastFile = $self->getLastFile ) {
|
||||
$var->{ lastFile_url } = $lastFile->getUrl;
|
||||
$var->{ lastFile_title } = $lastFile->get( "title" );
|
||||
$var->{ lastFile_thumbnailUrl } = $lastFile->getThumbnailUrl;
|
||||
}
|
||||
|
||||
return $var;
|
||||
}
|
||||
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
=head2 isFriendsOnly ( )
|
||||
|
|
@ -539,6 +637,13 @@ sub makeShortcut {
|
|||
$shortcut->setOverride( $overrides );
|
||||
}
|
||||
|
||||
if (WebGUI::VersionTag->autoCommitWorkingIfEnabled($session, {
|
||||
allowComments => 1,
|
||||
returnUrl => $self->getUrl,
|
||||
}) eq 'redirect') {
|
||||
return 'redirect';
|
||||
};
|
||||
|
||||
return $shortcut;
|
||||
}
|
||||
|
||||
|
|
@ -722,6 +827,19 @@ sub valid_parent_classes {
|
|||
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
=head2 validParent ( )
|
||||
|
||||
Override validParent to only allow GalleryAlbums to hold GalleryFiles.
|
||||
|
||||
=cut
|
||||
|
||||
sub validParent {
|
||||
my ($class, $session) = @_;
|
||||
return $session->asset->isa('WebGUI::Asset::Wobject::GalleryAlbum');
|
||||
}
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
=head2 view ( )
|
||||
|
||||
method called by the container www_view method.
|
||||
|
|
@ -765,13 +883,13 @@ sub view {
|
|||
keyword => $keyword,
|
||||
url_searchKeyword
|
||||
=> $self->getGallery->getUrl(
|
||||
"func=search;submit=1;keywords=" . uri_escape($keyword)
|
||||
"func=search;submit=1;keywords=" . uri_escape_utf8($keyword)
|
||||
),
|
||||
url_searchKeywordUser
|
||||
=> $self->getGallery->getUrl(
|
||||
"func=search;submit=1;"
|
||||
. "userId=" . $self->ownerUserId . ';'
|
||||
. 'keywords=' . uri_escape( $keyword )
|
||||
. 'keywords=' . uri_escape_utf8( $keyword )
|
||||
),
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -456,10 +456,12 @@ This page is only available to those who can edit this Photo.
|
|||
sub www_edit {
|
||||
my $self = shift;
|
||||
my $session = $self->session;
|
||||
my $form = $self->session->form;
|
||||
my $form = $session->form;
|
||||
|
||||
return $self->session->privilege->insufficient unless $self->canEdit;
|
||||
return $self->session->privilege->locked unless $self->canEditIfLocked;
|
||||
return $session->privilege->insufficient unless $self->canEdit;
|
||||
return $session->privilege->locked unless $self->canEditIfLocked;
|
||||
|
||||
my $i18n = WebGUI::International->new($session, 'WebGUI');
|
||||
|
||||
# Prepare the template variables
|
||||
# Cannot get all template vars since they require a storage location, doesn't work for
|
||||
|
|
@ -517,7 +519,7 @@ sub www_edit {
|
|||
$var->{ form_submit }
|
||||
= WebGUI::Form::submit( $session, {
|
||||
name => "submit",
|
||||
value => "Save",
|
||||
value => $i18n->get('save'),
|
||||
});
|
||||
|
||||
$var->{ form_title }
|
||||
|
|
|
|||
|
|
@ -95,11 +95,7 @@ override applyConstraints => sub {
|
|||
super();
|
||||
my $maxImageSize = $options->{maxImageSize} || $self->maxImageSize || $self->session->setting->get("maxImageSize");
|
||||
my $thumbnailSize = $options->{thumbnailSize} || $self->thumbnailSize || $self->session->setting->get("thumbnailSize");
|
||||
my $parameters = $self->parameters;
|
||||
my $storage = $self->getStorageLocation;
|
||||
unless ($parameters =~ /alt\=/) {
|
||||
$self->update({parameters=>$parameters.' alt="'.$self->title.'"'});
|
||||
}
|
||||
my $file = $self->filename;
|
||||
$storage->adjustMaxImageSize($file, $maxImageSize);
|
||||
$self->generateThumbnail($thumbnailSize);
|
||||
|
|
@ -139,34 +135,52 @@ Returns the TabForm object that will be used in generating the edit page for thi
|
|||
=cut
|
||||
|
||||
override getEditForm => sub {
|
||||
my $self = shift;
|
||||
my $tabform = super();
|
||||
my $i18n = WebGUI::International->new($self->session,"Asset_Image");
|
||||
$tabform->getTab("properties")->integer(
|
||||
-name=>"thumbnailSize",
|
||||
-label=>$i18n->get('thumbnail size'),
|
||||
-hoverHelp=>$i18n->get('Thumbnail size description'),
|
||||
-value=>$self->thumbnailSize,
|
||||
);
|
||||
$tabform->getTab("properties")->textarea(
|
||||
-name=>"parameters",
|
||||
-label=>$i18n->get('parameters'),
|
||||
-hoverHelp=>$i18n->get('Parameters description'),
|
||||
-value=>$self->parameters,
|
||||
);
|
||||
if ($self->get("filename") ne "") {
|
||||
$tabform->getTab("properties")->readOnly(
|
||||
-label=>$i18n->get('thumbnail'),
|
||||
-hoverHelp=>$i18n->get('Thumbnail description'),
|
||||
-value=>'<a href="'.$self->getFileUrl.'"><img src="'.$self->getThumbnailUrl.'?noCache='.$self->session->datetime->time().'" alt="thumbnail" /></a>'
|
||||
);
|
||||
my ($x, $y) = $self->getStorageLocation->getSizeInPixels($self->get("filename"));
|
||||
$tabform->getTab("properties")->readOnly(
|
||||
-label=>$i18n->get('image size'),
|
||||
-value=>$x.' x '.$y
|
||||
);
|
||||
}
|
||||
return $tabform;
|
||||
my $self = shift;
|
||||
my $tabform = super();
|
||||
|
||||
# Add the fields defined locally and apply any overrides from the config file
|
||||
my $i18n = WebGUI::International->new($self->session,"Asset_Image");
|
||||
|
||||
tie my %extraFields, "Tie::IxHash";
|
||||
|
||||
$extraFields{thumbnailSize} = {
|
||||
fieldType => "integer",
|
||||
name => "thumbnailSize",
|
||||
label => $i18n->get('thumbnail size'),
|
||||
hoverHelp => $i18n->get('Thumbnail size description'),
|
||||
value => $self->thumbnailSize,
|
||||
};
|
||||
$extraFields{parameters} = {
|
||||
fieldType => "textarea",
|
||||
name => "parameters",
|
||||
label => $i18n->get('parameters'),
|
||||
hoverHelp => $i18n->get('Parameters description'),
|
||||
value => $self->parameters,
|
||||
};
|
||||
|
||||
if ($self->filename ne "") {
|
||||
my ($x, $y) = $self->getStorageLocation->getSizeInPixels($self->filename);
|
||||
|
||||
$extraFields{thumbnail} = {
|
||||
fieldType => "readOnly",
|
||||
label => $i18n->get('thumbnail'),
|
||||
hoverHelp => $i18n->get('Thumbnail description'),
|
||||
value => '<a href="'.$self->getFileUrl.'"><img src="'.$self->getThumbnailUrl.'?noCache='.time().'" alt="thumbnail" /></a>'
|
||||
};
|
||||
$extraFields{imageSize} = {
|
||||
fieldType => "readOnly",
|
||||
label => $i18n->get('image size'),
|
||||
value => $x.' x '.$y,
|
||||
};
|
||||
}
|
||||
|
||||
my $overrides = $self->session->config->get("assets/".$self->className);
|
||||
|
||||
foreach my $fieldName (keys %extraFields) {
|
||||
$self->setupFormField($tabform, $fieldName, \%extraFields, $overrides);
|
||||
}
|
||||
|
||||
return $tabform;
|
||||
};
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
|
@ -206,16 +220,18 @@ Renders this asset.
|
|||
|
||||
sub view {
|
||||
my $self = shift;
|
||||
my $cache = $self->session->cache;
|
||||
if (!$self->session->var->isAdminOn && $self->cacheTimeout > 10) {
|
||||
my $out = eval{$cache->get("view_".$self->getId)};
|
||||
my $session = $self->session;
|
||||
my $cache = $session->cache;
|
||||
my $cacheKey = $self->getWwwCacheKey('view');
|
||||
if (!$session->var->isAdminOn && $self->cacheTimeout > 10) {
|
||||
my $out = eval { $cache->get( $cacheKey ) };
|
||||
return $out if $out;
|
||||
}
|
||||
my %var = %{$self->get};
|
||||
my ($crop_js, $domMe) = $self->annotate_js({ just_image => 1 });
|
||||
|
||||
if ($crop_js) {
|
||||
my ($style, $url) = $self->session->quick(qw(style url));
|
||||
my ($style, $url) = $session->quick(qw(style url));
|
||||
|
||||
$style->setLink($url->extras('yui/build/fonts/fonts-min.css'), {rel=>'stylesheet', type=>'text/css'});
|
||||
$style->setLink($url->extras('yui/container/assets/container.css'), {rel=>'stylesheet', type=>'text/css'});
|
||||
|
|
@ -223,18 +239,17 @@ sub view {
|
|||
$style->setScript($url->extras('yui/build/container/container-min.js'), {type=>'text/javascript'});
|
||||
}
|
||||
|
||||
$var{controls} = $self->getToolbar;
|
||||
$var{fileUrl} = $self->getFileUrl;
|
||||
$var{fileIcon} = $self->getFileIconUrl;
|
||||
$var{thumbnail} = $self->getThumbnailUrl;
|
||||
$var{annotateJs} = "$crop_js$domMe";
|
||||
$var{parameters} = sprintf("id=%s", $self->getId());
|
||||
my $form = $self->session->form;
|
||||
$var{controls} = $self->getToolbar;
|
||||
$var{fileUrl} = $self->getFileUrl;
|
||||
$var{fileIcon} = $self->getFileIconUrl;
|
||||
$var{thumbnail} = $self->getThumbnailUrl;
|
||||
$var{annotateJs} = $crop_js . $domMe;
|
||||
$var{parameters} .= sprintf("id=%s", $self->getId);
|
||||
my $out = $self->processTemplate(\%var,undef,$self->{_viewTemplate});
|
||||
if (!$self->session->var->isAdminOn && $self->cacheTimeout > 10) {
|
||||
eval{$cache->set("view_".$self->getId, $out, $self->get("cacheTimeout"))};
|
||||
}
|
||||
return $out;
|
||||
if (!$session->var->isAdminOn && $self->cacheTimeout > 10) {
|
||||
eval{ $cache->set( $cacheKey, $out, $self->get("cacheTimeout") ) };
|
||||
}
|
||||
return $out;
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -262,23 +277,27 @@ Also adds the Image template form variable.
|
|||
=cut
|
||||
|
||||
sub www_edit {
|
||||
my $self = shift;
|
||||
return $self->session->privilege->insufficient() unless $self->canEdit;
|
||||
return $self->session->privilege->locked() unless $self->canEditIfLocked;
|
||||
my $i18n = WebGUI::International->new($self->session, 'Asset_Image');
|
||||
$self->getAdminConsole->addSubmenuItem($self->getUrl('func=resize'),$i18n->get("resize image")) if ($self->filename);
|
||||
$self->getAdminConsole->addSubmenuItem($self->getUrl('func=rotate'),$i18n->get("rotate image")) if ($self->filename);
|
||||
$self->getAdminConsole->addSubmenuItem($self->getUrl('func=crop'),$i18n->get("crop image")) if ($self->filename);
|
||||
$self->getAdminConsole->addSubmenuItem($self->getUrl('func=annotate'),$i18n->get("annotate image")) if ($self->filename);
|
||||
$self->getAdminConsole->addSubmenuItem($self->getUrl('func=undo'),$i18n->get("undo image")) if ($self->filename);
|
||||
my $tabform = $self->getEditForm;
|
||||
$tabform->getTab("display")->template(
|
||||
-value=>$self->get("templateId"),
|
||||
-namespace=>"ImageAsset",
|
||||
-hoverHelp=>$i18n->get('image template description'),
|
||||
-defaultValue=>"PBtmpl0000000000000088"
|
||||
);
|
||||
return $self->getAdminConsole->render($tabform->print,$i18n->get("edit image"));
|
||||
my $self = shift;
|
||||
my $session = $self->session;
|
||||
return $session->privilege->insufficient() unless $self->canEdit;
|
||||
return $session->privilege->locked() unless $self->canEditIfLocked;
|
||||
my $i18n = WebGUI::International->new($session, 'Asset_Image');
|
||||
if ($self->filename) {
|
||||
my $ac = $self->getAdminConsole;
|
||||
$ac->addSubmenuItem($self->getUrl('func=resize'), $i18n->get("resize image"));
|
||||
$ac->addSubmenuItem($self->getUrl('func=rotate'), $i18n->get("rotate image"));
|
||||
$ac->addSubmenuItem($self->getUrl('func=crop'), $i18n->get("crop image"));
|
||||
$ac->addSubmenuItem($self->getUrl('func=annotate'), $i18n->get("annotate image"));
|
||||
$ac->addSubmenuItem($self->getUrl('func=undo'), $i18n->get("undo image"));
|
||||
}
|
||||
my $tabform = $self->getEditForm;
|
||||
$tabform->getTab("display")->template(
|
||||
-value => $self->templateId,
|
||||
-namespace => "ImageAsset",
|
||||
-hoverHelp => $i18n->get('image template description'),
|
||||
-defaultValue => "PBtmpl0000000000000088",
|
||||
);
|
||||
return $self->getAdminConsole->render($tabform->print,$i18n->get("edit image"));
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
|
@ -293,10 +312,8 @@ have been done to it.
|
|||
sub www_undo {
|
||||
my $self = shift;
|
||||
my $previous = (@{$self->getRevisions()})[1];
|
||||
# instantiate assetId
|
||||
if ($previous) {
|
||||
$self = $self->purgeRevision();
|
||||
$self = $previous;
|
||||
$self->generateThumbnail;
|
||||
}
|
||||
return $self->www_edit();
|
||||
|
|
@ -317,20 +334,21 @@ Allow the user to place some text on their image. This is done via JS and toolt
|
|||
=cut
|
||||
|
||||
sub www_annotate {
|
||||
my $self = shift;
|
||||
return $self->session->privilege->insufficient() unless $self->canEdit;
|
||||
return $self->session->privilege->locked() unless $self->canEditIfLocked;
|
||||
my $self = shift;
|
||||
my $session = $self->session;
|
||||
return $session->privilege->insufficient() unless $self->canEdit;
|
||||
return $session->privilege->locked() unless $self->canEditIfLocked;
|
||||
if (1) {
|
||||
my $newSelf = $self->addRevision();
|
||||
delete $newSelf->{_storageLocation};
|
||||
$newSelf->getStorageLocation->annotate($newSelf->filename,$newSelf,$newSelf->session->form);
|
||||
$newSelf->getStorageLocation->annotate($newSelf->filename,$newSelf,$session->form);
|
||||
$newSelf->setSize($newSelf->getStorageLocation->getFileSize($newSelf->filename));
|
||||
$self = $newSelf;
|
||||
$self->generateThumbnail;
|
||||
WebGUI::VersionTag->autoCommitWorkingIfEnabled($session, { allowComments => 0 });
|
||||
}
|
||||
|
||||
my ($style, $url) = $self->session->quick(qw(style url));
|
||||
# $style->setLink($url->extras('annotate/imageMap.css'), {rel=>'stylesheet', type=>'text/css'});
|
||||
my ($style, $url) = $session->quick(qw(style url));
|
||||
|
||||
$style->setLink($url->extras('yui/build/resize/assets/skins/sam/resize.css'), {rel=>'stylesheet', type=>'text/css'});
|
||||
$style->setLink($url->extras('yui/build/fonts/fonts-min.css'), {rel=>'stylesheet', type=>'text/css'});
|
||||
|
|
@ -342,10 +360,7 @@ sub www_annotate {
|
|||
$style->setScript($url->extras('yui/build/resize/resize-min.js'), {type=>'text/javascript'});
|
||||
$style->setScript($url->extras('yui/build/imagecropper/imagecropper-min.js'), {type=>'text/javascript'});
|
||||
|
||||
# my $imageAsset = $self->session->db->getRow("ImageAsset","assetId",$self->getId);
|
||||
|
||||
my @pieces = split(/\n/, $self->annotations);
|
||||
# my ($top_left, $width_height, $note) = split(/\n/, $imageAsset->{annotations});
|
||||
|
||||
my ($img_null, $tooltip_block, $tooltip_none) = ('', '', '');
|
||||
for (my $i = 0; $i < $#pieces; $i += 3) {
|
||||
|
|
@ -353,7 +368,6 @@ sub www_annotate {
|
|||
$tooltip_block .= "YAHOO.util.Dom.setStyle('tooltip$i', 'display', 'block');\n";
|
||||
$tooltip_none .= "YAHOO.util.Dom.setStyle('tooltip$i', 'display', 'none');\n";
|
||||
my $j = $i + 2;
|
||||
# warn("i: $i: ", $self->session->form->process("delAnnotate$i"));
|
||||
}
|
||||
|
||||
my $image = '<div align="center" class="yui-skin-sam"><img src="'.$self->getStorageLocation->getUrl($self->filename).'" style="border-style:none;" alt="'.$self->filename.'" id="yui_img" /></div>';
|
||||
|
|
@ -361,8 +375,8 @@ sub www_annotate {
|
|||
my ($width, $height) = $self->getStorageLocation->getSize($self->filename);
|
||||
|
||||
my @checkboxes = ();
|
||||
my $i18n = WebGUI::International->new($self->session,"Asset_Image");
|
||||
my $f = WebGUI::HTMLForm->new($self->session,-action=>$self->getUrl);
|
||||
my $i18n = WebGUI::International->new($session,"Asset_Image");
|
||||
my $f = WebGUI::HTMLForm->new($session);
|
||||
|
||||
$self->getAdminConsole->addSubmenuItem($self->getUrl('func=edit'),$i18n->get("edit image"));
|
||||
$f->hidden(
|
||||
|
|
@ -539,49 +553,51 @@ Returns the user to the roate form.
|
|||
=cut
|
||||
|
||||
sub www_rotate {
|
||||
my $self = shift;
|
||||
return $self->session->privilege->insufficient() unless $self->canEdit;
|
||||
return $self->session->privilege->locked() unless $self->canEditIfLocked;
|
||||
if (defined $self->session->form->process("Rotate")) {
|
||||
my $self = shift;
|
||||
my $session = $self->session;
|
||||
return $session->privilege->insufficient() unless $self->canEdit;
|
||||
return $session->privilege->locked() unless $self->canEditIfLocked;
|
||||
if (defined $session->form->process("Rotate")) {
|
||||
my $newSelf = $self->addRevision();
|
||||
delete $newSelf->{_storageLocation};
|
||||
$newSelf->getStorageLocation->rotate($newSelf->filename,$newSelf->session->form->process("Rotate"));
|
||||
$newSelf->getStorageLocation->rotate($newSelf->filename,$session->form->process("Rotate"));
|
||||
$newSelf->setSize($newSelf->getStorageLocation->getFileSize($newSelf->filename));
|
||||
$self = $newSelf;
|
||||
$self->generateThumbnail;
|
||||
WebGUI::VersionTag->autoCommitWorkingIfEnabled($session, { allowComments => 0 });
|
||||
}
|
||||
|
||||
my ($x, $y) = $self->getStorageLocation->getSizeInPixels($self->filename);
|
||||
|
||||
##YUI specific datatable CSS
|
||||
my ($style, $url) = $self->session->quick(qw(style url));
|
||||
my ($style, $url) = $session->quick(qw(style url));
|
||||
|
||||
my $img_name = $self->getStorageLocation->getUrl($self->filename);
|
||||
my $img_file = $self->filename;
|
||||
my $image = '<div align="center" class="yui-skin-sam"><img src="'.$self->getStorageLocation->getUrl($self->filename).'" style="border-style:none;" alt="'.$self->filename.'" id="yui_img" /></div>';
|
||||
|
||||
my $i18n = WebGUI::International->new($self->session,"Asset_Image");
|
||||
my $i18n = WebGUI::International->new($session,"Asset_Image");
|
||||
$self->getAdminConsole->addSubmenuItem($self->getUrl('func=edit'),$i18n->get("edit image"));
|
||||
my $f = WebGUI::HTMLForm->new($self->session,-action=>$self->getUrl);
|
||||
my $f = WebGUI::HTMLForm->new($session);
|
||||
$f->hidden(
|
||||
-name=>"func",
|
||||
-value=>"rotate"
|
||||
);
|
||||
);
|
||||
$f->button(
|
||||
-value=>"Left",
|
||||
-extras=>qq(onclick="var deg = document.getElementById('Rotate_formId').value; deg = parseInt(deg) + 90; document.getElementById('Rotate_formId').value = deg;"),
|
||||
);
|
||||
);
|
||||
$f->button(
|
||||
-value=>"Right",
|
||||
-extras=>qq(onclick="var deg = document.getElementById('Rotate_formId').value; deg = parseInt(deg) - 90; document.getElementById('Rotate_formId').value = deg;"),
|
||||
);
|
||||
);
|
||||
$f->integer(
|
||||
-label=>$i18n->get('degree'),
|
||||
-name=>"Rotate",
|
||||
-value=>0,
|
||||
);
|
||||
);
|
||||
$f->submit;
|
||||
return $self->getAdminConsole->render($f->print.$image,$i18n->get("rotate image"));
|
||||
return $self->getAdminConsole->render($f->print.$image,$i18n->get("rotate image"));
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
|
@ -596,22 +612,24 @@ Returns the user to the resize form.
|
|||
=cut
|
||||
|
||||
sub www_resize {
|
||||
my $self = shift;
|
||||
return $self->session->privilege->insufficient() unless $self->canEdit;
|
||||
return $self->session->privilege->locked() unless $self->canEditIfLocked;
|
||||
if ($self->session->form->process("newWidth") || $self->session->form->process("newHeight")) {
|
||||
my $newSelf = $self->addRevision();
|
||||
delete $newSelf->{_storageLocation};
|
||||
$newSelf->getStorageLocation->resize($newSelf->filename,$newSelf->session->form->process("newWidth"),$newSelf->session->form->process("newHeight"));
|
||||
$newSelf->setSize($newSelf->getStorageLocation->getFileSize($newSelf->filename));
|
||||
$self = $newSelf;
|
||||
$self->generateThumbnail;
|
||||
}
|
||||
my $self = shift;
|
||||
my $session = $self->session;
|
||||
return $session->privilege->insufficient() unless $self->canEdit;
|
||||
return $session->privilege->locked() unless $self->canEditIfLocked;
|
||||
if ($session->form->process("newWidth") || $session->form->process("newHeight")) {
|
||||
my $newSelf = $self->addRevision();
|
||||
delete $newSelf->{_storageLocation};
|
||||
$newSelf->getStorageLocation->resize($newSelf->filename,$session->form->process("newWidth"),$session->form->process("newHeight"));
|
||||
$newSelf->setSize($newSelf->getStorageLocation->getFileSize($newSelf->filename));
|
||||
$self = $newSelf;
|
||||
$self->generateThumbnail;
|
||||
WebGUI::VersionTag->autoCommitWorkingIfEnabled($session, { allowComments => 0 });
|
||||
}
|
||||
|
||||
my ($x, $y) = $self->getStorageLocation->getSizeInPixels($self->filename);
|
||||
|
||||
##YUI specific datatable CSS
|
||||
my ($style, $url) = $self->session->quick(qw(style url));
|
||||
my ($style, $url) = $session->quick(qw(style url));
|
||||
|
||||
$style->setLink($url->extras('yui/build/fonts/fonts-min.css'), {rel=>'stylesheet', type=>'text/css'});
|
||||
$style->setLink($url->extras('yui/build/resize/assets/skins/sam/resize.css'), {rel=>'stylesheet', type=>'text/css'});
|
||||
|
|
@ -630,8 +648,8 @@ sub www_resize {
|
|||
var resize = new YAHOO.util.Resize('yui_img', {
|
||||
handles: 'all',
|
||||
knobHandles: true,
|
||||
height: '${x}px',
|
||||
width: '${y}px',
|
||||
height: '${y}px',
|
||||
width: '${x}px',
|
||||
proxy: true,
|
||||
ghost: true,
|
||||
status: true,
|
||||
|
|
@ -658,33 +676,33 @@ sub www_resize {
|
|||
</script>
|
||||
);
|
||||
|
||||
my $i18n = WebGUI::International->new($self->session,"Asset_Image");
|
||||
$self->getAdminConsole->addSubmenuItem($self->getUrl('func=edit'),$i18n->get("edit image"));
|
||||
my $f = WebGUI::HTMLForm->new($self->session,-action=>$self->getUrl);
|
||||
$f->hidden(
|
||||
-name=>"func",
|
||||
-value=>"resize"
|
||||
);
|
||||
$f->readOnly(
|
||||
-label=>$i18n->get('image size'),
|
||||
-hoverHelp=>$i18n->get('image size description'),
|
||||
-value=>$x.' x '.$y,
|
||||
);
|
||||
$f->integer(
|
||||
-label=>$i18n->get('new width'),
|
||||
-hoverHelp=>$i18n->get('new width description'),
|
||||
-name=>"newWidth",
|
||||
-value=>$x,
|
||||
);
|
||||
$f->integer(
|
||||
-label=>$i18n->get('new height'),
|
||||
-hoverHelp=>$i18n->get('new height description'),
|
||||
-name=>"newHeight",
|
||||
-value=>$y,
|
||||
);
|
||||
$f->submit;
|
||||
my $image = '<div align="center" class="yui-skin-sam"><img src="'.$self->getStorageLocation->getUrl($self->filename).'" style="border-style:none;" alt="'.$self->filename.'" id="yui_img" /></div>'.$resize_js;
|
||||
return $self->getAdminConsole->render($f->print.$image,$i18n->get("resize image"));
|
||||
my $i18n = WebGUI::International->new($session,"Asset_Image");
|
||||
$self->getAdminConsole->addSubmenuItem($self->getUrl('func=edit'),$i18n->get("edit image"));
|
||||
my $f = WebGUI::HTMLForm->new($session);
|
||||
$f->hidden(
|
||||
-name=>"func",
|
||||
-value=>"resize"
|
||||
);
|
||||
$f->readOnly(
|
||||
-label=>$i18n->get('image size'),
|
||||
-hoverHelp=>$i18n->get('image size description'),
|
||||
-value=>$x.' x '.$y,
|
||||
);
|
||||
$f->integer(
|
||||
-label=>$i18n->get('new width'),
|
||||
-hoverHelp=>$i18n->get('new width description'),
|
||||
-name=>"newWidth",
|
||||
-value=>$x,
|
||||
);
|
||||
$f->integer(
|
||||
-label=>$i18n->get('new height'),
|
||||
-hoverHelp=>$i18n->get('new height description'),
|
||||
-name=>"newHeight",
|
||||
-value=>$y,
|
||||
);
|
||||
$f->submit;
|
||||
my $image = '<div align="center" class="yui-skin-sam"><img src="'.$self->getStorageLocation->getUrl($self->filename).'" style="border-style:none;" alt="'.$self->filename.'" id="yui_img" /></div>'.$resize_js;
|
||||
return $self->getAdminConsole->render($f->print.$image,$i18n->get("resize image"));
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
|
@ -700,29 +718,31 @@ Returns the user to the cropping form.
|
|||
=cut
|
||||
|
||||
sub www_crop {
|
||||
my $self = shift;
|
||||
return $self->session->privilege->insufficient() unless $self->canEdit;
|
||||
return $self->session->privilege->locked() unless $self->canEditIfLocked;
|
||||
my $self = shift;
|
||||
my $session = $self->session;
|
||||
return $session->privilege->insufficient() unless $self->canEdit;
|
||||
return $session->privilege->locked() unless $self->canEditIfLocked;
|
||||
|
||||
if ($self->session->form->process("Width") || $self->session->form->process("Height")
|
||||
|| $self->session->form->process("Top") || $self->session->form->process("Left")) {
|
||||
if ($session->form->process("Width") || $session->form->process("Height")
|
||||
|| $session->form->process("Top") || $session->form->process("Left")) {
|
||||
my $newSelf = $self->addRevision();
|
||||
delete $newSelf->{_storageLocation};
|
||||
$newSelf->getStorageLocation->crop(
|
||||
$newSelf->filename,
|
||||
$newSelf->session->form->process("Width"),
|
||||
$newSelf->session->form->process("Height"),
|
||||
$newSelf->session->form->process("Top"),
|
||||
$newSelf->session->form->process("Left")
|
||||
$session->form->process("Width"),
|
||||
$session->form->process("Height"),
|
||||
$session->form->process("Top"),
|
||||
$session->form->process("Left")
|
||||
);
|
||||
$self = $newSelf;
|
||||
$self->generateThumbnail;
|
||||
WebGUI::VersionTag->autoCommitWorkingIfEnabled($session, { allowComments => 0 });
|
||||
}
|
||||
|
||||
my $filename = $self->filename;
|
||||
|
||||
##YUI specific datatable CSS
|
||||
my ($style, $url) = $self->session->quick(qw(style url));
|
||||
my ($style, $url) = $session->quick(qw(style url));
|
||||
|
||||
my $crop_js = qq(
|
||||
<script>
|
||||
|
|
@ -760,10 +780,10 @@ sub www_crop {
|
|||
$style->setScript($url->extras('yui/build/resize/resize-min.js'), {type=>'text/javascript'});
|
||||
$style->setScript($url->extras('yui/build/imagecropper/imagecropper-min.js'), {type=>'text/javascript'});
|
||||
|
||||
my $i18n = WebGUI::International->new($self->session,"Asset_Image");
|
||||
my $i18n = WebGUI::International->new($session,"Asset_Image");
|
||||
|
||||
$self->getAdminConsole->addSubmenuItem($self->getUrl('func=edit'),$i18n->get("edit image"));
|
||||
my $f = WebGUI::HTMLForm->new($self->session,-action=>$self->getUrl);
|
||||
my $f = WebGUI::HTMLForm->new($session);
|
||||
$f->hidden(
|
||||
-name=>"degree",
|
||||
-value=>"0"
|
||||
|
|
@ -799,7 +819,7 @@ sub www_crop {
|
|||
);
|
||||
$f->submit;
|
||||
|
||||
my $image = '<div align="center" class="yui-skin-sam"><img src="'.$self->getStorageLocation->getUrl($filename).'" style="border-style:none;" alt="'.$filename.'" id="yui_img" /></div>'.$crop_js;
|
||||
my $image = '<div align="center" class="yui-skin-sam"><img src="'.$self->getStorageLocation->getUrl($filename).'" style="border-style:none;" alt="'.$filename.'" id="yui_img" /></div>'.$crop_js;
|
||||
|
||||
return $self->getAdminConsole->render($f->print.$image,$i18n->get("crop image"));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -184,8 +184,9 @@ used to show the file to administrators.
|
|||
sub view {
|
||||
my $self = shift;
|
||||
my $cache = $self->session->cache;
|
||||
if (!$self->session->var->isAdminOn && $self->cacheTimeout > 10) {
|
||||
my $out = eval{$cache->get("view_".$self->getId)};
|
||||
my $cacheKey = $self->getWwwCacheKey('view');
|
||||
if (!$self->session->var->isAdminOn && $self->cacheTimeout > 10) {
|
||||
my $out = eval { $cache->get( $cacheKey ) };
|
||||
return $out if $out;
|
||||
}
|
||||
my %var = %{$self->get};
|
||||
|
|
@ -207,10 +208,10 @@ sub view {
|
|||
$var{noInitialPage} = $i18n->get('noInitialPage');
|
||||
$var{noFileSpecified} = $i18n->get('noFileSpecified');
|
||||
my $out = $self->processTemplate(\%var,undef,$self->{_viewTemplate});
|
||||
if (!$self->session->var->isAdminOn && $self->cacheTimeout > 10) {
|
||||
eval{$cache->set("view_".$self->getId, $out, $self->cacheTimeout)};
|
||||
}
|
||||
return $out;
|
||||
if (!$self->session->var->isAdminOn && $self->cacheTimeout > 10) {
|
||||
eval{ $cache->set( $cacheKey, $out, $self->cacheTimeout) };
|
||||
}
|
||||
return $out;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue