/** * Launch the compilation of a template * * Store the result (a php content) into a cache file given by the selector. * @param jSelectorTpl $selector the template selector * @return boolean true if ok */ public function compile($selector) { $this->_sourceFile = $selector->getPath(); $this->outputType = $selector->outputType; $this->trusted = $selector->trusted; $md5 = md5($selector->module . '_' . $selector->resource . '_' . $this->outputType . ($this->trusted ? '_t' : '')); jApp::pushCurrentModule($selector->module); if (!file_exists($this->_sourceFile)) { $this->doError0('errors.tpl.not.found'); } $header = "if (jApp::config()->compilation['checkCacheFiletime'] &&\n"; $header .= "filemtime('" . $this->_sourceFile . '\') > ' . filemtime($this->_sourceFile) . "){ return false;\n} else {\n"; $footer = "return true;}\n"; $this->compileString(file_get_contents($this->_sourceFile), $selector->getCompiledFilePath(), $selector->userModifiers, $selector->userFunctions, $md5, $header, $footer); jApp::popCurrentModule(); return true; }
function single() { $rep = $this->_prepareResponse(); $module = $this->param('mod'); $testname = $this->param('test'); $category = $this->category ? ' ' . $this->category : ''; if (isset($this->testsList[$module])) { $reporter = jClasses::create($this->responseType); jClasses::inc('junittests~junittestcase'); jClasses::inc('junittests~junittestcasedb'); $reporter->setResponse($rep); foreach ($this->testsList[$module] as $test) { if ($test[1] == $testname) { $group = new TestSuite('"' . $module . '" module , ' . $test[2]); $group->addFile(jApp::config()->_modulesPathList[$module] . 'tests/' . $test[0]); jApp::pushCurrentModule($module); $result = $group->run($reporter); if (!$result) { $rep->setExitCode(jResponseCmdline::EXIT_CODE_ERROR); } jApp::popCurrentModule(); break; } } } else { $this->output("\n" . 'no' . $category . ' tests for "' . $module . '" module.' . "\n"); } return $this->_finishResponse($rep); }
/** * main method : launch the execution of the action. * * This method should be called in a entry point. * * @param jRequest $request the request object. It is required if a descendant of jCoordinator did not called setRequest before */ public function process($request = null) { jLog::log("process: start"); try { if ($request) { $this->setRequest($request); } jSession::start(); $ctrl = $this->getController($this->action); } catch (jException $e) { $config = jApp::config(); if ($config->urlengine['notfoundAct'] == '') { throw $e; } if (!jSession::isStarted()) { jSession::start(); } try { jLog::log("Exception: get notfoundact ctrl (" . $config->urlengine['notfoundAct'] . ")"); $this->action = new jSelectorAct($config->urlengine['notfoundAct']); $ctrl = $this->getController($this->action); } catch (jException $e2) { throw $e; } } jApp::pushCurrentModule($this->moduleName); if (count($this->plugins)) { $pluginparams = array(); if (isset($ctrl->pluginParams['*'])) { $pluginparams = $ctrl->pluginParams['*']; } if (isset($ctrl->pluginParams[$this->action->method])) { $pluginparams = array_merge($pluginparams, $ctrl->pluginParams[$this->action->method]); } jLog::dump($pluginparams, "process: plugin params"); foreach ($this->plugins as $name => $obj) { jLog::log("process: beforeAction on plugin {$name}"); $result = $this->plugins[$name]->beforeAction($pluginparams); if ($result) { $this->action = $result; jApp::popCurrentModule(); jApp::pushCurrentModule($result->module); jLog::log("process: beforeAction said to do internal redirect to " . $result->module . "~" . $result->resource); $this->moduleName = $result->module; $this->actionName = $result->resource; $ctrl = $this->getController($this->action); break; } } } jLog::log('process: call action'); $this->response = $ctrl->{$this->action->method}(); if ($this->response == null) { throw new jException('jelix~errors.response.missing', $this->action->toString()); } jLog::log('process: response: ' . get_class($this->response)); if (get_class($this->response) == 'jResponseRedirect') { jLog::log('process: redirection to ' . $this->response->action); } else { if (get_class($this->response) == 'jResponseRedirectUrl') { jLog::log('process: redirection to ' . $this->response->url); } } foreach ($this->plugins as $name => $obj) { jLog::log('process: beforeOutput on plugin ' . $name); $this->plugins[$name]->beforeOutput(); } jLog::log('process: call response output'); $this->response->output(); foreach ($this->plugins as $name => $obj) { jLog::log('process: afterProcess on plugin ' . $name); $this->plugins[$name]->afterProcess(); } jApp::popCurrentModule(); jSession::end(); jLog::log('process: end'); }
protected function tearDown() { jApp::popCurrentModule(); }
protected function parseRecord($xml, $tools) { //add the record properties if (isset($xml->record)) { if (isset($xml->record[0]['extends'])) { jApp::pushCurrentModule($this->selector->module); $this->_userRecord = new jSelectorDaoRecord((string) $xml->record[0]['extends']); jApp::popCurrentModule(); } if (isset($xml->record[0]->property)) { // don't append directly new properties into _properties, // so we can see the differences between imported properties // and readed properties $properties = array(); foreach ($xml->record[0]->property as $prop) { $p = new jDaoProperty($prop->attributes(), $this, $tools); if (isset($properties[$p->name])) { throw new jDaoXmlException($this->selector, 'property.already.defined', $p->name); } if (!in_array($p->name, $this->_tables[$p->table]['fields'])) { // if this property does not redefined an imported property $this->_tables[$p->table]['fields'][] = $p->name; } $properties[$p->name] = $p; } $this->_properties = array_merge($this->_properties, $properties); } } // in the case when there is no defined property and no imported dao if (count($this->_properties) == 0) { throw new jDaoXmlException($this->selector, 'properties.missing'); } // check that properties are attached to a known table. It can be // wrong if the datasource has been redefined with other table names $countprop = 0; foreach ($this->_properties as $p) { if (!isset($this->_tables[$p->table])) { throw new jDaoXmlException($this->selector, 'property.imported.unknown.table', $p->name); } if ($p->ofPrimaryTable && !$p->isPK) { $countprop++; } } $this->hasOnlyPrimaryKeys = $countprop == 0; }
function single() { $conf = jApp::config(); if (!isset($conf->enableTests) || !$conf->enableTests) { // security $rep = $this->getResponse('html', true); $rep->title = 'Error'; $rep->setHttpStatus('404', 'Not found'); $rep->addContent('<p>404 Not Found</p>'); return $rep; } $rep = $this->_prepareResponse(); $module = $this->param('mod'); $testname = $this->param('test'); if (isset($this->testsList[$module])) { $reporter = jClasses::create("junittests~jhtmlrespreporter"); jClasses::inc('junittests~junittestcase'); jClasses::inc('junittests~junittestcasedb'); $reporter->setResponse($rep); foreach ($this->testsList[$module] as $test) { if ($test[1] == $testname) { $group = new TestSuite('"' . $module . '" module , ' . $test[2]); $group->addFile($conf->_modulesPathList[$module] . 'tests/' . $test[0]); jApp::pushCurrentModule($module); $group->run($reporter); jApp::popCurrentModule(); break; } } } else { $rep->body->assign('MAIN', '<p>no tests for "' . $module . '" module.</p>'); } return $this->_finishResponse($rep); }
/** * main method : launch the execution of the action. * * This method should be called in a entry point. * * @param jRequest $request the request object. It is required if a descendant of jCoordinator did not called setRequest before */ public function process($request = null) { try { if ($request) { $this->setRequest($request); } jSession::start(); $ctrl = $this->getController($this->action); } catch (jException $e) { $config = jApp::config(); if ($config->urlengine['notfoundAct'] == '') { throw $e; } if (!jSession::isStarted()) { jSession::start(); } try { $this->action = new jSelectorAct($config->urlengine['notfoundAct']); $ctrl = $this->getController($this->action); } catch (jException $e2) { throw $e; } } jApp::pushCurrentModule($this->moduleName); if (count($this->plugins)) { $pluginparams = array(); if (isset($ctrl->pluginParams['*'])) { $pluginparams = $ctrl->pluginParams['*']; } if (isset($ctrl->pluginParams[$this->action->method])) { $pluginparams = array_merge($pluginparams, $ctrl->pluginParams[$this->action->method]); } foreach ($this->plugins as $name => $obj) { $result = $this->plugins[$name]->beforeAction($pluginparams); if ($result) { $this->action = $result; jApp::popCurrentModule(); jApp::pushCurrentModule($result->module); $this->moduleName = $result->module; $this->actionName = $result->resource; $ctrl = $this->getController($this->action); break; } } } $this->response = $ctrl->{$this->action->method}(); if ($this->response == null) { throw new jException('jelix~errors.response.missing', $this->action->toString()); } foreach ($this->plugins as $name => $obj) { $this->plugins[$name]->beforeOutput(); } $this->response->output(); foreach ($this->plugins as $name => $obj) { $this->plugins[$name]->afterProcess(); } jApp::popCurrentModule(); jSession::end(); }
/** * instancy a zone object, and call one of its methods * @param string $name zone selector * @param string $method method name * @param array $params arguments for the method * @return mixed the result returned by the method */ private static function _callZone($name, $method, &$params) { $sel = new jSelectorZone($name); jApp::pushCurrentModule($sel->module); $fileName = $sel->getPath(); require_once $fileName; $className = $sel->resource . 'Zone'; $zone = new $className($params); $toReturn = $zone->{$method}(); jApp::popCurrentModule(); return $toReturn; }