ePages 6.11.0 - DE_EPAGES/MediaGallery/API/Object/MediaGallery.pm

Package DE_EPAGES::MediaGallery::API::Object::MediaGallery

Interface for the MediaGallery folder.

Functions

absolutePath
addUploadedFiles
copyFileFromImageDb
createDirectory
createThumbnail
deleteDirectory
deleteFile
deleteThumbnail
directorySize
existsDirectory
existsFile
gallery2attributeFileName
increaseGallerySize
insertFile
moveFile
previewPath
relativePath
renameDirectory
renameFile
resizeImage
testGallerySize

absolutePath

Adds the public path part of the media gallery to an relative path.

Syntax
$AbsolutePath = $MediaGallery->absolutePath($RelativePath);
Example
$AbsolutePath = $MediaGallery->absolutePath("file.txt");
# $AbsolutePath eq "D:/epages/.../MediaGallery/file.txt"
Input
$AbsolutePath (string)
absolute path to a file or directory beneath the media
gallery root
Return
$RelativePath (string)
path relative to the media gallery root

addUploadedFiles

Adds files to the media gallery as given by $Servlet->form.

Syntax
$MediaGallery->addUploadedFiles($Directory, $hFiles, $hFileNames);
Input
$Directory (string)
a media gallery's sub directory to add the files to
$hFiles (hash.string)
references to the uploaded files' content as given by
$Servlet->form->files
$hFileNames (hash.string)
corresponding file names of the uploaded files
Return
$aUploadedFiles (array.string)
returns the names of the uploaded files

copyFileFromImageDb

Copies a file from the global image db to the user's media gallery. Uses webget if needed.

Syntax
$MediaGallery->copyFileFromImageDb($SourceFile, $TargetDirectory);
$MediaGallery->copyFileFromImageDb(
    "http://host.com/imagedb/image.jpg",
    "MyPictures/SubDir");
