/home/coolpkct/www/websites/cake3.cool.rocks/admin/plugins/juicebox/juiceboxgallery.inc.php
<?php
/**
 * Part of Showkase web site management package
 *
 * @package Showkase
 * @author Jack Hardie {@link http://www.jhardie.com}
 * @copyright Copyright (c) 2012, SimpleViewer Inc.
 */
defined('SK_ACCESS')||die('<h1>403: Forbidden</h1>');
require_once 'classes'.DIRECTORY_SEPARATOR.'gallery.php';
require_once 'classes'.DIRECTORY_SEPARATOR.'galleryreader.php';
 
/**
 * Models a SimpleViewer gallery
 *
 * @package Showkase
 */
class JuiceboxGallery extends Gallery
{  
 /**
  * @var string gallery type
  *
  */
  protected $galleryType = 'juicebox';
  
  
 /**
  * @var string name of image class
  */
  protected $imageClass = 'JuiceboxImage';
  
 /**
  * @var string default image path
  */
  protected $imageDirPathRelGallery = JB_IMAGE_PATH;
  
 /**
  * @var string default thumb path
  */
  protected $thumbDirPathRelGallery = JB_THUMB_PATH;
  
 /**
  * @var integer thumb width
  */ 
  protected $thumbWidth = JB_THUMB_WIDTH;

 /**
  * @var integer thumb height
  */
  protected $thumbHeight = JB_THUMB_HEIGHT;
  
 /**
  * @var integer thumb quality
  */
  protected $thumbQuality = JB_THUMB_QUALITY;
  
 /**
  * @var string name of gallery xml file
  */
  protected $galleryXmlFile = JB_XML_FILE;
  
 /**
  * @var string settings tag in gallery xml file
  */
  protected $xmlSettingsTag = JB_XML_SETTINGS_TAG;
  
 /**
  * @var string gallery.xml file image tag name
  */
  protected $xmlImageTag = JB_XML_IMAGE_TAG; 
  
  
  /**
   * Constructor
   * 
   * @access public
   * @param object Simpleviewer Page
   * @param string gallery reference (permanent reference not the galleriesData index)
   * @param string gallery path
   * @param boolean new gallery
   *
   */  
  function __construct(JuiceboxPage $page, $ref, $path)
  {
    parent::__construct($page, $ref, $path);
    if(!is_null($page->getLayerVar('thumbWidth')))
    {
      $this->thumbWidth = $page->getLayerVar('thumbWidth');
    }
    if(!is_null($page->getLayerVar('thumbHeight')))
    {
      $this->thumbHeight = $page->getLayerVar('thumbHeight');
    }
  }

 /**
  * Get xml path
  *
  * @access private
  * @return string calculated xml path
  */
  function getXmlPath()
  {
    return $this->galleryPathRelSvm.JB_XML_FILE;
  }
  
 /**
  * get prefix for colors in gallery.xml
  * @return string
  */
  public function getColorPrefix()
  {
    return '#';
  }

  /**
   * Set captions in image data
   *
   * @access public
   * @return  boolean true on success
   * @param array captions
   */
  public function setAllImageAttributes($post)
  {
    $captions = $post['cap'];
    $titles = $post['tit'];
    $links = $post['url'];
    $targets = $post['target'];
    $i=0;
    foreach (array_keys($this->imageObjects) as $key)
    {
      $this->imageObjects[$key]->setImageAttributes($titles[$key], $captions[$key], $links[$key], $targets[$key], $i);
      $i++;
    }
    return true;
  }
  
  /**
   * Reads gallery settings from gallery config file
   *
   * @return array of gallery settings
   */
  public function importConfig()
  {
      return GalleryReader::readSettings($this->galleryPathRelSvm.'config.xml', 'juiceboxgallery');
  }
     
}