コード例 #1
0
 /**
  * {@inheritdoc}
  *
  * @param string $module
  * @param string $controller
  * @param array $params
  * @return void
  */
 protected function preDispatch($module, $controller, $params = array())
 {
     // example of setup default title
     Layout::title("Bluz Skeleton");
     // apply "remember me" function
     if (!$this->user() && !empty($_COOKIE['rToken']) && !empty($_COOKIE['rId'])) {
         // try to login
         try {
             Auth\Table::getInstance()->authenticateCookie($_COOKIE['rId'], $_COOKIE['rToken']);
         } catch (AuthException $e) {
             $this->getResponse()->setCookie('rId', '', 1, '/');
             $this->getResponse()->setCookie('rToken', '', 1, '/');
         }
     }
     parent::preDispatch($module, $controller, $params);
 }
コード例 #2
0
ファイル: index.php プロジェクト: bluzphp/framework
            break;
        case 501:
            $title = __("Not Implemented");
            $description = __("The server does not understand or does not support the HTTP method");
            break;
        case 503:
            $title = __("Service Unavailable");
            $description = __("The server is currently unable to handle the request due to a temporary overloading");
            Response::setHeader('Retry-After', '600');
            break;
        default:
            $title = __("Internal Server Error");
            $description = __("An unexpected error occurred with your request. Please try again later");
            break;
    }
    // check CLI or HTTP request
    if (Request::isHttp()) {
        // simple AJAX call, accept JSON
        if (Request::getAccept(['application/json'])) {
            $this->useJson();
            Messages::addError($description);
            return null;
        }
        // dialog AJAX call, accept HTML
        if (!Request::isXmlHttpRequest()) {
            $this->useLayout('small.phtml');
        }
    }
    Layout::title($title);
    return ['error' => $title, 'description' => $description];
};
コード例 #3
0
ファイル: routers.php プロジェクト: dezvell/skeleton
/**
 * Build list of custom routers
 *
 * @author   Anton Shevchuk
 * @created  12.06.12 12:27
 */
namespace Application;

