pages = $pageRepository; $this->settings = $settingsService; $this->assets = $assetService; $this->sort = $sortService; $this->init = $initService; $this->dash = $dashController; } public function start($one = 00, $two = 00, $three = 00) { $global = $this->settings->getGlobal(); $currentTheme = $this->assets->getCurrentTheme(); $template; $pageData = []; $pages = $this->pages->getAll(); //weird bug where the whole url is being passed with optional params //for now, just split it manually and set it to the vars used $paths = explode('/', $one); if (isset($paths[0])) { $one = $paths[0]; } if (isset($paths[1])) { $two = $paths[1]; } if (isset($paths[2])) { $three = $paths[2]; } //check if configs are present if (file_exists(env('FOLKS_PATH')) && file_exists(env('SETTINGS_PATH'))) { if ($global['dynamicRender'] == 'true') { if (is_numeric($one)) { if ($one == 00 || !isset($one)) { $page = $pages->where('id', 0)->first(); $pageData = $this->sort->page($page, false); $template = $currentTheme . '.index'; } else { $page = $this->pages->getBySlug($three); $pageData = $this->sort->page($page, false); $template = $currentTheme . '.' . $page['layout']; } } else { if ($one == null || $one == '') { $page = $pages->where('id', 0)->first(); $pageData = $this->sort->page($page, false); $template = $currentTheme . '.index'; } else { if ($one == 'archives' || $one == 'archive' || $one == 'tags') { $currentTheme = $this->assets->getCurrentTheme(); switch ($one) { case 'archive': case 'archives': $template = $currentTheme . '.archive'; $pageData = $this->sort->archive(false); break; case 'tags': $template = $currentTheme . '.tags'; $tags = $this->sort->tags(false); $tagData = find($tags['tags'], ['tag_name' => $two]); $pageData = [ 'theme' => $currentTheme, // for theme kit 'title' => 'Pages Tagged as ' . $two, 'dynamicRender' => $tags['dynamicRender'], 'info' => $tags['info'], 'menu' => $tags['menu'], 'pages' => $tagData['pages'], 'media' => $tags['media'], ]; break; } } else { $page = $this->pages->getBySlug($one); $pageData = $this->sort->page($page, false); $template = $currentTheme . '.' . $page['layout']; } } } return view($template, $pageData); } else { if (is_file('../public/index.html')) { return response()->file('../public/index.html'); } else { return redirect()->intended('dashboard/start'); } } } else { return view('back.init', ["status" => false, "title" => "Set Up"]); } } //setup up a new site or restore from back up public function init($task, Request $request) { $result = []; switch ($task) { case 'fresh': $result = $this->init->fresh(json_decode($request->getContent())); break; case 'restore': $result = $this->init->restore($request); break; } return response()->json($result)->header('Content-Type', 'application/json'); } }