PageRenderTime 42ms CodeModel.GetById 17ms RepoModel.GetById 0ms app.codeStats 0ms

/4.8/administrator/components/com_mambots/admin.mambots.html.php

http://miacms.googlecode.com/
PHP | 332 lines | 281 code | 16 blank | 35 comment | 21 complexity | 827b48fd9ae1bd29f9c961a2523cd21d MD5 | raw file
Possible License(s): LGPL-2.1, GPL-2.0, LGPL-2.0
  1. <?php
  2. /**
  3. * @package MiaCMS
  4. * @subpackage Mambots
  5. * @author MiaCMS see README.php
  6. * @copyright see README.php
  7. * See COPYRIGHT.php for copyright notices and details.
  8. * @license GNU/GPL Version 2, see LICENSE.php
  9. * MiaCMS is free software; you can redistribute it and/or
  10. * modify it under the terms of the GNU General Public License
  11. * as published by the Free Software Foundation; version 2 of the License.
  12. */
  13. /** ensure this file is being included by a parent file */
  14. defined( '_VALID_MOS' ) or die( 'Direct Access to this location is not allowed.' );
  15. class HTML_modules {
  16. /**
  17. * Writes a list of the defined modules
  18. * @param array An array of category objects
  19. */
  20. function showMambots( &$rows, $client, &$pageNav, $option, &$lists, $search ) {
  21. global $my, $mainframe;
  22. ?>
  23. <form action="index2.php" method="post" id="adminForm" name="adminForm">
  24. <table class="adminheading">
  25. <tr>
  26. <th class="modules">
  27. <?php echo T_('Mambot Manager')?> <small><small>[ <?php echo $client == 'admin' ? T_('Administrator') : T_('Site');?> ]</small></small>
  28. </th>
  29. <td>
  30. <?php echo T_('Filter:')?>
  31. </td>
  32. <td>
  33. <input type="text" id="search" name="search" value="<?php echo $search;?>" class="text_area" />
  34. </td>
  35. <td>
  36. <?php echo $lists['type'];?>
  37. </td>
  38. </tr>
  39. </table>
  40. <table class="adminlist">
  41. <tr>
  42. <th width="20">#</th>
  43. <th width="20">
  44. <input id="check_all" type="checkbox" name="toggle" value="" />
  45. </th>
  46. <th class="title">
  47. <?php echo T_('Mambot Name')?>
  48. </th>
  49. <th nowrap="nowrap" width="10%">
  50. <?php echo T_('Published')?>
  51. </th>
  52. <th colspan="2" nowrap="nowrap" width="5%">
  53. <?php echo T_('Reorder')?>
  54. </th>
  55. <th width="2%">
  56. <?php echo T_('Order')?>
  57. </th>
  58. <th width="1%">
  59. <img id="saveorder" class="saveorder-icon" src="images/filesave.png" width="16" height="16" alt="<?php echo T_('Save Order'); ?>" />
  60. </th>
  61. <th nowrap="nowrap" width="10%">
  62. <?php echo T_('Access')?>
  63. </th>
  64. <th nowrap="nowrap" align="left" width="10%">
  65. <?php echo T_('Type')?>
  66. </th>
  67. <th nowrap="nowrap" align="left" width="10%">
  68. <?php echo T_('File')?>
  69. </th>
  70. </tr>
  71. <?php
  72. $k = 0;
  73. for ($i=0, $n=count( $rows ); $i < $n; $i++) {
  74. $row = &$rows[$i];
  75. $link = htmlentities('index2.php?option=com_mambots&client='. $client .'&task=editA&hidemainmenu=1&id='. $row->id);
  76. $access = mosCommonHTML::AccessProcessing( $row, $i );
  77. $checked = mosCommonHTML::CheckedOutProcessing( $row, $i );
  78. $published = mosCommonHTML::PublishedProcessing( $row, $i );
  79. ?>
  80. <tr class="<?php echo "row$k"; ?>">
  81. <td align="right"><?php echo $pageNav->rowNumber( $i ); ?></td>
  82. <td>
  83. <?php echo $checked; ?>
  84. </td>
  85. <td>
  86. <?php
  87. if ( $row->checked_out && ( $row->checked_out != $my->id ) ) {
  88. echo $row->name;
  89. } else {
  90. ?>
  91. <a href="<?php echo $link; ?>">
  92. <?php echo $row->name; ?>
  93. </a>
  94. <?php
  95. }
  96. ?>
  97. </td>
  98. <td align="center">
  99. <?php echo $published;?>
  100. </td>
  101. <td>
  102. <?php echo $pageNav->orderUpIcon( $i, ($row->folder == @$rows[$i-1]->folder && $row->ordering > -10000 && $row->ordering < 10000) ); ?>
  103. </td>
  104. <td>
  105. <?php echo $pageNav->orderDownIcon( $i, $n, ($row->folder == @$rows[$i+1]->folder && $row->ordering > -10000 && $row->ordering < 10000) ); ?>
  106. </td>
  107. <td align="center" colspan="2">
  108. <input type="text" name="order[]" size="5" value="<?php echo $row->ordering; ?>" class="text_area" style="text-align: center" />
  109. </td>
  110. <td align="center">
  111. <?php echo $access;?>
  112. </td>
  113. <td align="left" nowrap="nowrap">
  114. <?php echo $row->folder;?>
  115. </td>
  116. <td align="left" nowrap="nowrap">
  117. <?php echo $row->element;?>
  118. </td>
  119. </tr>
  120. <?php
  121. $k = 1 - $k;
  122. }
  123. ?>
  124. </table>
  125. <?php echo $pageNav->getListFooter(); ?>
  126. <input type="hidden" name="option" value="<?php echo $option;?>" />
  127. <input type="hidden" name="task" value="" />
  128. <input type="hidden" name="client" value="<?php echo $client;?>" />
  129. <input type="hidden" id="boxchecked" name="boxchecked" value="0" />
  130. <input type="hidden" id="hidemainmenu" name="hidemainmenu" value="0" />
  131. </form>
  132. <?php
  133. $rowCount = count( $rows );
  134. $saveOrderCount = $rowCount - 1;
  135. $tag = <<<JSTAG
  136. <script type="text/javascript">
  137. //Setup the check all onclick handler
  138. YAHOO.util.Event.addListener("check_all", "click", function() {
  139. YAHOO.miacms.base.checkAll($rowCount);
  140. });
  141. //Setup filter event handlers
  142. YAHOO.util.Event.addListener("search", "change", function() {
  143. YAHOO.util.Dom.get("adminForm").submit();
  144. });
  145. YAHOO.util.Event.addListener("filter_type", "change", function() {
  146. YAHOO.util.Dom.get("adminForm").submit();
  147. });
  148. //Setup save icon event handler
  149. YAHOO.util.Event.addListener("saveorder", "click", function() {
  150. YAHOO.miacms.base.saveorder($saveOrderCount);
  151. });
  152. </script>
  153. JSTAG;
  154. $mainframe->addCustomFootTag($tag);
  155. }
  156. /**
  157. * Writes the edit form for new and existing module
  158. *
  159. * A new record is defined when <var>$row</var> is passed with the <var>id</var>
  160. * property set to 0.
  161. * @param mosCategory The category object
  162. * @param array <p>The modules of the left side. The array elements are in the form
  163. * <var>$leftorder[<i>order</i>] = <i>label</i></var>
  164. * where <i>order</i> is the module order from the db table and <i>label</i> is a
  165. * text label associciated with the order.</p>
  166. * @param array See notes for leftorder
  167. * @param array An array of select lists
  168. * @param object Parameters
  169. */
  170. function editMambot( &$row, &$lists, &$params, $option ) {
  171. global $mosConfig_live_site, $mainframe;
  172. $row->nameA = '';
  173. if ( $row->id ) {
  174. $row->nameA = '<small><small>[ '. $row->name .' ]</small></small>';
  175. }
  176. ?>
  177. <div id="overDiv" style="position:absolute; visibility:hidden; z-index:10000;"></div>
  178. <table class="adminheading">
  179. <tr>
  180. <th class="mambots">
  181. <?php echo T_('Site Mambot:')?>
  182. <small>
  183. <?php echo $row->id ? T_('Edit') : T_('New');?>
  184. </small>
  185. <?php echo $row->nameA; ?>
  186. </th>
  187. </tr>
  188. </table>
  189. <form action="index2.php" method="post" id="adminForm" name="adminForm">
  190. <table cellspacing="0" cellpadding="0" width="100%">
  191. <tr valign="top">
  192. <td width="60%" valign="top">
  193. <table class="adminform">
  194. <tr>
  195. <th colspan="2">
  196. <?php echo T_('Mambot Details'); ?>
  197. </th>
  198. <tr>
  199. <tr>
  200. <td width="100" align="left">
  201. <?php echo T_('Name:'); ?>
  202. </td>
  203. <td>
  204. <input class="text_area" type="text" name="name" size="35" value="<?php echo $row->name; ?>" />
  205. </td>
  206. </tr>
  207. <tr>
  208. <td valign="top" align="left">
  209. <?php echo T_('Folder:'); ?>
  210. </td>
  211. <td>
  212. <?php echo $lists['folder']; ?>
  213. </td>
  214. </tr>
  215. <tr>
  216. <td valign="top" align="left">
  217. <?php echo T_('Mambot file:'); ?>
  218. </td>
  219. <td>
  220. <input class="text_area" type="text" name="element" size="35" value="<?php echo $row->element; ?>" />.php
  221. </td>
  222. </tr>
  223. <tr>
  224. <td valign="top" align="left">
  225. <?php echo T_('Mambot Order:'); ?>
  226. </td>
  227. <td>
  228. <?php echo $lists['ordering']; ?>
  229. </td>
  230. </tr>
  231. <tr>
  232. <td valign="top" align="left">
  233. <?php echo T_('Access Level:'); ?>
  234. </td>
  235. <td>
  236. <?php echo $lists['access']; ?>
  237. </td>
  238. </tr>
  239. <tr>
  240. <td valign="top">
  241. <?php echo T_('Published:'); ?>
  242. </td>
  243. <td>
  244. <?php echo $lists['published']; ?>
  245. </td>
  246. </tr>
  247. <tr>
  248. <td valign="top" colspan="2">&nbsp;
  249. </td>
  250. </tr>
  251. <tr>
  252. <td valign="top">
  253. <?php echo T_('Description:'); ?>
  254. </td>
  255. <td>
  256. <?php echo $row->description; ?>
  257. </td>
  258. </tr>
  259. </table>
  260. </td>
  261. <td width="40%">
  262. <table class="adminform">
  263. <tr>
  264. <th colspan="2">
  265. <?php echo T_('Parameters'); ?>
  266. </th>
  267. <tr>
  268. <tr>
  269. <td>
  270. <?php
  271. if ( $row->id ) {
  272. echo $params->render();
  273. } else {
  274. echo '<i>'.T_('No Parameters').'</i>';
  275. }
  276. ?>
  277. </td>
  278. </tr>
  279. </table>
  280. </td>
  281. </tr>
  282. </table>
  283. <input type="hidden" name="option" value="<?php echo $option; ?>" />
  284. <input type="hidden" name="id" value="<?php echo $row->id; ?>" />
  285. <input type="hidden" name="client" value="<?php echo $row->client_id; ?>" />
  286. <input type="hidden" name="task" value="" />
  287. </form>
  288. <?php
  289. //Define heredoc vars
  290. $nameMsg = T_('Mambot must have a name');
  291. $filenameMsg = T_('Mambot must have a filename');
  292. $tag = <<<JSTAG
  293. <script type="text/javascript">
  294. YAHOO.util.Event.on(window, "load", function() {
  295. YAHOO.miacms.base.submitbutton = function(pressbutton) {
  296. if (pressbutton === "cancel") {
  297. YAHOO.miacms.base.submitform(pressbutton);
  298. return;
  299. }
  300. // validation
  301. var form = YAHOO.util.Dom.get("adminForm") || document.adminForm;
  302. if (YAHOO.miacms.base.trim(form.name.value) === "") {
  303. alert( '$nameMsg' );
  304. } else if (YAHOO.miacms.base.trim(form.element.value) === "") {
  305. alert( '$filenameMsg' );
  306. } else {
  307. YAHOO.miacms.base.submitform(pressbutton);
  308. }
  309. };
  310. });
  311. </script>
  312. JSTAG;
  313. $mainframe->addCustomFootTag($tag);
  314. }
  315. }
  316. ?>