From afc33a9415a37b3707b601464e01b08c6cb44030 Mon Sep 17 00:00:00 2001 From: Robert Sesek Date: Fri, 20 Mar 2009 00:21:16 -0400 Subject: [PATCH] Templateize admin/userhelp.php * admin/templates/nav.html: Link up the userhelp page * admin/userhelp.php: Convert to using new admin architecture * admin/templates/userhelp.html: New file * admin/templates/userhelp_add.html: New file --- admin/templates/nav.html | 2 +- admin/templates/userhelp.html | 58 ++++++++++++++++++++++++++++ admin/templates/userhelp_add.html | 58 ++++++++++++++++++++++++++++ admin/userhelp.php | 64 +++++-------------------------- 4 files changed, 126 insertions(+), 56 deletions(-) create mode 100644 admin/templates/userhelp.html create mode 100644 admin/templates/userhelp_add.html diff --git a/admin/templates/nav.html b/admin/templates/nav.html index 15d32bc..0b05df3 100644 --- a/admin/templates/nav.html +++ b/admin/templates/nav.html @@ -15,7 +15,7 @@ diff --git a/admin/templates/userhelp.html b/admin/templates/userhelp.html new file mode 100644 index 0000000..8ac754a --- /dev/null +++ b/admin/templates/userhelp.html @@ -0,0 +1,58 @@ +<%- $templates['doctype'] %> + + + <%- $templates['headinclude'] %> + <%- $templates['title'] %> - <%- T('Edit User Help') %> + + + + +<%- $templates['nav'] %> + +
<%- T('Edit User Help') %>
+ +
+ +<%- admin_flash() %> + +
+ + + + + + + +<% foreach ($topics as $topic): %> + + + + +<% endforeach %> + +
<%- T('Edit User Help') %>
+
+
+ <%- $topic['keystring'] %> + <% if (!in_array($topic['keystring'], UserHelpAPI::not_able_to_delete())): %>[<%- T('Delete') %>]<% endif %> +
+
+ + + +
+ + +<%- admin_footer() %> + +
+ + + + + + \ No newline at end of file diff --git a/admin/templates/userhelp_add.html b/admin/templates/userhelp_add.html new file mode 100644 index 0000000..9149107 --- /dev/null +++ b/admin/templates/userhelp_add.html @@ -0,0 +1,58 @@ +<%- $templates['doctype'] %> + + + <%- $templates['headinclude'] %> + <%- $templates['title'] %> - <%- T('New Help Text') %> + + + + +<%- $templates['nav'] %> + +
<%- T('Manage Languages') %>
+ +
+ +<%- admin_flash() %> + +
+ + +
+ <%- T('New Help Text') %> + +
+ +
+
+ +
+ +
+
+ +
+
+ +
+
+ +
+ + +
+ +<%- admin_footer() %> + +
+ + + + + + + + \ No newline at end of file diff --git a/admin/userhelp.php b/admin/userhelp.php index 2217796..2e440fd 100755 --- a/admin/userhelp.php +++ b/admin/userhelp.php @@ -23,12 +23,6 @@ require_once('./global.php'); require_once('./includes/api_userhelp.php'); require_once('./includes/functions_datastore.php'); -APIError(array(new API_Error_Handler($admin), 'admin_error')); - -NavLinks::optionsPages(); -NavLinks::userhelpAdd(); -$navigator->set_focus('tab', 'options', null); - if (!can_perform('canadmintools')) { admin_login(); @@ -51,7 +45,7 @@ if ($_REQUEST['do'] == 'kill') build_user_help(); - $admin->redirect('userhelp.php?do=modify'); + admin_flash_redirect('userhelp.php?do=modify'); } // ################################################################### @@ -71,81 +65,41 @@ if ($_POST['do'] == 'insert') $help->set('body', $input->in['body']); $help->insert(); - $admin->redirect('userhelp.php?do=modify'); + admin_flash_redirect('userhelp.php?do=modify'); } // ################################################################### if ($_REQUEST['do'] == 'add') { - $navigator->set_focus('link', 'options-userhelp-add', 'options-userhelp'); - - $admin->page_start(T('New Help Text')); - - $admin->form_start('userhelp.php', 'insert'); - - $admin->table_start(); - $admin->table_head(T('New Help Text')); - - $admin->row_input(T('Topic Title'), 'title'); - $admin->row_input(T('Unique Key
(lowercase letters, underscores, and numbers only)'), 'keystring'); - $admin->row_textarea(T('Body Text'), 'body'); - - $admin->row_submit(); - - $admin->table_end(); - - $admin->form_end(); - - $admin->page_end(); + BSTemplate::fetch('userhelp_add')->evaluate()->flush(); } // ################################################################### if ($_POST['do'] == 'update') { - foreach ($input->in['help'] AS $keystring => $fields) + foreach ($input->in['help'] as $keystring => $fields) { $help = new UserHelpAPI(); - $help->norunners = array('post_update'); $help->set('keystring', $keystring); - $help->set_condition(); $help->set('title', $fields['title']); $help->set('body', $fields['body']); - $help->update(); + $help->update(true, false); } build_user_help(); - $admin->redirect('userhelp.php?do=modify'); + admin_flash_redirect('userhelp.php?do=modify'); } // ################################################################### if ($_REQUEST['do'] == 'modify') { - $navigator->set_focus('link', 'options-pages-userhelp', 'options-pages'); - - $admin->page_start(T('Edit User Help')); - - $admin->form_start('userhelp.php', 'update'); - - $admin->table_start(); - $admin->table_head(T('Edit User Help')); - - $topics = $db->query("SELECT * FROM " . TABLE_PREFIX . "fieldhelp ORDER BY keystring ASC"); - foreach ($topics as $topic) - { - $inputfield = ''; - $delete = (!in_array($topic['keystring'], UserHelpAPI::not_able_to_delete()) ? '

[' . T('Delete') . ']' : ''); - - $admin->row_textarea($inputfield . '
' . $topic['keystring'] . '' . $delete, 'help[' . $topic['keystring'] . '][body]', $topic['body']); - } - - $admin->row_submit(); - $admin->table_end(); - - $admin->page_end(); + $admin = new BSTemplate('userhelp'); + $admin->vars['topics'] = $db->query("SELECT * FROM " . TABLE_PREFIX . "fieldhelp ORDER BY keystring ASC"); + $admin->evaluate()->flush(); } ?> \ No newline at end of file -- 2.22.5