Exemplo n.º 1
0
/**
 * Puts up random image thumbs from the gallery
 *
 * @param int $number how many images
 * @param string $class optional class
 * @param string $option what you want selected: all for all images, album for selected ones from an album
 * @param mixed $rootAlbum optional album object/folder from which to get the image.
 * @param integer $width the width/cropwidth of the thumb if crop=true else $width is longest size.
 * @param integer $height the height/cropheight of the thumb if crop=true else not used
 * @param bool $crop 'true' (default) if the thumb should be cropped, 'false' if not
 * @param bool $fullimagelink 'false' (default) for the image page link , 'true' for the unprotected full image link (to use Colorbox for example)
 */
function printRandomImages($number = 5, $class = null, $option = 'all', $rootAlbum = '', $width = NULL, $height = NULL, $crop = NULL, $fullimagelink = false)
{
    if (is_null($crop) && is_null($width) && is_null($height)) {
        $crop = 2;
    } else {
        if (is_null($width)) {
            $width = 85;
        }
        if (is_null($height)) {
            $height = 85;
        }
        if (is_null($crop)) {
            $crop = 1;
        } else {
            $crop = (int) $crop && true;
        }
    }
    if (!empty($class)) {
        $class = ' class="' . $class . '"';
    }
    echo "<ul" . $class . ">";
    for ($i = 1; $i <= $number; $i++) {
        switch ($option) {
            case "all":
                $randomImage = getRandomImages();
                break;
            case "album":
                $randomImage = getRandomImagesAlbum($rootAlbum);
                break;
        }
        if (is_object($randomImage) && $randomImage->exists) {
            echo "<li>\n";
            if ($fullimagelink) {
                $randomImageURL = $randomImage->getFullimageURL();
            } else {
                $randomImageURL = $randomImage->getLink();
            }
            echo '<a href="' . html_encode($randomImageURL) . '" title="' . sprintf(gettext('View image: %s'), html_encode($randomImage->getTitle())) . '">';
            switch ($crop) {
                case 0:
                    $sizes = getSizeCustomImage($width, NULL, NULL, NULL, NULL, NULL, NULL, $randomImage);
                    $html = '<img src="' . html_encode(pathurlencode($randomImage->getCustomImage($width, NULL, NULL, NULL, NULL, NULL, NULL, TRUE))) . '" width="' . $sizes[0] . '" height="' . $sizes[1] . '" alt="' . html_encode($randomImage->getTitle()) . '" />' . "\n";
                    break;
                case 1:
                    $sizes = getSizeCustomImage(NULL, $width, $height, $width, $height, NULL, NULL, $randomImage);
                    $html = '<img src="' . html_encode(pathurlencode($randomImage->getCustomImage(NULL, $width, $height, $width, $height, NULL, NULL, TRUE))) . '" width="' . $sizes[0] . '" height="' . $sizes[1] . '" alt="' . html_encode($randomImage->getTitle()) . '" />' . "\n";
                    break;
                case 2:
                    $sizes = getSizeDefaultThumb($randomImage);
                    //$html = '<img src="' . html_encode(pathurlencode($randomImage->getThumb())) . '" width="' . $sizes[0] . '" height="' . $sizes[1] . '" alt="' . html_encode($randomImage->getTitle()) . '" />' . "\n";
                    $html = $randomImage->filename . " (" . $randomImage->album->name . ")";
                    break;
            }
            echo zp_apply_filter('custom_image_html', $html, false);
            echo "</a>";
            echo "</li>\n";
        } else {
            break;
        }
    }
    echo "</ul>";
}
Exemplo n.º 2
0
    $u = 0;
    while (next_album()) {
        $a = $_zp_current_album;
        $thumb = $a->getAlbumThumbImage();
        $title = $a->getTitle();
        $desc = $a->getDesc();
        $customThumb = $thumb->getCustomImage(NULL, 202, 56, 202, 56, NULL, NULL, false);
        $url = getAlbumURL();
        echo "\t<div class='thumb' index='{$u}' title='{$title}' location='{$customThumb}' url='{$url}'><description>{$desc}</description></div>\n";
        $u++;
    }
} else {
    $u = 0;
    while (next_image()) {
        $title = getImageTitle();
        $size = getSizeCustomImage(NULL, 383);
        $desc = getImageDesc();
        if (!empty($desc)) {
            $desc = theme_clean($desc);
        } else {
            $desc = '';
        }
        $thumb = getImageThumb();
        $small = getCustomImageURL(NULL, 383);
        $full = getFullImageURL();
        $width = $size[0];
        $height = $size[1];
        $rating = $_zp_current_image->get('rating');
        echo "\t<div class='thumb' index='{$u}' title='{$title}' \n\t\twidth='{$width}' " . "\n\t\theight='{$height}' \n\t\turl='{$full}' \n\t\tpreviewUrl='{$small}'" . "\n\t\tlocation='{$thumb}' \n\t\trating='{$rating}' \n\t\tobject_id='" . $_zp_current_image->id . "'>" . "\n\t\t<description>\n\t\t\t{$desc}\n\t\t</description>\n\t</div>\n";
        $u++;
    }
/**
 * Prints image statistic according to $option as an unordered HTML list
 * A css id is attached by default named accordingly'$option'
 *
 * @param string $number the number of albums to get
 * @param string $option "popular" for the most popular images,
 * 		"popular" for the most popular albums,
 * 		"latest" for the latest uploaded by id (Discovery)
 * 		"latest-date" for the latest by date
 * 		"latest-mtime" for the latest by mtime
 *   	"latest-publishdate" for the latest by publishdate
 *    "mostrated" for the most voted,
 * 		"toprated" for the best voted
 * 		"latestupdated" for the latest updated
 * 		"random" for random order (yes, strictly no statistical order...)
 * @param string $albumfolder foldername of an specific album
 * @param bool $showtitle if the image title should be shown
 * @param bool $showdate if the image date should be shown
 * @param bool $showdesc if the image description should be shown
 * @param integer $desclength the length of the description to be shown
 * @param string $showstatistic "hitcounter" for showing the hitcounter (views),
 * 		"rating" for rating,
 * 		"rating+hitcounter" for both.
 * @param integer $width the width/cropwidth of the thumb if crop=true else $width is longest size. (Default 85px)
 * @param integer $height the height/cropheight of the thumb if crop=true else not used.  (Default 85px)
 * @param bool $crop 'true' (default) if the thumb should be cropped, 'false' if not
 * @param bool $collection only if $albumfolder is set: true if you want to get statistics from this album and all of its subalbums
 * @param bool $fullimagelink 'false' (default) for the image page link , 'true' for the unprotected full image link (to use Colorbox for example)
 * @param integer $threshold the minimum number of ratings (for rating options) or hits (for popular option) an image must have to be included in the list. (Default 0)
 * @return string
 */
function printImageStatistic($number, $option, $albumfolder = '', $showtitle = false, $showdate = false, $showdesc = false, $desclength = 40, $showstatistic = '', $width = NULL, $height = NULL, $crop = NULL, $collection = false, $fullimagelink = false, $threshold = 0)
{
    $images = getImageStatistic($number, $option, $albumfolder, $collection, $threshold);
    if (is_null($crop) && is_null($width) && is_null($height)) {
        $crop = 2;
    } else {
        if (is_null($width)) {
            $width = 85;
        }
        if (is_null($height)) {
            $height = 85;
        }
        if (is_null($crop)) {
            $crop = 1;
        } else {
            $crop = (int) $crop && true;
        }
    }
    echo "\n<div id=\"{$option}\">\n";
    echo "<ul>";
    foreach ($images as $image) {
        if ($fullimagelink) {
            $imagelink = $image->getFullImageURL();
        } else {
            $imagelink = $image->getLink();
        }
        echo '<li><a href="' . html_encode($imagelink) . '" title="' . html_encode($image->getTitle()) . "\">\n";
        switch ($crop) {
            case 0:
                $sizes = getSizeCustomImage($width, NULL, NULL, NULL, NULL, NULL, NULL, $image);
                echo '<img src="' . html_encode(pathurlencode($image->getCustomImage($width, NULL, NULL, NULL, NULL, NULL, NULL, TRUE))) . '" width="' . $sizes[0] . '" height="' . $sizes[1] . '" alt="' . html_encode($image->getTitle()) . "\" /></a>\n";
                break;
            case 1:
                $sizes = getSizeCustomImage(NULL, $width, $height, $width, $height, NULL, NULL, $image);
                echo '<img src="' . html_encode(pathurlencode($image->getCustomImage(NULL, $width, $height, $width, $height, NULL, NULL, TRUE))) . '" width="' . $sizes[0] . '" height="' . $sizes[1] . '" alt="' . html_encode($image->getTitle()) . "\" width=\"" . $width . "\" height=\"" . $height . "\" /></a>\n";
                break;
            case 2:
                $sizes = getSizeDefaultThumb($image);
                echo '<img src="' . html_encode(pathurlencode($image->getThumb())) . '" width="' . $sizes[0] . '" height="' . $sizes[1] . '" alt="' . html_encode($image->getTitle()) . "\" /></a>\n<br />";
                break;
        }
        if ($showtitle) {
            echo '<h3><a href="' . html_encode(pathurlencode($image->getLink())) . '" title="' . html_encode($image->getTitle()) . "\">\n";
            echo $image->getTitle() . "</a></h3>\n";
        }
        if ($showdate) {
            echo "<p>" . zpFormattedDate(DATE_FORMAT, strtotime($image->getDateTime())) . "</p>";
        }
        if ($showstatistic === "rating" or $showstatistic === "rating+hitcounter") {
            $votes = $image->get("total_votes");
            $value = $image->get("total_value");
            if ($votes != 0) {
                $rating = round($value / $votes, 1);
            }
            echo "<p>" . sprintf(gettext('Rating: %1$u (Votes: %2$u)'), $rating, $votes) . "</p>";
        }
        if ($showstatistic === "hitcounter" or $showstatistic === "rating+hitcounter") {
            $hitcounter = $image->getHitcounter();
            if (empty($hitcounter)) {
                $hitcounter = "0";
            }
            echo "<p>" . sprintf(gettext("Views: %u"), $hitcounter) . "</p>";
        }
        if ($showdesc) {
            echo shortenContent($image->getDesc(), $desclength, ' (...)');
        }
        echo "</li>";
    }
    echo "</ul></div>\n";
}
Exemplo n.º 4
0
/**
 * prints the radio button image size selection list
 *
 * @param string $text text to introduce the radio button list
 * @param string $default the default (initial) for the image sizing
 * @param array $usersizes an array of sizes which may be choosen.
 */
function printUserSizeSelector($text = '', $default = NULL, $usersizes = NULL)
{
    $size = $width = $height = NULL;
    getViewerImageSize($default, $size, $width, $height);
    if (!empty($size)) {
        $current = $size;
    } else {
        $current = $width . 'x' . $height;
    }
    $sizes = array();
    if (empty($text)) {
        $text = gettext('Select image size');
    }
    if (is_null($usersizes)) {
        $inputs = explode(';', trim(getOption('viewer_size_image_sizes')));
        if (!empty($inputs)) {
            foreach ($inputs as $size) {
                if (!empty($size)) {
                    $size = str_replace(',', ';', $size) . ';';
                    $s = $w = $h = NULL;
                    if (false === eval($size)) {
                        zp_error(gettext('There is a format error in your <em>viewer_size_image_sizes</em> option string.'), E_USER_NOTICE);
                    }
                    if (!empty($s)) {
                        $key = $s;
                    } else {
                        $key = $w . 'x' . $h;
                    }
                    $sizes[$key] = array('$s' => $s, '$h' => $h, '$w' => $w);
                }
            }
        }
    } else {
        foreach ($usersizes as $key => $size) {
            if (!empty($size)) {
                $size = str_replace(',', ';', $size) . ';';
                $s = $w = $h = NULL;
                if (false === eval($size)) {
                    zp_error(gettext('There is a format error in your $usersizes string.'), E_USER_NOTICE);
                }
                if (!empty($s)) {
                    $key = $s;
                } else {
                    $key = $w . 'x' . $h;
                }
                $sizes[$key] = array('$s' => $s, '$h' => $h, '$w' => $w);
            }
        }
    }
    if (($cookiepath = WEBPATH) == '') {
        $cookiepath = '/';
    }
    ?>
	<script type="text/javascript">
		// <!-- <![CDATA[
	<?php 
    $selector = getOption('viewer_size_image_radio') == 1;
    if ($selector) {
        ?>
			function switchselection() {
				var selection = $("#viewer_size_image_selection").val();
				var items = selection.split(':');
				$('#image img').attr('width', items[1]);
				$('#image img').attr('height', items[2]);
				$('#image img').attr('src', items[3]);
				document.cookie = 'viewer_size_image_saved=' + items[0] + '; expires=<?php 
        echo date('Y-m-d H:i:s', time() + COOKIE_PESISTENCE);
        ?>
; path=<?php 
        echo $cookiepath;
        ?>
';
			}
		<?php 
    } else {
        //	radio buttons
        ?>
			function switchimage(obj) {
				var url = $(obj).attr('url');
				var w = $(obj).attr('im_w');
				var h = $(obj).attr('im_h');
				$('#image img').attr('width', w);
				$('#image img').attr('height', h);
				$('#image img').attr('src', url);
				document.cookie = 'viewer_size_image_saved=' + $(obj).attr('value') + '; expires=<?php 
        echo date('Y-m-d H:i:s', time() + COOKIE_PESISTENCE);
        ?>
; path=<?php 
        echo $cookiepath;
        ?>
';
			}
		<?php 
    }
    ?>
		// ]]> -->
	</script>
	<div>
		<?php 
    echo $text;
    if ($selector) {
        ?>
			<select id="viewer_size_image_selection" name="viewer_size_image_selection" onchange="switchselection();" >
				<?php 
    }
    foreach ($sizes as $key => $size) {
        if (empty($size['$s'])) {
            $display = sprintf(gettext('%1$s x %2$s px'), $size['$w'], $size['$h']);
            $url = getCustomImageURL(null, $size['$w'], $size['$h'], null, null, null, null, false);
            $value = '$h=' . $size['$h'] . ',$w=' . $size['$w'];
            $dims = array($size['$w'], $size['$h']);
        } else {
            $dims = getSizeCustomImage($size['$s']);
            $display = sprintf(gettext('%s px'), $size['$s']);
            $url = getCustomImageURL($size['$s'], null, null, null, null, null, null, false);
            $value = '$s=' . $size['$s'];
        }
        if ($selector) {
            $selected = '';
            if ($key == $current) {
                $selected = ' selected="selected"';
            }
            ?>
					<option id="s<?php 
            echo $key;
            ?>
" value="<?php 
            echo $value . ':' . implode(':', $dims) . ':' . $url;
            ?>
"<?php 
            echo $selected;
            ?>
 />
					<?php 
            echo $display;
            ?>
					</option>
					<?php 
        } else {
            $checked = "";
            if ($key == $current) {
                $checked = ' checked="checked"';
            }
            ?>
					<input type="radio" name="viewer_size_image_selection" id="s<?php 
            echo $key;
            ?>
" url="<?php 
            echo $url;
            ?>
"
								 im_w="<?php 
            echo $dims[0];
            ?>
" im_h="<?php 
            echo $dims[1];
            ?>
"
								 value="<?php 
            echo $value;
            ?>
"<?php 
            echo $checked;
            ?>
 onclick="switchimage(this);" />
					<label for="s<?php 
            echo $key;
            ?>
"> <?php 
            echo $display;
            ?>
</label>
					<?php 
        }
    }
    if ($selector) {
        ?>
			</select>
			<?php 
    }
    ?>
	</div>
	<?php 
}
Exemplo n.º 5
0
        $iw = null;
        $ih = $nh;
        if ($nw > $mw) {
            list($nw, $nh) = getSizeCustomImage(null, $mw);
            $iw = $nw;
            $ih = null;
        }
    }
    /*
    						echo 'o: ' . getFullWidth() . 'x' . getFullHeight() . "<br />\n";
    						echo 'i: ' . $iw . 'x' . $ih . "<br />\n";
    						echo 'm: ' . $mw . 'x' . $mh . "<br />\n";
    						echo 'n: ' . $nw . 'x' . $nh . "<br />\n";
    */
}
list($imgw, $imgh) = getSizeCustomImage(null, $iw, $ih);
?>
			<img src="<?php 
