Source code for file /joomla/installer/adapters/language.php
Documentation is available at language.php
* @version $Id: language.php 6138 2007-01-02 03:44:18Z eddiea $
* @package Joomla.Framework
* @copyright Copyright (C) 2005 - 2007 Open Source Matters. All rights reserved.
* @license GNU/GPL, see LICENSE.php
* Joomla! is free software. This version may have been modified pursuant
* to the GNU General Public License, and as distributed it includes or
* is derivative of works licensed under the GNU General Public License or
* other free or open source software licenses.
* See COPYRIGHT.php for copyright notices and details.
// Check to ensure this file is within the rest of the framework
* @package Joomla.Framework
* Core language pack flag
* @param object $parent Parent object [JInstaller instance]
$this->parent =
& $parent;
* @return boolean True on success
// Get database connector object
$db =
& $this->parent->getDBO();
$manifest =
& $this->parent->getManifest();
$root =
& $manifest->document;
// Get the client application target
if ($cname =
$root->attributes('client')) {
// Attempt to map the client to a base path
jimport('joomla.application.helper');
$this->parent->abort('Language Install: '.
JText::_('Unknown client type').
' ['.
$cname.
']');
$basePath =
$client->path;
// No client attribute was found so we assume the site as the client
$name =
& $root->getElementByPath('name');
$this->set('name', $name->data());
// Get the Language tag [ISO tag, eg. en-GB]
$tag =
& $root->getElementByPath('tag');
$this->set('tag', $tag->data());
// Set the language installation path
$this->parent->setPath('extension_site', $basePath.
DS.
"language".
DS.
$this->get('tag'));
// Do we have a meta file in the file list? In other words... is this a core language pack?
$element =
& $root->getElementByPath('files');
if (is_a($element, 'JSimpleXMLElement') &&
count($element->children())) {
$files =
$element->children();
foreach ($files as $file) {
if ($file->attributes('file') ==
'meta') {
// Either we are installing a core pack or a core pack must exist for the language we are installing.
if (!JFile::exists($this->parent->getPath('extension_site').
DS.
$this->get('tag').
'.xml')) {
$this->parent->abort('Language Install: '.
JText::_('No core pack exists for the language').
' :'.
$this->get('tag'));
// If the language directory does not exist, lets create it
if (!file_exists($this->parent->getPath('extension_site'))) {
if (!$created =
JFolder::create($this->parent->getPath('extension_site'))) {
$this->parent->abort('Language Install: '.
JText::_('Failed to create directory').
' "'.
$this->parent->getPath('extension_site').
'"');
* If we created the language directory and will want to remove it if we
* have to roll back the installation, lets add it to the installation
$this->parent->pushStep(array ('type' =>
'folder', 'path' =>
$this->parent->getPath('extension_site')));
// Copy all the necessary files
if ($this->parent->parseFiles($element) ===
false) {
// Install failed, rollback changes
// Copy all the necessary font files to the common pdf_fonts directory
$this->parent->setPath('extension_site', $basePath.
DS.
"language".
DS.
'pdf_fonts');
$overwrite =
$this->parent->setOverwrite(true);
if ($this->parent->parseFiles($root->getElementByPath('fonts')) ===
false) {
// Install failed, rollback changes
$this->parent->setOverwrite($overwrite);
// Get the language description
$description =
& $root->getElementByPath('description');
if (is_a($description, 'JSimpleXMLElement')) {
$this->parent->set('message', $this->get('name').
'<p>'.
$description->data().
'</p>');
$this->parent->set('message', $this->get('name'));
* Custom uninstall method
* @param string $tag The tag of the language to uninstall
* @param int $clientId The id of the client (unused)
* @return mixed Return value for uninstall method in component uninstall file