Example #1
0
 /**
  * Method to catch the onAfterDispatch event.
  *
  * This is where we setup the click-through content highlighting for.
  * The highlighting is done with JavaScript so we just
  * need to check a few parameters and the JHtml behavior will do the rest.
  *
  * @return  boolean  True on success
  *
  * @since   2.5
  */
 public function onAfterDispatch()
 {
     // Check that we are in the site application.
     if (JFactory::getApplication()->isAdmin()) {
         return true;
     }
     /**
      * no need to run if we don't need to show any event gallery related stuff. 
      * This plugin only kicks in if we are in the component and all the classes 
      * are registered
      */
     if (!class_exists('EventgalleryLibraryManagerFolder')) {
         return true;
     }
     $db = JFactory::getDbo();
     /**
      * find empty picasa folders
      **/
     $query = $db->getQuery(true)->select('folder.*')->from($db->quoteName('#__eventgallery_folder') . ' AS folder')->join('LEFT', $db->quoteName('#__eventgallery_file') . ' AS file ON folder.folder = file.folder and file.published=1')->where('file.file IS NULL')->where('folder.foldertypeid=1');
     $db->setQuery($query);
     $entries = $db->loadObjectList();
     $folderMgr = EventgalleryLibraryManagerFolder::getInstance();
     // use the picasa reload magic to refresh empty albums.
     foreach ($entries as $entry) {
         $folder = $folderMgr->getFolder($entry->folder);
         // we need to call the method getAlbum in order to start the XML sync
         if (method_exists($folder, 'getAlbum')) {
             $folder->getAlbum();
         }
     }
 }
Example #2
0
 /**
  * Entry point for the script
  *
  * @return  void
  *
  * @since   2.5
  */
 public function doExecute()
 {
     define('JPATH_COMPONENT_ADMINISTRATOR', JPATH_ADMINISTRATOR . '/components/com_eventgallery');
     define('JPATH_COMPONENT_SITE', JPATH_SITE . '/components/com_eventgallery');
     $language = JFactory::getLanguage();
     $language->load('com_eventgallery', JPATH_COMPONENT_ADMINISTRATOR, $language->getTag(), true);
     //JLoader::registerPrefix('Eventgallery', JPATH_COMPONENT_ADMINISTRATOR);
     JLoader::registerPrefix('Eventgallery', JPATH_COMPONENT_SITE);
     require_once JPATH_COMPONENT_ADMINISTRATOR . '/models/sync.php';
     $syncModel = JModelLegacy::getInstance('EventgalleryModelSync', '', array('ignore_request' => true));
     echo "\n\nAdding new Folders\n\n";
     /**
      * @var EventgalleryLibraryManagerFolder $folderMgr
      */
     $folderMgr = EventgalleryLibraryManagerFolder::getInstance();
     $errors = $folderMgr->addNewFolders();
     foreach ($errors as $error) {
         echo "ERROR: " . $error . "\n";
     }
     $folders = $syncModel->getFolders();
     echo "\n\nSynchronizing folders\n\n";
     foreach ($folders as $folder) {
         $result = $syncModel->syncFolder($folder);
         echo "Sync folder {$folder}: {$result}\n";
     }
 }
Example #3
0
 function display($tpl = NULL)
 {
     /**
      * @var JSite $app
      */
     $app = JFactory::getApplication();
     $this->state = $this->get('State');
     $this->params = $app->getParams();
     $file = JRequest::getString('file', '');
     $folder = JRequest::getString('folder', '');
     /**
      * @var EventgalleryLibraryManagerFolder $folderMgr
      */
     $folderMgr = EventgalleryLibraryManagerFolder::getInstance();
     $folder = $folderMgr->getFolder($folder);
     if (!is_object($folder)) {
         $app->redirect(JRoute::_("index.php?", false));
     }
     $formAction = JRoute::_("index.php?option=com_eventgallery&view=event&folder=" . $folder->getFolderName());
     $this->folder = $folder;
     $this->file = $file;
     $this->formaction = $formAction;
     $this->_prepareDocument();
     parent::display($tpl);
 }
Example #4
0
 /**
  * adds new folders to the databases
  * @return array with error Strings
  */
 public function addNewFolders()
 {
     /**
      * @var EventgalleryLibraryManagerFolder $folderMgr
      */
     $folderMgr = EventgalleryLibraryManagerFolder::getInstance();
     return $folderMgr->addNewFolders();
 }
