Templateize admin/userhelp.php
authorRobert Sesek <rsesek@bluestatic.org>
Fri, 20 Mar 2009 04:21:16 +0000 (00:21 -0400)
committerRobert Sesek <rsesek@bluestatic.org>
Fri, 20 Mar 2009 04:21:16 +0000 (00:21 -0400)
* 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
admin/templates/userhelp.html [new file with mode: 0644]
admin/templates/userhelp_add.html [new file with mode: 0644]
admin/userhelp.php

index 15d32bcedcac45f708a17b5133de955590fccd64..0b05df3a1148999c310ff3ca1d82b07778a7179b 100644 (file)
@@ -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 (file)
index 0000000..8ac754a
--- /dev/null
@@ -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&amp;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 (file)
index 0000000..9149107
--- /dev/null
@@ -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
index 2217796147c6ef00302e41ea2f4224b30e51ff37..2e440fd1332adee0dbd00f2aaa2ca0e77b9a0ca5 100755 (executable)
@@ -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&amp;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