From e0622f800afd662f842df5624b946839c3ba3909 Mon Sep 17 00:00:00 2001 From: Robert Sesek Date: Thu, 26 Feb 2009 13:11:22 -0500 Subject: [PATCH] Update the admin/language.php to use templates * admin/language.php * admin/templates/language.html: New file * admin/templates/language_edit.html: New file * admin/templates/nav.html: Link up the nav page --- admin/language.php | 99 +++++------------------------- admin/templates/language.html | 48 +++++++++++++++ admin/templates/language_edit.html | 70 +++++++++++++++++++++ admin/templates/nav.html | 2 +- 4 files changed, 136 insertions(+), 83 deletions(-) create mode 100644 admin/templates/language.html create mode 100644 admin/templates/language_edit.html diff --git a/admin/language.php b/admin/language.php index 6c32068..91348ec 100644 --- a/admin/language.php +++ b/admin/language.php @@ -19,14 +19,13 @@ || ################################################################### \*=====================================================================*/ +$fetchtemplates = array( + 'language' +); + require_once('./global.php'); require_once('./includes/api_language.php'); -APIError(array(new API_Error_Handler($admin), 'admin_error')); - -NavLinks::optionsPages(); -$navigator->set_focus('tab', 'options', null); - if (!can_perform('canadmintools')) { admin_login(); @@ -45,10 +44,10 @@ if ($_REQUEST['do'] == 'kill') { $language = new LanguageAPI(); $language->set('languageid', $input->in['languageid']); - $language->set_condition(); + $language->setCondition(); $language->delete(); - $admin->redirect('language.php?do=modify'); + admin_flash_redirect('language.php?do=modify'); } // ################################################################### @@ -70,35 +69,14 @@ if ($_POST['do'] == 'insert') $language->set('langcode', $input->in['langcode']); $language->insert(); - $admin->redirect('language.php?do=modify'); + admin_flash_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(); + BSTemplate::fetch('language_edit')->evaluate()->flush(); } // ################################################################### @@ -107,7 +85,7 @@ if ($_POST['do'] == 'update') { $language = new LanguageAPI(); $language->set('languageid', $input->in['languageid']); - $language->set_condition(); + $language->setCondition(); $language->set('title', $input->in['title']); $language->set('charset', $input->in['charset']); $language->set('direction', $input->in['direction']); @@ -115,73 +93,30 @@ if ($_POST['do'] == 'update') $language->set('langcode', $input->in['langcode']); $language->update(); - $admin->redirect('language.php?do=modify'); + admin_flash_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->setCondition(); $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(); + $admin = new BSTemplate('language_edit'); + $admin->vars['language'] = $language->record; + $admin->evaluate()->flush(); } // ################################################################### 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(); + $admin = new BSTemplate('language'); + $admin->vars['languages'] = $db->query("SELECT * FROM " . TABLE_PREFIX . "language ORDER BY languageid ASC"); + $admin->evaluate()->flush(); } ?> \ No newline at end of file diff --git a/admin/templates/language.html b/admin/templates/language.html new file mode 100644 index 0000000..8dd8739 --- /dev/null +++ b/admin/templates/language.html @@ -0,0 +1,48 @@ +<%- $templates['doctype'] %> + + + <%- $templates['headinclude'] %> + <%- $templates['title'] %> - <%- T('Manage Languages') %> + + + + +<%- $templates['nav'] %> + +
<%- T('Manage Languages') %>
+ +
+ +<%- admin_flash() %> + + + + + + + + + + +<% foreach ($languages as $language): %><% BSFunctions::swap_css_classes() %> + + + + + +<% endforeach %> + +
<%- T('Manage Languages') %>
<%- T('Title') %><%- T('Language Code / Charset') %><%- T('Options') %>
<%- $language['title'] %><%- $language['langcode'] %> / <%- $language['charset'] %> + <% if (bugdar::$options['defaultlanguage'] == $language['languageid']): %><%- T('DEFAULT LANGUAGE') %> /<% endif %> + <% if ($language['userselect']): %><%- T('User Selectable') %><% else: %><%- T('Private') %><% endif %> +
<%- T('Add New Language') %>
+ +<%- admin_footer() %> + +
+ + + + + + \ No newline at end of file diff --git a/admin/templates/language_edit.html b/admin/templates/language_edit.html new file mode 100644 index 0000000..12ed9fe --- /dev/null +++ b/admin/templates/language_edit.html @@ -0,0 +1,70 @@ +<%- $templates['doctype'] %> + + + <%- $templates['headinclude'] %> + <%- $templates['title'] %> - <%- T('Manage Languages') %> + + + + +<%- $templates['nav'] %> + +
<%- T('Manage Languages') %>
+ +
+ +<%- admin_flash() %> + +
+ +<% if ($language): %><% endif %> + +
+ <%- ($language ? T('Edit Language') : T('New Language')) %> + +
+ +
+
+ +
+ +
+
+ +
+
+ +
+
+ +
+ +
+
<%- BSDecorator::yesno('userselect', $language['userselect']) %>
+ +
+
+ +
+ + +
+ +<%- admin_footer() %> + +
+ + + + + + + + \ No newline at end of file diff --git a/admin/templates/nav.html b/admin/templates/nav.html index e007bca..15d32bc 100644 --- a/admin/templates/nav.html +++ b/admin/templates/nav.html @@ -14,7 +14,7 @@
  • -- 2.43.5