first commit

This commit is contained in:
alazhar
2020-01-02 22:20:31 +07:00
commit 10eb3340ad
5753 changed files with 631345 additions and 0 deletions

View File

@ -0,0 +1,247 @@
<?php
/**
* @package Joomla.Administrator
* @subpackage com_installer
*
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('_JEXEC') or die;
JLoader::register('InstallerModel', __DIR__ . '/extension.php');
JLoader::register('JoomlaInstallerScript', JPATH_ADMINISTRATOR . '/components/com_admin/script.php');
/**
* Installer Manage Model
*
* @package Joomla.Administrator
* @subpackage com_installer
* @since 1.6
*/
class InstallerModelDatabase extends InstallerModel
{
protected $_context = 'com_installer.discover';
/**
* Method to auto-populate the model state.
*
* Note. Calling getState in this method will result in recursion.
*
* @param string $ordering An optional ordering field.
* @param string $direction An optional direction (asc|desc).
*
* @return void
*
* @since 1.6
*/
protected function populateState($ordering = null, $direction = null)
{
$app = JFactory::getApplication();
$this->setState('message', $app->getUserState('com_installer.message'));
$this->setState('extension_message', $app->getUserState('com_installer.extension_message'));
$app->setUserState('com_installer.message', '');
$app->setUserState('com_installer.extension_message', '');
parent::populateState('name', 'asc');
}
/**
* Fixes database problems
*
* @return void
*/
public function fix()
{
if (!$changeSet = $this->getItems())
{
return false;
}
$changeSet->fix();
$this->fixSchemaVersion($changeSet);
$this->fixUpdateVersion();
$installer = new JoomlaInstallerScript;
$installer->deleteUnexistingFiles();
$this->fixDefaultTextFilters();
}
/**
* Gets the changeset object
*
* @return JSchemaChangeset
*/
public function getItems()
{
$folder = JPATH_ADMINISTRATOR . '/components/com_admin/sql/updates/';
try
{
$changeSet = JSchemaChangeset::getInstance(JFactory::getDbo(), $folder);
}
catch (RuntimeException $e)
{
JFactory::getApplication()->enqueueMessage($e->getMessage(), 'warning');
return false;
}
return $changeSet;
}
/**
* Method to get a JPagination object for the data set.
*
* @return boolean
*
* @since 12.2
*/
public function getPagination()
{
return true;
}
/**
* Get version from #__schemas table
*
* @return mixed the return value from the query, or null if the query fails
*
* @throws Exception
*/
public function getSchemaVersion()
{
$db = JFactory::getDbo();
$query = $db->getQuery(true)
->select('version_id')
->from($db->quoteName('#__schemas'))
->where('extension_id = 700');
$db->setQuery($query);
$result = $db->loadResult();
return $result;
}
/**
* Fix schema version if wrong
*
* @param JSchemaChangeSet $changeSet Schema change set
*
* @return mixed string schema version if success, false if fail
*/
public function fixSchemaVersion($changeSet)
{
// Get correct schema version -- last file in array
$schema = $changeSet->getSchema();
$db = JFactory::getDbo();
$result = false;
// Check value. If ok, don't do update
$version = $this->getSchemaVersion();
if ($version == $schema)
{
$result = $version;
}
else
{
// Delete old row
$query = $db->getQuery(true)
->delete($db->quoteName('#__schemas'))
->where($db->quoteName('extension_id') . ' = 700');
$db->setQuery($query);
$db->execute();
// Add new row
$query->clear()
->insert($db->quoteName('#__schemas'))
->set($db->quoteName('extension_id') . '= 700')
->set($db->quoteName('version_id') . '= ' . $db->quote($schema));
$db->setQuery($query);
if ($db->execute())
{
$result = $schema;
}
}
return $result;
}
/**
* Get current version from #__extensions table
*
* @return mixed version if successful, false if fail
*/
public function getUpdateVersion()
{
$table = JTable::getInstance('Extension');
$table->load('700');
$cache = new JRegistry($table->manifest_cache);
return $cache->get('version');
}
/**
* Fix Joomla version in #__extensions table if wrong (doesn't equal JVersion short version)
*
* @return mixed string update version if success, false if fail
*/
public function fixUpdateVersion()
{
$table = JTable::getInstance('Extension');
$table->load('700');
$cache = new JRegistry($table->manifest_cache);
$updateVersion = $cache->get('version');
$cmsVersion = new JVersion;
if ($updateVersion == $cmsVersion->getShortVersion())
{
return $updateVersion;
}
else
{
$cache->set('version', $cmsVersion->getShortVersion());
$table->manifest_cache = $cache->toString();
if ($table->store())
{
return $cmsVersion->getShortVersion();
}
else
{
return false;
}
}
}
/**
* For version 2.5.x only
* Check if com_config parameters are blank.
*
* @return string default text filters (if any)
*/
public function getDefaultTextFilters()
{
$table = JTable::getInstance('Extension');
$table->load($table->find(array('name' => 'com_config')));
return $table->params;
}
/**
* For version 2.5.x only
* Check if com_config parameters are blank. If so, populate with com_content text filters.
*
* @return mixed boolean true if params are updated, null otherwise
*/
public function fixDefaultTextFilters()
{
$table = JTable::getInstance('Extension');
$table->load($table->find(array('name' => 'com_config')));
// Check for empty $config and non-empty content filters
if (!$table->params)
{
// Get filters from com_content and store if you find them
$contentParams = JComponentHelper::getParams('com_content');
if ($contentParams->get('filters'))
{
$newParams = new JRegistry;
$newParams->set('filters', $contentParams->get('filters'));
$table->params = (string) $newParams;
$table->store();
return true;
}
}
}
}

View File

