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;
}
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)));
}

View file

@ -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',

View file

@ -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;
}
}

View file

@ -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'])) {

View file

@ -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!)");