| 1 |
<?php |
<?php |
| 2 |
|
/** |
| 3 |
|
* @package Mambo |
| 4 |
|
* @subpackage Languages |
| 5 |
|
* @author Mambo Foundation Inc see README.php |
| 6 |
|
* @copyright Mambo Foundation Inc. |
| 7 |
|
* See COPYRIGHT.php for copyright notices and details. |
| 8 |
|
* @license GNU/GPL Version 2, see LICENSE.php |
| 9 |
|
* Mambo is free software; you can redistribute it and/or |
| 10 |
|
* modify it under the terms of the GNU General Public License |
| 11 |
|
* as published by the Free Software Foundation; version 2 of the License. |
| 12 |
|
*/ |
| 13 |
|
|
| 14 |
defined( '_VALID_MOS' ) or die( 'Direct Access to this location is not allowed.' ); |
defined( '_VALID_MOS' ) or die( 'Direct Access to this location is not allowed.' ); |
| 15 |
class saveAction extends Action |
class saveAction extends Action |
| 16 |
{ |
{ |
| 70 |
$language->author = 'Mambo Foundation Inc.'; |
$language->author = 'Mambo Foundation Inc.'; |
| 71 |
$language->authorurl = 'http://www.mambo-foundation.org'; |
$language->authorurl = 'http://www.mambo-foundation.org'; |
| 72 |
$language->authoremail = 'translation@mambo-foundation.org'; |
$language->authoremail = 'translation@mambo-foundation.org'; |
| 73 |
$language->copyright = '(C) 2005 - 2006 Mambo Foundation Inc.'; |
$language->copyright = 'Refer to copyright.php'; |
| 74 |
$language->license = 'http://www.gnu.org/copyleft/gpl.html GNU/GPL'; |
$language->license = 'http://www.gnu.org/copyleft/gpl.html GNU/GPL'; |
| 75 |
$language->setPlurals($_POST['plural_form']); |
$language->setPlurals($_POST['plural_form']); |
| 76 |
|
|
| 127 |
|
|
| 128 |
$catalog->setComments($_POST['comments']); |
$catalog->setComments($_POST['comments']); |
| 129 |
$catalog->setHeaders($_POST['headers']); |
$catalog->setHeaders($_POST['headers']); |
| 130 |
|
$plural_forms = $catalog->headers['Plural-Forms']; |
| 131 |
|
preg_match('/nplurals[\s]*[=]{1}[\s]*([\d]+);[\s]*plural[\s]*[=]{1}[\s]*(.*);/', $plural_forms, $matches); |
| 132 |
|
$is_plural = $matches[1] > 1; |
| 133 |
foreach ($_POST as $key => $value) { |
foreach ($_POST as $key => $value) { |
| 134 |
if (preg_match('/^([a-z]+[_]?[a-z]+?)[_]?([0-9]+)?_([0-9]+)$/', $key, $matches)) { |
if (preg_match('/^([a-z]+[_]?[a-z]+?)[_]?([0-9]+)?_([0-9]+)$/', $key, $matches)) { |
| 135 |
switch ($matches[1]) |
switch ($matches[1]) |
| 137 |
case 'msgid': |
case 'msgid': |
| 138 |
if (get_magic_quotes_gpc() == 1){ |
if (get_magic_quotes_gpc() == 1){ |
| 139 |
$value = stripslashes($value); |
$value = stripslashes($value); |
| 140 |
$value = htmlentities($value); |
//$value = htmlentities($value); |
| 141 |
} |
} |
| 142 |
$messages[$matches[3]]['msgid'] = $value; |
$messages[$matches[3]]['msgid'] = $value; |
| 143 |
break; |
break; |
| 144 |
case 'msgid_plural': |
case 'msgid_plural': |
| 145 |
|
if ($is_plural){ |
| 146 |
$messages[$matches[3]]['msgid_plural'] = $value; |
$messages[$matches[3]]['msgid_plural'] = $value; |
| 147 |
|
} |
| 148 |
break; |
break; |
| 149 |
case 'msgstr': |
case 'msgstr': |
| 150 |
if (!empty($messages[$matches[3]]['msgid_plural'])) { |
if (!empty($messages[$matches[3]]['msgid_plural'])) { |
| 168 |
foreach ($messages as $index => $arr) { |
foreach ($messages as $index => $arr) { |
| 169 |
if (strcmp($catalog->strings[$index]->msgid, $arr['msgid']) == 0) { |
if (strcmp($catalog->strings[$index]->msgid, $arr['msgid']) == 0) { |
| 170 |
$catalog->strings[$index]->setmsgstr($arr['msgstr']); |
$catalog->strings[$index]->setmsgstr($arr['msgstr']); |
| 171 |
if ($arr['fuzzy']) { |
$catalog->strings[$index]->msgid_plural = isset($arr['msgid_plural'])?$arr['msgid_plural']:null;; |
| 172 |
$catalog->strings[$index]->setfuzzy($arr['fuzzy']); |
$catalog->strings[$index]->setfuzzy($arr['fuzzy']); |
| 173 |
} |
} |
| 174 |
} |
} |
|
} |
|
| 175 |
$catalog->save(); |
$catalog->save(); |
| 176 |
|
|
| 177 |
$language = new mamboLanguage($lang); |
$language = new mamboLanguage($lang); |
| 178 |
$language->save(); |
$language->save(); |
| 179 |
|
|
| 180 |
$gettext_admin = new PHPGettextAdmin(); |
$configuration =& mamboCore::getMamboCore(); |
| 181 |
|
$gettext_admin = new PHPGettextAdmin($configuration->get('mosConfig_locale_use_gettext')); |
| 182 |
$gettext_admin->add_to_dict($domain, $textdomain, $lang, $language->charset); |
$gettext_admin->add_to_dict($domain, $textdomain, $lang, $language->charset); |
| 183 |
$catalog->load(); |
$catalog->load(); |
| 184 |
|
|