diff --git a/application/common/behavior/ModuleTest.php b/application/common/behavior/ModuleTest.php index d35ddba..aadff58 100644 --- a/application/common/behavior/ModuleTest.php +++ b/application/common/behavior/ModuleTest.php @@ -15,7 +15,7 @@ class ModuleTest { public function run() { - $arr = Config::get('template'); + /* $arr = Config::get('template'); $arr = array_merge($arr, [ // 模板引擎类型 支持 php think 支持扩展 'type' => 'Think', @@ -35,6 +35,6 @@ class ModuleTest 'taglib_end' => '}', //'taglib_pre_load' => 'app\common\Tree', ]); - Config::set(['template' => $arr]); + Config::set(['template' => $arr]);*/ } } \ No newline at end of file diff --git a/application/index/config.php b/application/index/config.php index 3e67685..3d5ebf0 100644 --- a/application/index/config.php +++ b/application/index/config.php @@ -10,7 +10,7 @@ return [ // 模板引擎类型 支持 php think 支持扩展 'type' => 'Think', // 模板路径 - 'view_path' => __DIR__ . '/../../themes/blue/', + 'view_path' => '../themes/blue/', // 模板后缀 'view_suffix' => 'html', // 模板文件名分隔符 diff --git a/application/index/controller/Index.php b/application/index/controller/Index.php index 5cab541..f4722e8 100644 --- a/application/index/controller/Index.php +++ b/application/index/controller/Index.php @@ -8,10 +8,26 @@ class Index extends Base { public function index() { + /** + * getcwd() + * + */ + + var_dump(getcwd()); + var_dump($_SERVER['PHP_SELF']); + var_dump($_SERVER['DOCUMENT_ROOT']); + var_dump(__DIR__); + + $this->assign('__LIST__', [1, 2, 3]); $this->assign('demo_time', $this->request->time()); $this->assign('demo_name', 'king'); $this->assign('key', 'demo'); return $this->fetch(); } + + public function tree() + { + + } } diff --git a/tree.php b/tree.php index 630797b..78803aa 100644 --- a/tree.php +++ b/tree.php @@ -4,4 +4,78 @@ * User: Wind * Date: 2017/10/25 * Time: 13:46 - */ \ No newline at end of file + */ + + +$test_data = [ + ['id' => 0, 'name' => 'A'], + ['id' => 1, 'name' => 'a', 'pid' => 0], + ['id' => 2, 'name' => 'b', 'pid' => 1], + ['id' => 3, 'name' => 'c', 'pid' => 1], + ['id' => 4, 'name' => 'd', 'pid' => 0], + ['id' => 5, 'name' => 'e', 'pid' => 4], +]; +function m_tree($arr, $pid = 0) +{ + $tree = []; + foreach ($arr as $tmp) { + if (!isset($tmp['pid'])) { + $tree[] = $tmp; + } elseif($tmp['pid'] == $pid){ + $tree[$pid][$tmp['id']] = $tmp; + } /*else { + if ($tmp['pid'] > $pid) + $tree[$pid][] = m_tree($arr, $tmp['pid']); + }*/ + } + return $tree; +} + +echo '
'; +print_r(m_tree($test_data)); +echo ''; +die; + +function tree($directory) +{ + $mydir = dir($directory); + echo "