Redesign index.php
authorRobert Sesek <rsesek@bluestatic.org>
Tue, 6 Jan 2009 06:14:28 +0000 (22:14 -0800)
committerRobert Sesek <rsesek@bluestatic.org>
Tue, 6 Jan 2009 06:14:28 +0000 (22:14 -0800)
* index.php: Rewrote for the template system
* templates/main.html: New file

admin/index.php
admin/templates/main.html [new file with mode: 0644]

index 10d1d24eda971626737b493745ee2b101d8b6629..2ccd9f1d6c6e72b1165c1cb68b0d0ac54fdb9b3b 100755 (executable)
 
 require_once('./global.php');
 
-NavLinks::optionsPages();
-$navigator->set_focus('tab', 'options', null);
-$navigator->set_focus('link', 'options-pages-home', 'options-pages');
-
-$admin->page_start(T('Home'));
+$template = new BSTemplate('main');
 
 // ###################################################################
+// do version check
 
 if (!(defined('NO_VERSION_CHECK') AND constant('NO_VERSION_CHECK') == true))
 {
+       $template->vars['versionCheck'] = true;
+       
        $check = @file_get_contents('http://www.bluestatic.org/versioncheck.php?prod=bugdar&ver=' . str_replace(' ', '-', bugdar::$options['trackerversion']));
        if (strpos($check, '<version-check>') !== false)
        {
-               $check = $bugsys->xml->parse($check);
-               if (isset($check['version-check']['update']))
+               $check = simplexml_load_string($check);
+               if ($check->update)
                {
-                       $admin->page_code('<div style="background-color: white; border-color: red; border-width: 2px; border-style: solid; color: red; padding: 4px"><div style="font-size: 18px; font-weight: bold">' . T('Update Avaliable') . ':</div>' . sprintf(T('Your installation of Bugdar is out-of-date. You are running version <strong>%1$s</strong> and the latest version is <strong>%2$s</strong>. You can download the update at <a href="http://www.bluestatic.org">Blue Static\'s website</a>. You are strongly encouraged to apply all updates to fix bugs and any security issues (if present).'), bugdar::$options['trackerversion'], $check['version-check']['update']['value']) . '</div>');
+                       $template->vars['upToDate']             = false;
+                       $template->vars['updateTitle']  = T('Update Avaliable');
+                       $template->vars['updateString'] = sprintf(T('Your installation of Bugdar is out-of-date. You are running version <strong>%1$s</strong> and the latest version is <strong>%2$s</strong>. You can download the update at <a href="http://www.bluestatic.org">Blue Static\'s website</a>. You are strongly encouraged to apply all updates to fix bugs and any security issues (if present).'), bugdar::$options['trackerversion'], $check->update);
                }
-               else if (isset($check['version-check']['up-to-date']))
+               else
                {
-                       $admin->page_code('<div style="background-color: white; border-color: green; border-width: 2px; border-style: solid; color: green; padding: 4px"><div style="font-size: 18px; font-weight: bold">' . T('Up-to-Date') . ':</div>' . sprintf(T('Your installation of Bugdar is up-to-date. You are running version <strong>%1$s</strong>.'), bugdar::$options['trackerversion']) . '</div>');
+                       $template->vars['upToDate']             = true;
+                       $template->vars['updateTitle']  = T('Up-to-Date');
+                       $template->vars['updateString'] = sprintf(T('Your installation of Bugdar is up-to-date. You are running version <strong>%1$s</strong>.'), bugdar::$options['trackerversion']);
                }
        }
 }
 
 // ###################################################################
+// some option information
 
-$admin->table_start();
-$admin->table_head(T('Welcome to the Bugdar Admin Panel'));
-
-// -------------------------------------------------------------------
-$admin->row_span(T('Version Information'), 'thead');
-$admin->row_text(T('Bugdar Version'), bugdar::$options['trackerversion']);
-$admin->row_text(T('PHP Version'), phpversion());
-
-$mysql = $db->queryFirst("SELECT VERSION() AS version");
-$admin->row_text(T('MySQL Version'), $mysql['version']);
-
-$admin->row_text(T('Web Server'), ($_SERVER['SERVER_SOFTWARE'] ? $_SERVER['SERVER_SOFTWARE'] : $SERVER['SERVER_SOFTWARE']));
-
-// -------------------------------------------------------------------
-$admin->row_span(T('Server Options'), 'thead');
-
-$mysql = $db->queryFirst("SHOW VARIABLES LIKE 'max_allowed_packet'");
-$admin->row_text(T('MySQL: Maximum Packet Size'), $mysql['Value']);
-
-$admin->row_text(T('MySQL: Maximum Upload Size'), BSFunctions::fetch_max_php_file_size());
-
-$mysql = $db->queryFirst("SHOW VARIABLES LIKE 'ft_min_word_len'");
-$admin->row_text(T('MySQL: Full-Text Search Minimum Word Length'), $mysql['Value']);
-
-$admin->row_text(T('PHP: Safe Mode'), ((ini_get('safe_mode') == 1 OR strtolower(ini_get('safe_mode')) == 'on') ? T('Yes') : T('No')));
-$admin->row_text(T('PHP: Register Globals'), ((ini_get('register_globals') == 1 OR strtolower(ini_get('register_globals')) == 'on') ? T('Yes') : T('No')));
-$admin->row_text(T('PHP: Magic Quotes GPC'), ((ini_get('magic_quotes_gpc') == 1 OR strtolower(ini_get('magic_quotes_gpc')) == 'on') ? T('Yes') : T('No')));
-$admin->row_text(T('PHP: Magic Quotes Sybase'), ((ini_get('magic_quotes_sybase') == 1 OR strtolower(ini_get('magic_quotes_sybase')) == 'on') ? T('Yes') : T('No')));
-$admin->row_text(T('PHP: Gettext Installed'), (function_exists('ngettext') ? T('Yes') : T('No')));
+$template->vars['mysqlVersion']        = $db->queryFirst("SELECT VERSION() AS version", 'fetchObject')->version;
+$template->vars['webServer']   = ($_SERVER['SERVER_SOFTWARE']) ? $_SERVER['SERVER_SOFTWARE'] : $SERVER['SERVER_SOFTWARE'];
 
