From 4b3f67f0fa3f93f0e5ba79fe3b96309798741f6a Mon Sep 17 00:00:00 2001 From: Tanguy Pruvot Date: Fri, 6 May 2016 11:32:39 +0200 Subject: [PATCH] controller: cleanup --- web/framework-1.1.17/web/CWebApplication.php | 2 +- web/yaamp/config.php | 1 + web/yaamp/modules/common/CommonController.php | 33 ++++++++++--------- .../modules/explorer/ExplorerController.php | 3 -- web/yaamp/modules/site/SiteController.php | 4 ++- 5 files changed, 22 insertions(+), 21 deletions(-) diff --git a/web/framework-1.1.17/web/CWebApplication.php b/web/framework-1.1.17/web/CWebApplication.php index 4b12540..e343c0f 100644 --- a/web/framework-1.1.17/web/CWebApplication.php +++ b/web/framework-1.1.17/web/CWebApplication.php @@ -305,7 +305,7 @@ class CWebApplication extends CApplication $this->_controller=$oldController; } else - throw new CHttpException(404,Yii::t('yii','Unable to resolve the request "{route}".', + throw new CHttpException(404,Yii::t('yii','CWebApp: Unable to resolve the request "{route}".', array('{route}'=>$route===''?$this->defaultController:$route))); } diff --git a/web/yaamp/config.php b/web/yaamp/config.php index 8d0f603..ce423fc 100644 --- a/web/yaamp/config.php +++ b/web/yaamp/config.php @@ -7,6 +7,7 @@ return array( 'layout'=>'main', 'basePath'=>YAAMP_HTDOCS."/yaamp", + 'extensionPath'=>YAAMP_HTDOCS.'/extensions', 'controllerPath'=>'yaamp/modules', 'viewPath'=>'yaamp/modules', 'layoutPath'=>'yaamp/ui', diff --git a/web/yaamp/modules/common/CommonController.php b/web/yaamp/modules/common/CommonController.php index 8218cb0..dfc79a8 100644 --- a/web/yaamp/modules/common/CommonController.php +++ b/web/yaamp/modules/common/CommonController.php @@ -2,20 +2,22 @@ class CommonController extends CController { - public $admin = false; public $memcache; + public $t1; - private $t1; + // read-only via getAdmin() + private $admin = false; + protected function getAdmin() { return $this->admin; } - public function goback($count=-1) + protected function elapsedTime() { - Javascript("window.history.go($count)"); - die; + $t2 = microtime(true); + return ($t2 - $this->t1); } - public function beforeAction($action) + protected function beforeAction($action) { - // session_start(); + // debuglog("before action ".$action->getId()); $this->memcache = new YaampMemcache; $this->t1 = microtime(true); @@ -26,24 +28,17 @@ class CommonController extends CController $algo = user()->getState('yaamp-algo'); if(!$algo) user()->setState('yaamp-algo', 'x11'); - //$um = app()->getComponent('urlManager'); - //var_dump($um); die; - return true; } - public function afterAction($action) + protected function afterAction($action) { // debuglog("after action ".$action->getId()); - $t2 = microtime(true); - $d1 = $t2 - $this->t1; + $d1 = $this->elapsedTime(); $url = "$this->id/{$this->action->id}"; $this->memcache->add_monitoring_function($url, $d1); - - //$um = app()->getComponent('urlManager'); - //var_dump($um); die; } public function actionMaintenance() @@ -51,5 +46,11 @@ class CommonController extends CController $this->render('maintenance'); } + public function goback($count=-1) + { + Javascript("window.history.go($count);"); + die; + } + } diff --git a/web/yaamp/modules/explorer/ExplorerController.php b/web/yaamp/modules/explorer/ExplorerController.php index aa8b0e4..b224ad4 100644 --- a/web/yaamp/modules/explorer/ExplorerController.php +++ b/web/yaamp/modules/explorer/ExplorerController.php @@ -5,14 +5,11 @@ require_once("util.php"); class ExplorerController extends CommonController { public $defaultAction='index'; - public $admin = false; ///////////////////////////////////////////////// public function run($actionID) { - $this->admin = user()->getState('yaamp_admin'); - // Forward the url /explorer/BTC to the BTC block explorer if (!empty($actionID)) { if (is_numeric($actionID) && isset($_REQUEST['id'])) { diff --git a/web/yaamp/modules/site/SiteController.php b/web/yaamp/modules/site/SiteController.php index f2cf18a..93a78b6 100644 --- a/web/yaamp/modules/site/SiteController.php +++ b/web/yaamp/modules/site/SiteController.php @@ -907,8 +907,10 @@ class SiteController extends CommonController if($balance) runExchange($balance->name); + $tm = round($this->elapsedTime(), 3); + if ($balance) - debuglog("runexchange done ($balance->name)"); + debuglog("runexchange done ({$balance->name}) {$tm} sec"); else debuglog("runexchange failed (no id!)");