From 9e124662ebe488954ecec63bcc117c27d1c8ad84 Mon Sep 17 00:00:00 2001 From: Robert Sesek Date: Tue, 4 Jun 2013 01:45:09 -0400 Subject: [PATCH] Convert the version check of the admin index to the new stack. --- admin/home.php | 44 +++++++++++++++----------------- admin/templates/admin_header.tpl | 8 ++++++ admin/templates/admin_index.tpl | 17 ++++++++++++ 3 files changed, 46 insertions(+), 23 deletions(-) create mode 100644 admin/templates/admin_header.tpl create mode 100644 admin/templates/admin_index.tpl diff --git a/admin/home.php b/admin/home.php index b8db8f1..f0075b7 100644 --- a/admin/home.php +++ b/admin/home.php @@ -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, '') !== 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, '') !== false) - { - $check = $bugsys->xml->parse($check); - if (isset($check['version-check']['update'])) - { - $admin->page_code('
' . T('Update Avaliable') . ':
' . sprintf(T('Your installation of Bugdar is out-of-date. You are running version %1$s and the latest version is %2$s. You can download the update at Blue Static\'s website. 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']) . '
'); - } - else if (isset($check['version-check']['up-to-date'])) - { - $admin->page_code('
' . T('Up-to-Date') . ':
' . sprintf(T('Your installation of Bugdar is up-to-date. You are running version %1$s.'), $bugsys->options['trackerversion']) . '
'); + // 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 index 0000000..e26b7d5 --- /dev/null +++ b/admin/templates/admin_header.tpl @@ -0,0 +1,8 @@ + + + + Bugdar2 Admin Panel - {%= $title %} + + + + \ No newline at end of file diff --git a/admin/templates/admin_index.tpl b/admin/templates/admin_index.tpl new file mode 100644 index 0000000..7da3efa --- /dev/null +++ b/admin/templates/admin_index.tpl @@ -0,0 +1,17 @@ +{%#import 'admin_header'%} + +Hello World via Templates + +{% if ($new_version_number): %} +
+
{%=T('Update Avaliable')%}:
+ {%=sprintf(T('Your installation of Bugdar is out-of-date. You are running version %1$s and the latest version is %2$s. You can download the update at Blue Static\'s website. You are strongly encouraged to apply all updates to fix bugs and any security issues (if present).'), $current_version, $new_version_number) | raw %} +
+{% else: %} +
+
{%=T('Up-to-Date')%}:
+ {%=sprintf(T('Your installation of Bugdar is up-to-date. You are running version %1$s.'), $current_version) | raw %} +
+{% endif %} + +{%= Bugdar::$db->ConstructHTMLDebugBlock() | raw %} \ No newline at end of file -- 2.22.5