Maintenance : bugfix, jslint.
[Plinn.git] / skins / jscalendar / test.php
1 <?php
2
3 $lang = $_GET['lang'];
4 if (!$lang) {
5 $lang = $_REQUEST['lang'];
6 }
7 if (!$lang) {
8 $lang = 'en';
9 }
10 setcookie('lang', $lang);
11
12 ?>
13 <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
14 <html>
15 <head>
16 <title>
17 Test for calendar.php
18 </title>
19
20 <?php
21
22 // put here the correct path to "calendar.php"; don't move the file
23 // "calendar.php" -- I think it's best if you leave it inside the
24 // "/jscalendar/" directory. Just put here the correct path to it, such as
25 // "../jscalendar/calendar.php" or something.
26 require_once ('calendar.php');
27
28 // parameters to constructor:
29 // 1. the absolute URL path to the calendar files
30 // 2. the languate used for the calendar (see the lang/ dir)
31 // 3. the theme file used for the clanedar, without the ".css" extension
32 // 4. boolean that specifies if the "_stripped" files are to be loaded
33 // The stripped files are smaller as they have no whitespace and comments
34 $calendar = new DHTML_Calendar('/jscalendar/', $lang, 'calendar-win2k-2', false);
35
36 // call this in the <head> section; it will "echo" code that loads the calendar
37 // scripts and theme file.
38 $calendar->load_files();
39
40 ?>
41
42 </head>
43
44 <body>
45
46 <?php if ($_REQUEST['submitted']) { ?>
47
48 <h1>Form submitted</h1>
49
50 <?php foreach ($_REQUEST as $key => $val) {
51 echo htmlspecialchars($key) . ' = ' . htmlspecialchars($val) . '<br />';
52 } ?>
53
54 <?php } else { ?>
55
56 <h1>Calendar.php test</h1>
57
58 <form action="test.php" method="get">
59 Select language: <select name="lang" onchange="this.form.submit()">
60 <?php
61 $cwd = getcwd();
62 chdir('lang');
63 foreach (glob('*.js') as $filename) {
64 $l = preg_replace('/(^calendar-|.js$)/', '', $filename);
65 $selected = '';
66 if ($l == $lang)
67 $selected = 'selected="selected" ';
68 $display = $l;
69 if ($l == 'en')
70 $display = 'EN';
71 echo '<option ' . $selected . 'value="' . $l . '">' . $display . '</option>';
72 }
73 ?>
74 </select>
75 <blockquote style="font-size: 90%">
76 <b>NOTE</b>: as of this release, 0.9.6, only "EN" and "RO", which I
77 maintain, function correctly. Other language files do not work
78 because they need to be updated. If you update some language file,
79 please consider sending it back to me so that I can include it in the
80 calendar distribution.
81 </blockquote>
82 </form>
83
84 <form action="test.php" method="get">
85 <input type="hidden" name="submitted" value="1" />
86
87 <table>
88 <tr>
89 <td>
90 Date 1:
91 </td>
92 <td>
93 <?php $calendar->make_input_field(
94 // calendar options go here; see the documentation and/or calendar-setup.js
95 array('firstDay' => 1, // show Monday first
96 'showsTime' => true,
97 'showOthers' => true,
98 'ifFormat' => '%Y-%m-%d %I:%M %P',
99 'timeFormat' => '12'),
100 // field attributes go here
101 array('style' => 'width: 15em; color: #840; background-color: #ff8; border: 1px solid #000; text-align: center',
102 'name' => 'date1',
103 'value' => strftime('%Y-%m-%d %I:%M %P', strtotime('now')))); ?>
104 </td>
105 </tr>
106 </table>
107
108 <hr />
109 <button>Submit</button>
110
111 </form>
112
113 <?php } ?>
114
115 </body>
116 </html>