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.5KB

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