/**
  * 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 LoginModel();
     $session = Ioc::getSession();
     $user = $this->input->getVar('user');
     $result = $model->login($user['username'], $user['password']);
     $package = $this->getPackage();
     $redirect = $session->get('login.redirect.url');
     if ($result) {
         $url = $redirect ? base64_decode($redirect) : $package->get('redirect.login');
         $msg = Language::translate('Login Success');
     } else {
         $router = Ioc::getRouter();
         $url = $router->build($this->package->getRoutingPrefix() . ':login');
         $msg = Language::translate('Login Fail');
     }
     $uri = new Uri($url);
     if (!$uri->getScheme()) {
         $url = $this->app->get('uri.base.full') . $url;
     }
     $session->remove('login.redirect.url');
     $this->setRedirect($url, $msg);
     return true;
 }
 /**
  * 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 LoginModel();
     $view = new LoginHtmlView();
     $view['form'] = $model->getForm();
     return $view->render();
 }
示例#3
0
 /**
  * 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();
 }
示例#4
0
 /**
  * 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;
 }
示例#5
0
 protected function doExecute()
 {
     $data = $this->input->getVar('category');
     $data = new Data($data);
     $data['title'] = trim($data['title']);
     if (!$data['title']) {
         $this->setRedirect(Router::build('admin:categories'), 'Title should not be empty', 'danger');
         return false;
     }
     if (!$data['blog']) {
         $data['blog'] = Blog::get()->id;
     }
     $data['alias'] = OutputFilter::stringURLSafe(trim($data['title']));
     $data['alias'] = $data['alias'] ?: OutputFilter::stringURLSafe((string) new Date());
     $data['state'] = 1;
     if (!$data['ordering']) {
         $max = $this->getMaxOrder($data['blog']);
         $data['ordering'] = $max + 1;
     }
     try {
         $category = new Record('categories');
         if ($data['id']) {
             $category->load($data['id']);
         }
         $category->bind($data);
         $category->check();
         $category->store(true);
     } catch (\Exception $e) {
         if (WINDWALKER_DEBUG) {
             throw $e;
         }
         $this->setRedirect(Router::build('admin:categories'), 'Save Error', 'danger');
         return false;
     }
     $this->setRedirect(Router::build('admin:categories'), 'Create success', 'success');
     return true;
 }
示例#6
0
<?php 
$this->block('content');
?>
<div class="container">
	<div class="row">
		<div class="col-md-12">
			<form action="<?php 
echo $data->uri['current'];
?>
" class="form-horizontal" method="post">
				<fieldset>
					<legend>LOGIN</legend>
					<?php 
echo $data->form->renderFields();
?>

					<div class="buttons">
						<button class="btn btn-primary" type="submit">Login</button>

						<a class="btn btn-success" href="<?php 
echo $data->uri['base.path'] . Router::build('user:registration');
?>
">Register</a>
					</div>
				</fieldset>
			</form>
		</div>
	</div>
</div>
<?php 
$this->endblock();