[ PHPXref.com ] [ Generated: Sun Jul 20 16:25:17 2008 ] [ ActionApps 2.8.1b ]
[ Index ]     [ Variables ]     [ Functions ]     [ Classes ]     [ Constants ]     [ Statistics ]

title

Body

[close]

/ -> slice.php3 (source)

   1  <?php
   2  //$Id: slice.php3,v 1.81 2005/06/23 16:20:35 honzam Exp $
   3  /*
   4  Copyright (C) 1999, 2000 Association for Progressive Communications
   5  http://www.apc.org/
   6  
   7      This program is free software; you can redistribute it and/or modify
   8      it under the terms of the GNU General Public License as published by
   9      the Free Software Foundation; either version 2 of the License, or
  10      (at your option) any later version.
  11  
  12      This program is distributed in the hope that it will be useful,
  13      but WITHOUT ANY WARRANTY; without even the implied warranty of
  14      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  15      GNU General Public License for more details.
  16  
  17      You should have received a copy of the GNU General Public License
  18      along with this program (LICENSE); if not, write to the Free Software
  19      Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  20  */
  21  
  22  //expected  slice_id
  23  //expected  encap     // determines wheather this file is ssi included or called directly
  24  //optionaly sh_itm    // if specified - selected item is shown in full text
  25  //optionaly x         // the same as sh_itm, but short_id is used instead
  26                       // implemented for shorter item url (see _#SITEM_ID alias)
  27  //optionaly o         // the same as x but the hit is not counted
  28  //optionaly srch      // true if this script have to show search results
  29  //optionaly highlight // when true, shows only highlighted items in compact view
  30  //optionaly bigsrch   // NOT SUPPORTED IN AA v 1.5+
  31  //optionaly cat_id    // select only items in category with id cat_id
  32  //optionaly cat_name  // select only items in category with name cat_name
  33  //optionaly inc       // for dispalying another file instead of slice data
  34                       // (like static html file - inc=/contact.html)
  35  //optionaly listlen   // change number of listed items in compact view
  36                       // (aplicable in compact viewe only)
  37  //optionaly items[x]  // array of items to show one after one as fulltext
  38                       // the array format is
  39  //easy_query          // for easiest form of query
  40  //order               // order field id - if other than publish date
  41                       // add minus sign for descending order (like "headline.......1-");
  42  //timeorder           // rev - reverse publish date order
  43                       // (less priority than "order")
  44  //no_scr              // if true, no scroller is displayed
  45  //all_scr             // if true, scroller shows also 'All no scroller is displayed
  46  //scr_go              // sets scroller to specified page
  47  //scr_url             // redefines the page where the scroller should go (it is
  48                       // usefull if you include slice.php3 from another php script)
  49  //restrict            // field id used with "res_val" and "exact" for restricted
  50                       // output (display only items with
  51                       //       "restrict" field = "res_val"
  52  //res_val             // see restrict
  53  //exact               // = 1: "restrict" field must match res_val exactly (=)
  54                       // undefined: substring is sufficient (LIKE '%res_val%')
  55                       // = 2: the same as 1, but the res_val is taken as
  56                       // expression (like: "environment or (toxic and not fuel)")
  57  //als[]               // user alias definition. Parameter 'als[MY_ALIAS]=Summary'
  58                       // defines alias _#MY_ALIAS. If used, it prints 'Summary'.
  59  //lock                // used in join with "key" for multiple slices on one page
  60                       // display. each slice have to have its lock, so commands
  61                       // (like sh_itm, scr_go, ...) will be executed only if key
  62                       // is the same as lock. key is send automaticaly with all
  63                       // links generated in slice (at this time just prepared)
  64  //key                 // see lock (at this time just prepared)
  65  //slicetext           // displays just the text instead of any output
  66                       // can be used for hiding the output of slice.hp3
  67  
  68                        //Discussion parameters
  69  //optionaly add_disc   // if set, discussion comment will be added
  70  //optionaly parent_id  // parent id of added disc. comment
  71  //optionally sel_ids    // if set, show only discussion comments in $ids[] array
  72  //optionally ids[]      // array of discussion comments to show in fulltext mode (ids['x'.$id])
  73  //optionally all_ids    // if set, show all discussion comments
  74  //optionally hideFulltext // if set, don't show fulltext part
  75  //optionally neverAllItems // if set, don't show anything when everything would be shown (if no conds[] are set)
  76  //optionally defaultCondsOperator // replaces LIKE for conds with not specified operator
  77  //optionally group_n   // displayes only the n-th group (in listings where items
  78                        // are grouped by some field (category, for example))
  79                        // good for display all the items of last magazine issue
  80                        // ( group_n=1 )
  81                //
  82  //optionally mlx       // set language extension options (needs MLX field filled in Slice Settings)
  83                        // mlx=EN sets English as default language
  84                // mlx=EN-FR-DE first looks for EN, then FR, then DE
  85                //              and then displays the first one found
  86                // mlx=EN-ONLY  displays only EN items (like conds)
  87                // mlx=ALL      turns of language extension
  88  
  89  
  90  function add2sort(&$sort, $sarr) {
  91      if (isset($sort) AND is_array($sort)) {
  92          foreach ($sort as $s) {
  93              if (key($s) == key($sarr)) {
  94                  return;  // do not add new sort value to the sort array (it is already presented)
  95              }
  96          }
  97      }
  98      $sort[] = $sarr;
  99      return;
 100  }
 101  
 102  // handle with PHP magic quotes - quote the variables if quoting is set off
 103  function Myaddslashes($val, $n=1) {
 104    if (!is_array($val)) {
 105      return addslashes($val);
 106    }
 107    for (reset($val); list($k, $v) = each($val); )
 108      $ret[$k] = Myaddslashes($v, $n+1);
 109    return $ret;
 110  }
 111  
 112  if (!get_magic_quotes_gpc()) {
 113    // Overrides GPC variables
 114    if ( isset($HTTP_GET_VARS) AND is_array($HTTP_GET_VARS))
 115      for (reset($HTTP_GET_VARS); list($k, $v) = each($HTTP_GET_VARS); )
 116        $$k = Myaddslashes($v);
 117    if ( isset($HTTP_POST_VARS) AND is_array($HTTP_POST_VARS))
 118      for (reset($HTTP_POST_VARS); list($k, $v) = each($HTTP_POST_VARS); )
 119        $$k = Myaddslashes($v);
 120    if ( isset($HTTP_COOKIE_VARS) AND is_array($HTTP_COOKIE_VARS))
 121      for (reset($HTTP_COOKIE_VARS); list($k, $v) = each($HTTP_COOKIE_VARS); )
 122        $$k = Myaddslashes($v);
 123  }
 124  
 125  $encap = ( ($encap=="false") ? false : true );
 126  
 127  require_once  "./include/config.php3";
 128  require_once $GLOBALS['AA_INC_PATH']."easy_scroller.php3";
 129  require_once $GLOBALS['AA_INC_PATH']."util.php3";
 130  require_once $GLOBALS['AA_INC_PATH']."item.php3";
 131  require_once $GLOBALS['AA_INC_PATH']."view.php3";
 132  require_once $GLOBALS['AA_INC_PATH']."pagecache.php3";
 133  require_once $GLOBALS['AA_INC_PATH']."searchlib.php3";
 134  require_once $GLOBALS['AA_INC_PATH']."discussion.php3";
 135  require_once $GLOBALS['AA_INC_PATH']."mgettext.php3";
 136  // function definitions:
 137  require_once $GLOBALS['AA_INC_PATH']."slice.php3";
 138  
 139  require_once $GLOBALS['AA_INC_PATH']. ($encap ? "locsessi.php3" : "locsess.php3");
 140  $slice_starttime = get_microtime();
 141  
 142  //MLX stuff
 143  require_once $GLOBALS['AA_INC_PATH']."mlx.php";
 144  
 145  page_open(array("sess" => "AA_SL_Session"));
 146  
 147  $sess->register(r_packed_state_vars);
 148  $sess->register(slices);
 149  
 150  $r_state_vars = unserialize($r_packed_state_vars);
 151  
 152  // there was problems with storing too much ids in session veriable,
 153  // so I commented it out. It is not necessary to have it in session. The only
 154  // reason to have it there is the display speed, but because of impementing
 155  // pagecache.php3, it is not so big problem now
 156  
 157  //$sess->register(item_ids);
 158  
 159  if ($encap) {                    // adds values from QUERY_STRING_UNESCAPED
 160      add_vars("");                //       and REDIRECT_STRING_UNESCAPED
 161  }
 162  
 163  if (($key != $lock) OR $scrl) {  // command is for other slice on page
 164      RestoreVariables();          // or scroller
 165  }
 166  
 167  // url posted command to display specified text instead of slice content -------
 168  if ($slicetext) {
 169      echo $slicetext;
 170      ExitPage();
 171  }
 172  
 173  // url posted command to display another file ----------------------------------
 174  if ( $inc ) {                   // this section must be after add_vars()
 175      //  StoreVariables(array("inc")); // store in session
 176      if ( !eregi("^([0-9a-z_])+(\.[0-9a-z]*)?$", $inc) ) {
 177          echo _m("Bad inc parameter - included file must be in the same directory as this .shtml file and must contain only alphanumeric characters"). " $inc";
 178          ExitPage();
 179      } else {
 180          $fp = @fopen(shtml_base().$inc, "r");    //   if encapsulated
 181          if (!$fp) {
 182              echo _m("No such file") ." $inc";
 183          } else {
 184              FPassThru($fp);
 185          }
 186          ExitPage();
 187      }
 188  }
 189  
 190  // Take any slice to work with
 191  if (!$slice_id AND is_array($slices)) {
 192      reset ($slices);
 193      $slice_id = current($slices);
 194  }
 195  
 196  // if someone breaks <!--#include virtual=""... into two rows, then slice_id
 197  // (or other variables) could contain \n. Should be fixed more generaly -
 198  // We will do it during rewrite AA to $_GET[] variable handling (probably)
 199  $slice_id   = trim($slice_id);
 200  $p_slice_id = q_pack_id($slice_id);
 201  
 202  require_once $GLOBALS['AA_INC_PATH']."javascript.php3";
 203  
 204  $db  = new DB_AA;      // open BD
 205  $db2 = new DB_AA;      // open BD    (for subqueries in order to fullfill fulltext in feeded items)
 206  
 207  
 208  list($fields) = GetSliceFields($slice_id);     // get fields info
 209  $slice_info   = GetSliceInfo($slice_id);       // get slice info
 210  if (!$slice_info OR $slice_info['deleted']>0) {
 211      echo _m("Invalid slice number or slice was deleted") . " (ID: $slice_id)";
 212      ExitPage();
 213  }
 214  
 215  // Use right language (from slice settings) - languages are used for scroller (Next, ...)
 216  $lang_file = substr($slice_info['lang_file'], 0, 2);
 217  if (!$LANGUAGE_NAMES[$lang_file]) {
 218      $lang_file = "en";
 219  }
 220  bind_mgettext_domain($GLOBALS['AA_INC_PATH']."lang/".$lang_file."_output_lang.php3");
 221  
 222  if (!$slice_info['even_odd_differ']) {
 223      $slice_info['even_row_format'] = "";
 224  }
 225  
 226  // it is possible to redefine the design of fulltext or compact view by the view
 227  // see fview and iview url parameters for this file (slice.php3)
 228  if ($fview || $iview) {
 229      if ($fview) {                       // use formating from view for fulltext
 230          $fview_info = GetViewInfo($fview);
 231          if ($fview_info AND ($fview_info['deleted']<1)) {
 232              $slice_info['fulltext_format']        = $fview_info['odd'];
 233              $slice_info['fulltext_format_top']    = $fview_info['before'];
 234              $slice_info['fulltext_format_bottom'] = $fview_info['after'];
 235              $slice_info['fulltext_remove']        = $fview_info['remove_string'];
 236          }
 237      }
 238      if ($iview) {                       // use formating from view for index
 239          $iview_info = GetViewInfo($iview);
 240          if ($iview_info AND ($iview_info['deleted']<1)) {
 241              $slice_info['group_by']        = $iview_info['group_by1'];
 242              $slice_info['gb_direction']    = $VIEW_SORT_DIRECTIONS[$iview_info['g1_direction']];  // views uses different sort codes (historical reasons)
 243              $slice_info['category_format'] = $iview_info['group_title'];
 244              $slice_info['category_bottom'] = $iview_info['group_bottom'];
 245              $slice_info['compact_top']     = $iview_info['before'];
 246              $slice_info['compact_bottom']  = $iview_info['after'];
 247              $slice_info['compact_remove']  = $iview_info['remove_string'];
 248              $slice_info['even_row_format'] = $iview_info['even'];
 249              $slice_info['odd_row_format']  = $iview_info['odd'];
 250              $slice_info['even_odd_differ'] = $iview_info['even_odd_differ'];
 251          }
 252      }
 253  }
 254  define("DEFAULT_CODEPAGE","windows-1250");
 255  
 256  if (!$encap) {
 257      Page_HTML_Begin($slice_info['name']);
 258  }
 259  
 260  if ($bigsrch) {  // big search form ------------------------------------------
 261      echo '<!-- bigsrch parameter is NOT SUPPORTED IN AA v 1.5+ <br> See
 262            <a href="http://apc-aa.sourceforge.net/faq/index.shtml#215">AA FAQ</a>
 263            for more details. -->';
 264      ExitPage();
 265  }
 266  
 267  $add_aliases = $aliases    = GetAliasesFromUrl($als);
 268  
 269  // this is not good way - aliases are then different on each call, so it isn't
 270  // cached. The better way is below
 271  // $add_aliases['_#SESSION_'] = GetAliasDef( 'f_s:'. $sess->id, '', _m('session id'));
 272  
 273  $add_aliases['_#SESSION_'] = GetAliasDef( 'f_e:session', 'id..............', _m('session id'));
 274  
 275  // if banner parameter supplied => set format
 276  ParseBannerParam($slice_info, $banner);
 277  
 278  // get alias list from database and possibly from url
 279  // if working with multi-slice, get aliases for all slices
 280  if (!is_array($slices)) {
 281      $aliases = GetAliasesFromFields($fields);
 282      array_add($add_aliases, $aliases);
 283  } else {
 284      foreach ($slices as $slice) {
 285          list($fields) = GetSliceFields($slice);
 286          // hack for searching in multiple slices. This is not so nice part
 287          // of code - we mix there $aliases[<alias>] with $aliases[<p_slice_id>][<alias>]
 288          // it is needed by itemview::set_column() (see include/itemview.php3)
 289          $aliases[q_pack_id($slice)] = GetAliasesFromFields($fields,$als);
 290          array_add($add_aliases, $aliases[q_pack_id($slice)]);
 291      }
 292  }
 293  
 294  // fulltext view ---------------------------------------------------------------
 295  if ( $sh_itm OR $x OR $o ) {
 296      //  $r_state_vars = StoreVariables(array("sh_itm")); // store in session
 297      if ( !$x AND $o ) {
 298          $x = $o;
 299          $count_hit = false;
 300      } else {
 301          $count_hit = true;
 302      }
 303  
 304      if ($sh_itm) {
 305          LogItem($sh_itm, "id", $count_hit);
 306      } else {
 307          $sh_itm = LogItem($x,"short_id", $count_hit);
 308      }
 309  
 310      if (!isset ($hideFulltext)) {
 311          $itemview = new itemview($slice_info, $fields, $aliases, new zids($sh_itm,"l"),
 312                                   0,1, $sess->MyUrl($slice_id, $encap));
 313          $itemview->print_item();
 314      }
 315  
 316      // show discussion if assigned
 317      $discussion_vid = ( isset($dview) ? $dview : $slice_info['vid']);
 318      // you can set dview=0 to not show discussion
 319      if ($discussion_vid > 0) {
 320          $db->query("SELECT view.*, slice.flag FROM view, slice
 321                       WHERE slice.id='".q_pack_id($slice_id)."' AND view.id=$discussion_vid");
 322          if ($db->next_record()) {
 323              $view_info = $db->Record;
 324              // create array of parameters
 325              $disc = array('ids'         => $all_ids ? "" : $ids,
 326                            'type'        => $add_disc ? "adddisc" : (($sel_ids || $all_ids) ? "fulltext" : "thread"),
 327                            'item_id'     => $sh_itm,
 328                            'vid'         => $view_info['id'],
 329                            'html_format' => $view_info['flag'] & DISCUS_HTML_FORMAT,
 330                            'parent_id'   => $parent_id
 331                           );
 332              $aliases = GetDiscussionAliases();
 333  
 334              $format  = GetDiscussionFormat($view_info);
 335              $format['id'] = $p_slice_id;                  // set slice_id because of caching
 336  
 337              $itemview = new itemview($format, "", $aliases, null,"", "", $sess->MyUrl($slice_id, $encap), $disc);
 338              $itemview->print_discussion('nocache');  // discussions should not be
 339              // cached or even better (TODO) discussions should have its separate slice
 340              // which is cached independently form the item itself through standard
 341              // AA caching
 342  
 343          }
 344      }
 345      ExitPage();
 346  }
 347  
 348  // multiple items fulltext view ------------------------------------------------
 349  if ( $items AND is_array($items) ) {   // shows all $items[] as fulltext one after one
 350      //  $r_state_vars = StoreVariables(array("items")); // store in session
 351      while (list($k) = each( $items )) {
 352          $ids[] = substr($k,1);    //delete starting character ('x') - used for interpretation of index as string, not number (by PHP)
 353      }
 354      $zids     = new zids($ids,"l");
 355      $itemview = new itemview($slice_info, $fields, $aliases, $zids, 0,$zids->count(), $sess->MyUrl($slice_id, $encap));
 356      $itemview->print_itemlist();
 357      ExitPage();
 358  }
 359  
 360  // compact view ----------------------------------------------------------------
 361  if (!is_object($scr)) {
 362      $sess->register('scr');
 363      $scr_url_param = ($scr_url ? $sess->url("$scr_url") : $sess->MyUrl($slice_id, $encap))."&amp;";
 364      $scr = new easy_scroller( 'scr', $scr_url_param, $slice_info['d_listlen'], 0);
 365  }
 366  // display 'All' option in scroller
 367  if ($all_scr) { $scr->setShowAll($all_scr); }
 368  
 369  // change number of listed items
 370  if ($listlen) { $scr->setMetapage($listlen); }
 371  
 372  // default start page = 1
 373  if (!$scr_go) { $scr_go = 1; }
 374  
 375  // $scrl comes from easy_scroller
 376  if ($scrl)    { $scr->update(); }
 377  
 378  /** Add scroller aliases - page number, listlen */
 379  $scr_aliases['_#PAGE_NO_'] = GetAliasDef( 'f_s:'. $scr->current,  '', _m('number of current page (on pagescroller)'));
 380  $scr_aliases['_#PAGE_LEN'] = GetAliasDef( 'f_s:'. $scr->metapage, '', _m('page length (number of items)'));
 381  // aliases array have two form (quite stupid - will be changed in future - TODO)
 382  // depending on listing for one slice or many slices
 383  if (!is_array($slices)) {
 384      array_add($scr_aliases, $aliases);
 385  } else {
 386      foreach ($slices as $slice) {
 387          // hack for searching in multiple slices. This is not so nice part
 388          // of code - we mix there $aliases[<alias>] with $aliases[<p_slice_id>][<alias>]
 389          // it is needed by itemview::set_column() (see include/itemview.php3)
 390          array_add($scr_aliases, $aliases[q_pack_id($slice)]);
 391      }
 392  }
 393  
 394  
 395  
 396  /* old version of automatiocaly created search form - not used in AA > 1.2
 397     $easy_query .. easy query form
 398     $srch .. bigsrch form ??
 399  */
 400  
 401  if (($easy_query || $srch) AND !(is_array($conds) OR isset($group_by) OR isset($sort))) {
 402  
 403      if ($easy_query) {     // posted by easy query form ----------------
 404          $r_state_vars = StoreVariables(array("listlen","no_scr","scr_go","srch_fld","srch_from", "srch_to",
 405                                               "easy_query", "qry", "srch_relev", "mlx")); // store in session, added mlx
 406          $item_ids     = GetIDs_EasyQuery($fields, $db, $p_slice_id, $srch_fld, $srch_from, $srch_to, $qry, $srch_relev);
 407          if ( isset($item_ids) AND !is_array($item_ids) ) {
 408              echo "<div>$item_ids</div>";
 409          }
 410          if ( !$scrl ) {
 411              $scr->current = $scr_go;
 412          }
 413      }
 414      elseif ($srch) {     // posted by bigsrch form -------------------
 415          $r_state_vars = StoreVariables(array("listlen","no_scr","scr_go","big","search", "s_col", "mlx")); // store in session
 416          if ( !$big ) {
 417              $search['slice'] = $slice_id;
 418          }
 419          $item_ids = SearchWhere($search, $s_col);
 420          if ( !$scrl ) {
 421              $scr->current = $scr_go;
 422          }
 423      }
 424      elseif ($debug) {
 425          echo "ERROR: This branch should never be entered.";
 426      }
 427  } else {
 428      /** * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
 429       *         Parse parameters posted by query form and from $slice_info
 430       * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
 431  
 432      $r_state_vars = StoreVariables(array("no_scr","scr_go","order","cat_id", "cat_name",
 433       "exact","restrict","res_val","highlight","conds","group_by", "sort","als","defaultCondsOperator","mlx")); // store in session, added mlx
 434  
 435      // ***** CONDS *****
 436  
 437      if ($cat_id) {  // optional parameter cat_id - deprecated - slow ------
 438          $cat_group = GetCategoryGroup($slice_id);
 439          $SQL = "SELECT value FROM constant
 440                   WHERE group_id = '$cat_group' AND id='". q_pack_id($cat_id) ."'";
 441          $db->query($SQL);
 442          if ( $db->next_record() ) {
 443              $conds[] = array( GetCategoryFieldId( $fields ) => 1,
 444                                'value'                       => $db->f('value'),
 445                                'operator'                    => ($exact ? '=' : 'LIKE'));
 446          }
 447      } elseif ($cat_name)  {  // optional parameter cat_name -------
 448          $conds[]     = array( GetCategoryFieldId( $fields ) => 1,
 449                                'value'                       => $cat_name,
 450                                'operator'                    => ($exact ? '=' : 'LIKE'));
 451      }
 452  
 453      if ($restrict) {
 454          $conds[]     = array( $restrict  => 1,
 455                                'value'    => ((($res_val[0] == '"' OR $res_val[0] == "'") AND $exact != 2 ) ? $res_val : "\"$res_val\""),
 456                                'operator' => ($exact ? '=' : 'LIKE'));
 457      }
 458  
 459      if ($highlight != "") {
 460          $conds[] = array('highlight.......' => 1);
 461      }
 462  
 463      if (!isset($defaultCondsOperator)) {
 464          $defaultCondsOperator = 'LIKE';
 465      }
 466      if (is_array($conds)) {
 467          ParseEasyConds($conds, $defaultCondsOperator);
 468          foreach ( $conds as $k => $v ) {
 469              SubstituteAliases( $als, $conds[$k]['value'] );
 470          }
 471      }
 472  
 473      // ***** SORT *****
 474  
 475      /** order by field xy if other than publish date.
 476      *  Syntax: [number]field_id[-]
 477      *  (add minus sign for descending order (like "headline.......1-")
 478      *  (add number before the field if you want to group limit (limit number of items of the same value))
 479      */
 480      if ($order) {
 481          $order = GetSortArray($order);
 482          reset($order);
 483          list($order, $orderdirection) = each($order);
 484      }
 485  
 486      if ($debug) {
 487          echo "<BR>Group by: -$group_by- <br>Slice_info[category_sort] -$slice_info[category_sort]-<br>slice_info[group_by] -$slice_info[group_by]-";
 488      }
 489  
 490      $sort_tmp = array();
 491      if ($group_by) {
 492          $foo                    = GetSortArray( $group_by );
 493          $sort_tmp[]             = $foo;
 494          $slice_info["group_by"] = key($foo);
 495      }
 496      elseif ($slice_info['category_sort']) {
 497          $group_field = GetCategoryFieldId( $fields );
 498          $grp_odir    = (($order==$group_field) AND ($orderdirection!='d')) ? 'a' : 'd';
 499          $sort_tmp[]  = array( $group_field => $grp_odir );
 500      }
 501      elseif ($slice_info['group_by']) {
 502          switch( (string)$slice_info['gb_direction'] ) {  // gb_direction is number
 503              case '1': $gbd = '1'; break;      // 1 (1)- ascending by priority
 504              case 'd':                         //    d - descending - goes from view (iview) settings
 505              case '8': $gbd = 'd'; break;      // d (8)- descending
 506              case '9': $gbd = '9'; break;      // 9 (9)- descending by priority (for fields using constants)
 507              default:  $gbd = 'a';             // 2 (2)- ascending;
 508          }
 509          $sort_tmp[] = array($slice_info['group_by'] => $gbd);
 510      }
 511  
 512      $sort_tmp = array_merge($sort_tmp, getSortFromUrl($sort));
 513  
 514      if ($order) {
 515          add2sort($sort_tmp, array($order => (strstr('aAdD19',$orderdirection) ? $orderdirection : 'a')));
 516      }
 517  
 518      // time order the fields in compact view
 519      add2sort($sort_tmp, array('publish_date....' => (($timeorder == "rev") ? 'a' : 'd')));
 520      $sort  = $sort_tmp;
 521  
 522      //mlx stuff
 523      if (isMLXSlice($slice_info)) {
 524          if (!$mlxView) {
 525              $mlxView = new MLXView($mlx);
 526          }
 527          $mlxView->preQueryZIDs(unpack_id128($slice_info[MLX_SLICEDB_COLUMN]),$conds,$slices);
 528      }
 529      $zids = QueryZIDs($fields, $slice_id, $conds, $sort, $slice_info['group_by'], "ACTIVE", $slices, $neverAllItems, 0, $defaultCondsOperator, true );
 530  
 531      if (isMLXSlice($slice_info)) {
 532          $mlxView->postQueryZIDs($zids,unpack_id128($slice_info[MLX_SLICEDB_COLUMN]),$slice_id, $conds, $sort, $slice_info['group_by'],"ACTIVE", $slices, $neverAllItems, 0, $defaultCondsOperator,$nocache);
 533      }
 534  
 535      if ( !$scrl ) {
 536          $scr->current = $scr_go;
 537      }
 538  }
 539  
 540  if ( !$srch AND !$encap AND !$easy_query ) {
 541      $cur_cats=GetCategories($db,$p_slice_id);     // get list of categories
 542      pCatSelector($sess->name,$sess->id,$sess->MyUrl($slice_id, $encap, true),$cur_cats,$scr->filters[category_id]['value'], $slice_id, $encap);
 543  }
 544  
 545  
 546  if ($zids->count() > 0) {
 547      $scr->countPages( $zids->count() );
 548  
 549      $itemview = new itemview($slice_info, $fields, $aliases, $zids, $scr->metapage * ($scr->current - 1),
 550                               ($group_n ? -$group_n : $scr->metapage),  // negative number used for displaying n-th group
 551                               $sess->MyUrl($slice_id, $encap) );
 552      $itemview->print_view();
 553  
 554      if (($scr->pageCount() > 1) AND !$no_scr AND !$group_n) {
 555          $scr->pnavbar();
 556      }
 557  } else {
 558      echo $slice_info['noitem_msg'] ?               // <!--Vacuum--> is keyword for removing 'no item message'
 559            str_replace( '<!--Vacuum-->', '', $slice_info['noitem_msg']) : ("<div>"._m("No item found") ."</div>");
 560  }
 561  
 562  if ($searchlog) {
 563      PutSearchLog();
 564  }
 565  
 566  if ($debug) {
 567      $timeend = get_microtime();
 568      $time    = $timeend - $slice_starttime;
 569      echo "<br><br>Page generation time: $time";
 570  }
 571  
 572  ExitPage();
 573  ?>


[ Powered by PHPXref - Served by Debian GNU/Linux ]