[ Index ]

krapohl.info

title

Body

[close]

/plugins/ -> function.pc_sort_events.php (source)

   1  <?php
   2  /**
   3   *  $Id: function.pc_sort_events.php,v 1.1 2004/02/11 17:31:22 larsneo Exp $
   4   *
   5   *  PostCalendar::PostNuke Events Calendar Module
   6   *  Copyright (C) 2002  The PostCalendar Team
   7   *  http://postcalendar.tv
   8   *  
   9   *  This program is free software; you can redistribute it and/or modify
  10   *  it under the terms of the GNU General Public License as published by
  11   *  the Free Software Foundation; either version 2 of the License, or
  12   *  (at your option) any later version.
  13   *  
  14   *  This program is distributed in the hope that it will be useful,
  15   *  but WITHOUT ANY WARRANTY; without even the implied warranty of
  16   *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  17   *  GNU General Public License for more details.
  18   *  
  19   *  You should have received a copy of the GNU General Public License
  20   *  along with this program; if not, write to the Free Software
  21   *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  22   *
  23   *  To read the license please read the docs/license.txt or visit
  24   *  http://www.gnu.org/copyleft/gpl.html
  25   *
  26   */
  27  function smarty_function_pc_sort_events($params, &$smarty)
  28  {
  29      extract($params);
  30  
  31        if (empty($var)) {
  32          $smarty->trigger_error("sort_array: missing 'var' parameter");
  33          return;
  34      }
  35  
  36      if (!in_array('value', array_keys($params))) {
  37          $smarty->trigger_error("sort_array: missing 'value' parameter");
  38          return;
  39      }
  40      
  41      if (!in_array('sort', array_keys($params))) {
  42          $smarty->trigger_error("sort_array: missing 'sort' parameter");
  43          return;
  44      }
  45      
  46      if (!in_array('order', array_keys($params))) {
  47          $order = 'asc';
  48      }
  49      
  50      switch($sort) {
  51      
  52          case 'category' :
  53              if(strtolower($order) == 'asc') $function = 'sort_byCategoryA';
  54              if(strtolower($order) == 'desc') $function = 'sort_byCategoryD';
  55              break;
  56              
  57          case 'title' :
  58              if(strtolower($order) == 'asc') $function = 'sort_byTitleA';
  59              if(strtolower($order) == 'desc') $function = 'sort_byTitleD';
  60              break;
  61              
  62          case 'time' :
  63              if(strtolower($order) == 'asc') $function = 'sort_byTimeA';
  64              if(strtolower($order) == 'desc') $function = 'sort_byTimeD';
  65              break;
  66      }
  67  
  68      $newArray = array();
  69      foreach($value as $date=>$events) {
  70          usort($events,$function);
  71          $newArray[$date] = array();
  72          $newArray[$date] = $events;
  73      }
  74      
  75      $smarty->assign_by_ref($var,$newArray);
  76  }
  77  ?>


Generated: Wed Feb 16 22:40:07 2005 Cross-referenced by PHPXref 0.6