@ -0,0 +1,180 @@
<?php
/**
* @package Joomla.Administrator
* @subpackage com_installer
*
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('_JEXEC') or die;
require_once __DIR__ . '/extension.php';
/**
* Installer Manage Model
*
* @package Joomla.Administrator
* @subpackage com_installer
* @since 1.6
*/
class InstallerModelDiscover extends InstallerModel
{
protected $_context = 'com_installer.discover';
/**
* Method to auto-populate the model state.
*
* Note. Calling getState in this method will result in recursion.
*
* @param string $ordering An optional ordering field.
* @param string $direction An optional direction (asc|desc).
*
* @return void
*
* @since 1.6
*/
protected function populateState($ordering = null, $direction = null)
{
$app = JFactory::getApplication();
$this->setState('message', $app->getUserState('com_installer.message'));
$this->setState('extension_message', $app->getUserState('com_installer.extension_message'));
$app->setUserState('com_installer.message', '');
$app->setUserState('com_installer.extension_message', '');
parent::populateState('name', 'asc');
}
/**
* Method to get the database query.
*
* @return JDatabaseQuery the database query
*
* @since 1.6
*/
protected function getListQuery()
{
$db = JFactory::getDbo();
$query = $db->getQuery(true)
->select('*')
->from('#__extensions')
->where('state=-1');
return $query;
}
/**
* Discover extensions.
*
* Finds uninstalled extensions
*
* @return void
*
* @since 1.6
*/
public function discover()
{
// Purge the list of discovered extensions
$this->purge();
$installer = JInstaller::getInstance();
$results = $installer->discover();
// Get all templates, including discovered ones
$db = JFactory::getDbo();
$query = $db->getQuery(true)
->select('extension_id, element, folder, client_id, type')
->from('#__extensions');
$db->setQuery($query);
$installedtmp = $db->loadObjectList();
$extensions = array();
foreach ($installedtmp as $install)
{
$key = implode(':', array($install->type, $install->element, $install->folder, $install->client_id));
$extensions[$key] = $install;
}
unset($installedtmp);
foreach ($results as $result)
{
// Check if we have a match on the element
$key = implode(':', array($result->type, $result->element, $result->folder, $result->client_id));
if (!array_key_exists($key, $extensions))
{
// Put it into the table
$result->store();
}
}
}
/**
* Installs a discovered extension.
*
* @return void
*
* @since 1.6
*/
public function discover_install()
{
$app = JFactory::getApplication();
$installer = JInstaller::getInstance();
$eid = JRequest::getVar('cid', 0);
if (is_array($eid) || $eid)
{
if (!is_array($eid))
{
$eid = array($eid);
}
JArrayHelper::toInteger($eid);
$app = JFactory::getApplication();
$failed = false;
foreach ($eid as $id)
{
$result = $installer->discover_install($id);
if (!$result)
{
$failed = true;
$app->enqueueMessage(JText::_('COM_INSTALLER_MSG_DISCOVER_INSTALLFAILED') . ': ' . $id);
}
}
$this->setState('action', 'remove');
$this->setState('name', $installer->get('name'));
$app->setUserState('com_installer.message', $installer->message);
$app->setUserState('com_installer.extension_message', $installer->get('extension_message'));
if (!$failed)
{
$app->enqueueMessage(JText::_('COM_INSTALLER_MSG_DISCOVER_INSTALLSUCCESSFUL'));
}
}
else
{
$app->enqueueMessage(JText::_('COM_INSTALLER_MSG_DISCOVER_NOEXTENSIONSELECTED'));
}
}
/**
* Cleans out the list of discovered extensions.
*
* @return bool True on success
*
* @since 1.6
*/
public function purge()
{
$db = JFactory::getDbo();
$query = $db->getQuery(true)
->delete('#__extensions')
->where('state = -1');
$db->setQuery($query);
if ($db->execute())
{
$this->_message = JText::_('COM_INSTALLER_MSG_DISCOVER_PURGEDDISCOVEREDEXTENSIONS');
return true;
}
else
{
$this->_message = JText::_('COM_INSTALLER_MSG_DISCOVER_FAILEDTOPURGEEXTENSIONS');
return false;
}
}
}

View File

@ -0,0 +1,191 @@
<?php
/**
* @package Joomla.Administrator
* @subpackage com_installer
*
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('_JEXEC') or die;
/**
* Extension Manager Abstract Extension Model
*
* @abstract
* @package Joomla.Administrator
* @subpackage com_installer
* @since 1.5
*/
class InstallerModel extends JModelList
{
/**
* Constructor.
*
* @param array $config An optional associative array of configuration settings.
*
* @see JController
* @since 1.6
*/
public function __construct($config = array())
{
if (empty($config['filter_fields']))
{
$config['filter_fields'] = array(
'name',
'client_id',
'enabled',
'type',
'folder',
'extension_id',
);
}
parent::__construct($config);
}
/**
* Returns an object list
*
* @param string $query The query
* @param int $limitstart Offset
* @param int $limit The number of records
*
* @return array
*/
protected function _getList($query, $limitstart = 0, $limit = 0)
{
$ordering = $this->getState('list.ordering');
$search = $this->getState('filter.search');
// Replace slashes so preg_match will work
$search = str_replace('/', ' ', $search);
$db = $this->getDbo();
if ($ordering == 'name' || (!empty($search) && stripos($search, 'id:') !== 0))
{
$db->setQuery($query);
$result = $db->loadObjectList();
$this->translate($result);
if (!empty($search))
{
foreach ($result as $i => $item)
{
if (!preg_match("/$search/i", $item->name))
{
unset($result[$i]);
}
}
}
JArrayHelper::sortObjects($result, $this->getState('list.ordering'), $this->getState('list.direction') == 'desc' ? -1 : 1, true, true);
$total = count($result);
$this->cache[$this->getStoreId('getTotal')] = $total;
if ($total < $limitstart)
{
$limitstart = 0;
$this->setState('list.start', 0);
}
return array_slice($result, $limitstart, $limit ? $limit : null);
}
else
{
$query->order($db->quoteName($ordering) . ' ' . $this->getState('list.direction'));
$result = parent::_getList($query, $limitstart, $limit);
$this->translate($result);
return $result;
}
}
/**
* Translate a list of objects
*
* @param array &$items The array of objects
*
* @return array The array of translated objects
*/
private function translate(&$items)
{
$lang = JFactory::getLanguage();
foreach ($items as &$item)
{
if (strlen($item->manifest_cache))
{
$data = json_decode($item->manifest_cache);
if ($data)
{
foreach ($data as $key => $value)
{
if ($key == 'type')
{
// Ignore the type field
continue;
}
$item->$key = $value;
}
}
}
$item->author_info = @$item->authorEmail . '<br />' . @$item->authorUrl;
$item->client = $item->client_id ? JText::_('JADMINISTRATOR') : JText::_('JSITE');
$path = $item->client_id ? JPATH_ADMINISTRATOR : JPATH_SITE;
switch ($item->type)
{
case 'component':
$extension = $item->element;
$source = JPATH_ADMINISTRATOR . '/components/' . $extension;
$lang->load("$extension.sys", JPATH_ADMINISTRATOR, null, false, false)
|| $lang->load("$extension.sys", $source, null, false, false)
|| $lang->load("$extension.sys", JPATH_ADMINISTRATOR, $lang->getDefault(), false, false)
|| $lang->load("$extension.sys", $source, $lang->getDefault(), false, false);
break;
case 'file':
$extension = 'files_' . $item->element;
$lang->load("$extension.sys", JPATH_SITE, null, false, false)
|| $lang->load("$extension.sys", JPATH_SITE, $lang->getDefault(), false, false);
break;
case 'library':
$extension = 'lib_' . $item->element;
$lang->load("$extension.sys", JPATH_SITE, null, false, false)
|| $lang->load("$extension.sys", JPATH_SITE, $lang->getDefault(), false, false);
break;
case 'module':
$extension = $item->element;
$source = $path . '/modules/' . $extension;
$lang->load("$extension.sys", $path, null, false, false)
|| $lang->load("$extension.sys", $source, null, false, false)
|| $lang->load("$extension.sys", $path, $lang->getDefault(), false, false)
|| $lang->load("$extension.sys", $source, $lang->getDefault(), false, false);
break;
case 'package':
$extension = $item->element;
$lang->load("$extension.sys", JPATH_SITE, null, false, false)
|| $lang->load("$extension.sys", JPATH_SITE, $lang->getDefault(), false, false);
break;
case 'plugin':
$extension = 'plg_' . $item->folder . '_' . $item->element;
$source = JPATH_PLUGINS . '/' . $item->folder . '/' . $item->element;
$lang->load("$extension.sys", JPATH_ADMINISTRATOR, null, false, false)
|| $lang->load("$extension.sys", $source, null, false, false)
|| $lang->load("$extension.sys", JPATH_ADMINISTRATOR, $lang->getDefault(), false, false)
|| $lang->load("$extension.sys", $source, $lang->getDefault(), false, false);
break;
case 'template':
$extension = 'tpl_' . $item->element;
$source = $path . '/templates/' . $item->element;
$lang->load("$extension.sys", $path, null, false, false)
|| $lang->load("$extension.sys", $source, null, false, false)
|| $lang->load("$extension.sys", $path, $lang->getDefault(), false, false)
|| $lang->load("$extension.sys", $source, $lang->getDefault(), false, false);
break;
}
if (!in_array($item->type, array('language', 'template', 'library')))
{
$item->name = JText::_($item->name);
}
settype($item->description, 'string');
if (!in_array($item->type, array('language')))
{
$item->description = JText::_($item->description);
}
}
}
}

