diff --git a/Changelog b/Changelog index 8ecaa8b34..1fa48ecc8 100755 --- a/Changelog +++ b/Changelog @@ -1,3 +1,5 @@ +2016-07-18 DariusIII + * Chg: Change bootstraping process in nntmux 2016-07-15 DariusIII * Chg: Remove releases ordering in viewmoviefull page of all the themes * Fix: Prevent undefined index notices in api.php diff --git a/app/config/bootstrap.php b/app/config/bootstrap.php index bd844d959..bc205dfcf 100644 --- a/app/config/bootstrap.php +++ b/app/config/bootstrap.php @@ -6,9 +6,7 @@ * @license http://opensource.org/licenses/bsd-license.php The BSD License */ -if (!defined('DS')) { - define('DS', DIRECTORY_SEPARATOR); -} +require_once dirname(dirname(__DIR__)) . DIRECTORY_SEPARATOR . 'nntmux' . DIRECTORY_SEPARATOR . 'constants.php'; /** * This is the primary bootstrap file of your application, and is loaded immediately after the front diff --git a/app/config/bootstrap/libraries.php b/app/config/bootstrap/libraries.php index 5af97705b..9fece3a25 100644 --- a/app/config/bootstrap/libraries.php +++ b/app/config/bootstrap/libraries.php @@ -134,8 +134,6 @@ Libraries::add('nntmux', 'path' => NN_ROOT . 'nntmux', ]); -require_once NN_ROOT . 'constants.php'; - require_once LITHIUM_APP_PATH . DS . 'libraries' . DS . 'autoload.php'; /** * Add some plugins: diff --git a/app/extensions/command/Update.php b/app/extensions/command/Update.php index 878da4fe4..8bd05ae08 100644 --- a/app/extensions/command/Update.php +++ b/app/extensions/command/Update.php @@ -18,19 +18,18 @@ */ namespace app\extensions\command; -use \Exception; -use \Smarty; use \app\extensions\util\Git; use \app\extensions\util\Versions; use \lithium\console\command\Help; use \nntmux\db\DbUpdate; +use \Smarty; /** * Update various aspects of your indexer. * * Actions: - * * all|nntmux Fetches current git repo, composer dependencies, and update latest Db patches. + * * all|nzedb Fetches current git repo, composer dependencies, and update latest Db patches. * * db Update the Db with any patches not yet applied. * * git Performs git pull. * * predb Fetch and import TSV files into the predb table. @@ -39,11 +38,18 @@ use \nntmux\db\DbUpdate; */ class Update extends \app\extensions\console\Command { + const UPDATES_FILE = NN_CONFIGS . 'updates.json'; + /** * @var \app\extensions\util\Git object. */ protected $git; + /** + * @var array Decoded JSON updates file. + */ + protected $updates = null; + private $gitBranch; private $gitTag; @@ -66,7 +72,7 @@ class Update extends \app\extensions\console\Command public function all() { - $this->nntmux(); + $this->nzedb(); } public function db() @@ -91,7 +97,6 @@ class Update extends \app\extensions\console\Command } else { $this->out("Up to date.", 'info'); } - } public function git() @@ -100,10 +105,10 @@ class Update extends \app\extensions\console\Command // also prevent web access. $this->initialiseGit(); if (!in_array($this->git->getBranch(), $this->git->getBranchesMain())) { - $this->out("Not on the stable or dev branch! Refusing to update repository ;-)", 'error'); + $this->out("Not on the stable or dev branch! Refusing to update repository", 'error'); return; } - //return + $this->out($this->git->pull()); } @@ -129,6 +134,8 @@ class Update extends \app\extensions\console\Command }; } + $this->scripts(); + $smarty = new Smarty(); $smarty->setCompileDir(NN_SMARTY_TEMPLATES); $cleared = $smarty->clearCompiledTemplate(); @@ -229,5 +236,19 @@ class Update extends \app\extensions\console\Command if ($this->_config['git'] instanceof Git) { $this->git =& $this->_config['git']; } + + if (file_exists(UPDATES_FILE)) { + $this->updates = json_decode(file_get_contents(UPDATES_FILE), true); + } + } + + /** + * Fetches and executes scripts for customised updating tasks. + */ + protected function scripts() + { + if (![$this->updates]) { + $this->updates = ['script' => '0000-00-00 00:00:00']; + } } } diff --git a/autoloader.php b/build/postInstall.php old mode 100755 new mode 100644 similarity index 56% rename from autoloader.php rename to build/postInstall.php index 79f2a7fc2..44ad2aaf5 --- a/autoloader.php +++ b/build/postInstall.php @@ -4,37 +4,25 @@ * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * * You should have received a copy of the GNU General Public License * along with this program (see LICENSE.txt in the base directory. If * not, see: * * @link . * @author niel - * @copyright 2014 nZEDb + * @copyright 2016 nZEDb */ -/* -spl_autoload_register( - function ($class) { - // Only continue if the class is in our namespace. - if (strpos($class, 'nzedb\\') === 0) { - // Replace namespace separators with directory separators in the class name, append - // with .php - $file = nZEDb_ROOT . str_replace('\\', DIRECTORY_SEPARATOR, $class) . '.php'; - // if the file exists, require it - if (file_exists($file)) { - require_once $file; - } - } - } -); -*/ -require_once 'app/config/bootstrap/libraries.php'; -require_once 'app/libraries/autoload.php' +require_once '..' . DIRECTORY_SEPARATOR . 'nntmux' . DIRECTORY_SEPARATOR . 'constants.php'; + +$updates = NN_CONFIGS . 'updates.json'; +if (!file_exists($updates)) { + $json = [ 'script' => time()]; + file_put_contents(json_encode($json, JSON_PRETTY_PRINT)); +} + ?> diff --git a/nntmux/bootstrap.php b/nntmux/bootstrap.php index b8d4310fc..dec351980 100644 --- a/nntmux/bootstrap.php +++ b/nntmux/bootstrap.php @@ -18,7 +18,6 @@ * @author niel * @copyright 2016 nZEDb */ -require_once realpath(dirname(__DIR__) . DIRECTORY_SEPARATOR . 'constants.php'); require_once NN_ROOT . 'app/libraries/autoload.php'; //require_once 'config' . DS . 'Configure.php'; diff --git a/constants.php b/nntmux/constants.php similarity index 93% rename from constants.php rename to nntmux/constants.php index e913072ca..45310861e 100755 --- a/constants.php +++ b/nntmux/constants.php @@ -4,14 +4,10 @@ define('NN_MINIMUM_PHP_VERSION', '5.6.0'); define('NN_MINIMUM_MYSQL_VERSION', '5.5'); -if (!defined('DS')) { - define('DS', DIRECTORY_SEPARATOR); -} +define('DS', DIRECTORY_SEPARATOR); // These are file path constants -if (!defined('NN_ROOT')) { - define('NN_ROOT', realpath(__DIR__) . DS); -} +define('NN_ROOT', realpath(dirname(__DIR__)) . DS); // Used to refer to the main lib class files. define('NN_LIB', NN_ROOT . 'nntmux' . DS); diff --git a/www/smarty.php b/www/smarty.php index b48acadab..3511f049d 100644 --- a/www/smarty.php +++ b/www/smarty.php @@ -18,9 +18,8 @@ * @author niel * @copyright 2015 NN */ -require_once realpath(dirname(__DIR__) . DIRECTORY_SEPARATOR . 'constants.php'); -require_once realpath(dirname(__DIR__) . DIRECTORY_SEPARATOR . 'autoloader.php'); -//require_once 'autoloader.php'; +require_once realpath(dirname(__DIR__) . DIRECTORY_SEPARATOR . 'nntmux' . DIRECTORY_SEPARATOR . 'constants.php'); +require_once NN_ROOT . 'app/libraries/autoload.php'; use nntmux\config\Configure;