Пример #1
0
        $block['row'] = array();
        if ($param['option']['nocount']) {
            $row = array('title' => 'Не указано', 'filter' => $param['nofilter']);
            $row['checked'] = !!$mymd['no'];
            if ($row['checked']) {
                $row['add'] = $add . $paramid . '.no=';
            } else {
                $row['add'] = $add . $paramid . '.no=1';
            }
            $block['row'][] = $row;
        }
        if ($block['type'] == 'string') {
            foreach ($param['option']['values'] as $value) {
                $row = array('title' => $value['title'], 'filter' => $value['filter']);
                $row['checked'] = !!$mymd[$value['id']];
                $valueid = Sequence::short(array(Catalog::urlencode($value['id'])));
                if ($row['checked']) {
                    $row['add'] = $add . $paramid . '.' . $valueid . '=';
                } else {
                    $row['add'] = $add . $paramid . '.' . $valueid . '=1';
                }
                $block['row'][] = $row;
            }
        }
        if ($conf['filteroneitem'] || sizeof($block['row']) > 1) {
            $ans['template'][] = $block;
        }
    }
    return $ans;
}, $args, isset($_GET['re']));
$ans = array_merge($ans, $res);
Пример #2
0
};
Sequence::set(Template::$scope, array('infra', 'config'), $fn2);
Sequence::set(Template::$scope, array('Config', 'get'), $fn2);
Event::one('Controller.oninit', function () {
    Template::$scope['~conf'] = Config::get();
});
$fn3 = function () {
    return View::getPath();
};
Sequence::set(Template::$scope, array('infra', 'view', 'getPath'), $fn3);
$fn4 = function () {
    return View::getHost();
};
Sequence::set(Template::$scope, array('infra', 'view', 'getHost'), $fn4);
$fn5 = function ($s) {
    return Sequence::short($s);
};
Sequence::set(Template::$scope, array('infra', 'seq', 'short'), $fn5);
$fn6 = function ($s) {
    return Sequence::right($s);
};
Sequence::set(Template::$scope, array('infra', 'seq', 'right'), $fn6);
$fn7 = function () {
    return View::getRoot();
};
Sequence::set(Template::$scope, array('infra', 'view', 'getRoot'), $fn7);
$fn8 = function ($src) {
    return Load::srcInfo($src);
};
Sequence::set(Template::$scope, array('infra', 'srcinfo'), $fn8);
$host = $_SERVER['HTTP_HOST'];
Пример #3
0
 public static function writeNews($list, $session_id)
 {
     if (!$list) {
         return;
     }
     $db =& Db::pdo();
     global $infra_session_lasttime;
     $isphp = !!$infra_session_lasttime;
     $sql = 'insert into `ses_records`(`session_id`, `name`, `value`, `time`) VALUES(?,?,?,FROM_UNIXTIME(?))';
     $stmt = $db->prepare($sql);
     $sql = 'delete from `ses_records` where `session_id`=? and `name`=? and `time`<=FROM_UNIXTIME(?)';
     $delstmt = $db->prepare($sql);
     Each::exec($list, function &($rec) use($isphp, &$delstmt, &$stmt, $session_id) {
         $r = null;
         if (!$isphp && $rec['name'][0] == 'safe') {
             return $r;
         }
         $name = Sequence::short($rec['name']);
         $delstmt->execute(array($session_id, $name, $rec['time']));
         $stmt->execute(array($session_id, $name, Load::json_encode($rec['value']), $rec['time']));
         if (!$isphp && !$name) {
             //Сохранится safe
             Session::clear();
         }
         return $r;
     });
 }
Пример #4
0
 public static function short($right)
 {
     return Sequence::short($right, '/');
 }
