2
0

ManageCalendar.template.php 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. <?php
  2. /**
  3. * Simple Machines Forum (SMF)
  4. *
  5. * @package SMF
  6. * @author Simple Machines
  7. * @copyright 2014 Simple Machines and individual contributors
  8. * @license http://www.simplemachines.org/about/smf/license.php BSD
  9. *
  10. * @version 2.1 Alpha 1
  11. */
  12. // Editing or adding holidays.
  13. function template_edit_holiday()
  14. {
  15. global $context, $scripturl, $txt, $modSettings;
  16. // Start with javascript for getting the calendar dates right.
  17. echo '
  18. <script><!-- // --><![CDATA[
  19. var monthLength = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
  20. function generateDays()
  21. {
  22. var days = 0, selected = 0;
  23. var dayElement = document.getElementById("day"), yearElement = document.getElementById("year"), monthElement = document.getElementById("month");
  24. monthLength[1] = 28;
  25. if (yearElement.options[yearElement.selectedIndex].value % 4 == 0)
  26. monthLength[1] = 29;
  27. selected = dayElement.selectedIndex;
  28. while (dayElement.options.length)
  29. dayElement.options[0] = null;
  30. days = monthLength[monthElement.value - 1];
  31. for (i = 1; i <= days; i++)
  32. dayElement.options[dayElement.length] = new Option(i, i);
  33. if (selected < days)
  34. dayElement.selectedIndex = selected;
  35. }
  36. // ]]></script>';
  37. // Show a form for all the holiday information.
  38. echo '
  39. <div id="admincenter">
  40. <form action="', $scripturl, '?action=admin;area=managecalendar;sa=editholiday" method="post" accept-charset="', $context['character_set'], '">
  41. <div class="cat_bar">
  42. <h3 class="catbg">', $context['page_title'], '</h3>
  43. </div>
  44. <div class="windowbg">
  45. <div class="content">
  46. <dl class="settings">
  47. <dt class="small_caption">
  48. <strong>', $txt['holidays_title_label'], ':</strong>
  49. </dt>
  50. <dd class="small_caption">
  51. <input type="text" name="title" value="', $context['holiday']['title'], '" size="55" maxlength="60" />
  52. </dd>
  53. <dt class="small_caption">
  54. <strong>', $txt['calendar_year'], '</strong>
  55. </dt>
  56. <dd class="small_caption">
  57. <select name="year" id="year" onchange="generateDays();">
  58. <option value="0000"', $context['holiday']['year'] == '0000' ? ' selected="selected"' : '', '>', $txt['every_year'], '</option>';
  59. // Show a list of all the years we allow...
  60. for ($year = $modSettings['cal_minyear']; $year <= $modSettings['cal_maxyear']; $year++)
  61. echo '
  62. <option value="', $year, '"', $year == $context['holiday']['year'] ? ' selected="selected"' : '', '>', $year, '</option>';
  63. echo '
  64. </select>&nbsp;
  65. ', $txt['calendar_month'], '&nbsp;
  66. <select name="month" id="month" onchange="generateDays();">';
  67. // There are 12 months per year - ensure that they all get listed.
  68. for ($month = 1; $month <= 12; $month++)
  69. echo '
  70. <option value="', $month, '"', $month == $context['holiday']['month'] ? ' selected="selected"' : '', '>', $txt['months'][$month], '</option>';
  71. echo '
  72. </select>&nbsp;
  73. ', $txt['calendar_day'], '&nbsp;
  74. <select name="day" id="day" onchange="generateDays();">';
  75. // This prints out all the days in the current month - this changes dynamically as we switch months.
  76. for ($day = 1; $day <= $context['holiday']['last_day']; $day++)
  77. echo '
  78. <option value="', $day, '"', $day == $context['holiday']['day'] ? ' selected="selected"' : '', '>', $day, '</option>';
  79. echo '
  80. </select>
  81. </dd>
  82. </dl>
  83. <hr class="hrcolor" />';
  84. if ($context['is_new'])
  85. echo '
  86. <input type="submit" value="', $txt['holidays_button_add'], '" class="button_submit" />';
  87. else
  88. echo '
  89. <input type="submit" name="edit" value="', $txt['holidays_button_edit'], '" class="button_submit" />
  90. <input type="submit" name="delete" value="', $txt['holidays_button_remove'], '" class="button_submit" />
  91. <input type="hidden" name="holiday" value="', $context['holiday']['id'], '" />';
  92. echo '
  93. <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '" />
  94. </div>
  95. </div>
  96. </form>
  97. </div>';
  98. }
  99. ?>