/** * Поиск слоя по значению свойства **/ public static function &find($name, $value) { $right = Sequence::right($name); return Run::exec(Controller::$layers, function &(&$layer) use($right, $value) { if (Sequence::get($layer, $right) == $value) { return $layer; } $r = null; return $r; }); }
//$ans['params']=$params; $ans['search'] = $search; //Позиций найдено $ans['count'] = $count; //Позиций в группе $ans['template'] = array(); foreach ($params as $param) { $block = array(); if ($param['more']) { $right = array('more', $param['mdid']); $add = 'more.'; } else { $right = array($param['mdid']); $add = ''; } $mymd = Sequence::get($md, $right); if (!$mymd) { $mymd = array(); } $paramid = Sequence::short(array(Catalog::urlencode($param['mdid']))); $block['checked'] = !!$mymd['yes']; if ($block['checked']) { $block['add'] = $add . $paramid . '.yes='; } else { $block['add'] = $add . $paramid . '.yes=1'; } $block['title'] = $param['title']; $block['type'] = $param['option']['type']; $block['filter'] = $param['filter']; $block['search'] = $param['search']; $block['count'] = $param['count'];
public static function getVar(&$conf, $var = array()) { //dataroot это прощитанный путь до переменной в котором нет замен //$var содержит вставки по типу ['asdf',['asdf','asdf'],'asdf'] то есть это не одномерный массив. asdf[asdf.asdf].asdf //var одна переменная if (is_null($var)) { //if($checklastroot)$conf['lastroot']=false;//Афигенная ошибка. получена переменная и далее идём к шаблону переменной для которого нет, узнав об этом lastroot не сбивается и шаблон дальше загружается с переменной в lastroot {$indexOf(:asdf,:s)}{data:descr}{descr:}{} $value = ''; $root = false; } else { $right = static::getPath($conf, $var); $p = array_merge($conf['dataroot'], $right); $p = Sequence::right($p); if (@(string) $p[sizeof($p) - 1] == '~key') { $value = $conf['dataroot'][sizeof($conf['dataroot']) - 1]; if (!@static::$scope['kinsert']) { static::$scope['kinsert'] = array(); } $n = sizeof(static::$scope['kinsert']); static::$scope['kinsert'][$n] = $value; $root = array('kinsert', (string) $n); } else { $value = Sequence::get($conf['data'], $p); //Относительный путь от данных if (!is_null($value)) { $root = $p; } if (is_null($value) && sizeof($p)) { $value = Sequence::get(static::$scope, $p); //Относительный путь if (!is_null($value)) { $root = $p; } } if (is_null($value)) { $value = Sequence::get($conf['data'], $right); //Абсолютный путь if (!is_null($value)) { $root = $right; } } if (is_null($value) && sizeof($right)) { $value = Sequence::get(static::$scope, $right); //Абсолютный путь if (!is_null($value)) { $root = $right; } } if (is_object($value) && method_exists($value, 'toString')) { $value = $value->toString(); } if (is_null($value)) { $root = $right; } //Афигенная ошибка. получена переменная и далее идём к шаблону переменной для которого нет, узнав об этом lastroot не сбивается и шаблон дальше загружается с переменной в lastroot {$indexOf(:asdf,:s)}{data:descr}{descr:}{} } } return array('root' => $root, 'value' => $value); }
public static function addFiles($root, &$pos, $dir = false) { $props = array('producer', 'article'); if (!isset($pos['images'])) { $pos['images'] = array(); } if (!isset($pos['texts'])) { $pos['texts'] = array(); } if (!isset($pos['files'])) { $pos['files'] = array(); } if (!$dir) { $dir = array(); $pth = Path::resolve($root); if (Each::forr($props, function &($name) use(&$dir, &$pos) { $rname = Sequence::right($name); $val = Sequence::get($pos, $rname); if (!$val) { return true; } $dir[] = $val; $r = null; return $r; })) { return; } if ($dir) { $dir = implode('/', $dir) . '/'; $dir = $pth . $dir; } else { $dir = $pth; } } else { $dir = $root . $dir; } $dir = Path::theme($dir); if (!$dir) { return false; } if (is_dir($dir)) { $paths = glob($dir . '*'); } elseif (is_file($dir)) { $paths = array($dir); $p = Load::srcInfo($dir); $dir = $p['folder']; } Each::forr($paths, function &($p) use(&$pos, $dir) { $d = explode('/', $p); $name = array_pop($d); $n = mb_strtolower($name); $fd = Load::nameInfo($n); $ext = $fd['ext']; //if(!$ext)return; if (!is_file($dir . $name)) { return; } //$name=preg_replace('/\.\w{0,4}$/','',$name); /*$p=pathinfo($p); $name=$p['basename']; $ext=strtolower($p['extension']);*/ if ($name[0] == '.') { return; } $dir = Path::pretty($dir); $name = Path::toutf($dir . $name); $im = array('png', 'gif', 'jpg'); $te = array('html', 'tpl', 'mht', 'docx'); if (in_array($ext, $im)) { $pos['images'][] = $name; } else { if (in_array($ext, $te)) { $pos['texts'][] = $name; } else { if ($ext != 'db') { $pos['files'][] = $name; } } } $r = null; return $r; }); $pos['images'] = array_unique($pos['images']); $pos['texts'] = array_unique($pos['texts']); $pos['files'] = array_unique($pos['files']); }
public static function user_get($email, $short = array(), $def = null) { $obj =& Session::user_init($email); $right = Sequence::right($short); $value = Sequence::get($obj, $right); if (is_null($value)) { $value = $def; } return $value; }
public static function initMark(&$ans = array()) { //Нельзя добавлять в скрипте к метке новые значения. так как метка приходит во многие скрипты и везде должен получится один результат и все должны получить одинаковую новую метку содержающую изменения $mark = Path::toutf(Sequence::get($_GET, array('m'))); $mark = Mark::getInstance($mark); $md = $mark->getData(); $defmd = array_merge(Catalog::$md, Catalog::$conf['md']); $admit = array_keys($defmd); $md = array_intersect_key($md, array_flip($admit)); Catalog::markData($md); $ans['m'] = $mark->setData($md); $md = array_merge($defmd, $md); $ans['md'] = $md; return $md; }