View File

@ -0,0 +1 @@
<!DOCTYPE html><title></title>

View File

@ -0,0 +1,276 @@
<?php
/**
* @package Joomla.Administrator
* @subpackage com_installer
*
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('_JEXEC') or die;
/**
* Extension Manager Install Model
*
* @package Joomla.Administrator
* @subpackage com_installer
* @since 1.5
*/
class InstallerModelInstall extends JModelLegacy
{
/**
* @var object JTable object
*/
protected $_table = null;
/**
* @var object JTable object
*/
protected $_url = null;
/**
* Model context string.
*
* @var string
*/
protected $_context = 'com_installer.install';
/**
* Method to auto-populate the model state.
*
* Note. Calling getState in this method will result in recursion.
*
* @return void
*
* @since 1.6
*/
protected function populateState()
{
$app = JFactory::getApplication('administrator');
$this->setState('message', $app->getUserState('com_installer.message'));
$this->setState('extension_message', $app->getUserState('com_installer.extension_message'));
$app->setUserState('com_installer.message', '');
$app->setUserState('com_installer.extension_message', '');
// Recall the 'Install from Directory' path.
$path = $app->getUserStateFromRequest($this->_context . '.install_directory', 'install_directory', $app->getCfg('tmp_path'));
$this->setState('install.directory', $path);
parent::populateState();
}
/**
* Install an extension from either folder, url or upload.
*
* @return boolean result of install
*
* @since 1.5
*/
public function install()
{
$this->setState('action', 'install');
// Set FTP credentials, if given.
JClientHelper::setCredentialsFromRequest('ftp');
$app = JFactory::getApplication();
switch ($app->input->getWord('installtype'))
{
case 'folder':
// Remember the 'Install from Directory' path.
$app->getUserStateFromRequest($this->_context . '.install_directory', 'install_directory');
$package = $this->_getPackageFromFolder();
break;
case 'upload':
$package = $this->_getPackageFromUpload();
break;
case 'url':
$package = $this->_getPackageFromUrl();
break;
default:
$app->setUserState('com_installer.message', JText::_('COM_INSTALLER_NO_INSTALL_TYPE_FOUND'));
return false;
break;
}
// Was the package unpacked?
if (!$package)
{
$app->setUserState('com_installer.message', JText::_('COM_INSTALLER_UNABLE_TO_FIND_INSTALL_PACKAGE'));
return false;
}
// Get an installer instance
$installer = JInstaller::getInstance();
// Install the package
if (!$installer->install($package['dir']))
{
// There was an error installing the package
$msg = JText::sprintf('COM_INSTALLER_INSTALL_ERROR', JText::_('COM_INSTALLER_TYPE_TYPE_' . strtoupper($package['type'])));
$result = false;
}
else
{
// Package installed sucessfully
$msg = JText::sprintf('COM_INSTALLER_INSTALL_SUCCESS', JText::_('COM_INSTALLER_TYPE_TYPE_' . strtoupper($package['type'])));
$result = true;
}
// Set some model state values
$app = JFactory::getApplication();
$app->enqueueMessage($msg);
$this->setState('name', $installer->get('name'));
$this->setState('result', $result);
$app->setUserState('com_installer.message', $installer->message);
$app->setUserState('com_installer.extension_message', $installer->get('extension_message'));
$app->setUserState('com_installer.redirect_url', $installer->get('redirect_url'));
// Cleanup the install files
if (!is_file($package['packagefile']))
{
$config = JFactory::getConfig();
$package['packagefile'] = $config->get('tmp_path') . '/' . $package['packagefile'];
}
JInstallerHelper::cleanupInstall($package['packagefile'], $package['extractdir']);
return $result;
}
/**
* Works out an installation package from a HTTP upload
*
* @return package definition or false on failure
*/
protected function _getPackageFromUpload()
{
// Get the uploaded file information
$userfile = JRequest::getVar('install_package', null, 'files', 'array');
// Make sure that file uploads are enabled in php
if (!(bool) ini_get('file_uploads'))
{
JError::raiseWarning('', JText::_('COM_INSTALLER_MSG_INSTALL_WARNINSTALLFILE'));
return false;
}
// Make sure that zlib is loaded so that the package can be unpacked
if (!extension_loaded('zlib'))
{
JError::raiseWarning('', JText::_('COM_INSTALLER_MSG_INSTALL_WARNINSTALLZLIB'));
return false;
}
// If there is no uploaded file, we have a problem...
if (!is_array($userfile))
{
JError::raiseWarning('', JText::_('COM_INSTALLER_MSG_INSTALL_NO_FILE_SELECTED'));
return false;
}
// Check if there was a problem uploading the file.
if ($userfile['error'] || $userfile['size'] < 1)
{
JError::raiseWarning('', JText::_('COM_INSTALLER_MSG_INSTALL_WARNINSTALLUPLOADERROR'));
return false;
}
// Build the appropriate paths
$config = JFactory::getConfig();
$tmp_dest = $config->get('tmp_path') . '/' . $userfile['name'];
$tmp_src = $userfile['tmp_name'];
// Move uploaded file
jimport('joomla.filesystem.file');
JFile::upload($tmp_src, $tmp_dest);
// Unpack the downloaded package file
$package = JInstallerHelper::unpack($tmp_dest);
return $package;
}
/**
* Install an extension from a directory
*
* @return array Package details or false on failure
*
* @since 1.5
*/
protected function _getPackageFromFolder()
{
$input = JFactory::getApplication()->input;
// Get the path to the package to install
$p_dir = $input->getString('install_directory');
$p_dir = JPath::clean($p_dir);
// Did you give us a valid directory?
if (!is_dir($p_dir))
{
JError::raiseWarning('', JText::_('COM_INSTALLER_MSG_INSTALL_PLEASE_ENTER_A_PACKAGE_DIRECTORY'));
return false;
}
// Detect the package type
$type = JInstallerHelper::detectType($p_dir);
// Did you give us a valid package?
if (!$type)
{
JError::raiseWarning('', JText::_('COM_INSTALLER_MSG_INSTALL_PATH_DOES_NOT_HAVE_A_VALID_PACKAGE'));
return false;
}
$package['packagefile'] = null;
$package['extractdir'] = null;
$package['dir'] = $p_dir;
$package['type'] = $type;
return $package;
}
/**
* Install an extension from a URL
*
* @return Package details or false on failure
*
* @since 1.5
*/
protected function _getPackageFromUrl()
{
$input = JFactory::getApplication()->input;
// Get the URL of the package to install
$url = $input->getString('install_url');
// Did you give us a URL?
if (!$url)
{
JError::raiseWarning('', JText::_('COM_INSTALLER_MSG_INSTALL_ENTER_A_URL'));
return false;
}
// Download the package at the URL given
$p_file = JInstallerHelper::downloadPackage($url);
// Was the package downloaded?
if (!$p_file)
{
JError::raiseWarning('', JText::_('COM_INSTALLER_MSG_INSTALL_INVALID_URL'));
return false;
}
$config = JFactory::getConfig();
$tmp_dest = $config->get('tmp_path');
// Unpack the downloaded package file
$package = JInstallerHelper::unpack($tmp_dest . '/' . $p_file);
return $package;
}
}

