Annotation of /mambo/branches/4.6/administrator/components/com_languages/actions/default.action.php
Parent Directory
|
Revision Log
Revision 1756 - (view) (download)
| 1 : | csouza | 403 | <?php |
| 2 : | elpie | 971 | /** |
| 3 : | * @package Mambo | ||
| 4 : | * @subpackage Languages | ||
| 5 : | elpie | 1756 | * @author Mambo Foundation Inc see README.php |
| 6 : | * @copyright (C) 2000 - 2009 Mambo Foundation Inc. | ||
| 7 : | * See COPYRIGHT.php for copyright notices and details. | ||
| 8 : | * @license GNU/GPL Version 2, see LICENSE.php | ||
| 9 : | * | ||
| 10 : | * Redistributions of files must retain the above copyright notice. | ||
| 11 : | * | ||
| 12 : | * Mambo is free software; you can redistribute it and/or | ||
| 13 : | * modify it under the terms of the GNU General Public License | ||
| 14 : | * as published by the Free Software Foundation; version 2 of the License. | ||
| 15 : | */ | ||
| 16 : | ocs_cms | 1396 | |
| 17 : | andphe | 915 | defined( '_VALID_MOS' ) or die( 'Direct Access to this location is not allowed.' ); |
| 18 : | csouza | 403 | class defaultAction extends Action |
| 19 : | { | ||
| 20 : | function execute(&$controller, &$request) | ||
| 21 : | { | ||
| 22 : | $lang = mosGetParam( $_REQUEST, 'lang' ); | ||
| 23 : | $root = mamboCore::get('rootPath'); | ||
| 24 : | $fp = fopen("../configuration.php","r"); | ||
| 25 : | $config = ""; | ||
| 26 : | $session =& $request->session(); | ||
| 27 : | |||
| 28 : | andphe | 861 | $langfile = $root.DIRECTORY_SEPARATOR.'language'.DIRECTORY_SEPARATOR.$lang.'.xml'; |
| 29 : | $p = xml_parser_create(); | ||
| 30 : | xml_parser_set_option($p, XML_OPTION_CASE_FOLDING, 0); | ||
| 31 : | xml_parser_set_option($p, XML_OPTION_SKIP_WHITE, 1); | ||
| 32 : | xml_parse_into_struct($p, implode("", file($langfile)), $values); | ||
| 33 : | xml_parser_free($p); | ||
| 34 : | foreach($values as $key => $value) | ||
| 35 : | { | ||
| 36 : | if ($value['tag'] == 'param') { | ||
| 37 : | $name = $value['attributes']['name']; | ||
| 38 : | $language[$name] = $value['attributes']['default']; | ||
| 39 : | } | ||
| 40 : | } | ||
| 41 : | csouza | 403 | while(!feof($fp)){ |
| 42 : | $buffer = fgets($fp,4096); | ||
| 43 : | andphe | 861 | if (strstr($buffer,"\$mosConfig_locale =")){ |
| 44 : | $config .= "\$mosConfig_locale = '{$lang}';\n"; | ||
| 45 : | } elseif (strstr($buffer,"\$mosConfig_lang =")){ | ||
| 46 : | $locales = explode (",",$language['locale']); | ||
| 47 : | $config .= "\$mosConfig_lang = \"{$locales[3]}\";\n"; | ||
| 48 : | andphe | 1685 | } elseif (strstr($buffer,"\$mosConfig_charset =")){ |
| 49 : | $config .= "\$mosConfig_charset = \"{$language['charset']}\";\n"; | ||
| 50 : | csouza | 403 | } else { |
| 51 : | $config .= $buffer; | ||
| 52 : | } | ||
| 53 : | } | ||
| 54 : | fclose($fp); | ||
| 55 : | if ($fp = fopen("../configuration.php","w")){ | ||
| 56 : | fputs($fp, $config, strlen($config)); | ||
| 57 : | fclose($fp); | ||
| 58 : | $session['mosmsg'] = T_('Default Language succesfully updated!'); | ||
| 59 : | } else { | ||
| 60 : | $session['mosmsg'] = T_('Error! Make sure that configuration.php is writeable.'); | ||
| 61 : | } | ||
| 62 : | return $controller->redirect(); | ||
| 63 : | } | ||
| 64 : | } | ||
| 65 : | ?> |
| ViewVC Help | |
| Powered by ViewVC 1.0.0 |
Web Hosting provided by Network Redux.

