- md5
- 1d92f2d2f4498864213bcd7482b45bfb
- sha1
- eb8dc7af58cd3d9d2a4f065c0ffd3432452c6884
- sha256
- 0f15f10503a718aea617154fd99bb8c25f85789a0e805e0ec5454735bb38c602
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256
<?php
/**
* @version $Id: admin.languages.php 4671 2006-08-23 13:29:47Z stingrey $
* @package Joomla
* @subpackage Languages
* @copyright Copyright (C) 2005 Open Source Matters. All rights reserved.
* @license http://www.gnu.org/copyleft/gpl.html 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.
*/
// no direct access
defined( '_VALID_MOS' ) or die( 'Restricted access' );
// ensure user has access to this function
if (!$acl->acl_check( 'administration', 'config', 'users', $my->usertype )) {
mosRedirect( 'index2.php', _NOT_AUTH );
}
require_once( $mainframe->getPath( 'admin_html' ) );
// XML library
require_once( "$mosConfig_absolute_path/includes/domit/xml_domit_lite_include.php" );
$cid = mosGetParam( $_REQUEST, 'cid', array(0) );
if (!is_array( $cid )) {
$cid = array(0);
} else {
foreach ( $cid as $key => $value ) {
$key = preg_replace( '#\W#', '', $value );
}
}
switch ($task) {
case 'new':
mosRedirect( 'index2.php?option=com_installer&element=language' );
break;
case 'edit_source':
editLanguageSource( $cid[0], $option );
break;
case 'save_source':
saveLanguageSource( $option );
break;
case 'remove':
removeLanguage( $cid[0], $option );
break;
case 'publish':
publishLanguage( $cid[0], $option );
break;
case 'cancel':
mosRedirect( "index2.php?option=$option" );
break;
default:
viewLanguages( $option );
break;
}
/**
* Compiles a list of installed languages
*/
function viewLanguages( $option ) {
global $languages;
global $mainframe;
global $mosConfig_lang, $mosConfig_absolute_path, $mosConfig_list_limit;
$limit = $mainframe->getUserStateFromRequest( "viewlistlimit", 'limit', $mosConfig_list_limit );
$limitstart = $mainframe->getUserStateFromRequest( "view{$option}limitstart", 'limitstart', 0 );
// get current languages
$cur_language = $mosConfig_lang;
$rows = array();
// Read the template dir to find templates
$languageBaseDir = mosPathName(mosPathName($mosConfig_absolute_path) . "language");
$rowid = 0;
$xmlFilesInDir = mosReadDirectory($languageBaseDir,'.xml$');
$dirName = $languageBaseDir;
foreach($xmlFilesInDir as $xmlfile) {
// Read the file to see if it's a valid template XML file
$xmlDoc = new DOMIT_Lite_Document();
$xmlDoc->resolveErrors( true );
if (!$xmlDoc->loadXML( $dirName . $xmlfile, false, true )) {
continue;
}
$root = &$xmlDoc->documentElement;
if ($root->getTagName() != 'mosinstall') {
continue;
}
if ($root->getAttribute( "type" ) != "language") {
continue;
}
$row = new StdClass();
$row->id = $rowid;
$row->language = substr($xmlfile,0,-4);
$element = &$root->getElementsByPath('name', 1 );
$row->name = $element->getText();
$element = &$root->getElementsByPath('creationDate', 1);
$row->creationdate = $element ? $element->getText() : 'Unknown';
$element = &$root->getElementsByPath('author', 1);
$row->author = $element ? $element->getText() : 'Unknown';
$element = &$root->getElementsByPath('copyright', 1);
$row->copyright = $element ? $element->getText() : '';
$element = &$root->getElementsByPath('authorEmail', 1);
$row->authorEmail = $element ? $element->getText() : '';
$element = &$root->getElementsByPath('authorUrl', 1);
$row->authorUrl = $element ? $element->getText() : '';
$element = &$root->getElementsByPath('version', 1);
$row->version = $element ? $element->getText() : '';
// if current than set published
if ($cur_language == $row->language) {
$row->published = 1;
} else {
$row->published = 0;
}
$row->checked_out = 0;
$row->mosname = strtolower( str_replace( " ", "_", $row->name ) );
$rows[] = $row;
$rowid++;
}
require_once( $GLOBALS['mosConfig_absolute_path'] . '/administrator/includes/pageNavigation.php' );
$pageNav = new mosPageNav( count( $rows ), $limitstart, $limit );
$rows = array_slice( $rows, $pageNav->limitstart, $pageNav->limit );
HTML_languages::showLanguages( $cur_language, $rows, $pageNav, $option );
}
/**
* Publish, or make current, the selected language
*/
function publishLanguage( $p_lname, $option ) {
global $mosConfig_lang;
$config = '';
$fp = fopen('../configuration.php','r');
while(!feof($fp)){
$buffer = fgets($fp,4096);
if (strstr($buffer,"\$mosConfig_lang")){
$config .= "\$mosConfig_lang = \"$p_lname\";\n";
} else {
$config .= $buffer;
}
}
fclose($fp);
if ($fp = fopen('../configuration.php','w')){
fputs($fp, $config, strlen($config));
fclose($fp);
mosRedirect('index2.php?option=com_languages',"Language successfully changed! $p_lname");
} else {
mosRedirect('index2.php?option=com_languages','Error!');
}
}
/**
* Remove the selected language
*/
function removeLanguage( $cid, $option, $client = 'admin' ) {
global $mosConfig_lang;
$client_id = $client=='admin' ? 1 : 0;
$cur_language = $mosConfig_lang;
if ($cur_language == $cid) {
mosErrorAlert( "You can not delete language in use." );
}
/*$lang_path = "../language/$cid.php";
$lang_ignore_path = "../language/$cid.ignore.php";
$xml_path = "../language/$cid.xml";
unlink($lang_path);
unlink($lang_ignore_path);
unlink($xml_path);
*/
mosRedirect( 'index2.php?option=com_installer&element=language&client='. $client .'&task=remove&cid[]='. $cid );
}
function editLanguageSource( $p_lname, $option) {
$file = stripslashes( "../language/$p_lname.php" );
if ($fp = fopen( $file, "r" )) {
$content = fread( $fp, filesize( $file ) );
$content = htmlspecialchars( $content );
HTML_languages::editLanguageSource( $p_lname, $content, $option );
} else {
mosRedirect( "index2.php?option=$option&mosmsg=Operation Failed: Could not open $file" );
}
}
function saveLanguageSource( $option ) {
$language = mosGetParam( $_POST, 'language', '' );
$filecontent = mosGetParam( $_POST, 'filecontent', '', _MOS_ALLOWHTML );
if (!$language) {
mosRedirect( "index2.php?option=$option&mosmsg=Operation failed: No language specified." );
}
if (!$filecontent) {
mosRedirect( "index2.php?option=$option&mosmsg=Operation failed: Content empty." );
}
$file = "../language/$language.php";
$enable_write = mosGetParam($_POST,'enable_write',0);
$oldperms = fileperms($file);
if ($enable_write) @chmod($file, $oldperms | 0222);
clearstatcache();
if (is_writable( $file ) == false) {
mosRedirect( "index2.php?option=$option&mosmsg=Operation failed: The file is not writable." );
}
if ($fp = fopen ($file, "w")) {
fputs( $fp, stripslashes( $filecontent ) );
fclose( $fp );
if ($enable_write) {
@chmod($file, $oldperms);
} else {
if (mosGetParam($_POST,'disable_write',0))
@chmod($file, $oldperms & 0777555);
} // if
mosRedirect( "index2.php?option=$option" );
} else {
if ($enable_write) @chmod($file, $oldperms);
mosRedirect( "index2.php?option=$option&mosmsg=Operation failed: Failed to open file for writing." );
}
}
?>
No other release has this exact content. See every version of this file.