pluginsadmin.html 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205
  1. <!DOCTYPE html>
  2. <html>
  3. <head>{include="includes"}</head>
  4. <body>
  5. <div id="pageheader">
  6. {include="page.header"}
  7. </div>
  8. <noscript>
  9. <div>
  10. <ul class="errors">
  11. <li>You need to enable Javascript to change plugin loading order.</li>
  12. </ul>
  13. </div>
  14. <div class="clear"></div>
  15. </noscript>
  16. <div id="pluginsadmin">
  17. <form action="?do=save_pluginadmin" method="POST">
  18. <section id="enabled_plugins">
  19. <h1>Enabled Plugins</h1>
  20. <div>
  21. {if="count($enabledPlugins)==0"}
  22. <p>No plugin enabled.</p>
  23. {else}
  24. <table id="plugin_table">
  25. <thead>
  26. <tr>
  27. <th class="center">Disable</th>
  28. <th class="center">Order</th>
  29. <th>Name</th>
  30. <th>Description</th>
  31. </tr>
  32. </thead>
  33. <tbody>
  34. {loop="$enabledPlugins"}
  35. <tr data-line="{$key}" data-order="{$counter}">
  36. <td class="center"><input type="checkbox" name="{$key}" id="{$key}" checked="checked"></td>
  37. <td class="center">
  38. <a href="#" class="arrow"
  39. onclick="return orderUp(this.parentNode.parentNode.getAttribute('data-order'));">
  40. </a>
  41. <a href="#" class="arrow"
  42. onclick="return orderDown(this.parentNode.parentNode.getAttribute('data-order'));">
  43. </a>
  44. <input type="hidden" name="order_{$key}" value="{$counter}">
  45. </td>
  46. <td><label for="{$key}">{function="str_replace('_', ' ', $key)"}</label></td>
  47. <td><label for="{$key}">{$value.description}</label></td>
  48. </tr>
  49. {/loop}
  50. </tbody>
  51. </table>
  52. {/if}
  53. </div>
  54. </section>
  55. <section id="disabled_plugins">
  56. <h1>Disabled Plugins</h1>
  57. <div>
  58. {if="count($disabledPlugins)==0"}
  59. <p>No plugin disabled.</p>
  60. {else}
  61. <table>
  62. <tr>
  63. <th class="center">Enable</th>
  64. <th>Name</th>
  65. <th>Description</th>
  66. </tr>
  67. {loop="$disabledPlugins"}
  68. <tr>
  69. <td class="center"><input type="checkbox" name="{$key}" id="{$key}"></td>
  70. <td><label for="{$key}">{function="str_replace('_', ' ', $key)"}</label></td>
  71. <td><label for="{$key}">{$value.description}</label></td>
  72. </tr>
  73. {/loop}
  74. </table>
  75. {/if}
  76. </div>
  77. <div class="center">
  78. <input type="submit" value="Save"/>
  79. </div>
  80. </section>
  81. </form>
  82. <form action="?do=save_pluginadmin" method="POST">
  83. <section id="plugin_parameters">
  84. <h1>Enabled Plugin Parameters</h1>
  85. <div>
  86. {if="count($enabledPlugins)==0"}
  87. <p>No plugin enabled.</p>
  88. {else}
  89. {loop="$enabledPlugins"}
  90. {if="count($value.parameters) > 0"}
  91. <div class="plugin_parameters">
  92. <h2>{function="str_replace('_', ' ', $key)"}</h2>
  93. {loop="$value.parameters"}
  94. <div class="plugin_parameter">
  95. <div class="float_label">
  96. <label for="{$key}">
  97. <code>{$key}</code><br>
  98. {if="isset($value.desc)"}
  99. {$value.desc}
  100. {/if}
  101. </label>
  102. </div>
  103. <div class="float_input">
  104. <input name="{$key}" value="{$value.value}" id="{$key}"/>
  105. </div>
  106. </div>
  107. {/loop}
  108. </div>
  109. {/if}
  110. {/loop}
  111. {/if}
  112. <div class="center">
  113. <input type="submit" name="parameters_form" value="Save"/>
  114. </div>
  115. </div>
  116. </section>
  117. </form>
  118. </div>
  119. {include="page.footer"}
  120. <script>
  121. /**
  122. * Change the position counter of a row.
  123. *
  124. * @param elem Element Node to change.
  125. * @param toPos int New position.
  126. */
  127. function changePos(elem, toPos) {
  128. var elemName = elem.getAttribute('data-line');
  129. elem.setAttribute('data-order', toPos);
  130. var hiddenInput = document.querySelector('[name="order_' + elemName + '"]');
  131. hiddenInput.setAttribute('value', toPos);
  132. }
  133. /**
  134. * Move a row up or down.
  135. *
  136. * @param pos Element Node to move.
  137. * @param move int Move: +1 (down) or -1 (up)
  138. */
  139. function changeOrder(pos, move) {
  140. var newpos = parseInt(pos) + move;
  141. var lines = document.querySelectorAll('[data-order="' + pos + '"]');
  142. var changelines = document.querySelectorAll('[data-order="' + newpos + '"]');
  143. // If we go down reverse lines to preserve the rows order
  144. if (move > 0) {
  145. lines = [].slice.call(lines).reverse();
  146. }
  147. for (var i = 0; i < lines.length; i++) {
  148. var parent = changelines[0].parentNode;
  149. changePos(lines[i], newpos);
  150. changePos(changelines[i], parseInt(pos));
  151. var changeItem = move < 0 ? changelines[0] : changelines[changelines.length - 1].nextSibling;
  152. parent.insertBefore(lines[i], changeItem);
  153. }
  154. }
  155. /**
  156. * Move a row up in the table.
  157. *
  158. * @param pos int row counter.
  159. *
  160. * @returns false
  161. */
  162. function orderUp(pos) {
  163. if (pos == 0) {
  164. return false;
  165. }
  166. changeOrder(pos, -1);
  167. return false;
  168. }
  169. /**
  170. * Move a row down in the table.
  171. *
  172. * @param pos int row counter.
  173. *
  174. * @returns false
  175. */
  176. function orderDown(pos) {
  177. var lastpos = document.querySelector('[data-order]:last-child').getAttribute('data-order');
  178. if (pos == lastpos) {
  179. return false;
  180. }
  181. changeOrder(pos, +1);
  182. return false;
  183. }
  184. </script>
  185. </body>
  186. </html>