ManageScheduledTasks.template.php 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  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. // Template for listing all scheduled tasks.
  13. function template_view_scheduled_tasks()
  14. {
  15. global $context, $txt, $scripturl, $modSettings;
  16. // We completed some tasks?
  17. if (!empty($context['tasks_were_run']))
  18. {
  19. if (empty($context['scheduled_errors']))
  20. echo '
  21. <div class="infobox">
  22. ', $txt['scheduled_tasks_were_run'], '
  23. </div>';
  24. else
  25. {
  26. echo '
  27. <div class="errorbox" id="errors">
  28. <dl>
  29. <dt>
  30. <strong id="error_serious">', $txt['scheduled_tasks_were_run_errors'], '</strong>
  31. </dt>';
  32. foreach ($context['scheduled_errors'] as $task => $errors)
  33. {
  34. echo '
  35. <dd class="error">
  36. <strong>', isset($txt['scheduled_task_' . $task]) ? $txt['scheduled_task_' . $task] : $task, '</strong>
  37. <ul><li>', implode('</li><li>', $errors), '</li></ul>
  38. </dd>';
  39. }
  40. echo '
  41. </dl>
  42. </div>';
  43. }
  44. }
  45. template_show_list('scheduled_tasks');
  46. }
  47. // A template for, you guessed it, editing a task!
  48. function template_edit_scheduled_tasks()
  49. {
  50. global $context, $txt, $scripturl, $modSettings;
  51. // Starts off with general maintenance procedures.
  52. echo '
  53. <div id="admincenter">
  54. <form action="', $scripturl, '?action=admin;area=scheduledtasks;sa=taskedit;save;tid=', $context['task']['id'], '" method="post" accept-charset="', $context['character_set'], '">
  55. <div class="cat_bar">
  56. <h3 class="catbg">', $txt['scheduled_task_edit'], '</h3>
  57. </div>
  58. <div class="information">
  59. <em>', sprintf($txt['scheduled_task_time_offset'], $context['server_time']), ' </em>
  60. </div>
  61. <div class="windowbg">
  62. <div class="content">
  63. <dl class="settings">
  64. <dt>
  65. <strong>', $txt['scheduled_tasks_name'], ':</strong>
  66. </dt>
  67. <dd>
  68. ', $context['task']['name'], '<br />
  69. <span class="smalltext">', $context['task']['desc'], '</span>
  70. </dd>
  71. <dt>
  72. <strong><label for="regularity">', $txt['scheduled_task_edit_interval'], ':</label></strong>
  73. </dt>
  74. <dd>
  75. ', $txt['scheduled_task_edit_repeat'], '
  76. <input type="text" name="regularity" id="regularity" value="', empty($context['task']['regularity']) ? 1 : $context['task']['regularity'], '" onchange="if (this.value < 1) this.value = 1;" size="2" maxlength="2" class="input_text" />
  77. <select name="unit">
  78. <option value="0">', $txt['scheduled_task_edit_pick_unit'], '</option>
  79. <option value="0">---------------------</option>
  80. <option value="m" ', empty($context['task']['unit']) || $context['task']['unit'] == 'm' ? 'selected="selected"' : '', '>', $txt['scheduled_task_reg_unit_m'], '</option>
  81. <option value="h" ', $context['task']['unit'] == 'h' ? 'selected="selected"' : '', '>', $txt['scheduled_task_reg_unit_h'], '</option>
  82. <option value="d" ', $context['task']['unit'] == 'd' ? 'selected="selected"' : '', '>', $txt['scheduled_task_reg_unit_d'], '</option>
  83. <option value="w" ', $context['task']['unit'] == 'w' ? 'selected="selected"' : '', '>', $txt['scheduled_task_reg_unit_w'], '</option>
  84. </select>
  85. </dd>
  86. <dt>
  87. <strong><label for="start_time">', $txt['scheduled_task_edit_start_time'], ':</label></strong><br />
  88. <span class="smalltext">', $txt['scheduled_task_edit_start_time_desc'], '</span>
  89. </dt>
  90. <dd>
  91. <input type="text" name="offset" id="start_time" value="', $context['task']['offset_formatted'], '" size="6" maxlength="5" class="input_text" />
  92. </dd>
  93. <dt>
  94. <strong><label for="enabled">', $txt['scheduled_tasks_enabled'], ':</label></strong>
  95. </dt>
  96. <dd>
  97. <input type="checkbox" name="enabled" id="enabled" ', !$context['task']['disabled'] ? 'checked="checked"' : '', ' class="input_check" />
  98. </dd>
  99. </dl>
  100. <div class="righttext">
  101. <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '" />
  102. <input type="hidden" name="', $context['admin-st_token_var'], '" value="', $context['admin-st_token'], '" />
  103. <input type="submit" name="save" value="', $txt['scheduled_tasks_save_changes'], '" class="button_submit" />
  104. </div>
  105. </div>
  106. </div>
  107. </form>
  108. </div>';
  109. }
  110. ?>