Пример #1
0
 /**
  * HTML view display method
  *
  * @param   string  $tpl  The name of the template file to parse
  * @return  void
  * @since   3.0
  */
 public function display($tpl = null)
 {
     JToolBarHelper::title(JText::_('COM_JOOMGALLERY_AJAX_UPLOAD'), 'upload');
     $this->_doc->addScriptDeclaration('    var jg_filenamewithjs = ' . ($this->_config->get('jg_filenamewithjs') ? 'true' : 'false') . ';');
     // Load Fine Uploader resources
     $this->_doc->addStyleSheet($this->_ambit->getScript('fineuploader/fineuploader.css'));
     $this->_doc->addScript($this->_ambit->getScript('fineuploader/js/fineuploader' . (JFactory::getConfig()->get('debug') ? '' : '.min') . '.js'));
     $this->fileSizeLimit = 0;
     $this->chunkSize = 0;
     $post_max_size = @ini_get('post_max_size');
     if (!empty($post_max_size)) {
         $post_max_size = JoomHelper::iniToBytes($post_max_size);
         $this->chunkSize = (int) min(500000, (int) (0.8 * $post_max_size));
     }
     $upload_max_filesize = @ini_get('upload_max_filesize');
     if (!empty($upload_max_filesize)) {
         $upload_max_filesize = JoomHelper::iniToBytes($upload_max_filesize);
         $this->fileSizeLimit = $upload_max_filesize;
     }
     $this->editFilename = $this->_config->get('jg_useorigfilename');
     JForm::addFormPath(JPATH_COMPONENT . '/models/forms');
     $this->form = JForm::getInstance(_JOOM_OPTION . '.ajaxupload', 'ajaxupload');
     $this->form->setFieldAttribute('access', 'default', (int) JFactory::getConfig()->get('access'));
     if ($this->_config->get('jg_useorigfilename')) {
         $this->form->setFieldAttribute('imgtitle', 'required', 'false');
     }
     $this->sidebar = JHtmlSidebar::render();
     parent::display($tpl);
 }
Пример #2
0
 /**
  * Add the toolbar and toolbar title.
  *
  * @access  protected
  * @return  void
  *
  * @since 2.0
  */
 protected function addToolbar()
 {
     // Get the results for each action
     $canDo = JoomHelper::getActions();
     JToolBarHelper::title(JText::_('COM_JOOMGALLERY_IMGMAN_IMAGE_MANAGER'), 'images');
     if (($this->_config->get('jg_disableunrequiredchecks') || $canDo->get('joom.upload') || count(JoomHelper::getAuthorisedCategories('joom.upload'))) && $this->pagination->total) {
         JToolbarHelper::addNew('new');
     }
     if (($canDo->get('core.edit') || $canDo->get('core.edit.own')) && $this->pagination->total) {
         JToolbarHelper::editList();
         JToolbarHelper::custom('edit', 'checkbox-partial', 'checkbox-partial', 'JTOOLBAR_BATCH');
         JToolbarHelper::custom('showmove', 'move.png', 'move.png', 'COM_JOOMGALLERY_COMMON_TOOLBAR_MOVE');
         JToolbarHelper::custom('recreate', 'refresh.png', 'refresh.png', 'COM_JOOMGALLERY_COMMON_TOOLBAR_RECREATE');
         JToolbarHelper::divider();
     }
     if ($canDo->get('core.edit.state') && $this->pagination->total) {
         JToolbarHelper::publishList('publish', JText::_('COM_JOOMGALLERY_COMMON_PUBLISH'));
         JToolbarHelper::unpublishList('unpublish', JText::_('COM_JOOMGALLERY_COMMON_UNPUBLISH'));
         JToolbarHelper::custom('approve', 'upload.png', 'upload_f2.png', 'COM_JOOMGALLERY_IMGMAN_TOOLBAR_APPROVE');
         JToolbarHelper::divider();
     }
     //if($canDo->get('core.delete'))
     //{
     JToolbarHelper::deleteList('', 'remove');
     //}
 }
Пример #3
0
 /**
  * Add the toolbar and toolbar title.
  *
  * @access  protected
  * @return  void
  *
  * @since 2.0
  */
 protected function addToolbar()
 {
     // Get the results for each action
     $canDo = JoomHelper::getActions();
     JToolBarHelper::title(JText::_('COM_JOOMGALLERY_CATMAN_CATEGORY_MANAGER'), 'folder');
     if ($this->_config->get('jg_disableunrequiredchecks') || $canDo->get('core.create') || count(JoomHelper::getAuthorisedCategories('core.create'))) {
         JToolbarHelper::addNew('new');
     }
     if (($this->_config->get('jg_disableunrequiredchecks') || $canDo->get('core.edit') || count(JoomHelper::getAuthorisedCategories('core.edit'))) && $this->pagination->total) {
         JToolbarHelper::editList('edit');
         JHtml::_('bootstrap.modal', 'collapseModal');
         $title = JText::_('JTOOLBAR_BATCH');
         $dhtml = "<button data-toggle=\"modal\" data-target=\"#collapseModal\" class=\"btn btn-small\">\n                  <i class=\"icon-checkbox-partial\" title=\"{$title}\"></i>\n                  {$title}</button>";
         JToolBar::getInstance('toolbar')->appendButton('Custom', $dhtml, 'batch');
         JToolbarHelper::divider();
     }
     if (($this->_config->get('jg_disableunrequiredchecks') || count(JoomHelper::getAuthorisedCategories('core.edit.state'))) && $this->pagination->total) {
         JToolbarHelper::publishList('publish', JText::_('COM_JOOMGALLERY_COMMON_PUBLISH'));
         JToolbarHelper::unpublishList('unpublish', JText::_('COM_JOOMGALLERY_COMMON_UNPUBLISH'));
         JToolbarHelper::divider();
     }
     if (($this->_config->get('jg_disableunrequiredchecks') || $canDo->get('core.delete') || count(JoomHelper::getAuthorisedCategories('core.delete'))) && $this->pagination->total) {
         JToolbarHelper::deleteList('', 'remove');
         JToolbarHelper::divider();
     }
 }
Пример #4
0
 /**
  * Add the toolbar and toolbar title.
  *
  * @access  protected
  * @return  void
  *
  * @since 2.0
  */
 protected function addToolbar()
 {
     // Get the results for each action
     $canDo = JoomHelper::getActions();
     JToolBarHelper::title(JText::_('COM_JOOMGALLERY_CATMAN_CATEGORY_MANAGER'), 'folder');
     if ($this->_config->get('jg_disableunrequiredchecks') || $canDo->get('core.create') || count(JoomHelper::getAuthorisedCategories('core.create'))) {
         JToolbarHelper::addNew('new');
     }
     if (($this->_config->get('jg_disableunrequiredchecks') || $canDo->get('core.edit') || count(JoomHelper::getAuthorisedCategories('core.edit'))) && $this->pagination->total) {
         JToolbarHelper::editList('edit');
         JHtml::_('bootstrap.modal', 'collapseModal');
         $title = JText::_('JTOOLBAR_BATCH');
         $dhtml = "<button data-toggle=\"modal\" data-target=\"#collapseModal\" class=\"btn btn-small\">\n                  <i class=\"icon-checkbox-partial\" title=\"{$title}\"></i>\n                  {$title}</button>";
         JToolBar::getInstance('toolbar')->appendButton('Custom', $dhtml, 'batch');
         JToolbarHelper::divider();
     }
     if (($this->_config->get('jg_disableunrequiredchecks') || count(JoomHelper::getAuthorisedCategories('core.edit.state'))) && $this->pagination->total) {
         JToolbarHelper::publishList('publish', JText::_('COM_JOOMGALLERY_COMMON_PUBLISH'));
         JToolbarHelper::unpublishList('unpublish', JText::_('COM_JOOMGALLERY_COMMON_UNPUBLISH'));
         JToolbarHelper::divider();
     }
     if (($this->_config->get('jg_disableunrequiredchecks') || $canDo->get('core.delete') || count(JoomHelper::getAuthorisedCategories('core.delete'))) && $this->pagination->total) {
         JToolbarHelper::deleteList('', 'remove');
         JToolbarHelper::divider();
     }
     $options = array(JHtml::_('select.option', 1, JText::_('COM_JOOMGALLERY_COMMON_OPTION_PUBLISHED_ONLY')), JHtml::_('select.option', 0, JText::_('COM_JOOMGALLERY_COMMON_OPTION_NOT_PUBLISHED_ONLY')));
     JHtmlSidebar::addFilter(JText::_('JOPTION_SELECT_PUBLISHED'), 'filter_published', JHtml::_('select.options', $options, 'value', 'text', $this->state->get('filter.published'), true));
     JHtmlSidebar::addFilter(JText::_('JOPTION_SELECT_ACCESS'), 'filter_access', JHtml::_('select.options', JHtml::_('access.assetgroups'), 'value', 'text', $this->state->get('filter.access')));
     $options = array(JHtml::_('select.option', 1, JText::_('COM_JOOMGALLERY_CATMAN_OPTION_USERCATEGORIES_ONLY')), JHtml::_('select.option', 2, JText::_('COM_JOOMGALLERY_CATMAN_OPTION_BACKENDCATEGORIES_ONLY')));
     JHtmlSidebar::addFilter(JText::_('COM_JOOMGALLERY_COMMON_OPTION_SELECT_TYPE'), 'filter_type', JHtml::_('select.options', $options, 'value', 'text', $this->state->get('filter.type'), true));
 }
Пример #5
0
 /**
  * Constructor
  *
  * @access  protected
  * @return  void
  * @since   1.5.5
  */
 function __construct($config = array())
 {
     parent::__construct($config);
     $this->_ambit = JoomAmbit::getInstance();
     $this->_config = JoomConfig::getInstance();
     $this->_mainframe = JFactory::getApplication('administrator');
     $this->_user = JFactory::getUser();
     $this->_doc = JFactory::getDocument();
     $this->_doc->addStyleSheet($this->_ambit->getStyleSheet('admin.joomgallery.css'));
     JHtmlBehavior::framework();
     $this->_doc->addScript($this->_ambit->getScript('admin.js'));
     JoomHelper::addSubmenu();
     JHTML::addIncludePath(JPATH_COMPONENT . '/helpers/html');
     // Check for available updates
     if (!($checked = $this->_mainframe->getUserState('joom.update.checked'))) {
         $controller = JRequest::getCmd('controller');
         if ($this->_config->get('jg_checkupdate') && $controller && $controller != 'control') {
             $dated_extensions = JoomExtensions::checkUpdate();
             if (count($dated_extensions)) {
                 $this->_mainframe->enqueueMessage(JText::_('COM_JOOMGALLERY_ADMENU_SYSTEM_NOT_UPTODATE'), 'warning');
                 $this->_mainframe->setUserState('joom.update.checked', -1);
             } else {
                 $this->_mainframe->setUserState('joom.update.checked', 1);
             }
         }
     } else {
         if ($checked == -1) {
             $controller = JRequest::getCmd('controller');
             if ($controller && $controller != 'control') {
                 $this->_mainframe->enqueueMessage(JText::_('COM_JOOMGALLERY_ADMENU_SYSTEM_NOT_UPTODATE'), 'warning');
             }
         }
     }
 }
Пример #6
0
 /**
  * Displays the default upload form
  *
  * @param   boolean  $cachable   If true, the view output will be cached
  * @param   array    $urlparams  An array of safe url parameters and their variable types, for valid values see {@link JFilterInput::clean()}.
  * @return  void
  * @since   2.0
  */
 public function display($cachable = false, $urlparams = false)
 {
     // Access check
     if (!$this->_config->get('jg_disableunrequiredchecks') && !count(JoomHelper::getAuthorisedCategories('joom.upload'))) {
         $this->setRedirect(JRoute::_($this->_ambit->getRedirectUrl('categories'), false), JText::_('No categories found into which you are allowed to upload'), 'notice');
         return;
     }
     parent::display($cachable, $urlparams);
 }
Пример #7
0
 public function pay()
 {
     $user = JFactory::getUser();
     if ($user->guest) {
         die("Yêu cầu đăng nhập để mua");
     } else {
         $user_id = $user->id;
         $image_id = JRequest::getVar("id");
         $db = JFactory::getDBO();
         $db->setQuery("SELECT imgtitle, owner, catid, imgfilename FROM #__joomgallery WHERE id = " . $image_id);
         $image = $db->loadObject();
         $image_name = $image->imgtitle;
         $author = $image->owner;
         $price = JoomHelper::getAdditional($image_id, "price");
         $db->setQuery("INSERT INTO #__orders(user_id, image_id, image_name, author, price, buy_date) VALUES (" . $user_id . ", " . $image_id . ", '" . $image_name . "', " . $author . ", " . $price . ", NOW())");
         $db->query();
         $db->setQuery("UPDATE #__users SET balance = balance - " . (int) $price . " WHERE id = " . $user_id);
         $db->query();
         $catPath = JoomHelper::getCatPath($image->catid);
         $catPath1 = str_replace("/", DIRECTORY_SEPARATOR, $catPath);
         $path = JPATH_ROOT . DIRECTORY_SEPARATOR . 'images' . DIRECTORY_SEPARATOR . 'joomgallery' . DIRECTORY_SEPARATOR . 'originals' . DIRECTORY_SEPARATOR . $catPath1 . $image->imgfilename;
         $owner = JFactory::getUser($author);
         $app = JFactory::getApplication();
         $mailfrom = $app->get('mailfrom');
         $fromname = $app->get('fromname');
         $sitename = $app->get('sitename');
         $body = "Xin chào " . $owner->name . "<br/><br/>\n\t\t\tĐây là hình mà bạn đã mua từ Khoảnh khắc Việt Nam:<br/>\n\t\t\t- Tên: " . $image_name . "<br/>\n\t\t\t- Tác giả: " . $owner->name . "<br/>\n\t\t\t- Giá: " . number_format($price, 0, ',', '.') . "<br/><br/>\n\t\t\tKhoảnh khắc Việt Nam\n\t\t\t";
         $mail = JFactory::getMailer();
         $mail->addRecipient($user->email);
         $mail->addCC($owner->email);
         $mail->setSender(array($mailfrom, $fromname));
         $mail->setSubject($sitename . ': ' . $image_name);
         $mail->setBody($body);
         $mail->IsHTML(true);
         $mail->AddAttachment($path, $image->imgfilename);
         $sent = $mail->Send();
         //Push notification to android device
         $db->setQuery("SELECT gcm_id FROM #__users_gsm WHERE user_id = " . $author . " AND login_state = 1");
         $gcms = $db->loadColumn();
         foreach ($gcms as $gcm) {
             // prep the bundle
             $msg = array('message' => 'test', 'user_id' => $user_id, 'author' => $author);
             $fields = array('registration_ids' => $gcm, 'data' => $msg);
             $headers = array('Authorization: key=AIzaSyA0r0rtbBIUXi2uU6oqRZ5TSbkeBGWYje8', 'Content-Type: application/json');
             $ch = curl_init();
             curl_setopt($ch, CURLOPT_URL, 'https://android.googleapis.com/gcm/send');
             curl_setopt($ch, CURLOPT_POST, true);
             curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
             curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
             curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
             curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($fields));
             $result = curl_exec($ch);
             curl_close($ch);
         }
         $this->setRedirect(JRoute::_('index.php?option=com_recharge&view=cart&layout=success'));
     }
 }
