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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236
  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_search() { ?>
  65. <div class="box">
  66. <div class="head">Search</div>
  67. <div class="pad">
  68. <form class="search_form" action="sitehistory.php" method="get">
  69. <input type="hidden" name="action" value="search" />
  70. <input type="text" id="title" name="title" size="20" placeholder="Title" />
  71. <br /><br />
  72. <input type="text" id="tags" name="tags" size="20" placeholder="Comma-separated tags" />
  73. <br /><br />
  74. <select name="category" id="category">
  75. <option value="0">Choose a category</option>
  76. <?php
  77. $Categories = SiteHistory::get_categories();
  78. foreach ($Categories as $Key => $Value) {
  79. ?>
  80. <option<?=$Key == $Event['Category'] ? ' selected="selected"' : ''?>
  81. value="<?=$Key?>"><?=$Value?>
  82. </option>
  83. <?php
  84. } ?>
  85. </select>
  86. <br /><br />
  87. <select name="subcategory">
  88. <option value="0">Choose a subcategory</option>
  89. <?php
  90. $SubCategories = SiteHistory::get_sub_categories();
  91. foreach ($SubCategories as $Key => $Value) {
  92. ?>
  93. <option<?=$Key == $Event['SubCategory'] ? ' selected="selected"' : ''?>
  94. value="<?=$Key?>"><?=$Value?>
  95. </option>
  96. <?php
  97. } ?>
  98. </select>
  99. <br /><br />
  100. <input value="Search" type="submit" />
  101. </form>
  102. </div>
  103. </div>
  104. <?php }
  105. public static function render_edit_form($Event) { ?>
  106. <form id="event_form" method="post" action="">
  107. <?php if ($Event) { ?>
  108. <input type="hidden" name="action" value="take_edit" />
  109. <input type="hidden" name="id"
  110. value="<?=$Event['ID']?>" />
  111. <?php } else { ?>
  112. <input type="hidden" name="action" value="take_create" />
  113. <?php } ?>
  114. <input type="hidden" name="auth"
  115. value="<?=G::$LoggedUser['AuthKey']?>" />
  116. <table cellpadding="6" cellspacing="1" border="0" class="layout border" width="100%">
  117. <tr>
  118. <td class="label">Title:</td>
  119. <td>
  120. <input type="text" id="title" name="title" size="50" class="required"
  121. value="<?=$Event['Title']?>" />
  122. </td>
  123. </tr>
  124. <tr>
  125. <td class="label">Link:</td>
  126. <td>
  127. <input type="text" id="url" name="url" size="50"
  128. value="<?=$Event['Url']?>" />
  129. </td>
  130. </tr>
  131. <tr>
  132. <td class="label">Date:</td>
  133. <td>
  134. <input type="date" id="date" name="date" class="required" <?=$Event ? ' value="' . date('Y-m-d', strtotime($Event['Date'])) . '"' : ''?>
  135. />
  136. </td>
  137. </tr>
  138. <tr>
  139. <td class="label">Category:</td>
  140. <td>
  141. <select id="category" name="category" class="required">
  142. <option value="0">Choose a category</option>
  143. <?php
  144. $Categories = SiteHistory::get_categories();
  145. foreach ($Categories as $Key => $Value) {
  146. ?>
  147. <option<?=$Key == $Event['Category'] ? ' selected="selected"' : ''?>
  148. value="<?=$Key?>"><?=$Value?>
  149. </option>
  150. <?php
  151. } ?>
  152. </select>
  153. </td>
  154. </tr>
  155. <tr>
  156. <td class="label">Subcategory:</td>
  157. <td>
  158. <select id="category" name="sub_category" class="required">
  159. <option value="0">Choose a subcategory</option>
  160. <?php $SubCategories = SiteHistory::get_sub_categories();
  161. foreach ($SubCategories as $Key => $Value) { ?>
  162. <option<?=$Key == $Event['SubCategory'] ? ' selected="selected"' : ''?>
  163. value="<?=$Key?>"><?=$Value?>
  164. </option>
  165. <?php } ?>
  166. </select>
  167. </td>
  168. </tr>
  169. <tr>
  170. <td class="label">Tags:</td>
  171. <td>
  172. <input type="text" id="tags" name="tags" placeholder="Comma-separated tags; use periods/dots for spaces"
  173. size="50"
  174. value="<?=$Event['Tags']?>" />
  175. <select id="tag_list">
  176. <option>Choose tags</option>
  177. <?php
  178. $Tags = SiteHistory::get_tags();
  179. foreach ($Tags as $Tag) {
  180. ?>
  181. <option><?=$Tag?>
  182. </option>
  183. <?php
  184. } ?>
  185. </select>
  186. </td>
  187. </tr>
  188. <tr>
  189. <td class="label">Body:</td>
  190. <td>
  191. <textarea id="body" name="body" cols="90" rows="8" tabindex="1"
  192. onkeyup="resize('body');"><?=$Event['Body']?></textarea>
  193. </td>
  194. </tr>
  195. </table>
  196. <input type="submit" name="submit" value="Submit" />
  197. <?php if ($Event) { ?>
  198. <input type="submit" name="delete" value="Delete" />
  199. <?php } ?>
  200. </form>
  201. <?php
  202. }
  203. public static function render_recent_sidebar($Events) { ?>
  204. <div class="box">
  205. <div class="head colhead_dark">
  206. <strong><a href="sitehistory.php">Latest site history</a></strong>
  207. </div>
  208. <ul class="stats nobullet">
  209. <?php
  210. $Categories = SiteHistory::get_categories();
  211. foreach ($Events as $Event) {
  212. ?>
  213. <li>
  214. <a href="sitehistory.php?action=search&amp;category=<?=$Event['Category']?>"
  215. class="brackets"><?=$Categories[$Event['Category']]?></a>
  216. <?php if (!empty($Event['Url'])) { ?>
  217. <a href="<?=$Event['Url']?>"><?=Format::cut_string($Event['Title'], 20)?></a>
  218. <?php } else { ?>
  219. <?=Format::cut_string($Event['Title'], 20)?>
  220. <?php } ?>
  221. </li>
  222. <?php
  223. } ?>
  224. </ul>
  225. </div>
  226. <?php
  227. }
  228. }