View File

@ -0,0 +1,278 @@
<?php
/**
* @package Joomla.Administrator
* @subpackage com_installer
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('_JEXEC') or die;
jimport('joomla.updater.update');
/**
* Languages Installer Model
*
* @package Joomla.Administrator
* @subpackage com_installer
* @since 2.5.7
*/
class InstallerModelLanguages extends JModelList
{
/**
* Constructor override, defines a white list of column filters.
*
* @param array $config An optional associative array of configuration settings.
*
* @since 2.5.7
*/
public function __construct($config = array())
{
if (empty($config['filter_fields']))
{
$config['filter_fields'] = array(
'update_id', 'update_id',
'name', 'name',
);
}
parent::__construct($config);
}
/**
* Method to get the available languages database query.
*
* @return JDatabaseQuery The database query
*
* @since 2.5.7
*/
protected function _getListQuery()
{
$db = JFactory::getDbo();
$query = $db->getQuery(true);
// Select the required fields from the updates table
$query->select('update_id, name, version, detailsurl, type')
->from('#__updates');
// This Where clause will avoid to list languages already installed.
$query->where('extension_id = 0');
// Filter by search in title
$search = $this->getState('filter.search');
if (!empty($search))
{
$search = $db->quote('%' . $db->escape($search, true) . '%');
$query->where('(name LIKE ' . $search . ')');
}
// Add the list ordering clause.
$listOrder = $this->state->get('list.ordering');
$orderDirn = $this->state->get('list.direction');
$query->order($db->escape($listOrder) . ' ' . $db->escape($orderDirn));
return $query;
}
/**
* Method to get a store id based on model configuration state.
*
* @param string $id A prefix for the store id.
*
* @return string A store id.
*
* @since 2.5.7
*/
protected function getStoreId($id = '')
{
// Compile the store id.
$id .= ':' . $this->getState('filter.search');
return parent::getStoreId($id);
}
/**
* Method to auto-populate the model state.
*
* Note. Calling getState in this method will result in recursion.
*
* @param string $ordering list order
* @param string $direction direction in the list
*
* @return void
*
* @since 2.5.7
*/
protected function populateState($ordering = 'name', $direction = 'asc')
{
$app = JFactory::getApplication();
$value = $app->getUserStateFromRequest($this->context . '.filter.search', 'filter_search');
$this->setState('filter.search', $value);
$this->setState('extension_message', $app->getUserState('com_installer.extension_message'));
parent::populateState($ordering, $direction);
}
/**
* Method to find available languages in the Accredited Languages Update Site.
*
* @param int $cache_timeout time before refreshing the cached updates
*
* @return bool
*
* @since 2.5.7
*/
public function findLanguages($cache_timeout = 0)
{
$updater = JUpdater::getInstance();
/*
* The following function uses extension_id 600, that is the english language extension id.
* In #__update_sites_extensions you should have 600 linked to the Accredited Translations Repo
*/
$updater->findUpdates(array(600), $cache_timeout);
return true;
}
/**
* Install languages in the system.
*
* @param array $lids array of language ids selected in the list
*
* @return bool
*
* @since 2.5.7
*/
public function install($lids)
{
$app = JFactory::getApplication();
$installer = JInstaller::getInstance();
// Loop through every selected language
foreach ($lids as $id)
{
// Loads the update database object that represents the language
$language = JTable::getInstance('update');
$language->load($id);
// Get the url to the XML manifest file of the selected language
$remote_manifest = $this->_getLanguageManifest($id);
if (!$remote_manifest)
{
// Could not find the url, the information in the update server may be corrupt
$message = JText::sprintf('COM_INSTALLER_MSG_LANGUAGES_CANT_FIND_REMOTE_MANIFEST', $language->name);
$message .= ' ' . JText::_('COM_INSTALLER_MSG_LANGUAGES_TRY_LATER');
$app->enqueueMessage($message);
continue;
}
// Based on the language XML manifest get the url of the package to download
$package_url = $this->_getPackageUrl($remote_manifest);
if (!$package_url)
{
// Could not find the url , maybe the url is wrong in the update server, or there is not internet access
$message = JText::sprintf('COM_INSTALLER_MSG_LANGUAGES_CANT_FIND_REMOTE_PACKAGE', $language->name);
$message .= ' ' . JText::_('COM_INSTALLER_MSG_LANGUAGES_TRY_LATER');
$app->enqueueMessage($message);
continue;
}
// Download the package to the tmp folder
$package = $this->_downloadPackage($package_url);
// Install the package
if (!$installer->install($package['dir']))
{
// There was an error installing the package
$message = JText::sprintf('COM_INSTALLER_INSTALL_ERROR', $language->name);
$message .= ' ' . JText::_('COM_INSTALLER_MSG_LANGUAGES_TRY_LATER');
$app->enqueueMessage($message);
continue;
}
// Package installed successfully
$app->enqueueMessage(JText::sprintf('COM_INSTALLER_INSTALL_SUCCESS', $language->name));
// Cleanup the install files in tmp folder
if (!is_file($package['packagefile']))
{
$config = JFactory::getConfig();
$package['packagefile'] = $config->get('tmp_path') . '/' . $package['packagefile'];
}
JInstallerHelper::cleanupInstall($package['packagefile'], $package['extractdir']);
// Delete the installed language from the list
$language->delete($id);
}
}
/**
* Gets the manifest file of a selected language from a the language list in a update server.
*
* @param int $uid the id of the language in the #__updates table
*
* @return string
*
* @since 2.5.7
*/
protected function _getLanguageManifest($uid)
{
$instance = JTable::getInstance('update');
$instance->load($uid);
return $instance->detailsurl;
}
/**
* Finds the url of the package to download.
*
* @param string $remote_manifest url to the manifest XML file of the remote package
*
* @return string|bool
*
* @since 2.5.7
*/
protected function _getPackageUrl( $remote_manifest )
{
$update = new JUpdate;
$update->loadFromXML($remote_manifest);
$package_url = trim($update->get('downloadurl', false)->_data);
return $package_url;
}
/**
* Download a language package from a URL and unpack it in the tmp folder.
*
* @param string $url hola
*
* @return array|bool Package details or false on failure
*
* @since 2.5.7
*/
protected function _downloadPackage($url)
{
// Download the package from the given URL
$p_file = JInstallerHelper::downloadPackage($url);
// Was the package downloaded?
if (!$p_file)
{
JError::raiseWarning('', JText::_('COM_INSTALLER_MSG_INSTALL_INVALID_URL'));
return false;
}
$config = JFactory::getConfig();
$tmp_dest = $config->get('tmp_path');
// Unpack the downloaded package file
$package = JInstallerHelper::unpack($tmp_dest . '/' . $p_file);
return $package;
}
}

