예제 #1
0
function imager_prepareSrc($src)
{
    if (preg_match("/^https{0,1}:\\/\\//", $src)) {
        //$src=infra_theme('*imager/noimage.png');
        $src = imager_remote($src, $hour);
    } else {
        if (preg_match("/\\.php/", $src)) {
            //Такое может быть если путь до картинки передан тоже с imager то есть двойной вызов
            $src = imager_getReal($src);
        } else {
            $src = infra_theme($src);
        }
    }
    if ($src && is_dir($src)) {
        //папка смотрим в ней для src
        $list = array();
        array_map(function ($file) use(&$list) {
            if ($file[0] == '.') {
                return;
            }
            $fd = infra_nameinfo($file);
            $ext = infra_strtolower($fd['ext']);
            if (in_array($ext, array('jpg', 'gif', 'png'))) {
                $list[] = $file;
            }
        }, scandir($src));
        if (empty($list[0])) {
            $src = false;
        } else {
            $src = $src . $list[0];
        }
    }
    return $src;
}
예제 #2
0
파일: Xlsx.php 프로젝트: akiyatkin/files
 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']);
 }
예제 #3
0
<?php

namespace itlife\catalog;

use itlife\files\Xlsx;
infra_cache_no();
$orig_val = infra_toutf(strip_tags($_GET['val']));
$orig_art = infra_toutf(strip_tags($_GET['art']));
$val = infra_strtolower($orig_val);
$art = infra_strtolower($orig_art);
$args = array($val, $art);
$ans = array();
$pos = Catalog::cache('position', function ($val, $art) {
    $data = Catalog::init();
    // список всей продукции
    return Xlsx::runPoss($data, function (&$pos, $i, &$group) use(&$val, &$art) {
        if (mb_strtolower($pos['producer']) !== $val) {
            return;
        }
        if (mb_strtolower($pos['article']) !== $art) {
            return;
        }
        return $pos;
    });
}, $args, isset($_GET['re']));
if (isset($_GET['seo'])) {
    if (!$pos) {
        return infra_err($ans, 'Position not found');
    }
    $link = $_GET['seo'];
    $link = $link . '/' . $pos['producer'] . '/' . $pos['article'];
예제 #4
0
 public static function searchTest($pos, $v)
 {
     $str = $pos['Артикул'];
     $str .= ' ' . implode(' ', $pos['path']);
     $str .= ' ' . $pos['article'];
     $str .= ' ' . $pos['Наименование'];
     $str .= ' ' . $pos['Производитель'];
     $str .= ' ' . $pos['producer'];
     $str .= ' ' . $pos['Описание'];
     if (!empty($pos['more'])) {
         $str .= ' ' . implode(' ', $pos['more']);
         $str .= ' ' . implode(' ', array_keys($pos['more']));
     }
     $str = infra_strtolower($str);
     foreach ($v as $s) {
         if (mb_strrpos($str, $s) === false) {
             return false;
         }
     }
     return true;
 }