BioTorrents.de’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 7.0KB

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