Example #1
0
 /**
  * @param int $limitstart
  * @param int $limit
  * @param int $imagesForEvents if true load the main images at the first position
  * @return array
  */
 public function getFiles($limitstart = 0, $limit = 0, $imagesForEvents = 0)
 {
     // database handling
     // database handling
     $db = JFactory::getDBO();
     $query = $db->getQuery(true)->select('file.*, COUNT(comment.id) AS ' . $db->quoteName('commentCount'))->from($db->quoteName('#__eventgallery_file') . ' AS file')->join('INNER', $db->quoteName('#__eventgallery_folder') . ' AS folder ON folder.folder=file.folder and folder.published=1')->join('LEFT', $db->quoteName('#__eventgallery_comment') . ' AS comment ON file.folder=comment.folder and file.file=comment.file')->where('file.folder=' . $db->Quote($this->_foldername))->where('file.published=1')->group('file.id');
     if ($imagesForEvents == 0) {
         // find files which are allowed to show in a list
         $query->where('file.ismainimageonly=0')->order('ordering DESC, file.file');
     } else {
         // find files and sort them with the main images first
         $query->order('file.ismainimage DESC, ordering DESC, file.file');
     }
     if ($limit != 0) {
         $db->setQuery($query, $limitstart, $limit);
     } else {
         $db->setQuery($query);
     }
     $entries = $db->loadObjectList();
     $result = array();
     /**
      * @var EventgalleryLibraryManagerFile $fileMgr
      */
     $fileMgr = EventgalleryLibraryManagerFile::getInstance();
     foreach ($entries as $entry) {
         $result[] = $fileMgr->getFile($entry);
     }
     return $result;
 }
Example #2
0
 public function display($cachable = false, $urlparams = array())
 {
     /**
      * @var JApplicationSite $app
      */
     $app = JFactory::getApplication();
     $params = $app->getParams();
     $str_folder = JRequest::getVar('folder', null);
     $str_file = JRequest::getVar('file', null);
     $is_sharing_download = JRequest::getBool('is_for_sharing', false);
     /**
      * @var EventgalleryLibraryManagerFile $fileMgr
      */
     $fileMgr = EventgalleryLibraryManagerFile::getInstance();
     $file = $fileMgr->getFile($str_folder, $str_file);
     if (!is_object($file) || !$file->isPublished()) {
         JError::raiseError(404, JText::_('COM_EVENTGALLERY_SINGLEIMAGE_NO_PUBLISHED_MESSAGE'));
     }
     $folder = $file->getFolder();
     if (!$folder->isPublished() || !$folder->isVisible()) {
         JError::raiseError(404, JText::_('COM_EVENTGALLERY_EVENT_NO_PUBLISHED_MESSAGE'));
     }
     // deny downloads if the social sharing option is disabled
     if ($params->get('use_social_sharing_button', 0) == 0) {
         JError::raiseError(404, JText::_('COM_EVENTGALLERY_FILE_NOT_DOWNLOADABLE_MESSAGE'));
     }
     // allow the download if at least one sharing type is enabled both global and for the event
     if ($params->get('use_social_sharing_facebook', 0) == 1 && $folder->getAttribs()->get('use_social_sharing_facebook', 1) == 1 || $params->get('use_social_sharing_google', 0) == 1 && $folder->getAttribs()->get('use_social_sharing_google', 1) == 1 || $params->get('use_social_sharing_twitter', 0) == 1 && $folder->getAttribs()->get('use_social_sharing_twitter', 1) == 1 || $params->get('use_social_sharing_pinterest', 0) == 1 && $folder->getAttribs()->get('use_social_sharing_pinterest', 1) == 1 || $params->get('use_social_sharing_email', 0) == 1 && $folder->getAttribs()->get('use_social_sharing_email', 1) == 1 || $params->get('use_social_sharing_download', 0) == 1 && $folder->getAttribs()->get('use_social_sharing_download', 1) == 1) {
     } else {
         JError::raiseError(404, JText::_('COM_EVENTGALLERY_FILE_NOT_DOWNLOADABLE_MESSAGE'));
     }
     $basename = COM_EVENTGALLERY_IMAGE_FOLDER_PATH . $folder->getFolderName() . '/';
     $filename = $basename . $file->getFileName();
     if ($params->get('download_original_images', 0) == 1) {
         $mime = ($mime = getimagesize($filename)) ? $mime['mime'] : $mime;
         $size = filesize($filename);
         $fp = fopen($filename, "rb");
         if (!($mime && $size && $fp)) {
             // Error.
             return;
         }
         header("Content-type: " . $mime);
         header("Content-Length: " . $size);
         if (!$is_sharing_download) {
             header("Content-Disposition: attachment; filename=" . $file->getFileName());
         }
         header('Content-Transfer-Encoding: binary');
         header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
         fpassthru($fp);
         die;
     } else {
         if (!$is_sharing_download) {
             header("Content-Disposition: attachment; filename=" . $file->getFileName());
         }
         header('Content-Transfer-Encoding: binary');
         header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
         $this->resize($file->getFolderName(), $file->getFileName(), COM_EVENTGALLERY_IMAGE_ORIGINAL_MAX_WIDTH, null, null);
         die;
     }
 }
Example #3
0
 function getFile($commentId)
 {
     $comment = $this->getData($commentId);
     /**
      * @var EventgalleryLibraryManagerFile $fileMgr
      */
     $fileMgr = EventgalleryLibraryManagerFile::getInstance();
     return $fileMgr->getFile($comment->folder, $comment->file);
 }
