test.php 3.3KB

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