PageRenderTime 64ms CodeModel.GetById 22ms RepoModel.GetById 0ms app.codeStats 0ms

/4.6/components/com_weblinks/weblinks.html.php

http://miacms.googlecode.com/
PHP | 327 lines | 273 code | 19 blank | 35 comment | 31 complexity | 4c8aaed7f1c5585d42e387dbac02c93b MD5 | raw file
Possible License(s): LGPL-2.1, GPL-2.0, LGPL-2.0
  1. <?php
  2. /**
  3. * @package MiaCMS
  4. * @subpackage Weblinks
  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. require_once( $GLOBALS['mosConfig_absolute_path'] . '/includes/HTML_toolbar.php' );
  16. class HTML_weblinks {
  17. function displaylist( &$categories, &$rows, $catid, $currentcat=NULL, &$params, $tabclass ) {
  18. global $Itemid, $mosConfig_live_site, $hide_js;
  19. if ( $params->get( 'page_title' ) ) {
  20. ?>
  21. <div class="componentheading<?php echo $params->get( 'pageclass_sfx' ); ?>">
  22. <?php echo $currentcat->header; ?>
  23. </div>
  24. <?php
  25. }
  26. ?>
  27. <form action="index.php" method="post" name="adminForm">
  28. <table width="100%" cellpadding="4" cellspacing="0" border="0" align="center" class="contentpane<?php echo $params->get( 'pageclass_sfx' ); ?>">
  29. <tr>
  30. <td width="60%" valign="top" class="contentdescription<?php echo $params->get( 'pageclass_sfx' ); ?>" colspan="2">
  31. <?php
  32. // show image
  33. if ( $currentcat->img ) {
  34. ?>
  35. <img src="<?php echo $currentcat->img; ?>" align="<?php echo $currentcat->align; ?>" hspace="6" alt="<?php echo T_('Web Links'); ?>" />
  36. <?php
  37. }
  38. echo $currentcat->descrip;
  39. ?>
  40. </td>
  41. </tr>
  42. <tr>
  43. <td>
  44. <?php
  45. if ( count( $rows ) ) {
  46. HTML_weblinks::showTable( $params, $rows, $catid, $tabclass );
  47. }
  48. ?>
  49. </td>
  50. </tr>
  51. <tr>
  52. <td>&nbsp;
  53. </td>
  54. </tr>
  55. <tr>
  56. <td>
  57. <?php
  58. // Displays listing of Categories
  59. if ( ( $params->get( 'type' ) == 'category' ) && $params->get( 'other_cat' ) ) {
  60. HTML_weblinks::showCategories( $params, $categories, $catid );
  61. } else if ( ( $params->get( 'type' ) == 'section' ) && $params->get( 'other_cat_section' ) ) {
  62. HTML_weblinks::showCategories( $params, $categories, $catid );
  63. }
  64. ?>
  65. </td>
  66. </tr>
  67. </table>
  68. </form>
  69. <?php
  70. // displays back button
  71. mosHTML::BackButton ( $params, $hide_js );
  72. }
  73. /**
  74. * Display Table of items
  75. */
  76. function showTable( &$params, &$rows, $catid, $tabclass ) {
  77. global $mosConfig_live_site;
  78. // icon in table display
  79. if ( $params->get( 'weblink_icons' ) <> -1 ) {
  80. $mainframe =& mosMainFrame::getInstance();
  81. $img = $mainframe->ImageCheck( 'weblink.png', '/images/M_images/', $params->get( 'weblink_icons' ) );
  82. } else {
  83. $img = NULL;
  84. }
  85. ?>
  86. <table width="100%" border="0" cellspacing="0" cellpadding="0">
  87. <?php
  88. if ( $params->get( 'headings' ) ) {
  89. ?>
  90. <tr>
  91. <?php
  92. if ( $img ) {
  93. ?>
  94. <td class="sectiontableheader<?php echo $params->get( 'pageclass_sfx' ); ?>">&nbsp;
  95. </td>
  96. <?php
  97. }
  98. ?>
  99. <td width="90%" height="20" class="sectiontableheader<?php echo $params->get( 'pageclass_sfx' ); ?>">
  100. <?php echo T_('Web Link'); ?>
  101. </td>
  102. <?php
  103. if ( $params->get( 'hits' ) ) {
  104. ?>
  105. <td width="30px" height="20" class="sectiontableheader<?php echo $params->get( 'pageclass_sfx' ); ?>" align="right">
  106. <?php echo T_('Hits'); ?>
  107. </td>
  108. <?php
  109. }
  110. ?>
  111. </tr>
  112. <?php
  113. }
  114. $k = 0;
  115. foreach ($rows as $row) {
  116. $iparams =& new mosParameters( $row->params );
  117. $link = sefRelToAbs( 'index.php?option=com_weblinks&task=view&catid='. $catid .'&id='. $row->id );
  118. $menuclass = 'category'.$params->get( 'pageclass_sfx' );
  119. switch ($iparams->get( 'target' )) {
  120. // cases are slightly different
  121. case 1:
  122. // open in a new window
  123. $txt = '<a href="'. $link .'" target="_blank" class="'. $menuclass .'">'. stripslashes($row->title) .'</a>';
  124. break;
  125. case 2:
  126. // open in a popup window
  127. $txt = "<a href=\"#\" onclick=\"javascript: window.open('". $link ."', '', 'toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=780,height=550'); return false\" class=\"$menuclass\">". stripslashes($row->title) ."</a>\n";
  128. break;
  129. default: // formerly case 2
  130. // open in parent window
  131. $txt = '<a href="'. $link .'" class="'. $menuclass .'">'. stripslashes($row->title) .'</a>';
  132. break;
  133. }
  134. ?>
  135. <tr class="<?php echo $tabclass[$k]; ?>">
  136. <?php
  137. if ( $img ) {
  138. ?>
  139. <td width="100px" height="20" align="center">
  140. &nbsp;&nbsp;<?php echo $img;?>&nbsp;&nbsp;
  141. </td>
  142. <?php
  143. }
  144. ?>
  145. <td height="20">
  146. <?php echo $txt; ?>
  147. <?php
  148. if ( $params->get( 'item_description' ) ) {
  149. ?>
  150. <br />
  151. <?php echo $row->description; ?>
  152. <?php
  153. }
  154. ?>
  155. </td>
  156. <?php
  157. if ( $params->get( 'hits' ) ) {
  158. ?>
  159. <td align="center">
  160. <?php echo $row->hits; ?>
  161. </td>
  162. <?php
  163. }
  164. ?>
  165. </tr>
  166. <?php
  167. $k = 1 - $k;
  168. }
  169. ?>
  170. </table>
  171. <?php
  172. }
  173. /**
  174. * Display links to categories
  175. */
  176. function showCategories( &$params, &$categories, $catid ) {
  177. global $mosConfig_live_site, $Itemid;
  178. ?>
  179. <ul>
  180. <?php
  181. if ($categories) {
  182. foreach ( $categories as $cat ) {
  183. if ( $catid == $cat->catid ) {
  184. ?>
  185. <li>
  186. <strong>
  187. <?php echo $cat->name;?>
  188. </strong>
  189. &nbsp;
  190. <span class="small">
  191. (<?php echo $cat->numlinks;?>)
  192. </span>
  193. </li>
  194. <?php
  195. } else {
  196. $link = 'index.php?option=com_weblinks&catid='. $cat->catid .'&Itemid='. $Itemid;
  197. ?>
  198. <li>
  199. <a href="<?php echo sefRelToAbs( $link ); ?>" class="category<?php echo $params->get( 'pageclass_sfx' ); ?>">
  200. <?php echo $cat->name;?>
  201. </a>
  202. &nbsp;
  203. <span class="small">
  204. (<?php echo $cat->numlinks;?>)
  205. </span>
  206. </li>
  207. <?php
  208. }
  209. }
  210. } else {
  211. echo T_('There are currently no links');
  212. }
  213. ?>
  214. </ul>
  215. <?php
  216. }
  217. /**
  218. * Writes the edit form for new and existing record (FRONTEND)
  219. *
  220. * A new record is defined when <var>$row</var> is passed with the <var>id</var>
  221. * property set to 0.
  222. * @param mosWeblink The weblink object
  223. * @param string The html for the categories select list
  224. */
  225. function editWeblink( $option, &$row, &$lists ) {
  226. $Returnid = intval( mosGetParam( $_REQUEST, 'Returnid', 0 ) );
  227. ?>
  228. <form action="<?php echo sefRelToAbs("index.php"); ?>" method="post" name="adminForm" id="adminForm">
  229. <table cellpadding="0" cellspacing="0" border="0" width="100%">
  230. <tr>
  231. <td class="contentheading">
  232. <?php echo T_('Submit A Web Link'); ?>
  233. </td>
  234. <td width="10%">
  235. <?php
  236. mosToolBar::startTable();
  237. mosToolBar::spacer();
  238. mosToolBar::save();
  239. mosToolBar::cancel();
  240. mosToolBar::endtable();
  241. ?>
  242. </td>
  243. </tr>
  244. </table>
  245. <table cellpadding="4" cellspacing="1" border="0" width="100%">
  246. <tr>
  247. <td width="20%" align="right">
  248. <?php echo T_('Name:'); ?>
  249. </td>
  250. <td width="80%">
  251. <input class="inputbox" type="text" name="title" size="50" maxlength="250" value="<?php echo htmlspecialchars( stripslashes($row->title));?>" />
  252. </td>
  253. </tr>
  254. <tr>
  255. <td valign="top" align="right">
  256. <?php echo T_('Category:'); ?>
  257. </td>
  258. <td>
  259. <?php echo $lists['catid']; ?>
  260. </td>
  261. </tr>
  262. <tr>
  263. <td valign="top" align="right">
  264. <?php echo T_('URL:'); ?>
  265. </td>
  266. <td>
  267. <input class="inputbox" type="text" name="url" value="<?php echo $row->url; ?>" size="50" maxlength="250" />
  268. </td>
  269. </tr>
  270. <tr>
  271. <td valign="top" align="right">
  272. <?php echo T_('Description:'); ?>
  273. </td>
  274. <td>
  275. <textarea class="inputbox" cols="30" rows="6" name="description" style="width:300px" width="300"><?php echo htmlspecialchars( $row->description, ENT_QUOTES );?></textarea>
  276. </td>
  277. </tr>
  278. </table>
  279. <input type="hidden" name="id" value="<?php echo $row->id; ?>" />
  280. <input type="hidden" name="option" value="<?php echo $option;?>" />
  281. <input type="hidden" name="task" value="" />
  282. <input type="hidden" name="ordering" value="<?php echo $row->ordering; ?>" />
  283. <input type="hidden" name="approved" value="<?php echo $row->approved; ?>" />
  284. <input type="hidden" name="Returnid" value="<?php echo $Returnid; ?>" />
  285. </form>
  286. <script type="text/javascript">
  287. YAHOO.miacms.base.submitbutton = function(pressbutton) {
  288. var form = YAHOO.util.Dom.get("adminForm");
  289. if (pressbutton === 'cancel') {
  290. YAHOO.miacms.base.submitform( pressbutton );
  291. return;
  292. }
  293. // do field validation
  294. if (YAHOO.miacms.base.trim(form.title.value) === ""){
  295. alert( '<?php echo T_("Web Link item must have a title"); ?>' );
  296. } else if (YAHOO.miacms.base.getSelectedValue('adminForm','catid') < 1) {
  297. alert( '<?php echo T_("You must select a category."); ?>' );
  298. } else if (YAHOO.miacms.base.trim(form.url.value) === ""){
  299. alert( '<?php echo T_("You must have a url."); ?>' );
  300. } else {
  301. YAHOO.miacms.base.submitform( pressbutton );
  302. }
  303. };
  304. </script>
  305. <?php
  306. }
  307. }
  308. ?>