Exemple #1
0
 /**
  * Prints the slideshow using the {@link http://http://www.malsup.com/jquery/cycle/  jQuery plugin Cycle}
  *
  * Two ways to use:
  * a) Use on your theme's slideshow.php page and called via printSlideShowLink():
  * If called from image.php it starts with that image, called from album.php it starts with the first image (jQuery only)
  * To be used on slideshow.php only and called from album.php or image.php.
  *
  * b) Calling directly via printSlideShow() function (jQuery mode)
  * Place the printSlideShow() function where you want the slideshow to appear and set create an album object for $albumobj and if needed an image object for $imageobj.
  * The controls are disabled automatically.
  *
  * NOTE: The jQuery mode does not support movie and audio files anymore. If you need to show them please use the Flash mode.
  * Also note that this function is not used for the Colorbox mode!
  *
  * @param bool $heading set to true (default) to emit the slideshow breadcrumbs in flash mode
  * @param bool $speedctl controls whether an option box for controlling transition speed is displayed
  * @param obj $albumobj The object of the album to show the slideshow of. If set this overrides the POST data of the printSlideShowLink()
  * @param obj $imageobj The object of the image to start the slideshow with. If set this overrides the POST data of the printSlideShowLink(). If not set the slideshow starts with the first image of the album.
  * @param int $width The width of the images (jQuery mode). If set this overrides the size the slideshow_width plugin option that otherwise is used.
  * @param int $height The heigth of the images (jQuery mode). If set this overrides the size the slideshow_height plugin option that otherwise is used.
  * @param bool $crop Set to true if you want images cropped width x height (jQuery mode only)
  * @param bool $shuffle Set to true if you want random (shuffled) order
  * @param bool $linkslides Set to true if you want the slides to be linked to their image pages (jQuery mode only)
  * @param bool $controls Set to true (default) if you want the slideshow controls to be shown (might require theme CSS changes if calling outside the slideshow.php page) (jQuery mode only)
  *
  */
 function printSlideShow($heading = true, $speedctl = false, $albumobj = NULL, $imageobj = NULL, $width = NULL, $height = NULL, $crop = false, $shuffle = false, $linkslides = false, $controls = true)
 {
     global $_myFavorites, $_zp_conf_vars;
     if (!isset($_POST['albumid']) and !is_object($albumobj)) {
         return '<div class="errorbox" id="message"><h2>' . gettext('Invalid linking to the slideshow page.') . '</h2></div>';
     }
     //getting the image to start with
     if (!empty($_POST['imagenumber']) and !is_object($imageobj)) {
         $imagenumber = sanitize_numeric($_POST['imagenumber']) - 1;
         // slideshows starts with 0, but zp with 1.
     } elseif (is_object($imageobj)) {
         $imagenumber = $imageobj->getIndex();
     } else {
         $imagenumber = 0;
     }
     // set pagenumber to 0 if not called via POST link
     if (isset($_POST['pagenr'])) {
         $pagenumber = sanitize_numeric($_POST['pagenr']);
     } else {
         $pagenumber = 1;
     }
     // getting the number of images
     if (!empty($_POST['numberofimages'])) {
         $numberofimages = sanitize_numeric($_POST['numberofimages']);
     } elseif (is_object($albumobj)) {
         $numberofimages = $albumobj->getNumImages();
     } else {
         $numberofimages = 0;
     }
     if ($imagenumber < 2 || $imagenumber > $numberofimages) {
         $imagenumber = 0;
     }
     //getting the album to show
     if (!empty($_POST['albumid']) && !is_object($albumobj)) {
         $albumid = sanitize_numeric($_POST['albumid']);
     } elseif (is_object($albumobj)) {
         $albumid = $albumobj->getID();
     } else {
         $albumid = 0;
     }
     if (isset($_POST['preserve_search_params'])) {
         // search page
         $search = new SearchEngine();
         $params = sanitize($_POST['preserve_search_params']);
         $search->setSearchParams($params);
         $searchwords = $search->getSearchWords();
         $searchdate = $search->getSearchDate();
         $searchfields = $search->getSearchFields(true);
         $page = $search->page;
         $returnpath = getSearchURL($searchwords, $searchdate, $searchfields, $page);
         $albumobj = new AlbumBase(NULL, false);
         $albumobj->setTitle(gettext('Search'));
         $albumobj->images = $search->getImages(0);
     } else {
         if (isset($_POST['favorites_page'])) {
             $albumobj = $_myFavorites;
             $returnpath = $_myFavorites->getLink($pagenumber);
         } else {
             $albumq = query_single_row("SELECT title, folder FROM " . prefix('albums') . " WHERE id = " . $albumid);
             $albumobj = newAlbum($albumq['folder']);
             if (empty($_POST['imagenumber'])) {
                 $returnpath = $albumobj->getLink($pagenumber);
             } else {
                 $image = newImage($albumobj, sanitize($_POST['imagefile']));
                 $returnpath = $image->getLink();
             }
         }
     }
     echo slideshow::getShow($heading, $speedctl, $albumobj, $imageobj, $width, $height, $crop, $shuffle, $linkslides, $controls, $returnpath, $imagenumber);
 }
 /**
  * Copy this album to the location specified by $newfolder, copying all
  * metadata, subalbums, and subalbums' metadata with it.
  * @param $newfolder string the folder to copy to, including the name of the current folder (possibly renamed).
  * @return int 0 on success and error indicator on failure.
  *
  */
 function copy($newfolder)
 {
     return parent::copy($newfolder);
 }
 function getLink($page = NULL, $instance = NULL)
 {
     return AlbumBase::getLink($page);
 }
