Esempio n. 1
0
 public static function t($string, array $replace_pairs = array())
 {
     isset(static::$current) or static::set(Request::get()->locale()) or static::set(self::REFERENCE);
     if (static::$current !== static::REFERENCE) {
         foreach (App::all('Sedra\\Locale\\TranslationProvider') as &$translation_provider) {
             $translation = $translation_provider->get_translation($string, static::$current);
             if ($translation) {
                 $string = $translation;
                 break;
             }
         }
         # else : Not found, not translated
     }
     # Transform arguments before inserting them.
     foreach ($replace_pairs as $key => &$value) {
         switch ($key[0]) {
             case '@':
             default:
                 # XXX $replace_pairs[$key] = htmlentities($value, ENT_QUOTES, 'UTF-8');
                 $value = htmlentities($value, ENT_QUOTES, 'UTF-8');
                 break;
             case '!':
                 # Do not escape the string
         }
     }
     return strtr($string, $replace_pairs);
 }
Esempio n. 2
0
 public static function static_data($key)
 {
     if (array_key_exists($key, self::$static_data)) {
         return self::$static_data[$key];
     }
     foreach (App::all('Sedra\\View\\DataProvider') as &$data_provider) {
         $data_provider->get_view_data($key, self::$static_data, Request::get());
     }
     if (!array_key_exists($key, self::$static_data)) {
         self::$static_data[$key] = null;
     }
     return self::$static_data[$key];
 }
Esempio n. 3
0
 function __construct()
 {
     $method = $_SERVER['REQUEST_METHOD'];
     $query = @$_SERVER['PATH_INFO'] ?: @$_GET['q'];
     parent::__construct($method, $query);
     $this->get =& $_GET;
     $this->post =& $_POST;
     $this->files =& $_FILES;
     $this->is_ajax = @$_SERVER['HTTP_X_REQUESTED_WITH'] || @$_REQUEST['__ajax'];
     if ($method === 'GET') {
         $this->data =& $this->get;
     } else {
         $this->data =& $this->post;
     }
 }