Example #1
0
 public static function init()
 {
     global $infra, $infrajs;
     Event::handler('Infrajs.oninit', function () {
         //Обработка envs, envtochild, myenvtochild, envframe
         External::add('myenv', 'config');
         //Обрабатывается также как config
         //external::add('env', '');//Никак не обрабатывается.. будет установлено только если нечего небыло
         External::add('envs', 'childs');
         //Объединяется так же как childs
         Run::runAddKeys('envs');
         //Теперь бегаем и по envs свойству
     });
 }
Example #2
0
<?php

namespace infrajs\controller;

use infrajs\path\Path;
use infrajs\event\Event;
use infrajs\template\Template;
/**
 * div, divs, divtpl
 *
 **/
Path::req('*controller/infra.php');
Event::handler('oninit', function () {
    Run::runAddKeys('divs');
    External::add('divs', function (&$now, $ext) {
        //Если уже есть пропускаем
        if (!$now) {
            $now = array();
        }
        foreach ($ext as $i => $v) {
            if (isset($now[$i])) {
                continue;
            }
            $now[$i] = array();
            Each::fora($ext[$i], function (&$l) use(&$now, $i) {
                array_push($now[$i], array('external' => $l));
            });
        }
        return $now;
    });
}, 'div:layer');
Example #3
0
    if (is_string(@$layer['tpl']) && @$layer['tplcheck']) {
        //Мы не можем делать проверку пока другой плагин не подменит tpl
        $res = Load::loadTEXT($layer['tpl']);
        if (!$res) {
            return false;
        }
    }
}, 'tplcheck:is');
Event::handler('Layer.isshow', function (&$layer) {
    //tpl depricated
    if (Layer::pop($layer, 'onlyclient')) {
        return;
    }
    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) {
Example #4
0
<?php

namespace infrajs\controller;

use infrajs\path\Path;
use infrajs\event\Event;
use infrajs\each\Each;
Event::handler('Infrajs.oninit', function () {
    Run::runAddKeys('subs');
    //if (!class_exists('External')) return;
    //External::add('subs', 'divs');
}, 'subs:external,div');
Event::handler('layer.oncheck', function (&$layer) {
    if (@(!$layer['parent'])) {
        return;
    }
    if (@$layer['parent']['subs']) {
        //forx бежим по свойствам объекта, как по массивам. Массивы могут быть вложенные
        //var_dump($layer['parent']['subs']);
        $key = Each::forx($layer['parent']['subs'], function (&$l, $key) use(&$layer) {
            //Такую пробежку у родителя сразу для всех детей делать не нельзя, так как external у детей ещё не сделан.
            if (Each::isEqual($layer, $l)) {
                return $key;
            }
            //Ага, текущей слой описан у родителя в subs. Любой return останавливает цикл и возвращает иначе key был бы undefined.
        });
        if ($key) {
            //Так так теперь предопределяем свойства
            //div не круче external.(но в external div не указывается) в  tpl и tplroot не круче
            $layer['div'] = $key;
            $layer['sub'] = true;