/** * Sets the current sheet. Default is 'main'. * @param string $sheet * @return */ public static function ln($sheet) { if (self::$translator === NULL) { self::$translator = Environment::getService('ITranslator'); } return self::$translator->setCurrentSheet($sheet); }
public function authenticate(array $credentials) { $login = $credentials['username']; $password = $this->phash($credentials['password']); $super_admin = Environment::getVariable('admin'); if ($login == $super_admin['login']) { if ($password == $super_admin['password']) { $super_admin['roles'] = array('super admin'); $super_admin['id'] = 0; $row = new DibiRow($super_admin); MokujiServiceLocator::addService('UserAuthorizator', new Admin_UserModel()); } else { throw new AuthenticationException("Invalid password.", self::INVALID_CREDENTIAL); } } else { try { $login_manager = Environment::getService('UserAuthenticator'); $row = $login_manager->authenticate($credentials); } catch (InvalidStateException $e) { throw new AuthenticationException("Login and password combination failed.", self::INVALID_CREDENTIAL); } } $identity = new Identity($row->id, $row->roles, $row); $identity->id = $row->id; return $identity; }
private function gatherActions() { $service = Environment::getService('Nette\\Loaders\\RobotLoader'); $class_list = $service->list; $actions = array(); foreach ($class_list as $class => $file) { //zachtime annotation exception lebo nette si generuje nejake annotation claasy do robotloodera try { $r = new ReflectionClass($class); if ($r->isSubclassOf('Admin_SecurePresenter') && $r->getName() != 'BaseModulePresenter') { $methods = $r->getMethods(ReflectionMethod::IS_PUBLIC); foreach ($methods as $method) { if (String::lower($method->class) == $class) { if (strpos($method->getName(), 'action') !== false || strpos($method->getName(), 'handle') !== false) { $actions[$class][] = $method->getName(); } } } } } catch (ReflectionException $e) { } } $actions = array_merge($actions, Environment::getApplication()->getModulesPermissions()); $model = new UsersModuleModel(); $model->saveActions($actions); return $actions; }
public function startup() { parent::startup(); if (!isset($this->lang)) { $this->lang = $this->getHttpRequest()->detectLanguage($this->langs); if ($this->lang == null) { $this->lang = 'en'; } $this->canonicalize(); } $this->translator = Environment::getService('Mokuji\\Translator\\Admin'); $this->translator->lang = $this->lang; //$this->translator = new Admin_Translator($this->lang); $cache = Environment::getCache('langs'); $langs = $cache->offsetGet('langs'); if ($langs == NULL) { $this->langs = $this->translator->getSupportedLangs(); //$this->model('lang')->getAll(); $cache->save('langs', $this->langs); } else { $this->langs = $langs; } $this->refreshConfig(); }
/** * Returns current authorization handler. * @return IAuthorizator */ public final function getAuthorizationHandler() { if ($this->authorizationHandler === NULL) { $this->authorizationHandler = Environment::getService('Nette\\Security\\IAuthorizator'); } return $this->authorizationHandler; }
/** * Texyla preview */ public function actionPreview() { $texy = Environment::getService("Texy"); $html = $texy->process(Environment::getHttpRequest()->getPost("texy")); $this->terminate(new RenderResponse($html)); }
public function getTranslator() { if (is_null($this->translator)) { $this->translator = Environment::getService('Nette\\ITranslator'); } return $this->translator; }
/** * Returns the ICacheJournal * @return ICacheJournal */ protected function getJournal() { if ($this->journal === NULL) { $this->journal = Environment::getService('Nette\\Caching\\ICacheJournal'); } return $this->journal; }