Exemplo n.º 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);
     }
 }
Exemplo n.º 2
0
    /**
     * Prints the JS configuration of flv player
     *
     * @param string $moviepath the direct path of a movie (within the slideshow), if empty (within albums) the zenphoto function getUnprotectedImageURL() is used
     * @param string $imagetitle the title of the movie to be passed to the player for display (within slideshow), if empty (within albums) the function getImageTitle() is used
     * @param string $count unique text for when there are multiple player items on a page
     */
    function getPlayerConfig($moviepath = '', $imagetitle = '', $count = '')
    {
        global $_zp_current_image, $_zp_current_album;
        if (empty($moviepath)) {
            $moviepath = getUnprotectedImageURL();
            $ext = strtolower(strrchr(getUnprotectedImageURL(), "."));
        } else {
            $ext = strtolower(strrchr($moviepath, "."));
        }
        if (empty($imagetitle)) {
            $imagetitle = getImageTitle();
        }
        if (!empty($count)) {
            $count = "-" . $count;
        }
        $imgextensions = array(".jpg", ".jpeg", ".gif", ".png");
        if (is_null($_zp_current_image)) {
            $albumfolder = $moviepath;
            $filename = $imagetitle;
            $videoThumb = '';
        } else {
            $album = $_zp_current_image->getAlbum();
            $albumfolder = $album->name;
            $filename = $_zp_current_image->filename;
            $videoThumb = checkObjectsThumb(getAlbumFolder() . $albumfolder, $filename);
            if (!empty($videoThumb)) {
                $videoThumb = getAlbumFolder(WEBPATH) . $albumfolder . '/' . $videoThumb;
            }
        }
        $output = '';
        $output .= '<p id="player' . $count . '"><a href="http://www.macromedia.com/go/getflashplayer">' . gettext("Get Flash") . '</a> to see this player.</p>
			<script type="text/javascript">';
        if ($ext === ".mp3" and !isset($videoThumb)) {
            $output .= '	var so = new SWFObject("' . WEBPATH . '/' . ZENFOLDER . '/plugins/flvplayer/' . getOption("flv_player_version") . '.swf","player' . $count . '","' . getOption('flv_player_width') . '","' . FLV_PLAYER_MP3_HEIGHT . '","7");';
        } else {
            $output .= '	var so = new SWFObject("' . WEBPATH . '/' . ZENFOLDER . '/plugins/flvplayer/' . getOption("flv_player_version") . '.swf","player' . $count . '","' . getOption('flv_player_width') . '","' . getOption('flv_player_height') . '","7");';
            $output .= 'so.addVariable("displayheight","' . getOption('flv_player_displayheight') . '");';
        }
        $output .= 'so.addParam("allowfullscreen","true");
			so.addVariable("file","' . $moviepath . '&amp;title=' . strip_tags($imagetitle) . '");
			' . (!empty($videoThumb) ? 'so.addVariable("image","' . $videoThumb . '")' : '') . '
			so.addVariable("backcolor","' . getOption('flv_player_backcolor') . '");
			so.addVariable("frontcolor","' . getOption('flv_player_frontkcolor') . '");
			so.addVariable("lightcolor","' . getOption('flv_player_lightcolor') . '");
			so.addVariable("screencolor","' . getOption('flv_player_screencolor') . '");
			so.addVariable("autostart","' . (getOption('flv_player_autostart') ? 'true' : 'false') . '");
			so.addVariable("overstretch","true");
			so.addVariable("bufferlength","' . getOption('flv_player_buffer') . '");
			so.addVariable("controlbar","' . getOption('flv_player_controlbar') . '");
			so.write("player' . $count . '");
			</script>';
        return $output;
    }
