Exemplo n.º 1
0
function SetProperty($pagename, $prop, $value, $sep = NULL) {
  global $PCache, $KeepToken;
  NoCache();
  $prop = "=p_$prop";
  $value = preg_replace("/$KeepToken(\\d.*?)$KeepToken/e", 
                        "\$GLOBALS['KPV']['$1']", $value);
  if (!is_null($sep) && isset($PCache[$pagename][$prop]))
    $value = $PCache[$pagename][$prop] . $sep . $value;
  $PCache[$pagename][$prop] = $value;
  return $value;
}
Exemplo n.º 2
0
function SetProperty($pagename, $prop, $value, $sep=NULL, $keep=NULL) {
  global $PCache, $KeepToken;
  NoCache();
  $prop = "=p_$prop";
  $value = PPRE("/$KeepToken(\\d.*?)$KeepToken/",
                        "\$GLOBALS['KPV'][\$m[1]]", $value);
  if (!is_null($sep) && isset($PCache[$pagename][$prop]))
    $value = $PCache[$pagename][$prop] . $sep . $value;
  if (is_null($keep) || !isset($PCache[$pagename][$prop]))
    $PCache[$pagename][$prop] = $value;
  return $PCache[$pagename][$prop];
}
Exemplo n.º 3
0
function PageListSort(&$list, &$opt, $pn, &$page) {
  global $PageListSortCmp, $PCache, $PageListSortRead;
  SDVA($PageListSortRead, array('name' => 0, 'group' => 0, 'random' => 0,
    'title' => 0));

  switch ($opt['=phase']) {
    case PAGELIST_PRE:
      $ret = 0;
      foreach(preg_split('/[\\s,|]+/', @$opt['order'], -1, PREG_SPLIT_NO_EMPTY) 
              as $o) {
        $ret |= PAGELIST_POST;
        $r = '+';
        if ($o{0} == '-') { $r = '-'; $o = substr($o, 1); }
        $opt['=order'][$o] = $r;
        if ($o{0} != '$' && 
            (!isset($PageListSortRead[$o]) || $PageListSortRead[$o]))
          $ret |= PAGELIST_ITEM;
      }
      StopWatch(@"PageListSort pre ret=$ret order={$opt['order']}");
      return $ret;

    case PAGELIST_ITEM:
      if (!$page) { $page = ReadPage($pn, READPAGE_CURRENT); $opt['=readc']++; }
      return 1;
  }

  ## case PAGELIST_POST
  StopWatch('PageListSort begin');
  $order = $opt['=order'];
  if (@$order['title'])
    foreach($list as $pn) $PCache[$pn]['=title'] = PageVar($pn, '$Title');
  if (@$order['group'])
    foreach($list as $pn) $PCache[$pn]['group'] = PageVar($pn, '$Group');
  if (@$order['random']) 
    { NoCache(); foreach($list as $pn) $PCache[$pn]['random'] = rand(); }
  foreach(preg_grep('/^\\$/', array_keys($order)) as $o) 
    foreach($list as $pn) 
      $PCache[$pn][$o] = PageVar($pn, $o);
  $code = '';
  foreach($opt['=order'] as $o => $r) {
    if (@$PageListSortCmp[$o]) 
      $code .= "\$c = {$PageListSortCmp[$o]}; "; 
    else 
      $code .= "\$c = @strcasecmp(\$PCache[\$x]['$o'],\$PCache[\$y]['$o']); ";
    $code .= "if (\$c) return $r\$c;\n";
  }
  StopWatch('PageListSort sort');
  if ($code) 
    uasort($list,
           create_function('$x,$y', "global \$PCache; $code return 0;"));
  StopWatch('PageListSort end');
}
Exemplo n.º 4
0
function CondDate($condparm)
{
    global $Now;
    if (!preg_match('/^(\\S*?)(\\.\\.(\\S*))?(\\s+\\S.*)?$/', trim($condparm), $match)) {
        return false;
    }
    if ($match[4] == '') {
        $x0 = $Now;
        NoCache();
    } else {
        list($x0, $x1) = DRange($match[4]);
    }
    if ($match[1] > '') {
        list($t0, $t1) = DRange($match[1]);
        if ($x0 < $t0) {
            return false;
        }
        if ($match[2] == '' && $x0 >= $t1) {
            return false;
        }
    }
    if ($match[3]) {
        list($t0, $t1) = Drange($match[3]);
        if ($x0 >= $t1) {
            return false;
        }
    }
    return true;
}
Exemplo n.º 5
0
function CondDate($condparm)
{
    global $Now;
    NoCache();
    if (!preg_match('/^(.*?)(\\.\\.(.*))?$/', $condparm, $match)) {
        return false;
    }
    if ($match[2]) {
        $t0 = $match[1];
        if ($t0 == '') {
            $t0 = '19700101';
        }
        $t1 = $match[3];
        if ($t1 == '') {
            $t1 = '20380101';
        }
    } else {
        $t0 = $t1 = $match[1];
    }
    $t0 = preg_replace('/\\D/', '', $t0);
    if (!preg_match('/^(\\d{4})(\\d\\d)(\\d\\d)$/', $t0, $m)) {
        return false;
    }
    $g0 = mktime(0, 0, 0, $m[2], $m[3], $m[1]);
    if ($Now < $g0) {
        return false;
    }
    $t1 = preg_replace('/\\D/', '', $t1);
    $t1++;
    if (!preg_match('/^(\\d{4})(\\d\\d)(\\d\\d)$/', $t1, $m)) {
        return false;
    }
    $g1 = mktime(0, 0, 0, $m[2], $m[3], $m[1]);
    if ($Now >= $g1) {
        return false;
    }
    return true;
}
Exemplo n.º 6
0
function SetProperty($pagename, $prop, $value, $sep = NULL, $keep = NULL)
{
    global $PCache, $KeepToken;
    NoCache();
    $prop = "=p_{$prop}";
    $value = preg_replace("/{$KeepToken}(\\d.*?){$KeepToken}/e", "\$GLOBALS['KPV']['\$1']", $value);
    if (!is_null($sep) && isset($PCache[$pagename][$prop])) {
        $value = $PCache[$pagename][$prop] . $sep . $value;
    }
    if (is_null($keep) || !isset($PCache[$pagename][$prop])) {
        $PCache[$pagename][$prop] = $value;
    }
    return $PCache[$pagename][$prop];
}