home *** CD-ROM | disk | FTP | other *** search
/ Cricao de Sites - 650 Layouts Prontos / WebMasters.iso / CMS / xoops-2.0.18.1.exe / xoops-2.0.18.1 / htdocs / class / xoopsform / formdatetime.php < prev    next >
Encoding:
PHP Script  |  2005-11-03  |  3.5 KB  |  76 lines

  1. <?php
  2. // $Id: formdatetime.php 2 2005-11-02 18:23:29Z skalpa $
  3. //  ------------------------------------------------------------------------ //
  4. //                XOOPS - PHP Content Management System                      //
  5. //                    Copyright (c) 2000 XOOPS.org                           //
  6. //                       <http://www.xoops.org/>                             //
  7. //  ------------------------------------------------------------------------ //
  8. //  This program is free software; you can redistribute it and/or modify     //
  9. //  it under the terms of the GNU General Public License as published by     //
  10. //  the Free Software Foundation; either version 2 of the License, or        //
  11. //  (at your option) any later version.                                      //
  12. //                                                                           //
  13. //  You may not change or alter any portion of this comment or credits       //
  14. //  of supporting developers from this source code or any supporting         //
  15. //  source code which is considered copyrighted (c) material of the          //
  16. //  original comment or credit authors.                                      //
  17. //                                                                           //
  18. //  This program is distributed in the hope that it will be useful,          //
  19. //  but WITHOUT ANY WARRANTY; without even the implied warranty of           //
  20. //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the            //
  21. //  GNU General Public License for more details.                             //
  22. //                                                                           //
  23. //  You should have received a copy of the GNU General Public License        //
  24. //  along with this program; if not, write to the Free Software              //
  25. //  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA //
  26. //  ------------------------------------------------------------------------ //
  27. // Author: Kazumi Ono (AKA onokazu)                                          //
  28. // URL: http://www.myweb.ne.jp/, http://www.xoops.org/, http://jp.xoops.org/ //
  29. // Project: The XOOPS Project                                                //
  30. // ------------------------------------------------------------------------- //
  31. if (!defined('XOOPS_ROOT_PATH')) {
  32.     die("XOOPS root path not defined");
  33. }
  34. /**
  35.  * 
  36.  * 
  37.  * @package     kernel
  38.  * @subpackage  form
  39.  * 
  40.  * @author        Kazumi Ono    <onokazu@xoops.org>
  41.  * @copyright    copyright (c) 2000-2003 XOOPS.org
  42.  */
  43.  
  44. /**
  45.  * Date and time selection field
  46.  * 
  47.  * @author    Kazumi Ono    <onokazu@xoops.org>
  48.  * @copyright    copyright (c) 2000-2003 XOOPS.org
  49.  * 
  50.  * @package     kernel
  51.  * @subpackage  form
  52.  */
  53. class XoopsFormDateTime extends XoopsFormElementTray
  54. {
  55.  
  56.     function XoopsFormDateTime($caption, $name, $size = 15, $value=0)
  57.     {
  58.         $this->XoopsFormElementTray($caption, ' ');
  59.         $value = intval($value);
  60.         $value = ($value > 0) ? $value : time();
  61.         $datetime = getDate($value);
  62.         $this->addElement(new XoopsFormTextDateSelect('', $name.'[date]', $size, $value));
  63.         $timearray = array();
  64.         for ($i = 0; $i < 24; $i++) {
  65.             for ($j = 0; $j < 60; $j = $j + 10) {
  66.                 $key = ($i * 3600) + ($j * 60);
  67.                 $timearray[$key] = ($j != 0) ? $i.':'.$j : $i.':0'.$j;
  68.             }
  69.         }
  70.         ksort($timearray);
  71.         $timeselect = new XoopsFormSelect('', $name.'[time]', $datetime['hours'] * 3600 + 600 * ceil($datetime['minutes'] / 10));
  72.         $timeselect->addOptionArray($timearray);
  73.         $this->addElement($timeselect);
  74.     }
  75. }
  76. ?>