2
0

ManageCalendar.template.php 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. <?php
  2. /**
  3. * Simple Machines Forum (SMF)
  4. *
  5. * @package SMF
  6. * @author Simple Machines
  7. * @copyright 2011 Simple Machines
  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, $settings, $options, $scripturl, $txt, $modSettings;
  16. // Start with javascript for getting the calendar dates right.
  17. echo '
  18. <script type="text/javascript"><!-- // --><![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. <span class="topslice"><span></span></span>
  46. <div class="content">
  47. <dl class="settings">
  48. <dt class="small_caption">
  49. <strong>', $txt['holidays_title_label'], ':</strong>
  50. </dt>
  51. <dd class="small_caption">
  52. <input type="text" name="title" value="', $context['holiday']['title'], '" size="55" maxlength="60" />
  53. </dd>
  54. <dt class="small_caption">
  55. <strong>', $txt['calendar_year'], '</strong>
  56. </dt>
  57. <dd class="small_caption">
  58. <select name="year" id="year" onchange="generateDays();">
  59. <option value="0000"', $context['holiday']['year'] == '0000' ? ' selected="selected"' : '', '>', $txt['every_year'], '</option>';
  60. // Show a list of all the years we allow...
  61. for ($year = $modSettings['cal_minyear']; $year <= $modSettings['cal_maxyear']; $year++)
  62. echo '
  63. <option value="', $year, '"', $year == $context['holiday']['year'] ? ' selected="selected"' : '', '>', $year, '</option>';
  64. echo '
  65. </select>&nbsp;
  66. ', $txt['calendar_month'], '&nbsp;
  67. <select name="month" id="month" onchange="generateDays();">';
  68. // There are 12 months per year - ensure that they all get listed.
  69. for ($month = 1; $month <= 12; $month++)
  70. echo '
  71. <option value="', $month, '"', $month == $context['holiday']['month'] ? ' selected="selected"' : '', '>', $txt['months'][$month], '</option>';
  72. echo '
  73. </select>&nbsp;
  74. ', $txt['calendar_day'], '&nbsp;
  75. <select name="day" id="day" onchange="generateDays();">';
  76. // This prints out all the days in the current month - this changes dynamically as we switch months.
  77. for ($day = 1; $day <= $context['holiday']['last_day']; $day++)
  78. echo '
  79. <option value="', $day, '"', $day == $context['holiday']['day'] ? ' selected="selected"' : '', '>', $day, '</option>';
  80. echo '
  81. </select>
  82. </dd>
  83. </dl>
  84. <hr class="hrcolor" />';
  85. if ($context['is_new'])
  86. echo '
  87. <input type="submit" value="', $txt['holidays_button_add'], '" class="button_submit" />';
  88. else
  89. echo '
  90. <input type="submit" name="edit" value="', $txt['holidays_button_edit'], '" class="button_submit" />
  91. <input type="submit" name="delete" value="', $txt['holidays_button_remove'], '" class="button_submit" />
  92. <input type="hidden" name="holiday" value="', $context['holiday']['id'], '" />';
  93. echo '
  94. <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '" />
  95. <br class="clear_right" />
  96. </div>
  97. <span class="botslice"><span></span></span>
  98. </div>
  99. </form>
  100. </div>
  101. <br class="clear" />';
  102. }
  103. ?>