/home/coolpkct/www/websites/cake3.cool.rocks/admin/plugins/simpleviewer/simpleviewergallery.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 SimpleviewerGallery extends Gallery
{    
    /**
     * @var string gallery type
     *
     */
    protected $galleryType = 'simpleviewer';
    
    /**
     * @var string name of image class
     */
    protected $imageClass = 'SimpleviewerImage';
    
    /**
     * @var string default image path
     */
    protected $imageDirPathRelGallery = SV_IMAGE_PATH;
    
    /**
     * @var string default thumb path
     */
    protected $thumbDirPathRelGallery = SV_THUMB_PATH;
    
    /**
     * @var integer thumb width
     */ 
    protected $thumbWidth = SV_THUMB_WIDTH;

    /**
     * @var integer thumb height
     */
    protected $thumbHeight = SV_THUMB_HEIGHT;
    
    /**
     * @var integer thumb quality
     */
    protected $thumbQuality = SV_THUMB_QUALITY;
    
    /**
     * @var string acceptable html tags in captions
     */
    protected $okCaptionTags = '<u><a><font><b><i><br><br/>';
    
    /**
      * @var string name of gallery xml file
      */
    protected $galleryXmlFile = SV_XML_FILE;
    
    /**
     * @var string settings tag in gallery xml file
     */
    protected $xmlSettingsTag = SV_XML_SETTINGS_TAG;
    
    /**
     * @var string gallery.xml file image tag name
     */
    protected $xmlImageTag = SV_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(SimpleviewerPage $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.SV_XML_FILE;
    }
    
    /**
     * get prefix for colors in gallery.xml
     * @return string
     */
    public function getColorPrefix()
    {
        return '0x';
    }

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