Exemplo n.º 3
0
 /**
  * Constructor for class-video
  *
  * @param object &$album the owning album
  * @param sting $filename the filename of the image
  * @return Image
  */
 function __construct($album, $filename, $quiet = false)
 {
     global $_zp_supported_images;
     $msg = false;
     if (!is_object($album) || !$album->exists) {
         $msg = gettext('Invalid video instantiation: Album does not exist');
     } else {
         if (!$this->classSetup($album, $filename) || !file_exists($this->localpath) || is_dir($this->localpath)) {
             $msg = gettext('Invalid video instantiation: file does not exist.');
         }
     }
     if ($msg) {
         $this->exists = false;
         if (!$quiet) {
             trigger_error($msg, E_USER_ERROR);
         }
         return;
     }
     $alts = explode(',', extensionEnabled('class-video_videoalt'));
     foreach ($alts as $alt) {
         $this->videoalt[] = trim(strtolower($alt));
     }
     $this->sidecars = $_zp_supported_images;
     $this->video = true;
     $this->objectsThumb = checkObjectsThumb($this->localpath);
     // This is where the magic happens...
     $album_name = $album->name;
     $this->updateDimensions();
     $new = $this->instantiate('images', array('filename' => $filename, 'albumid' => $this->album->getID()), 'filename', true, empty($album_name));
     if ($new || $this->filemtime != $this->get('mtime')) {
         if ($new) {
             $this->setTitle($this->displayname);
         }
         $this->updateMetaData();
         $this->set('mtime', $this->filemtime);
         $this->save();
         if ($new) {
             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();
     }
 }
Exemplo n.º 5
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);
		}
	}
