set_focus('tab', 'options', null);
if (!can_perform('canadmintools'))
{
admin_login();
}
// ###################################################################
if (empty($_REQUEST['do']))
{
$_REQUEST['do'] = 'modify';
}
// ###################################################################
if ($_REQUEST['do'] == 'kill')
{
$language = new LanguageAPI();
$language->set('languageid', $input->in['languageid']);
$language->set_condition();
$language->delete();
$admin->redirect('language.php?do=modify');
}
// ###################################################################
if ($_REQUEST['do'] == 'delete')
{
$admin->page_confirm(T('Are you sure you want to delete this language?'), 'language.php', 'kill', array('languageid' => $input->inputClean('languageid', TYPE_UINT)));
}
// ###################################################################
if ($_POST['do'] == 'insert')
{
$language = new LanguageAPI();
$language->set('title', $input->in['title']);
$language->set('charset', $input->in['charset']);
$language->set('direction', $input->in['direction']);
$language->set('userselect', $input->in['userselect']);
$language->set('langcode', $input->in['langcode']);
$language->insert();
$admin->redirect('language.php?do=modify');
}
// ###################################################################
if ($_REQUEST['do'] == 'add')
{
NavLinks::languagesAdd();
$navigator->set_focus('link', 'options-languages-add', 'options-languages');
$admin->page_start(T('New Language'));
$admin->form_start('language.php', 'insert');
$admin->table_start();
$admin->table_head(T('New Language'));
$admin->row_input(T('Title'), 'title');
$admin->row_input(T('Gettext Language Code (language_COUNTRY)'), 'langcode');
$admin->row_input(T('Character Set'), 'charset', 'utf-8');
$admin->list_item(T('Left-to-Right'), 'ltr', true);
$admin->list_item(T('Right-to-Left'), 'rtl');
$admin->row_list(T('Direction'), 'direction');
$admin->row_yesno(T('User Selectable'), 'userselect', true);
$admin->row_submit();
$admin->table_end();
$admin->form_end();
$admin->page_end();
}
// ###################################################################
if ($_POST['do'] == 'update')
{
$language = new LanguageAPI();
$language->set('languageid', $input->in['languageid']);
$language->set_condition();
$language->set('title', $input->in['title']);
$language->set('charset', $input->in['charset']);
$language->set('direction', $input->in['direction']);
$language->set('userselect', $input->in['userselect']);
$language->set('langcode', $input->in['langcode']);
$language->update();
$admin->redirect('language.php?do=modify');
}
// ###################################################################
if ($_REQUEST['do'] == 'edit')
{
NavLinks::languagesEdit($input->in['languageid']);
$navigator->set_focus('link', 'options-languages-edit', 'options-languages');
$languageapi = new LanguageAPI();
$languageapi->set('languageid', $input->in['languageid']);
$languageapi->set_condition();
$languageapi->fetch();
$language =& $languageapi->record;
$admin->page_start(T('Edit Language'));
$admin->form_start('language.php', 'update');
$admin->table_start();
$admin->table_head(sprintf(T('Edit Language - %1$s'), $language['title']));
$admin->form_hidden_field('languageid', $language['languageid']);
$admin->row_input(T('Title'), 'title', $language['title']);
$admin->row_input(T('Gettext Language Code (language_COUNTRY)'), 'langcode', $language['langcode']);
$admin->row_input(T('Character Set'), 'charset', $language['charset']);
$admin->list_item(T('Left-to-Right'), 'ltr', (($language['direction'] == 'ltr') ? true : false));
$admin->list_item(T('Right-to-Left'), 'rtl', (($language['direction'] == 'rtl') ? true : false));
$admin->row_list(T('Direction'), 'direction');
$admin->row_yesno(T('User Selectable'), 'userselect', $language['userselect']);
$admin->row_submit();
$admin->table_end();
$admin->form_end();
$admin->page_end();
}
// ###################################################################
if ($_REQUEST['do'] == 'modify')
{
NavLinks::languagesAdd();
$navigator->set_focus('link', 'options-pages-languages', 'options-pages');
$admin->page_start(T('Manage Languages'));
$admin->table_start();
$admin->table_head(T('Manage Languages'), 3, 'language_manage');
$admin->table_column_head(array(T('Title'), T('Language Code / Charset'), T('Options')));
$languages = $db->query("SELECT * FROM " . TABLE_PREFIX . "language ORDER BY languageid ASC");
foreach ($languages as $language)
{
$admin->row_multi_item(array(
"$language[title]" => 'l',
$language['langcode'] . ' / ' . $language['charset'] => 'c',
((bugdar::$options['defaultlanguage'] == $language['languageid']) ? '' . T('DEFAULT LANGUAGE') . ' / ' : '') . ($language['userselect'] ? T('User Selectable') : T('Private')) => 'c'
));
}
$admin->table_end();
$admin->page_end();
}
?>