Example #1
0
 public static function init()
 {
     External::add('configtpl', function &(&$now, &$ext, &$layer, &$external, $i) {
         //if(!isset($layer['configtpl']))return $now;
         //if(isset($layer['config']))return $now;
         if (!$now) {
             return $ext;
         }
         return $now;
     });
 }
Example #2
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 #3
0
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');
Event::handler('layer.oncheck', function (&$layer) {
    //В onchange слоя может не быть див// Это нужно чтобы в external мог быть определён div перед тем как наследовать div от родителя
    if (@(!$layer['div']) && @$layer['parent']) {
        $layer['div'] = $layer['parent']['div'];
    }
}, 'div');
Event::handler('layer.oncheck', function (&$layer) {
Example #4
0
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;
    }
    Crumb::set($layer, 'crumb', $layer['dyn']['crumb']);
    //Возможно у родителей обновился crumb из-за child у детей тоже должен обновиться хотя они не в child
}, 'crumb');
Example #5
0
External::$props = array('div' => function (&$now, &$ext) {
    return $ext;
}, 'layers' => function (&$now, &$ext) {
    if (!$now) {
        $now = array();
    } elseif (Each::isAssoc($now) !== false) {
        $now = array($now);
    }
    Each::fora($ext, function &($j) use(&$now) {
        //array_unshift($now,array('external'=>&$ext));
        array_push($now, array('external' => &$j));
        $r = null;
        return $r;
    });
    return $now;
}, 'external' => function (&$now, &$ext) {
    //Используется в global.js, css
    if (!$now) {
        $now = array();
    } elseif (Each::isAssoc($now) !== false) {
        $now = array(&$now);
    }
    array_push($now, $ext);
    return $now;
}, 'config' => function (&$now, &$ext, &$layer) {
    //object|string any
    if (Each::isAssoc($ext) === true) {
        if (!$now) {
            $now = array();
        }
        foreach ($ext as $j => $v) {
            if (!is_null(@$now[$j])) {
                continue;
            }
            $now[$j] =& $ext[$j];
        }
    } else {
        if (is_null($now)) {
            $now =& $ext;
        }
    }
    return $now;
});
Example #6
0
<?php

namespace infrajs\controller;

use infrajs\router\Router;
use infrajs\load\Load;
if (!is_file('vendor/autoload.php')) {
    chdir('../../../../');
    require_once 'vendor/autoload.php';
    Router::init();
}
$data = Controller::$conf['index'];
Run::exec($data, function &(&$layer) {
    while (@$layer['external'] && !Layer::pop($layer, 'onlyclient')) {
        $ext =& $layer['external'];
        External::checkExt($layer, $ext);
    }
    $r = null;
    return $r;
});
$data = Load::json_encode($data);
?>
infrajs.checkAdd(<?php 
echo $data;
?>
);
Event.handler('Crumb.onchange', function () {
	infrajs.check();
}, 'infrajs');<?php