View File

@ -0,0 +1,329 @@
<?php
/**
* @package Joomla.Administrator
* @subpackage com_installer
*
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('_JEXEC') or die;
require_once __DIR__ . '/extension.php';
/**
* Installer Manage Model
*
* @package Joomla.Administrator
* @subpackage com_installer
* @since 1.5
*/
class InstallerModelManage extends InstallerModel
{
/**
* Constructor.
*
* @param array $config An optional associative array of configuration settings.
*
* @see JController
* @since 1.6
*/
public function __construct($config = array())
{
if (empty($config['filter_fields']))
{
$config['filter_fields'] = array('name', 'client_id', 'status', 'type', 'folder', 'extension_id',);
}
parent::__construct($config);
}
/**
* Method to auto-populate the model state.
*
* Note. Calling getState in this method will result in recursion.
*
* @param string $ordering An optional ordering field.
* @param string $direction An optional direction (asc|desc).
*
* @return void
*
* @since 1.6
*/
protected function populateState($ordering = null, $direction = null)
{
$app = JFactory::getApplication();
// Load the filter state.
$search = $this->getUserStateFromRequest($this->context . '.filter.search', 'filter_search');
$this->setState('filter.search', $search);
$clientId = $this->getUserStateFromRequest($this->context . '.filter.client_id', 'filter_client_id', '');
$this->setState('filter.client_id', $clientId);
$status = $this->getUserStateFromRequest($this->context . '.filter.status', 'filter_status', '');
$this->setState('filter.status', $status);
$categoryId = $this->getUserStateFromRequest($this->context . '.filter.type', 'filter_type', '');
$this->setState('filter.type', $categoryId);
$group = $this->getUserStateFromRequest($this->context . '.filter.group', 'filter_group', '');
$this->setState('filter.group', $group);
$this->setState('message', $app->getUserState('com_installer.message'));
$this->setState('extension_message', $app->getUserState('com_installer.extension_message'));
$app->setUserState('com_installer.message', '');
$app->setUserState('com_installer.extension_message', '');
parent::populateState('name', 'asc');
}
/**
* Enable/Disable an extension.
*
* @param array &$eid Extension ids to un/publish
* @param int $value Publish value
*
* @return boolean True on success
*
* @since 1.5
*/
public function publish(&$eid = array(), $value = 1)
{
$user = JFactory::getUser();
if ($user->authorise('core.edit.state', 'com_installer'))
{
$result = true;
/*
* Ensure eid is an array of extension ids
* TODO: If it isn't an array do we want to set an error and fail?
*/
if (!is_array($eid))
{
$eid = array($eid);
}
// Get a table object for the extension type
$table = JTable::getInstance('Extension');
JTable::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_templates/tables');
// Enable the extension in the table and store it in the database
foreach ($eid as $i => $id)
{
$table->load($id);
if ($table->type == 'template')
{
$style = JTable::getInstance('Style', 'TemplatesTable');
if ($style->load(array('template' => $table->element, 'client_id' => $table->client_id, 'home' => 1)))
{
JError::raiseNotice(403, JText::_('COM_INSTALLER_ERROR_DISABLE_DEFAULT_TEMPLATE_NOT_PERMITTED'));
unset($eid[$i]);
continue;
}
}
if ($table->protected == 1)
{
$result = false;
JError::raiseWarning(403, JText::_('JLIB_APPLICATION_ERROR_EDITSTATE_NOT_PERMITTED'));
}
else
{
$table->enabled = $value;
}
if (!$table->store())
{
$this->setError($table->getError());
$result = false;
}
}
}
else
{
$result = false;
JError::raiseWarning(403, JText::_('JLIB_APPLICATION_ERROR_EDITSTATE_NOT_PERMITTED'));
}
return $result;
}
/**
* Refreshes the cached manifest information for an extension.
*
* @param int $eid extension identifier (key in #__extensions)
*
* @return boolean result of refresh
*
* @since 1.6
*/
public function refresh($eid)
{
if (!is_array($eid))
{
$eid = array($eid => 0);
}
// Get an installer object for the extension type
$installer = JInstaller::getInstance();
$result = 0;
// Uninstall the chosen extensions
foreach ($eid as $id)
{
$result |= $installer->refreshManifestCache($id);
}
return $result;
}
/**
* Remove (uninstall) an extension
*
* @param array $eid An array of identifiers
*
* @return boolean True on success
*
* @since 1.5
*/
public function remove($eid = array())
{
$user = JFactory::getUser();
if ($user->authorise('core.delete', 'com_installer'))
{
$failed = array();
/*
* Ensure eid is an array of extension ids in the form id => client_id
* TODO: If it isn't an array do we want to set an error and fail?
*/
if (!is_array($eid))
{
$eid = array($eid => 0);
}
// Get an installer object for the extension type
$installer = JInstaller::getInstance();
$row = JTable::getInstance('extension');
// Uninstall the chosen extensions
foreach ($eid as $id)
{
$id = trim($id);
$row->load($id);
if ($row->type && $row->type != 'language')
{
$result = $installer->uninstall($row->type, $id);
// Build an array of extensions that failed to uninstall
if ($result === false)
{
$failed[] = $id;
}
}
else
{
$failed[] = $id;
}
}
$langstring = 'COM_INSTALLER_TYPE_TYPE_' . strtoupper($row->type);
$rowtype = JText::_($langstring);
if (strpos($rowtype, $langstring) !== false)
{
$rowtype = $row->type;
}
if (count($failed))
{
if ($row->type == 'language')
{
// One should always uninstall a language package, not a single language
$msg = JText::_('COM_INSTALLER_UNINSTALL_LANGUAGE');
$result = false;
}
else
{
// There was an error in uninstalling the package
$msg = JText::sprintf('COM_INSTALLER_UNINSTALL_ERROR', $rowtype);
$result = false;
}
}
else
{
// Package uninstalled sucessfully
$msg = JText::sprintf('COM_INSTALLER_UNINSTALL_SUCCESS', $rowtype);
$result = true;
}
$app = JFactory::getApplication();
$app->enqueueMessage($msg);
$this->setState('action', 'remove');
$this->setState('name', $installer->get('name'));
$app->setUserState('com_installer.message', $installer->message);
$app->setUserState('com_installer.extension_message', $installer->get('extension_message'));
return $result;
}
else
{
JError::raiseWarning(403, JText::_('JERROR_CORE_DELETE_NOT_PERMITTED'));
}
}
/**
* Method to get the database query
*
* @return JDatabaseQuery The database query
*
* @since 1.6
*/
protected function getListQuery()
{
$status = $this->getState('filter.status');
$type = $this->getState('filter.type');
$client = $this->getState('filter.client_id');
$group = $this->getState('filter.group');
$query = JFactory::getDbo()->getQuery(true)
->select('*')
->select('2*protected+(1-protected)*enabled as status')
->from('#__extensions')
->where('state=0');
if ($status != '')
{
if ($status == '2')
{
$query->where('protected = 1');
}
elseif ($status == '3')
{
$query->where('protected = 0');
}
else
{
$query->where('protected = 0')
->where('enabled=' . (int) $status);
}
}
if ($type)
{
$query->where('type=' . $this->_db->quote($type));
}
if ($client != '')
{
$query->where('client_id=' . (int) $client);
}
if ($group != '' && in_array($type, array('plugin', 'library', '')))
{
$query->where('folder=' . $this->_db->quote($group == '*' ? '' : $group));
}
// Filter by search in id
$search = $this->getState('filter.search');
if (!empty($search) && stripos($search, 'id:') === 0)
{
$query->where('extension_id = ' . (int) substr($search, 3));
}
return $query;
}
}

