Oppaitime's version of Gazelle
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

sitehistoryview.class.php 8.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243
  1. <?php
  2. class SiteHistoryView
  3. {
  4. public static function render_linkbox()
  5. {
  6. if (check_perms('users_mod')
  7. ) {
  8. ?>
  9. <div class="linkbox">
  10. <a href="sitehistory.php?action=edit" class="brackets">Create new event</a>
  11. </div>
  12. <?php
  13. }
  14. }
  15. public static function render_events($Events)
  16. {
  17. $Categories = SiteHistory::get_categories();
  18. $SubCategories = SiteHistory::get_sub_categories();
  19. $CanEdit = check_perms('users_mod');
  20. foreach ($Events as $Event) {
  21. ?>
  22. <div class="box">
  23. <div class="head colhead_dark">
  24. <div class="title">
  25. <?php if ($CanEdit) { ?>
  26. <a class="brackets" href="sitehistory.php?action=edit&amp;id=<?=$Event['ID']?>">Edit</a>
  27. <?php } ?>
  28. <?=date('F d, Y', strtotime($Event['Date'])); ?>
  29. -
  30. <a href="sitehistory.php?action=search&amp;category=<?=$Event['Category']?>" class="brackets"><?=$Categories[$Event['Category']]?></a>
  31. <a href="sitehistory.php?action=search&amp;subcategory=<?=$Event['SubCategory']?>" class="brackets"><?=$SubCategories[$Event['SubCategory']]?></a>
  32. <?php if (!empty($Event['Url'])) { ?>
  33. <a href="<?=$Event['Url']?>"><?=$Event['Title']?></a>
  34. <?php } else { ?>
  35. <?=$Event['Title']?>
  36. <?php } ?>
  37. </div>
  38. <div class="tags">
  39. <?php self::render_tags($Event['Tags'])?>
  40. </div>
  41. </div>
  42. <?php if (!empty($Event['Body'])) { ?>
  43. <div class="body">
  44. <?=Text::full_format($Event['Body'])?>
  45. </div>
  46. <?php } ?>
  47. </div>
  48. <?php
  49. }
  50. }
  51. private static function render_tags($Tags)
  52. {
  53. $Tags = explode(',', $Tags);
  54. natcasesort($Tags);
  55. $FormattedTags = '';
  56. foreach ($Tags as $Tag) {
  57. $FormattedTags .= "<a href=\"sitehistory.php?action=search&amp;tags=$Tag\">$Tag" . "</a>, ";
  58. }
  59. echo rtrim($FormattedTags, ', ');
  60. }
  61. public static function render_months($Months)
  62. {
  63. ?>
  64. <div class="box">
  65. <div class="head">Calendar</div>
  66. <div class="pad">
  67. <?php
  68. $Year = "";
  69. foreach ($Months as $Month) {
  70. if ($Month['Year'] != $Year) {
  71. $Year = $Month['Year'];
  72. echo "<h2>$Year</h2>";
  73. } ?>
  74. <a style="margin-left: 5px;" href="sitehistory.php?month=<?=$Month['Month']?>&amp;year=<?=$Month['Year']?>"><?=$Month['MonthName']?></a>
  75. <?php
  76. } ?>
  77. </div>
  78. </div>
  79. <?php
  80. }
  81. public static function render_search()
  82. {
  83. ?>
  84. <div class="box">
  85. <div class="head">Search</div>
  86. <div class="pad">
  87. <form class="search_form" action="sitehistory.php" method="get">
  88. <input type="hidden" name="action" value="search" />
  89. <input type="text" id="title" name="title" size="20" placeholder="Title" />
  90. <br /><br/>
  91. <input type="text" id="tags" name="tags" size="20" placeholder="Comma-separated tags" />
  92. <br /><br/>
  93. <select name="category" id="category">
  94. <option value="0">Choose a category</option>
  95. <?php
  96. $Categories = SiteHistory::get_categories();
  97. foreach ($Categories as $Key => $Value) {
  98. ?>
  99. <option<?=$Key == $Event['Category'] ? ' selected="selected"' : ''?> value="<?=$Key?>"><?=$Value?></option>
  100. <?php
  101. } ?>
  102. </select>
  103. <br /><br/>
  104. <select name="subcategory">
  105. <option value="0">Choose a subcategory</option>
  106. <?php
  107. $SubCategories = SiteHistory::get_sub_categories();
  108. foreach ($SubCategories as $Key => $Value) {
  109. ?>
  110. <option<?=$Key == $Event['SubCategory'] ? ' selected="selected"' : ''?> value="<?=$Key?>"><?=$Value?></option>
  111. <?php
  112. } ?>
  113. </select>
  114. <br /><br/>
  115. <input value="Search" type="submit" />
  116. </form>
  117. </div>
  118. </div>
  119. <?php
  120. }
  121. public static function render_edit_form($Event)
  122. {
  123. ?>
  124. <form id="event_form" method="post" action="">
  125. <?php if ($Event) { ?>
  126. <input type="hidden" name="action" value="take_edit" />
  127. <input type="hidden" name="id" value="<?=$Event['ID']?>" />
  128. <?php } else { ?>
  129. <input type="hidden" name="action" value="take_create" />
  130. <?php } ?>
  131. <input type="hidden" name="auth" value="<?=G::$LoggedUser['AuthKey']?>" />
  132. <table cellpadding="6" cellspacing="1" border="0" class="layout border" width="100%">
  133. <tr>
  134. <td class="label">Title:</td>
  135. <td>
  136. <input type="text" id="title" name="title" size="50" class="required" value="<?=$Event['Title']?>" />
  137. </td>
  138. </tr>
  139. <tr>
  140. <td class="label">Link:</td>
  141. <td>
  142. <input type="text" id="url" name="url" size="50" value="<?=$Event['Url']?>" />
  143. </td>
  144. </tr>
  145. <tr>
  146. <td class="label">Date:</td>
  147. <td>
  148. <input type="date" id="date" name="date" class="required"<?=$Event ? ' value="' . date('Y-m-d', strtotime($Event['Date'])) . '"' : ''?> />
  149. </td>
  150. </tr>
  151. <tr>
  152. <td class="label">Category:</td>
  153. <td>
  154. <select id="category" name="category" class="required">
  155. <option value="0">Choose a category</option>
  156. <?php
  157. $Categories = SiteHistory::get_categories();
  158. foreach ($Categories as $Key => $Value) {
  159. ?>
  160. <option<?=$Key == $Event['Category'] ? ' selected="selected"' : ''?> value="<?=$Key?>"><?=$Value?></option>
  161. <?php
  162. } ?>
  163. </select>
  164. </td>
  165. </tr>
  166. <tr>
  167. <td class="label">Subcategory:</td>
  168. <td>
  169. <select id="category" name="sub_category" class="required">
  170. <option value="0">Choose a subcategory</option>
  171. <?php $SubCategories = SiteHistory::get_sub_categories();
  172. foreach ($SubCategories as $Key => $Value) { ?>
  173. <option<?=$Key == $Event['SubCategory'] ? ' selected="selected"' : ''?> value="<?=$Key?>"><?=$Value?></option>
  174. <?php } ?>
  175. </select>
  176. </td>
  177. </tr>
  178. <tr>
  179. <td class="label">Tags:</td>
  180. <td>
  181. <input type="text" id="tags" name="tags" placeholder="Comma-separated tags; use periods/dots for spaces" size="50" value="<?=$Event['Tags']?>" />
  182. <select id="tag_list">
  183. <option>Choose tags</option>
  184. <?php
  185. $Tags = SiteHistory::get_tags();
  186. foreach ($Tags as $Tag) {
  187. ?>
  188. <option><?=$Tag?></option>
  189. <?php
  190. } ?>
  191. </select>
  192. </td>
  193. </tr>
  194. <tr>
  195. <td class="label">Body:</td>
  196. <td>
  197. <textarea id="body" name="body" cols="90" rows="8" tabindex="1" onkeyup="resize('body');"><?=$Event['Body']?></textarea>
  198. </td>
  199. </tr>
  200. </table>
  201. <input type="submit" name="submit" value="Submit" />
  202. <?php if ($Event) { ?>
  203. <input type="submit" name="delete" value="Delete" />
  204. <?php } ?>
  205. </form>
  206. <?php
  207. }
  208. public static function render_recent_sidebar($Events)
  209. {
  210. ?>
  211. <div class="box">
  212. <div class="head colhead_dark">
  213. <strong><a href="sitehistory.php">Latest site history</a></strong>
  214. </div>
  215. <ul class="stats nobullet">
  216. <?php
  217. $Categories = SiteHistory::get_categories();
  218. foreach ($Events as $Event) {
  219. ?>
  220. <li>
  221. <a href="sitehistory.php?action=search&amp;category=<?=$Event['Category']?>" class="brackets"><?=$Categories[$Event['Category']]?></a>
  222. <?php if (!empty($Event['Url'])) { ?>
  223. <a href="<?=$Event['Url']?>"><?=Format::cut_string($Event['Title'], 20)?></a>
  224. <?php } else { ?>
  225. <?=Format::cut_string($Event['Title'], 20)?>
  226. <?php } ?>
  227. </li>
  228. <?php
  229. } ?>
  230. </ul>
  231. </div>
  232. <?php
  233. }
  234. }