/home/coolpkct/www/websites/cake3.cool.rocks/admin/plugins/juicebox/juiceboximage.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.'image.php';
 
/**
 * Autoviewer image
 *
 * @package Showkase
 */
class JuiceboxImage extends Image
{

  /**
   * constructor
   *
   * @param string  gallery path rel svm
   * @param string image path rel gallery or null if not known
   * @param object xml image element
   */
  public function __construct(Page $page, $galleryPathRelSvm, $imagePathRelGallery, $imageData=null)
  {
      parent::__construct($page, $galleryPathRelSvm, $imagePathRelGallery, $imageData);
      if (is_null($imageData)) {
          $this->thumbPathRelGallery = JB_THUMB_PATH.basename($this->imagePathRelGallery);
          $this->thumbUrl = str_replace(array('\\', '/'), '/', $this->thumbPathRelGallery);
      }
      else {
          if ($this->thumbUrl == '') {
            $this->thumbUrl = JB_THUMB_PATH.basename($this->imageUrl);
          }
          $this->thumbPathRelGallery = str_replace(array('\\', '/'), DIRECTORY_SEPARATOR, $this->thumbUrl);
      }
      $this->thumbPathRelGallery = Helpers::changeFileExtension($this->thumbPathRelGallery, 'jpg', array('jpeg', 'JPG', 'JPEG'));
      $this->thumbUrl = Helpers::changeFileExtension($this->thumbUrl, 'jpg', array('jpeg', 'JPG', 'JPEG'));
  }
    
  /**
   * Create dom document to represent the image
   * @return object
   */
  public function getXml()
  {
      $domDoc = new domDocument('1.0', 'utf-8');
      $rootElement = $domDoc->createElement('image');
      $domDoc->appendChild($rootElement); 
      $rootElement->setAttribute('imageURL', str_replace(array('\\', '/'), '/', $this->imagePathRelGallery));
      $rootElement->setAttribute('thumbURL', str_replace(array('\\', '/'), '/', $this->thumbPathRelGallery));
      $rootElement->setAttribute('linkURL', $this->imageLinkUrl);
      $rootElement->setAttribute('linkTarget', $this->imageLinkTarget);
      $titleElement = $domDoc->createElement('title');
      $titleText = $domDoc->createCDATASection($this->imageTitle);
      $titleElement->appendChild($titleText);
      $rootElement->appendChild($titleElement);
      $captionElement = $domDoc->createElement('caption');
      $captionText = $domDoc->createCDATASection($this->imageCaption);
      $captionElement->appendChild($captionText);
      $rootElement->appendChild($captionElement);
      return $domDoc;
  }
  
  /**
   * Set image caption
   *
   * @return void
   * @param string title text
   * @param string caption text
   * @param string link url
   * @param string link target
   * @param integer key to image objects array
   */
  function setImageAttributes($title, $caption, $linkUrl, $linkTarget, $i)
  {
      $this->imageCaption = $this->formatImageAttributes($caption, $i);
      $this->imageLinkUrl = $this->formatImageAttributes($linkUrl, $i);
      $this->imageTitle = $this->formatImageAttributes($title, $i);
      $this->imageLinkTarget = $linkTarget;
  }
}