Files
@ f43d1a4680a9
Branch filter:
Location: hot67beta/libraries/joomla/installer/adapters/language.php - annotation
f43d1a4680a9
6.6 KiB
text/x-php
menubar 0 to 10
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 | c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 | <?php
/**
* @version $Id:language.php 6961 2007-03-15 16:06:53Z tcp $
* @package Joomla.Framework
* @subpackage Installer
* @copyright Copyright (C) 2005 - 2008 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
defined('JPATH_BASE') or die();
/**
* Language installer
*
* @package Joomla.Framework
* @subpackage Installer
* @since 1.5
*/
class JInstallerLanguage extends JObject
{
/**
* Core language pack flag
* @access private
* @var boolean
*/
var $_core = false;
/**
* Constructor
*
* @access protected
* @param object $parent Parent object [JInstaller instance]
* @return void
* @since 1.5
*/
function __construct(&$parent)
{
$this->parent =& $parent;
}
/**
* Custom install method
*
* @access public
* @return boolean True on success
* @since 1.5
*/
function install()
{
$manifest =& $this->parent->getManifest();
$this->manifest =& $manifest->document;
$root =& $manifest->document;
// Get the client application target
if ($root->attributes('client') == 'both')
{
$siteElement =& $root->getElementByPath('site');
$element =& $siteElement->getElementByPath('files');
if (!$this->_install('site', JPATH_SITE, 0, $element)) {
return false;
}
$adminElement =& $root->getElementByPath('administration');
$element =& $adminElement->getElementByPath('files');
if (!$this->_install('administrator', JPATH_ADMINISTRATOR, 1, $element)) {
return false;
}
return true;
}
elseif ($cname = $root->attributes('client'))
{
// Attempt to map the client to a base path
jimport('joomla.application.helper');
$client =& JApplicationHelper::getClientInfo($cname, true);
if ($client === null) {
$this->parent->abort(JText::_('Language').' '.JText::_('Install').': '.JText::_('Unknown client type').' ['.$cname.']');
return false;
}
$basePath = $client->path;
$clientId = $client->id;
$element =& $root->getElementByPath('files');
return $this->_install($cname, $basePath, $clientId, $element);
}
else
{
// No client attribute was found so we assume the site as the client
$cname = 'site';
$basePath = JPATH_SITE;
$clientId = 0;
$element =& $root->getElementByPath('files');
return $this->_install($cname, $basePath, $clientId, $element);
}
}
/**
*
*/
function _install($cname, $basePath, $clientId, &$element)
{
$manifest =& $this->parent->getManifest();
$this->manifest =& $manifest->document;
$root =& $manifest->document;
// Get the language name
// Set the extensions name
$name =& $this->manifest->getElementByPath('name');
$name = JFilterInput::clean($name->data(), 'cmd');
$this->set('name', $name);
// Get the Language tag [ISO tag, eg. en-GB]
$tag =& $root->getElementByPath('tag');
// Check if we found the tag - if we didn't, we may be trying to install from an older language package
if ( ! $tag )
{
$this->parent->abort(JText::_('Language').' '.JText::_('Install').': '.JText::_('NO LANGUAGE TAG?'));
return false;
}
$this->set('tag', $tag->data());
$folder = $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?
if (is_a($element, 'JSimpleXMLElement') && count($element->children())) {
$files = $element->children();
foreach ($files as $file) {
if ($file->attributes('file') == 'meta') {
$this->_core = true;
break;
}
}
}
// Either we are installing a core pack or a core pack must exist for the language we are installing.
if (!$this->_core) {
if (!JFile::exists($this->parent->getPath('extension_site').DS.$this->get('tag').'.xml')) {
$this->parent->abort(JText::_('Language').' '.JText::_('Install').': '.JText::_('No core pack exists for the language').' :'.$this->get('tag'));
return false;
}
}
// If the language directory does not exist, lets create it
$created = false;
if (!file_exists($this->parent->getPath('extension_site'))) {
if (!$created = JFolder::create($this->parent->getPath('extension_site'))) {
$this->parent->abort(JText::_('Language').' '.JText::_('Install').': '.JText::_('Failed to create directory').' "'.$this->parent->getPath('extension_site').'"');
return false;
}
}
/*
* 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
* step stack
*/
if ($created) {
$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
$this->parent->abort();
return false;
}
// Copy all the necessary font files to the common pdf_fonts directory
$this->parent->setPath('extension_site', JPATH_SITE.DS."language".DS.'pdf_fonts');
$overwrite = $this->parent->setOverwrite(true);
if ($this->parent->parseFiles($root->getElementByPath('fonts')) === false) {
// Install failed, rollback changes
$this->parent->abort();
return false;
}
$this->parent->setOverwrite($overwrite);
// Get the language description
$description = & $root->getElementByPath('description');
if (is_a($description, 'JSimpleXMLElement')) {
$this->parent->set('message', $description->data());
} else {
$this->parent->set('message', '' );
}
return true;
}
/**
* Custom uninstall method
*
* @access public
* @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
* @since 1.5
*/
function uninstall($tag, $clientId)
{
$path = trim($tag);
if (!JFolder::exists($path)) {
JError::raiseWarning(100, JText::_('Language').' '.JText::_('Uninstall').': '.JText::_('Language path is empty, cannot uninstall files'));
return false;
}
if (!JFolder::delete($path)) {
JError::raiseWarning(100, JText::_('Language').' '.JText::_('Uninstall').': '.JText::_('Unable to remove language directory'));
return false;
}
return true;
}
}
|