Convert the version check of the admin index to the new stack.
authorRobert Sesek <rsesek@bluestatic.org>
Tue, 4 Jun 2013 05:45:09 +0000 (01:45 -0400)
committerRobert Sesek <rsesek@bluestatic.org>
Tue, 4 Jun 2013 05:45:49 +0000 (01:45 -0400)
admin/home.php
admin/templates/admin_header.tpl [new file with mode: 0644]
admin/templates/admin_index.tpl [new file with mode: 0644]

index b8db8f10ee69fc41d6138a65badbeb7a47ab2b37..f0075b7471a1eb8b962f433e76ec6681c61fb02d 100644 (file)
@@ -30,39 +30,37 @@ class HomeAction extends http\Action
 {
        public function Invoke(http\Request $request, http\Response $response)
        {
+               $response->data['title'] = T('Home');
+
+               $response->data['new_version_number'] = $this->_DoVersionCheck();
+               $response->data['current_version'] = Bugdar::$options['trackerversion'];
+
                $response->context['template'] = 'admin_index';
        }
-}
-
-/*
-require_once('./global.php');
 
-NavLinks::optionsPages();
-$navigator->set_focus('tab', 'options', null);
-$navigator->set_focus('link', 'options-pages-home', 'options-pages');
+       // Contacts Blue Static to see if Bugdar is up-to-date. Returns NULL if the
+       // current version is the latest, or a string version number of the latest
+       // version.
+       private function _DoVersionCheck()
+       {
+               global $bugsys;
 
-$admin->page_start(T('Home'));
+               if (defined('NO_VERSION_CHECK') && constant('NO_VERSION_CHECK'))
+                       return;
 
-// ###################################################################
+               $check = @file_get_contents('https://www.bluestatic.org/versioncheck.php?prod=bugdar&ver=' . str_replace(' ', '-', Bugdar::$options['trackerversion']));
+               if (strpos($check, '<version-check>') !== false) {
+                       if (!isset($check['version-check']['update']))
+                               return NULL;
 
-if (!(defined('NO_VERSION_CHECK') AND constant('NO_VERSION_CHECK') == true))
-{
-       $check = @file_get_contents('http://www.bluestatic.org/versioncheck.php?prod=bugdar&ver=' . str_replace(' ', '-', $bugsys->options['trackerversion']));
-       if (strpos($check, '<version-check>') !== false)
-       {
-               $check = $bugsys->xml->parse($check);
-               if (isset($check['version-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).'), $bugsys->options['trackerversion'], $check['version-check']['update']['value']) . '</div>');
-               }
-               else if (isset($check['version-check']['up-to-date']))
-               {
-                       $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>.'), $bugsys->options['trackerversion']) . '</div>');
+                       // TODO(rsesek): Switch to SimpleXML.
+                       $check = $bugsys->xml->parse($check);
+                       return $check['version-check']['update']['value'];
                }
        }
 }
 
-// ###################################################################
+/*
 
 $admin->table_start();
 $admin->table_head(T('Welcome to the Bugdar Admin Panel'));
diff --git a/admin/templates/admin_header.tpl b/admin/templates/admin_header.tpl
new file mode 100644 (file)
index 0000000..e26b7d5
--- /dev/null
@@ -0,0 +1,8 @@
+<!DOCTYPE html>
+<html lang="TODO(rsesek)">
+       <head>
+               <title>Bugdar2 Admin Panel - {%= $title %}</title>
+               <link rel="stylesheet" href="templates/css/reset.css">
+               <link rel="stylesheet" href="templates/css/admin.css">
+       </head>
+<body>
\ No newline at end of file
diff --git a/admin/templates/admin_index.tpl b/admin/templates/admin_index.tpl
new file mode 100644 (file)
index 0000000..7da3efa
--- /dev/null
@@ -0,0 +1,17 @@
+{%#import 'admin_header'%}
+
+Hello World via Templates
+
+{% if ($new_version_number): %}
+<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="https://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).'), $current_version, $new_version_number) | raw %}
+</div>
+{% else: %}
+<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>.'), $current_version) | raw %}
+</div>
+{% endif %}
+
+{%= Bugdar::$db->ConstructHTMLDebugBlock() | raw %}
\ No newline at end of file