view('admin.pages-custom.ace_content');
if ($request->isMethod('post') || false == empty($request->get('act'))) {
if($request->get('act') == 'tree') {
//获取代码树形结构
$appearance_id = $request->get('appearance_id');
$dist_id = $request->get('dist_id');
return $this->showTree($appearance_id, $dist_id);
} elseif ($request->get('act') == 'content') {
//得到文件内容
$id = $request->get('id');
return DistAppearanceTemplate::getContent($id);
} elseif ($request->get('act') == 'content_save') {
//保存文件内容
$template_id = $request->get('template_id');
$content = $request->get('content');
return DistAppearanceTemplate::saveContent($template_id, $content);
}
}
$leftForm = new AceLeft();
return $content
->header('Template Editor')
->body(admin_view('admin.pages-custom.ace',['leftForm'=>$leftForm]));
}
/*
* 显示代码树
*/
private function showTree($appearance_id, $dist_id) {
$appearance_id = empty($appearance_id) ? 0 : $appearance_id;
$dist_id = empty($dist_id) ? 0 : $dist_id;
$tree = DistAppearanceTemplate::getTemplateTree($appearance_id, $dist_id);
$html = '
';
foreach ($tree as $key => $value) {
$fa = 'fa-angle-down';
$file_name = $value['file_name'];
if ($value['file_type'] == 1) {
$fa = 'fa-angle-right';
$file_name = ''. $file_name.'';
} else {
$file_name = ''. $file_name.'';
}
$html .= '';
}
$html .= '
';
return $html;
}
private function treeBuilder($value) {
$html = '';
if (!empty($value['children'])) {
$html = '';
}
return $html;
}
//
// /**
// * page index
// */
// public function index(Content $content)
// {
// return $content
// ->header('列表')
// ->description('全部')
// ->breadcrumb(['text'=>'列表','url'=>''])
// ->body($this->grid());
// }
//
// /**
// * Make a grid builder.
// *
// * @return Grid
// */
// protected function grid()
// {
// return Grid::make(new DistAppearanceTemplate(), function (Grid $grid) {
// $grid->column('id')->sortable();
// $grid->column('dist_id');
// $grid->column('appearance_id');
// $grid->column('file_name');
// $grid->column('file_path');
// $grid->column('content');
// $grid->column('created_at');
// $grid->column('updated_at')->sortable();
//
// $grid->filter(function (Grid\Filter $filter) {
// $filter->equal('id');
//
// });
// });
// }
//
// /**
// * Make a show builder.
// *
// * @param mixed $id
// *
// * @return Show
// */
// protected function detail($id)
// {
// return Show::make($id, new DistAppearanceTemplate(), function (Show $show) {
// $show->field('id');
// $show->field('dist_id');
// $show->field('appearance_id');
// $show->field('file_name');
// $show->field('file_path');
// $show->field('content');
// $show->field('created_at');
// $show->field('updated_at');
// });
// }
//
// /**
// * Make a form builder.
// *
// * @return Form
// */
// protected function form()
// {
// return Form::make(new DistAppearanceTemplate(), function (Form $form) {
// $form->display('id');
// $form->text('dist_id');
// $form->text('appearance_id');
// $form->text('file_name');
// $form->text('file_path');
// $form->text('content');
//
// $form->display('created_at');
// $form->display('updated_at');
// });
// }
}