Example #5
0
 function display($tpl = null)
 {
     $this->item = $this->get('Item');
     $folderMgr = EventgalleryLibraryManagerFolder::getInstance();
     $this->folder = $folderMgr->getFolder($this->item->folder);
     $this->addToolbar();
     EventgalleryHelpersEventgallery::addSubmenu('events');
     $this->sidebar = JHtmlSidebar::render();
     parent::display($tpl);
 }
Example #6
0
 function getTotal($folder = '')
 {
     /**
      * @var EventgalleryLibraryManagerFolder $folderMgr
      */
     $folderMgr = EventgalleryLibraryManagerFolder::getInstance();
     $folder = $folderMgr->getFolder($folder);
     if ($folder == null) {
         return 0;
     }
     return $folder->getFileCount(true);
 }
Example #7
0
 /**
  * creates the lineitem object. $dblineitem is the database object of this line item
  *
  * @param string $foldername
  * @param string $filename
  */
 function __construct($foldername, $filename)
 {
     $this->_foldername = $foldername;
     $this->_filename = $filename;
     /**
      * @var EventgalleryLibraryManagerFolder $folderMgr
      */
     $folderMgr = EventgalleryLibraryManagerFolder::getInstance();
     $this->_folder = $folderMgr->getFolder($foldername);
     if ($this->_file == null) {
         $this->_loadFile();
     }
     $this->_ls_title = new EventgalleryLibraryDatabaseLocalizablestring($this->_file->title);
     $this->_ls_caption = new EventgalleryLibraryDatabaseLocalizablestring($this->_file->caption);
 }
Example #8
0
 /**
  * Display the view
  */
 public function display($tpl = null)
 {
     $this->state = $this->get('State');
     $this->item = $this->get('Item');
     $this->form = $this->get('Form');
     $folderMgr = EventgalleryLibraryManagerFolder::getInstance();
     $this->folder = $folderMgr->getFolder($this->item->folder);
     // Check for errors.
     if (count($errors = $this->get('Errors'))) {
         JError::raiseError(500, implode("\n", $errors));
         return false;
     }
     $this->addToolbar();
     EventgalleryHelpersEventgallery::addSubmenu('event');
     $this->sidebar = JHtmlSidebar::render();
     return parent::display($tpl);
 }
Example #9
0
 /**
  * creates the lineitem object. The foldername can either be a string or a file data object
  *
  * @param string|object $foldername
  * @param string $filename
  */
 function __construct($foldername, $filename = NULL)
 {
     if (is_object($foldername)) {
         $this->_file = $foldername;
         /**
          * @var EventgalleryLibraryManagerFolder $folderMgr
          */
         $folderMgr = EventgalleryLibraryManagerFolder::getInstance();
         $this->_folder = $folderMgr->getFolder($foldername->folder);
     } else {
         parent::__construct($foldername, $filename);
     }
     if (isset($this->_file->height)) {
         $this->imageRatio = $this->_file->width / $this->_file->height;
     } else {
         $this->imageRatio = 1;
     }
 }
Example #10
0
 public function display($cachable = false, $urlparams = array())
 {
     $password = JRequest::getString('password', '');
     $folder = JRequest::getString('folder', '');
     /**
      * @var EventgalleryLibraryManagerFolder $folderMgr
      */
     $folderMgr = EventgalleryLibraryManagerFolder::getInstance();
     $folder = $folderMgr->getFolder($folder);
     // we need to do this only if someone entered a password.
     // the views will protect themselfs
     $accessAllowed = EventgalleryHelpersFolderprotection::isAccessAllowed($folder, $password);
     if (strlen($password) > 0 && !$accessAllowed) {
         $msg = JText::_('COM_EVENTGALLERY_PASSWORD_FORM_ERROR');
         $this->setRedirect(JRoute::_("index.php?option=com_eventgallery&view=password&folder=" . $folder->getFolderName(), false), $msg);
         $this->redirect();
     }
     parent::display($cachable, $urlparams);
 }
