@@ -4,44 +4,44 @@ discard block |
||
| 4 | 4 | class Controller |
| 5 | 5 | { |
| 6 | 6 | |
| 7 | - protected $viewPath = ''; |
|
| 7 | + protected $viewPath=''; |
|
| 8 | 8 | private $twig; |
| 9 | - private $tVar = array(); |
|
| 9 | + private $tVar=array(); |
|
| 10 | 10 | protected $title=''; |
| 11 | 11 | public function __construct() |
| 12 | 12 | { |
| 13 | - $loader = new \Twig_Loader_Filesystem(BASE_PATH . $this->viewPath); |
|
| 14 | - $twig = new \Twig_Environment($loader, array( |
|
| 13 | + $loader=new \Twig_Loader_Filesystem(BASE_PATH.$this->viewPath); |
|
| 14 | + $twig=new \Twig_Environment($loader, array( |
|
| 15 | 15 | 'debug' => DEBUG, |
| 16 | - 'cache' => BASE_PATH . '/cache', |
|
| 16 | + 'cache' => BASE_PATH.'/cache', |
|
| 17 | 17 | )); |
| 18 | - $this->twig = $twig; |
|
| 18 | + $this->twig=$twig; |
|
| 19 | 19 | $this->initTwigFilter(); |
| 20 | 20 | $this->initTwigFunction(); |
| 21 | - $this->db = \MysqliDb::getInstance(); |
|
| 21 | + $this->db=\MysqliDb::getInstance(); |
|
| 22 | 22 | } |
| 23 | - private function initTwigFilter(){ |
|
| 24 | - $filter = new \Twig_SimpleFilter('long2ip', 'long2ip'); |
|
| 23 | + private function initTwigFilter() { |
|
| 24 | + $filter=new \Twig_SimpleFilter('long2ip', 'long2ip'); |
|
| 25 | 25 | $this->twig->addFilter($filter); |
| 26 | 26 | } |
| 27 | - private function initTwigFunction(){ |
|
| 28 | - $function = new \Twig_SimpleFunction('I','I'); |
|
| 27 | + private function initTwigFunction() { |
|
| 28 | + $function=new \Twig_SimpleFunction('I', 'I'); |
|
| 29 | 29 | $this->twig->addFunction($function); |
| 30 | 30 | } |
| 31 | - protected function assign($name, $value = '') |
|
| 31 | + protected function assign($name, $value='') |
|
| 32 | 32 | { |
| 33 | 33 | if (is_array($name)) { |
| 34 | - $this->tVar = array_merge($this->tVar, $name); |
|
| 34 | + $this->tVar=array_merge($this->tVar, $name); |
|
| 35 | 35 | } else { |
| 36 | - $this->tVar[$name] = $value; |
|
| 36 | + $this->tVar[$name]=$value; |
|
| 37 | 37 | } |
| 38 | 38 | } |
| 39 | 39 | |
| 40 | - protected function show($tmpPath = '') |
|
| 40 | + protected function show($tmpPath='') |
|
| 41 | 41 | { |
| 42 | 42 | if ($tmpPath == '') { |
| 43 | 43 | if (defined("CONTROLLER_NAME") && defined("ACTION_NAME")) { |
| 44 | - $tmpPath = parse_name(CONTROLLER_NAME) . '/' . parse_name(ACTION_NAME); |
|
| 44 | + $tmpPath=parse_name(CONTROLLER_NAME).'/'.parse_name(ACTION_NAME); |
|
| 45 | 45 | } else { |
| 46 | 46 | show_json($this->tVar); |
| 47 | 47 | } |
@@ -49,8 +49,8 @@ discard block |
||
| 49 | 49 | header('Content-Type:text/html; charset=utf-8'); |
| 50 | 50 | header('Cache-control: private'); // 页面缓存控制 |
| 51 | 51 | header('X-Powered-By:ViviAnAuthSystem'); |
| 52 | - $this->assign('title',$this->title); |
|
| 53 | - echo $this->twig->render($tmpPath . '.' . TempExt, $this->tVar); |
|
| 52 | + $this->assign('title', $this->title); |
|
| 53 | + echo $this->twig->render($tmpPath.'.'.TempExt, $this->tVar); |
|
| 54 | 54 | die(); |
| 55 | 55 | } |
| 56 | 56 | } |
| 57 | 57 | \ No newline at end of file |