| [ Index ] |
|
Code source de Joomla 1.0.13 |
1 <?php 2 /** 3 * @version $Id: admin.languages.php 4671 2006-08-23 13:29:47Z stingrey $ 4 * @package Joomla 5 * @subpackage Languages 6 * @copyright Copyright (C) 2005 Open Source Matters. All rights reserved. 7 * @license http://www.gnu.org/copyleft/gpl.html GNU/GPL, see LICENSE.php 8 * Joomla! is free software. This version may have been modified pursuant 9 * to the GNU General Public License, and as distributed it includes or 10 * is derivative of works licensed under the GNU General Public License or 11 * other free or open source software licenses. 12 * See COPYRIGHT.php for copyright notices and details. 13 */ 14 15 // no direct access 16 defined( '_VALID_MOS' ) or die( 'Restricted access' ); 17 18 // ensure user has access to this function 19 if (!$acl->acl_check( 'administration', 'config', 'users', $my->usertype )) { 20 mosRedirect( 'index2.php', _NOT_AUTH ); 21 } 22 23 require_once( $mainframe->getPath( 'admin_html' ) ); 24 // XML library 25 require_once( "$mosConfig_absolute_path/includes/domit/xml_domit_lite_include.php" ); 26 27 $cid = mosGetParam( $_REQUEST, 'cid', array(0) ); 28 if (!is_array( $cid )) { 29 $cid = array(0); 30 } else { 31 foreach ( $cid as $key => $value ) { 32 $key = preg_replace( '#\W#', '', $value ); 33 } 34 } 35 36 switch ($task) { 37 case 'new': 38 mosRedirect( 'index2.php?option=com_installer&element=language' ); 39 break; 40 41 case 'edit_source': 42 editLanguageSource( $cid[0], $option ); 43 break; 44 45 case 'save_source': 46 saveLanguageSource( $option ); 47 break; 48 49 case 'remove': 50 removeLanguage( $cid[0], $option ); 51 break; 52 53 case 'publish': 54 publishLanguage( $cid[0], $option ); 55 break; 56 57 case 'cancel': 58 mosRedirect( "index2.php?option=$option" ); 59 break; 60 61 default: 62 viewLanguages( $option ); 63 break; 64 } 65 66 /** 67 * Compiles a list of installed languages 68 */ 69 function viewLanguages( $option ) { 70 global $languages; 71 global $mainframe; 72 global $mosConfig_lang, $mosConfig_absolute_path, $mosConfig_list_limit; 73 74 $limit = $mainframe->getUserStateFromRequest( "viewlistlimit", 'limit', $mosConfig_list_limit ); 75 $limitstart = $mainframe->getUserStateFromRequest( "view{$option}limitstart", 'limitstart', 0 ); 76 77 // get current languages 78 $cur_language = $mosConfig_lang; 79 80 $rows = array(); 81 // Read the template dir to find templates 82 $languageBaseDir = mosPathName(mosPathName($mosConfig_absolute_path) . "language"); 83 84 $rowid = 0; 85 86 $xmlFilesInDir = mosReadDirectory($languageBaseDir,'.xml$'); 87 88 $dirName = $languageBaseDir; 89 foreach($xmlFilesInDir as $xmlfile) { 90 // Read the file to see if it's a valid template XML file 91 $xmlDoc = new DOMIT_Lite_Document(); 92 $xmlDoc->resolveErrors( true ); 93 if (!$xmlDoc->loadXML( $dirName . $xmlfile, false, true )) { 94 continue; 95 } 96 97 $root = &$xmlDoc->documentElement; 98 99 if ($root->getTagName() != 'mosinstall') { 100 continue; 101 } 102 if ($root->getAttribute( "type" ) != "language") { 103 continue; 104 } 105 106 $row = new StdClass(); 107 $row->id = $rowid; 108 $row->language = substr($xmlfile,0,-4); 109 $element = &$root->getElementsByPath('name', 1 ); 110 $row->name = $element->getText(); 111 112 $element = &$root->getElementsByPath('creationDate', 1); 113 $row->creationdate = $element ? $element->getText() : 'Unknown'; 114 115 $element = &$root->getElementsByPath('author', 1); 116 $row->author = $element ? $element->getText() : 'Unknown'; 117 118 $element = &$root->getElementsByPath('copyright', 1); 119 $row->copyright = $element ? $element->getText() : ''; 120 121 $element = &$root->getElementsByPath('authorEmail', 1); 122 $row->authorEmail = $element ? $element->getText() : ''; 123 124 $element = &$root->getElementsByPath('authorUrl', 1); 125 $row->authorUrl = $element ? $element->getText() : ''; 126 127 $element = &$root->getElementsByPath('version', 1); 128 $row->version = $element ? $element->getText() : ''; 129 130 // if current than set published 131 if ($cur_language == $row->language) { 132 $row->published = 1; 133 } else { 134 $row->published = 0; 135 } 136 137 $row->checked_out = 0; 138 $row->mosname = strtolower( str_replace( " ", "_", $row->name ) ); 139 $rows[] = $row; 140 $rowid++; 141 } 142 143 require_once( $GLOBALS['mosConfig_absolute_path'] . '/administrator/includes/pageNavigation.php' ); 144 $pageNav = new mosPageNav( count( $rows ), $limitstart, $limit ); 145 146 $rows = array_slice( $rows, $pageNav->limitstart, $pageNav->limit ); 147 148 HTML_languages::showLanguages( $cur_language, $rows, $pageNav, $option ); 149 } 150 151 /** 152 * Publish, or make current, the selected language 153 */ 154 function publishLanguage( $p_lname, $option ) { 155 global $mosConfig_lang; 156 157 $config = ''; 158 159 $fp = fopen('../configuration.php','r'); 160 while(!feof($fp)){ 161 $buffer = fgets($fp,4096); 162 if (strstr($buffer,"\$mosConfig_lang")){ 163 $config .= "\$mosConfig_lang = \"$p_lname\";\n"; 164 } else { 165 $config .= $buffer; 166 } 167 } 168 fclose($fp); 169 170 if ($fp = fopen('../configuration.php','w')){ 171 fputs($fp, $config, strlen($config)); 172 fclose($fp); 173 mosRedirect('index2.php?option=com_languages',"Language successfully changed! $p_lname"); 174 } else { 175 mosRedirect('index2.php?option=com_languages','Error!'); 176 } 177 178 } 179 180 /** 181 * Remove the selected language 182 */ 183 function removeLanguage( $cid, $option, $client = 'admin' ) { 184 global $mosConfig_lang; 185 186 $client_id = $client=='admin' ? 1 : 0; 187 188 $cur_language = $mosConfig_lang; 189 190 if ($cur_language == $cid) { 191 mosErrorAlert( "You can not delete language in use." ); 192 } 193 194 /*$lang_path = "../language/$cid.php"; 195 $lang_ignore_path = "../language/$cid.ignore.php"; 196 $xml_path = "../language/$cid.xml"; 197 198 unlink($lang_path); 199 unlink($lang_ignore_path); 200 unlink($xml_path); 201 */ 202 203 mosRedirect( 'index2.php?option=com_installer&element=language&client='. $client .'&task=remove&cid[]='. $cid ); 204 205 } 206 207 function editLanguageSource( $p_lname, $option) { 208 $file = stripslashes( "../language/$p_lname.php" ); 209 210 if ($fp = fopen( $file, "r" )) { 211 $content = fread( $fp, filesize( $file ) ); 212 $content = htmlspecialchars( $content ); 213 214 HTML_languages::editLanguageSource( $p_lname, $content, $option ); 215 } else { 216 mosRedirect( "index2.php?option=$option&mosmsg=Operation Failed: Could not open $file" ); 217 } 218 } 219 220 function saveLanguageSource( $option ) { 221 $language = mosGetParam( $_POST, 'language', '' ); 222 $filecontent = mosGetParam( $_POST, 'filecontent', '', _MOS_ALLOWHTML ); 223 224 if (!$language) { 225 mosRedirect( "index2.php?option=$option&mosmsg=Operation failed: No language specified." ); 226 } 227 if (!$filecontent) { 228 mosRedirect( "index2.php?option=$option&mosmsg=Operation failed: Content empty." ); 229 } 230 231 $file = "../language/$language.php"; 232 $enable_write = mosGetParam($_POST,'enable_write',0); 233 $oldperms = fileperms($file); 234 if ($enable_write) @chmod($file, $oldperms | 0222); 235 236 clearstatcache(); 237 if (is_writable( $file ) == false) { 238 mosRedirect( "index2.php?option=$option&mosmsg=Operation failed: The file is not writable." ); 239 } 240 241 if ($fp = fopen ($file, "w")) { 242 fputs( $fp, stripslashes( $filecontent ) ); 243 fclose( $fp ); 244 if ($enable_write) { 245 @chmod($file, $oldperms); 246 } else { 247 if (mosGetParam($_POST,'disable_write',0)) 248 @chmod($file, $oldperms & 0777555); 249 } // if 250 mosRedirect( "index2.php?option=$option" ); 251 } else { 252 if ($enable_write) @chmod($file, $oldperms); 253 mosRedirect( "index2.php?option=$option&mosmsg=Operation failed: Failed to open file for writing." ); 254 } 255 } 256 ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
| Généré le : Wed Nov 21 14:43:32 2007 | par Balluche grâce à PHPXref 0.7 |
|