Back to index

plone3  3.1.7
test.php
Go to the documentation of this file.
00001 <?php
00002 
00003 $lang = $_GET['lang'];
00004 if (!$lang) {
00005     $lang = $_REQUEST['lang'];
00006 }
00007 if (!$lang) {
00008     $lang = 'en';
00009 }
00010 setcookie('lang', $lang);
00011 
00012 ?>
00013 <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
00014 <html>
00015 <head>
00016 <title>
00017 Test for calendar.php
00018 </title>
00019 
00020 <?php
00021 
00022 // put here the correct path to "calendar.php"; don't move the file
00023 // "calendar.php" -- I think it's best if you leave it inside the
00024 // "/jscalendar/" directory.  Just put here the correct path to it, such as
00025 // "../jscalendar/calendar.php" or something.
00026 require_once ('calendar.php');
00027 
00028 // parameters to constructor:
00029 //     1. the absolute URL path to the calendar files
00030 //     2. the languate used for the calendar (see the lang/ dir)
00031 //     3. the theme file used for the clanedar, without the ".css" extension
00032 //     4. boolean that specifies if the "_stripped" files are to be loaded
00033 //        The stripped files are smaller as they have no whitespace and comments
00034 $calendar = new DHTML_Calendar('/jscalendar/', $lang, 'calendar-win2k-2', false);
00035 
00036 // call this in the <head> section; it will "echo" code that loads the calendar
00037 // scripts and theme file.
00038 $calendar->load_files();
00039 
00040 ?>
00041 
00042 </head>
00043 
00044 <body>
00045 
00046 <?php if ($_REQUEST['submitted']) { ?>
00047 
00048 <h1>Form submitted</h1>
00049 
00050 <?php foreach ($_REQUEST as $key => $val) {
00051     echo htmlspecialchars($key) . ' = ' . htmlspecialchars($val) . '<br />';
00052 } ?>
00053 
00054 <?php } else { ?>
00055 
00056 <h1>Calendar.php test</h1>
00057 
00058      <form action="test.php" method="get">
00059      Select language: <select name="lang" onchange="this.form.submit()">
00060      <?php
00061 $cwd = getcwd();
00062 chdir('lang');
00063 foreach (glob('*.js') as $filename) {
00064     $l = preg_replace('/(^calendar-|.js$)/', '', $filename);
00065     $selected = '';
00066     if ($l == $lang)
00067         $selected = 'selected="selected" ';
00068     $display = $l;
00069     if ($l == 'en')
00070         $display = 'EN';
00071     echo '<option ' . $selected . 'value="' . $l . '">' . $display . '</option>';
00072 }
00073      ?>
00074      </select>
00075      <blockquote style="font-size: 90%">
00076        <b>NOTE</b>: as of this release, 0.9.6, only "EN" and "RO", which I
00077        maintain, function correctly.  Other language files do not work
00078        because they need to be updated.  If you update some language file,
00079        please consider sending it back to me so that I can include it in the
00080        calendar distribution.
00081      </blockquote>
00082      </form>
00083 
00084      <form action="test.php" method="get">
00085      <input type="hidden" name="submitted" value="1" />
00086 
00087      <table>
00088      <tr>
00089      <td>
00090        Date 1:
00091      </td>
00092      <td>
00093        <?php $calendar->make_input_field(
00094            // calendar options go here; see the documentation and/or calendar-setup.js
00095            array('firstDay'       => 1, // show Monday first
00096                  'showsTime'      => true,
00097                  'showOthers'     => true,
00098                  'ifFormat'       => '%Y-%m-%d %I:%M %P',
00099                  'timeFormat'     => '12'),
00100            // field attributes go here
00101            array('style'       => 'width: 15em; color: #840; background-color: #ff8; border: 1px solid #000; text-align: center',
00102                  'name'        => 'date1',
00103                  'value'       => strftime('%Y-%m-%d %I:%M %P', strtotime('now')))); ?>
00104      </td>
00105      </tr>
00106      </table>
00107 
00108      <hr />
00109      <button>Submit</button>
00110 
00111      </form>
00112 
00113 <?php } ?>
00114 
00115 </body>
00116 </html>