public function buildWindow(core\request $path, core\argument $exts, $bUpdate = null, $bRun = true) { $this->setSettings($exts); $sExtension = strtolower($path->getExtension()); if (!$sExtension) { $sExtension = self::EXTENSION_DEFAULT; } $settings = $this->get($sExtension); $sCurrent = (string) $path; $path->parse(); $aPaths = $this->buildWindowStack($settings, $sCurrent); $aPaths[] = (string) $path->asFile(); $bAccess = true; foreach ($aPaths as $sFile) { $file = $this->getFile($sFile, false); if (!$file || !$file->checkRights(\Sylma::MODE_EXECUTE)) { $bAccess = false; break; } } if (!$bAccess) { $this->getInitializer()->send404(); $aPaths = $this->buildWindowStack($this->createArgument(array($this->get('error'))), ''); $aPaths[] = $this->read('error/path'); } $aPaths = array_reverse($aPaths); $sMain = array_pop($aPaths); $window = $this->getFile($sMain); $args = $path->getArguments(); $args->set('sylma-paths', $aPaths); $builder = $this->getManager(self::PARSER_MANAGER); return $builder->load($window, array('arguments' => $args), $bUpdate, $bRun); }
protected function runScript(core\request $path) { $sResult = ''; $bProfile = $this->readArgument('debug/profile'); if ($bProfile) { $profiler = $this->create('profiler'); $profiler->start(); //xdebug_start_code_coverage(XDEBUG_CC_UNUSED | XDEBUG_CC_DEAD_CODE); } $sExtension = $path->parseExtension(true); if ($sExtension == $this->readArgument('redirect/extension')) { $path->parse(); $redirect = $this->prepareScript($path->asFile(), $path->getArguments()); if (!$redirect instanceof core\redirect) { $this->throwException('Cannot redirect at that adress'); } $this->runRedirect($redirect); } else { if (in_array($sExtension, $this->query('executables'))) { $sResult = $this->runExecutable($path); } else { if (!$path->getExtension()) { $builder = $this->createWindowBuilder(); $sResult = $builder->buildWindow($path, $this->get('window'), $this->read('debug/update', false), $this->read('debug/run')); } else { $this->throwException('No valid window defined'); } } } if ($bProfile) { $profiler->stop(); $profiler->save(); /* $data = xdebug_get_code_coverage(); xdebug_stop_code_coverage(); //print_r($data); */ } return $sResult; }