예제 #1
0
 /**
  * Constructor for class-video
  *
  * @param object &$album the owning album
  * @param sting $filename the filename of the image
  * @return Image
  */
 function Video(&$album, $filename)
 {
     global $_zp_supported_images;
     // $album is an Album object; it should already be created.
     if (!is_object($album)) {
         return NULL;
     }
     if (!$this->classSetup($album, $filename)) {
         // spoof attempt
         $this->exists = false;
         return;
     }
     $this->sidecars = $_zp_supported_images;
     $this->video = true;
     $this->objectsThumb = checkObjectsThumb($album->localpath, $filename);
     // Check if the file exists.
     if (!file_exists($this->localpath) || is_dir($this->localpath)) {
         $this->exists = false;
         return;
     }
     // This is where the magic happens...
     $album_name = $album->name;
     $this->updateDimensions();
     if (parent::PersistentObject('images', array('filename' => $filename, 'albumid' => $this->album->id), 'filename', false, empty($album_name))) {
         $this->set('mtime', $ts = filemtime($this->localpath));
         $this->updateMetaData();
         $this->save();
         zp_apply_filter('new_image', $this);
     }
 }
 /**
  * creates a transient image (that is, one that is not stored in the database)
  *
  * @param object $gallery
  * @param string $image the full path to the image
  * @return transientimage
  */
 function Transientimage(&$album, $image)
 {
     if (!is_object($album)) {
         return NULL;
     }
     $this->album = $album;
     $this->localpath = $image;
     $filename = makeSpecialImageName($image);
     $this->filename = $filename;
     $this->displayname = substr(basename($image), 0, strrpos(basename($image), '.'));
     if (empty($this->displayname)) {
         $this->displayname = $this->filename;
     }
     $this->filemtime = filemtime($this->localpath);
     $this->comments = null;
     parent::PersistentObject('images', array('filename' => $filename, 'albumid' => $this->album->id), 'filename', false, true);
 }
예제 #3
0
 /**
  * Constructor for class-video
  *
  * @param object &$album the owning album
  * @param sting $filename the filename of the image
  * @return Image
  */
 function Video(&$album, $filename)
 {
     // $album is an Album object; it should already be created.
     if (!is_object($album)) {
         return NULL;
     }
     $this->classSetup($album, $filename);
     $this->video = true;
     $this->objectsThumb = checkObjectsThumb($album->localpath, $filename);
     // Check if the file exists.
     if (!file_exists($this->localpath) || is_dir($this->localpath)) {
         $this->exists = false;
         return NULL;
     }
     // This is where the magic happens...
     $album_name = $album->name;
     $this->updateDimensions();
     // TODO: figure out how to know if this should change. I.e. old videos, changes of the flash player.
     if (parent::PersistentObject('images', array('filename' => $filename, 'albumid' => $this->album->id), 'filename', false, empty($album_name))) {
         $newDate = strftime('%Y/%m/%d %T', filemtime($this->localpath));
         $this->set('date', $newDate);
         $alb = $this->album;
         if (!is_null($alb)) {
             if (is_null($alb->getDateTime()) || getOption('album_use_new_image_date')) {
                 $this->album->setDateTime($newDate);
                 //  not necessarily the right one, but will do. Can be changed in Admin
                 $this->album->save();
             }
         }
         $title = $this->getDefaultTitle();
         $this->set('title', sanitize($title, 2));
         $this->set('mtime', filemtime($this->localpath));
         apply_filter('new_image', $this);
         $this->save();
     }
 }
	/**
	 * @param object $album the owner album
	 * @param string $filename the filename of the media file
	 */
	function __construct(&$album, $filename) {
		global $_zp_supported_images;

		// $album is an Album object; it should already be created.
		if ( ! is_object($album)) return NULL;
		if ( ! $this->classSetup($album, $filename)) { // spoof attempt
			$this->exists = FALSE;
			return;
		}
		$this->sidecars = $_zp_supported_images;
		$this->objectsThumb = checkObjectsThumb($album->localpath, $filename);
		// Check if the file exists.
		if ( ! file_exists($this->localpath) || is_dir($this->localpath)) {
			$this->exists = FALSE;
			return;
		}

		/* check the file extension, and then set the mediaType if supported */
		$extension = substr(strtolower(strrchr($this->localpath,'.')),1);
		foreach ($this->mediaTypes AS $t => $l) {
			if (in_array($extension,$l)) {
				$this->mediaType = $t;
				break;
			}
		}
		unset($t,$l);

		$this->updateDimensions();

		if (parent::PersistentObject('images', array('filename'=>$filename, 'albumid'=>$this->album->id), 'filename', FALSE, FALSE)) {
			$this->set('mtime', $ts = filemtime($this->localpath));
			$this->updateMetaData();
			$this->save();
			zp_apply_filter('new_image', $this);
		}
	}
 /**
  * creates a textobject (image standin)
  *
  * @param object $album the owner album
  * @param string $filename the filename of the text file
  * @return TextObject
  */
 function TextObject($album, $filename)
 {
     // $album is an Album object; it should already be created.
     if (!is_object($album)) {
         return NULL;
     }
     $this->classSetup($album, $filename);
     $this->objectsThumb = checkObjectsThumb($album->localpath, $filename);
     // Check if the file exists.
     if (!file_exists($this->localpath) || is_dir($this->localpath)) {
         $this->exists = false;
         return NULL;
     }
     if (parent::PersistentObject('images', array('filename' => $filename, 'albumid' => $this->album->id), 'filename', false, false)) {
         $this->updateDimensions();
         $title = $this->getDefaultTitle();
         $this->set('title', $title);
         $this->set('mtime', filemtime($this->localpath));
         apply_filter('new_image', $this);
         $this->save();
     }
 }
 /**
  * Handles class common instantiation
  * @param $album
  * @param $filename
  */
 function common_instantiate($album, $filename)
 {
     global $_zp_supported_images;
     // $album is an Album object; it should already be created.
     if (!is_object($album)) {
         return NULL;
     }
     if (!$this->classSetup($album, $filename)) {
         // spoof attempt
         $this->exists = false;
         return;
     }
     $this->sidecars = $_zp_supported_images;
     $this->objectsThumb = checkObjectsThumb($album->localpath, $filename);
     // Check if the file exists.
     if (!file_exists($this->localpath) || is_dir($this->localpath)) {
         $this->exists = false;
         return;
     }
     $this->updateDimensions();
     if (parent::PersistentObject('images', array('filename' => $filename, 'albumid' => $this->album->id), 'filename', false, false)) {
         $title = $this->getDefaultTitle();
         $this->set('title', $title);
         $this->set('mtime', $ts = filectime($this->localpath));
         $newdate = strftime('%Y-%m-%d %H:%M:%S', $ts);
         $this->updateMetaData();
         $this->save();
         zp_apply_filter('new_image', $this);
     }
 }