Templateize admin/userhelp.php
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
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 @@
<ul>
<li id="nav_system_settings"><a href="settings.php"><%- T('Bugdar Settings') %></a></li>
<li id="nav_system_language"><a href="language.php"><%- T('Languages') %></a></li>
- <li><a href="userhelp.php"><%- T('User Help Items') %></a></li>
+ <li id="nav_system_userhelp"><a href="userhelp.php"><%- T('User Help Items') %></a></li>
</ul>
</li>
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'] %>
+<html xmlns="http://www.w3.org/1999/xhtml" lang="<%- $stylevar['lang'] %>" xml:lang="<%- $stylevar['lang'] %>" dir="<%- $stylevar['lang_dir'] %>">
+<head>
+ <%- $templates['headinclude'] %>
+ <title><%- $templates['title'] %> - <%- T('Edit User Help') %></title>
+</head>
+
+<body>
+
+<%- $templates['nav'] %>
+
+<div id="title"><%- T('Edit User Help') %></div>
+
+<div id="body">
+
+<%- admin_flash() %>
+
+<form action="userhelp.php" method="post">
+<input type="hidden" name="do" value="update" />
+
+<table>
+<thead>
+ <tr><td colspan="2"><%- T('Edit User Help') %></td></tr>
+</thead>
+
+<% foreach ($topics as $topic): %>
+<tr class="alt1">
+ <td>
+ <div><input type="text" class="input" name="help[<%- $topic['keystring'] %>][title]" value="<%- $topic['title'] %>" size="35" /></div>
+ <div>
+ <em><%- $topic['keystring'] %></em>
+ <% if (!in_array($topic['keystring'], UserHelpAPI::not_able_to_delete())): %><a href="userhelp.php?do=delete&keystring=<%- $topic['keystring'] %>">[<%- T('Delete') %>]</a><% endif %>
+ </div>
+ </td>
+ <td><textarea name="help[<%- $topic['keystring'] %>][body]"><%- $topic['body'] %></textarea></td>
+</tr>
+<% endforeach %>
+
+</table>
+
+<div class="submit">
+ <input type="submit" value="<%- T('Save') %>" />
+ <input type="reset" value="<%- T('Reset') %>" />
+ <a href="userhelp.php?do=add" class="button"><%- T('Add New Item') %></a>
+</div>
+
+</form>
+
+
+<%- admin_footer() %>
+
+</div>
+
+<script type="text/javascript"> nav_init("system", "system_userhelp"); </script>
+
+</body>
+
+</html>
\ 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'] %>
+<html xmlns="http://www.w3.org/1999/xhtml" lang="<%- $stylevar['lang'] %>" xml:lang="<%- $stylevar['lang'] %>" dir="<%- $stylevar['lang_dir'] %>">
+<head>
+ <%- $templates['headinclude'] %>
+ <title><%- $templates['title'] %> - <%- T('New Help Text') %></title>
+</head>
+
+<body>
+
+<%- $templates['nav'] %>
+
+<div id="title"><%- T('Manage Languages') %></div>
+
+<div id="body">
+
+<%- admin_flash() %>
+
+<form action="userhelp.php" method="post">
+<input type="hidden" name="do" value="insert" />
+
+<fieldset>
+ <legend><%- T('New Help Text') %></legend>
+
+ <dl>
+
+ <dt><label for="l_title"><%- T('Topic Title') %></label></dt>
+ <dd><input type="text" name="title" id="l_title" /></dd>
+
+ <dt>
+ <label for="keystring">
+ <%- T('Unique Key') %>
+ <dfn><%- T('This should contain lonly owercase letters, underscores, and numbers.') %></dfn>
+ </label>
+ </dt>
+ <dd><input type="text" name="keystring" id="keystring" /></dd>
+
+ <dt><label for="body"><%- T('Body Text') %></label></dt>
+ <dd><textarea id="body"></textarea></dd>
+
+ </dl>
+</fieldset>
+
+<div class="submit">
+ <input type="submit" value="<%- T('Save') %>" />
+ <input type="reset" value="<%- T('Reset') %>" />
+</div>
+
+<%- admin_footer() %>
+
+</div>
+
+</body>
+
+<script type="text/javascript"> nav_init("system", "system_userhelp"); </script>
+
+</body>
+
+</html>
\ 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<br />(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 = '<input type="text" class="input" name="help[' . $topic['keystring'] . '][title]" value="' . $topic['title'] . '" size="35" />';
- $delete = (!in_array($topic['keystring'], UserHelpAPI::not_able_to_delete()) ? '<br /><br /><a href="userhelp.php?do=delete&keystring=' . $topic['keystring'] . '">[' . T('Delete') . ']</a>' : '');
-
- $admin->row_textarea($inputfield . '<br /><em>' . $topic['keystring'] . '</em>' . $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