echo getCustomImageURL(null, $iw, $ih);
?>
"
				alt="<?php 
echo getImageTitle();
?>
"
				width="<?php 
echo $imgw;
?>
" height="<?php 
echo $imgh;
?>
/**
 * Print normal video or custom sized images.
 * Note: a class of 'not_visible' or 'password_protected' will be added as appropriate
 *
 * Notes on cropping:
 *
 * The $crop* parameters determine the portion of the original image that will be incorporated
 * into the final image. The w and h "sizes" are typically proportional. That is you can set them to
 * values that reflect the ratio of width to height that you want for the final image. Typically
 * you would set them to the fincal height and width.
 *
 * @param string $alt Alt text for the url
 * @param int $size size
 * @param int $width width
 * @param int $height height
 * @param int $cropw crop width
 * @param int $croph crop height
 * @param int $cropx crop x axis
 * @param int $cropy crop y axis
 * @param string $class Optional style class
 * @param string $id Optional style id
 * @param bool $thumbStandin set to true to treat as thumbnail
 * @param bool $effects image effects (e.g. set gray to force grayscale)
 * */
function printCustomSizedImage($alt, $size, $width = NULL, $height = NULL, $cropw = NULL, $croph = NULL, $cropx = NULL, $cropy = NULL, $class = NULL, $id = NULL, $thumbStandin = false, $effects = NULL)
{
    global $_zp_current_image;
    if (is_null($_zp_current_image)) {
        return;
    }
    if (!$_zp_current_image->getShow()) {
        $class .= " not_visible";
    }
    $album = $_zp_current_image->getAlbum();
    $pwd = $album->getPassword();
    if (!empty($pwd)) {
        $class .= " password_protected";
    }
    if ($size) {
        $dims = getSizeCustomImage($size);
        $sizing = ' width="' . $dims[0] . '" height="' . $dims[1] . '"';
    } else {
        $sizing = '';
        if ($width) {
            $sizing .= ' width="' . $width . '"';
        }
        if ($height) {
            $sizing .= ' height="' . $height . '"';
        }
    }
    if ($id) {
        $id = ' id="' . $id . '"';
    }
    if ($class) {
        $id .= ' class="' . $class . '"';
    }
    if (isImagePhoto() || $thumbStandin) {
        $html = '<img src="' . html_encode(getCustomImageURL($size, $width, $height, $cropw, $croph, $cropx, $cropy, $thumbStandin, $effects)) . '"' . ' alt="' . html_encode($alt) . '"' . $id . $sizing . ' />';
        $html = zp_apply_filter('custom_image_html', $html, $thumbStandin);
        echo $html;
    } else {
        // better be a plugin
        echo $_zp_current_image->getBody($width, $height);
    }
}
/**
 * Returns an array [width, height] of the default-sized image.
 *
 * @return array
 */
