Switch the 'modify' code of admin/field.php to use templates master
authorRobert Sesek <rsesek@bluestatic.org>
Thu, 9 Apr 2009 14:33:35 +0000 (10:33 -0400)
committerRobert Sesek <rsesek@bluestatic.org>
Thu, 9 Apr 2009 14:33:53 +0000 (10:33 -0400)
* admin/field.php
* admin/templates/field.html
* admin/templates/nav.html

admin/field.php
admin/templates/field.html [new file with mode: 0644]
admin/templates/nav.html

index 6abc03e2da3c61fa137fc03f817ce7cf8d6164ed..9bb4a290f2c314f6fa0b0ffeea6b02970ee93b68 100644 (file)
 || ###################################################################
 \*=====================================================================*/
 
+$fetchtemplates = array(
+       'field'
+);
+
 require_once('./global.php');
 require_once('./includes/api_field.php');
 
-APIError(array(new API_Error_Handler($admin), 'admin_error'));
-
-NavLinks::fieldsPages();
-$navigator->set_focus('tab', 'fields', null);
-
 if (!can_perform('canadminfields'))
 {
        admin_login();
@@ -277,30 +276,9 @@ if ($_REQUEST['do'] == 'add' OR $_REQUEST['do'] == 'edit')
 
 if ($_REQUEST['do'] == 'modify')
 {
-       NavLinks::fieldsAdd();
-       $navigator->set_focus('link', 'fields-pages-fields', 'fields-pages');
-       
-       $admin->page_start(T('Additional Bug Fields'));
-       
-       $admin->table_start();
-       $admin->table_head(T('Additional Bug Fields'), 3, 'custom_bug_fields');
-       $admin->table_column_head(array(T('Display Name/Description'), T('Field ID'), T('Actions')));
-       
-       $fields = $db->query("SELECT * FROM " . TABLE_PREFIX . "bugfield ORDER BY fieldid ASC");
-       foreach ($fields as $field)
-       {
-               $admin->row_multi_item(
-                       array(
-                               "$field[name]<div class=\"smallfont\"><em>$field[description]</em></div>" => 'l',
-                               "$field[fieldid]" => 'c',
-                               "<a href=\"field.php?do=edit&amp;fieldid=$field[fieldid]\">[" . T('Edit') . "]</a> <a href=\"field.php?do=delete&amp;fieldid=$field[fieldid]\">[" . T('Delete') . "]</a>" => 'c'
-                       )
-               );
-       }
-       
-       $admin->table_end();
-       
-       $admin->page_end();
+       $tpl = new BSTemplate('field');
+       $tpl->vars['fields'] = $db->query("SELECT * FROM " . TABLE_PREFIX . "bugfield ORDER BY fieldid ASC");
+       $tpl->evaluate()->flush();
 }
 
 ?>
\ No newline at end of file
diff --git a/admin/templates/field.html b/admin/templates/field.html
new file mode 100644 (file)
index 0000000..c8d64ff
--- /dev/null
@@ -0,0 +1,51 @@
+<%- $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('Custom Fields') %></title>
+</head>
+
+<body>
+
+<%- $templates['nav'] %>
+
+<div id="title"><%- T('Custom Fields') %></div>
+
+<div id="body">
+
+<%- admin_flash() %>
+
+<table>
+<thead>
+       <tr><td colspan="3"><%- T('Custom Fields') %></td></tr>
+</thead>
+<tr class="headings">
+       <td style="width: 75%"><%- T('Display Name/Description') %></td>
+       <td style="width: 10%"><%- T('Field ID') %></td>
+       <td><%- T('Actions') %></td>
+</tr>
+<% $i = 0; foreach ($fields as $field): %>
+<tr class="alt<%- ($i % 2) + 1 %>">
+       <td>
+               <%- $field['name'] %>
+               <dfn><%- $field['description'] %></dfn>
+       </td>
+       <td style="text-align: center"><%- $field['fieldid'] %></td>
+       <td style="text-align: center">
+               <a class="button" href="field.php?do=edit&amp;fieldid=<%- $field['fieldid'] %>"><%- T('Edit') %></a>
+               <a class="button" href="field.php?do=delete&amp;fieldid=<%- $field['fieldid'] %>"><%- T('Delete') %></a>
+       </td>
+</tr>
+<% $i++ %>
+<% endforeach %>
+</table>
+
+<%- admin_footer() %>
+
+</div>
+
+<script type="text/javascript"> nav_init("fields", "fields_custom"); </script>
+
+</body>
+
+</html>
\ No newline at end of file
index b70f90023de104b6a9cf6d753c1b7c985eaf8f7c..9a7e58c8a352a1a83c6c1f58adeb1e250167123b 100644 (file)
@@ -23,7 +23,7 @@
                <li>
                        <ul>
                                <li id="nav_fields_product"><a href="product.php"><%- T('Products') %></a></li>
-                               <li><a href="field.php"><%- T('Custom Fields') %></a></li>
+                               <li id="nav_fields_custom"><a href="field.php"><%- T('Custom Fields') %></a></li>
                                <li><a href="priority.php"><%- T('Priorities') %></a></li>
                                <li><a href="resolution.php"><%- T('Resolutions') %></a></li>
                                <li><a href="severity.php"><%- T('Severities') %></a></li>