/** * loadRouting * * @return mixed */ public static function loadRouting() { $app = Ioc::getApplication(); if ($app->get('client') == 'admin' || $app->get('client') == 'site') { return parent::loadRouting(); } return []; }
/** * onAfterExecute * * @param Event $event * * @return void * * @throws \Windwalker\Filesystem\Exception\FilesystemException */ public function onAfterExecute(Event $event) { /** @var WebApplication $app */ $app = Ioc::getApplication(); // Un comment this line, Translator will export all orphans to /cache/language if ($app->get('language.debug')) { TranslatorHelper::dumpOrphans('ini'); } }
/** * doExecute * * @return string */ protected function doExecute() { $view = new ProfileHtmlView($this->data); $model = new ProfileModel(); $session = Ioc::getSession(); $user = $session->get('profile.edit.data') ?: User::get(); $view['item'] = $user; $view['form'] = $model->getForm($user); return $view->setLayout('edit')->render(); }
/** * onUserAfterLogin * * @param Event $event * * @return void */ public function onUserAfterLogin(Event $event) { $options = $event['options']; $remember = $options['remember']; if ($remember) { $session = Ioc::getSession(); $uri = Ioc::get('uri'); setcookie(session_name(), $_COOKIE[session_name()], time() + 60 * 60 * 24 * 100, $session->getOption('cookie_path', $uri['base.path']), $session->getOption('cookie_domain')); } }
/** * Execute the controller. * * @return mixed Return executed result. * * @throws \LogicException * @throws \RuntimeException */ public function execute() { if (UserHelper::isLogin()) { Ioc::getApplication()->redirect(Router::build('admin:dashboard')); } $model = new RegistrationModel(); $view = new RegistrationHtmlView(); $session = Ioc::getSession(); $view['item'] = $session['register.form.data'] ?: array(); $view['item'] = new Data($view['item']); return $view->render(); }
/** * buildInput * * @param array $attrs * * @return string */ public function buildInput($attrs) { // Convert timezone $from = $this->get('from', 'UTC'); $to = $this->get('to', Ioc::getConfig()->get('system.timezone', 'UTC')); if ($attrs['value'] && $attrs['value'] != static::EMPTY_DATETIME) { $attrs['value'] = DateTime::convert($attrs['value'], $from, $to); } $input = parent::buildInput($attrs); $format = $this->get('format', 'YYYY-MM-DD HH:mm:ss'); $id = $this->getId(); return WidgetHelper::render('phoenix.form.field.calendar', array('id' => $id, 'input' => $input, 'attrs' => $attrs, 'format' => $format, 'field' => $this), WidgetHelper::EDGE); }
/** * Execute the controller. * * @return mixed Return executed result. * * @throws \LogicException * @throws \RuntimeException */ public function execute() { $model = new LoginModel(); $user = User::get(); if ($user->isNull()) { $this->setRedirect('login', 'Already logout', 'success'); } $model->logout($user->username); // Session $session = Ioc::getSession(); $session->remove('current.blog'); $this->setRedirect(Router::buildHttp('front:home'), 'Logout success', 'success'); return true; }
/** * Execute the controller. * * @return mixed Return executed result. * * @throws \LogicException * @throws \RuntimeException */ public function execute() { $id = $this->input->get('id'); $return = $this->input->get('return'); $return = $return ? base64_decode($return) : Router::build('admin:dashboard'); $user = User::get(); $blogModel = new BlogModel(); $blogModel['user.isAdmin'] = false; $blog = $blogModel->getCurrentBlog($user->id, $id); $session = Ioc::getSession(); if (!$blog->isNull()) { $session->set('current.blog', $blog->id); } $this->setRedirect($return); return true; }
/** * Execute this command. * * @return int * * @since 2.0 */ protected function doExecute() { $package = $this->getArgument(0); if (!$package) { throw new WrongArgumentException('Please enter package name.'); } $package = ConsoleHelper::getAllPackagesResolver()->getPackage($package); if (!$package) { throw new \InvalidArgumentException(sprintf('Package: %s not found', $this->getArgument(0))); } $recordClass = $this->getArgument(1); if (!$recordClass) { throw new WrongArgumentException('Please enter record name or class.'); } $recordClass = StringNormalise::toClassNamespace($recordClass); $pkgNamespace = ReflectionHelper::getNamespaceName($package); if (!class_exists($recordClass)) { $recordClass = $pkgNamespace . '\\Record\\' . ucfirst($recordClass) . 'Record'; } $table = null; if (class_exists($recordClass)) { try { /** @var Record $record */ $record = new $recordClass(); $table = $record->getTableName(); } catch (\Exception $e) { // Nothing } } if ($this->getArgument(2)) { $table = $this->getArgument(2); } $columns = Ioc::getDatabase()->getTable($table, true)->getColumnDetails(true); $fields = []; $dataType = Ioc::getDatabase()->getTable($table)->getDataType(); foreach ($columns as $column) { $fields[] = ['name' => $column->Field, 'type' => $dataType::getPhpType(explode('(', $column->Type)[0])]; } // Prepare Trait name $name = end(explode('\\', $recordClass)); $name = str_replace('Record', '', $name); $shortName = ucfirst($name) . 'DataTrait'; $data = ['package_namespace' => $pkgNamespace . '\\Record\\Traits', 'short_name' => $shortName, 'columns' => $fields]; $content = (new Edge(new EdgeStringLoader()))->render($this->getTemplate(), $data); $file = $package->getDir() . '/Record/Traits/' . $shortName . '.php'; if (is_file($file) && !(new BooleanPrompter())->ask('File: <comment>' . $file . '</comment> exists, do you want to override it? [N/y]: ', false)) { throw new \RuntimeException(' Canceled...'); } File::write($file, $content); $this->out()->out('Writing file: <info>' . $file . '</info> success.'); return true; }
/** * logout * * @param UserDataInterface|UserData $user * * @return bool */ public function logout(UserDataInterface $user) { $session = Ioc::getSession(); $session->remove('user'); return true; }