Exemplo n.º 7
0
require_once "../../template-functions.php";
$albumid = sanitize_numeric($_GET["albumid"]);
$albumresult = query_single_row("SELECT folder from " . prefix('albums') . " WHERE id = " . $albumid);
$album = new Album(new Gallery(), $albumresult['folder']);
$playlist = $album->getImages();
echo "<playlist version='1' xmlns='http://xspf.org/ns/0/'>\n";
echo "<title>Sample XSPF Playlist</title>";
echo "<info>http://www.what.de</info>";
echo "<annotation>An example of a playlist with commercial</annotation>";
echo "<trackList>\n";
$imgextensions = array(".jpg", ".jpeg", ".gif", ".png");
foreach ($playlist as $item) {
    $image = newImage($album, $item);
    $ext = strtolower(strrchr($item, "."));
    if ($ext == ".flv" || $ext == ".mp3" || $ext == ".mp4") {
        $videoThumb = checkObjectsThumb($album->localpath, $item);
        if (!empty($videoThumb)) {
            $videoThumb = ".." . ALBUMFOLDER . "/" . $album->name . "/" . $videoThumb;
        }
        echo "\t<track>\n";
        echo "\t\t<title>" . $image->getTitle() . " (" . $ext . ")</title>\n";
        // As documentated on the fvl player's site movies and mp3 have are called via differently relative urls...
        // http://www.jeroenwijering.com/?item=Supported_Playlists
        if ($ext == ".flv" or $ext == ".mp4") {
            echo "\t\t<location>../../.." . ALBUMFOLDER . "/" . $album->name . "/" . $item . "</location>\n";
        } else {
            echo "\t\t<location>../" . ALBUMFOLDER . "/" . $album->name . "/" . $item . "</location>\n";
        }
        echo "\t\t<image>" . $videoThumb . "</image>\n";
        echo "\t\t<info>.." . ALBUMFOLDER . "/" . $item . "</info>\n";
        echo "\t</track>\n";
Exemplo n.º 8
0
 /**
  * Handles class common instantiation
  * @param $album
  * @param $filename
  */
 function common_instantiate($album, $filename, $quiet = false)
 {
     global $_zp_supported_images;
     $msg = false;
     if (!is_object($album) || !$album->exists) {
         $msg = gettext('Invalid Textobject instantiation: Album does not exist');
     } else {
         if (!$this->classSetup($album, $filename) || !file_exists($this->localpath) || is_dir($this->localpath)) {
             $msg = gettext('Invalid Textobject instantiation: file does not exist');
         }
     }
     if ($msg) {
         $this->exists = false;
         if (!$quiet) {
             trigger_error($msg, E_USER_ERROR);
         }
         return;
     }
     $this->sidecars = $_zp_supported_images;
     $this->objectsThumb = checkObjectsThumb($this->localpath);
     $this->updateDimensions();
     $new = $this->instantiate('images', array('filename' => $filename, 'albumid' => $this->album->getID()), 'filename');
     if ($new || $this->filemtime != $this->get('mtime')) {
         if ($new) {
             $this->setTitle($this->displayname);
         }
         $title = $this->displayname;
         $this->updateMetaData();
         $this->set('mtime', $this->filemtime);
         $this->save();
         if ($new) {
             zp_apply_filter('new_image', $this);
         }
     }
 }
Exemplo n.º 9
0
 /**
  * Gets the album's set thumbnail image from the database if one exists,
  * otherwise, finds the first image in the album or sub-album and returns it
  * as an Image object.
  *
  * @return Image
  */
 function getAlbumThumbImage()
 {
     if (!is_null($this->albumthumbnail)) {
         return $this->albumthumbnail;
     }
     $albumdir = $this->localpath;
     $thumb = $this->get('thumb');
     $i = strpos($thumb, '/');
     if ($root = $i === 0) {
         $thumb = substr($thumb, 1);
         // strip off the slash
         $albumdir = getAlbumFolder();
     }
     $shuffle = $thumb != '1';
     if (!empty($thumb) && $thumb != '1' && file_exists($albumdir . UTF8ToFilesystem($thumb))) {
         if ($i === false) {
             return newImage($this, $thumb);
         } else {
             $pieces = explode('/', $thumb);
             $i = count($pieces);
             $thumb = $pieces[$i - 1];
             unset($pieces[$i - 1]);
             $albumdir = implode('/', $pieces);
             if (!$root) {
                 $albumdir = $this->name . "/" . $albumdir;
             } else {
                 $albumdir = $albumdir . "/";
             }
             $this->albumthumbnail = newImage(new Album($this->gallery, $albumdir), $thumb);
             return $this->albumthumbnail;
         }
     } else {
         if ($this->isDynamic()) {
             $this->getImages(0, 0, 'ID', 'DESC');
             $thumbs = $this->images;
             if (!is_null($thumbs)) {
                 if ($shuffle) {
                     shuffle($thumbs);
                 }
                 while (count($thumbs) > 0) {
                     $thumb = array_shift($thumbs);
                     if (is_valid_image($thumb['filename'])) {
                         $alb = new Album($this->gallery, $thumb['folder']);
                         $thumb = newImage($alb, $thumb['filename']);
                         if ($thumb->getShow()) {
                             $this->albumthumbnail = $thumb;
                             return $thumb;
                         }
                     }
                 }
             }
         } else {
             $this->getImages(0, 0, 'ID', 'DESC');
             $thumbs = $this->images;
             if (!is_null($thumbs)) {
                 if ($shuffle) {
                     shuffle($thumbs);
                 }
                 while (count($thumbs) > 0) {
                     $thumb = array_shift($thumbs);
                     if (is_valid_image($thumb)) {
                         $thumb = newImage($this, $thumb);
                         if ($thumb->getShow()) {
                             $this->albumthumbnail = $thumb;
                             return $thumb;
                         }
                     }
                 }
             }
             // Otherwise, look in sub-albums.
             $subalbums = $this->getSubAlbums();
             if (!is_null($subalbums)) {
                 if ($shuffle) {
                     shuffle($subalbums);
                 }
                 while (count($subalbums) > 0) {
                     $folder = array_pop($subalbums);
                     $subalbum = new Album($this->gallery, $folder);
                     $pwd = $subalbum->getPassword();
                     if ($subalbum->getShow() && empty($pwd) || isMyALbum($folder, ALL_RIGHTS)) {
                         $thumb = $subalbum->getAlbumThumbImage();
                         if (strtolower(get_class($thumb)) !== 'transientimage' && $thumb->exists) {
                             $this->albumthumbnail = $thumb;
                             return $thumb;
                         }
                     }
                 }
             }
             //jordi-kun - no images, no subalbums, check for videos
             $dp = opendir($albumdir);
             while ($thumb = readdir($dp)) {
                 if (is_file($albumdir . $thumb) && is_valid_video($thumb)) {
                     $othersThumb = checkObjectsThumb($albumdir, $thumb);
                     if (!empty($othersThumb)) {
                         $thumb = newImage($this, $othersThumb);
                         if ($this->getShow()) {
                             $this->albumthumbnail = $thumb;
                             return $thumb;
                         }
                     }
                 }
             }
         }
     }
     $nullimage = SERVERPATH . '/' . ZENFOLDER . '/images/imageDefault.png';
     if (OFFSET_PATH == 0) {
         // check for theme imageDefault.png if we are in the gallery
         $theme = '';
         $uralbum = getUralbum($this);
         $albumtheme = $uralbum->getAlbumTheme();
         if (!empty($albumtheme)) {
             $theme = $albumtheme;
         } else {
             $theme = $this->gallery->getCurrentTheme();
         }
         if (!empty($theme)) {
             $themeimage = SERVERPATH . '/' . THEMEFOLDER . '/' . $theme . '/images/imageDefault.png';
             if (file_exists(UTF8ToFilesystem($themeimage))) {
                 $nullimage = $themeimage;
             }
         }
     }
     $this->albumthumbnail = new transientimage($this, $nullimage);
     return $this->albumthumbnail;
 }
 /**
  * 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);
     }
 }