use Bluz\Proxy\Layout;
return function () use($view) {
    /**
     * @var Bootstrap $this
     * @var \Bluz\View\View $view
     */
    Layout::title('Routers Map');
    Layout::setTemplate('dashboard.phtml');
    Layout::breadCrumbs([$view->ahref('Dashboard', ['dashboard', 'index']), $view->ahref('System', ['system', 'index']), __('Routers Map')]);
    $routers = array();
    foreach (new \GlobIterator(PATH_APPLICATION . '/modules/*/controllers/*.php') as $file) {
        $module = pathinfo(dirname(dirname($file->getPathname())), PATHINFO_FILENAME);
        $controller = pathinfo($file->getPathname(), PATHINFO_FILENAME);
        $reflection = $this->reflection($file->getPathname());
        if ($route = $reflection->getRoute()) {
            if (!isset($routers[$module])) {
                $routers[$module] = array();
            }
            $routers[$module][$controller] = ['route' => $route, 'params' => $reflection->getParams()];
        }
    }
    $view->routers = $routers;
コード例 #4
0
ファイル: bootstrap.php プロジェクト: dezvell/skeleton
<?php

/**
 * Bootstrap of index module
 *
 * @author   Anton Shevchuk
 * @created  07.07.11 18:03
 * @return closure
 */
namespace Application;

use Bluz\Proxy\Layout;
return function ($a) {
    Layout::title("Test", Layout::POS_APPEND);
    return $a * 2;
};
コード例 #5
0
ファイル: cache-data.php プロジェクト: dezvell/skeleton
 *
 * @author   dark
 * @created  08.07.11 13:23
 */
namespace Application;

use Bluz\Proxy\Cache;
use Bluz\Proxy\Layout;
return function ($id = null) use($bootstrap, $view) {
    /**
     * @var Bootstrap $this
     * @var \Bluz\View\View $view
     */
    Layout::breadCrumbs([$view->ahref('Test', ['test', 'index']), 'Cache Data']);
    /* @var Bootstrap $this */
    Layout::title('Check cache');
    // try to load profile of current user
    if (!$id && $this->user()) {
        $id = $this->user()->id;
    }
    if (!$id) {
        throw new \Exception('User not found', 404);
    }
    /**
     * @var Users\Row $userRow
     */
    if (!($userRow = Cache::get('user:'******'user:' . $id, $userRow, 30);
    }
    if (!$userRow) {
コード例 #6
0
ファイル: index.php プロジェクト: bluzphp/skeleton
<?php

/**
 * @author   Anton Shevchuk
 * @created  21.08.12 12:39
 */
namespace Application;

use Bluz\Proxy\Layout;
/**
 * @privilege Info
 *
 * @return \closure
 */
return function () {
    Layout::title('System Module');
    Layout::setTemplate('dashboard.phtml');
    Layout::breadCrumbs([Layout::ahref('Dashboard', ['dashboard', 'index']), __('System')]);
};
コード例 #7
0
ファイル: session.php プロジェクト: Kit-kat1/bluz
<?php

/**
 * Default module/controllers
 *
 * @author   Anton Shevchuk
 * @created  06.07.11 18:39
 * @return closure
 */
namespace Application;

use Bluz\Proxy\Layout;
use Bluz\Proxy\Session;
return function () use($view) {
    /**
     * @var Bootstrap $this
     * @var \Bluz\View\View $view
     */
    Layout::breadCrumbs([$view->ahref('Test', ['test', 'index']), 'Session']);
    Layout::title("Test/Index");
    Session::set('test', Session::get('test') ?: 'Session time: ' . date("H:i:s"));
    $view->title = Layout::title();
    $view->session = Session::get('test');
    //    if ($identity = $app->user()) {
    //        var_dump($acl->isAllowed('index/index', $identity['sid']));
    //        var_dump($acl->isAllowed('index/test', $identity['sid']));
    //        var_dump($acl->isAllowed('index/error', $identity['sid']));
    //    } else {
    //        Auth::authenticate('admin', '123456');
    //    }
};
コード例 #8
0
ファイル: index.php プロジェクト: dezvell/skeleton
 */
namespace Application;

use Bluz\Application\Exception\NotFoundException;
use Bluz\Proxy\HttpCacheControl;
use Bluz\Proxy\Layout;
use Bluz\View\View;
return function ($alias) use($view) {
    /**
     * @var Bootstrap $this
     * @var View $view
     * @var Pages\Row $page
     */
    $page = Pages\Table::getInstance()->getByAlias($alias);
    if (!$page) {
        // throw NOT FOUND exception
        // all logic of error scenario you can found in default error controller
        // see /application/modules/error/controllers/index.php
        throw new NotFoundException();
    } else {
        // setup HTML layout data
        Layout::title(esc($page->title), View::POS_PREPEND);
        Layout::meta('keywords', esc($page->keywords));
        Layout::meta('description', esc($page->description));
        // setup HTTP cache
        HttpCacheControl::setPublic();
        HttpCacheControl::setLastModified($page->updated);
        // assign page to view
        $view->page = $page;
    }
};
コード例 #9
0
ファイル: index.php プロジェクト: dezvell/skeleton
<?php

/**
 * Test of test of test
 *
 * @author   Anton Shevchuk
 * @created  21.08.12 12:39
 */
namespace Application;

use Bluz\Proxy\Layout;
return function () {
    /**
     * @var Bootstrap $this
     */
    Layout::title('Test Module');
    Layout::title('Append', Layout::POS_APPEND);
    Layout::title('Prepend', Layout::POS_PREPEND);
    Layout::breadCrumbs(['Test']);
};
コード例 #10
0
ファイル: bookmarks.php プロジェクト: bluzphp/skeleton
<?php

/**
 * Debug bookmarklet
 *
 * @author   Anton Shevchuk
 * @created  22.08.12 17:14
 */
namespace Application;

use Bluz\Controller\Controller;
use Bluz\Proxy\Layout;
/**
 * @privilege Info
 *
 * @return array
 */
return function () {
    /**
     * @var Controller $this
     */
    Layout::title('Bookmarklets');
    Layout::setTemplate('dashboard.phtml');
    Layout::breadCrumbs([Layout::ahref('Dashboard', ['dashboard', 'index']), Layout::ahref('System', ['system', 'index']), __('Bookmarklets')]);
    $key = getenv('BLUZ_DEBUG_KEY') ?: 'BLUZ_DEBUG';
    return ['key' => $key];
};
コード例 #11
0
ファイル: info.php プロジェクト: dezvell/skeleton
<?php

/**
 * PHP Info Wrapper
 *
 * @author   Anton Shevchuk
 * @created  22.08.12 17:14
 */
namespace Application;

use Bluz\Proxy\Layout;
return function () use($view) {
    /**
     * @var Bootstrap $this
     * @var \Bluz\View\View $view
     */
    Layout::title('PHP Info');
    Layout::setTemplate('dashboard.phtml');
    Layout::breadCrumbs([$view->ahref('Dashboard', ['dashboard', 'index']), $view->ahref('System', ['system', 'index']), __('PHP Info')]);
};
コード例 #12
0
ファイル: profile.php プロジェクト: dezvell/skeleton
/**
 * View User Profile
 *
 * @author   Anton Shevchuk
 * @created  01.09.11 13:15
 */
namespace Application;

use Application\Users;
use Bluz\Proxy\Layout;
return function ($id = null) use($view) {
    /**
     * @var Bootstrap $this
     * @var \Bluz\View\View $view
     */
    Layout::title('User Profile');
    // try to load profile of current user
    if (!$id && $this->user()) {
        $id = $this->user()->id;
    }
    /**
     * @var Users\Row $user
     */
    $user = Users\Table::findRow($id);
    if (!$user) {
        throw new Exception('User not found', 404);
    } else {
        $view->user = $user;
    }
};