Example #4
0
 /**
  * @return EventgalleryLibraryFile|null
  */
 public function getFile()
 {
     if ($this->_file == null) {
         /**
          * @var EventgalleryLibraryManagerFile $fileMgr
          */
         $fileMgr = EventgalleryLibraryManagerFile::getInstance();
         $this->_file = $fileMgr->getFile($this->_lineitem->folder, $this->_lineitem->file);
     }
     return $this->_file;
 }
Example #5
0
 /**
  * @param int $lineitemcontainerid
  * @param string $foldername
  * @param string $filename
  * @param int $imagetypeid
  * @param int $quantity
  *
  * @return EventgalleryLibraryImagelineitem
  */
 public function createLineitem($lineitemcontainerid, $foldername, $filename, $imagetypeid, $quantity)
 {
     /**
      * @var EventgalleryLibraryManagerFile $fileMgr
      */
     $fileMgr = EventgalleryLibraryManagerFile::getInstance();
     $file = $fileMgr->getFile($foldername, $filename);
     $imagetype = $file->getFolder()->getImageTypeSet()->getImageType($imagetypeid);
     if ($imagetype == null) {
         $imagetype = $file->getFolder()->getImageTypeSet()->getDefaultImageType();
     }
     $item = array('lineitemcontainerid' => $lineitemcontainerid, 'folder' => $file->getFolderName(), 'file' => $file->getFileName(), 'quantity' => $quantity, 'singleprice' => $imagetype->getPrice()->getAmount(), 'price' => $quantity * $imagetype->getPrice()->getAmount(), 'taxrate' => $imagetype->getTaxrate(), 'currency' => $imagetype->getPrice()->getCurrency(), 'imagetypeid' => $imagetype->getId());
     $result = $this->store($item, 'Imagelineitem');
     return new EventgalleryLibraryImagelineitem($result);
 }
Example #6
0
 /**
  * Display the view
  */
 public function display($tpl = null)
 {
     $this->state = $this->get('State');
     $this->item = $this->get('Item');
     $this->form = $this->get('Form');
     /**
      * @var EventgalleryLibraryManagerFile $fm
      */
     $fm = EventgalleryLibraryManagerFile::getInstance();
     $this->file = $fm->getFile($this->item);
     // Check for errors.
     if (count($errors = $this->get('Errors'))) {
         JError::raiseError(500, implode("\n", $errors));
         return false;
     }
     $this->addToolbar();
     EventgalleryHelpersEventgallery::addSubmenu('file');
     $this->sidebar = JHtmlSidebar::render();
     return parent::display($tpl);
 }
Example #7
0
<?php

/**
 * @package     Sven.Bluege
 * @subpackage  com_eventgallery
 *
 * @copyright   Copyright (C) 2005 - 2013 Sven Bluege All rights reserved.
 * @license     GNU General Public License version 2 or later; see LICENSE.txt
 */
defined('_JEXEC') or die('Restricted access');
JHtml::_('behavior.tooltip');
/**
 * @var EventgalleryLibraryManagerFile $fileMgr
 */
$fileMgr = EventgalleryLibraryManagerFile::getInstance();
?>

<form action="index.php" method="post" id="adminForm" name="adminForm">
<?php 
if (!empty($this->sidebar)) {
    ?>
	<div id="j-sidebar-container" class="span2">
		<?php 
    echo $this->sidebar;
    ?>
	</div>
	<div id="j-main-container" class="span10">
<?php 
} else {
    ?>
	<div id="j-main-container">
Example #8
0
 /**
  * adds an image to the cart and checks if this action is actually allowed
  */
 function addItem($foldername, $filename, $count = 1, $typeid = NULL)
 {
     if ($filename == NULL || $foldername == NULL) {
         throw new Exception("can't add item with invalid file or folder name");
     }
     /**
      * @var EventgalleryLibraryManagerFile $fileMgr
      */
     $fileMgr = EventgalleryLibraryManagerFile::getInstance();
     $file = $fileMgr->getFile($foldername, $filename);
     /* security check BEGIN */
     if (!$file->isPublished()) {
         throw new Exception("the item you try to add is not published.");
     }
     if (!$file->getFolder()->isCartable()) {
         throw new Exception("the item you try to add is not cartable.");
     }
     if (!$file->getFolder()->isVisible()) {
         throw new Exception("the item you try to add is not visible for you. You might want to login first.");
     }
     if (!$file->getFolder()->isAccessible()) {
         throw new Exception("the item you try to add is not accessible. You might need to enter a password to unlock the folder first.");
     }
     /* check of the folder allows the type id. take the first type if not specific type was given. */
     /*@var EventgalleryLibraryImagetype */
     $imageType = NULL;
     if ($typeid == NULL) {
         $imageType = $file->getFolder()->getImageTypeSet()->getDefaultImageType();
     } else {
         $imageType = $file->getFolder()->getImageTypeSet()->getImageType($typeid);
     }
     if ($imageType == NULL) {
         throw new Exception("the image type you specified for the new item is invalid. Reason for this can be that there is not image type set, no image type set image type assignments or the image type set does not contain the image type");
     }
     /* security check END */
     /**
      * @var EventgalleryLibraryFactoryImagelineitem $imageLineItemFactory
      */
     $imageLineItemFactory = EventgalleryLibraryFactoryImagelineitem::getInstance();
     $lineitem = $this->getLineItemByFileAndType($foldername, $filename, $typeid);
     if ($lineitem == null) {
         $lineitem = $imageLineItemFactory->createLineitem($this->getId(), $foldername, $filename, $typeid, $count);
     } else {
         $lineitem->setQuantity($lineitem->getQuantity() + $count);
     }
     $this->_updateLineItemContainer();
     return $lineitem;
 }