Source for file languages.php
Documentation is available at languages.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
* Languages Installer Model
* @package Joomla.Administrator
* @subpackage com_installer
* Constructor override, defines a white list of column filters.
* @param array $config An optional associative array of configuration settings.
if (empty($config['filter_fields']))
$config['filter_fields'] =
array(
'update_id', 'update_id',
* Method to get the available languages database query.
* @return JDatabaseQuery The database query
$query =
$db->getQuery(true);
// Select the required fields from the updates table
$query->select('update_id, name, version, detailsurl, type')
// 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');
$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));
* 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.
$id .=
':' .
$this->getState('filter.search');
* 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
protected function populateState($ordering =
'name', $direction =
'asc')
$value =
$app->getUserStateFromRequest($this->context .
'.filter.search', 'filter_search');
$this->setState('filter.search', $value);
$this->setState('extension_message', $app->getUserState('com_installer.extension_message'));
* Method to find available languages in the Accredited Languages Update Site.
* @param int $cache_timeout time before refreshing the cached updates
* 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);
* Install languages in the system.
* @param array $lids array of language ids selected in the list
// Loop through every selected language
// Loads the update database object that represents the language
// Get the url to the XML manifest file of the selected language
// 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);
// Based on the language XML manifest get the url of the package to download
// 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);
// Download the package to the tmp folder
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);
// 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']))
$package['packagefile'] =
$config->get('tmp_path') .
'/' .
$package['packagefile'];
// Delete the installed language from the list
* 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 $instance->detailsurl;
* Finds the url of the package to download.
* @param string $remote_manifest url to the manifest XML file of the remote package
$update->loadFromXML($remote_manifest);
$package_url =
trim($update->get('downloadurl', false)->_data);
* 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
// Download the package from the given URL
// Was the package downloaded?
$tmp_dest =
$config->get('tmp_path');
// Unpack the downloaded package file
Documentation generated on Tue, 19 Nov 2013 15:06:38 +0100 by phpDocumentor 1.4.3