Exemple #4
0
function printBaseSlideShow()
{
    global $_zp_gallery, $_zp_gallery_page, $_myFavorites, $_zp_conf_vars, $_zp_themeroot, $isMobile, $isTablet;
    if (!isset($_POST['albumid'])) {
        return '<div class="errorbox" id="message"><h2>' . gettext('Invalid linking to the slideshow page.') . '</h2></div>';
    }
    //getting the image to start with
    if (!empty($_POST['imagenumber'])) {
        $imagenumber = sanitize_numeric($_POST['imagenumber']) - 1;
        // slideshows starts with 0, but zp with 1.
    } else {
        $imagenumber = 0;
    }
    // set pagenumber to 0 if not called via POST link
    if (isset($_POST['pagenr'])) {
        $pagenumber = sanitize_numeric($_POST['pagenr']);
    } else {
        $pagenumber = 1;
    }
    // getting the number of images
    if (!empty($_POST['numberofimages'])) {
        $numberofimages = sanitize_numeric($_POST['numberofimages']);
    } else {
        $numberofimages = 0;
    }
    //if ($imagenumber < 2 || $imagenumber > $numberofimages) {
    //	$imagenumber = 0;
    //}
    //getting the album to show
    if (!empty($_POST['albumid'])) {
        $albumid = sanitize_numeric($_POST['albumid']);
    } else {
        $albumid = 0;
    }
    if (isset($_POST['preserve_search_params'])) {
        // search page
        $search = new SearchEngine();
        $params = sanitize($_POST['preserve_search_params']);
        $search->setSearchParams($params);
        $searchwords = $search->getSearchWords();
        $searchdate = $search->getSearchDate();
        $searchfields = $search->getSearchFields(true);
        $page = $search->page;
        $returnpath = getSearchURL($searchwords, $searchdate, $searchfields, $page);
        $albumobj = new AlbumBase(NULL, false);
        $albumobj->setTitle(gettext('Search'));
        $albumobj->images = $search->getImages(0);
        $albumtitle = gettext('Search');
    } else {
        if (isset($_POST['favorites_page'])) {
            $albumobj = $_myFavorites;
            $returnpath = rewrite_path($_myFavorites->getLink() . '/' . $pagenumber, FULLWEBPATH . '/index.php?p=favorites' . '&page=' . $pagenumber);
            $albumtitle = gettext('Favorites');
        } else {
            $albumq = query_single_row("SELECT title, folder FROM " . prefix('albums') . " WHERE id = " . $albumid);
            $albumobj = newAlbum($albumq['folder']);
            $albumtitle = $albumobj->getTitle();
            if (empty($_POST['imagenumber'])) {
                $returnpath = $albumobj->getLink($pagenumber);
            } else {
                $image = newImage($albumobj, sanitize($_POST['imagefile']));
                $returnpath = $image->getLink();
            }
        }
    }
    if (!$albumobj->isMyItem(LIST_RIGHTS) && !checkAlbumPassword($albumobj)) {
        return '<div class="errorbox" id="message"><h2>' . gettext('This album is password protected!') . '</h2></div>';
    }
    $slideshow = '';
    $numberofimages = $albumobj->getNumImages();
    if ($numberofimages == 0) {
        return '<div class="errorbox" id="message"><h2>' . gettext('No images for the slideshow!') . '</h2></div>';
    }
    $images = $albumobj->getImages(0);
    // slideshow generate data for galleria
    ?>
		<script>
			var data = [
			<?php 
    for ($c = 0, $idx = 0; $c < $numberofimages; $c++, $idx++) {
        if (is_array($images[$idx])) {
            $filename = $images[$idx]['filename'];
            $album = newAlbum($images[$idx]['folder']);
            $image = newImage($album, $filename);
        } else {
            $filename = $images[$idx];
            $image = newImage($albumobj, $filename);
        }
        if (isImagePhoto($image)) {
            makeImageCurrent($image);
            echo '{' . "\n";
            echo 'thumb: \'' . getImageThumb() . '\',' . "\n";
            echo 'image: \'' . getDefaultSizedImage() . '\',' . "\n";
            echo 'big: \'' . getCustomImageURL(getOption('zpbase_galbigsize')) . '\',' . "\n";
            echo 'title: \'' . js_encode($image->getTitle()) . '\',' . "\n";
            $desc = $image->getDesc();
            $desc = str_replace("\r\n", '<br />', $desc);
            $desc = str_replace("\r", '<br />', $desc);
            echo 'description: \'' . js_encode($desc) . '\',' . "\n";
            if (!getOption('zpbase_nodetailpage')) {
                echo 'link: \'' . html_encode($image->getLink()) . '\'' . "\n";
            }
            if ($c == $numberofimages - 1) {
                echo '}' . "\n";
            } else {
                echo '},' . "\n";
            }
        } else {
            if ($imagenumber > 0 && $imagenumber > $c) {
                $imagenumber--;
            }
        }
    }
    echo "\n";
    ?>
			];
		</script>
		<?php 
    $sspage = true;
    require_once 'inc/galleria-jscall.php';
}
 /**
  * Sets default values for a new album
  *
  * @return bool
  */
 protected function setDefaults()
 {
     global $_zp_gallery;
     parent::setDefaults();
     return true;
 }
