PageRenderTime 57ms CodeModel.GetById 15ms RepoModel.GetById 1ms app.codeStats 0ms

/administrator/components/com_modules/admin.modules.html.php

https://github.com/adothompson/ucsc-identity-joomla
PHP | 621 lines | 538 code | 34 blank | 49 comment | 60 complexity | 99dc3cfddf7984fa5560857a2558bd3f MD5 | raw file
Possible License(s): LGPL-2.1
  1. <?php
  2. /**
  3. * @version $Id: admin.modules.html.php 10559 2008-07-16 20:57:43Z instance $
  4. * @package Joomla
  5. * @subpackage Modules
  6. * @copyright Copyright (C) 2005 - 2008 Open Source Matters. All rights reserved.
  7. * @license GNU/GPL, see LICENSE.php
  8. * Joomla! is free software. This version may have been modified pursuant
  9. * to the GNU General Public License, and as distributed it includes or
  10. * is derivative of works licensed under the GNU General Public License or
  11. * other free or open source software licenses.
  12. * See COPYRIGHT.php for copyright notices and details.
  13. */
  14. // no direct access
  15. defined( '_JEXEC' ) or die( 'Restricted access' );
  16. /**
  17. * @package Joomla
  18. * @subpackage Modules
  19. */
  20. class HTML_modules
  21. {
  22. /**
  23. * Writes a list of the defined modules
  24. * @param array An array of category objects
  25. */
  26. function view( &$rows, &$client, &$page, &$lists )
  27. {
  28. $user =& JFactory::getUser();
  29. //Ordering allowed ?
  30. $ordering = (($lists['order'] == 'm.position'));
  31. JHTML::_('behavior.tooltip');
  32. ?>
  33. <form action="index.php?option=com_modules" method="post" name="adminForm">
  34. <table>
  35. <tr>
  36. <td align="left" width="100%">
  37. <?php echo JText::_( 'Filter' ); ?>:
  38. <input type="text" name="search" id="search" value="<?php echo $lists['search'];?>" class="text_area" onchange="document.adminForm.submit();" />
  39. <button onclick="this.form.submit();"><?php echo JText::_( 'Go' ); ?></button>
  40. <button onclick="document.getElementById('search').value='';this.form.submit();"><?php echo JText::_( 'Reset' ); ?></button>
  41. </td>
  42. <td nowrap="nowrap">
  43. <?php
  44. echo $lists['assigned'];
  45. echo $lists['position'];
  46. echo $lists['type'];
  47. echo $lists['state'];
  48. ?>
  49. </td>
  50. </tr>
  51. </table>
  52. <table class="adminlist" cellspacing="1">
  53. <thead>
  54. <tr>
  55. <th width="20">
  56. <?php echo JText::_( 'NUM' ); ?>
  57. </th>
  58. <th width="20">
  59. <input type="checkbox" name="toggle" value="" onclick="checkAll(<?php echo count( $rows );?>);" />
  60. </th>
  61. <th class="title">
  62. <?php echo JHTML::_('grid.sort', 'Module Name', 'm.title', @$lists['order_Dir'], @$lists['order'] ); ?>
  63. </th>
  64. <th nowrap="nowrap" width="7%">
  65. <?php echo JHTML::_('grid.sort', 'Published', 'm.published', @$lists['order_Dir'], @$lists['order'] ); ?>
  66. </th>
  67. <th width="80" nowrap="nowrap">
  68. <?php echo JHTML::_('grid.sort', 'Order', 'm.position', @$lists['order_Dir'], @$lists['order'] ); ?>
  69. </th>
  70. <th width="1%">
  71. <?php echo JHTML::_('grid.order', $rows ); ?>
  72. </th>
  73. <?php
  74. if ( $client->id == 0 ) {
  75. ?>
  76. <th nowrap="nowrap" width="7%">
  77. <?php echo JHTML::_('grid.sort', 'Access', 'groupname', @$lists['order_Dir'], @$lists['order'] ); ?>
  78. </th>
  79. <?php
  80. }
  81. ?>
  82. <th nowrap="nowrap" width="7%">
  83. <?php echo JHTML::_('grid.sort', 'Position', 'm.position', @$lists['order_Dir'], @$lists['order'] ); ?>
  84. </th>
  85. <th nowrap="nowrap" width="5%">
  86. <?php echo JHTML::_('grid.sort', 'Pages', 'pages', @$lists['order_Dir'], @$lists['order'] ); ?>
  87. </th>
  88. <th nowrap="nowrap" width="10%" class="title">
  89. <?php echo JHTML::_('grid.sort', 'Type', 'm.module', @$lists['order_Dir'], @$lists['order'] ); ?>
  90. </th>
  91. <th nowrap="nowrap" width="1%">
  92. <?php echo JHTML::_('grid.sort', 'ID', 'm.id', @$lists['order_Dir'], @$lists['order'] ); ?>
  93. </th>
  94. </tr>
  95. </thead>
  96. <tfoot>
  97. <tr>
  98. <td colspan="12">
  99. <?php echo $page->getListFooter(); ?>
  100. </td>
  101. </tr>
  102. </tfoot>
  103. <tbody>
  104. <?php
  105. $k = 0;
  106. for ($i=0, $n=count( $rows ); $i < $n; $i++) {
  107. $row = &$rows[$i];
  108. $link = JRoute::_( 'index.php?option=com_modules&client='. $client->id .'&task=edit&cid[]='. $row->id );
  109. $access = JHTML::_('grid.access', $row, $i );
  110. $checked = JHTML::_('grid.checkedout', $row, $i );
  111. $published = JHTML::_('grid.published', $row, $i );
  112. ?>
  113. <tr class="<?php echo "row$k"; ?>">
  114. <td align="right">
  115. <?php echo $page->getRowOffset( $i ); ?>
  116. </td>
  117. <td width="20">
  118. <?php echo $checked; ?>
  119. </td>
  120. <td>
  121. <?php
  122. if ( JTable::isCheckedOut($user->get ('id'), $row->checked_out ) ) {
  123. echo $row->title;
  124. } else {
  125. ?>
  126. <span class="editlinktip hasTip" title="<?php echo JText::_( 'Edit Module' );?>::<?php echo $row->title; ?>">
  127. <a href="<?php echo $link; ?>">
  128. <?php echo $row->title; ?></a>
  129. </span>
  130. <?php
  131. }
  132. ?>
  133. </td>
  134. <td align="center">
  135. <?php echo $published;?>
  136. </td>
  137. <td class="order" colspan="2">
  138. <span><?php echo $page->orderUpIcon( $i, ($row->position == @$rows[$i-1]->position), 'orderup', 'Move Up', $ordering ); ?></span>
  139. <span><?php echo $page->orderDownIcon( $i, $n, ($row->position == @$rows[$i+1]->position),'orderdown', 'Move Down', $ordering ); ?></span>
  140. <?php $disabled = $ordering ? '' : 'disabled="disabled"'; ?>
  141. <input type="text" name="order[]" size="5" value="<?php echo $row->ordering; ?>" <?php echo $disabled ?> class="text_area" style="text-align: center" />
  142. </td>
  143. <?php
  144. if ( $client->id == 0 ) {
  145. ?>
  146. <td align="center">
  147. <?php echo $access;?>
  148. </td>
  149. <?php
  150. }
  151. ?>
  152. <td align="center">
  153. <?php echo $row->position; ?>
  154. </td>
  155. <td align="center">
  156. <?php
  157. if (is_null( $row->pages )) {
  158. echo JText::_( 'None' );
  159. } else if ($row->pages > 0) {
  160. echo JText::_( 'Varies' );
  161. } else {
  162. echo JText::_( 'All' );
  163. }
  164. ?>
  165. </td>
  166. <td>
  167. <?php echo $row->module ? $row->module : JText::_( 'User' );?>
  168. </td>
  169. <td>
  170. <?php echo $row->id;?>
  171. </td>
  172. </tr>
  173. <?php
  174. $k = 1 - $k;
  175. }
  176. ?>
  177. </tbody>
  178. </table>
  179. <input type="hidden" name="option" value="com_modules" />
  180. <input type="hidden" name="client" value="<?php echo $client->id;?>" />
  181. <input type="hidden" name="task" value="" />
  182. <input type="hidden" name="boxchecked" value="0" />
  183. <input type="hidden" name="filter_order" value="<?php echo $lists['order']; ?>" />
  184. <input type="hidden" name="filter_order_Dir" value="<?php echo $lists['order_Dir']; ?>" />
  185. <?php echo JHTML::_( 'form.token' ); ?>
  186. </form>
  187. <?php
  188. }
  189. /**
  190. * Writes the edit form for new and existing module
  191. *
  192. * A new record is defined when <var>$row</var> is passed with the <var>id</var>
  193. * property set to 0.
  194. * @param JTableCategory The category object
  195. * @param array <p>The modules of the left side. The array elements are in the form
  196. * <var>$leftorder[<i>order</i>] = <i>label</i></var>
  197. * where <i>order</i> is the module order from the db table and <i>label</i> is a
  198. * text label associciated with the order.</p>
  199. * @param array See notes for leftorder
  200. * @param array An array of select lists
  201. * @param object Parameters
  202. */
  203. function edit( &$model, &$row, &$orders2, &$lists, &$params, $client )
  204. {
  205. JRequest::setVar( 'hidemainmenu', 1 );
  206. // clean item data
  207. JFilterOutput::objectHTMLSafe( $row, ENT_QUOTES, 'content' );
  208. // Check for component metadata.xml file
  209. //$path = JApplicationHelper::getPath( 'mod'.$client->id.'_xml', $row->module );
  210. //$params = new JParameter( $row->params, $path );
  211. $document =& JFactory::getDocument();
  212. JHTML::_('behavior.combobox');
  213. jimport('joomla.html.pane');
  214. // TODO: allowAllClose should default true in J!1.6, so remove the array when it does.
  215. $pane = &JPane::getInstance('sliders', array('allowAllClose' => true));
  216. $editor =& JFactory::getEditor();
  217. JHTML::_('behavior.tooltip');
  218. ?>
  219. <script language="javascript" type="text/javascript">
  220. function submitbutton(pressbutton) {
  221. if ( ( pressbutton == 'save' || pressbutton == 'apply' ) && ( document.adminForm.title.value == "" ) ) {
  222. alert("<?php echo JText::_( 'Module must have a title', true ); ?>");
  223. } else {
  224. <?php
  225. if ($row->module == '' || $row->module == 'mod_custom') {
  226. echo $editor->save( 'content' );
  227. }
  228. ?>
  229. submitform(pressbutton);
  230. }
  231. }
  232. <!--
  233. var originalOrder = '<?php echo $row->ordering;?>';
  234. var originalPos = '<?php echo $row->position;?>';
  235. var orders = new Array(); // array in the format [key,value,text]
  236. <?php $i = 0;
  237. foreach ($orders2 as $k=>$items) {
  238. foreach ($items as $v) {
  239. echo "\n orders[".$i++."] = new Array( \"$k\",\"$v->value\",\"$v->text\" );";
  240. }
  241. }
  242. ?>
  243. //-->
  244. </script>
  245. <form action="index.php" method="post" name="adminForm">
  246. <div class="col width-50">
  247. <fieldset class="adminform">
  248. <legend><?php echo JText::_( 'Details' ); ?></legend>
  249. <table class="admintable" cellspacing="1">
  250. <tr>
  251. <td valign="top" class="key">
  252. <?php echo JText::_( 'Module Type' ); ?>:
  253. </td>
  254. <td>
  255. <strong>
  256. <?php echo JText::_($row->module); ?>
  257. </strong>
  258. </td>
  259. </tr>
  260. <tr>
  261. <td class="key">
  262. <label for="title">
  263. <?php echo JText::_( 'Title' ); ?>:
  264. </label>
  265. </td>
  266. <td>
  267. <input class="text_area" type="text" name="title" id="title" size="35" value="<?php echo $row->title; ?>" />
  268. </td>
  269. </tr>
  270. <tr>
  271. <td width="100" class="key">
  272. <?php echo JText::_( 'Show title' ); ?>:
  273. </td>
  274. <td>
  275. <?php echo $lists['showtitle']; ?>
  276. </td>
  277. </tr>
  278. <tr>
  279. <td valign="top" class="key">
  280. <?php echo JText::_( 'Published' ); ?>:
  281. </td>
  282. <td>
  283. <?php echo $lists['published']; ?>
  284. </td>
  285. </tr>
  286. <tr>
  287. <td valign="top" class="key">
  288. <label for="position" class="hasTip" title="<?php echo JText::_('MODULE_POSITION_TIP_TITLE', true); ?>::<?php echo JText::_('MODULE_POSITION_TIP_TEXT', true); ?>">
  289. <?php echo JText::_( 'Position' ); ?>:
  290. </label>
  291. </td>
  292. <td>
  293. <input type="text" id="position" class="combobox" name="position" value="<?php echo $row->position; ?>" />
  294. <ul id="combobox-position" style="display:none;"><?php
  295. $positions = $model->getPositions();
  296. for ($i=0,$n=count($positions);$i<$n;$i++) {
  297. echo '<li>',$positions[$i],'</li>';
  298. }
  299. ?></ul>
  300. </td>
  301. </tr>
  302. <tr>
  303. <td valign="top" class="key">
  304. <label for="ordering">
  305. <?php echo JText::_( 'Order' ); ?>:
  306. </label>
  307. </td>
  308. <td>
  309. <script language="javascript" type="text/javascript">
  310. <!--
  311. writeDynaList( 'class="inputbox" name="ordering" id="ordering" size="1"', orders, originalPos, originalPos, originalOrder );
  312. //-->
  313. </script>
  314. </td>
  315. </tr>
  316. <tr>
  317. <td valign="top" class="key">
  318. <label for="access">
  319. <?php echo JText::_( 'Access Level' ); ?>:
  320. </label>
  321. </td>
  322. <td>
  323. <?php echo $lists['access']; ?>
  324. </td>
  325. </tr>
  326. <tr>
  327. <td valign="top" class="key">
  328. <?php echo JText::_( 'ID' ); ?>:
  329. </td>
  330. <td>
  331. <?php echo $row->id; ?>
  332. </td>
  333. </tr>
  334. <tr>
  335. <td valign="top" class="key">
  336. <?php echo JText::_( 'Description' ); ?>:
  337. </td>
  338. <td>
  339. <?php echo JText::_($row->description); ?>
  340. </td>
  341. </tr>
  342. </table>
  343. </fieldset>
  344. <fieldset class="adminform">
  345. <legend><?php echo JText::_( 'Menu Assignment' ); ?></legend>
  346. <script type="text/javascript">
  347. function allselections() {
  348. var e = document.getElementById('selections');
  349. e.disabled = true;
  350. var i = 0;
  351. var n = e.options.length;
  352. for (i = 0; i < n; i++) {
  353. e.options[i].disabled = true;
  354. e.options[i].selected = true;
  355. }
  356. }
  357. function disableselections() {
  358. var e = document.getElementById('selections');
  359. e.disabled = true;
  360. var i = 0;
  361. var n = e.options.length;
  362. for (i = 0; i < n; i++) {
  363. e.options[i].disabled = true;
  364. e.options[i].selected = false;
  365. }
  366. }
  367. function enableselections() {
  368. var e = document.getElementById('selections');
  369. e.disabled = false;
  370. var i = 0;
  371. var n = e.options.length;
  372. for (i = 0; i < n; i++) {
  373. e.options[i].disabled = false;
  374. }
  375. }
  376. </script>
  377. <table class="admintable" cellspacing="1">
  378. <tr>
  379. <td valign="top" class="key">
  380. <?php echo JText::_( 'Menus' ); ?>:
  381. </td>
  382. <td>
  383. <?php if ($row->client_id != 1) : ?>
  384. <?php if ($row->pages == 'all') { ?>
  385. <label for="menus-all"><input id="menus-all" type="radio" name="menus" value="all" onclick="allselections();" checked="checked" /><?php echo JText::_( 'All' ); ?></label>
  386. <label for="menus-none"><input id="menus-none" type="radio" name="menus" value="none" onclick="disableselections();" /><?php echo JText::_( 'None' ); ?></label>
  387. <label for="menus-select"><input id="menus-select" type="radio" name="menus" value="select" onclick="enableselections();" /><?php echo JText::_( 'Select From List' ); ?></label>
  388. <?php } elseif ($row->pages == 'none') { ?>
  389. <label for="menus-all"><input id="menus-all" type="radio" name="menus" value="all" onclick="allselections();" /><?php echo JText::_( 'All' ); ?></label>
  390. <label for="menus-none"><input id="menus-none" type="radio" name="menus" value="none" onclick="disableselections();" checked="checked" /><?php echo JText::_( 'None' ); ?></label>
  391. <label for="menus-select"><input id="menus-select" type="radio" name="menus" value="select" onclick="enableselections();" /><?php echo JText::_( 'Select From List' ); ?></label>
  392. <?php } else { ?>
  393. <label for="menus-all"><input id="menus-all" type="radio" name="menus" value="all" onclick="allselections();" /><?php echo JText::_( 'All' ); ?></label>
  394. <label for="menus-none"><input id="menus-none" type="radio" name="menus" value="none" onclick="disableselections();" /><?php echo JText::_( 'None' ); ?></label>
  395. <label for="menus-select"><input id="menus-select" type="radio" name="menus" value="select" onclick="enableselections();" checked="checked" /><?php echo JText::_( 'Select From List' ); ?></label>
  396. <?php } ?>
  397. <?php endif; ?>
  398. </td>
  399. </tr>
  400. <tr>
  401. <td valign="top" class="key">
  402. <?php echo JText::_( 'Menu Selection' ); ?>:
  403. </td>
  404. <td>
  405. <?php echo $lists['selections']; ?>
  406. </td>
  407. </tr>
  408. </table>
  409. <?php if ($row->client_id != 1) : ?>
  410. <?php if ($row->pages == 'all') { ?>
  411. <script type="text/javascript">allselections();</script>
  412. <?php } elseif ($row->pages == 'none') { ?>
  413. <script type="text/javascript">disableselections();</script>
  414. <?php } else { ?>
  415. <?php } ?>
  416. <?php endif; ?>
  417. </fieldset>
  418. </div>
  419. <div class="col width-50">
  420. <fieldset class="adminform">
  421. <legend><?php echo JText::_( 'Parameters' ); ?></legend>
  422. <?php
  423. echo $pane->startPane("menu-pane");
  424. echo $pane->startPanel(JText :: _('Module Parameters'), "param-page");
  425. $p = $params;
  426. if($params = $p->render('params')) :
  427. echo $params;
  428. else :
  429. echo "<div style=\"text-align: center; padding: 5px; \">".JText::_('There are no parameters for this item')."</div>";
  430. endif;
  431. echo $pane->endPanel();
  432. if ($p->getNumParams('advanced')) {
  433. echo $pane->startPanel(JText :: _('Advanced Parameters'), "advanced-page");
  434. if($params = $p->render('params', 'advanced')) :
  435. echo $params;
  436. else :
  437. echo "<div style=\"text-align: center; padding: 5px; \">".JText::_('There are no advanced parameters for this item')."</div>";
  438. endif;
  439. echo $pane->endPanel();
  440. }
  441. if ($p->getNumParams('legacy')) {
  442. echo $pane->startPanel(JText :: _('Legacy Parameters'), "legacy-page");
  443. if($params = $p->render('params', 'legacy')) :
  444. echo $params;
  445. else :
  446. echo "<div style=\"text-align: center; padding: 5px; \">".JText::_('There are no legacy parameters for this item')."</div>";
  447. endif;
  448. echo $pane->endPanel();
  449. }
  450. if ($p->getNumParams('other')) {
  451. echo $pane->startPanel(JText :: _('Other Parameters'), "other-page");
  452. if($params = $p->render('params', 'other')) :
  453. echo $params;
  454. else :
  455. echo "<div style=\"text-align: center; padding: 5px; \">".JText::_('There are no other parameters for this item')."</div>";
  456. endif;
  457. echo $pane->endPanel();
  458. }
  459. echo $pane->endPane();
  460. ?>
  461. </fieldset>
  462. </div>
  463. <div class="clr"></div>
  464. <?php
  465. if ( !$row->module || $row->module == 'custom' || $row->module == 'mod_custom' ) {
  466. ?>
  467. <fieldset class="adminform">
  468. <legend><?php echo JText::_( 'Custom Output' ); ?></legend>
  469. <?php
  470. // parameters : areaname, content, width, height, cols, rows
  471. echo $editor->display( 'content', $row->content, '100%', '400', '60', '20', array('pagebreak', 'readmore') ) ;
  472. ?>
  473. </fieldset>
  474. <?php
  475. }
  476. ?>
  477. <input type="hidden" name="option" value="com_modules" />
  478. <input type="hidden" name="id" value="<?php echo $row->id; ?>" />
  479. <input type="hidden" name="cid[]" value="<?php echo $row->id; ?>" />
  480. <input type="hidden" name="original" value="<?php echo $row->ordering; ?>" />
  481. <input type="hidden" name="module" value="<?php echo $row->module; ?>" />
  482. <input type="hidden" name="task" value="" />
  483. <input type="hidden" name="client" value="<?php echo $client->id ?>" />
  484. <?php echo JHTML::_( 'form.token' ); ?>
  485. </form>
  486. <?php
  487. }
  488. function preview()
  489. {
  490. $editor =& JFactory::getEditor();
  491. ?>
  492. <script>
  493. var form = window.top.document.adminForm
  494. var title = form.title.value;
  495. var alltext = window.top.<?php echo $editor->getContent('text') ?>;
  496. </script>
  497. <table align="center" width="90%" cellspacing="2" cellpadding="2" border="0">
  498. <tr>
  499. <td class="contentheading" colspan="2"><script>document.write(title);</script></td>
  500. </tr>
  501. <tr>
  502. <script>document.write("<td valign=\"top\" height=\"90%\" colspan=\"2\">" + alltext + "</td>");</script>
  503. </tr>
  504. </table>
  505. <?php
  506. }
  507. /**
  508. /**
  509. * Displays a selection list for module types
  510. */
  511. function add(&$modules, $client)
  512. {
  513. JHTML::_('behavior.tooltip');
  514. ?>
  515. <form action="index.php" method="post" name="adminForm">
  516. <table class="adminlist" cellpadding="1" summary="Add Module">
  517. <thead>
  518. <tr>
  519. <th colspan="4">
  520. <?php echo JText::_('Modules'); ?>
  521. </th>
  522. </tr>
  523. </thead>
  524. <tfoot>
  525. <tr>
  526. <th colspan="4">&nbsp;
  527. </th>
  528. </tr>
  529. </tfoot>
  530. <tbody>
  531. <?php
  532. $altRow = 0;
  533. $count = count($modules);
  534. // Variable-column ready, just pass $cols in.
  535. $cols = 2;
  536. $pct = floor(100 / $cols);
  537. $rows = ceil($count / $cols);
  538. $posn = 0;
  539. do {
  540. ?>
  541. <tr class="<?php echo 'row' . $altRow; ?>" valign="top">
  542. <?php
  543. $altRow = 1 - $altRow;
  544. for ($col = 0; $col < $cols; ++$col) :
  545. if (($mod = $posn + $col * $rows) >= $count) :
  546. ?>
  547. <td width="<?php echo $pct; ?>%">&nbsp;</td>
  548. <?php
  549. continue;
  550. endif;
  551. $item = &$modules[$mod];
  552. $link = 'index.php?option=com_modules&amp;task=edit&amp;module='
  553. . $item->module . '&amp;created=1&amp;client=' . $client->id;
  554. ?>
  555. <td width="<?php echo $pct; ?>%">
  556. <span class="editlinktip hasTip" title="<?php
  557. echo htmlspecialchars($item->name . ' :: '
  558. . JText::_(stripslashes($item->descrip)), ENT_QUOTES, 'UTF-8');
  559. ?>" name="module" value="<?php
  560. echo $item->module;
  561. ?>" onclick="isChecked(this.checked);">
  562. <input type="radio" name="module" value="<?php
  563. echo $item->module;
  564. ?>" id="cb<?php echo $mod; ?>"/><a href="<?php
  565. echo $link;
  566. ?>"><?php echo htmlspecialchars($item->name, ENT_QUOTES, 'UTF-8'); ?></a></span>
  567. </td>
  568. <?php
  569. endfor;
  570. ++$posn;
  571. ?>
  572. </tr>
  573. <?php
  574. } while ($posn < $rows);
  575. ?>
  576. </tbody>
  577. </table>
  578. <input type="hidden" name="option" value="com_modules" />
  579. <input type="hidden" name="client" value="<?php echo $client->id; ?>" />
  580. <input type="hidden" name="created" value="1" />
  581. <input type="hidden" name="task" value="edit" />
  582. <input type="hidden" name="boxchecked" value="0" />
  583. <?php echo JHTML::_('form.token'); ?>
  584. </form>
  585. <?php
  586. }
  587. }