예제 #1
0
파일: Token.php 프로젝트: johnstyle/sjo
 public static function has($type = 'REQUEST')
 {
     if (Request::env($type)->token->eq(self::get(Router::getToken()))) {
         return true;
     }
     return false;
 }
예제 #2
0
파일: Auth.php 프로젝트: johnstyle/sjo
 public static function secure()
 {
     $rc = new \ReflectionClass(self::model());
     $modelName = $rc->getShortName();
     if (Router::$controller !== $modelName . '\\Auth') {
         if (!self::model()->isLogged()) {
             http_response_code(401);
             Http::redirect(Router::link(Router::$interface, $modelName . '\\Auth', array('redirect' => Request::env('SERVER')->REQUEST_URI->val())));
         }
     } elseif (self::model()->isLogged() && !Router::$method) {
         Http::redirect(Router::link());
     }
 }
예제 #3
0
파일: edit.php 프로젝트: johnstyle/sjo
<?php

use sJo\Module\Admin\Model\Admin;
use sJo\Loader\Router;
use sJo\View\Helper;
use sJo\Libraries as Lib;
Helper\Panel::create(array('col' => 6, 'title' => Admin::getInstance()->getPrimaryValue() ? Lib\I18n::__('Edit admin') : Lib\I18n::__('Create admin'), 'class' => Admin::getInstance()->getPrimaryValue() ? 'panel-primary' : 'panel-success', 'elements' => Helper\Fieldset::create(array(Helper\Token::create(Router::getToken()), Helper\Input::create(array('type' => 'email', 'name' => 'email', 'label' => Lib\I18n::__('Email address'), 'placeholder' => Lib\I18n::__('Enter email'), 'value' => Admin::getInstance()->request('email'))), Helper\Input::create(array('type' => 'text', 'name' => 'name', 'label' => Lib\I18n::__('Name'), 'placeholder' => Lib\I18n::__('Enter name'), 'value' => Admin::getInstance()->request('name'))))), 'footer' => Helper\ButtonGroup::create(array('class' => 'pull-right', 'elements' => array(Helper\Button::create(array('name' => 'saveAndStay', 'value' => Lib\I18n::__('Save and stay'))), Helper\Button::create(array('name' => 'saveAndCreate', 'value' => Lib\I18n::__('Save and create new'), 'class' => 'btn-warning')), Helper\Button::create(array('value' => Lib\I18n::__('Save and back to list'), 'class' => 'btn-primary')))))))->render();
예제 #4
0
파일: bootstrap.php 프로젝트: johnstyle/sjo
<?php

use sJo\Loader\Router;
use sJo\View\Helper;
use sJo\Libraries\I18n;
use sJo\Module\Admin\Back\Controller\Auth;
Auth::secure();
Helper\Menu::addRegistry('top', array(Helper\Link::create(array('elements' => I18n::__('My profil'), 'attributes' => array('href' => Router::linkBack('Admin/Profile'))))));
Helper\Menu::addRegistry('sidebar', array(Helper\Link::create(array('elements' => I18n::__('Manage admins'), 'attributes' => array('href' => Router::linkBack('Admin/Manager'))))));
예제 #5
0
파일: Auth.php 프로젝트: johnstyle/sjo
?>
" />
    <title><?php 
Lib\I18n::_e('Authentification');
?>
</title>
    <meta name="description" content="<?php 
Lib\I18n::_e('Authentification');
?>
">
    <?php 
