source: temp/test-xoops.ec-cube.net/html/class/xoopsform/formdatetime.php @ 405

Revision 405, 3.4 KB checked in by root, 20 years ago (diff)
Line 
1<?php
2// $Id: formdatetime.php,v 1.2 2005/03/18 12:51:55 onokazu Exp $
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/**
32 *
33 *
34 * @package     kernel
35 * @subpackage  form
36 *
37 * @author      Kazumi Ono  <[email protected]>
38 * @copyright   copyright (c) 2000-2003 XOOPS.org
39 */
40 
41/**
42 * Date and time selection field
43 *
44 * @author  Kazumi Ono  <[email protected]>
45 * @copyright   copyright (c) 2000-2003 XOOPS.org
46 *
47 * @package     kernel
48 * @subpackage  form
49 */
50class XoopsFormDateTime extends XoopsFormElementTray
51{
52
53    function XoopsFormDateTime($caption, $name, $size = 15, $value=0)
54    {
55        $this->XoopsFormElementTray($caption, '&nbsp;');
56        $value = intval($value);
57        $value = ($value > 0) ? $value : time();
58        $datetime = getDate($value);
59        $this->addElement(new XoopsFormTextDateSelect('', $name.'[date]', $size, $value));
60        $timearray = array();
61        for ($i = 0; $i < 24; $i++) {
62            for ($j = 0; $j < 60; $j = $j + 10) {
63                $key = ($i * 3600) + ($j * 60);
64                $timearray[$key] = ($j != 0) ? $i.':'.$j : $i.':0'.$j;
65            }
66        }
67        ksort($timearray);
68        $timeselect = new XoopsFormSelect('', $name.'[time]', $datetime['hours'] * 3600 + 600 * ceil($datetime['minutes'] / 10));
69        $timeselect->addOptionArray($timearray);
70        $this->addElement($timeselect);
71    }
72}
73?>
Note: See TracBrowser for help on using the repository browser.