View File

@ -0,0 +1,383 @@
<?php
/**
* @package Joomla.Administrator
* @subpackage com_installer
*
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('_JEXEC') or die;
jimport('joomla.updater.update');
/**
* Installer Update Model
*
* @package Joomla.Administrator
* @subpackage com_installer
* @since 1.6
*/
class InstallerModelUpdate extends JModelList
{
/**
* Constructor.
*
* @param array $config An optional associative array of configuration settings.
*
* @see JController
* @since 1.6
*/
public function __construct($config = array())
{
if (empty($config['filter_fields']))
{
$config['filter_fields'] = array(
'name',
'client_id',
'type',
'folder',
'extension_id',
'update_id',
'update_site_id',
);
}
parent::__construct($config);
}
/**
* Method to auto-populate the model state.
*
* Note. Calling getState in this method will result in recursion.
*
* @param string $ordering An optional ordering field.
* @param string $direction An optional direction (asc|desc).
*
* @return void
*
* @since 1.6
*/
protected function populateState($ordering = null, $direction = null)
{
$app = JFactory::getApplication();
$value = $app->getUserStateFromRequest($this->context . '.filter.search', 'filter_search');
$this->setState('filter.search', $value);
$clientId = $this->getUserStateFromRequest($this->context . '.filter.client_id', 'filter_client_id', '');
$this->setState('filter.client_id', $clientId);
$categoryId = $this->getUserStateFromRequest($this->context . '.filter.type', 'filter_type', '');
$this->setState('filter.type', $categoryId);
$group = $this->getUserStateFromRequest($this->context . '.filter.group', 'filter_group', '');
$this->setState('filter.group', $group);
$this->setState('message', $app->getUserState('com_installer.message'));
$this->setState('extension_message', $app->getUserState('com_installer.extension_message'));
$app->setUserState('com_installer.message', '');
$app->setUserState('com_installer.extension_message', '');
parent::populateState('name', 'asc');
}
/**
* Method to get the database query
*
* @return JDatabaseQuery The database query
*
* @since 1.6
*/
protected function getListQuery()
{
$db = $this->getDbo();
$query = $db->getQuery(true);
$type = $this->getState('filter.type');
$client = $this->getState('filter.client_id');
$group = $this->getState('filter.group');
// Grab updates ignoring new installs
$query->select('*')
->from('#__updates')
->where('extension_id != 0')
->order($this->getState('list.ordering') . ' ' . $this->getState('list.direction'));
if ($type)
{
$query->where('type=' . $db->quote($type));
}
if ($client != '')
{
$query->where('client_id = ' . intval($client));
}
if ($group != '' && in_array($type, array('plugin', 'library', '')))
{
$query->where('folder=' . $db->quote($group == '*' ? '' : $group));
}
// Filter by extension_id
if ($eid = $this->getState('filter.extension_id'))
{
$query->where($db->quoteName('extension_id') . ' = ' . $db->quote((int) $eid));
}
else
{
$query->where($db->quoteName('extension_id') . ' != ' . $db->quote(0))
->where($db->quoteName('extension_id') . ' != ' . $db->quote(700));
}
// Filter by search
$search = $this->getState('filter.search');
if (!empty($search))
{
$query->where('name LIKE ' . $db->quote('%' . $search . '%'));
}
return $query;
}
/**
* Finds updates for an extension.
*
* @param int $eid Extension identifier to look for
* @param int $cache_timeout Cache timout
*
* @return boolean Result
*
* @since 1.6
*/
public function findUpdates($eid = 0, $cache_timeout = 0)
{
// Purge the updates list
$this->purge();
$updater = JUpdater::getInstance();
$updater->findUpdates($eid, $cache_timeout);
return true;
}
/**
* Removes all of the updates from the table.
*
* @return boolean result of operation
*
* @since 1.6
*/
public function purge()
{
$db = JFactory::getDbo();
// Note: TRUNCATE is a DDL operation
// This may or may not mean depending on your database
$db->setQuery('TRUNCATE TABLE #__updates');
if ($db->execute())
{
// Reset the last update check timestamp
$query = $db->getQuery(true)
->update($db->quoteName('#__update_sites'))
->set($db->quoteName('last_check_timestamp') . ' = ' . $db->quote(0));
$db->setQuery($query);
$db->execute();
$this->_message = JText::_('COM_INSTALLER_PURGED_UPDATES');
return true;
}
else
{
$this->_message = JText::_('COM_INSTALLER_FAILED_TO_PURGE_UPDATES');
return false;
}
}
/**
* Enables any disabled rows in #__update_sites table
*
* @return boolean result of operation
*
* @since 1.6
*/
public function enableSites()
{
$db = JFactory::getDbo();
$query = $db->getQuery(true)
->update('#__update_sites')
->set('enabled = 1')
->where('enabled = 0');
$db->setQuery($query);
if ($db->execute())
{
if ($rows = $db->getAffectedRows())
{
$this->_message .= JText::plural('COM_INSTALLER_ENABLED_UPDATES', $rows);
}
return true;
}
else
{
$this->_message .= JText::_('COM_INSTALLER_FAILED_TO_ENABLE_UPDATES');
return false;
}
}
/**
* Update function.
*
* Sets the "result" state with the result of the operation.
*
* @param array $uids Array[int] List of updates to apply
*
* @return void
*
* @since 1.6
*/
public function update($uids)
{
$result = true;
foreach ($uids as $uid)
{
$update = new JUpdate;
$instance = JTable::getInstance('update');
$instance->load($uid);
$update->loadFromXML($instance->detailsurl);
// Install sets state and enqueues messages
$res = $this->install($update);
if ($res)
{
$instance->delete($uid);
}
$result = $res & $result;
}
// Set the final state
$this->setState('result', $result);
}
/**
* Handles the actual update installation.
*
* @param JUpdate $update An update definition
*
* @return boolean Result of install
*
* @since 1.6
*/
private function install($update)
{
$app = JFactory::getApplication();
if (isset($update->get('downloadurl')->_data))
{
$url = $update->downloadurl->_data;
}
else
{
JError::raiseWarning('', JText::_('COM_INSTALLER_INVALID_EXTENSION_UPDATE'));
return false;
}
$p_file = JInstallerHelper::downloadPackage($url);
// Was the package downloaded?
if (!$p_file)
{
JError::raiseWarning('', JText::sprintf('COM_INSTALLER_PACKAGE_DOWNLOAD_FAILED', $url));
return false;
}
$config = JFactory::getConfig();
$tmp_dest = $config->get('tmp_path');
// Unpack the downloaded package file
$package = JInstallerHelper::unpack($tmp_dest . '/' . $p_file);
// Get an installer instance
$installer = JInstaller::getInstance();
$update->set('type', $package['type']);
// Install the package
if (!$installer->update($package['dir']))
{
// There was an error updating the package
$msg = JText::sprintf('COM_INSTALLER_MSG_UPDATE_ERROR', JText::_('COM_INSTALLER_TYPE_TYPE_' . strtoupper($package['type'])));
$result = false;
}
else
{
// Package updated successfully
$msg = JText::sprintf('COM_INSTALLER_MSG_UPDATE_SUCCESS', JText::_('COM_INSTALLER_TYPE_TYPE_' . strtoupper($package['type'])));
$result = true;
}
// Quick change
$this->type = $package['type'];
// Set some model state values
$app->enqueueMessage($msg);
// TODO: Reconfigure this code when you have more battery life left
$this->setState('name', $installer->get('name'));
$this->setState('result', $result);
$app->setUserState('com_installer.message', $installer->message);
$app->setUserState('com_installer.extension_message', $installer->get('extension_message'));
// Cleanup the install files
if (!is_file($package['packagefile']))
{
$config = JFactory::getConfig();
$package['packagefile'] = $config->get('tmp_path') . '/' . $package['packagefile'];
}
JInstallerHelper::cleanupInstall($package['packagefile'], $package['extractdir']);
return $result;
}
/**
* Method to get the row form.
*
* @param array $data Data for the form.
* @param boolean $loadData True if the form is to load its own data (default case), false if not.
*
* @return mixed A JForm object on success, false on failure
*
* @since 2.5.2
*/
public function getForm($data = array(), $loadData = true)
{
// Get the form.
JForm::addFormPath(JPATH_COMPONENT . '/models/forms');
JForm::addFieldPath(JPATH_COMPONENT . '/models/fields');
$form = JForm::getInstance('com_installer.update', 'update', array('load_data' => $loadData));
// Check for an error.
if ($form == false)
{
$this->setError($form->getMessage());
return false;
}
// Check the session for previously entered form data.
$data = $this->loadFormData();
// Bind the form data if present.
if (!empty($data))
{
$form->bind($data);
}
return $form;
}
/**
* Method to get the data that should be injected in the form.
*
* @return mixed The data for the form.
*
* @since 2.5.2
*/
protected function loadFormData()
{
// Check the session for previously entered form data.
$data = JFactory::getApplication()->getUserState($this->context . '.data', array());
return $data;
}
}