Пример #8
0
 /**
  * HTML view display method
  *
  * @access  public
  * @param   string  $tpl  The name of the template file to parse
  * @return  void
  * @since   1.5.5
  */
 function display($tpl = null)
 {
     $params = $this->_mainframe->getParams();
     // Breadcrumbs
     if ($this->_config->get('jg_completebreadcrumbs')) {
         $breadcrumbs = $this->_mainframe->getPathway();
         $breadcrumbs->addItem(JText::_('COM_JOOMGALLERY_DOWNLOADZIP_DOWNLOAD'));
     }
     // Header and footer
     JoomHelper::prepareParams($params);
     $pathway = JText::_('COM_JOOMGALLERY_DOWNLOADZIP_DOWNLOAD');
     $backtarget = JRoute::_('index.php?view=favourites');
     //see above
     $backtext = JText::_('COM_JOOMGALLERY_DOWNLOADZIP_BACK_TO_FAVOURITES');
     // Get number of images and hits in gallery
     $numbers = JoomHelper::getNumberOfImgHits();
     // Load modules at position 'top'
     $modules['top'] = JoomHelper::getRenderedModules('top');
     if (count($modules['top'])) {
         $params->set('show_top_modules', 1);
     }
     // Load modules at position 'btm'
     $modules['btm'] = JoomHelper::getRenderedModules('btm');
     if (count($modules['btm'])) {
         $params->set('show_btm_modules', 1);
     }
     $zipname = $this->_mainframe->getUserState('joom.favourites.zipname');
     if (!$zipname || !file_exists(JPath::clean(JPATH_ROOT . '/' . $zipname))) {
         $this->_mainframe->redirect(JRoute::_('index.php?view=favourites', false), JText::_('COM_JOOMGALLERY_DOWNLOADZIP_ZIPFILE_NOT_FOUND'), 'error');
     }
     $zipsize = filesize($zipname);
     if ($zipsize < 1000000) {
         $zipsize = round($zipsize, -3) / 1000;
         $zipsize_string = JText::sprintf('COM_JOOMGALLERY_FAVOURITES_ZIP_SIZEKB', $zipsize);
     } else {
         $zipsize = round($zipsize, -6) / 1000000;
         $zipsize_string = JText::sprintf('COM_JOOMGALLERY_FAVOURITES_ZIP_SIZEMB', $zipsize);
     }
     $this->assignRef('params', $params);
     $this->assignRef('zipname', $zipname);
     $this->assignRef('zipsize', $zipsize_string);
     $this->assignRef('pathway', $pathway);
     $this->assignRef('modules', $modules);
     $this->assignRef('backtarget', $backtarget);
     $this->assignRef('backtext', $backtext);
     $this->assignRef('numberofpics', $numbers[0]);
     $this->assignRef('numberofhits', $numbers[1]);
     parent::display($tpl);
 }
Пример #9
0
 protected function addToolbar()
 {
     // Get the results for each action
     $canDo = JoomHelper::getActions();
     JToolBarHelper::title(JText::_('COM_JOOMGALLERY_IMGMAN_IMAGE_MANAGER'), 'images');
     if (($this->_config->get('jg_disableunrequiredchecks') || $canDo->get('joom.upload') || count(JoomHelper::getAuthorisedCategories('joom.upload'))) && $this->pagination->total) {
         JToolbarHelper::addNew('new');
     }
     if (($canDo->get('core.edit') || $canDo->get('core.edit.own')) && $this->pagination->total) {
         JToolbarHelper::editList();
         JToolbarHelper::custom('edit', 'checkbox-partial', 'checkbox-partial', 'JTOOLBAR_BATCH');
         JToolbarHelper::custom('showmove', 'move.png', 'move.png', 'COM_JOOMGALLERY_COMMON_TOOLBAR_MOVE');
         JToolbarHelper::custom('recreate', 'refresh.png', 'refresh.png', 'COM_JOOMGALLERY_COMMON_TOOLBAR_RECREATE');
         JToolbarHelper::divider();
     }
     if ($canDo->get('core.edit.state') && $this->pagination->total) {
         JToolbarHelper::publishList('publish', JText::_('COM_JOOMGALLERY_COMMON_PUBLISH'));
         JToolbarHelper::unpublishList('unpublish', JText::_('COM_JOOMGALLERY_COMMON_UNPUBLISH'));
         JToolbarHelper::custom('approve', 'upload.png', 'upload_f2.png', 'COM_JOOMGALLERY_IMGMAN_TOOLBAR_APPROVE');
         JToolbarHelper::divider();
     }
     //if($canDo->get('core.delete'))
     //{
     JToolbarHelper::deleteList('', 'remove');
     //}
     // Add filter by state
     $options = array(JHtml::_('select.option', 0, JText::_('JOPTION_SELECT_PUBLISHED')), JHtml::_('select.option', 1, JText::_('COM_JOOMGALLERY_COMMON_OPTION_PUBLISHED_ONLY')), JHtml::_('select.option', 2, JText::_('COM_JOOMGALLERY_COMMON_OPTION_NOT_PUBLISHED_ONLY')), JHtml::_('select.option', 3, JText::_('COM_JOOMGALLERY_COMMON_OPTION_APPROVED_ONLY')), JHtml::_('select.option', 4, JText::_('COM_JOOMGALLERY_COMMON_OPTION_NOT_APPROVED_ONLY')), JHtml::_('select.option', 5, JText::_('COM_JOOMGALLERY_COMMON_OPTION_REJECTED_ONLY')));
     JHtmlSidebar::addFilter(JText::_('JOPTION_SELECT_PUBLISHED'), 'filter_state', JHtml::_('select.options', $options, 'value', 'text', $this->state->get('filter.state'), false), true);
     // Add filter by category
     if (!$this->_config->get('jg_ajaxcategoryselection')) {
         // TODO must find a better way instead of removing the tags, what about switching to AJAX boxes -> doesn't work
         $options = preg_replace('~^<select[^>]*+>\\s*~', '', trim(JHtml::_('joomselect.categorylist', $this->state->get('filter.category'), 'filter_category', 'class="inputbox" onchange="document.id(\'adminForm\').submit()"', null, '- ', 'filter')));
         $options = preg_replace('~\\s*</select>$~', '', $options);
         JHtmlSidebar::addFilter(JText::_('COM_JOOMGALLERY_COMMON_ALL'), 'filter_category', $options, true);
     }
     // Add filter by access
     JHtmlSidebar::addFilter(JText::_('JOPTION_SELECT_ACCESS'), 'filter_access', JHtml::_('select.options', JHtml::_('access.assetgroups'), 'value', 'text', $this->state->get('filter.access')));
     // Add filter by owner
     $html = JHtml::_('joomselect.userspopup', 'filter_owner', $this->state->get('filter.owner'), 'document.id(\'adminForm\').submit();');
     if (strpos($html, '<select') !== false) {
         // TODO must find a better way instead of removing the tags
         $options = preg_replace('~^<select[^>]*+>\\s*~', '', trim($html));
         $options = preg_replace('~\\s*</select>$~', '', $options);
         JHtmlSidebar::addFilter(JText::_('COM_JOOMGALLERY_COMMON_OPTION_SELECT_OWNER'), 'filter_owner', $options, true);
     }
     // Add filter by type
     $options = array(JHTML::_('select.option', 0, JText::_('COM_JOOMGALLERY_COMMON_OPTION_SELECT_TYPE')), JHTML::_('select.option', 1, JText::_('COM_JOOMGALLERY_COMMON_OPTION_USER_UPLOADED_ONLY')), JHTML::_('select.option', 2, JText::_('COM_JOOMGALLERY_COMMON_OPTION_ADMIN_UPLOADED_ONLY')));
     JHtmlSidebar::addFilter(JText::_('COM_JOOMGALLERY_COMMON_OPTION_SELECT_TYPE'), 'filter_type', JHtml::_('select.options', $options, 'value', 'text', $this->state->get('filter.type'), false), true);
 }
Пример #10
0
 /**
  * Retrieves the comments data
  *
  * @return  array   Array of objects containing the comments data from the database
  * @since   1.5.5
  */
 public function getComments()
 {
     // Lets load the data if it doesn't already exist
     if (empty($this->_comments)) {
         $query = $this->_buildQuery();
         $this->_comments = $this->_getList($query, $this->getStart(), $this->getState('list.limit'));
         foreach ($this->_comments as $key => $comment) {
             if ($comment->userid > 0) {
                 $this->_comments[$key]->cmtname = JHTML::_('joomgallery.displayname', $comment->userid);
             }
             $this->_comments[$key]->cmttext = JoomHelper::processText($comment->cmttext);
         }
     }
     return $this->_comments;
 }
Пример #11
0
 /**
  * HTML view display method
  *
  * @param   string  $tpl  The name of the template file to parse
  * @return  void
  * @since   1.5.5
  */
 public function display($tpl = null)
 {
     $this->params = JComponentHelper::getParams('com_joomgallery');
     JToolBarHelper::title(JText::_('COM_JOOMGALLERY_ADMENU_ADMINMENU'), 'joomgallery');
     $this->canDo = JoomHelper::getActions();
     if ($this->canDo->get('core.admin')) {
         JToolBarHelper::preferences('com_joomgallery');
         JToolBarHelper::spacer();
     }
     // Get data from the model
     $model = $this->getModel();
     $this->state = $model->getState();
     $this->items = $model->getData();
     $this->popularImages = $model->getImages('a.hits desc', true, 5, 'a.hits > 0');
     $this->notApprovedImages = $model->getImages('a.imgdate desc', false, 5);
     $this->notApprovedComments = $model->getComments('c.cmtdate desc', false, 5);
     $this->topDownloads = $model->getImages('a.downloads desc', true, 5, 'a.downloads > 0');
     $lang = JFactory::getLanguage();
     $this->modules =& JModuleHelper::getModules('joom_cpanel');
     if ($this->_config->get('jg_checkupdate')) {
         $available_extensions = JoomExtensions::getAvailableExtensions();
         $this->params->set('url_fopen_allowed', @ini_get('allow_url_fopen'));
         $this->params->set('curl_loaded', extension_loaded('curl'));
         // If there weren't any available extensions found
         // loading the RSS feed wasn't successful
         if (count($available_extensions)) {
             $installed_extensions = JoomExtensions::getInstalledExtensions();
             $this->assignRef('available_extensions', $available_extensions);
             $this->assignRef('installed_extensions', $installed_extensions);
             $this->params->set('show_available_extensions', 1);
             $dated_extensions = JoomExtensions::checkUpdate();
             if (count($dated_extensions)) {
                 $this->assignRef('dated_extensions', $dated_extensions);
                 $this->params->set('dated_extensions', 1);
             } else {
                 $this->params->set('dated_extensions', 0);
                 $this->params->set('show_update_info_text', 1);
             }
         }
     } else {
         $this->params->set('dated_extensions', 0);
     }
     parent::display($tpl);
 }
Пример #12
0
 /**
  * Returns the query for loading the menu entries
  *
  * @return  object  The query to be used to retrieve the menu entries from the database
  * @since   1.5.5
  */
 protected function _buildQuery()
 {
     $query = $this->_db->getQuery(true)->select('*')->from('#__menu')->where('parent_id != 1')->where("menutype = 'main'");
     $where[] = "link LIKE 'index.php?option=com_joomgallery&controller=images%'";
     $where[] = "link LIKE 'index.php?option=com_joomgallery&controller=categories%'";
     $where[] = "link LIKE 'index.php?option=com_joomgallery&controller=comments%'";
     $where[] = "link LIKE 'index.php?option=com_joomgallery&controller=migration%'";
     $where[] = "link LIKE 'index.php?option=com_joomgallery&controller=help%'";
     $canDo = JoomHelper::getActions();
     if ($this->_config->get('jg_disableunrequiredchecks') || $canDo->get('joom.upload') || count(JoomHelper::getAuthorisedCategories('joom.upload'))) {
         $where[] = "link LIKE 'index.php?option=com_joomgallery&controller=upload%'";
         $where[] = "link LIKE 'index.php?option=com_joomgallery&controller=ajaxupload%'";
         $where[] = "link LIKE 'index.php?option=com_joomgallery&controller=batchupload%'";
         $where[] = "link LIKE 'index.php?option=com_joomgallery&controller=ftpupload%'";
         $where[] = "link LIKE 'index.php?option=com_joomgallery&controller=jupload%'";
     }
     if ($canDo->get('core.admin')) {
         $where[] = "link LIKE 'index.php?option=com_joomgallery&controller=config%'";
         $where[] = "link LIKE 'index.php?option=com_joomgallery&controller=cssedit%'";
         $where[] = "link LIKE 'index.php?option=com_joomgallery&controller=maintenance%'";
     }
     $query->where('(' . implode(' OR ', $where) . ')')->order('id');
     return $query;
 }
Пример #13
0
        echo $this->image->id;
        ?>
" class="btn btn-warning btn-blue btn-big btn-sm strong-me text-uppercase">Mua tác phẩm</a>
						<?php 
    }
}
?>
					</div>
				</div>
				
				<div class="m10t clearfix">
					<a class="pull-left btn-action active">
						<div class="icon-action pull-left">
							<span class="glyphicon glyphicon-thumbs-up" aria-hidden="true"></span>
							<span class="text-nowrap des"><?php 
echo JoomHelper::getAdditional($this->image->id, "like");
?>
</span>
						</div>
					</a>
					<?php 