-// -------------------------------------------------------------------
+$template->vars['mysqlPacketSize']     = $db->queryFirst("SHOW VARIABLES LIKE 'max_allowed_packet'", 'fetchObject')->Value;
+$template->vars['mysqlWordLength']     = $db->queryFirst("SHOW VARIABLES LIKE 'ft_min_word_len'", 'fetchObject')->Value;
 
-$admin->table_end();
+$template->vars['phpSafeMode']                 = (ini_get('safe_mode') == 1 || strtolower(ini_get('safe_mode')) == 'on');
+$template->vars['phpRegGlobals']               = (ini_get('register_globals') == 1 || strtolower(ini_get('register_globals')) == 'on');
+$template->vars['phpMagicQuotesGPC']   = (ini_get('magic_quotes_gpc') == 1 || strtolower(ini_get('magic_quotes_gpc')) == 'on');
+$template->vars['phpMagicQuotesSybase']        = (ini_get('magic_quotes_sybase') == 1 || strtolower(ini_get('magic_quotes_sybase')) == 'on');
 
-$admin->page_end();
+$template->evaluate()->flush();
 
 ?>
\ No newline at end of file
diff --git a/admin/templates/main.html b/admin/templates/main.html
new file mode 100644 (file)
index 0000000..ce0416e
--- /dev/null
@@ -0,0 +1,88 @@
+<%- $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('Home') %></title>
+</head>
+
+<body>
+
+<%- $templates['nav'] %>
+
+<div id="title"><%- T('Administration') %></div>
+
+<div id="body">
+
+<% if ($versionCheck): %>
+<div class="<%- ($upToDate) ? 'message' : 'error' %>-box">
+       <h1><%- $updateTitle %></h1>
+       <%- $updateString %>
+</div>
+<% endif; %>
+
+<table>
+<thead>
+       <tr><td colspan="2"><%- T('Welcome to the Bugdar Admin Panel') %></td></tr>
+</thead>
+
+<tr class="headings"><td colspan="2"><%- T('Version Information') %></td>
+<tr class="alt1">
+       <td><%- T('Bugdar Version') %></td>
+       <td><%- bugdar::$options['trackerversion'] %></td>
+</tr>
+<tr class="alt2">
+       <td><%- T('PHP Version') %></td>
+       <td><%- phpversion() %></td>
+</tr>
+<tr class="alt1">
+       <td><%- T('MySQL Version') %></td>
+       <td><%- $mysqlVersion %></td>
+</tr>
+<tr class="alt2">
+       <td><%- T('Web Server') %></td>
+       <td><%- $webServer %></td>
+</tr>
+
+<tr class="headings"><td colspan="2"><%- T('Server Options') %></td></tr>
+<tr class="alt1">
+       <td><%- T('MySQL: Maximum Packet Size') %></td>
+       <td><%- $mysqlPacketSize %></td>
+</tr>
+<tr class="alt2">
+       <td><%- T('MySQL: Maximum Upload Size') %></td>
+       <td><%- BSFunctions::fetch_max_php_file_size() %></td>
+</tr>
+<tr class="alt1">
+       <td><%- T('MySQL: Full-Text Search Minimum Word Length') %></td>
+       <td><%- $mysqlWordLength %></td>
+</tr>
+<tr class="alt2">
+       <td><%- T('PHP: Safe Mode') %></td>
+       <td><%- BSFunctions::bool_to_string($phpSafeMode) %></td>
+</tr>
+<tr class="alt1">
+       <td><%- T('PHP: Register Globals') %></td>
+       <td><%- BSFunctions::bool_to_string($phpRegGlobals) %></td>
+</tr>
+<tr class="alt2">
+       <td><%- T('PHP: Magic Quotes GPC') %></td>
+       <td><%- BSFunctions::bool_to_string($phpMagicQuotesGPC) %></td>
+</tr>
+<tr class="alt1">
+       <td><%- T('PHP: Magic Quotes Sybase') %></td>
+       <td><%- BSFunctions::bool_to_string($phpMagicQuotesSybase) %></td>
+</tr>
+<tr class="alt2">
+       <td><%- T('PHP: Gettext Installed') %></td>
+       <td><%- BSFunctions::bool_to_string(function_exists('ngettext')) %></td>
+</tr>
+
+</table>
+
+</div>
+
+<script type="text/javascript"> nav_init() </script>
+
+</body>
+
+</html>
\ No newline at end of file