public function controller() { $O = $this; $route = $this->route()->getRoute(); // dev tools if ($this->glob('debug') > 2) { $c = $this->route()->getCommand(); if (isset($c[0])) { switch ($c[0]) { case 'Generator_Webservice': $this->tpl()->setDebug(0); \FpModule\Webservice\Module::invoke($O)->html()->render(); break; case 'Generator_Crud': case 'Generator_Crud2': $this->tpl()->setDebug(0); \FpModule\Crud\Module::invoke($O)->html()->render(); break; } } } // si c'est un module // le point d'entrée du module doit être présent dans la conf if (!$this->output()) { if ($module_class = Filter::raw('module', $_GET)) { $module_entry = $this->glob('module_entry'); $module_class = trim(str_replace('.', '\\', $module_class), '/'); $mode = Filter::id('mode', $_REQUEST); if ($module_class) { if (class_exists($module_class)) { $module = new $module_class($O); if ($module instanceof \Fp\Module\Module) { $module->setMode($mode); if ($module->getMode()) { $controller = $module->getController($module->getMode()); $controller->setRequestParams($_GET); $controller->init(); $controller->render(); } else { throw new Exception('mode not found', 404); } } else { throw new Exception('module not found', 404); } } else { throw new Exception('module not found', 404); } } else { throw new Exception('module not found', 404); } } } if (!$this->output()) { $this->router()->parse($this, '/' . $this->router()->getRawRoute()); } // si on a toujours rien pour la sortie on regarde dans data/route/ if (!$this->output()) { // c'est un fichier ou un dossier $file = $this->dir_route . $route; if (is_dir($file) && is_file($file . '/index.php')) { include_once $file . '/index.php'; } elseif (is_file($file . '.php')) { include_once $file . '.php'; } } if (!$this->output()) { // ancienne méthode, déprécié // encore utilisé par le module facebook ( voir redirect_uri ) $command_0 = $this->route()->getCommand(0); if ($command_0 == 'mod') { $module_entry = $this->glob('module_entry'); $module_class = null; $module_class = $this->route()->getCommand(1); $module_class = trim(str_replace('.', '\\', $module_class), '/'); if (!($mode = Filter::id('m', $_REQUEST))) { $mode = $this->route()->getCommand(2); } if ($module_class && class_exists($module_class)) { $module = new $module_class($O); if ($module instanceof \Fp\Module\Module) { $module->setMode($mode); if ($module->getMode()) { $controller = $module->getController($module->getMode()); $controller->setRequestParams($_GET); $controller->init(); $controller->render(); } else { throw new Exception('mode not found', 404); } } else { throw new Exception('module not found', 404); } } } } }
/** * Logs with an arbitrary level. * * @param mixed $level * @param string $message * @param array $context * @return null */ public function log($level, $message, array $context = array()) { $errstr = $backtrace = $errno = $errfile = $errline = $code = null; if (isset($context[0]) && $context[0] instanceof \Exception) { $errstr = $context[0]->getMessage(); $backtrace = $context[0]->getTraceAsString(); $errfile = $context[0]->getFile(); $errline = $context[0]->getLine(); $code = $context[0]->getCode(); } else { if (array_key_exists('exception', $context) and $context['exception'] instanceof \Exception) { $errstr = $context['exception']->getMessage(); $backtrace = $context['exception']->getTraceAsString(); $errfile = $context['exception']->getFile(); $errline = $context['exception']->getLine(); $code = $context['exception']->getCode(); } else { $errortype = array(E_ERROR => 'Erreur', E_WARNING => 'Alerte', E_PARSE => 'Erreur d\'analyse', E_NOTICE => 'Notice', E_CORE_ERROR => 'Core Error', E_CORE_WARNING => 'Core Warning', E_COMPILE_ERROR => 'Compile Error', E_COMPILE_WARNING => 'Compile Warning', E_USER_ERROR => 'Erreur spécifique', E_USER_WARNING => 'Alerte spécifique', E_USER_NOTICE => 'Note spécifique', E_STRICT => 'Runtime Notice', E_RECOVERABLE_ERROR => 'Catchable Fatal Error'); $errno = Filter::int($level); if ($errno && array_key_exists($errno, $errortype)) { $level = $errortype[$errno]; } $errfile = Filter::raw('file', $context); $errline = Filter::raw('line', $context); $code = null; } } \Fp\Core\Debug::msg($message, $backtrace, $errno, $errfile, $errline, $level); self::$logMessage[] = "<div><b>{$level}:</b> {$message}<div>{$errfile} {$errline}<pre>{$backtrace}</pre></div></div>"; }