public function view($params) { //si c'est un repertoire $rep = true; $document = array(); //si ont ce déplace dans le repertoire if (isset($_GET['dir'])) { //si on demande de revenir en arriére if ($_GET['dir'] == '..') { $this->path->retrograde(); } else { //si c'est un dossier if (is_dir($this->path->get() . $_GET['dir'])) { $this->path->addDir($_GET['dir']); } } } //si ont demande un fichier if (isset($_GET['file'])) { if (file_exists($_GET['file'])) { $file = $_GET['file']; //si modifier un fichier if (!isset($_GET['noEdit'])) { $_GET['noEdit'] = false; } //ce n'est pas un repertoir $rep = false; //extension fichier $extension = FoxFWFile::getExtension($file); //config document $document['fichier'] = $file; $document['url'] = FoxFWKernel::router('index') . $file; $document['type'] = $extension; $document['path'] = $file; $document['body'] = ''; $document['edit'] = !$_GET['noEdit']; //chargement du body switch ($extension) { case 'txt': case 'html': case 'js': case 'css': case 'json': case 'tpl': case 'php': $document['body'] = file_get_contents($document['path']); break; } } } //lister repertoire $files = array(); $dirs = array(); if ($dh = opendir($this->path->get())) { while (false !== ($filename = readdir($dh))) { if (is_dir($this->path->get() . $filename)) { array_push($dirs, $filename); } else { array_push($files, $filename); } } } else { die('Dossier inconu !'); } //render return $GLOBALS['Twig']->render(FoxFWKernel::getView('Document_view'), array('path' => $this->path->get(), 'file' => $files, 'dir' => $dirs, 'rep' => $rep, 'document' => $document)); }
// // //-------------------------------------------------------------------------------- //twig extension function path ! $GLOBALS['Twig']->addFunction(new Twig_SimpleFunction('path', function ($url) { return FoxFWKernel::path($url); })); //-------------------------------------------------------------------------------- //-------------------------------------------------------------------------------- // // // //-------------------------------------------------------------------------------- //twig extension function router ! $GLOBALS['Twig']->addFunction(new Twig_SimpleFunction('router', function ($id, $add = '') { return FoxFWKernel::router($id, $add); })); //-------------------------------------------------------------------------------- //-------------------------------------------------------------------------------- // // // //-------------------------------------------------------------------------------- //twig extension function controller $GLOBALS['Twig']->addFunction(new Twig_SimpleFunction('controller', function ($method, $params = array()) { $error = FoxFWKernel::controller($method, $params); if ($error != 200) { die('Error Controller Twig Appel ! '); } }, array('is_safe' => array('html')))); //--------------------------------------------------------------------------------
public static function loadRouter($id, $add = '') { header('Location: ' . FoxFWKernel::router($id, $add)); }
public function e401() { //header('Location: '.FoxFWKernel::router('user_login') ); return $GLOBALS['Twig']->render(FoxFWKernel::getView('error_error'), array('error' => '401', 'message' => '<b style="color:red;">Une authentification/Roles est nécessaire pour accéder à la ressource !</b><br/><a href="' . FoxFWKernel::router('user_login') . '"> - Se connecter - </a>')); }