public function editpageAction() { $id = request()->getId(); if (!is_null($id)) { $permission = 'cms'; $auth = auth()->can($permission); if (true === $auth || true === $this->isAdmin) { $dirPages = realpath(APPLICATION_PATH . DS . '..' . DS . 'public' . DS . 'content' . DS . SITE_NAME . DS . 'pages'); $dirPartials = realpath(APPLICATION_PATH . DS . '..' . DS . 'public' . DS . 'content' . DS . SITE_NAME . DS . 'partials'); if (!strlen($dirPages) || !strlen($dirPartials)) { $this->forward('home'); } $pages = File::readdir($dirPages); $partials = File::readdir($dirPartials); $pages = array_merge($pages, $partials); $key = $id - 1; $file = isset($pages[$key]) ? $pages[$key] : false; if (false !== $file) { if ($this->isPost()) { $html = request()->getHtml(); $config = request()->getConfig(); $content = "/*\n {$config}\n*/\n{$html}"; File::delete($file); File::put($file, $content); $this->forward('pagelist'); } else { $content = fgc($file); $this->view->configPage = repl(array('/*', '*/'), '', $this->getConfigPage($content)); $this->view->htmlPage = $this->getHtml($content); $this->view->title = 'Mettre à jour une page'; } } else { $this->forward('pagelist'); } } else { $this->forward('pagelist'); } } else { $this->forward('pagelist'); } }