View File

@ -0,0 +1,144 @@
<?php
/**
* @package Joomla.Administrator
* @subpackage com_installer
*
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('_JEXEC') or die;
/**
* Extension Manager Templates Model
*
* @package Joomla.Administrator
* @subpackage com_installer
* @since 1.6
*/
class InstallerModelWarnings extends JModelList
{
/**
* Extension Type
* @var string
*/
public $type = 'warnings';
/**
* Return the byte value of a particular string.
*
* @param string $val String optionally with G, M or K suffix
*
* @return integer size in bytes
*
* @since 1.6
*/
public function return_bytes($val)
{
$val = trim($val);
$last = strtolower($val{strlen($val) - 1});
switch ($last)
{
// The 'G' modifier is available since PHP 5.1.0
case 'g':
$val *= 1024;
case 'm':
$val *= 1024;
case 'k':
$val *= 1024;
}
return $val;
}
/**
* Load the data.
*
* @return array Messages
*
* @since 1.6
*/
public function getItems()
{
static $messages;
if ($messages)
{
return $messages;
}
$messages = array();
$file_uploads = ini_get('file_uploads');
if (!$file_uploads)
{
$messages[] = array('message' => JText::_('COM_INSTALLER_MSG_WARNINGS_FILEUPLOADSDISABLED'),
'description' => JText::_('COM_INSTALLER_MSG_WARNINGS_FILEUPLOADISDISABLEDDESC'));
}
$upload_dir = ini_get('upload_tmp_dir');
if (!$upload_dir)
{
$messages[] = array('message' => JText::_('COM_INSTALLER_MSG_WARNINGS_PHPUPLOADNOTSET'),
'description' => JText::_('COM_INSTALLER_MSG_WARNINGS_PHPUPLOADNOTSETDESC'));
}
else
{
if (!is_writeable($upload_dir))
{
$messages[] = array('message' => JText::_('COM_INSTALLER_MSG_WARNINGS_PHPUPLOADNOTWRITEABLE'),
'description' => JText::sprintf('COM_INSTALLER_MSG_WARNINGS_PHPUPLOADNOTWRITEABLEDESC', $upload_dir));
}
}
$config = JFactory::getConfig();
$tmp_path = $config->get('tmp_path');
if (!$tmp_path)
{
$messages[] = array('message' => JText::_('COM_INSTALLER_MSG_WARNINGS_JOOMLATMPNOTSET'),
'description' => JText::_('COM_INSTALLER_MSG_WARNINGS_JOOMLATMPNOTSETDESC'));
}
else
{
if (!is_writeable($tmp_path))
{
$messages[] = array('message' => JText::_('COM_INSTALLER_MSG_WARNINGS_JOOMLATMPNOTWRITEABLE'),
'description' => JText::sprintf('COM_INSTALLER_MSG_WARNINGS_JOOMLATMPNOTWRITEABLEDESC', $tmp_path));
}
}
$memory_limit = $this->return_bytes(ini_get('memory_limit'));
if ($memory_limit < (8 * 1024 * 1024))
{
// 8MB
$messages[] = array('message' => JText::_('COM_INSTALLER_MSG_WARNINGS_LOWMEMORYWARN'),
'description' => JText::_('COM_INSTALLER_MSG_WARNINGS_LOWMEMORYDESC'));
}
elseif ($memory_limit < (16 * 1024 * 1024))
{
// 16MB
$messages[] = array('message' => JText::_('COM_INSTALLER_MSG_WARNINGS_MEDMEMORYWARN'),
'description' => JText::_('COM_INSTALLER_MSG_WARNINGS_MEDMEMORYDESC'));
}
$post_max_size = $this->return_bytes(ini_get('post_max_size'));
$upload_max_filesize = $this->return_bytes(ini_get('upload_max_filesize'));
if ($post_max_size < $upload_max_filesize)
{
$messages[] = array('message' => JText::_('COM_INSTALLER_MSG_WARNINGS_UPLOADBIGGERTHANPOST'),
'description' => JText::_('COM_INSTALLER_MSG_WARNINGS_UPLOADBIGGERTHANPOSTDESC'));
}
if ($post_max_size < (4 * 1024 * 1024)) // 4MB
{
$messages[] = array('message' => JText::_('COM_INSTALLER_MSG_WARNINGS_SMALLPOSTSIZE'),
'description' => JText::_('COM_INSTALLER_MSG_WARNINGS_SMALLPOSTSIZEDESC'));
}
if ($upload_max_filesize < (4 * 1024 * 1024)) // 4MB
{
$messages[] = array('message' => JText::_('COM_INSTALLER_MSG_WARNINGS_SMALLUPLOADSIZE'),
'description' => JText::_('COM_INSTALLER_MSG_WARNINGS_SMALLUPLOADSIZEDESC'));
}
return $messages;
}
}