/** * 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'); } } } }
/** * Installs a new extension for JoomGallery * * The cURL library needs to be installed on the server for this. * * @access public * @return void * @since 1.5.5 */ function install() { $extension = JRequest::getCmd('extension', 0, 'get'); $extensions = JoomExtensions::getAvailableExtensions(); if (!isset($extensions[$extension]['updatelink']) || !extension_loaded('curl')) { $this->setRedirect('index.php?option=' . _JOOM_OPTION, JText::_('COM_JOOMGALLERY_ADMENU_MSG_ERROR_FETCHING_ZIP'), 'error'); } else { JoomExtensions::autoUpdate($extensions[$extension]['updatelink']); } }
/** * Installs a new language package for JoomGallery * * The cURL library needs to be installed on the server for this. * * @access public * @return void * @since 1.5.5 */ function install() { $language = JRequest::getCmd('language', 0, 'get'); if (!$this->_config->get('jg_checkupdate') || !$language || !extension_loaded('curl')) { $link = base64_decode(JRequest::getCmd('downloadlink')); $this->setRedirect($this->_ambit->getRedirectUrl(), JText::sprintf('COM_JOOMGALLERY_ADMENU_MSG_ERROR_FETCHING_LANGUAGE_ZIP', $link), 'error'); } else { $extensions = JoomExtensions::getAvailableExtensions(); $url = $extensions['JoomGallery']['updatelink']; $url = substr($url, 0, strrpos($url, '/') + 1); $url = str_replace('component/', '', $url); $url .= 'languages/' . $language . '.com_joomgallery.zip'; JoomExtensions::autoUpdate($url); } }
/** * 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); }
/** * Constructor * * Presets all variables * * @access protected * @return void * @since 1.5.5 */ function __construct() { jimport('joomla.filesystem.folder'); $config = JoomConfig::getInstance(); $mainframe = JFactory::getApplication('administrator'); // Fill all variables $this->icon_url = JURI::root() . 'media/joomgallery/images/'; $this->css_url = JURI::root() . 'media/joomgallery/css/'; $this->js_url = JURI::root() . 'media/joomgallery/js/'; $this->_external['thumb'] = false; $this->thumb_url = JURI::root() . $config->get('jg_paththumbs'); $this->thumb_path = JPath::clean(JPATH_ROOT . '/' . $config->get('jg_paththumbs')); if (!JFolder::exists($this->thumb_path)) { $this->_external['thumb'] = true; $this->thumb_url = ''; $this->thumb_path = JPath::clean($config->get('jg_paththumbs')); } $this->_external['img'] = false; $this->img_url = JURI::root() . $config->get('jg_pathimages'); $this->img_path = JPath::clean(JPATH_ROOT . '/' . $config->get('jg_pathimages')); if (!JFolder::exists($this->img_path)) { $this->_external['img'] = true; $this->img_url = ''; $this->img_path = JPath::clean($config->get('jg_pathimages')); } $this->_external['orig'] = false; $this->orig_url = JURI::root() . $config->get('jg_pathoriginalimages'); $this->orig_path = JPath::clean(JPATH_ROOT . '/' . $config->get('jg_pathoriginalimages')); if (!JFolder::exists($this->orig_path)) { $this->_external['orig'] = true; $this->orig_url = ''; $this->orig_path = JPath::clean($config->get('jg_pathoriginalimages')); } $this->temp_path = JPath::clean(JPATH_ROOT . '/' . $config->get('jg_pathtemp')); if (!JFolder::exists($this->temp_path)) { $this->temp_path = JPath::clean($config->get('jg_pathtemp')); } $this->ftp_path = JPath::clean(JPATH_ROOT . '/' . $config->get('jg_pathftpupload')); if (!JFolder::exists($this->ftp_path)) { $this->ftp_path = JPath::clean($config->get('jg_pathftpupload')); } $this->wtm_path = JPath::clean(JPATH_ROOT . '/' . $config->get('jg_wmpath')); if (!JFolder::exists($this->wtm_path)) { $this->wtm_path = JPath::clean($config->get('jg_wmpath')); } if (!($this->version = $mainframe->getUserState('joom.version.string'))) { $this->version = JoomExtensions::getGalleryVersion(); $mainframe->setUserState('joom.version.string', $this->version); } }
/** * Returns the currently installed version of JoomGallery * * @return string Version * @since 1.5.0 */ public static function getGalleryVersion() { static $version; if (!isset($version)) { $config = JoomConfig::getInstance(); $version_from_xml = true; // Do not read RSS file if update check is disabled if ($config->get('jg_checkupdate')) { $version_from_xml = false; $mainframe = JFactory::getApplication('administrator'); if (!($version = $mainframe->getUserState('joom.version.string'))) { $extensions = JoomExtensions::getInstalledExtensions(); if (isset($extensions['JoomGallery']['installed_version'])) { $version = $extensions['JoomGallery']['installed_version']; } else { $version_from_xml = true; } $mainframe->setUserState('joom.version.string', $version); } } if ($version_from_xml) { $xml_file = JPATH_ADMINISTRATOR . '/components/com_joomgallery/joomgallery.xml'; if (file_exists($xml_file)) { $xml = simplexml_load_file($xml_file); if (!isset($xml->version)) { $version = 'not found'; } else { $version = (string) $xml->version; } } } } return $version; }