protected function _createInstance() { if ($this->toSelector === null) { $this->instance = null; $this->toSelector = $this->_getClassSelector(); } return jClasses::create($this->toSelector->toString()); }
/** * function to manage data before assigning to the template of its zone */ protected function _prepareTpl() { list($nbAnonymous, $members, $bots) = jClasses::create('activeusers~connectedusers')->getConnectedList(); $this->_tpl->assign('nbAnonymous', $nbAnonymous); $this->_tpl->assign('members', $members); $this->_tpl->assign('nbMembers', count($members)); $this->_tpl->assign('bots', $bots); }
public function verifyPassword($login, $password) { if (trim($password) == '') { return false; } $classuser = jClasses::create($this->_params['class']); $user = $classuser->getByLoginPassword($login, $this->cryptPassword($password)); return $user ? $user : false; }
/** * function to manage data before assigning to the template of its zone */ protected function _prepareTpl() { $today = mktime(0, 0, 0, date("m"), date("d"), date("Y")); list($nbAnonymous, $members, $bots) = jClasses::create('activeusers~connectedusers')->getConnectedList($today, true); $this->_tpl->assign('nbAnonymous', $nbAnonymous); $this->_tpl->assign('members', $members); $this->_tpl->assign('nbMembers', count($members)); $this->_tpl->assign('bots', $bots); }
/** * Get the binded instance * * @return mixed */ public function getInstance() { if ($this->instance === null) { if ($this->toSelector === null) { $this->toSelector = $this->_getClassSelector(); } $this->instance = jClasses::create($this->toSelector->toString()); } return $this->instance; }
public function testBindingInCodeToInstance() { $instance = jClasses::create('jelix_tests~myclass'); jClasses::bind('jelix_tests~test')->toInstance($instance); $class = jClasses::getBindedService('jelix_tests~test'); $this->assertTrue($class instanceof myclass); jClasses::bind('jelix_tests~test')->toInstance($instance); $classname = jClasses::bind('jelix_tests~test')->getClassName(); $this->assertTrue($classname === 'myclass'); }
/** * function to manage data before assigning to the template of its zone */ protected function _prepareTpl() { $login = $this->param('login'); $status = 'offline'; if ($login) { if (jClasses::create('connectedusers')->isConnected($login)) { $status = 'online'; } else { $status = 'offline'; } } $this->_tpl->assign('status', $status); }
function save() { $rep = $this->getResponse('redirect'); $rep->action = 'default:index'; $form = jForms::fill('config'); if (!$form) { return $rep; } if (!$form->check()) { return $rep; } $activeusers = jClasses::create('activeusers~connectedusers'); try { $activeusers->saveVisitTimeout($form->getData('timeout_visit')); jMessage::add(jLocale::get('main.config.save.ok')); } catch (Exception $e) { jMessage::add('Error: ' . $e->getMessage(), 'error'); } return $rep; }
public function verifyPassword($login, $password) { if (trim($password) == '') { return false; } $class = jClasses::create($this->_params['class']); $user = $class->getByLogin($login); if (!$user) { return false; } $result = $this->checkPassword($password, $user->password); if ($result === false) { return false; } if ($result !== true) { // it is a new hash for the password, let's update it persistently $user->password = $result; $class->updatePassword($login, $result); } return $user; }
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); }
function onservinfoGetInfo($event) { $nbMembers = jClasses::create('activeusers~connectedusers')->getCount(); $label = jLocale::get('activeusers_admin~main.server.infos.online.users'); $event->add(new serverinfoData('user-online', $label, $nbMembers)); }
function single() { $rep = $this->_prepareResponse(); $module = $this->param('mod'); $testname = $this->param('test'); if (isset($this->testsList[$module])) { $reporter = jClasses::create("junittests~jtextrespreporter"); jClasses::inc('junittests~junittestcase'); jClasses::inc('junittests~junittestcasedb'); $reporter->setResponse($rep); foreach ($this->testsList[$module] as $test) { if ($test[1] == $testname) { $group = new GroupTest('"' . $module . '" module , ' . $test[2]); $group->addTestFile($GLOBALS['gJConfig']->_modulesPathList[$module] . 'tests/' . $test[0]); jContext::push($module); $result = $group->run($reporter); if (!$result) { $rep->setExitCode(jResponseCmdline::EXIT_CODE_ERROR); } jContext::pop(); break; } } } else { $rep->addContent("\n" . 'no tests for "' . $module . '" module.' . "\n"); } return $this->_finishResponse($rep); }
protected function _prepareResponse() { $rep = $this->getResponse('html', true); $rep->bodyTpl = 'junittests~main'; $rep->body->assign('page_title', 'Unit Tests'); $rep->body->assign('versionphp', phpversion()); $rep->body->assign('versionjelix', JELIX_VERSION); $rep->body->assign('basepath', jApp::config()->urlengine['basePath']); $rep->body->assign('isurlsig', jApp::config()->urlengine['engine'] == 'significant'); $runnerPreparer = jClasses::create('junittests~jrunnerpreparer'); $this->allTestsList = $runnerPreparer->getTestsList('html'); $this->category = $this->param('categ', false); $this->testsList = $runnerPreparer->filterTestsByCategory($this->category, $this->allTestsList); $rep->body->assign('modules', $this->allTestsList); return $rep; }
function single() { if (!isset($GLOBALS['gJConfig']->enableTests) || !$GLOBALS['gJConfig']->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 GroupTest('"' . $module . '" module , ' . $test[2]); $group->addTestFile($GLOBALS['gJConfig']->_modulesPathList[$module] . 'tests/' . $test[0]); jContext::push($module); $group->run($reporter); jContext::pop(); break; } } } else { $rep->body->assign('MAIN', '<p>no tests for "' . $module . '" module.</p>'); } return $this->_finishResponse($rep); }