[ Index ]

PHP Cross Reference of Mambo 4.6.5

[ Variables ]     [ Functions ]     [ Classes ]     [ Constants ]     [ Statistics ]

title

Body

[close]

/administrator/components/com_languages/actions/ -> default.action.php (source)

   1  <?php
   2  /**
   3  * @package Mambo
   4  * @subpackage Languages
   5  * @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  
  17  defined( '_VALID_MOS' ) or die( 'Direct Access to this location is not allowed.' );
  18  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          $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          while(!feof($fp)){
  42              $buffer = fgets($fp,4096);
  43              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              } elseif (strstr($buffer,"\$mosConfig_charset =")){
  49                  $config .= "\$mosConfig_charset = \"{$language['charset']}\";\n";
  50              } 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  ?>