if (Helper\Style::hasRegistry()) {
    ?>
        <?php 
    Helper\Style::applyRegistry();
    ?>
    <?php 
}
?>
    <style type="text/css">
        body{background:#333}
        form{background:#fff;width:300px;margin:150px auto 0;padding:0 20px 20px;border:5px solid #000;border-radius:10px;box-shadow:0 0 10px #000}
    </style>
</head>
<body>

<?php 
Helper\Form::create(array(Helper\Fieldset::create(array(Helper\Token::create(Router::getToken('signin')), Helper\Container::create(array('tagname' => 'h2', 'attributes' => array('class' => 'form-signin-heading'), 'elements' => Lib\I18n::__('Authentification'))), Helper\Alert::create(), Helper\Input::create(array('attributes' => array('name' => 'email', 'value' => Request::env('POST')->email->val(), 'placeholder' => Lib\I18n::__('Adresse email'), 'autofocus' => true))), Helper\Input::create(array('attributes' => array('type' => 'password', 'name' => 'password', 'placeholder' => Lib\I18n::__('Mot de passe')))), Helper\Button::create(array('attributes' => array('class' => 'btn-lg btn-block btn-primary', 'value' => Lib\I18n::__('Connexion'))))))))->render();
?>
</body>
</html>
예제 #6
0
파일: Table.php 프로젝트: johnstyle/sjo
 public function setElement($element)
 {
     $head = array();
     $instance = null;
     if (is_object($element['tbody']) && method_exists($element['tbody'], 'db')) {
         $instance = $element['tbody'];
         $element['tbody'] = $instance->db()->results();
     }
     if ($element['thead'] === null && is_array($element['tbody'])) {
         $thead = array();
         foreach ($element['tbody'] as $line) {
             foreach ($line as $name => $value) {
                 if (!in_array($name, $thead)) {
                     $thead[] = $name;
                 }
             }
         }
         $element['thead'] = $thead;
         unset($thead);
     }
     if (is_array($element['thead'])) {
         $arrayThead = array();
         foreach ($element['thead'] as $key => &$thead) {
             if (!is_array($thead)) {
                 if (!Validate::isInt($key)) {
                     $thead = array('name' => $key, 'label' => $thead);
                 } else {
                     $thead = array('name' => $thead);
                 }
             }
             $thead = Lib\Arr::extend(array('name' => $key, 'callback' => null, 'align' => null, 'label' => ucfirst(isset($thead['name']) ? $thead['name'] : $key)), $thead);
             $head[] = $thead['name'];
             $arrayThead[$thead['name']] = $thead;
         }
         $element['thead'] = $arrayThead;
     }
     if (is_array($element['tbody'])) {
         if ($element['actions']) {
             if (is_array($element['thead'])) {
                 $element['thead']['actions'] = array('name' => 'actions', 'label' => Lib\I18n::__('Actions'), 'align' => 'right');
             }
             foreach ($element['tbody'] as &$line) {
                 $line->actions = '';
                 foreach ($element['actions'] as $action => $options) {
                     if (!is_array($options)) {
                         $action = $options;
                         $options = array();
                     }
                     $options = Lib\Arr::extend(array('interface' => Router::$interface, 'controller' => null, 'href' => null, 'icon' => null), $options);
                     if (!$options['href']) {
                         $options['href'] = Router::link($options['interface'], $options['controller'], array('method' => $action, $instance->getPrimaryKey() => $line->{$instance->getPrimaryKey()}));
                     }
                     if (!$options['icon']) {
                         switch ($action) {
                             case 'delete':
                                 $options['icon'] = 'trash';
                                 break;
                             case 'update':
                                 $options['icon'] = 'edit';
                                 break;
                             case 'create':
                                 $options['icon'] = 'plus';
                                 break;
                             default:
                                 $options['icon'] = $action;
                                 break;
                         }
                     }
                     $line->actions .= self::createStatic('Link', array_merge(array('icon' => $options['icon']), $options))->html();
                 }
             }
         }
         if (count($head)) {
             foreach ($element['tbody'] as &$line) {
                 foreach ($line as $name => $value) {
                     if (!in_array($name, $head)) {
                         unset($line->{$name});
                         continue;
                     }
                     if (isset($element['thead'][$name]['callback'])) {
                         $line->{$name} = call_user_func($element['thead'][$name]['callback'], $line->{$name});
                     }
                 }
             }
         }
     }
     return $element;
 }
예제 #7
0
파일: Loader.php 프로젝트: johnstyle/sjo
 private function ErrorDocument($controller, $msg, $code = 0)
 {
     Router::ErrorDocument($controller);
     new Exception($msg, $code);
     $this->init();
     $this->instance->message = $msg;
 }
예제 #8
0
파일: Form.php 프로젝트: johnstyle/sjo
 /**
  *
  */
 public function redirectForm()
 {
     $next = 'back';
     if (Request::env('REQUEST')->__saveAndStay->exists()) {
         $next = 'stay';
     } elseif (Request::env('REQUEST')->__saveAndCreate->exists()) {
         $next = 'create';
     }
     switch ($next) {
         default:
             Http::redirect(Router::link(null, Router::$controller));
             break;
         case 'stay':
             Http::redirect(Router::link(null, null, array($this->getPrimaryKey() => $this->getPrimaryValue())));
             break;
         case 'create':
             Http::redirect(Router::link());
             break;
     }
 }
예제 #9
0
파일: Manager.php 프로젝트: johnstyle/sjo
 public function index()
 {
     Helper\Menu::addRegistry('main', array(Helper\Link::create(array('elements' => I18n::__('Create admin'), 'attributes' => array('class' => 'bg-success plus', 'href' => Router::linkBack('Admin/Manager::edit'))))));
 }
예제 #10
0
파일: Profile.php 프로젝트: johnstyle/sjo
<?php

use sJo\Loader\Router;
use sJo\Module\Admin\Model\Admin;
use sJo\View\Helper;
use sJo\Libraries as Lib;
$this->header();
Helper\Panel::create(array('col' => 6, 'title' => 'Edition', 'class' => 'panel-primary', 'elements' => Helper\Fieldset::create(array(Helper\Token::create(Router::getToken('update')), Helper\Input::create(array('type' => 'email', 'name' => 'email', 'label' => Lib\I18n::__('Email address'), 'placeholder' => Lib\I18n::__('Enter email'), 'value' => Admin::logged()->email)), Helper\Input::create(array('type' => 'text', 'name' => 'name', 'label' => Lib\I18n::__('Name'), 'placeholder' => Lib\I18n::__('Enter name'), 'value' => Admin::logged()->name)))), 'footer' => Helper\Button::create(array('class' => 'pull-right btn-primary', 'value' => Lib\I18n::__('Save')))))->render();
$this->footer();