Exemplo n.º 1
0
<?php

$policy = function ($rq, $res) {
    $serial = \System\Resource::get_serial();
    try {
        $static_domain = \System\Settings::get('resources', 'domain');
    } catch (\System\Error\Config $e) {
        $static_domain = null;
    }
    try {
        $locales_url = ($static_domain ? '//' . $static_domain : '') . $res->url("system_resource", array('static', 'locale', '{lang}.' . $serial . '.json'));
    } catch (\System\Error\NotFound $e) {
        $locales_url = '';
    }
    try {
        $autoload = \System\Settings::get('locales', 'autoload');
    } catch (\System\Error\Config $e) {
        $autoload = false;
    }
    try {
        $debug = \System\Settings::get('dev', 'debug');
    } catch (\System\Error\Config $e) {
        $debug = array('frontend' => true, 'backend' => true);
    }
    $now = new \DateTime();
    $tz = new \DateTimeZone(\System\Settings::get('locales', 'timezone'));
    $now->setTimeZone($tz);
    $cont = array("locales" => array("url" => $locales_url, "lang" => $res->locales->get_lang(), "autoload" => $autoload, "tz" => -$tz->getOffset($now) / 60, "now" => $now->format('c')), "comm" => array("blank" => '/share/html/blank.html'), "debug" => $debug, "proxy" => array('url' => '/proxy/head/?url={url}'));
    try {
        $frontend = \System\Settings::get('frontend');
    } catch (\System\Error $e) {
Exemplo n.º 2
0
<?php

$policy = function ($rq, $res) {
    $past_route = function ($rq, $name) {
        return \System\Router::get_route_str($rq->host, $name);
    };
    $url_pack = $past_route($rq, 'system_resource');
    $url_pack = str_replace(array('{res_src}', '{res_type}', '{res_path}'), array('media', 'schema', '{name}.' . \System\Resource::get_serial()), $url_pack);
    $urls = array('pack' => $url_pack, 'schema' => $past_route($rq, 'api_model_schema'), 'browse' => $past_route($rq, 'api_model_browse'), 'create' => $past_route($rq, 'api_model_create'), 'edit' => $past_route($rq, 'api_model_object_edit'), 'drop' => $past_route($rq, 'api_model_object_drop'));
    $rq->fconfig = array_merge_recursive($rq->fconfig, array('models' => array('url' => $urls)));
    return true;
};