예제 #1
0
 public function run()
 {
     /** Module that sends resource content
      * @package modules
      */
     $this->req('res_src');
     $this->req('res_type');
     $this->req('res_path');
     $resource = \System\Resource::sort_out(array('request' => $this->request, 'response' => $this->response, 'path' => $this->res_path, 'src' => $this->res_src, 'type' => $this->res_type));
     $resource->serve();
 }
예제 #2
0
파일: json.php 프로젝트: just-paja/fudjan
 public function set_headers()
 {
     $this->mime = 'application/json';
     return parent::set_headers();
 }
예제 #3
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) {
예제 #4
0
 /** Get content from location
  * @param string $place
  * @return string
  */
 public function get_content_from($place)
 {
     if (is_array($this->content[$place]) && array_key_exists($place, self::$resource_filter)) {
         $this->content[$place] = \System\Resource::filter_output_content(self::$resource_filter[$place], $this->content[$place]);
     }
     return $this->content[$place];
 }
예제 #5
0
파일: thumb.php 프로젝트: just-paja/fudjan
 public function url()
 {
     return \System\Resource::get_url('media', 'thumb', $this->hash() . '.' . $this->image->suffix());
 }
예제 #6
0
 public function run()
 {
     $this->flow->redirect(\System\Resource::get_url('media', 'schema', $this->name));
 }
예제 #7
0
파일: file.php 프로젝트: just-paja/fudjan
 public function to_object()
 {
     if (!$this->mime) {
         $this->read_meta();
     }
     $path = str_replace(\System\File::DIR, '', $this->get_path_relative());
     $src = 'media';
     $cname = $this::RESOURCE_CNAME;
     $stat = $cname::DIR_STATIC;
     try {
         $cache = \System\Settings::get('cache', 'resources');
     } catch (\System\Error $e) {
         $cache = false;
     }
     if ($cache) {
         $dirs = array($stat);
     } else {
         $dirs = \System\Composer::list_dirs($stat);
         array_unshift($dirs, $stat);
     }
     foreach ($dirs as $dir) {
         if (strpos($path, $dir) === 0 || strpos($path, $dir = substr($dir, 1)) === 0) {
             $path = substr($path, strlen($dir));
             $src = 'static';
             break;
         }
     }
     $url = \System\Resource::get_url($src, self::RESOURCE_TYPE, preg_replace("/^\\//", '', $path));
     return array("url" => $url, "path" => $path, "name" => $this->name, "mime" => $this->mime, "size" => $this->size, "method" => $this->method ? $this->method : 'save');
 }
예제 #8
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;
};