query_first("SELECT COUNT(*) AS count FROM language");
if ($count['count'] < 2)
{
$admin->error($lang->string('At least one language needs to be present. Deleting this language would violate that.'));
}
$language = $db->query_first("SELECT * FROM language WHERE languageid = " . intval($bugsys->in['languageid']));
if ($language['default'])
{
$admin->error($lang->string('You cannot delete the default language. Please select another language to be the default language and then delete this one.'));
}
$db->query("DELETE FROM language WHERE languageid = " . intval($bugsys->in['languageid']));
$db->query("DELETE FROM localization WHERE languageid = " . intval($bugsys->in['languageid']));
build_languages();
$admin->redirect('language.php?do=modify');
}
// ###################################################################
if ($_REQUEST['do'] == 'delete')
{
$admin->page_confirm($lang->string('Are you sure you want to delete this language?'), 'language.php?do=kill&languageid=' . intval($bugsys->in['languageid']));
}
// ###################################################################
if ($_POST['do'] == 'insert')
{
$languageid = $db->query("
INSERT INTO language
(title, charset, direction, userselect, debug, filename)
VALUES
('" . $bugsys->in['title'] . "', '" . $bugsys->in['charset'] . "',
'" . $bugsys->in['direction'] . "', " . intval($bugsys->in['userselect']) . ",
" . intval($bugsys->in['debug']) . ", '" . $bugsys->in['filename'] . "'
)"
);
build_languages();
build_language_cache($languageid);
}
// ###################################################################
if ($_REQUEST['do'] == 'add')
{
$admin->page_start($lang->string('New Language'));
$admin->form_start('language.php', 'update');
$admin->table_start();
$admin->table_head($lang->string('New Language'));
$admin->row_input($lang->string('Title'), 'title');
$admin->row_input($lang->string('Character Set'), 'charset');
$admin->list_item($lang->string('Left-to-Right'), 'ltr', true);
$admin->list_item($lang->string('Right-to-Left'), 'rtl');
$admin->row_list($lang->string('Direction'), 'direction');
$admin->row_input($lang->string('Path to XML'), 'filename');
$admin->row_yesno($lang->string('User Selectable'), 'userselect', true);
$admin->row_yesno($lang->string('Debug Mode (run directly from XML)'), 'langdebug', false);
$admin->row_submit();
$admin->table_end();
$admin->form_end();
$admin->page_end();
}
// ###################################################################
if ($_POST['do'] == 'update')
{
$db->query("
UPDATE language
SET title = '" . $bugsys->in['title'] . "',
charset = '" . $bugsys->in['charset'] . "',
direction = '" . $bugsys->in['direction'] . "',
userselect = " . intval($bugsys->in['userselect']) . ",
debug = " . intval($bugsys->in['langdebug']) . ",
filename = '" . $bugsys->in['filename'] . "'
WHERE languageid = " . intval($bugsys->in['languageid'])
);
build_languages();
$admin->redirect('language.php?do=modify');
}
// ###################################################################
if ($_REQUEST['do'] == 'edit')
{
$language = $db->query_first("SELECT * FROM " . TABLE_PREFIX . "language WHERE languageid = " . intval($bugsys->in['languageid']));
if (!$language)
{
$admin->error($lang->getlex('error_invalid_id'));
}
$admin->page_start($lang->string('Edit Language'));
$admin->form_start('language.php', 'update');
$admin->table_start();
$admin->table_head(sprintf($lang->string('Edit Language - %1$s'), $language['title']));
$admin->form_hidden_field('languageid', $language['languageid']);
$admin->row_input($lang->string('Title'), 'title', $language['title']);
$admin->row_input($lang->string('Character Set'), 'charset', $language['charset']);
$admin->list_item($lang->string('Left-to-Right'), 'ltr', (($language['direction'] == 'ltr') ? true : false));
$admin->list_item($lang->string('Right-to-Left'), 'rtl', (($language['direction'] == 'rtl') ? true : false));
$admin->row_list($lang->string('Direction'), 'direction');
$admin->row_input($lang->string('Path to XML'), 'filename', $language['filename']);
$admin->row_yesno($lang->string('User Selectable'), 'userselect', $language['userselect']);
$admin->row_yesno($lang->string('Debug Mode (run directly from XML)'), 'langdebug', (bool)$language['debug']);
$admin->row_submit();
$admin->table_end();
$admin->form_end();
$admin->page_end();
}
// ###################################################################
if ($_REQUEST['do'] == 'reload')
{
$language = $db->query_first("SELECT * FROM " . TABLE_PREFIX . "language WHERE languageid = " . intval($bugsys->in['languageid']));
if (!$language)
{
$admin->error($lang->getlex('error_invalid_id'));
}
build_language_cache($language['languageid']);
$admin->redirect('language.php?do=modify');
}
// ###################################################################
if ($_REQUEST['do'] == 'modify')
{
$admin->page_start($lang->string('Manage Languages'));
$admin->table_start();
$admin->table_head($lang->string('Manage Languages'), 4);
$admin->table_column_head(array($lang->string('Title'), $lang->string('Charset'), $lang->string('Options'), $lang->string('Actions')));
$languages = $db->query("SELECT * FROM " . TABLE_PREFIX . "language ORDER BY languageid ASC");
while ($language = $db->fetch_array($languages))
{
$admin->row_multi_item(array(
$language['title'] => 'l',
$language['charset'] => 'c',
(($language['default']) ? '' . $lang->string('DEFAULT LANGUAGE') . ' / ' : '') . ($language['userselect'] ? $lang->string('User Selectable') : $lang->string('Private')) => 'c',
"[" . $lang->string('Edit Settings') . "] [" . $lang->string('Reload Language XML') . "]" => 'c'
));
}
$admin->row_span('[' . $lang->string('Add New Language') . ']', 'tfoot', 'center', 4);
$admin->table_end();
$admin->page_end();
}
/*=====================================================================*\
|| ###################################################################
|| # $HeadURL$
|| # $Id$
|| ###################################################################
\*=====================================================================*/
?>