[ Index ]

krapohl.info

title

Body

[close]

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

   1  <?php
   2  /**
   3   *  $Id: function.pc_date_select.php,v 1.2 2004/02/11 19:11:51 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_date_select($args) 
  28  {   
  29      $print = pnVarCleanFromInput('print');
  30      $tplview = pnVarCleanFromInput('tplview');
  31      $viewtype = pnVarCleanFromInput('viewtype');
  32      if(!isset($viewtype)) $viewtype = _SETTING_DEFAULT_VIEW;
  33      $Date = postcalendar_getDate();
  34      
  35      if(!isset($y)) $y = substr($Date,0,4);
  36      if(!isset($m)) $m = substr($Date,4,2);
  37      if(!isset($d)) $d = substr($Date,6,2);
  38      
  39      if(!isset($args['day']) || strtolower($args['day']) == 'on') {
  40          $args['day'] = true;
  41          @define('_PC_FORM_DATE',true);
  42      } else {
  43          $args['day'] = false;
  44      }
  45      if(!isset($args['month']) || strtolower($args['month']) == 'on') {
  46          $args['month'] = true;
  47          @define('_PC_FORM_DATE',true);
  48      } else {
  49          $args['month'] = false;
  50      }
  51      if(!isset($args['year']) || strtolower($args['year']) == 'on') {
  52          $args['year'] = true;
  53          @define('_PC_FORM_DATE',true);
  54      } else {
  55          $args['year'] = false;
  56      }
  57      if(!isset($args['view']) || strtolower($args['view']) == 'on') {
  58          $args['view'] = true;
  59          @define('_PC_FORM_VIEW_TYPE',true);
  60      } else {
  61          $args['view'] = false;
  62      }
  63      $dayselect=$monthselect=$yearselect=$viewselect='';
  64      $output =& new pnHTML();
  65      $output->SetOutputMode(_PNH_RETURNOUTPUT);
  66          if($args['day'] === true) {
  67              $sel_data = pnModAPIFunc(__POSTCALENDAR__,'user','buildDaySelect',array('pc_day'=>$d));
  68              $dayselect = $output->FormSelectMultiple('jumpday', $sel_data);
  69          }
  70          
  71          if($args['month'] === true) {
  72              $sel_data = pnModAPIFunc(__POSTCALENDAR__,'user','buildMonthSelect',array('pc_month'=>$m));
  73              $monthselect = $output->FormSelectMultiple('jumpmonth', $sel_data);
  74          }
  75          
  76          if($args['year'] === true) {
  77              $sel_data = pnModAPIFunc(__POSTCALENDAR__,'user','buildYearSelect',array('pc_year'=>$y));
  78              $yearselect = $output->FormSelectMultiple('jumpyear', $sel_data);
  79          }
  80          
  81          if($args['view'] === true) {
  82              $sel_data = array();
  83              $sel_data[0]['id']         = 'day';
  84              $sel_data[0]['selected']   = $viewtype=='day';
  85              $sel_data[0]['name']       = _CAL_DAYVIEW;
  86              $sel_data[1]['id']         = 'week';
  87              $sel_data[1]['selected']   = $viewtype=='week';
  88              $sel_data[1]['name']       = _CAL_WEEKVIEW;
  89              $sel_data[2]['id']         = 'month';
  90              $sel_data[2]['selected']   = $viewtype=='month';
  91              $sel_data[2]['name']       = _CAL_MONTHVIEW;
  92              $sel_data[3]['id']         = 'year';
  93              $sel_data[3]['selected']   = $viewtype=='year';
  94              $sel_data[3]['name']       = _CAL_YEARVIEW;
  95              $viewselect = $output->FormSelectMultiple('viewtype', $sel_data);
  96          }
  97          if(!isset($args['label'])) $args['label'] = _PC_JUMP_MENU_SUBMIT;
  98          $jumpsubmit = '<input type="submit" name="submit" value="'.$args['label'].'" />';
  99      $output->SetOutputMode(_PNH_KEEPOUTPUT);
 100      
 101      $orderArray = array('day'=>$dayselect,
 102                          'month'=>$monthselect,
 103                          'year'=>$yearselect,
 104                          'view'=>$viewselect,
 105                          'jump'=>$jumpsubmit);
 106                          
 107      if(isset($args['order'])) {
 108          $newOrder = array();
 109          $order = explode(',',$args['order']);
 110          foreach($order as $tmp_order) {
 111              array_push($newOrder,$orderArray[$tmp_order]);
 112          }
 113          foreach($orderArray as $key=>$old_order) {
 114              if(!in_array($key,$newOrder)) {
 115                  array_push($newOrder,$orderArray[$old_order]);
 116              }
 117          }
 118          $order = $newOrder;
 119      } else {
 120          $order = $orderArray;
 121      }
 122      
 123      foreach($order as $element) {
 124          echo $element;
 125      }
 126  }
 127  ?>


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