if (!$user->guest) {
    ?>
					<?php 
    if (!$isOwner) {
        ?>
					<a href="<?php 
        echo $fav_link;
        ?>
" class="pull-left btn-action <?php 
        if ($favourite) {
Пример #14
0
 /**
  * Method for retreiving categories allowed for a certain action
  *
  * @param   string  $action       Optional action to check the categories against
  * @param   int     $filter       Optional category ID which will be filtered out together with its sub-categories
  * @param   string  $searchstring Optional string for searching specific categories (name of category will be used for searching)
  * @param   int     $limitstart   Optional limit start parameter for database query
  * @return  array   A result set with an array of categories and indicator whether there are more results left on success, Exception object otherwise
  * @since   2.1
  */
 public function getAllowedCategories($action = null, $filter = null, $searchstring = '', $limitstart = 0, $current = 0)
 {
     JHtml::addIncludePath(JPATH_COMPONENT_ADMINISTRATOR . '/helpers/html');
     // Initialise variables
     $results = array('results' => array());
     $action2 = false;
     if ($action == 'joom.upload') {
         $action2 = 'joom.upload.inown';
     }
     if ($action == 'core.create') {
         $action2 = 'joom.create.inown';
     }
     if ($action == 'core.edit') {
         $action2 = 'core.edit.own';
     }
     $filtered = array();
     if ($filter) {
         $filtered = JoomHelper::getAllSubCategories($filter, true, true, true, false);
     }
     try {
         // Create the search query
         $query = $this->_db->getQuery(true)->select('cid, name, owner')->from($this->_db->qn(_JOOM_TABLE_CATEGORIES))->where('cid != 1')->order('lft');
         if ($searchstring) {
             $searchstring = $this->_db->q('%' . $searchstring . '%');
             $query->where('name LIKE ' . $searchstring);
         }
         // Load all results
         $this->_db->setQuery($query);
         $result = $this->_db->loadObjectList();
         // Check the results starting from limit start
         $count = count($result);
         $j = 0;
         if (!$limitstart && ($current == 0 || !$action || $action == 'core.create' && $this->_user->authorise($action, _JOOM_OPTION))) {
             $none = new stdclass();
             $none->cid = 0;
             $none->name = JText::_('COM_JOOMGALLERY_COMMON_NO_CATEGORY');
             $none->path = '';
             $none->none = true;
             $results['results'][$j] = $none;
             $j++;
         }
         for ($i = $limitstart; $i < $count; $i++) {
             if (in_array($result[$i]->cid, $filtered)) {
                 continue;
             }
             if ($result[$i]->cid != $current && $action && !$this->_user->authorise($action, _JOOM_OPTION . '.category.' . $result[$i]->cid) && (!$action2 || !$result[$i]->owner || $result[$i]->owner != $this->_user->get('id') || !$this->_user->authorise($action2, _JOOM_OPTION . '.category.' . $result[$i]->cid))) {
                 continue;
             }
             // Stop as soon as we have 10 results.
             // This check is done not earlier than at this point because
             // we want to know whether there is at least one more result.
             if ($j == 10) {
                 // If 'more' is set a 'More Results' link will be displayed in the view
                 $results['more'] = $i;
                 break;
             }
             $results['results'][$j] = $result[$i];
             $results['results'][$j]->path = JHtml::_('joomgallery.categorypath', $result[$i]->cid, false, ' &raquo; ', false, false, true);
             $j++;
         }
     } catch (JDatabaseException $e) {
         return $e;
     }
     return $results;
 }
Пример #15
0
 /**
  * Overloaded store function
  *
  * @param   boolean   $updateNulls  True to update null values as well.
  * @return  boolean   True on success, false otherwise
  * @since   1.5.7
  */
 public function store($updateNulls = false)
 {
     if (!parent::store($updateNulls)) {
         return false;
     }
     // If there aren't any sub categories there isn't anything to do anymore
     $cats = JoomHelper::getAllSubCategories($this->cid, false, true, true, false);
     if (!count($cats)) {
         return true;
     }
     // Set state of all sub-categories
     // according to the settings of this category
     $query = $this->_db->getQuery(true)->update(_JOOM_TABLE_CATEGORIES)->set('published = ' . (int) $this->published)->where('cid IN (' . implode(',', $cats) . ')');
     $this->_db->setQuery($query);
     if (!$this->_db->query()) {
         $this->setError($this->_db->getErrorMsg());
         return false;
     }
     // Set 'in_hidden' of all sub-categories
     // according to hidden state of this category
     // (but only if there was a change of this state)
     if ($this->_hidden != $this->hidden && !$this->in_hidden || $this->_in_hidden != $this->in_hidden) {
         if ($this->hidden == 0 && $this->in_hidden == 0) {
             // If 'hidden' is 0 only the categories
             // which aren't set to hidden must be changed
             // because they form a hidden group themselves
             // anyway and have to stay hidden
             $cats = JoomHelper::getAllSubCategories($this->cid, false, true, true, true);
         }
         $query = $this->_db->getQuery(true)->update(_JOOM_TABLE_CATEGORIES)->set('in_hidden = ' . (int) ($this->hidden || $this->in_hidden))->where('cid IN (' . implode(',', $cats) . ')');
         $this->_db->setQuery($query);
         if (!$this->_db->query()) {
             $this->setError($this->_db->getErrorMsg());
             return false;
         }
     }
     return true;
 }
Пример #16
0
 /**
  * HTML view display method
  *
  * @param   string  $tpl  The name of the template file to parse
  * @return  void
  * @since   1.5.5
  */
 public function display($tpl = null)
 {
     $params = $this->_mainframe->getParams();
     // Header and footer
     JoomHelper::prepareParams($params);
     $backtarget = JRoute::_('index.php?view=gallery');
     //see above
     $backtext = JText::_('COM_JOOMGALLERY_COMMON_BACK_TO_GALLERY');
     // Get number of images and hits in gallery
     $numbers = JoomHelper::getNumberOfImgHits();
     // Load modules at position 'top'
     $modules['top'] = JoomHelper::getRenderedModules('top');
     if (count($modules['top'])) {
         $params->set('show_top_modules', 1);
     }
     // Load modules at position 'btm'
     $modules['btm'] = JoomHelper::getRenderedModules('btm');
     if (count($modules['btm'])) {
         $params->set('show_btm_modules', 1);
     }
     $type = JRequest::getCmd('type');
     switch ($type) {
         case 'lastcommented':
             $rows = $this->get('LastCommented');
             $title = JText::sprintf('COM_JOOMGALLERY_TOPLIST_LAST_COMMENTED_IMAGE', $this->_config->get('jg_toplist'));
             $pathway = $title;
             break;
         case 'lastadded':
             $rows = $this->get('LastAdded');
             $title = JText::sprintf('COM_JOOMGALLERY_TOPLIST_LAST_ADDED_IMAGE', $this->_config->get('jg_toplist'));
             $pathway = $title;
             break;
         case 'toprated':
             $rows = $this->get('TopRated');
             $title = JText::sprintf('COM_JOOMGALLERY_TOPLIST_BEST_RATED_IMAGE', $this->_config->get('jg_toplist'));
             $pathway = $title;
             break;
         default:
             $rows = $this->get('MostViewed');
             $title = JText::sprintf('COM_JOOMGALLERY_TOPLIST_MOST_VIEWED_IMAGE', $this->_config->get('jg_toplist'));
             $pathway = $title;
             break;
     }
     // Check whether this is the active menu item. This is a
     // special case in addition to code in constructor of parent class
     // because here we have to check the toplist type, too.
     if ($type == 'lastcommented' || $type == 'lastadded' || $type == 'toprated') {
         $active = $this->_mainframe->getMenu()->getActive();
         if (!$active || strpos($active->link, '&type=' . $type) === false) {
             // Get the default layout from the configuration
             if ($layout = $this->_config->get('jg_alternative_layout')) {
                 $this->setLayout($layout);
             }
         }
     }
     // Breadcrumbs
     if ($this->_config->get('jg_completebreadcrumbs')) {
         $breadcrumbs = $this->_mainframe->getPathway();
         $breadcrumbs->addItem($title);
     }
     // Check whether the (comments) data rows where delivered by a plugin
     if (isset($rows[0]->delivered_by_plugin) && $rows[0]->delivered_by_plugin) {
         $params->set('delivered_by_plugin', 1);
     }
     foreach ($rows as $key => $row) {
         $rows[$key]->link = JHTML::_('joomgallery.openimage', $this->_config->get('jg_detailpic_open'), $row);
         $cropx = null;
         $cropy = null;
         $croppos = null;
         if ($this->_config->get('jg_dyncrop')) {
             $cropx = $this->_config->get('jg_dyncropwidth');
             $cropy = $this->_config->get('jg_dyncropheight');
             $croppos = $this->_config->get('jg_dyncropposition');
         }
         $rows[$key]->thumb_src = $this->_ambit->getImg('thumb_url', $row, null, 0, true, $cropx, $cropy, $croppos);
         // Set the title attribute in a tag with title and/or description of image
         // if a box is activated
         if (!is_numeric($this->_config->get('jg_detailpic_open')) || $this->_config->get('jg_detailpic_open') > 1) {
             $rows[$key]->atagtitle = JHTML::_('joomgallery.getTitleforATag', $row);
         } else {
             // Set the imgtitle by default
             $rows[$key]->atagtitle = 'title="' . $row->imgtitle . '"';
         }
         if ($this->_config->get('jg_showauthor')) {
             if ($row->imgauthor) {
                 $rows[$key]->authorowner = $row->imgauthor;
             } else {
                 if ($this->_config->get('jg_showowner')) {
                     $rows[$key]->authorowner = JHTML::_('joomgallery.displayname', $row->owner);
                 } else {
                     $rows[$key]->authorowner = JText::_('COM_JOOMGALLERY_COMMON_NO_DATA');
                 }
             }
         }
         if (!$params->get('delivered_by_plugin')) {
             if ($type == 'lastcommented' && $this->_config->get('jg_showthiscomment')) {
                 if ($row->userid) {
                     $rows[$key]->cmtname = JHTML::_('joomgallery.displayname', $row->userid, false);
                 }
                 $cmttext = $row->cmttext;
                 $cmttext = JoomHelper::processText($cmttext);
                 if ($this->_config->get('jg_bbcodesupport')) {
                     $cmttext = JHTML::_('joomgallery.bbdecode', $cmttext);
                 }
                 if ($this->_config->get('jg_smiliesupport')) {
                     $smileys = JoomHelper::getSmileys();
                     foreach ($smileys as $i => $sm) {
                         $cmttext = str_replace($i, '<img src="' . $sm . '" border="0" alt="' . $i . '" title="' . $i . '" />', $cmttext);
                     }
                 }
                 $cmttext = stripslashes($cmttext);
                 $rows[$key]->processed_cmttext = $cmttext;
             }
         }
         // Show editor links for that image
         $rows[$key]->show_edit_icon = false;
         $rows[$key]->show_delete_icon = false;
         if ($this->_config->get('jg_showtoplisteditorlinks') == 1 && $this->_config->get('jg_userspace') == 1) {
             if ($this->_user->authorise('core.edit', _JOOM_OPTION . '.image.' . $rows[$key]->id) || $this->_user->authorise('core.edit.own', _JOOM_OPTION . '.image.' . $rows[$key]->id) && $rows[$key]->owner && $rows[$key]->owner == $this->_user->get('id')) {
                 $rows[$key]->show_edit_icon = true;
             }
             if ($this->_user->authorise('core.delete', _JOOM_OPTION . '.image.' . $rows[$key]->id)) {
                 $rows[$key]->show_delete_icon = true;
             }
         }
     }
     // Download Icon
     if ($this->_config->get('jg_download') && $this->_config->get('jg_showtoplistdownload')) {
         if ($this->_user->get('id') || $this->_config->get('jg_download_unreg')) {
             $params->set('show_download_icon', 1);
         } else {
             if ($this->_config->get('jg_download_hint')) {
                 $params->set('show_download_icon', -1);
             }
         }
     }
     // Favourites icon
     if (!$params->get('disable_global_info') && $this->_config->get('jg_favourites') && $this->_config->get('jg_showtoplistfavourite')) {
         if ($this->_user->get('id') || $this->_config->get('jg_usefavouritesforpubliczip') == 1 && !$this->_user->get('id')) {
             if ($this->_config->get('jg_usefavouritesforzip') || $this->_config->get('jg_usefavouritesforpubliczip') && !$this->_user->get('id')) {
                 $params->set('show_favourites_icon', 2);
             } else {
                 $params->set('show_favourites_icon', 1);
             }
         } else {
             if ($this->_config->get('jg_favouritesshownotauth') == 1) {
                 if ($this->_config->get('jg_usefavouritesforzip')) {
                     $params->set('show_favourites_icon', -2);
                 } else {
                     $params->set('show_favourites_icon', -1);
                 }
             }
         }
     }
     // Report icon
     if ($this->_config->get('jg_report_images') && $this->_config->get('jg_toplist_report_images')) {
         if ($this->_user->get('id') || $this->_config->get('jg_report_unreg')) {
             $params->set('show_report_icon', 1);
             JHTML::_('behavior.modal');
         } else {
             if ($this->_config->get('jg_report_hint')) {
                 $params->set('show_report_icon', -1);
             }
         }
     }
     // Set redirect url used in editor links to redirect back to favourites view after edit/delete
     $redirect = '&redirect=' . base64_encode(JFactory::getURI()->toString());
     $this->assignRef('params', $params);
     $this->assignRef('rows', $rows);
     $this->assignRef('title', $title);
     $this->assignRef('type', $type);
     $this->assignRef('pathway', $pathway);
     $this->assignRef('modules', $modules);
     $this->assignRef('backtarget', $backtarget);
     $this->assignRef('backtext', $backtext);
     $this->assignRef('numberofpics', $numbers[0]);
     $this->assignRef('numberofhits', $numbers[1]);
     $this->assignRef('redirect', $redirect);
     parent::display($tpl);
 }
Пример #17
0
 /**
  * HTML view display method
  *
  * @access  public
  * @param   string  $tpl  The name of the template file to parse
  * @return  void
  * @since   1.5.5
  */
 function display($tpl = null)
 {
     JForm::addFormPath(JPATH_COMPONENT_ADMINISTRATOR . '/models/forms');
     // Initialise some variables
     $this->page = 1;
     $this->e_name = $this->_mainframe->getUserStateFromRequest('joom.mini.e_name', 'e_name', 'text', 'string');
     $this->images_fields = array('type', 'position', 'linked', 'linked_type', 'alttext', 'class', 'linkedtext');
     $this->extended = $this->_mainframe->getUserStateFromRequest('joom.mini.extended', 'extended', 1, 'int');
     $this->upload_catid = $this->_mainframe->input->getInt('upload_category');
     $this->prefix = $this->_mainframe->getUserStateFromRequest('joom.mini.prefix', 'prefix', 'joom', 'cmd');
     // Decide which tabs have to be displayed
     $this->tabs = array('images' => true);
     if ($this->extended > 0) {
         $this->tabs = array('images' => true, 'categories' => true, 'upload' => true, 'createcategory' => true);
     }
     if ($this->upload_catid) {
         $this->tabs = array('upload' => true);
     }
     // Images tab
     if (isset($this->tabs['images'])) {
         // Also display the options for inserting images into articles
         if ($this->extended > 0) {
             $plugin = JPluginHelper::getPlugin('content', 'joomplu');
             if (!$this->upload_catid && !count($plugin)) {
                 $this->_mainframe->enqueueMessage(JText::_('COM_JOOMGALLERY_MINI_MSG_NOT_INSTALLED_OR_ACTIVATED'), 'notice');
                 $params = '';
             } else {
                 $params = $plugin->params;
             }
             // Load plugin parameters
             $this->params = new JRegistry();
             $this->params->loadString($params);
             $this->images_form = JForm::getInstance(_JOOM_OPTION . '.mini.images', 'mini.images');
             $fields_default_values = array('type' => 'thumb', 'position' => '', 'linked' => 0, 'linked_type' => 'orig', 'alttext' => '', 'class' => '', 'linkedtext' => '');
             foreach ($this->images_fields as $field) {
                 $this->images_form->setFieldAttribute($field, 'default', $this->params->get('default_' . $field, $fields_default_values[$field]));
             }
             // Hidden images
             $this->_mainframe->setUserState('joom.mini.showhidden', $this->params->get('showhidden'));
         }
         // Pagination
         $this->total = $this->get('TotalImages');
         // Calculation of the number of total pages
         $limit = $this->_mainframe->getUserStateFromRequest('joom.mini.limit', 'limit', 30, 'int');
         if (!$limit) {
             $this->totalpages = 1;
         } else {
             $this->totalpages = floor($this->total / $limit);
             $offcut = $this->total % $limit;
             if ($offcut > 0) {
                 $this->totalpages++;
             }
         }
         $totalimages = $this->total;
         $this->total = number_format($this->total, 0, JText::_('COM_JOOMGALLERY_COMMON_DECIMAL_SEPARATOR'), JText::_('COM_JOOMGALLERY_COMMON_THOUSANDS_SEPARATOR'));
         // Get the current page
         $this->page = JRequest::getInt('page', 0);
         if ($this->page > $this->totalpages) {
             $this->page = $this->totalpages;
         }
         if ($this->page < 1) {
             $this->page = 1;
         }
         // Limitstart
         $limitstart = ($this->page - 1) * $limit;
         JRequest::setVar('limitstart', $limitstart);
         if ($this->total <= $limit) {
             $limitstart = 0;
             JRequest::setVar('limitstart', $limitstart);
         }
         JRequest::setVar('limit', $limit);
         require_once JPATH_COMPONENT_ADMINISTRATOR . '/helpers/pagination.php';
         $onclick = 'javascript:ajaxRequest(\'index.php?option=' . _JOOM_OPTION . '&view=mini&format=json\', %u); return false;';
         $this->pagination = new JoomPagination($totalimages, $limitstart, $limit, '', null, $onclick);
         $this->images = $this->get('Images');
         $this->catid = $this->_mainframe->getUserStateFromRequest('joom.mini.catid', 'catid', 0, 'int');
         foreach ($this->images as $key => $image) {
             $image->thumb_src = null;
             $thumb = $this->_ambit->getImg('thumb_path', $image);
             if ($image->imgthumbname && is_file($thumb)) {
                 $imginfo = getimagesize($thumb);
                 $image->thumb_src = $this->_ambit->getImg('thumb_url', $image);
                 $image->thumb_width = $imginfo[0];
                 $image->thumb_height = $imginfo[1];
                 $this->image = $image;
                 $overlib = $this->loadTemplate('overlib');
                 $image->overlib = str_replace(array("\r\n", "\r", "\n"), '', htmlspecialchars($overlib, ENT_QUOTES, 'UTF-8'));
             }
             $this->images[$key] = $image;
         }
         // Limit Box
         $limits = array();
         // Create the option list
         for ($i = 5; $i <= 30; $i += 5) {
             $limits[] = JHtml::_('select.option', $i);
         }
         $limits[] = JHtml::_('select.option', '50');
         $limits[] = JHtml::_('select.option', '100');
         $limits[] = JHtml::_('select.option', '0', JText::_('JALL'));
         $url = 'index.php?option=' . _JOOM_OPTION . '&view=mini&format=json';
         $this->lists = array();
         $this->lists['limit'] = JHtml::_('select.genericlist', $limits, 'limit', 'class="inputbox input-mini" size="1" onchange="javascript:ajaxRequest(\'' . $url . '\', 0, \'limit=\' + this[this.selectedIndex].value)"', 'value', 'text', $limit);
         $this->lists['image_categories'] = JHtml::_('joomselect.categorylist', $this->catid, 'catid', 'onchange="javascript:ajaxRequest(\'' . $url . '\', 0, \'catid=\' + document.id(\'catid\').value)"', null, '- ', 'filter');
         $this->object = $this->_mainframe->getUserStateFromRequest('joom.mini.object', 'object', '', 'cmd');
         $this->search = $this->_mainframe->getUserStateFromRequest('joom.mini.search', 'search', '', 'string');
     }
     // Categories tab
     if (isset($this->tabs['categories'])) {
         $this->categories_form = JForm::getInstance(_JOOM_OPTION . '.mini.categories', 'mini.categories');
         $this->categories_form->setFieldAttribute('category_catid', 'onchange', str_replace('joom_', $this->prefix . '_', $this->categories_form->getFieldAttribute('category_catid', 'onchange')));
         $categories_fields = array('category_mode', 'category_limit', 'category_columns', 'category_ordering', 'category_linkedtext');
         foreach ($categories_fields as $field) {
             $this->categories_form->setFieldAttribute($field, 'default', $this->params->get('default_' . $field));
         }
     }
     // Upload tab
     if (isset($this->tabs['upload'])) {
         $this->upload_form = JForm::getInstance(_JOOM_OPTION . '.mini.upload', 'mini.upload');
         if ($this->upload_catid) {
             $this->upload_form->setFieldAttribute('catid', 'default', $this->upload_catid);
         }
         $this->fileSizeLimit = $this->_mainframe->isSite() ? $this->_config->get('jg_maxfilesize') : 0;
         $this->chunkSize = 0;
         $post_max_size = @ini_get('post_max_size');
         if (!empty($post_max_size)) {
             $post_max_size = JoomHelper::iniToBytes($post_max_size);
             $this->chunkSize = (int) min(500000, (int) (0.8 * $post_max_size));
         }
         $upload_max_filesize = @ini_get('upload_max_filesize');
         if (!empty($upload_max_filesize)) {
             $upload_max_filesize = JoomHelper::iniToBytes($upload_max_filesize);
             if ($this->fileSizeLimit <= 0 || $this->fileSizeLimit > $upload_max_filesize) {
                 $this->fileSizeLimit = $upload_max_filesize;
             }
         }
         $this->editFilename = $this->_mainframe->isSite() ? $this->_config->get('jg_useruseorigfilename') : $this->_config->get('jg_useorigfilename');
         $this->delete_original = $this->_mainframe->isSite() ? $this->_config->get('jg_delete_original_user') == 2 : $this->_config->get('jg_delete_original') == 2;
         JText::script('COM_JOOMGALLERY_MINI_TYPE');
         JText::script('COM_JOOMGALLERY_MINI_POSITION');
         JText::script('COM_JOOMGALLERY_MINI_ALTTEXT');
         JText::script('COM_JOOMGALLERY_COMMON_THUMBNAIL');
         JText::script('COM_JOOMGALLERY_MINI_DETAIL');
         JText::script('COM_JOOMGALLERY_MINI_ORIGINAL');
         JText::script('JNONE');
         JText::script('JGLOBAL_CENTER');
         JText::script('JGLOBAL_LEFT');
         JText::script('JGLOBAL_RIGHT');
     }
     // Create category tab
     if (isset($this->tabs['createcategory'])) {
         $this->category_form = JForm::getInstance(_JOOM_OPTION . '.mini.category', 'mini.category');
         JText::script('COM_JOOMGALLERY_MINI_PLEASE_ENTER_TEXT');
     }
     // The parameter object is necessary for the even if it
     // doesn't contain any data (this simplifies things)
     if (!isset($this->params)) {
         $this->params = new JRegistry();
         $this->params->loadString('');
     }
     // Set some default values before possibly modifying the view
     $this->upload_categories = null;
     $this->parent_categories = null;
     $this->upload_enabled = true;
     $this->createcat_enabled = true;
     // If we are in frontend modify the view by adding possibility to
     // change the category select boxes according to the plugin settings
     if (!$this->upload_catid && $this->_mainframe->isSite()) {
         $this->modifyView();
     }
     JText::script('JLIB_FORM_FIELD_INVALID');
     // Build the sorted message list
     $messages = $this->_mainframe->getMessageQueue();
     $this->messages = array();
     if (is_array($messages) && !empty($messages)) {
         foreach ($messages as $msg) {
             if (isset($msg['type']) && isset($msg['message'])) {
                 $this->messages[$msg['type']][] = $msg['message'];
             }
         }
     }
     parent::display($tpl);
 }
Пример #18
0
 /**
  * Prepares a slideshow to be ready to launch
  *
  * @param   string  $imgelement     html for thumbnail element representing category
  *                                  (for link adaption)
  * @param   string  $slideshowclass identifier for slideshow class for CSS
  * @param   string  $slideshowid    identifier for slideshow for CSS
  * @param   int     $catid          category id of slideshow images
  * @param   string  $catname        name of category
  * @param   object  $img_rows       array of image objects from database
  */
 protected function prepareSlideshow(&$imgelement, $slideshowclass, $slideshowid, $catid, $catname, $img_rows)
 {
     $doc = JFactory::getDocument();
     static $firstcall = true;
     $maxwidth = 0;
     $maxheight = 0;
     $number = 0;
     $script = '';
     $transition = 'fade';
     // Check, if we are in JoomGallery's detail view
     $viewIsJoomGalleryDetailView = false;
     $errorMessage = '';
     $option = JRequest::getVar('option', '', '', 'string');
     $view = JRequest::getVar('view', '', '', 'string');
     if ($option == 'com_joomgallery' && $view == 'detail') {
         $viewIsJoomGalleryDetailView = true;
         $errorMessage = addslashes(JText::_('MOD_JOOMCAT_ERRORMSG_SLD_NOT_AVAILABLE'));
     }
     if ($firstcall) {
         // Include javascripts
         JHtml::_('behavior.framework', true);
         $doc->addScript(JURI::base() . 'media/mod_joomcat/mod_joomcat.js');
         if (!$viewIsJoomGalleryDetailView) {
             $doc->addStyleSheet($this->getAmbit()->getScript('smoothgallery/css/jd.gallery.css'));
             $doc->addScript($this->getAmbit()->getScript('smoothgallery/scripts/jd.gallery.js'));
             // No include if standard effects 'fade/crossfade/fadebg' chosen
             switch ($this->getConfig('sldtransition')) {
                 case 0:
                     $transition = 'fade';
                     break;
                 case 1:
                     $transition = 'fadeslideleft';
                     $doc->addScript($this->getAmbit()->getScript('smoothgallery/scripts/jd.gallery.transitions.js'));
                     break;
                 case 2:
                     $transition = 'crossfade';
                     break;
                 case 3:
                     $transition = 'continuoushorizontal';
                     $doc->addScript($this->getAmbit()->getScript('smoothgallery/scripts/jd.gallery.transitions.js'));
                     break;
                 case 4:
                     $transition = 'continuousvertical';
                     $doc->addScript($this->getAmbit()->getScript('smoothgallery/scripts/jd.gallery.transitions.js'));
                     break;
                 case 5:
                     $transition = 'fadebg';
                     break;
                 default:
                     $transition = 'fade';
                     break;
             }
         }
         $script = "    function catImage(image, thumbnail, linkTitle, link, title, description, number)\n" . "    {\n" . "      this.image = image;\n" . "      this.thumbnail = thumbnail;\n" . "      this.linkTitle = linkTitle;\n" . "      this.link =link;\n" . "      this.title = title;\n" . "      this.description = description;\n" . "      this.transition = '{$transition}';\n" . "      this.number = number;\n" . "    }\n";
         $firstcall = false;
     }
     $script .= "    var catImages" . $this->getConfig('module_id') . "_{$catid} = new Array();\n";
     // Get the router
     $router = JFactory::getApplication()->getRouter();
     // Get current values of vars 'option' and 'Itemid'
     $option = $router->getVar('option');
     $Itemid = $router->getVar('Itemid');
     // Set vars 'option' and 'Itemid'
     $router->setVar('option', 'com_joomgallery');
     $router->setVar('Itemid', $this->getJoomId(false));
     $script .= "    /* <![CDATA[ */\n";
     foreach ($img_rows as $row) {
         // Description
         if ($row->imgtext != '') {
             $description = JoomHelper::fixForJS($row->imgtext);
             // $description = preg_replace('/[\n\t\r]*/', '', htmlentities($row->imgtext, ENT_QUOTES, 'UTF-8'));
         } else {
             $description = '&nbsp;';
         }
         if ($this->getConfig('sldmaxdimauto')) {
             // Get dimensions of image for calculating the max. width/height
             // of all images
             $dimensions = getimagesize($this->getAmbit()->getImg('img_path', $row));
             if ($dimensions[0] > $maxwidth) {
                 $maxwidth = $dimensions[0];
             }
             if ($dimensions[1] > $maxheight) {
                 $maxheight = $dimensions[1];
             }
         }
         $script .= "    catImages" . $this->getConfig('module_id') . "_{$catid}" . "[{$number}] = new catImage(\n" . "      '" . str_replace('&amp;', '&', $this->GetAmbit()->getImg('img_url', $row)) . "',//image\n" . "      '" . $this->GetAmbit()->getImg('thumb_url', $row) . "',//thumbnail\n" . "      '" . JoomHelper::fixForJS($row->imgtitle) . "',//linkTitle\n" . "      '" . str_replace('&amp;', '&', $this->GetAmbit()->getImg('img_url', $row)) . "',//link\n" . "      '" . JoomHelper::fixForJS($row->imgtitle) . "',//title\n" . "      '{$description}',//description\n" . "      {$number}//number\n" . "    );\n";
         $number++;
     }
     $script .= "    /* ]]> */\n";
     // Reset var 'option'
     $router->setVar('option', $option);
     $router->setVar('Itemid', $Itemid);
     if (!$this->getConfig('sldmaxdimauto')) {
         $maxwidth = $this->getConfig('sldwidth');
         $maxheight = $this->getConfig('sldheight');
     }
     $script .= "    var jsJoomCatModule" . $this->getConfig('module_id') . "_{$catid} = null;\n" . "    window.addEvent('domready', function(){\n" . "      jsJoomCatModule" . $this->getConfig('module_id') . "_{$catid} = new JoomCatModule({\n" . "        div: '{$slideshowid}',\n" . "        classname: '{$slideshowclass}',\n" . "        delay: " . $this->GetConfig('sldtimer') . ",\n" . "        fadeDuration: " . $this->GetConfig('sldtranstime') . ",\n" . "        showArrows: " . $this->GetConfig('sldarrows') . ",\n" . "        showCarousel: " . $this->GetConfig('sldcarousel') . ",\n" . "        textShowCarousel: '" . JText::_('COM_JOOMGALLERY_DETAIL_SLIDESHOW_IMAGES') . "',\n" . "        showInfopane: " . $this->GetConfig('sldinfopane') . ",\n" . "        manualData: catImages" . $this->getConfig('module_id') . "_{$catid},\n" . "        maxWidth: {$maxwidth},\n" . "        maxHeight: {$maxheight},\n" . "        errorMessage: '{$errorMessage}',\n" . "        baseURL: '" . JURI::base() . "',\n" . "        catTitle: '" . JoomHelper::fixForJS($catname) . "'\n" . "      });\n" . "    });\n";
     $doc->addScriptDeclaration($script);
     // Prepare image link for slideshow
     if (preg_match('/<img ([^>]*)>/', $imgelement, $matches) > 0) {
         $replace = '<a href="javascript:void(0);" title="' . $catname . '" onclick="jsJoomCatModule' . $this->getConfig('module_id') . '_' . $catid . '.startSlideshow()">' . $matches[0] . '</a>';
         $imgelement = preg_replace('/<img ([^>]*)>/', $replace, $imgelement);
     }
 }
Пример #19
0
 /**
  * Checks all categories of the gallery registered in the database
  *
  * @return  void
  * @since   1.5.5
  */
 public function checkCategories()
 {
     $start = false;
     if (!$this->_mainframe->getUserState('joom.maintenance.check.checkcategories')) {
         $start = true;
         $this->_mainframe->setUserState('joom.maintenance.check.limitstart', 0);
         $this->_mainframe->setUserState('joom.maintenance.check.checkcategories', true);
     }
     $query = $this->_db->getQuery(true);
     $query->select('COUNT(c.cid)')->from(_JOOM_TABLE_CATEGORIES . ' AS c');
     $this->_db->setQuery($query);
     $total = $this->_db->loadResult();
     $refresher = new JoomRefresher(array('name' => JText::_('COM_JOOMGALLERY_MAIMAN_CHECK_CATEGORIES'), 'remaining' => $total, 'start' => $start));
     $query->clear('select')->select('c.cid, c.parent_id, c.name, c.owner, c.alias, p.cid AS parent_category, u.id AS user')->leftJoin(_JOOM_TABLE_CATEGORIES . ' AS p ON c.parent_id = p.cid')->leftJoin('#__users AS u ON c.owner = u.id');
     $types = array('thumb', 'img', 'orig');
     $table = $this->getTable('joomgallerymaintenance');
     $start = $this->_mainframe->getUserState('joom.maintenance.check.limitstart', 0);
     for ($limitstart = $start; $limitstart < $total; $limitstart += $this->limit) {
         $categories = $this->_getList($query, $limitstart, $this->limit);
         foreach ($categories as $category) {
             // Skip ROOT category
             if ($category->cid == 1) {
                 continue;
             }
             $corrupt = false;
             // Check for valid parent category
             if (!$category->parent_category) {
                 $category->parent_id = -1;
                 $corrupt = true;
             }
             // Check for valid owner
             if ($category->owner && !$category->user) {
                 $category->owner = -1;
                 $corrupt = true;
             }
             // Look for folders
             foreach ($types as $type) {
                 $folder = JPath::clean($this->_ambit->get($type . '_path') . rtrim(JoomHelper::getCatPath($category->cid), '/'), '/');
                 if (JFolder::exists($folder)) {
                     $category->{$type} = $folder;
                     // Delete the corresponding entry in orphans table
                     $delete_query = $this->_db->getQuery(true)->delete()->from(_JOOM_TABLE_ORPHANS)->where("fullpath = '" . JPath::clean($folder, '/') . "'")->where("type = 'folder'");
                     $this->_db->setQuery($delete_query);
                     $this->_db->query();
                 } else {
                     $corrupt = true;
                 }
             }
             // Check whether the image is corrupt
             if ($corrupt) {
                 // If yes, store the gathered information in the database
                 $table->reset();
                 $table->bind($category);
                 $table->id = 0;
                 $table->refid = $category->cid;
                 $table->title = $category->name;
                 $table->catid = $category->parent_id;
                 $table->type = 1;
                 $table->check();
                 $table->store();
             }
         }
         if (!$refresher->check()) {
             $this->_mainframe->setUserState('joom.maintenance.check.limitstart', $limitstart + $this->limit);
             $refresher->refresh($total - ($limitstart + $this->limit));
         }
     }
     // Prepare next step
     $query = $this->_db->getQuery(true)->select('COUNT(id)')->from(_JOOM_TABLE_ORPHANS)->where("(type = 'thumb' OR type = 'img' OR type = 'orig')");
     $this->_db->setQuery($query);
     $total = $this->_db->loadResult();
     $this->_mainframe->setUserState('joom.maintenance.check.index', 0);
     $this->_mainframe->setUserState('joom.maintenance.check.createfilesuggestions', true);
     $refresher->reset($total, true, JText::_('COM_JOOMGALLERY_MAIMAN_CREATE_FILE_SUGGESTIONS'));
     // Next step
     $refresher->refresh(0, 'createfilesuggestions');
 }
Пример #20
0
    ?>
</td>
									<td><?php 
    echo JHtml::_('joomgallery.categorypath', $item->catid, true, ' &raquo; ', false, false, true);
    ?>
</td>
									<td><?php 
    echo $orig_info[0] . 'x' . $orig_info[1];
    ?>
</td>
									<td><?php 
    echo JoomHelper::getTags($item->id);
    ?>
</td>
									<td class="text-right"><strong><?php 
    echo number_format(JoomHelper::getAdditional($item->id, "price"), 0, ",", ".");
    ?>
</strong> vnđ</td>
									<td>
										<?php 
    if ($item->published) {
        ?>
										<a class="btn btn-sm btn-default" href="<?php 
        echo JRoute::_('index.php?task=image.publish&id=' . $item->id . $this->slimitstart);
        ?>
">Ẩn hình<span class="glyphicon glyphicon-download" aria-hidden="true"></span></a>
										<?php 
    } else {
        ?>
										<a class="btn btn-sm btn-success" href="<?php 
        echo JRoute::_('index.php?task=image.publish&id=' . $item->id . $this->slimitstart);
Пример #21
0
 /**
  * Creates images from the original one or moves the existing ones
  * into the folders of their category.
  *
  * Required parameters are the first two ($row and $origimage) with $row being the data object with image
  * information and $origimage being the path and filename of the image to migrate. $origimage will be the one
  * stored in the original images directory of JoomGallery.
  * You can also specify $detailimage and $thumbnail which will store them in the respective folders. If you
  * don't specify them they will be created from the original image.
  *
  * [jimport('joomla.filesystem.file') has to be called afore]
  *
  * @param   object  $row          Holds information about the new image
  * @param   string  $origimage    The original image
  * @param   string  $detailimage  The detail image
  * @param   string  $thumbnail    The thumbnail
  * @param   boolean $newfilename  True if a new file name shall be generated for the files
  * @param   boolean $copy         True if the image shall be copied into the new directory, not moved
  * @param   boolean $checkOwner   Determines whether the owner ID shall be checked against the existing users
  * @return  boolean True on success, false otherwise
  * @since   1.5.0
  */
 public function moveAndResizeImage($row, $origimage, $detailimage = null, $thumbnail = null, $newfilename = true, $copy = null, $checkOwner = null)
 {
     if (is_null($copy)) {
         $copy = $this->copyImages;
     }
     if (is_null($checkOwner)) {
         $checkOwner = $this->checkOwner;
     }
     // Some checks
     if (!isset($row->id) || $row->id < 1) {
         $this->setError('Invalid image ID');
         return false;
     }
     if (!isset($row->imgfilename)) {
         $this->setError('Image file name wasn\'t found.');
         return false;
     }
     if (!isset($row->catid) || $row->catid < 1) {
         $this->setError('Invalid category ID');
         return false;
     } else {
         // If image with category ID 1 comes in we have to set
         // the category ID to the newly created one because
         // category with ID 1 is the ROOT category in JoomGallery
         if ($row->catid == 1) {
             $row->catid = $this->newCatid;
         }
     }
     if (!isset($row->catpath)) {
         $row->catpath = JoomHelper::getCatpath($row->catid);
         if (!$row->catpath) {
             $this->setError('Category with ID ' . $row->catid . ' does not exist for image with ID ' . $row->id . '. Image cannot be migrated.');
             return false;
         }
     }
     if (!isset($row->imgtitle)) {
         $row->imgtitle = str_replace(JFile::getExt($row->imgfilename), '', $row->imgfilename);
     }
     if (!isset($row->alias)) {
         // Will be created later on
         $row->alias = '';
     }
     if (!isset($row->imgauthor)) {
         $row->imgauthor = '';
     }
     if (!isset($row->imgtext)) {
         $row->imgtext = '';
     }
     if (!isset($row->imgdate) || is_numeric($row->imgdate)) {
         $date = JFactory::getDate();
         $row->imgdate = $date->toSQL();
     }
     if (!isset($row->hits)) {
         $row->hits = 0;
     }
     if (!isset($row->downloads)) {
         $row->downloads = 0;
     }
     if (!isset($row->imgvotes)) {
         $row->imgvotes = 0;
     }
     if (!isset($row->imgvotesum)) {
         $row->imgvotesum = 0;
     }
     if (!isset($row->access) || $row->access < 1) {
         $row->access = $this->_mainframe->getCfg('access');
     }
     if (!isset($row->published)) {
         $row->published = 0;
     }
     if (!isset($row->hidden)) {
         $row->hidden = 0;
     }
     if (!isset($row->imgthumbname)) {
         $row->imgthumbname = $row->imgfilename;
     }
     if (!isset($row->checked_out)) {
         $row->checked_out = 0;
     }
     if (!isset($row->owner) || !is_numeric($row->owner) || $row->owner < 1 || $checkOwner && !JUser::getTable()->load($row->owner)) {
         $row->owner = 0;
     }
     if (!isset($row->approved)) {
         $row->approved = 1;
     }
     if (!isset($row->useruploaded)) {
         $row->useruploaded = 0;
     }
     if (!isset($row->ordering)) {
         $row->ordering = 0;
     }
     if (!isset($row->params)) {
         $row->params = '';
     }
     if (!isset($row->metakey)) {
         $row->metakey = '';
     }
     if (!isset($row->metadesc)) {
         $row->metadesc = '';
     }
     // Check whether one of the images to migrate already exist in the destination directory
     $orig_exists = false;
     $img_exists = false;
     $thumb_exists = false;
     $neworigimage = $this->_ambit->getImg('orig_path', $row);
     $newdetailimage = $this->_ambit->getImg('img_path', $row);
     $newthumbnail = $this->_ambit->getImg('thumb_path', $row);
     if (JFile::exists($neworigimage)) {
         $orig_exists = true;
     }
     if (JFile::exists($newdetailimage)) {
         $img_exists = true;
     }
     if (JFile::exists($newthumbnail)) {
         $thumb_exists = true;
     }
     // Generate a new file name if requested or if a file with the current name already exists
     if ($newfilename || $orig_exists || $img_exists || $thumb_exists) {
         $row->imgfilename = $this->genFilename($row->imgtitle, $origimage, $row->catid);
         $row->imgthumbname = $row->imgfilename;
     }
     $result = array();
     // Copy or move original image into the folder of the original images
     if (!$orig_exists) {
         // If it doesn't already exists with another name try to copy or move from source directory
         if (!JFile::exists($origimage)) {
             $this->setError('Original image not found: ' . $origimage);
             return false;
         }
         $neworigimage = $this->_ambit->getImg('orig_path', $row);
         if ($copy) {
             $result['orig'] = JFile::copy(JPath::clean($origimage), JPath::clean($neworigimage));
             if (!$result['orig']) {
                 $this->setError('Could not copy original image from ' . $origimage . ' to ' . $neworigimage);
                 return false;
             }
         } else {
             $result['orig'] = JFile::move(JPath::clean($origimage), JPath::clean($neworigimage));
             if (!$result['orig']) {
                 $this->setError('Could not move original image from ' . $origimage . ' to ' . $neworigimage);
                 return false;
             }
         }
     } else {
         // If it already exists with another name copy it to a file with the new name
         if (!JFile::copy($neworigimage, $this->_ambit->getImg('orig_path', $row))) {
             $this->setError('Could not copy original image from ' . $neworigimage . ' to ' . $this->_ambit->getImg('orig_path', $row));
             return false;
         }
         // Populate the new original file name and path because it will be
         // necessary for deleting it of deleting original images is configured
         $neworigimage = $this->_ambit->getImg('orig_path', $row);
     }
     if (!$img_exists) {
         // If it doesn't already exists with another name try to copy or move from source directory or create a new one
         $newdetailimage = $this->_ambit->getImg('img_path', $row);
         if (is_null($detailimage) || !JFile::exists($detailimage)) {
             // Create new detail image
             $debugoutput = '';
             $result['detail'] = JoomFile::resizeImage($debugoutput, $neworigimage, $newdetailimage, false, $this->_config->get('jg_maxwidth'), false, $this->_config->get('jg_thumbcreation'), $this->_config->get('jg_thumbquality'), true, 0);
             if (!$result['detail']) {
                 $this->setError('Could not create detail image ' . $newdetailimage);
             }
         } else {
             // Copy or move existing detail image
             if ($copy) {
                 $result['detail'] = JFile::copy(JPath::clean($detailimage), JPath::clean($newdetailimage));
                 if (!$result['detail']) {
                     $this->setError('Could not copy detail image from ' . $detailimage . ' to ' . $newdetailimage);
                 }
             } else {
                 $result['detail'] = JFile::move(JPath::clean($detailimage), JPath::clean($newdetailimage));
                 if (!$result['detail']) {
                     $this->setError('Could not move detail image from ' . $detailimage . ' to ' . $newdetailimage);
                 }
             }
         }
     } else {
         // If it already exists with another name copy it to a file with the new name
         $result['detail'] = JFile::copy($newdetailimage, $this->_ambit->getImg('img_path', $row));
         if (!$result['detail']) {
             $this->setError('Could not copy detail image from ' . $newdetailimage . ' to ' . $this->_ambit->getImg('img_path', $row));
         }
     }
     if (!$thumb_exists) {
         // If it doesn't already exists with another name try to copy or move from source directory or create a new one
         $newthumbnail = $this->_ambit->getImg('thumb_path', $row);
         if (is_null($thumbnail) || !JFile::exists($thumbnail)) {
             // Create new thumbnail
             $debugoutput = '';
             $result['thumb'] = JoomFile::resizeImage($debugoutput, $neworigimage, $newthumbnail, $this->_config->get('jg_useforresizedirection'), $this->_config->get('jg_thumbwidth'), $this->_config->get('jg_thumbheight'), $this->_config->get('jg_thumbcreation'), $this->_config->get('jg_thumbquality'), false, $this->_config->get('jg_cropposition'));
             if (!$result['thumb']) {
                 $this->setError('Could not create thumbnail ' . $newthumbnail);
             }
         } else {
             // Copy or move existing thumbnail
             if ($copy) {
                 $result['thumb'] = JFile::copy(JPath::clean($thumbnail), JPath::clean($newthumbnail));
                 if (!$result['thumb']) {
                     $this->setError('Could not copy thumbnail from ' . $thumbnail . ' to ' . $newthumbnail);
                 }
             } else {
                 $result['thumb'] = JFile::move(JPath::clean($thumbnail), JPath::clean($newthumbnail));
                 if (!$result['thumb']) {
                     $this->setError('Could not move thumbnail from ' . $thumbnail . ' to ' . $newthumbnail);
                 }
             }
         }
     } else {
         // If it already exists with another name copy it to a file with the new name
         $result['thumb'] = JFile::copy($newthumbnail, $this->_ambit->getImg('thumb_path', $row));
         if (!$result['thumb']) {
             $this->setError('Could not copy thumbnail from ' . $newthumbnail . ' to ' . $this->_ambit->getImg('thumb_path', $row));
         }
     }
     // Delete original image if configured in JoomGallery
     if ($this->_config->get('jg_delete_original') == 1) {
         $result['delete_orig'] = JFile::delete($neworigimage);
         if (!$result['delete_orig']) {
             $this->setError('Could not delete original image ' . $neworigimage);
         }
     }
     // Create database entry
     $query = $this->_db->getQuery(true)->insert(_JOOM_TABLE_IMAGES)->columns('id, catid, imgtitle, alias, imgauthor, imgtext, imgdate, hits, downloads, imgvotes, imgvotesum, access, published, hidden, imgfilename, imgthumbname, checked_out, owner, approved, useruploaded, ordering, params, metakey, metadesc')->values((int) $row->id . ',' . (int) $row->catid . ',' . $this->_db->quote($row->imgtitle) . ',' . $this->_db->quote($row->alias) . ',' . $this->_db->quote($row->imgauthor) . ',' . $this->_db->quote($row->imgtext) . ',' . $this->_db->quote($row->imgdate) . ',' . (int) $row->hits . ',' . (int) $row->downloads . ',' . (int) $row->imgvotes . ',' . (int) $row->imgvotesum . ',' . (int) $row->access . ',' . (int) $row->published . ',' . (int) $row->hidden . ',' . $this->_db->quote($row->imgfilename) . ',' . $this->_db->quote($row->imgthumbname) . ',' . (int) $row->checked_out . ',' . (int) $row->owner . ',' . (int) $row->approved . ',' . (int) $row->useruploaded . ',' . (int) $row->ordering . ',' . $this->_db->quote($row->params) . ',' . $this->_db->quote($row->metakey) . ',' . $this->_db->quote($row->metadesc));
     $this->_db->setQuery($query);
     $result[] = $this->runQuery();
     // Create asset and alias
     $table = JTable::getInstance('joomgalleryimages', 'Table');
     $table->load($row->id);
     if ($table->check()) {
         $result['db'] = $table->store();
         if (!$result['db']) {
             $this->setError($table->getError(), true);
         }
     }
     if (!in_array(false, $result)) {
         $this->writeLogfile('Image successfully migrated: ' . $row->id . ' Title: ' . $row->imgtitle);
         return true;
     } else {
         $this->writeLogfile('-> Error migrating image: ' . $row->id . ' Title: ' . $row->imgtitle);
         return false;
     }
 }
Пример #22
0
 /**
  * HTML view display method
  *
  * @param   string  $tpl  The name of the template file to parse
  * @return  void
  * @since   1.5.5
  */
 public function display($tpl = null)
 {
     $params = $this->_mainframe->getParams();
     // Prepare params for header and footer
     JoomHelper::prepareParams($params);
     // Load modules at position 'top'
     $modules['top'] = JoomHelper::getRenderedModules('top');
     if (count($modules['top'])) {
         $params->set('show_top_modules', 1);
     }
     // Load modules at position 'btm'
     $modules['btm'] = JoomHelper::getRenderedModules('btm');
     if (count($modules['btm'])) {
         $params->set('show_btm_modules', 1);
     }
     // Check whether this is the active menu item. This is a
     // special case in addition to code in constructor of parent class
     // because here we have to check the category ID, too.
     $active = $this->_mainframe->getMenu()->getActive();
     if (!$active || strpos($active->link, '&catid=' . JRequest::getInt('catid')) === false) {
         // Get the default layout from the configuration
         if ($layout = $this->_config->get('jg_alternative_layout')) {
             $this->setLayout($layout);
         }
     }
     // Get number of images and hits in gallery
     $numbers = JoomHelper::getNumberOfImgHits();
     // Categories pagination
     if ($this->_config->get('jg_hideemptycats') == 2) {
         $totalcategories =& $this->get('TotalCategoriesWithoutEmpty');
     } else {
         $totalcategories = $this->get('TotalCategories');
     }
     // Calculation of the number of total pages
     $catperpage = $this->_config->get('jg_subperpage');
     if (!$catperpage) {
         $catperpage = 10;
     }
     $cattotalpages = floor($totalcategories / $catperpage);
     $offcut = $totalcategories % $catperpage;
     if ($offcut > 0) {
         $cattotalpages++;
     }
     $total = $totalcategories;
     $totalcategories = number_format($totalcategories, 0, ',', '.');
     // Get the current page
     $catpage = JRequest::getInt('catpage', 0);
     if ($catpage > $cattotalpages) {
         $catpage = $cattotalpages;
         if ($catpage <= 0) {
             $catpage = 1;
         }
     } else {
         if ($catpage < 1) {
             $catpage = 1;
         }
     }
     // Limitstart
     $limitstart = ($catpage - 1) * $catperpage;
     JRequest::setVar('catlimitstart', $limitstart);
     require_once JPATH_COMPONENT_ADMINISTRATOR . '/helpers/pagination.php';
     $this->catpagination = new JoomPagination($total, $limitstart, $catperpage, 'cat', 'subcategory');
     if ($cattotalpages > 1 && $totalcategories != 0) {
         if ($this->_config->get('jg_showpagenavsubs') <= 2) {
             $params->set('show_pagination_cat_top', 1);
         }
         if ($this->_config->get('jg_showpagenavsubs') >= 2) {
             $params->set('show_pagination_cat_bottom', 1);
         }
     }
     // Displaying of category number depends on pagination position
     if ($this->_config->get('jg_showsubcatcount')) {
         if ($this->_config->get('jg_showpagenavsubs') <= 2) {
             $params->set('show_count_cat_top', 1);
         }
         if ($this->_config->get('jg_showpagenavsubs') >= 2) {
             $params->set('show_count_cat_bottom', 1);
         }
     }
     // Images pagination
     $totalimages = $this->get('TotalImages');
     // Calculation of the number of total pages
     $perpage = $this->_config->get('jg_perpage');
     if (!$perpage) {
         $perpage = 10;
     }
     $totalpages = floor($totalimages / $perpage);
     $offcut = $totalimages % $perpage;
     if ($offcut > 0) {
         $totalpages++;
     }
     $total = $totalimages;
     $totalimages = number_format($totalimages, 0, ',', '.');
     // Get the current page
     $page = JRequest::getInt('page', 0);
     if ($page > $totalpages) {
         $page = $totalpages;
         if ($page <= 0) {
             $page = 1;
         }
     } else {
         if ($page < 1) {
             $page = 1;
         }
     }
     // Limitstart
     $limitstart = ($page - 1) * $perpage;
     $this->pagination = new JoomPagination($total, $limitstart, $perpage);
     // 'jg_detailpic_open' is not numeric if an OpenImage plugin was selected, thus we handle it like > 4
     if ($this->_config->get('jg_lightbox_slide_all') && (!is_numeric($this->_config->get('jg_detailpic_open')) || $this->_config->get('jg_detailpic_open') > 4)) {
         $params->set('show_all_in_popup', 1);
         JRequest::setVar('limitstart', -1);
         // We need all images of this category
         $images = $this->get('Images');
         $popup = array();
         $end = ($page - 1) * $perpage;
         $start = $page * $perpage;
         $popup['before'] = JHTML::_('joomgallery.popup', $images, 0, $end);
         $popup['after'] = JHTML::_('joomgallery.popup', $images, $start);
         $this->assignRef('popup', $popup);
         // Now we have to select the images according to the pagination
         $images = array_slice($images, $limitstart, $perpage);
     } else {
         JRequest::setVar('limitstart', $limitstart);
         JRequest::setVar('limit', $this->_config->get('jg_perpage'));
         $images = $this->get('Images');
     }
     if ($totalpages > 1 && $totalimages != 0) {
         if ($this->_config->get('jg_showpagenav') <= 2) {
             $params->set('show_pagination_img_top', 1);
         }
         if ($this->_config->get('jg_showpagenav') >= 2) {
             $params->set('show_pagination_img_bottom', 1);
         }
     }
     // Displaying of image number depends on pagination position
     if ($this->_config->get('jg_showpiccount')) {
         if ($this->_config->get('jg_showpagenav') <= 2) {
             $params->set('show_count_img_top', 1);
         }
         if ($this->_config->get('jg_showpagenav') >= 2) {
             $params->set('show_count_img_bottom', 1);
         }
     }
     $cat = $this->get('Category');
     if (isset($cat->protected)) {
         $this->cat = $cat;
         echo $this->loadTemplate('password');
         return;
     }
     $backlink = array();
     if ($cat->parent_id > 1) {
         // Sub-category -> parent category
         $backlink[0] = JRoute::_('index.php?view=category&catid=' . $cat->parent_id);
         $backlink[1] = JText::_('COM_JOOMGALLERY_COMMON_BACK_TO_CATEGORY');
     } else {
         // Category view -> gallery view
         $backlink[0] = JRoute::_('index.php?view=gallery');
         $backlink[1] = JText::_('COM_JOOMGALLERY_COMMON_BACK_TO_GALLERY');
     }
     // Meta data
     if ($cat->metadesc) {
         $this->_doc->setDescription($cat->metadesc);
     }
     if ($cat->metakey) {
         $this->_doc->setMetadata('keywords', $cat->metakey);
     }
     /*if($this->_mainframe->getCfg('MetaAuthor') == '1' && $cat->author)
       {
         $this->_doc->setMetaData('author', $cat->author);
       }*/
     // Breadcrumbs
     if ($this->_config->get('jg_completebreadcrumbs') || $this->_config->get('jg_showpathway')) {
         $parents = JoomHelper::getAllParentCategories($cat->cid);
     }
     $menus = $this->_mainframe->getMenu();
     $menu = $menus->getActive();
     if ($menu && array_key_exists('view', $menu->query) && $this->_config->get('jg_completebreadcrumbs')) {
         $breadcrumbs = $this->_mainframe->getPathway();
         switch ($menu->query['view']) {
             case '':
             case 'gallery':
                 foreach ($parents as $parent) {
                     $breadcrumbs->addItem($parent->name, 'index.php?view=category&catid=' . $parent->cid);
                 }
                 $breadcrumbs->addItem($cat->name);
                 break;
             case 'category':
                 $skip = true;
                 foreach ($parents as $key => $parent) {
                     if ($skip) {
                         if ($key == $menu->query['catid']) {
                             $skip = false;
                         }
                     } else {
                         $breadcrumbs->addItem($parent->name, 'index.php?view=category&catid=' . $parent->cid);
                     }
                 }
                 if (!$skip) {
                     $breadcrumbs->addItem($cat->name);
                 }
                 break;
             default:
                 break;
         }
     }
     /*if($this->_config->get('jg_completebreadcrumbs'))
         {
           $breadcrumbs  = &$this->_mainframe->getPathway();
     
           foreach($parents as $parent)
           {
             $breadcrumbs->addItem($parent->name, 'index.php?view=category&catid='.$parent->cid);
           }
     
           $breadcrumbs->addItem($cat->name);
         }*/
     // JoomGallery Pathway
     $pathway = '';
     if ($this->_config->get('jg_showpathway')) {
         $pathway = '<a href="' . JRoute::_('index.php?view=gallery') . '" class="jg_pathitem">' . JText::_('COM_JOOMGALLERY_COMMON_HOME') . '</a> &raquo; ';
         foreach ($parents as $parent) {
             $pathway .= '<a href="' . JRoute::_('index.php?view=category&catid=' . $parent->cid) . '" class="jg_pathitem">' . $parent->name . '</a> &raquo; ';
         }
         $pathway .= $cat->name;
     }
     // Page title
     if ($this->_config->get('jg_pagetitle_cat')) {
         $pagetitle = JoomHelper::createPagetitle($this->_config->get('jg_pagetitle_cat'), $cat->name, '', $params->get('page_title') ? $params->get('page_title') : JText::_('COM_JOOMGALLERY_COMMON_GALLERY'));
         $this->_doc->setTitle($pagetitle);
     }
     // RSS feed
     if ($this->_config->get('jg_category_rss')) {
         $link = '&format=feed&limitstart=';
         $attribs = array('type' => 'application/rss+xml', 'title' => 'RSS 2.0');
         $this->_doc->addHeadLink(JRoute::_($link . '&type=rss'), 'alternate', 'rel', $attribs);
         $attribs = array('type' => 'application/atom+xml', 'title' => 'Atom 1.0');
         $this->_doc->addHeadLink(JRoute::_($link . '&type=atom'), 'alternate', 'rel', $attribs);
         if ($this->_config->get('jg_category_rss_icon')) {
             $params->set('show_feed_icon', 1);
             $params->set('feed_url', JRoute::_($link . '&type=' . $this->_config->get('jg_category_rss_icon')));
         }
     }
     // Favourites icon for categories
     if ($this->_config->get('jg_allimagesofcategory') && $this->_config->get('jg_favourites')) {
         if ($this->_user->get('id') || $this->_config->get('jg_usefavouritesforpubliczip') == 1 && !$this->_user->get('id')) {
             if ($this->_config->get('jg_usefavouritesforzip') || $this->_config->get('jg_usefavouritesforpubliczip') && !$this->_user->get('id')) {
                 $params->set('show_headerfavourites_icon', 2);
             } else {
                 $params->set('show_headerfavourites_icon', 1);
             }
         } else {
             if ($this->_config->get('jg_favouritesshownotauth') == 1) {
                 if ($this->_config->get('jg_usefavouritesforzip')) {
                     $params->set('show_headerfavourites_icon', -2);
                 } else {
                     $params->set('show_headerfavourites_icon', -1);
                 }
             }
         }
     }
     // Icon for quick upload
     if ($this->_config->get('jg_uploadiconcategory') && ($this->_user->authorise('joom.upload', _JOOM_OPTION . '.category.' . $cat->cid) || $cat->owner && $cat->owner == $this->_user->get('id') && $this->_user->authorise('joom.upload.inown', _JOOM_OPTION . '.category.' . $cat->cid))) {
         $params->set('show_upload_icon', 1);
         JHtml::_('behavior.modal');
     }
     // Get all sub-categories of the current category
     if ($this->_config->get('jg_hideemptycats') == 2) {
         // If the third alternative for hiding empty categories
         // is chosen ('Also those which contain empty sub-categories'),
         // we need additional code to exclude these categories.
         // (For the second alternative only the query in the model is modified.)
         $categories =& $this->get('CategoriesWithoutEmpty');
     } else {
         $categories = $this->get('Categories');
     }
     foreach ($categories as $key => $category) {
         $categories[$key]->isnew = '';
         if ($this->_config->get('jg_showcatasnew')) {
             // Check if an image in this category or in sub-categories is marked with 'new'
             $categories[$key]->isnew = JoomHelper::checkNewCatg($categories[$key]->cid);
         }
         // Count the images in category and sub-categories
         $imgshits = JoomHelper::getNumberOfImgHits($categories[$key]->cid);
         $categories[$key]->pictures = $imgshits[0];
         if ($categories[$key]->pictures == '1') {
             $categories[$key]->picorpics = 'COM_JOOMGALLERY_GALLERY_ONE_IMAGE';
         } else {
             $categories[$key]->picorpics = 'COM_JOOMGALLERY_GALLERY_IMAGES';
         }
         // Count the hits of all images in category and sub-categories
         $categories[$key]->totalhits = $imgshits[1];
         $category->thumb_src = null;
         $category->gallerycontainer = 'jg_subcatelem_cat';
         $category->photocontainer = 'jg_subcatelem_photo';
         $category->textcontainer = 'jg_subcatelem_txt';
         if ($this->_config->get('jg_showsubthumbs') > 0 && in_array($categories[$key]->access, $this->_user->getAuthorisedViewLevels())) {
             if ($this->_config->get('jg_showsubthumbs') == 2 || $this->_config->get('jg_showsubthumbs') == 3 && (!$categories[$key]->thumbnail || !isset($categories[$key]->id))) {
                 // Random choice of category/thumbnail
                 switch ($this->_config->get('jg_showrandomsubthumb')) {
                     // Only from current category
                     case 1:
                         $random_catid = $category->cid;
                         break;
                         // Only from sub-categories
                     // Only from sub-categories
                     case 2:
                         // Get array of all sub-categories without the current category
                         // Only with images
                         $allsubcats = JoomHelper::getAllSubCategories($category->cid, false);
                         if (count($allsubcats)) {
                             $random_catid = $allsubcats[mt_rand(0, count($allsubcats) - 1)];
                         } else {
                             $random_catid = 0;
                         }
                         break;
                         // From both
                     // From both
                     case 3:
                         // Get array of all sub-categories including the current category
                         // Only with images
                         $allsubcats = JoomHelper::getAllSubCategories($category->cid, true);
                         if (count($allsubcats)) {
                             $random_catid = $allsubcats[mt_rand(0, count($allsubcats) - 1)];
                         } else {
                             $random_catid = 0;
                         }
                         break;
                     default:
                         $random_catid = 0;
                         break;
                 }
                 // Random image, only if there are $randomcat(s)
                 if ($this->_config->get('jg_showrandomsubthumb') == 1 || $this->_config->get('jg_showrandomsubthumb') >= 2 && $random_catid != 0) {
                     $model = $this->getModel();
                     if ($row = $model->getRandomImage($category->cid, $random_catid)) {
                         $cropx = null;
                         $cropy = null;
                         $croppos = null;
                         if ($this->_config->get('jg_dyncrop')) {
                             $cropx = $this->_config->get('jg_dyncropwidth');
                             $cropy = $this->_config->get('jg_dyncropheight');
                             $croppos = $this->_config->get('jg_dyncropposition');
                         }
                         $categories[$key]->thumb_src = $this->_ambit->getImg('thumb_url', $row, null, 0, true, $cropx, $cropy, $croppos);
                         // Store the image id for later skipping the category view
                         if (isset($row->catid) && $categories[$key]->cid == $row->catid) {
                             $categories[$key]->dtlimgid = $row->id;
                         }
                     }
                 }
             } else {
                 // Check if there's a category thumbnail selected
                 // 'isset' checks whether it is a valid image which we are allowed to display
                 if ($categories[$key]->thumbnail && isset($categories[$key]->id)) {
                     $cropx = null;
                     $cropy = null;
                     $croppos = null;
                     if ($this->_config->get('jg_dyncrop')) {
                         $cropx = $this->_config->get('jg_dyncropwidth');
                         $cropy = $this->_config->get('jg_dyncropheight');
                         $croppos = $this->_config->get('jg_dyncropposition');
                     }
                     $categories[$key]->thumb_src = $this->_ambit->getImg('thumb_url', $categories[$key], null, 0, true, $cropx, $cropy, $croppos);
                     if (!$categories[$key]->imghidden && isset($categories[$key]->catid) && $categories[$key]->cid == $categories[$key]->catid) {
                         // Store the image id for later skipping the category view
                         $categories[$key]->dtlimgid = $categories[$key]->id;
                     }
                     // Own choice of alignment
                     switch ($categories[$key]->img_position) {
                         // Left
                         case 0:
                             $categories[$key]->photocontainer = 'jg_subcatelem_photo_l';
                             $categories[$key]->textcontainer = 'jg_subcatelem_txt_l';
                             break;
                             // Right
                         // Right
                         case 1:
                             $categories[$key]->gallerycontainer = 'jg_subcatelem_cat_r';
                             $categories[$key]->photocontainer = 'jg_subcatelem_photo_r';
                             $categories[$key]->textcontainer = 'jg_subcatelem_txt_r';
                             break;
                             // Centered
                         // Centered
                         case 2:
                             $categories[$key]->photocontainer = 'jg_subcatelem_photo_c';
                             $categories[$key]->textcontainer = 'jg_subcatelem_txt_c';
                             break;
                         default:
                             // Use global settings: The default classes are used
                             if ($this->_config->get('jg_subcatthumbalign') != 1) {
                                 $gallerycontainer = 'jg_subcatelem_cat_r';
                             }
                             break;
                     }
                 }
             }
         }
         // Set the href url for the <a>-Tag, dependent on setting in
         // jg_skipcatview
         // link to category view or directly to detail view if the category
         // doesn't contain other categories
         if ($this->_config->get('jg_skipcatview')) {
             // Get subcategories from category
             $allsubcats = JoomHelper::getAllSubCategories($categories[$key]->cid, false);
             // Link to category view if there are any viewable subcategories
             // otherwise to detail view
             if (count($allsubcats)) {
                 $categories[$key]->link = JRoute::_('index.php?view=category&catid=' . $category->cid);
             } else {
                 // Try to set link to detail view
                 // get link with the help of model if
                 // 1) view of thumb in configuration deactivated
                 // 2) view of thumb activated but no thumb setted for category
                 if ($this->_config->get('jg_showsubthumbs') == 0 || $this->_config->get('jg_showsubthumbs') != 0 && !isset($categories[$key]->dtlimgid)) {
                     // Get the model
                     $categoryModel = $this->getModel();
                     // Get the id of image
                     $image = $categoryModel->getImageCat($categories[$key]->cid);
                     // Set the id of image for the link to detail view
                     if (isset($image)) {
                         $categories[$key]->dtlimgid = $image;
                     }
                 }
                 // Check the id of image setted before
                 if (isset($categories[$key]->dtlimgid)) {
                     // Set link to detail view
                     $categories[$key]->link = JHTML::_('joomgallery.openimage', $this->_config->get('jg_detailpic_open'), $categories[$key]->dtlimgid);
                     // If category view is skipped we display the favourites icon for adding all images at the thumbnail.
                     // Calculations for that have already been done for the favourites icon in the header
                     $categories[$key]->show_favourites_icon = $params->get('show_headerfavourites_icon');
                 } else {
                     $categories[$key]->link = JRoute::_('index.php?view=category&catid=' . $category->cid);
                 }
             }
         } else {
             // Set link to category view if no skipping
             $categories[$key]->link = JRoute::_('index.php?view=category&catid=' . $category->cid);
         }
         // Icon for quick upload at sub-category thumbnail
         if ($this->_config->get('jg_uploadiconsubcat') && ($this->_user->authorise('joom.upload', _JOOM_OPTION . '.category.' . $category->cid) || $category->owner && $category->owner == $this->_user->get('id') && $this->_user->authorise('joom.upload.inown', _JOOM_OPTION . '.category.' . $category->cid))) {
             $categories[$key]->show_upload_icon = true;
             JHtml::_('behavior.modal');
         }
         $categories[$key]->event = new stdClass();
         // Additional HTML added by plugins
         $results = $this->_mainframe->triggerEvent('onJoomAfterDisplayCatThumb', array($category->cid));
         $categories[$key]->event->afterDisplayCatThumb = trim(implode('', $results));
         /*// Additional icons added by plugins
           $results  = $this->_mainframe->triggerEvent('onJoomDisplayIcons', array('category.category', $category));
           $categories[$key]->event->icons                 = trim(implode('', $results));*/
     }
     // Download icon
     if ($this->_config->get('jg_download') && $this->_config->get('jg_showcategorydownload')) {
         if ($this->_user->get('id') || $this->_config->get('jg_download_unreg')) {
             $params->set('show_download_icon', 1);
         } else {
             if ($this->_config->get('jg_download_hint')) {
                 $params->set('show_download_icon', -1);
             }
         }
     }
     // Favourites icon
     if (!$params->get('disable_global_info') && $this->_config->get('jg_favourites') && $this->_config->get('jg_showcategoryfavourite')) {
         if ($this->_user->get('id') || $this->_config->get('jg_usefavouritesforpubliczip') == 1 && !$this->_user->get('id')) {
             if ($this->_config->get('jg_usefavouritesforzip') || $this->_config->get('jg_usefavouritesforpubliczip') && !$this->_user->get('id')) {
                 $params->set('show_favourites_icon', 2);
             } else {
                 $params->set('show_favourites_icon', 1);
             }
         } else {
             if ($this->_config->get('jg_favouritesshownotauth') == 1) {
                 if ($this->_config->get('jg_usefavouritesforzip')) {
                     $params->set('show_favourites_icon', -2);
                 } else {
                     $params->set('show_favourites_icon', -1);
                 }
             }
         }
     }
     // Report icon
     if ($this->_config->get('jg_report_images') && $this->_config->get('jg_category_report_images')) {
         if ($this->_user->get('id') || $this->_config->get('jg_report_unreg')) {
             $params->set('show_report_icon', 1);
             JHTML::_('behavior.modal');
         } else {
             if ($this->_config->get('jg_report_hint')) {
                 $params->set('show_report_icon', -1);
             }
         }
     }
     foreach ($images as $key => $image) {
         $cropx = null;
         $cropy = null;
         $croppos = null;
         if ($this->_config->get('jg_dyncrop')) {
             $cropx = $this->_config->get('jg_dyncropwidth');
             $cropy = $this->_config->get('jg_dyncropheight');
             $croppos = $this->_config->get('jg_dyncropposition');
             $images[$key]->imgwh = 'width="' . $cropx . '" height="' . $cropy . '"';
         } else {
             // Get dimensions for width and height attribute in img tag
             $imgwh = getimagesize($this->_ambit->getImg('thumb_path', $image));
             $images[$key]->imgwh = $imgwh[3];
         }
         $images[$key]->thumb_src = $this->_ambit->getImg('thumb_url', $image, null, 0, true, $cropx, $cropy, $croppos);
         if ($this->_config->get('jg_showpicasnew')) {
             $images[$key]->isnew = JoomHelper::checkNew($image->imgdate, $this->_config->get('jg_daysnew'));
         }
         $images[$key]->link = JHTML::_('joomgallery.openimage', $this->_config->get('jg_detailpic_open'), $image);
         if ($this->_config->get('jg_showauthor')) {
             if ($image->imgauthor) {
                 $images[$key]->authorowner = $image->imgauthor;
             } else {
                 if ($this->_config->get('jg_showowner')) {
                     $images[$key]->authorowner = JHTML::_('joomgallery.displayname', $image->owner);
                 } else {
                     $images[$key]->authorowner = JText::_('COM_JOOMGALLERY_COMMON_NO_DATA');
                 }
             }
         }
         // Show editor links for that image
         $images[$key]->show_edit_icon = false;
         $images[$key]->show_delete_icon = false;
         if ($this->_config->get('jg_showcategoryeditorlinks') == 1 && $this->_config->get('jg_userspace') == 1) {
             if ($this->_user->authorise('core.edit', _JOOM_OPTION . '.image.' . $images[$key]->id) || $this->_user->authorise('core.edit.own', _JOOM_OPTION . '.image.' . $images[$key]->id) && $images[$key]->owner && $images[$key]->owner == $this->_user->get('id')) {
                 $images[$key]->show_edit_icon = true;
             }
             if ($this->_user->authorise('core.delete', _JOOM_OPTION . '.image.' . $images[$key]->id)) {
                 $images[$key]->show_delete_icon = true;
             }
         }
         // Set the title attribute in a tag with title and/or description of image
         // if a box is activated
         if (!is_numeric($this->_config->get('jg_detailpic_open')) || $this->_config->get('jg_detailpic_open') > 1) {
             $images[$key]->atagtitle = JHTML::_('joomgallery.getTitleforATag', $images[$key]);
         } else {
             // Set the imgtitle by default
             $images[$key]->atagtitle = 'title="' . $images[$key]->imgtitle . '"';
         }
         $images[$key]->event = new stdClass();
         // Additional HTML added by plugins
         $results = $this->_mainframe->triggerEvent('onJoomAfterDisplayThumb', array($image->id));
         $images[$key]->event->afterDisplayThumb = trim(implode('', $results));
         // Additional icons added by plugins
         $results = $this->_mainframe->triggerEvent('onJoomDisplayIcons', array('category.image', $image));
         $images[$key]->event->icons = trim(implode('', $results));
         // Check if there are any elements beside the image to be shown
         // if not deactivate the output of corresponding html tags in template
         // to avoid empty div/ul/li
         if (!$this->_config->get('jg_showtitle') && !$this->_config->get('jg_showpicasnew') && !$this->_config->get('jg_showhits') && !$this->_config->get('jg_showdownloads') && !$this->_config->get('jg_showauthor') && !$this->_config->get('jg_showcatcom') && !$this->_config->get('jg_showcatrate') && (!$this->_config->get('jg_showcatdescription') || $this->_config->get('jg_showcatdescription') && !$images[$key]->imgtext) && !$params->get('show_download_icon') && !$params->get('show_favourites_icon') && !$params->get('show_report_icon') && (!$this->_config->get('jg_showcategoryeditorlinks') || $this->_config->get('jg_showcategoryeditorlinks') && !$images[$key]->show_delete_icon && !$images[$key]->show_edit_icon) && !$images[$key]->event->afterDisplayThumb && !$images[$key]->event->icons) {
             $images[$key]->show_elems = false;
         } else {
             $images[$key]->show_elems = true;
         }
     }
     if ($this->_config->get('jg_cooliris') && count($images)) {
         $href = JRoute::_('index.php?view=category&catid=' . $cat->cid . '&page=' . $page . '&format=raw');
         $attribs = array('id' => 'gallery', 'type' => 'application/rss+xml', 'title' => 'Cooliris');
         $this->_doc->addHeadLink($href, 'alternate', 'rel', $attribs);
         if ($this->_config->get('jg_coolirislink')) {
             $this->_doc->addScript('http://lite.piclens.com/current/piclens.js');
         }
     }
     if ($this->_config->get('jg_usercatorder') && count($images)) {
         $orderby = $this->_mainframe->getUserStateFromRequest('joom.category.images.orderby', 'orderby');
         $orderdir = $this->_mainframe->getUserStateFromRequest('joom.category.images.orderdir', 'orderdir');
         // If subcategory navigation active insert current subcategory startpage
         if ($catpage > 1) {
             $sort_url = JRoute::_('index.php?view=category&catid=' . $cat->cid . '&catpage=' . $catpage) . JHTML::_('joomgallery.anchor', 'category');
         } else {
             $sort_url = JRoute::_('index.php?view=category&catid=' . $cat->cid) . JHTML::_('joomgallery.anchor', 'category');
         }
         $this->assignRef('sort_url', $sort_url);
         $this->assignRef('order_by', $orderby);
         $this->assignRef('order_dir', $orderdir);
     }
     // Set redirect url used in editor links to redirect back to favourites view after edit/delete
     $redirect = '&redirect=' . base64_encode(JFactory::getURI()->toString());
     $this->assignRef('params', $params);
     $this->assignRef('category', $cat);
     $this->assignRef('images', $images);
     $this->assignRef('categories', $categories);
     $this->assignRef('totalimages', $totalimages);
     $this->assignRef('totalpages', $totalpages);
     $this->assignRef('page', $page);
     $this->assignRef('totalcategories', $totalcategories);
     $this->assignRef('cattotalpages', $cattotalpages);
     $this->assignRef('catpage', $catpage);
     $this->assignRef('pathway', $pathway);
     $this->assignRef('modules', $modules);
     $this->assignRef('backtarget', $backlink[0]);
     $this->assignRef('backtext', $backlink[1]);
     $this->assignRef('numberofpics', $numbers[0]);
     $this->assignRef('numberofhits', $numbers[1]);
     $this->assignRef('redirect', $redirect);
     parent::display($tpl);
 }
Пример #23
0
 /**
  * Creates new folders for categories.
  *
  * @return  int/boolean Number of created folders on success, false otherwise
  * @since   1.5.5
  */
 public function create()
 {
     $cids = JRequest::getVar('cid', array(), '', 'array');
     $types = JRequest::getVar('type', array('thumb', 'img', 'orig'), '', 'array');
     if (!count($cids)) {
         $this->setError(JText::_('COM_JOOMGALLERY_COMMON_MSG_NO_CATEGORIES_SELECTED'));
         return false;
     }
     // Get selected category IDs
     $query = $this->_db->getQuery(true)->select('refid')->from($this->_db->qn(_JOOM_TABLE_MAINTENANCE))->where('id IN (' . implode(',', $cids) . ')')->where('type != 0');
     $this->_db->setQuery($query);
     if (!($ids = $this->_db->loadColumn())) {
         $this->setError($this->_db->getErrorMsg());
         return false;
     }
     $count = 0;
     foreach ($types as $type) {
         foreach ($ids as $cid) {
             // Create the folder
             $folder = $this->_ambit->get($type . '_path') . JoomHelper::getCatPath($cid);
             if (!JFolder::create($folder)) {
                 continue;
             }
             JoomFile::copyIndexHtml($folder);
             // Update maintenance table
             $query = $this->_db->getQuery(true)->update($this->_db->qn(_JOOM_TABLE_MAINTENANCE))->set($type . ' = ' . $this->_db->q($this->_db->escape($folder)))->where('refid = ' . $cid)->where('type != 0');
             $this->_db->setQuery($query);
             if (!$this->_db->query()) {
                 $this->setError($this->_db->getErrorMsg());
                 return false;
             }
             $count++;
         }
     }
     return $count;
 }
Пример #24
0
 /**
  * Add the page title and toolbar.
  *
  * @return  void
  *
  * @since 2.0
  */
 public function addToolbar()
 {
     // Get the results for each action
     $canDo = JoomHelper::getActions('category', $this->item->cid);
     $title = JText::_('COM_JOOMGALLERY_CATMAN_CATEGORY_MANAGER') . ' :: ';
     if ($this->isNew) {
         $title .= JText::_('COM_JOOMGALLERY_CATMAN_ADD_CATEGORY');
     } else {
         $title .= JText::_('COM_JOOMGALLERY_CATMAN_EDIT_CATEGORY');
     }
     $title .= ' ' . JText::_('COM_JOOMGALLERY_COMMON_CATEGORY');
     JToolBarHelper::title($title, 'folder');
     // For new categories check the create permission
     if ($this->isNew && ($this->_config->get('jg_disableunrequiredchecks') || $canDo->get('core.create') || count(JoomHelper::getAuthorisedCategories('core.create')))) {
         JToolBarHelper::apply('apply', 'JTOOLBAR_APPLY');
         JToolBarHelper::save('save', 'JTOOLBAR_SAVE');
         JToolBarHelper::custom('save2new', 'save-new.png', 'save-new_f2.png', 'JTOOLBAR_SAVE_AND_NEW', false);
     } else {
         if ($canDo->get('core.edit') || $canDo->get('core.edit.own') && $this->item->owner == $this->_user->get('id')) {
             JToolBarHelper::apply('apply', 'JTOOLBAR_APPLY');
             JToolBarHelper::save('save', 'JTOOLBAR_SAVE');
             if ($this->_config->get('jg_disableunrequiredchecks') || $canDo->get('core.create') || count(JoomHelper::getAuthorisedCategories('core.create'))) {
                 JToolBarHelper::save2new();
             }
         }
     }
     // If it's an already existing category a copy may be saved (only if creating categories is allowed)
     if (!$this->isNew && ($this->_config->get('jg_disableunrequiredchecks') || $canDo->get('core.create') || count(JoomHelper::getAuthorisedCategories('core.create')))) {
         JToolBarHelper::save2copy();
     }
     if ($this->isNew) {
         JToolBarHelper::cancel('cancel', 'JTOOLBAR_CANCEL');
     } else {
         JToolBarHelper::cancel('cancel', 'JTOOLBAR_CLOSE');
     }
     JToolbarHelper::spacer();
 }
Пример #25
0
 /**
  * Function to check whether a category has to be hidden because of JoomGallery's
  * backend setting for 'jg_hideemptycats'.
  *
  * @param    int      catid
  * @return   boolean  True if category has to be hidden
  */
 protected function hideCategory($catid)
 {
     $hide = false;
     if ($this->getJConfig('jg_hideemptycats')) {
         $subcatids = JoomHelper::getAllSubCategories($catid, true, $this->getJConfig('jg_hideemptycats') == 1, true, $this->getConfig('showhidden') == 0);
         // If 'jg_hideemptycats' is set to 1 the root category will always be in $subcatids, so check check
         // whether there are images in it
         if (!count($subcatids) || count($subcatids) == 1 && $this->getJConfig('jg_hideemptycats') == 1 && $this->allcategories[$catid]->piccount == 0) {
             $hide = true;
         }
     }
     return $hide;
 }
Пример #26
0
									<td><a href="<?php 
        echo $link;
        ?>
"><img src="index.php?option=com_joomgallery&view=image&format=raw&type=thumb&id=<?php 
        echo $order->image_id;
        ?>
" alt="" class="thumbnail"></a></td>
									<td><a href="<?php 
        echo $link;
        ?>
"><?php 
        echo $order->image_name;
        ?>
</a></td>
									<td><?php 
        echo JoomHelper::getAdditional($order->image_id, "code");
        ?>
</td>
									<td><?php 
        echo JHtml::_('date', $order->buy_date, 'H:i d-m-Y');
        ?>
</td>
									<td class="text-right strong-me"><?php 
        echo number_format($order->price, 0, ",", ".");
        ?>
</td>
								</tr>
								<?php 
    }
    ?>
							</tbody>
Пример #27
0
 /**
  * Retrieves the data for creating the orderings drop down list
  *
  * @param   int     $parent Parent category which has to be included into the list independent of it's access state
  * @return  array   An array of JHTML select options with the ordering numbers
  *                  and the category names
  * @since   1.5.7
  */
 public function getOrderings($parent = null)
 {
     if (empty($this->_orderings)) {
         $categories = JoomHelper::getAuthorisedCategories('core.create');
         $allowed_categories = '';
         // If the user is allowed to create main categories add '0' as an allowed parent category
         if ($this->_user->authorise('core.create', _JOOM_OPTION)) {
             $allowed_categories .= '1,';
         }
         foreach ($categories as $category) {
             $allowed_categories .= $category->cid . ',';
         }
         if (!is_null($parent)) {
             $allowed_categories .= $parent;
         } else {
             $allowed_categories = trim($allowed_categories, ',');
         }
         if (!$allowed_categories) {
             return array();
         }
         $query = $this->_db->getQuery(true);
         $query->select('cid')->select('parent_id')->select('name')->from(_JOOM_TABLE_CATEGORIES)->where('parent_id IN (' . $allowed_categories . ')')->where('lft > 0')->order('lft');
         $this->_db->setQuery($query);
         if (!($this->_orderings = $this->_db->loadObjectList())) {
             $this->setError($this->_db->getError());
             return array();
         }
     }
     return $this->_orderings;
 }
Пример #28
0
 /**
  * Moves image into another category
  * (The given image data is only stored in the database if old and new category are different from each other)
  *
  * @param   object  $item       Holds the data of the image to move, if it's not an object we will try to retrieve the data from the database
  * @param   int     $catid_new  The ID of the category to which the image should be moved
  * @param   int     $catid_old  The ID of the old category of the image
  * @return  boolean True on success, false otherwise
  * @since   1.5.5
  */
 public function moveImage($item, $catid_new, $catid_old = 0)
 {
     jimport('joomla.filesystem.file');
     // If we just have the image ID
     if (!is_object($item)) {
         $id = intval($item);
         $item = $this->getTable('joomgalleryimages');
         $item->load($id);
         $catid_old = $item->catid;
     }
     // If the image is already in the correct category return false, no message will be set
     if ($catid_new == $catid_old) {
         return false;
     }
     $catpath_old = JoomHelper::getCatPath($catid_old);
     $catpath_new = JoomHelper::getCatPath($catid_new);
     // Database query to check if there are other images which this
     // thumbnail is assigned to and how many of them exist
     $query = $this->_db->getQuery(true)->select('COUNT(id)')->from(_JOOM_TABLE_IMAGES)->where("imgthumbname  = '" . $item->imgthumbname . "'")->where('id != ' . $item->id)->where('catid = ' . $catid_old);
     $this->_db->setQuery($query);
     $thumb_count = $this->_db->loadResult();
     // Check if thumbnail already exists in source directory and
     // if it doesn't already exist in destination directory.
     // If that's the case the file will not be copied.
     $thumb_created = false;
     $thumb_source = $this->_ambit->get('thumb_path') . $catpath_old . $item->imgthumbname;
     $thumb_dest = $this->_ambit->get('thumb_path') . $catpath_new . $item->imgthumbname;
     if (JFile::exists($thumb_dest)) {
         JError::raiseNotice(0, JText::_('COM_JOOMGALLERY_COMMON_DEST_THUMB_ALREADY_EXISTS'));
         if ($thumb_count && JFile::exists($thumb_source)) {
             JFile::delete($thumb_source);
         }
     } else {
         if (!JFile::exists($thumb_source)) {
             JError::raiseWarning(500, JText::sprintf('COM_JOOMGALLERY_COMMON_SOURCE_THUMB_NOT_EXISTS', $thumb_source));
             return false;
         } else {
             // If there is no image remaining in source directory
             // which uses the file
             if (!$thumb_count) {
                 // Move the thumbnail
                 $result = JFile::move($thumb_source, $thumb_dest);
             } else {
                 // Otherwise just copy the thumbnail in order that it remains in the source directory
                 $result = JFile::copy($thumb_source, $thumb_dest);
             }
             // If not succesful raise an error message and abort
             if (!$result) {
                 JError::raiseWarning(100, JText::sprintf('COM_JOOMGALLERY_COULD_NOT_MOVE_THUMB', JPath::clean($thumb_dest)));
                 return false;
             }
             // Set control variable according to the successful move/copy procedure
             $thumb_created = true;
         }
     }
     // Database query to check if there are other images which this
     // file is assigned to and how many of them exist
     $query->clear('where')->where("imgfilename = '" . $item->imgfilename . "'")->where('id != ' . $item->id)->where('catid = ' . $catid_old);
     $this->_db->setQuery($query);
     $img_count = $this->_db->loadResult();
     // Same procedure with the detail image
     // In case of error roll previous copy/move procedure back
     $img_created = false;
     $img_source = $this->_ambit->get('img_path') . $catpath_old . $item->imgfilename;
     $img_dest = $this->_ambit->get('img_path') . $catpath_new . $item->imgfilename;
     if (JFile::exists($img_dest)) {
         JError::raiseNotice(0, JText::_('COM_JOOMGALLERY_COMMON_DEST_IMG_ALREADY_EXISTS'));
         if ($img_count && JFile::exists($img_source)) {
             JFile::delete($img_source);
         }
     } else {
         if (!JFile::exists($img_source)) {
             JError::raiseWarning(500, JText::sprintf('COM_JOOMGALLERY_COMMON_SOURCE_IMG_NOT_EXISTS', $img_source));
             return false;
         } else {
             if (!$img_count) {
                 $result = JFile::move($img_source, $img_dest);
             } else {
                 $result = JFile::copy($img_source, $img_dest);
             }
             if (!$result) {
                 if ($thumb_created) {
                     if (!$thumb_count) {
                         JFile::move($thumb_dest, $thumb_source);
                     } else {
                         JFile::delete($thumb_dest);
                     }
                 }
                 JError::raiseWarning(100, JText::sprintf('COM_JOOMGALLERY_COULD_NOT_MOVE_IMG', JPath::clean($img_dest)));
                 return false;
             }
             // Set control variable according to the successful move/copy procedure
             $img_created = true;
         }
     }
     // Go on with original image
     $orig_source = $this->_ambit->get('orig_path') . $catpath_old . $item->imgfilename;
     $orig_dest = $this->_ambit->get('orig_path') . $catpath_new . $item->imgfilename;
     if (JFile::exists($orig_dest)) {
         JError::raiseNotice(0, JText::_('COM_JOOMGALLERY_COMMON_DEST_ORIG_ALREADY_EXISTS'));
         if ($img_count && JFile::exists($orig_source)) {
             JFile::delete($orig_source);
         }
     } else {
         if (JFile::exists($orig_source)) {
             if (!$img_count) {
                 $result = JFile::move($orig_source, $orig_dest);
             } else {
                 $result = JFile::copy($orig_source, $orig_dest);
             }
             if (!$result) {
                 if ($thumb_created) {
                     if (!$thumb_count) {
                         JFile::move($thumb_dest, $thumb_source);
                     } else {
                         JFile::delete($thumb_dest);
                     }
                 }
                 if ($img_created) {
                     if (!$img_count) {
                         JFile::move($img_dest, $img_source);
                     } else {
                         JFile::delete($img_dest);
                     }
                 }
                 JError::raiseWarning(100, JText::sprintf('COM_JOOMGALLERY_COULD_NOT_MOVE_ORIGINAL', JPath::clean($orig_dest)));
                 return false;
             }
         }
     }
     // If all folder operations for the image were successful
     // modify the database entry
     $item->catid = $catid_new;
     $item->ordering = $item->getNextOrder('catid = ' . $catid_new);
     // Make sure the record is valid
     if (!$item->check()) {
         JError::raiseWarning($item->getError());
         return false;
     }
     // Store the entry to the database
     if (!$item->store()) {
         JError::raiseWarning($item->getError());
         return false;
     }
     return true;
 }
Пример #29
0
 /**
  * Returns the URL or the path to an image
  *
  * @param   string            $type   The type of the URL or path
  * @param   string/object/int $img    Filename, database object or ID of the image
  * @param   int               $catid  The ID of the category in which the image is stored
  * @return  string            The URL or the path to the image
  * @since   1.5.5
  */
 public function getImg($type, $img, $id = 0, $catid = 0)
 {
     $types = array('thumb_path', 'thumb_url', 'img_path', 'img_url', 'orig_path', 'orig_url');
     if (!in_array($type, $types)) {
         JError::raiseError(500, JText::sprintf('Wrong image type: %s', $type));
     }
     if (!is_object($img)) {
         if (is_numeric($img)) {
             $img = $this->getImgObject($img);
         } else {
             if (!is_null($id)) {
                 $img = $this->getImgObject($id);
             }
         }
     }
     if (is_object($img)) {
         $id = $img->id;
         $catid = $img->catid;
         if ($type == 'thumb_path' || $type == 'thumb_url') {
             $img = $img->imgthumbname;
         } else {
             $img = $img->imgfilename;
         }
     }
     // Check whether the image shall be output through the PHP script or with its real path
     if (strpos($type, 'url') && ($this->_external[str_replace('_url', '', $type)] || strpos($type, 'img') !== false || strpos($type, 'orig') !== false)) {
         $type = str_replace('_url', '', $type);
         return JRoute::_('index.php?option=' . _JOOM_OPTION . '&controller=images&view=image&format=raw&type=' . $type . '&cid=' . $id);
     }
     $catpath = JoomHelper::getCatPath($catid);
     // Create the complete path
     $img = $this->{$type} . $catpath . $img;
     if (strpos($type, 'path')) {
         $img = JPath::clean($img);
     }
     return $img;
 }
Пример #30
0
 /**
  * Creates the path to a category which can be displayed
  *
  * @param   int     $catid      The category ID
  * @param   boolean $child      True, if category itself shall also be included, defaults to true
  * @param   string  $separator  The separator
  * @param   boolean $linked     True if elements shall be linked, defaults to false
  * @param   boolean $with_home  True if the home link shall be included, defaults to false
  * @param   boolean $all        True if all categories shall be shown defaults to false
  * @return  string  The HTML output
  * @since   1.5.5
  */
 public static function categoryPath(&$catid, $child = true, $separator = ' &raquo; ', &$linked = false, &$with_home = false, $all = false)
 {
     // Maybe this path was already generated
     static $catPaths = array();
     if (isset($catPaths[$catid])) {
         return $catPaths[$catid];
     }
     $path = '';
     $catid = intval($catid);
     $user = JFactory::getUser();
     $ambit = JoomAmbit::getInstance();
     $allowed_categories = $ambit->getCategoryStructure();
     // Get category and their parents
     $pathCats = JoomHelper::getAllParentCategories($catid, $child, $all);
     $count = count($pathCats);
     if (!$count) {
         return $path;
     }
     // Construct the HTML
     if ($count == 1) {
         $category = reset($pathCats);
         // Link to category only if category published
         if ($linked && isset($allowed_categories[$catid])) {
             $path = '<a href="' . JRoute::_('index.php?view=category&catid=' . $catid) . '" class="jg_pathitem">' . $category->name . '</a>';
         } else {
             $path = $category->name;
         }
     } else {
         // Reindex the array with index from 0 to n
         $pathCatsidx = array_values($pathCats);
         // First element
         if ($linked && isset($allowed_categories[$pathCatsidx[0]->cid])) {
             $path = '<a href="' . JRoute::_('index.php?view=category&catid=' . $pathCatsidx[0]->cid) . '" class="jg_pathitem">' . $pathCatsidx[0]->name . '</a>';
         } else {
             $path = $pathCatsidx[0]->name;
         }
         for ($i = 1; $i < $count; $i++) {
             if ($linked && isset($allowed_categories[$pathCatsidx[$i]->cid])) {
                 $path .= $separator . '<a href="' . JRoute::_('index.php?view=category&catid=' . $pathCatsidx[$i]->cid) . '" class="jg_pathitem">' . $pathCatsidx[$i]->name . '</a>';
             } else {
                 $path .= $separator . $pathCatsidx[$i]->name;
             }
         }
     }
     if ($with_home) {
         $home = '<a href="' . JRoute::_('index.php?view=gallery') . '" class="jg_pathitem">' . JText::_('COM_JOOMGALLERY_COMMON_HOME') . '</a>';
         $path = $home . $separator . $path . ' ';
     }
     // Store it for later use
     $catPaths[$catid] = $path;
     return $path;
 }