Input
$SourceFile (string)
the source file in the image db, either as a local file
name or as uri (starting with http:// or https://)
$TargetDirectory (string)
target directory in the user's media gallery to copy
the file to. If the value is undefined the main directory is used

createDirectory

Creates a directory in the media gallery.

Syntax
$MediaGallery->createDirectory($Path);
$MediaGallery->createDirectory($Name, $BaseDir);
Example
$MediaGallery->createDirectory('MyFiles/SomeDir/NewDir');
$MediaGallery->createDirectory('NewDir', 'MyFiles/SomeDir');
$MediaGallery->createDirectory('NewDir', 'MediaGallery/MyFiles/SomeDir');
Input
$TargetDirectory (string)
name or path of the directory to create.
$BaseDirectory (string)
optional, a directory in the media gallery relative to
the media gallery root (base path for $TargetDirectory)
$hFlags
some options:
usebasedirectory => set to 1 to force the use of the second method
parameter for the base directory (optional, default is 0)

createThumbnail

Creates an thumbnail for display on mediagallery.

Syntax
$GalleryImage->createThumbnail($ImageFile);
Input
$ImageFile (string)
original filename

deleteDirectory

Deletes a directory in the media gallery.

Syntax
$MediaGallery->deleteDirectory($Directory);
Example
$MediaGallery->deleteDirectory('MyFiles/SomeDir');
Input
$Directory (string)
a file in the media gallery relative to the media gallery
root

deleteFile

Deletes a file in the media gallery and may delete the parent folder, if it becomes empty.

Syntax
$MediaGallery->deleteFile($FileName, $DeleteEmptyDirectory);
Example
$MediaGallery->deleteFile('MyFiles/file.txt');
$MediaGallery->deleteFile('MyFiles/file.txt', 1);
Input
$FileName (string)
a file in the media gallery relative to the media gallery root
$DeleteEmptyDirectory (boolean)
if directory becomes empty, then it may be deleted;
used for preview images/directories (optional)

deleteThumbnail

Deletes an thumbnail of the given mediagallery file.

Syntax
$GalleryImage->deleteThumbnail($ImageFile);
Input
$ImageFile (string)
original filename (relative path)

directorySize

Returns the default value of a directory to take in count for feature GallerySize.

Syntax
$DirectorySize = $MediaGallery->directorySize;
Return
$DirectorySize (int)
directory size in bytes

existsDirectory

Returns whether a directory exists in the user's media gallery.

Syntax
$MediaGallery->existsDirectory($RelativePath);
Example
$MediaGallery->existsDirectory('MyFiles/SomeDir');
Input
$RelativePath (string)
a directory in the media gallery relative to the media
gallery root
Return
$ExistsFile (boolean)
exists file

existsFile

Returns whether a file exists in the user's media gallery.

Syntax
$MediaGallery->existsFile($RelativePath);
Example
$MediaGallery->existsFile('MyFiles/file.txt');
Input
$RelativePath (string)
a file in the media gallery relative to the media gallery
root
Return
$ExistsFile (boolean)
exists file

gallery2attributeFileName

Adds MediaGallery/ in front of filename.

Syntax
$AttributeFile = $GalleryImage->gallery2attributeFileName($GalleryFile);
Input
$AttributeFile (string)
'MediaGallery/Dir/File.ext'
Return
$GalleryFile (string)
'Dir/File.ext'

increaseGallerySize

Increases the size of the gallery by a particular amount of bytes.

Syntax
$MediaGallery->increaseGallerySize($Value);
Example
$MediaGallery->increaseGallerySize(1024);
Input
$Value (int)
value in bytes to add to the gallery size

insertFile

Inserts a file in the media gallery.

Syntax
$MediaGallery->insertFile($FileName, $rContent, $hFlags);
Example
$MediaGallery->insertFile('MyFiles/SomeDir/File.ext', $hForm->{'File'}, {overwrite=>1});
Input
$FileName (string)
filename includes path
$rContent (ref.string)
content of file
$hFlags
some options:
overwrite => if true then the file will be overwritten, if it already
exists, otherwise a similar file name will be found, that
does not exist (optional, default is 0)
Return
$FileName (string)
the filename (with path relative to the media gallery root)
of the new created file

moveFile

Moves a file in the media gallery to another directory.

Syntax
$MediaGallery->moveFile($File, $NewDirectory);
Example
$MediaGallery->moveFile('MyFiles/OldDir/file.txt', 'MyFiles/NewDir');
Input
$File (string)
a file in the media gallery relative to the media gallery
root
$NewDirectory (string)
a directory in the media gallery relative to the media gallery
root

previewPath

Removes MediaGallery/ in front of filename.

Syntax
$GalleryFile = $GalleryImage->attribute2galleryFileName($AttributeFile);
Input
$AttributeFile (string)
'MediaGallery/Dir/File.ext'
Return
$GalleryFile (string)
'Dir/File.ext'

relativePath

Removes the public path part of the media gallery from an absolute path.

Syntax
$RelativePath = $MediaGallery->relativePath($AbsolutePath);
Example
$RelativePath = $MediaGallery->relativePath("D:/epages/.../MediaGallery/file.txt");
# $RelativePath eq "MediaGallery/file.txt"
Input
$AbsolutePath (string)
absolute path to a file or directory beneath the media
gallery root
Return
$RelativePath (string)
path relative to the media gallery root

renameDirectory

Renames a directory in the media gallery.

Syntax
$MediaGallery->renameDirectory($Directory, $NewDirectoryName);
Example
$MediaGallery->renameDirectory('MyFiles/OldDir', 'NewDir');
Input
$Directory (string)
a directory in the media gallery relative to the media gallery
root
$NewDirectoryName (string)
the new directory name (without any path)

renameFile

Renames a file in the media gallery.

Syntax
$MediaGallery->renameFile($File, $NewFileName);
Example
$MediaGallery->renameFile('OldDir/MyFiles/oldfile.txt', 'newfile.txt');
Input
$File (string)
a files in the media gallery relative to the media gallery
root
$NewFileName (string)
the new file name (without any path)

resizeImage

Resizes an image file in the media gallery and writes the results to a specified directory in the media gallery.

Syntax
$MediaGallery->resizeImage($SourceFile, $TargetDirectory, $Width, $Height, $Quality);
Example
$MediaGallery->resizeImage(
    'MyFiles/image.jpg',
    'MyFiles/Thumbnails',
    100,
    80,
    85);
Input
$SourceFile (string)
a file in the media gallery relative to the media gallery
root
$TargetFile (string)
absolute file name of the target file
$Width (int)
maximum width of the resized image in pixels
$Height (int)
maximum height of the resized image in pixels
$Quality (int)
quality of the resized image (if applies), 1..100
(optional = 100)

testGallerySize

test if size of the gallery is to large.

Syntax
$MediaGallery->testGallerySize;