rpicms

A CMS for the Raspberry Pi
git clone git://archive.git.mtrnord.blog/RpicmsTeam/rpicms.git
Log | Files | Refs | README | LICENSE

commit 16e5668440c6543fa59331c2522775ebe801fbc6
parent a0525ad283f86e96cb4287d08b99a615d5bbfe43
Author: MTRNord <mtrnord1@gmail.com>
Date:   Sat, 28 Feb 2015 20:34:16 +0100

update script maintainer had an update :D braches (^^)/

Diffstat:
Mcore/update/update/update.php | 88++++++++++++++++++++++++++++++++++++++++++++++++++-----------------------------
Mthemes/jumbotron/update.php | 19++++++++++++++++---
2 files changed, 72 insertions(+), 35 deletions(-)

diff --git a/core/update/update/update.php b/core/update/update/update.php @@ -1,14 +1,14 @@ <?php namespace VisualAppeal; -use vierbergenlars\SemVer\version; -use vierbergenlars\SemVer\expression; -use vierbergenlars\SemVer\SemVerException; +use \vierbergenlars\SemVer\version; +use \vierbergenlars\SemVer\expression; +use \vierbergenlars\SemVer\SemVerException; -use Desarrolla2\Cache\Cache; -use Desarrolla2\Cache\Adapter\NotCache; +use \Desarrolla2\Cache\Cache; +use \Desarrolla2\Cache\Adapter\NotCache; -use Monolog\Logger; -use Monolog\Handler\NullHandler; +use \Monolog\Logger; +use \Monolog\Handler\NullHandler; ############################### @@ -25,7 +25,6 @@ if ($root_3[1] == 'core') { $root = $root_1 . '/' . $root_3[1]; } - /** * Auto update class. */ @@ -60,46 +59,46 @@ class AutoUpdate private $_simulationResults = array(); /** - * Url to the update folder on the server. + * Temporary download directory. * * @var string */ - protected $_updateUrl = 'http://media.nordgedanken.de/rpicms/update/server/'; + private $_tempDir = ''; - /* - * branch on the server - * - * @var string + /** + * Install directory. + * + * @var string */ - protected $_branch = 'stable'; + private $_installDir = ''; /** - * Version filename on the server. + * Update branch. * * @var string */ - protected $_updateFile = 'update.json.'; + private $_branch = ''; /** - * Current version. + * Url to the update folder on the server. * - * @var vierbergenlars\SemVer\version + * @var string */ - protected $_currentVersion = null; + protected $_updateUrl = 'http://media.nordgedanken.de/rpicms/update/server/'; /** - * Temporary download directory. + * Version filename on the server. * * @var string */ - private $_tempDir = ''; + protected $_updateFile = 'update.json'; /** - * Install directory. + * Current version. * - * @var string + * @var vierbergenlars\SemVer\version */ - private $_installDir = ''; + protected $_currentVersion = null; /** * Create new folders with this privileges. @@ -203,6 +202,7 @@ class AutoUpdate } $this->_tempDir = $dir; + return $this; } /** @@ -224,6 +224,7 @@ class AutoUpdate } $this->_installDir = $dir; + return $this; } /** @@ -233,7 +234,8 @@ class AutoUpdate */ public function setUpdateFile($updateFile) { - $this->_updateFile = $updateFile . $this->_branch; + $this->_updateFile = $updateFile; + return $this; } /** @@ -244,6 +246,18 @@ class AutoUpdate public function setUpdateUrl($updateUrl) { $this->_updateUrl = $updateUrl; + return $this; + } + + /** + * Set the update branch. + * + * @param string branch + */ + public function setBranch($branch) + { + $this->_branch = $branch; + return $this; } /** @@ -256,6 +270,7 @@ class AutoUpdate { $adapter->setOption('ttl', $ttl); $this->_cache = new Cache($adapter); + return $this; } /** @@ -274,7 +289,7 @@ class AutoUpdate } $this->_currentVersion = $version; - return true; + return $this; } /** @@ -285,6 +300,7 @@ class AutoUpdate public function addLogHandler(\Monolog\Handler\HandlerInterface $handler) { $this->_log->pushHandler($handler); + return $this; } /** @@ -364,7 +380,11 @@ class AutoUpdate // Check if cache is empty if ($versions === false) { - $updateFile = $this->_updateUrl . '/' . $this->_updateFile . $this->_branch; + // Create absolute url to update file + $updateFile = $this->_updateUrl . '/' . $this->_updateFile; + if (!empty($this->_branch)) + $updateFile .= '.' . $this->_branch; + $this->_log->addDebug(sprintf('Get new updates from %s', $updateFile)); // Read update file from update server @@ -375,12 +395,12 @@ class AutoUpdate } // Parse update file - $updateFileExtension = substr(strrchr($this->_updateFile . $this->_branch, '.'), 1); + $updateFileExtension = substr(strrchr($this->_updateFile, '.'), 1); switch ($updateFileExtension) { case 'ini': - $versions = parse_ini_string($update, true); + $versions = @parse_ini_string($update, true); if (!is_array($versions)) { - $this->_log->addInfo('Unable to parse update file!'); + $this->_log->addInfo('Unable to parse ini update file!'); return false; } @@ -390,7 +410,11 @@ class AutoUpdate break; case 'json': - $versions = json_decode($update); + $versions = (array) @json_decode($update); + if (!is_array($versions)) { + $this->_log->addInfo('Unable to parse json update file!'); + return false; + } break; default: diff --git a/themes/jumbotron/update.php b/themes/jumbotron/update.php @@ -34,6 +34,20 @@ global $root, $root_1, $root_2, $root_3; $update = new AutoUpdate($root . '/temp/', $root . '/', 60); $update->setCurrentVersion('1.0.0'); $update->setUpdateUrl('http://media.nordgedanken.de/rpicms/server'); +public function BranchStable() +{ + $this->_update->setUpdateFile('update.json'); + $this->_update->setBranch('stable'); + $response = $this->_update->checkUpdate(); + $this->assertTrue($response); +} +public function BranchDevelop() +{ + $this->_update->setUpdateFile('update.json'); + $this->_update->setBranch('nightly'); + $response = $this->_update->checkUpdate(); + $this->assertTrue($response); +} // Optional: $update->addLogHandler(new Monolog\Handler\StreamHandler($root . '/core/update/update.log')); @@ -76,7 +90,7 @@ if ($update->newVersionAvailable()) { <meta name="viewport" content="width=device-width, initial-scale=1"> <meta name="description" content=""> <meta name="author" content=""> - + <link rel="icon" href="../../core/libs/theme_engine/BootStrap/favicon.ico"> <!-- Bootstrap core CSS --> @@ -101,4 +115,4 @@ if ($update->newVersionAvailable()) { </html> <?php } -?> -\ No newline at end of file +?>