Deprecated: Assigning the return value of new by reference is deprecated in /home/bluestat/public_html/source/index.php on line 477
Bugdar - Commitdiff - ViewGit - Blue Static

Switch the 'modify' code of admin/field.php to use templates

Robert Sesek [2009-04-09 14:33]
Switch the 'modify' code of admin/field.php to use templates

* admin/field.php
* admin/templates/field.html
* admin/templates/nav.html
diff --git a/admin/field.php b/admin/field.php
index 6abc03e..9bb4a29 100644
--- a/admin/field.php
+++ b/admin/field.php
@@ -19,14 +19,13 @@
 || ###################################################################
 \*=====================================================================*/

+$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
index 0000000..c8d64ff
--- /dev/null
+++ b/admin/templates/field.html
@@ -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
diff --git a/admin/templates/nav.html b/admin/templates/nav.html
index b70f900..9a7e58c 100644
--- a/admin/templates/nav.html
+++ b/admin/templates/nav.html
@@ -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>