Example #11
0
 /**
  * Method to save a record.
  *
  * @param   string  $key     The name of the primary key of the URL variable.
  * @param   string  $urlVar  The name of the URL variable if different from the primary key (sometimes required to avoid router collisions).
  *
  * @return  boolean  True if successful, false otherwise.
  *
  * @since   12.2
  */
 public function save($key = null, $urlVar = null)
 {
     $task = $this->getTask();
     if ($task == 'save2copy') {
         $data = $this->input->post->get('jform', array(), 'array');
         /**
          * @var EventgalleryLibraryManagerFolder $folderMgr
          */
         $folderMgr = EventgalleryLibraryManagerFolder::getInstance();
         $folder = $folderMgr->getFolder($data['folder']);
         if (null != $folder) {
             $this->setError(JText::_('COM_EVENTGALLERY_EVENT_COPY_ERROR'));
             $this->setMessage($this->getError(), 'error');
             $this->setRedirect(JRoute::_('index.php?option=' . $this->option . '&view=' . $this->view_item . $this->getRedirectToItemAppend($data['id'], 'id'), false));
             return false;
         }
     }
     parent::save($key, $urlVar);
 }
Example #12
0
 /**
  * Returns a file
  *
  * @param $foldername
  * @param $filename
  * @return EventgalleryLibraryFile
  */
 public function getFile($foldername, $filename = null)
 {
     if (is_object($foldername)) {
         $currentFolder = $foldername->folder;
         $filename = $foldername->file;
     } else {
         $currentFolder = $foldername;
     }
     if (!isset($this->_folders[$currentFolder][$filename])) {
         /**
          * @var EventgalleryLibraryManagerFolder $folderMgr
          */
         $folderMgr = EventgalleryLibraryManagerFolder::getInstance();
         $folder = $folderMgr->getFolder($currentFolder);
         if ($folder == null) {
             $this->_folders[$currentFolder][$filename] = null;
         } else {
             $fileClass = $folder->getFileHandlerClassname();
             $this->_folders[$currentFolder][$filename] = new $fileClass($foldername, $filename);
         }
     }
     return $this->_folders[$currentFolder][$filename];
 }
Example #13
0
				</th>
                <th class="nowrap">
                    <?php 
echo JText::_('COM_EVENTGALLERY_EVENTS_EVENT_DATE');
?>
                </th>
				
			</tr>			
		</thead>
		<?php 