Exemple #6
0
 /**
  * Returns a of a slice of the images for this album. They will
  * also be sorted according to the sort type of this album, or by filename if none
  * has been set.
  *
  * @param string $page  Which page of images should be returned. If zero, all images are returned.
  * @param int $firstPageCount count of images that go on the album/image transition page
  * @param string $sorttype optional sort type
  * @param string $sortdirection optional sort direction
  * @param bool $care set to false if the order of the images does not matter
  * @param bool $mine set true/false to override ownership
  *
  * @return array
  */
 function getImages($page = 0, $firstPageCount = 0, $sorttype = null, $sortdirection = null, $care = true, $mine = NULL)
 {
     if ($mine || is_null($this->images) || $care && $sorttype . $sortdirection !== $this->lastimagesort) {
         $this->images = NULL;
         $images = array();
         $result = query('SELECT * FROM ' . prefix('plugin_storage') . ' WHERE `type`="favorites" AND `aux`=' . db_quote($this->getInstance()) . ' AND `data` LIKE "%s:4:\\"type\\";s:6:\\"images\\";%"');
         if ($result) {
             while ($row = db_fetch_assoc($result)) {
                 $id = $row['id'];
                 $data = getSerializedArray($row['data']);
                 $imageObj = newImage(NULL, array('folder' => dirname($data['id']), 'filename' => basename($data['id'])), true);
                 if ($imageObj->exists) {
                     $images[] = array_merge(array('folder' => dirname($data['id']), 'filename' => basename($data['id'])), $imageObj->getData());
                 } else {
                     query("DELETE FROM " . prefix('plugin_storage') . ' WHERE `id`=' . $row['id']);
                 }
             }
             db_free_result($result);
             if (is_null($sorttype)) {
                 $sorttype = $this->getSortType();
             }
             $sortkey = str_replace('` ', ' ', $this->getImageSortKey($sorttype));
             if ($sortkey == 'sort_order' || $sortkey == 'RAND()') {
                 // manual sort is always ascending
                 $order = false;
             } else {
                 if (!is_null($sortdirection)) {
                     $order = strtoupper($sortdirection) == 'DESC';
                 } else {
                     $order = $this->getSortDirection('image');
                 }
             }
             $images = sortByKey($images, $sortkey, $order);
             $this->images = array();
             foreach ($images as $data) {
                 $this->images[] = array('folder' => $data['folder'], 'filename' => $data['filename']);
             }
             $this->lastimagesort = $sorttype . $sortdirection;
         }
     }
     return parent::getImages($page, $firstPageCount);
 }
Exemple #7
0
 /**
  * Sets default values for a new album
  *
  * @return bool
  */
 protected function setDefaults()
 {
     global $_zp_gallery;
     // Set default data for a new Album (title and parent_id)
     parent::setDefaults();
     $parentalbum = $this->getParent();
     $this->set('mtime', filemtime($this->localpath));
     if (!$_zp_gallery->getAlbumUseImagedate()) {
         $this->setDateTime(strftime('%Y-%m-%d %H:%M:%S', $this->get('mtime')));
     }
     $title = trim($this->name);
     if (!is_null($parentalbum)) {
         $this->set('parentid', $parentalbum->getID());
         $title = substr($title, strrpos($title, '/') + 1);
     }
     $this->set('title', sanitize($title, 2));
     return true;
 }