/**
* JSON representation of this gallery's images.
*
- * @param array $images An array of Ansel_Image objects. If this is null
- * the images are fetched based on $from and $count.
- *
- * @param integer $from Image to start at.
- * @param integer $count Number of images to get.
+ * @param array $params An array of parameters for this method:
+ * <pre>
+ * images - Array of Ansel_Images to generate JSON for [null]
+ * full - Should a full URL be generated? [false]
+ * from - Starting image count [0]
+ * count - The number of images to include (starting at from) [0]
+ * image_view - The type of ImageView to obtain the src url for. [screen]
+ * view_links - Should the JSON include links to the Image and/or Gallery View? [false]
+ * perpage - Number of images per page [from user prefs]
+ * </pre>
*
* @return string A serialized JSON array.
*/
- public function json($images = null, $full = false, $from = 0, $count = 0,
- $image_view = 'screen', $view_links = false)
+ public function json($params = array())
{
global $conf, $prefs;
+ $default = array('full' => false,
+ 'from' => 0,
+ 'count' => 0,
+ 'image_view' => 'screen',
+ 'view_links' => false,
+ 'perpage' => $prefs->getValue('tilesperpage', $conf['thumbnail']['perpage']));
+
+ $params = array_merge($default, $params);
+
$json = array();
- $perpage = $prefs->getValue('tilesperpage', $conf['thumbnail']['perpage']);
$curimage = 0;
$curpage = 0;
- if (is_null($images)) {
- $images = $this->gallery->getImages($from, $count);
+ if (empty($params['images'])) {
+ $images = $this->gallery->getImages($params['from'], $params['count']);
}
$style = $this->gallery->getStyle();
foreach ($images as $image) {
// Calculate the page this image will appear on in the
// gallery view.
- if (++$curimage > $perpage) {
+ if (++$curimage > $params['perpage']) {
++$curpage;
$curimage = 0;
}
- $data = array(Ansel::getImageUrl($image->id, $image_view, $full, $style['name']),
+ $data = array(Ansel::getImageUrl($image->id, $params['image_view'], $params['full'], $style['name']),
htmlspecialchars($image->filename, ENT_COMPAT, Horde_Nls::getCharset()),
Horde_Text_Filter::filter($image->caption, 'text2html', array('parselevel' => Horde_Text_Filter_Text2html::MICRO_LINKURL)),
$image->id,
$curpage);
- if ($view_links) {
+ if ($params['view_links']) {
$data[] = Ansel::getUrlFor('view',
array('gallery' => $this->gallery->id,
'slug' => $this->gallery->get('slug'),
'image' => $image->id,
- 'view' => 'Image'),
+ 'view' => 'Image',
+ 'page' => $curpage),
true);
$data[] = Ansel::getUrlFor('view',
array('gallery' => $image->gallery,
}
if (empty($images)) {
- $json = $this->json(null, true, $start, $count, $thumbsize, true);
- $json_full = $this->json(null, true, $start, $count, 'screen', true);
+ $json = $this->json(array('full' => true,
+ 'from' => $start,
+ 'count' => $count,
+ 'image_view' => $thumbsize,
+ 'view_links' => true));
+ $json_full = $this->json(array('full' => true,
+ 'from' => $start,
+ 'count' => $count,
+ 'view_links' => true));
} else {
$json = $GLOBALS['ansel_storage']->getImageJson($images, null, true, $thumbsize, true);
$json_full = $GLOBALS['ansel_storage']->getImageJson($images, null, true, 'screen', true);
<script type="text/javascript">
//<![CDATA[
-SlideController.initialize(<?php echo $this->json() ?>, <?php echo $imageIndex ?>, "<?php echo $GLOBALS['registry']->get('webroot')?>", <?php echo $this->gallery->id ?>, "<?php echo $this->gallery->getName()?>");
+SlideController.initialize(<?php echo $this->json(array('view_links' => true)) ?>, <?php echo $imageIndex ?>, "<?php echo $GLOBALS['registry']->get('webroot')?>", <?php echo $this->gallery->id ?>, "<?php echo $this->gallery->getName()?>");
//]]>
function stopSlideShow()
{
- location.href = "<?php echo Horde::applicationUrl($this->_urls['gallery'], true) ?>?image=" + SlideController.photos[SlideController.photoId][3] + "&view=Image&page=" + SlideController.photos[SlideController.photoId][4];
+ location.href = SlideController.photos[SlideController.photoId][5];
}
</script>
<tr>
<td style="margin:5px;height:<?php echo $GLOBALS['conf']['screen']['height'] ?>px;vertical-align:top;">
<div id="Container">
- <?php echo Horde::img('blank.gif', '', array('id' => 'Photo', 'style' => 'display:none;', 'width' => $this->_geometry['width'], 'height' => $this->_geometry['height']), $registry->getImageDir('horde')) ?>
+ <?php echo Horde::img('blank.gif', '', array('id' => 'Photo', 'style' => 'display:none;'), $registry->getImageDir('horde')) ?>
</div>
</td>
</tr>