AbstractController.class.php
1.88 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
<?php
/**
* Created by PhpStorm.
*
* User: zhoutao
* Date: 16/7/14
* Time: 下午2:56
*/
namespace Frontend\Controller\Index;
abstract class AbstractController extends \Common\Controller\Frontend\AbstractController
{
/**
* Apidoc 不需要任何数据库支持, 也不需要登录, 所以不执行基类操作
* @param string $action
* @return bool
*/
public function before_action($action = '')
{
return true;
}
/**
* output
* @desc 输出模板
*
* @param string $tpl 引入的模板
*
* @return bool
*/
protected function _output($tpl)
{
// 当前页标识
$currentMenu = array();
$currentMenu[CONTROLLER_NAME] = 'active ';
$this->assign('identifier', APP_IDENTIFIER);
$this->assign('enumber', QY_DOMAIN);
$this->assign('host', $_SERVER['REQUEST_SCHEME'] . '://' . $_SERVER['HTTP_HOST']);
$this->assign('currentMenu', $currentMenu);
$this->assign('classUrl', oaUrl('/Frontend/Index/ListClass'));
$this->assign('methodUrl', oaUrl('/Frontend/Index/ListMethod'));
$this->assign('indexUrl', oaUrl('/Frontend/Index/Index'));
$this->assign('docUrl', oaUrl('/Frontend/Index/Doc'));
// 切换目录列表
$this->assign('dirs', $this->_listDir());
parent::_output($tpl);
return true;
}
/**
* 获取目录列表
* @return array
*/
protected function _listDir()
{
$file = I('request.file');
if (empty($file)) {
$file = I('request.dir');
}
$file = ltrim($file, '/');
$dirs = array();
$count = substr_count($file, '/');
for (; $count > 0; $count--) {
$pos = strrpos($file, '/');
$file = substr($file, 0, $pos);
$dirs[] = $file;
}
return $dirs;
}
}