2 /************************************************************************/
\r
4 /************************************************************************/
\r
5 /* Copyright (c) 2010 */
\r
6 /* Inclusive Design Institute */
\r
8 /* This program is free software. You can redistribute it and/or */
\r
9 /* modify it under the terms of the GNU General Public License */
\r
10 /* as published by the Free Software Foundation. */
\r
11 /************************************************************************/
\r
13 define('TR_INCLUDE_PATH', '../include/');
\r
15 include(TR_INCLUDE_PATH.'vitals.inc.php');
\r
16 include_once(TR_INCLUDE_PATH.'classes/DAO/LanguagesDAO.class.php');
\r
17 include_once(TR_INCLUDE_PATH.'classes/DAO/LangCodesDAO.class.php');
\r
18 include_once(TR_INCLUDE_PATH.'classes/Language/LanguageUtility.class.php');
\r
20 if (isset($_GET["id"]))
\r
22 $pieces = explode('_', $_GET['id'], 2);
\r
23 $lang_code = $pieces[0];
\r
24 $charset = $pieces[1];
\r
27 $languagesDAO = new LanguagesDAO();
\r
28 $langCodesDAO = new LangCodesDAO();
\r
31 if (isset($_POST['cancel']))
\r
33 $msg->addFeedback('CANCELLED');
\r
34 header('Location: index.php');
\r
37 else if (isset($_POST['save']))
\r
39 if (isset($_GET["id"])) // edit existing language
\r
41 if ($languagesDAO->Update($lang_code,
\r
44 $addslashes(trim($_POST['native_name'])),
\r
45 $addslashes(trim($_POST['english_name'])),
\r
48 $msg->addFeedback('ACTION_COMPLETED_SUCCESSFULLY');
\r
49 header('Location: index.php');
\r
53 else // create a new language
\r
55 if (isset($_POST['locale']) && $_POST['locale'] <> '')
\r
56 $language_code = $_POST['lang_code'] . TR_LANGUAGE_LOCALE_SEP. $_POST['locale'];
\r
58 $language_code = $_POST['lang_code'];
\r
60 if ($languagesDAO->Create($language_code,
\r
61 $addslashes(trim($_POST['charset'])),
\r
63 $addslashes(trim($_POST['native_name'])),
\r
64 $addslashes(trim($_POST['english_name'])),
\r
67 $msg->addFeedback('ACTION_COMPLETED_SUCCESSFULLY');
\r
68 header('Location: index.php');
\r
74 // interface display
\r
75 if (isset($lang_code) && isset($charset))
\r
77 // edit existing guideline
\r
78 $row = $languagesDAO->getByLangCodeAndCharset($lang_code, $charset);
\r
79 $row['lang_code'] = LanguageUtility::getParentCode($row['language_code']);
\r
80 $row['locale'] = LanguageUtility::getLocale($row['language_code']);
\r
82 $savant->assign('row', $row);
\r
85 $savant->assign('rows_lang', $langCodesDAO->GetAll());
\r
87 $savant->display('language/language_add_edit.tmpl.php');
\r