controller: cleanup

This commit is contained in:
Tanguy Pruvot 2016-05-06 11:32:39 +02:00
parent 3707c1d564
commit 4b3f67f0fa
5 changed files with 22 additions and 21 deletions

View file

@ -305,7 +305,7 @@ class CWebApplication extends CApplication
$this->_controller=$oldController; $this->_controller=$oldController;
} }
else 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))); array('{route}'=>$route===''?$this->defaultController:$route)));
} }

View file

@ -7,6 +7,7 @@ return array(
'layout'=>'main', 'layout'=>'main',
'basePath'=>YAAMP_HTDOCS."/yaamp", 'basePath'=>YAAMP_HTDOCS."/yaamp",
'extensionPath'=>YAAMP_HTDOCS.'/extensions',
'controllerPath'=>'yaamp/modules', 'controllerPath'=>'yaamp/modules',
'viewPath'=>'yaamp/modules', 'viewPath'=>'yaamp/modules',
'layoutPath'=>'yaamp/ui', 'layoutPath'=>'yaamp/ui',

View file

@ -2,20 +2,22 @@
class CommonController extends CController class CommonController extends CController
{ {
public $admin = false;
public $memcache; 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)"); $t2 = microtime(true);
die; return ($t2 - $this->t1);
} }
public function beforeAction($action) protected function beforeAction($action)
{ {
// session_start(); // debuglog("before action ".$action->getId());
$this->memcache = new YaampMemcache; $this->memcache = new YaampMemcache;
$this->t1 = microtime(true); $this->t1 = microtime(true);
@ -26,24 +28,17 @@ class CommonController extends CController
$algo = user()->getState('yaamp-algo'); $algo = user()->getState('yaamp-algo');
if(!$algo) user()->setState('yaamp-algo', 'x11'); if(!$algo) user()->setState('yaamp-algo', 'x11');
//$um = app()->getComponent('urlManager');
//var_dump($um); die;
return true; return true;
} }
public function afterAction($action) protected function afterAction($action)
{ {
// debuglog("after action ".$action->getId()); // debuglog("after action ".$action->getId());
$t2 = microtime(true); $d1 = $this->elapsedTime();
$d1 = $t2 - $this->t1;
$url = "$this->id/{$this->action->id}"; $url = "$this->id/{$this->action->id}";
$this->memcache->add_monitoring_function($url, $d1); $this->memcache->add_monitoring_function($url, $d1);
//$um = app()->getComponent('urlManager');
//var_dump($um); die;
} }
public function actionMaintenance() public function actionMaintenance()
@ -51,5 +46,11 @@ class CommonController extends CController
$this->render('maintenance'); $this->render('maintenance');
} }
public function goback($count=-1)
{
Javascript("window.history.go($count);");
die;
}
} }

View file

@ -5,14 +5,11 @@ require_once("util.php");
class ExplorerController extends CommonController class ExplorerController extends CommonController
{ {
public $defaultAction='index'; public $defaultAction='index';
public $admin = false;
///////////////////////////////////////////////// /////////////////////////////////////////////////
public function run($actionID) public function run($actionID)
{ {
$this->admin = user()->getState('yaamp_admin');
// Forward the url /explorer/BTC to the BTC block explorer // Forward the url /explorer/BTC to the BTC block explorer
if (!empty($actionID)) { if (!empty($actionID)) {
if (is_numeric($actionID) && isset($_REQUEST['id'])) { if (is_numeric($actionID) && isset($_REQUEST['id'])) {

View file

@ -907,8 +907,10 @@ class SiteController extends CommonController
if($balance) if($balance)
runExchange($balance->name); runExchange($balance->name);
$tm = round($this->elapsedTime(), 3);
if ($balance) if ($balance)
debuglog("runexchange done ($balance->name)"); debuglog("runexchange done ({$balance->name}) {$tm} sec");
else else
debuglog("runexchange failed (no id!)"); debuglog("runexchange failed (no id!)");