Пример #5
0
 public static function filtering(&$poss, $md)
 {
     if (!sizeof($poss)) {
         return;
     }
     $params = Catalog::getParams();
     $filters = array();
     foreach ($params as $prop) {
         if ($prop['more']) {
             if (empty($md['more'])) {
                 continue;
             }
             //Filter more
             if (empty($md['more'][$prop['mdid']])) {
                 continue;
             }
             //Filter more
             $valtitles = array();
             $val = $md['more'][$prop['mdid']];
             foreach ($val as $value => $one) {
                 $valtitles[$value] = $value;
             }
             $filter = array('title' => $prop['title'], 'name' => Sequence::short(array('more', Catalog::urlencode($prop['mdid']))));
             $poss = array_filter($poss, function ($pos) use($prop, $val, &$valtitles) {
                 foreach ($val as $value => $one) {
                     $option = $pos['more'][$prop['posid']];
                     if ($value === 'yes' && Xlsx::isSpecified($option)) {
                         return true;
                     }
                     if ($value === 'no' && !Xlsx::isSpecified($option)) {
                         return true;
                     }
                     $titles = $pos['more'][$prop['posname']];
                     if ($prop['separator']) {
                         $option = explode($prop['separator'], $option);
                         $titles = explode($prop['separator'], $titles);
                     } else {
                         $option = array($option);
                         $titles = array($titles);
                     }
                     foreach ($option as $k => $opt) {
                         $id = Path::encode($opt);
                         if (strcasecmp($value, $id) == 0) {
                             $valtitles[$value] = $titles[$k];
                             return true;
                         }
                     }
                 }
                 return false;
             });
             if ($val['no']) {
                 unset($val['no']);
                 $val['Не указано'] = 1;
             }
             if ($val['yes']) {
                 unset($val['yes']);
                 $val['Указано'] = 1;
             }
             $filter['value'] = implode(', ', array_values($valtitles));
             $filters[] = $filter;
         } else {
             if (empty($md[$prop['mdid']])) {
                 continue;
             }
             $valtitles = array();
             $val = $md[$prop['mdid']];
             foreach ($val as $value => $one) {
                 $valtitles[$value] = $value;
             }
             $filter = array('title' => $prop['title'], 'name' => Sequence::short(array(Catalog::urlencode($prop['mdid']))));
             $poss = array_filter($poss, function ($pos) use($prop, $val, &$valtitles) {
                 foreach ($val as $value => $one) {
                     $option = $pos[$prop['posid']];
                     $titles = $pos[$prop['posname']];
                     if ($value === 'yes' && Xlsx::isSpecified($option)) {
                         return true;
                     }
                     if ($value === 'no' && !Xlsx::isSpecified($option)) {
                         return true;
                     }
                     if ($prop['separator']) {
                         $option = explode($prop['separator'], $option);
                         $titles = explode($prop['separator'], $titles);
                     } else {
                         $option = array($option);
                         $titles = array($titles);
                     }
                     foreach ($option as $k => $opt) {
                         $id = Path::encode($opt);
                         if (strcasecmp($value, $id) == 0) {
                             $valtitles[$value] = $titles[$k];
                             return true;
                         }
                     }
                 }
                 return false;
             });
             if ($val['no']) {
                 unset($val['no']);
                 $val['Не указано'] = 1;
             }
             if ($val['yes']) {
                 unset($val['yes']);
                 $val['Указано'] = 1;
             }
             $filter['value'] = implode(', ', array_values($valtitles));
             $filters[] = $filter;
         }
     }
     //Filter group
     $key = 'group';
     if (!empty($md[$key])) {
         $title = 'Группа';
         $val = $md[$key];
         $filter = array('title' => $title, 'name' => Sequence::short(array(Catalog::urlencode($key))));
         $poss = array_filter($poss, function ($pos) use($key, $val) {
             $prop = $pos[$key];
             foreach ($val as $value => $one) {
                 if ($value === 'yes') {
                     return true;
                 }
                 foreach ($pos['path'] as $path) {
                     if ((string) $value === $path) {
                         return true;
                     }
                 }
             }
             return false;
         });
         if ($val['no']) {
             unset($val['no']);
             $val['Не указано'] = 1;
         }
         if ($val['yes']) {
             unset($val['yes']);
             $val['Указано'] = 1;
         }
         $filter['value'] = implode(', ', array_keys($val));
         if ($md['search']) {
             $filters[] = $filter;
         }
     }
     //Filter search
     if (!empty($md['search'])) {
         $v = preg_split("/\\s+/", mb_strtolower($md['search']));
         foreach ($v as $i => $s) {
             $v[$i] = preg_replace("/ы\$/", "", $s);
         }
         $poss = array_filter($poss, function ($pos) use($v) {
             return Catalog::searchTest($pos, $v);
         });
         $filters[] = array('title' => 'Поиск', 'name' => 'search', 'value' => $md['search']);
     }
     //Extend::filtering($poss, $md, $filters);
     return $filters;
 }