123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180 |
- <?php
- namespace App\Admin\Controllers;
- use App\Admin\Repositories\DistAppearanceTemplate;
- use Dcat\Admin\Form;
- use Dcat\Admin\Grid;
- use Dcat\Admin\Show;
- use Dcat\Admin\Http\Controllers\AdminController;
- use Dcat\Admin\Layout\Content;
- use Dcat\Admin\Admin;
- use App\Admin\Forms\AceLeft;
- use Illuminate\Http\Request;
- use Illuminate\Support\Str;
- use Dcat\Admin\Widgets\Card;
- class DistAppearanceTemplateController extends AdminController
- {
-
- public function ace(Content $content,Request $request) {
- $content->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 = '<ul class="list-group list-group-flush">';
- 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 = '<a href="#" class="file-action" file_id="'. $value['id'].'" title="'.$file_name.'">'. $file_name.'</a>';
- } else {
- $file_name = '<span class="custom-blue-bold">'. $file_name.'</span>';
- }
- $html .= '<li class="list-group-item has-submenu">';
- $html .= '<i class="fa '.$fa.'"></i> '. $file_name;
- $html .= $this->treeBuilder($value);
- $html .= '</li>';
- }
- $html .= '</ul>';
- return $html;
- }
- private function treeBuilder($value) {
- $html = '';
- if (!empty($value['children'])) {
- $html = '<ul class="submenu">';
- foreach ($value['children'] as $k => $v) {
- $fa = 'fa-angle-down';
- $file_name = $v['file_name'];
- if ($v['file_type'] == 1) {
- $fa = 'fa-angle-right';
- $file_name = '<a href="#" class="file-action" file_id="'. $v['id'].'" title="'.$file_name.'">'. $file_name.'</a>';
- } else {
- $file_name = '<span class="custom-blue-bold">'. $file_name.'</span>';
- }
- $html .= '<li class="list-group-item"><i class="fa '.$fa.'"></i> '. $file_name;
- if (!empty($v['children'])) {
- $html .= $this->treeBuilder($v);
- }
- $html .= '</li>';
- }
- $html .= '</ul>';
- }
- return $html;
- }
- }
|