Ejemplo n.º 1
0
 public static function addFiles(&$pos, $dir = false)
 {
     $conf = infra_config();
     $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 = $conf['catalog']['dir'];
         if (infra_forr($props, function &($name) use(&$dir, &$pos) {
             $rname = infra_seq_right($name);
             $val = infra_seq_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;
         }
     }
     $dir = infra_theme($dir);
     if (!$dir) {
         return false;
     }
     if (is_dir($dir)) {
         $paths = glob($dir . '*');
     } elseif (is_file($dir)) {
         $paths = array($dir);
         $p = infra_srcinfo($dir);
         $dir = $p['folder'];
     }
     infra_forr($paths, function &($p) use(&$pos, $dir) {
         $d = explode('/', $p);
         $name = array_pop($d);
         $n = infra_strtolower($name);
         $fd = infra_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']);*/
         $dirs = infra_dirs();
         $dir = preg_replace('/^' . str_replace('/', '\\/', $dirs['data']) . '/', '*', $dir);
         $name = infra_toutf($dir . $name);
         if ($name[0] == '.') {
             return;
         }
         $im = array('png', 'gif', 'jpg');
         $te = array('html', 'tpl', 'mht', 'docx');
         if (infra_forr($im, function ($e) use($ext) {
             if ($ext == $e) {
                 return true;
             }
         })) {
             $pos['images'][] = $name;
         } elseif (infra_forr($te, function ($e) use($ext) {
             if ($ext == $e) {
                 return true;
             }
         })) {
             $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']);
 }
Ejemplo n.º 2
0
 //$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 = infra_seq_get($md, $right);
     if (!$mymd) {
         $mymd = array();
     }
     $paramid = infra_seq_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'];
Ejemplo n.º 3
0
 public static function initMark(&$ans = array())
 {
     //Нельзя добавлять в скрипте к метке новые значения. так как метка приходит во многие скрипты и везде должен получится один результат и все должны получить одинаковую новую метку содержающую изменения
     $mark = infra_toutf(infra_seq_get($_GET, infra_seq_right('m')));
     $mark = Mark::getInstance($mark);
     $md = $mark->getData();
     $conf = infra_config();
     $defmd = array_merge(Catalog::$md, $conf['catalog']['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;
 }