languages.php
上传用户:gzy2002
上传日期:2010-02-11
资源大小:1785k
文件大小:8k
- <?php
- // +-------------------------------------------------------------+
- // | DeskPRO v [2.0.1 Production]
- // | Copyright (C) 2001 - 2004 Headstart Solutions Limited
- // | Supplied by WTN-WDYL
- // | Nullified by WTN-WDYL
- // | Distribution via WebForum, ForumRU and associated file dumps
- // +-------------------------------------------------------------+
- // | DESKPRO IS NOT FREE SOFTWARE
- // +-------------------------------------------------------------+
- // | License ID : Full Enterprise License =) ...
- // | License Owner : WTN-WDYL Team
- // +-------------------------------------------------------------+
- // | $RCSfile: languages.php,v $
- // | $Date: 2004/02/12 21:16:57 $
- // | $Revision: 1.28 $
- // +-------------------------------------------------------------+
- // | File Details:
- // | - Language maintenance (administration interface)
- // +-------------------------------------------------------------+
- error_reporting(E_ALL & ~E_NOTICE);
- // start file
- require("./global.php");
- // globalise variables
- $global = array (
- array('id')
- );
- rg($global);
- // default do
- $_REQUEST['do'] = trim($_REQUEST['do']);
- if (!isset($_REQUEST['do']) or $_REQUEST['do'] == "") {
- $_REQUEST['do'] = "view";
- }
- // do a check to see if languages are enabled
- if (!$settings['language_on']) {
- $header_note = table_border("Note that until you enable the multi-language interface your users will not be shown these language options. You can enable the multi-language interface in the <a href="settings.php">settings system</a>.") . "<br />";
- }
- ############################### UPDATE LANGUAGES ###############################
- if ($_REQUEST['do'] == "update") {
- if (!$_REQUEST['default']) {
- $message = 'You <B>must</B> specify a default language.';
- } else {
- $db->query("SELECT id FROM languages WHERE id = '" . addslashes($_REQUEST['default']) . "'");
- if (!$db->num_rows()) {
- $message = 'The language you specified as a default is not defined.';
- }
- }
- if ($message) {
- $_REQUEST['do'] = 'view';
- } else {
- while (list ($key, $value) = each ($_REQUEST[is_selectable])) {
- $db->query("UPDATE languages SET is_selectable = '" . addslashes(htmlspecialchars($value)) . "' WHERE id = '$key'");
- }
- while (list ($key, $value) = each ($_REQUEST[name])) {
- $db->query("UPDATE languages SET name = '" . addslashes(htmlspecialchars($value)) . "' WHERE id = '$key'");
- }
- $db->query("UPDATE settings SET value = " . $_REQUEST['default'] . " WHERE settings = 'default_language'");
- // default language must be 'selectable'
- $db->query("UPDATE languages SET is_selectable = 1 WHERE id = '$_REQUEST[default]'");
- get_settings();
- $_REQUEST['do'] = "view";
- }
- }
- ############################### CREATE LANGUAGE ###############################
- if ($_REQUEST['do'] == "add" OR $_REQUEST['do'] == 'edit') {
- $language = $db->query_return("SELECT * FROM languages WHERE id = '$id'");
- admin_header('Languages', 'Add New Language');
- echo $header_note;
- $table[] = array('<b>Name</b>', form_input('name', $language['name']));
- $table[] = array('<b>User Selectable</b>', form_radio_yn('is_selectable', '', 1));
- $table[] = array('<b>Country Code</b><br />See <a href="hxxp://lcweb.loc.gov/standards/iso639-2/englangn.html">here</a> for details', form_input('isocode', $language[isocode], 5));
- $table[] = array('<b>Character Set</b><br />See <a href="hxxp://en.wikipedia.org/wiki/ISO_8859">here</a> for details', form_input('contentype', iff($language[contenttype], $language[contentype], 'ISO-8859-1')));
- $table[] = array('<b>Text Direction</b>', form_select('direction', array('ltr' => 'Left => Right', 'rtl' => 'Right => Left'), '', $language[direction]));
- if ($_REQUEST['do'] == 'add') {
- table_header("Create New Language", 'languages.php', array('do' => 'new2'));
- table_content($columns, $table);
- table_footer('Create Language');
- } else {
- table_header("Update Language", 'languages.php', array('do' => 'edit2', 'id' => $id));
- table_content($columns, $table);
- table_footer('Update Language');
- }
- }
- ############################### UPDATE LANGUAGE (2) ###############################
- if ($_REQUEST['do'] == "edit2") {
- $db->query("UPDATE languages SET
- name = '" . addslashes(htmlspecialchars($_REQUEST['name'])) . "',
- is_selectable = $_REQUEST[is_selectable],
- isocode = '" . addslashes($_REQUEST[isocode]) . "',
- contenttype = '" . addslashes($_REQUEST[contentype]) . "',
- direction = '" . addslashes($_REQUEST[direction]) . "',
- custom = 1
- WHERE id = '$id'
- ");
- jump('languages.php?do=view', 'Language Updated');
- }
- ############################### CREATE LANGUAGE (2) ###############################
- if ($_REQUEST['do'] == "new2") {
- $db->query("INSERT INTO languages SET
- name = '" . addslashes(htmlspecialchars($_REQUEST['name'])) . "',
- is_selectable = $_REQUEST[is_selectable],
- custom = 1
- ");
- jump('languages.php?do=view', 'Language Created');
- }
- ############################### DELETE LANGUAGE ###############################
- if ($_REQUEST['do'] == "delete") {
- $language = $db->query_return("SELECT * FROM languages WHERE id = $id");
-
- if ($language['default'] == "1") {
- alert('You can not delete a default language.');
- $_REQUEST['do'] = 'view';
- } else {
- $db->query("DELETE FROM languages WHERE id = $id");
- $db->query("DELETE FROM template_words WHERE language = $id");
- $db->query("DELETE FROM template_email WHERE language = $id");
- $db->query("UPDATE user SET language = $settings[default_language] WHERE language = $id");
- $category_languages = unserialize(get_data('category_languages'));
- $priority_languages = unserialize(get_data('priority_languages'));
- unset($category_languages[$id]);
- unset($priority_languages[$id]);
- update_data('category_languages', $category_languages);
- update_data('priority_languages', $priority_languages);
- jump('languages.php', 'Language and associated templates/words deleted');
- }
- }
- ############################### VIEW LANGUAGES ###############################
- if ($_REQUEST['do'] == "view") {
- admin_header('Languages', 'View Languages');
- echo $header_note;
- echo table_border("Non English languages have been supplied by other DeskPRO users. We can make no assurances as to the accuracy of these translations and suggest that if you rely on a language provided that you check the quality of the translation.");
- $setting = $db->query_return("SELECT * FROM settings WHERE settings = 'default_language'");
- $default = $settings[default_language];
- $db->query("SELECT * FROM languages");
- while ($lang = $db->row_array()) {
- if ($lang[id] == $default) {
- $extra = " checked=checked";
- } else {
- unset($extra);
- }
- $table[] = array(
- form_input($lang[id], $lang[name], 30, 'name'),
- "<input type="radio" name="default" value="$lang[id]"$extra>",
- form_radio_yn($lang[id], 'is_selectable', $lang[is_selectable]),
- ifynb($lang[custom]),
- iff($lang[custom], "<a href="languages.php?do=delete&id=$lang[id]">delete</a>", "<I>n/a</I>"),
- "<a href="languages.php?do=edit&id=$lang[id]">edit</a>"
- );
- }
- $columns = array('Language', 'Default Language', 'User Selectable', 'Is Custom', 'Delete', 'Edit');
- table_header("The Avaliable Languages", 'languages.php', array('do' => 'update'));
- table_content($columns, $table);
- table_footer('Update Language Details');
- echo table_border("<b>Please note that selecting a language as default will automatically make it user selectable.</b>");
- }
- ##############################################################
- admin_footer();
- ?>