[ Index ]

PHP Cross Reference of Mambo 4.6.5

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

title

Body

[close]

/administrator/components/com_languages/actions/ -> publish.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 publishAction extends Action
  19  {
  20      function execute(&$controller, &$request)
  21      {
  22          $lang = mosGetParam( $_REQUEST, 'lang', array(0) ); 
  23          $root = mamboCore::get('rootPath');            
  24          $fp = fopen("../configuration.php","r");
  25          $config = "";
  26          
  27          $langfile = $root.DIRECTORY_SEPARATOR.'language'.DIRECTORY_SEPARATOR.$lang[0].'.xml';        
  28          $p = xml_parser_create();
  29          xml_parser_set_option($p, XML_OPTION_CASE_FOLDING, 0);
  30          xml_parser_set_option($p, XML_OPTION_SKIP_WHITE, 1);
  31          xml_parse_into_struct($p, implode("", file($langfile)), $values);
  32          xml_parser_free($p);
  33          foreach($values as $key => $value)
  34          {
  35              if ($value['tag'] == 'param') {
  36                  $name = $value['attributes']['name'];
  37                  $language[$name] = $value['attributes']['default'];
  38              }
  39          }        
  40          while(!feof($fp)){
  41              $buffer = fgets($fp,4096);
  42              if (strstr($buffer,"\$mosConfig_lang =")){
  43                  $config .= "\$mosConfig_lang = \"{$lang[0]}\";\n";
  44              } elseif (strstr($buffer,"\$mosConfig_locale =")){
  45                  $config .= "\$mosConfig_locale = \"{$language['locale']}\";\n";
  46              } elseif (strstr($buffer,"\$mosConfig_charset =")){
  47                  $config .= "\$mosConfig_charset = \"{$language['charset']}\";\n";
  48              } else {
  49                  $config .= $buffer;
  50              }
  51          }
  52          fclose($fp);
  53          if ($fp = fopen("../configuration.php","w")){
  54              fputs($fp, $config, strlen($config));
  55              fclose($fp);
  56              $request->setAttribute('msg', T_('Configuration succesfully updated!'));
  57          } else {
  58              $request->setAttribute('msg', T_('Error! Make sure that configuration.php is writeable.'));
  59          }                   
  60          return $controller->redirect();
  61      }
  62  }
  63  ?>