function getSizeDefaultImage()
{
    return getSizeCustomImage(getOption('image_size'));
}
Exemplo n.º 8
0
 function getSubalbumsHTML()
 {
     $numAlbums = $this->getNumAlbums();
     if ($numAlbums <= 0 || $this->albumPage >= $this->getFirstImagePage()) {
         return '';
     }
     global $_zp_themeroot, $_zp_gallery, $_zp_current_image, $_zp_current_album;
     $w = 318;
     $slideshowLink = $this->getSlideshowLink();
     $subalbums = "<div id='subalbums'>";
     $i = 0;
     $albums = $this->getAlbums();
     $page = $this->getAlbumPage();
     $start = ($page - 1) * getOption('albums_per_page');
     $albums = array_slice($albums, $start, getOption('albums_per_page'));
     for ($u = 0; $u < count($albums); $u++) {
         $a = new Album($_zp_gallery, $albums[$u]);
         $thumb = $a->getAlbumThumbImage();
         $title = $a->getTitle();
         $desc = $a->getDesc();
         $customThumb = $thumb->getCustomImage(NULL, 104, 56, 104, 56, NULL, NULL, false);
         $subalbums .= "<span class='subalbum' id='subalbum-{$u}' width='104' height='56' >" . "<a href='" . getAlbumURL($a) . "' >" . "<img width='104' height='56' src='{$customThumb}'/></a></span>";
         $i++;
     }
     $m = $i;
     $i++;
     while ($i <= getOption('albums_per_page')) {
         $subalbums .= "<span class='subalbum' id='subalbum-{$i}'>" . "<img width='104' height='56' src='{$_zp_themeroot}/resources/images/opa/bg-b-20.png'/>" . "</span>";
         $i++;
     }
     $subalbums .= "</div>";
     $s = ($this->getAlbumPage() - 1) * getOption('albums_per_page');
     $batch = $s + 1 . "-" . ($s + $m);
     $subalbums = "<div id='subalbum-count' class='count'>" . (isset($slideshowLink) && $this->getNumImages() > 0 ? "<span id='album-slideshow-link' class='unselected'><a href='{$slideshowLink}'>Slideshow</a></span>" : "") . "<span class='selected'>{$batch} / " . $numAlbums . " " . gettext($this->getAlbumTabText($numAlbums)) . "</span>" . ($this->getNumImages() > 0 ? "<span class='unselected last'><a href='" . $this->getImageTabLink() . "'>" . $this->getNumImages() . " " . gettext("images") . "</a></span>" : "<span class='unselected last'>" . $this->getNumImages() . " " . gettext("image") . "</span>") . "</div>" . $subalbums;
     if ($this->showRandomImage()) {
         $img = $this->getRandomAlbumImage();
         $subalbums .= "<div id='random-album-image'>";
         $previous = $_zp_current_image;
         $_zp_current_image = $img;
         $size = getSizeCustomImage(NULL, $w + 2);
         $small = getCustomImageURL(NULL, $w + 2);
         $width = $img->getWidth();
         $height = $img->getHeight();
         $ratio = ($w + 2) / $width;
         $height = $height * $ratio;
         $subalbums .= "<img src='{$small}' width='" . ($w + 2) . "' height='{$height}'/>";
         $subalbums .= "<div class='caption'>Random selection</div>";
         $subalbums .= "</div>";
         $_zp_current_image = $previous;
     }
     return $subalbums;
 }
Exemplo n.º 9
0
		<?php 
while (next_image()) {
    $ch = THM_HEIGHT;
    $cw = THM_WIDTH;
    if (isLandscape()) {
        list($nw, $nh) = getSizeCustomImage(null, null, $ch);
        $ih = $ch;
        if ($nw < $cw) {
            list($nw, $nh) = getSizeCustomImage(null, $cw);
            $ih = $ch;
            $iw = $nw;
        } else {
            $iw = $cw;
        }
    } else {
        list($nw, $nh) = getSizeCustomImage(null, $cw);
        $iw = $cw;
        $ih = $ch;
    }
    //$cx = ($iw - $cw) / 2;
    //$cy = ($ih - $ch) / 2;
    ?>

			<li>
				<a href="<?php 
    echo getImageURL();
    ?>
"
					title="<?php 
    echo getImageTitle();
    ?>