Пример #1
0
 private function __construct($mark)
 {
     $this->warrantytime = 60 * 60 * 24 * 60;
     //60 дней
     $mark = preg_replace("/:(.+)::\\./U", ":\$1::\$1.", $mark);
     $r = explode($this->sym, $mark);
     $this->mark = array_shift($r);
     if ($this->mark != '') {
         $src = Path::theme('~.marks/' . $this->prefix . $this->mark . '.json');
         if ($src) {
             $data = file_get_contents($src);
             $data = Load::json_decode($data);
         } else {
             $data = false;
         }
         //$data=infra_mem_get($this->prefix.$this->mark);
         if (!$data || !is_array($data['data'])) {
             $this->mark = '';
         } else {
             if (!$data['time']) {
                 $data['time'] = time();
             }
             $this->isold = true;
             $this->isoutdate = time() > $data['time'] + $this->warrantytime;
             $this->old = $data['data'];
         }
     }
     $this->data = $this->old;
     $add = implode($this->sym, $r);
     if ($add !== '') {
         $r = explode($this->sym, $add);
         $l = sizeof($r);
         if ($this->sym == $this->symeq) {
             if ($l % 2) {
                 $l++;
                 $r[] = '';
             }
             for ($i = 0; $i < $l; $i = $i + 2) {
                 if (!$r[$i]) {
                     continue;
                 }
                 Sequence::set($this->data, Sequence::right($r[$i]), $r[$i + 1]);
             }
         } else {
             for ($i = 0; $i < $l; $i = $i + 1) {
                 if (!$r[$i]) {
                     continue;
                 }
                 $rr = explode($this->symeq, $r[$i], 2);
                 if (!$rr[0]) {
                     continue;
                 }
                 Sequence::set($this->data, Sequence::right($rr[0]), $rr[1]);
             }
         }
     }
 }
Пример #2
0
});
$fn3 = function () {
    return View::getPath();
};
Sequence::set(Template::$scope, array('infra', 'view', 'getPath'), $fn3);
$fn4 = function () {
    return View::getHost();
};
Sequence::set(Template::$scope, array('infra', 'view', 'getHost'), $fn4);
$fn5 = function ($s) {
    return Sequence::short($s);
};
Sequence::set(Template::$scope, array('infra', 'seq', 'short'), $fn5);
$fn6 = function ($s) {
    return Sequence::right($s);
};
Sequence::set(Template::$scope, array('infra', 'seq', 'right'), $fn6);
$fn7 = function () {
    return View::getRoot();
};
Sequence::set(Template::$scope, array('infra', 'view', 'getRoot'), $fn7);
$fn8 = function ($src) {
    return Load::srcInfo($src);
};
Sequence::set(Template::$scope, array('infra', 'srcinfo'), $fn8);
$host = $_SERVER['HTTP_HOST'];
$p = explode('?', $_SERVER['REQUEST_URI']);
$pathname = $p[0];
Sequence::set(Template::$scope, array('location', 'host'), $host);
Sequence::set(Template::$scope, array('location', 'pathname'), $pathname);
Пример #3
0
    return Tpl::jsoncheck($layer);
}, 'jsoncheck:is');
Run::runAddKeys('childs');
Run::runAddList('child');
Event::handler('Layer.oninit', function () {
    $root = Crumb::getInstance();
    if (!$root->is) {
        throw new \Exception('Crumb нужно инициализировать до запуска контроллера');
    }
    Sequence::set(Template::$scope, Sequence::right('infra.Crumb.query'), $root->query);
    Sequence::set(Template::$scope, Sequence::right('infra.Crumb.params'), Crumb::$params);
    Sequence::set(Template::$scope, Sequence::right('infra.Crumb.get'), Crumb::$get);
    $cl = function ($mix = null) {
        return ext\Crumb::getInstance($mix);
    };
    Sequence::set(Template::$scope, Sequence::right('infra.Crumb.getInstance'), $cl);
    External::add('child', 'layers');
    External::add('crumb', function (&$now, &$ext, &$layer, &$external, $i) {
        //проверка external в onchange
        Crumb::set($layer, 'crumb', $ext);
        return $layer[$i];
    });
}, 'crumb');
Event::handler('Layer.oninit', function (&$layer) {
    //это из-за child// всё что после child начинает плыть. по этому надо crumb каждый раз определять, брать от родителя.
    if (!isset($layer['dyn'])) {
        //Делается только один раз
        Crumb::set($layer, 'crumb', $layer['crumb']);
    }
    if (empty($layer['parent'])) {
        return;
Пример #4
0
            $n['name'] = Sequence::right($n['name']);
            $r = Each::exec($list, function &($item) use(&$n, &$ans) {
                //Устанавливаемое значение ищим в новости
                $r = null;
                //найдено совпадение новости с устанавливаемым значением.. новость удаляем
                $a = Sequence::contain($item['name'], $n['name']);
                if ($a || $a == array()) {
                    $r = true;
                    return $r;
                    //news Длиннее... и часть новости изменена в устанавливаемом значение
                }
                $ans['a'] = $a;
                //Новость ищим в устанавливаемом значение
                $right = Sequence::contain($n['name'], $item['name']);
                if ($right) {
                    $n['value'] = Sequence::set($n['value'], $right, $item['value']);
                    //Новость осталась но она включает устанавливаемые данные
                }
                return $r;
            });
            if ($r) {
                $del = new Fix('del');
                return $del;
            }
            $r = null;
            return $r;
        });
    }
}
if ($list) {
    if (!$session_id) {
Пример #5
0
 /**
  * Записывает в сессию session_id или email имя и значение.
  *
  * @param string|int	  $email Может быть $session_id
  * @param string|string[] $short Может быть $right путь до значения в объекте
  * @param mixed		   $value Значение для записи. Любое значение записывается даже null, которое по факту приводит к удалению значения
  *
  * @return void|string Строка-ошибка
  */
 public static function user_set($email, $short = array(), $value = null)
 {
     $user = Session::getUser($email);
     if (!$user) {
         return 'Email Not Found';
     }
     $obj =& Session::user_init($email);
     $right = Sequence::right($short);
     Sequence::set($obj, $right, $value);
     $list = array();
     $list['name'] = $right;
     $list['value'] = $value;
     $list['time'] = time();
     Session::writeNews($list, $user['session_id']);
 }
Пример #6
0
namespace infrajs\crumb;

use infrajs\controller\Controller;
use infrajs\each\Each;
use infrajs\controller\Run;
use infrajs\controller\Layer;
use infrajs\path\Path;
use infrajs\event\Event;
use infrajs\sequence\Sequence;
use infrajs\template\Template;
use infrajs\session\Session;
use infrajs\controller\External;
Path::reqif('-controller/infra.php');
$cl = function ($name, $def = null) {
    return Session::get($name, $def);
};
Sequence::set(Template::$scope, Sequence::right('infra.session.get'), $cl);
$cl = function () {
    return Session::getLink();
};
Sequence::set(Template::$scope, Sequence::right('infra.session.getLink'), $cl);
$cl = function () {
    return Session::getTime();
};
Sequence::set(Template::$scope, Sequence::right('infra.session.getTime'), $cl);
$cl = function () {
    return Session::getId();
};
Sequence::set(Template::$scope, Sequence::right('infra.session.getId'), $cl);