Sindbad~EG File Manager
<?php
/*
* Gallery - a web based photo album viewer and editor
* Copyright (C) 2000-2007 Bharat Mediratta
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or (at
* your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
*/
GalleryCoreApi::requireOnce('modules/core/classes/GalleryDataItem.class');
/**
* A subclass of DataItem for containing Animations.
* A GalleryItem whose source is an animation of some kind (like a Flash or Shockwave)
*
* @g2 <class-name>GalleryAnimationItem</class-name>
* @g2 <parent-class-name>GalleryDataItem</parent-class-name>
* @g2 <schema>
* @g2 <schema-major>1</schema-major>
* @g2 <schema-minor>0</schema-minor>
* @g2 </schema>
* @g2 <requires-id/>
*
* @package GalleryCore
* @subpackage Classes
* @author Bharat Mediratta <bharat@menalto.com>
* @version $Revision: 15534 $
*/
class GalleryAnimationItem extends GalleryDataItem {
/**
* The width of this animation.
* @var int
*
* @g2 <member>
* @g2 <member-name>width</member-name>
* @g2 <member-type>INTEGER</member-type>
* @g2 <linked/>
* @g2 <member-external-access>FULL</member-external-access>
* @g2 </member>
*/
var $width;
/**
* The height of this animation.
* @var int
*
* @g2 <member>
* @g2 <member-name>height</member-name>
* @g2 <member-type>INTEGER</member-type>
* @g2 <linked/>
* @g2 <member-external-access>FULL</member-external-access>
* @g2 </member>
*/
var $height;
/**
* @see GalleryDataItem::canBeViewedInline
*/
function canBeViewedInline() {
/* The mimeTypes listed here should provide a render() output */
static $mimeList = array(
'application/x-shockwave-flash',
'application/x-director',
);
return $this->_canBeViewedInline(
($this->getWidth() > 0 && $this->getHeight() > 0) ? $mimeList : null);
}
/**
* Create a new GalleryAnimationItem from a animation file
*
* @param int $parentId the id of the parent GalleryItem
* @param string $animationFileName the path to the source animation
* @param string $mimeType
* @param string $targetName the desired name of the new item
* @param boolean $symlink (optional) a boolean true if we should symlink instead
* of copy (default is false).
* @return object GalleryStatus a status code
*/
function create($parentId, $animationFileName, $mimeType, $targetName=null, $symlink=false) {
global $gallery;
$platform =& $gallery->getPlatform();
/* Validate the input filename */
if (empty($animationFileName)) {
return GalleryCoreApi::error(ERROR_BAD_PARAMETER);
}
if (!$platform->file_exists($animationFileName)) {
return GalleryCoreApi::error(ERROR_BAD_PATH);
}
/* Create our data item */
$ret = parent::create($parentId, $animationFileName, $mimeType, $targetName, $symlink);
if ($ret) {
return $ret;
}
/* Default to empty dimensions */
$this->setWidth(0);
$this->setHeight(0);
/* We're linkable */
$this->setIsLinkable(true);
/* Detect our dimensions, if possible */
$ret = $this->rescan();
if ($ret) {
/* Cleanup our datafile on failure */
list ($ret2, $path) = $this->fetchPath();
if (!$ret2) {
@$platform->unlink($path);
}
return $ret;
}
return null;
}
/**
* @see GalleryDataItem::rescan
*/
function rescan() {
global $gallery;
$ret = parent::rescan();
if ($ret) {
return $ret;
}
list ($ret, $path) = $this->fetchPath();
if ($ret) {
return $ret;
}
$mimeType = $this->getMimeType();
list ($ret, $toolkit) = GalleryCoreApi::getToolkitByProperty($mimeType, 'dimensions');
if ($ret) {
return $ret;
}
if (isset($toolkit)) {
list ($ret, $dimensions) = $toolkit->getProperty($mimeType, 'dimensions', $path);
if ($ret) {
/*
* If we can't get the dimensions, it's probably a bad image.
* Or our graphics code is broken. Hard to tell which at this point.
*/
$ret->addErrorCode(ERROR_BAD_DATA_TYPE);
return $ret;
}
$this->setWidth($dimensions[0]);
$this->setHeight($dimensions[1]);
}
return null;
}
/**
* @see GalleryEntity::itemTypeName
*/
function itemTypeName($localized = true) {
global $gallery;
if ($localized) {
list ($ret, $core) = GalleryCoreApi::loadPlugin('module', 'core');
if (! $ret) {
return array($core->translate('Animation'), $core->translate('animation'));
}
}
return array('Animation', 'animation');
}
/**
* @see GalleryDataItem::render
*/
function render($format, $params) {
global $gallery;
$fallback = trim(preg_replace("/[\r\n]/", '', $params['fallback']));
switch($format) {
case 'HTML':
$urlGenerator =& $gallery->getUrlGenerator();
$src = $urlGenerator->generateUrl(
array('view' => 'core.DownloadItem', 'itemId' => $this->getId(),
'serialNumber' => $this->getSerialNumber()),
array('forceFullUrl' => !empty($params['forceFullUrl'])));
list ($width, $height) = array($this->getWidth(), $this->getHeight());
switch($this->getMimeType()) {
case 'application/x-shockwave-flash':
return sprintf('<script type="text/javascript">
// <![CDATA[
if (window.ActiveXObject) {
document.write(\'<object id="animation"\');
document.write(\' %s\');
document.write(\' width="%s"\');
document.write(\' height="%s"\');
document.write(\' autoplay="true"\');
document.write(\' ' .
'pluginspage="http://www.apple.com/quicktime/download/"\');
document.write(\' codebase="http://download.macromedia.com' .
'/pub/shockwave/cabs/flash/swflash.cab#version=5,0,30,0"\');
document.write(\' ' .
'classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000">\');
document.write(\' <param name="movie" value="%s" />\');
document.write(\' <param name="quality" value="high" />\');
document.write(\' <param name="salign" value="TL" />\');
document.write(\' <param name="swliveconnect" value="true" />\');
document.write(\' %s\');
document.write(\'</object>\');
} else {
document.write(\'<object id="movie"\');
document.write(\' %s\');
document.write(\' type="%s"\');
document.write(\' data="%s"\');
document.write(\' width="%s"\');
document.write(\' height="%s">\');
document.write(\' <param name="movie" value="%s" />\');
document.write(\' <param name="quality" value="high" />\');
document.write(\' <param name="salign" value="TL" />\');
document.write(\' <param name="swliveconnect" value="true" />\');
document.write(\' %s\');
document.write(\'</object>\');
}
//]]>
</script>',
/* IE Object */
!empty($params['class']) ? 'class="' . $params['class'] . '"' : '',
$width,
$height,
$src,
$fallback,
/* Mozilla Object */
!empty($params['class']) ? 'class="' . $params['class'] . '"' : '',
$this->getMimeType(),
$src,
$width,
$height,
$src,
$fallback);
case 'application/x-director':
return sprintf('<script type="text/javascript">
// <![CDATA[
if (window.ActiveXObject) {
document.write(\'<object id="animation"\');
document.write(\' %s\');
document.write(\' width="%s"\');
document.write(\' height="%s"\');
document.write(\' autoplay="true"\');
document.write(\' ' .
'pluginspage="http://www.apple.com/quicktime/download/"\');
document.write(\' codebase="http://download.macromedia.com' .
'/pub/shockwave/cabs/director/sw.cab#version=8,0,0,0"\');
document.write(\' ' .
'classid="clsid:166B1BCA-3F9C-11CF-8075-444553540000">\');
document.write(\' <param name="src" value="%s" />\');
document.write(\' <param name="swRemote" value="swTarget=false ' .
'swVolume=false swRestart=false swPausePlay=false ' .
'swFastForward=false swContextMenu=true swSend=false" />\');
document.write(\' <param name="sw3" value="2" />\');
document.write(\' <param name="swStretchStyle" value="none" />\');
document.write(\' <param name="bgColor" value="#000000" />\');
document.write(\' %s\');
document.write(\'</object>\');
} else {
document.write(\'<object id="movie"\');
document.write(\' %s\');
document.write(\' type="%s"\');
document.write(\' data="%s"\');
document.write(\' width="%s"\');
document.write(\' height="%s">\');
document.write(\' %s\');
document.write(\'</object>\');
}
//]]>
</script>',
/* IE Object */
!empty($params['class']) ? 'class="' . $params['class'] . '"' : '',
$width,
$height,
$src,
$fallback,
/* Mozilla Object */
!empty($params['class']) ? 'class="' . $params['class'] . '"' : '',
$this->getMimeType(),
$src,
$width,
$height,
$fallback);
default:
return $fallback;
}
default:
return null;
}
}
/**
* @see GalleryEntity::getClassName
*/
function getClassName() {
return 'GalleryAnimationItem';
}
function getWidth() {
return $this->width;
}
function setWidth($width) {
$this->width = $width;
}
function getHeight() {
return $this->height;
}
function setHeight($height) {
$this->height = $height;
}
}
?>
Sindbad File Manager Version 1.0, Coded By Sindbad EG ~ The Terrorists