Exemplo n.º 1
0
 function display($tpl = NULL)
 {
     /**
      * @var JSite $app
      */
     $app = JFactory::getApplication();
     $this->state = $this->get('State');
     $this->params = $app->getParams();
     $model = $this->getModel('singleimage');
     $model->getData(JRequest::getString('folder'), JRequest::getString('file'));
     $this->model = $model;
     $this->file = $model->file;
     if (!isset($this->file) || strlen($this->file->getFileName()) == 0 || $this->file->isPublished() != 1) {
         JError::raiseError(404, JText::_('COM_EVENTGALLERY_SINGLEIMAGE_NO_PUBLISHED_MESSAGE'));
     }
     $this->folder = $this->file->getFolder();
     if (!isset($this->file) || strlen($this->file->getFileName()) == 0 || $this->file->isPublished() != 1) {
         JError::raiseError(404, JText::_('COM_EVENTGALLERY_SINGLEIMAGE_NO_PUBLISHED_MESSAGE'));
     }
     $this->position = $model->position;
     /* Default Page fallback*/
     $active = $app->getMenu()->getActive();
     if (NULL == $active) {
         $this->params->merge($app->getMenu()->getDefault()->params);
         $active = $app->getMenu()->getDefault();
     }
     $this->currentItemid = $active->id;
     $this->use_comments = $this->params->get('use_comments');
     if (!$this->folder->isVisible()) {
         $user = JFactory::getUser();
         if ($user->guest) {
             $redirectUrl = JRoute::_("index.php?option=com_eventgallery&view=singleimage&folder=" . $this->folder->getFolderName() . "&file=" . $this->file->getFileName(), 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($this->folder, $password);
     if (!$accessAllowed) {
         $app->redirect(JRoute::_("index.php?option=com_eventgallery&view=password&folder=" . $this->folder->getFolderName(), false));
     }
     $this->setLayout(JRequest::getString('layout', 'minipage'));
     parent::display($tpl);
 }
Exemplo n.º 2
0
 function display($tpl = NULL)
 {
     /**
      * @var JSite $app
      */
     $app = JFactory::getApplication();
     $this->state = $this->get('State');
     $this->params = $app->getParams();
     $model = $this->getModel('singleimage');
     $modelComment = JModelLegacy::getInstance('Comment', 'EventgalleryModel');
     $model->getData(JRequest::getString('folder'), JRequest::getString('file'));
     $this->model = $model;
     $this->file = $model->file;
     if (!is_object($this->file) || $this->file->isPublished() != 1) {
         JError::raiseError(404, JText::_('COM_EVENTGALLERY_SINGLEIMAGE_NO_PUBLISHED_MESSAGE'));
     }
     $this->folder = $this->file->getFolder();
     $this->position = $model->position;
     /** Default Page fallback
      * @var JMenu $active
      */
     $active = $app->getMenu()->getActive();
     if (NULL == $active) {
         $this->params->merge($app->getMenu()->getDefault()->params);
         $active = $app->getMenu()->getDefault();
     }
     $this->currentItemid = $active->id;
     $this->use_comments = $this->params->get('use_comments');
     if ($this->use_comments) {
         $this->commentform = $modelComment->getForm();
     }
     if (!is_object($this->folder) || $this->folder->isPublished() != 1) {
         JError::raiseError(404, JText::_('COM_EVENTGALLERY_EVENT_NO_PUBLISHED_MESSAGE'));
     }
     if (!isset($this->file) || strlen($this->file->getFileName()) == 0 || $this->file->isPublished() != 1) {
         JError::raiseError(404, JText::_('COM_EVENTGALLERY_SINGLEIMAGE_NO_PUBLISHED_MESSAGE'));
     }
     if (!$this->folder->isVisible()) {
         $user = JFactory::getUser();
         if ($user->guest) {
             $redirectUrl = JRoute::_("index.php?option=com_eventgallery&view=singleimage&folder=" . $this->folder->getFolderName() . "&file=" . $this->file->getFileName(), 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($this->folder, $password);
     if (!$accessAllowed) {
         $app->redirect(JRoute::_("index.php?option=com_eventgallery&view=password&folder=" . $this->folder->getFolderName(), false));
     }
     // remove the password from the url
     if (strlen($password) > 0) {
         $app->redirect(JRoute::_("index.php?option=com_eventgallery&view=singleimage&folder=" . $this->folder->getFolderName() . "&file=" . $this->file->getFileName(), false));
     }
     $this->imageset = $this->folder->getImageTypeSet();
     $pathway = $app->getPathWay();
     if ($active->query['view'] == 'categories') {
         EventgalleryHelpersCategories::addCategoryPathToPathway($pathway, JRequest::getInt('catid', 0), $this->folder->getCategoryId(), $this->currentItemid);
     }
     $pathway->addItem($this->folder->getDisplayName(), JRoute::_('index.php?option=com_eventgallery&view=event&folder=' . $this->folder->getFolderName()));
     $pathway->addItem($model->position . ' / ' . $model->overallcount);
     $this->_prepareDocument();
     parent::display($tpl);
 }