for ($i = 0, $n = count($this->items); $i < $n; $i++) {
    $row = $this->items[$i];
    /**
     * @var EventgalleryLibraryManagerFolder $folderMgr
     */
    $folderMgr = EventgalleryLibraryManagerFolder::getInstance();
    $folder = $folderMgr->getFolder($row->folder);
    ?>
			<tr class="">
				<td>
					<div class="btn-group">

                        
                        <?php 
    if ($row->published == 1) {
        ?>
                            <a title="<?php 
        echo JText::_('COM_EVENTGALLERY_BUTTON_PUBLISHED_DESC');
        ?>
" style="color: green" class="btn btn-micro active jgrid" href="javascript:void(0);" >
                                <span class="state"><i class="icon-publish"></i></span>
Example #14
0
 /**
  * This method calculates the image and delivers it to the client.
  *
  * @param $folder
  * @param $file
  * @param $width
  * @param $height
  * @param $mode
  */
 public function resize($folder, $file, $width = -1, $height = -1, $mode = 'nocrop')
 {
     $jpeg_orientation_translation = array(1 => 0, 2 => 0, 3 => 180, 4 => 0, 5 => 0, 6 => -90, 7 => 0, 8 => 90);
     /**
      * @var JApplicationSite $app
      */
     $app = JFactory::getApplication();
     $params = $app->getParams();
     if (strcmp($mode, 'full') == 0) {
         $mode = 'nocrop';
         $width = COM_EVENTGALLERY_IMAGE_ORIGINAL_MAX_WIDTH;
         $height = COM_EVENTGALLERY_IMAGE_ORIGINAL_MAX_WIDTH;
     }
     if ($height > $width) {
         $width = $height;
     }
     $sizeSet = new EventgalleryHelpersSizeset();
     $saveAsSize = $sizeSet->getMatchingSize($width);
     $file = STR_REPLACE("\\.\\.", "", $file);
     $folder = STR_REPLACE("\\.\\.", "", $folder);
     $width = STR_REPLACE("\\.\\.", "", $width);
     $mode = STR_REPLACE("\\.\\.", "", $mode);
     $file = STR_REPLACE("/", "", $file);
     $folder = STR_REPLACE("/", "", $folder);
     $width = STR_REPLACE("/", "", $width);
     $mode = STR_REPLACE("/", "", $mode);
     $file = STR_REPLACE("\\", "", $file);
     $folder = STR_REPLACE("\\", "", $folder);
     $width = STR_REPLACE("\\", "", $width);
     $mode = STR_REPLACE("\\", "", $mode);
     $basedir = COM_EVENTGALLERY_IMAGE_FOLDER_PATH;
     $sourcedir = $basedir . $folder;
     $cachebasedir = COM_EVENTGALLERY_IMAGE_CACHE_PATH;
     $cachedir = $cachebasedir . $folder;
     $cachedir_thumbs = $cachebasedir . $folder;
     if (!is_dir(JPATH_CACHE)) {
         //mkdir($cachebasedir, 0777);
         mkdir(JPATH_CACHE);
     }
     if (!is_dir($cachebasedir)) {
         //mkdir($cachebasedir, 0777);
         mkdir($cachebasedir);
     }
     if (!is_dir($cachedir)) {
         //mkdir($cachedir, 0777);
         mkdir($cachedir);
     }
     if (!is_dir($cachedir_thumbs)) {
         //mkdir($cachedir_thumbs, 0777);
         mkdir($cachedir_thumbs);
     }
     $image_file = $sourcedir . DIRECTORY_SEPARATOR . $file;
     $image_thumb_file = $cachedir_thumbs . DIRECTORY_SEPARATOR . $mode . $saveAsSize . $file;
     //$last_modified = gmdate('D, d M Y H:i:s T', filemtime ($image_file));
     $last_modified = gmdate('D, d M Y H:i:s T', mktime(0, 0, 0, 1, 1, 2100));
     #echo "<br>".$image_thumb_file."<br>";
     $debug = false;
     if ($debug || !file_exists($image_thumb_file)) {
         $ext = pathinfo($image_file, PATHINFO_EXTENSION);
         $input_jpeg = null;
         $exif = null;
         if (strtolower($ext) == "gif") {
             if (!($im_original = imagecreatefromgif($image_file))) {
                 echo "Error opening {$image_file}!";
                 exit;
             }
         } else {
             if (strtolower($ext) == "jpg" || strtolower($ext) == "jpeg") {
                 // try to use PEL first. If things fail, use the php internal method to get the JPEG
                 try {
                     $input_jpeg = new PelJpeg($image_file);
                     /* Retrieve the original Exif data in $jpeg (if any). */
                     $exif = $input_jpeg->getExif();
                     /* The input image is already loaded, so we can reuse the bytes stored
                      * in $input_jpeg when creating the Image resource. */
                     if (!($im_original = ImageCreateFromString($input_jpeg->getBytes()))) {
                         echo "Error opening {$image_file}!";
                         exit;
                     }
                 } catch (Exception $e) {
                     if (!($im_original = imagecreatefromjpeg($image_file))) {
                         echo "Error opening {$image_file}!";
                         exit;
                     }
                 }
             } else {
                 if (strtolower($ext) == "png") {
                     if (!($im_original = imagecreatefrompng($image_file))) {
                         echo "Error opening {$image_file}!";
                         exit;
                     }
                 } else {
                     die("{$ext} not supported");
                 }
             }
         }
         if ($params->get('use_autorotate', 1) == 1 && $exif != NULL) {
             $tiff = $exif->getTiff();
             $ifd0 = $tiff->getIfd();
             $orientation = $ifd0->getEntry(PelTag::ORIENTATION);
             if ($orientation != null) {
                 $im_original = imagerotate($im_original, $jpeg_orientation_translation[$orientation->getValue()], 0);
                 $orientation->setValue(1);
             }
         }
         $orig_width = imagesx($im_original);
         $orig_height = imagesy($im_original);
         $orig_ratio = imagesx($im_original) / imagesy($im_original);
         $sizeCalc = new EventgalleryHelpersSizecalculator($orig_width, $orig_height, $width, strcmp('crop', $mode) == 0);
         $height = $sizeCalc->getHeight();
         $width = $sizeCalc->getWidth();
         //print_r($sizeCalc);
         // create canvas/border image
         //adjust height to not enlarge images
         if ($width > $orig_width) {
             $width = $orig_width;
         }
         if ($height > $orig_height) {
             $height = $orig_height;
         }
         if (strcmp('crop', $mode) != 0) {
             $canvasWidth = $width;
             $canvasHeight = ceil($width / $orig_ratio);
             if ($canvasHeight > $height) {
                 $canvasHeight = $height;
                 $canvasWidth = ceil($height * $orig_ratio);
             }
             $width = $canvasWidth;
             $height = $canvasHeight;
         } else {
             $height = $width;
         }
         $isOriginalSize = false;
         if ($height == $orig_height && $width == $orig_width) {
             $isOriginalSize = true;
         }
         /**
          * Do not recalculate the image if we don't need to resize it.
          */
         if ($isOriginalSize && $params->get('use_sharpening_for_originalsize', 1) == 0) {
             $im_output = $im_original;
         } else {
             $im_output = imagecreatetruecolor($width, $height);
             $resize_faktor = $orig_height / $height;
             $new_height = $height;
             $new_width = $orig_width / $resize_faktor;
             if ($new_width < $width) {
                 $resize_faktor = $orig_width / $width;
                 $new_width = $width;
                 $new_height = $orig_height / $resize_faktor;
             }
             imagecopyresampled($im_output, $im_original, $width / 2 - $new_width / 2, $height / 2 - $new_height / 2, 0, 0, $new_width, $new_height, $orig_width, $orig_height);
             $use_sharpening = $params->get('use_sharpening', 1);
             if ($use_sharpening == 1) {
                 // configure the sharpening
                 $stringSharpenMatrix = $params->get('image_sharpenMatrix', '[[-1,-1,-1],[-1,16,-1],[-1,-1,-1]]');
                 $sharpenMatrix = json_decode($stringSharpenMatrix);
                 if (null == $sharpenMatrix || count($sharpenMatrix) != 3) {
                     $sharpenMatrix = array(array(-1, -1, -1), array(-1, 16, -1), array(-1, -1, -1));
                 }
                 $divisor = array_sum(array_map('array_sum', $sharpenMatrix));
                 $offset = 0;
                 if (function_exists('imageconvolution')) {
                     if (version_compare(phpversion(), '5.5.9', '=')) {
                         $this->imageconvolution($im_output, $sharpenMatrix, $divisor, $offset);
                     } else {
                         imageconvolution($im_output, $sharpenMatrix, $divisor, $offset);
                     }
                 }
             }
         }
         /**
          * @var EventgalleryLibraryManagerFolder $folderMgr
          * @var EventgalleryLibraryFolder $folder
          */
         $folderMgr = EventgalleryLibraryManagerFolder::getInstance();
         $folder = $folderMgr->getFolder($folder);
         $watermark = $folder->getWatermark();
         // load default watermark
         if (null == $watermark || !$watermark->isPublished()) {
             /**
              * @var EventgalleryLibraryManagerWatermark $watermarkMgr
              * @var EventgalleryLibraryWatermark $watermark
              */
             $watermarkMgr = EventgalleryLibraryManagerWatermark::getInstance();
             $watermark = $watermarkMgr->getDefaultWatermark();
         }
         if (null != $watermark && $watermark->isPublished()) {
             $watermark->addWatermark($im_output);
         }
         $image_quality = $params->get('image_quality', 85);
         if ($input_jpeg != null) {
             Pel::setJPEGQuality($image_quality);
             /* We want the raw JPEG data from $scaled. Luckily, one can create a
              * PelJpeg object from an image resource directly: */
             $output_jpeg = new PelJpeg($im_output);
             /* If no Exif data was present, then $exif is null. */
             if ($exif != null) {
                 $output_jpeg->setExif($exif);
             }
             /* We can now save the scaled image. */
             $writeSuccess = true;
             $output_jpeg->saveFile($image_thumb_file);
         } else {
             $writeSuccess = imagejpeg($im_output, $image_thumb_file, $image_quality);
             if (!$writeSuccess) {
                 die("Unable to write to file {$image_thumb_file}");
             }
         }
         if (!$writeSuccess) {
             die("Unable to write to file {$image_thumb_file}");
         }
         $time = time() + 315360000;
         touch($image_thumb_file, $time);
         // add the ICC profile
         try {
             $o = new JPEG_ICC();
             $o->LoadFromJPEG($image_file);
             $o->SaveToJPEG($image_thumb_file);
         } catch (Exception $e) {
         }
     }
     $mime = ($mime = getimagesize($image_thumb_file)) ? $mime['mime'] : $mime;
     $size = filesize($image_thumb_file);
     $fp = fopen($image_thumb_file, "rb");
     if (!($mime && $size && $fp)) {
         // Error.
         return;
     }
     if (!$debug) {
         header("Content-Type: " . $mime);
         header("Content-Length: " . $size);
         header("Last-Modified: {$last_modified}");
     }
     fpassthru($fp);
     die;
     //$app->close();
 }
Example #15
0
 /**
  * returns the number of comments for an event.
  *
  * @return mixed
  */
 public function getCommentCount()
 {
     /**
      * @var EventgalleryLibraryManagerFolder $folderMgr
      */
     $folderMgr = EventgalleryLibraryManagerFolder::getInstance();
     return $folderMgr->getCommentCount($this->_foldername);
 }
Example #16
0
 /**
  * just get the entries for this model.
  *
  * @param int $limitstart
  * @param int $limit
  * @param string $tags
  * @param string $sortAttribute
  * @param $usergroups array even if unused we need this for the cache call
  * @param $catid the category id to filter the events
  * @param $recursive defines if we should get the events for the subcategories too.
  * @return array
  */
 function getEntriesUnCached($limitstart = 0, $limit = 0, $tags = "", $sortAttribute = 'ordering', $usergroups, $catid, $recursive = false)
 {
     if ($this->_entries == null) {
         $query = $this->_db->getQuery(true)->select('folder.*, count(1) AS ' . $this->_db->quoteName('overallCount'))->from($this->_db->quoteName('#__eventgallery_folder') . ' AS folder')->join('', $this->_db->quoteName('#__eventgallery_file') . ' AS file ON folder.folder = file.folder and file.published=1')->where('(file.ismainimageonly IS NULL OR file.ismainimageonly=0)')->where('folder.published=1')->group('folder.id');
         if (null != $catid && (int) $catid != 0) {
             if ($recursive) {
                 $options = array();
                 $categories = JCategories::getInstance('Eventgallery', $options);
                 /**
                  * @var JCategoryNode $currentCategory
                  * @var JCategoryNode $childCategory
                  */
                 $currentCategory = $categories->get($catid);
                 $childCategories = $currentCategory->getChildren(true);
                 $conditions = array($catid);
                 foreach ($childCategories as $childCategory) {
                     array_push($conditions, $childCategory->id);
                 }
                 $query->where('catid in (' . implode(',', $conditions) . ') ');
             } else {
                 $query->where('catid=' . $this->_db->quote($catid));
             }
         }
         if ($sortAttribute == "date_asc") {
             $query->order('date ASC, ordering DESC');
         } elseif ($sortAttribute == "date_desc") {
             $query->order('date DESC, ordering DESC');
         } elseif ($sortAttribute == "name_asc") {
             $query->order('folder.folder ASC');
         } elseif ($sortAttribute == "name_desc") {
             $query->order('folder.folder DESC');
         } else {
             $query->order('ordering DESC');
         }
         $entries = $this->_getList($query);
         $newList = array();
         /**
          * @var EventgalleryLibraryManagerFolder $folderMgr
          */
         $folderMgr = EventgalleryLibraryManagerFolder::getInstance();
         foreach ($entries as $entry) {
             $entryObject = $folderMgr->getFolder($entry);
             // count check commented out because of picasa performance issues
             #if ($entryObject->getFileCount()>0) {
             array_push($newList, $entryObject);
             #}
         }
         $entries = $newList;
         if (strlen($tags) != 0) {
             // remove all non matching entries
             // handle space and comma separated lists like "foo bar" or "foo, bar"
             $finalWinners = array();
             /**
              * @var EventgalleryLibraryFolder $entry
              */
             foreach ($entries as $entry) {
                 if (EventgalleryHelpersTags::checkTags($entry->getFolderTags(), $tags)) {
                     $finalWinners[] = $entry;
                 }
             }
             $entries = $finalWinners;
         }
         /**
          * @var EventgalleryLibraryFolder $entry
          */
         // filter by user group
         foreach ($entries as $key => $entry) {
             if (!$entry->isVisible()) {
                 unset($entries[$key]);
             }
         }
         $this->_entries = $entries;
         $this->_total = count($entries);
     }
     return $this->_entries;
 }
Example #17
0
 function display($tpl = NULL)
 {
     /**
      * @var JSite $app
      */
     $app = JFactory::getApplication();
     $this->state = $this->get('State');
     $this->params = $app->getParams();
     /* Default Page fallback*/
     $active = $app->getMenu()->getActive();
     if (NULL == $active) {
         $this->params->merge($app->getMenu()->getDefault()->params);
         $active = $app->getMenu()->getDefault();
         //just in case the default menu item sets something else.
         $this->setLayout('default');
     }
     $this->currentItemid = $active->id;
     if ($this->getLayout() == 'default' && ($layout = $this->params->get('event_layout'))) {
         //override the layout with the menu item setting in case we link directly to an event
         if ($active != null && isset($active->query['layout']) && $active->component == 'com_eventgallery') {
             $layout = $active->query['layout'];
         }
         $this->setLayout($layout);
     }
     // legacy fix since I renamed default to pageable
     if ($this->getLayout() == 'default') {
         $this->setLayout('pageable');
     }
     $model = $this->getModel('event');
     $pageNav = $model->getPagination(JRequest::getVar('folder', ''));
     if ($this->getLayout() == 'ajaxpaging' || $this->params->get('use_event_paging', 0) == 0) {
         $entries = $model->getEntries(JRequest::getVar('folder', ''), -1, -1);
     } else {
         $entries = $model->getEntries(JRequest::getVar('folder', ''));
     }
     /**
      * @var EventgalleryLibraryManagerFolder $folderMgr
      */
     $folderMgr = EventgalleryLibraryManagerFolder::getInstance();
     $folder = $folderMgr->getFolder(JRequest::getVar('folder', ''));
     if (!is_object($folder) || $folder->isPublished() != 1) {
         JError::raiseError(404, JText::_('COM_EVENTGALLERY_EVENT_NO_PUBLISHED_MESSAGE'));
     }
     if (!$folder->isVisible()) {
         $user = JFactory::getUser();
         if ($user->guest) {
             $redirectUrl = JRoute::_("index.php?option=com_eventgallery&view=event&folder=" . $folder->getFolderName(), false);
             $redirectUrl = urlencode(base64_encode($redirectUrl));
             $redirectUrl = '&return=' . $redirectUrl;
             $joomlaLoginUrl = 'index.php?option=com_users&view=login';
             $finalUrl = JRoute::_($joomlaLoginUrl . $redirectUrl, false);
             $app->redirect($finalUrl);
         } else {
             $this->setLayout('noaccess');
         }
     }
     $password = JRequest::getString('password', '');
     $accessAllowed = EventgalleryHelpersFolderprotection::isAccessAllowed($folder, $password);
     if (!$accessAllowed) {
         $app->redirect(JRoute::_("index.php?option=com_eventgallery&view=password&folder=" . $folder->getFolderName(), false));
     }
     // remove the password from the url.
     if (strlen($password) > 0) {
         $app->redirect(JRoute::_("index.php?option=com_eventgallery&view=event&folder=" . $folder->getFolderName(), false));
     }
     if (($this->params->get('shuffle_images', 0) == 1 || $folder->getAttribs()->get('shuffle_images', 0) == 1) && $this->params->get('use_event_paging', 0) != 1) {
         $allowedLayouts = array('ajaxpaging', 'imagelist', 'simple', 'tiles');
         if (in_array($this->getLayout(), $allowedLayouts)) {
             shuffle($entries);
         }
     }
     $folder->countHits();
     $this->pageNav = $pageNav;
     $this->entries = $entries;
     $this->entriesCount = count($entries);
     $this->folder = $folder;
     $this->use_comments = $this->params->get('use_comments');
     $this->imageset = $folder->getImageTypeSet();
     /**
      * @var JPathway $pathway
      */
     $pathway = $app->getPathway();
     if ($active->query['view'] == 'categories') {
         EventgalleryHelpersCategories::addCategoryPathToPathway($pathway, JRequest::getInt('catid', 0), $folder->getCategoryId(), $this->currentItemid);
     }
     // add the event
     $pathway->addItem($folder->getDisplayName());
     $this->_prepareDocument();
     parent::display($tpl);
 }
Example #18
0
 function loadFolder($foldername)
 {
     /**
      * @var EventModelEvent $eventModel
      */
     if (!$this->folder) {
         /**
          * @var EventgalleryLibraryManagerFolder $folderMgr
          */
         $folderMgr = EventgalleryLibraryManagerFolder::getInstance();
         $this->folder = $folderMgr->getFolder($foldername);
     }
 }
Example #19
0
 /**
  * Method to get the field input markup.
  *
  * @return  string	The field input markup.
  * @since   1.6
  */
 protected function getInput()
 {
     // Load necessary media files
     EventgalleryHelpersBackendmedialoader::load();
     $allowEdit = (string) $this->element['edit'] == 'true' ? true : false;
     $allowClear = (string) $this->element['clear'] != 'false' ? true : false;
     // Load language
     JFactory::getLanguage()->load('com_eventgallery', JPATH_ADMINISTRATOR);
     // Load the modal behavior script.
     JHtml::_('behavior.modal', 'a.modal');
     // Build the script.
     $script = array();
     // Select button script
     $script[] = '	function jSelectEvent_' . $this->id . '(id, title) {';
     $script[] = '		document.getElementById("' . $this->id . '_id").value = id;';
     $script[] = '		document.getElementById("' . $this->id . '_name").value = title;';
     if ($allowEdit) {
         $script[] = '		eventgallery.jQuery("#' . $this->id . '_edit").removeClass("hidden");';
     }
     if ($allowClear) {
         $script[] = '		eventgallery.jQuery("#' . $this->id . '_clear").removeClass("hidden");';
     }
     $script[] = '		SqueezeBox.close();';
     $script[] = '	}';
     // Clear button script
     static $scriptClear;
     if ($allowClear && !$scriptClear) {
         $scriptClear = true;
         $script[] = '	function jClearEvent(id) {';
         $script[] = '		document.getElementById(id + "_id").value = "";';
         $script[] = '		document.getElementById(id + "_name").value = "' . htmlspecialchars(JText::_('COM_EVENTGALLERY_SELECT_AN_EVENT', true), ENT_COMPAT, 'UTF-8') . '";';
         $script[] = '		eventgallery.jQuery("#" + id + "_clear").addClass("hidden");';
         $script[] = '		if (document.getElementById("#" + id + "_edit")) {';
         $script[] = '			eventgallery.jQuery("#" + id + "_edit").addClass("hidden");';
         $script[] = '		}';
         $script[] = '		return false;';
         $script[] = '	}';
     }
     // Add the script to the document head.
     JFactory::getDocument()->addScriptDeclaration(implode("\n", $script));
     // Setup variables for display.
     $html = array();
     $link = 'index.php?option=com_eventgallery&amp;view=events&amp;layout=modal&amp;tmpl=component&amp;function=jSelectEvent_' . $this->id;
     if (strlen($this->value) > 0) {
         /**
          * @var EventgalleryLibraryManagerFolder $folderMgr
          */
         $folderMgr = EventgalleryLibraryManagerFolder::getInstance();
         $folder = $folderMgr->getFolder($this->value);
         if (null == $folder) {
             JError::raiseWarning(500, JText::sprintf('COM_EVENTGALLERY_EVENT_NOT_FOUND', $this->value));
         } else {
             $title = $folder->getDisplayName();
         }
     }
     if (empty($title)) {
         $title = JText::_('COM_EVENTGALLERY_SELECT_AN_EVENT');
     }
     $title = htmlspecialchars($title, ENT_QUOTES, 'UTF-8');
     // The active event id field.
     if (strlen($this->value) == 0) {
         $value = '';
     } else {
         $value = $this->value;
     }
     // The current event display field.
     $html[] = '<span class="input-append">';
     $html[] = '<input type="text" class="input-medium" id="' . $this->id . '_name" value="' . $title . '" disabled="disabled" size="35" />';
     $html[] = '<a class="modal btn hasTooltip" title="' . JText::_('COM_EVENTGALLERY_CHANGE_EVENT') . '"  href="' . $link . '&amp;' . JSession::getFormToken() . '=1" rel="{handler: \'iframe\', size: {x: 800, y: 450}}"><i class="icon-file"></i> ' . JText::_('JSELECT') . '</a>';
     // Clear event button
     if ($allowClear) {
         $html[] = '<button id="' . $this->id . '_clear" class="btn' . ($value ? '' : ' hidden') . '" onclick="return jClearEvent(\'' . $this->id . '\')"><span class="icon-remove"></span> ' . JText::_('JCLEAR') . '</button>';
     }
     $html[] = '</span>';
     // class='required' for client side validation
     $class = '';
     if ($this->required) {
         $class = ' class="required modal-value"';
     }
     $html[] = '<input type="hidden" id="' . $this->id . '_id"' . $class . ' name="' . $this->name . '" value="' . $value . '" />';
     return implode("\n", $html);
 }