PageRenderTime 46ms CodeModel.GetById 19ms RepoModel.GetById 0ms app.codeStats 0ms

/administrator/components/com_frontpage/views/frontpage.php

https://github.com/navinpai/GEC-Tandav
PHP | 263 lines | 225 code | 14 blank | 24 comment | 43 complexity | af09d44f27382b5d3b8da753305011f0 MD5 | raw file
  1. <?php
  2. /**
  3. * @version $Id: frontpage.php 11655 2009-03-08 20:04:17Z willebil $
  4. * @package Joomla
  5. * @subpackage Content
  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 Content
  19. */
  20. class FrontpageView
  21. {
  22. /**
  23. * Writes a list of the articles
  24. * @param array An array of content objects
  25. */
  26. function showList( &$rows, $page, $option, $lists )
  27. {
  28. $limitstart = JRequest::getVar('limitstart', '0', '', 'int');
  29. $user =& JFactory::getUser();
  30. $db =& JFactory::getDBO();
  31. $nullDate = $db->getNullDate();
  32. $config =& JFactory::getConfig();
  33. $now =& JFactory::getDate();
  34. //Ordering allowed ?
  35. $ordering = (($lists['order'] == 'fpordering'));
  36. JHTML::_('behavior.tooltip');
  37. ?>
  38. <form action="index.php?option=com_frontpage" method="post" name="adminForm">
  39. <table>
  40. <tr>
  41. <td width="100%" class="filter">
  42. <?php echo JText::_( 'Filter' ); ?>:
  43. <input type="text" name="search" id="search" value="<?php echo $lists['search'];?>" class="text_area" onchange="document.adminForm.submit();" />
  44. <button onclick="this.form.submit();"><?php echo JText::_( 'Go' ); ?></button>
  45. <button onclick="document.getElementById('search').value=''; this.form.getElementById('filter_sectionid').value='-1'; this.form.getElementById('catid').value='0'; this.form.getElementById('filter_authorid').value='0'; this.form.getElementById('filter_state').value=''; this.form.submit();"><?php echo JText::_( 'Reset' ); ?></button>
  46. </td>
  47. <td nowrap="nowrap">
  48. <?php
  49. echo $lists['sectionid'];
  50. echo $lists['catid'];
  51. echo $lists['authorid'];
  52. echo $lists['state'];
  53. ?>
  54. </td>
  55. </tr>
  56. </table>
  57. <table class="adminlist">
  58. <thead>
  59. <tr>
  60. <th width="5">
  61. <?php echo JText::_( 'Num' ); ?>
  62. </th>
  63. <th width="20">
  64. <input type="checkbox" name="toggle" value="" onclick="checkAll(<?php echo count( $rows ); ?>);" />
  65. </th>
  66. <th class="title">
  67. <?php echo JHTML::_('grid.sort', 'Title', 'c.title', @$lists['order_Dir'], @$lists['order'] ); ?>
  68. </th>
  69. <th width="10%" nowrap="nowrap">
  70. <?php echo JHTML::_('grid.sort', 'Published', 'c.state', @$lists['order_Dir'], @$lists['order'] ); ?>
  71. </th>
  72. <th width="80" nowrap="nowrap">
  73. <?php echo JHTML::_('grid.sort', 'Order', 'fpordering', @$lists['order_Dir'], @$lists['order'] ); ?>
  74. </th>
  75. <th width="1%">
  76. <?php if ($ordering) echo JHTML::_('grid.order', $rows ); ?>
  77. </th>
  78. <th width="8%" nowrap="nowrap">
  79. <?php echo JHTML::_('grid.sort', 'Access', 'groupname', @$lists['order_Dir'], @$lists['order'] ); ?>
  80. </th>
  81. <th width="2%" class="title" align="center" nowrap="nowrap">
  82. <?php echo JHTML::_('grid.sort', 'ID', 'c.id', @$lists['order_Dir'], @$lists['order'] ); ?>
  83. </th>
  84. <th width="10%" class="title">
  85. <?php echo JHTML::_('grid.sort', 'Section', 'sect_name', @$lists['order_Dir'], @$lists['order'] ); ?>
  86. </th>
  87. <th width="10%" class="title">
  88. <?php echo JHTML::_('grid.sort', 'Category', 'cc.name', @$lists['order_Dir'], @$lists['order'] ); ?>
  89. </th>
  90. <th width="10%" class="title">
  91. <?php echo JHTML::_('grid.sort', 'Author', 'author', @$lists['order_Dir'], @$lists['order'] ); ?>
  92. </th>
  93. </tr>
  94. </thead>
  95. <tfoot>
  96. <tr>
  97. <td colspan="13">
  98. <?php echo $page->getListFooter(); ?>
  99. </td>
  100. </tr>
  101. </tfoot>
  102. <tbody>
  103. <?php
  104. $k = 0;
  105. for ($i=0, $n=count( $rows ); $i < $n; $i++)
  106. {
  107. $row = &$rows[$i];
  108. $link = JRoute::_( 'index.php?option=com_content&task=edit&cid[]='. $row->id );
  109. $publish_up =& JFactory::getDate($row->publish_up);
  110. $publish_down =& JFactory::getDate($row->publish_down);
  111. $publish_up->setOffset($config->getValue('config.offset'));
  112. $publish_down->setOffset($config->getValue('config.offset'));
  113. if ( $now->toUnix() <= $publish_up->toUnix() && $row->state == 1 ) {
  114. $img = 'publish_y.png';
  115. $alt = JText::_( 'Published' );
  116. } else if ( ( $now->toUnix() <= $publish_down->toUnix() || $row->publish_down == $nullDate ) && $row->state == 1 ) {
  117. $img = 'publish_g.png';
  118. $alt = JText::_( 'Published' );
  119. } else if ( $now->toUnix() > $publish_down->toUnix() && $row->state == 1 ) {
  120. $img = 'publish_r.png';
  121. $alt = JText::_( 'Expired' );
  122. } else if ( $row->state == 0 ) {
  123. $img = 'publish_x.png';
  124. $alt = JText::_( 'Unpublished' );
  125. } else if ( $row->state == -1 ) {
  126. $img = 'disabled.png';
  127. $alt = JText::_( 'Archived' );
  128. }
  129. $times = '';
  130. if (isset($row->publish_up)) {
  131. if ($row->publish_up == $nullDate) {
  132. $times .= JText::_( 'Start: Always' );
  133. } else {
  134. $times .= JText::_( 'Start' ) .": ". $publish_up->toFormat();
  135. }
  136. }
  137. if (isset($row->publish_down)) {
  138. if ($row->publish_down == $nullDate) {
  139. $times .= "<br />". JText::_( 'Finish: No Expiry' );
  140. } else {
  141. $times .= "<br />". JText::_( 'Finish' ) .": ". $publish_down->toFormat();
  142. }
  143. }
  144. $access = JHTML::_('grid.access', $row, $i );
  145. $checked = JHTML::_('grid.checkedout', $row, $i );
  146. if ( $user->authorize( 'com_users', 'manage' ) ) {
  147. if ( $row->created_by_alias ) {
  148. $author = $row->created_by_alias;
  149. } else {
  150. $linkA = JRoute::_( 'index.php?option=com_users&task=edit&cid[]='. $row->created_by );
  151. $author='<span class="editlinktip hasTip" title="'.JText::_( 'Edit User' ).'::'.$row->author.'">' .
  152. '<a href="'. $linkA .'">'. $row->author .'</a><span>';
  153. }
  154. } else {
  155. if ( $row->created_by_alias ) {
  156. $author = $row->created_by_alias;
  157. } else {
  158. $author = $row->author;
  159. }
  160. }
  161. // section handling
  162. if ($row->sectionid) {
  163. $row->sect_link = JRoute::_( 'index.php?option=com_sections&task=edit&cid[]='. $row->sectionid );
  164. $title_sec = JText::_( 'Edit Section' );
  165. }
  166. // category handling
  167. if ($row->catid) {
  168. $row->cat_link = JRoute::_( 'index.php?option=com_categories&task=edit&cid[]='. $row->catid );
  169. $title_cat = JText::_( 'Edit Category' );
  170. }
  171. ?>
  172. <tr class="<?php echo "row$k"; ?>">
  173. <td>
  174. <?php echo $page->getRowOffset( $i ); ?>
  175. </td>
  176. <td>
  177. <?php echo $checked; ?>
  178. </td>
  179. <td>
  180. <?php
  181. if ( JTable::isCheckedOut($user->get ('id'), $row->checked_out ) ) {
  182. echo $row->title;
  183. } else {
  184. ?>
  185. <span class="editlinktip hasTip" title="<?php echo JText::_( 'Edit Content' );?>::<?php echo $row->name; ?>">
  186. <a href="<?php echo $link; ?>">
  187. <?php echo $row->title; ?></a></span>
  188. <?php
  189. }
  190. ?>
  191. </td>
  192. <?php
  193. if ( $times ) {
  194. ?>
  195. <td align="center">
  196. <span class="editlinktip hasTip" title="<?php echo JText::_( 'Publish Information' );?>::<?php echo $times; ?>">
  197. <a href="javascript:void(0);" onclick="return listItemTask('cb<?php echo $i;?>','<?php echo $row->state ? 'unpublish' : 'publish' ?>')">
  198. <img src="images/<?php echo $img;?>" width="16" height="16" border="0" alt="<?php echo $alt;?>" /></a></span>
  199. </td>
  200. <?php
  201. }
  202. ?>
  203. <td class="order" colspan="2">
  204. <span><?php echo $page->orderUpIcon( $i, true, 'orderup', 'Move Up', $ordering ); ?></span>
  205. <span><?php echo $page->orderDownIcon( $i, $n, true, 'orderdown', 'Move Down', $ordering ); ?></span>
  206. <?php $disabled = $ordering ? '' : 'disabled="disabled"'; ?>
  207. <input type="text" name="order[]" size="5" value="<?php echo $row->fpordering;?>" <?php echo $disabled ?> class="text_area" style="text-align: center" />
  208. </td>
  209. <td align="center">
  210. <?php echo $access;?>
  211. </td>
  212. <td align="center">
  213. <?php echo $row->id;?>
  214. </td>
  215. <td>
  216. <?php if ($row->sectionid) : ?>
  217. <span class="editlinktip hasTip" title="<?php echo $title_sec; ?>::<?php echo $row->sect_name; ?>">
  218. <a href="<?php echo $row->sect_link; ?>">
  219. <?php echo $row->sect_name; ?></a></span>
  220. <?php endif; ?>
  221. </td>
  222. <td>
  223. <?php if ($row->catid) : ?>
  224. <span class="editlinktip hasTip" title="<?php echo $title_cat; ?>::<?php echo $row->name; ?>">
  225. <a href="<?php echo $row->cat_link; ?>" title="<?php echo $title_cat; ?>">
  226. <?php echo $row->name; ?></a></span>
  227. <?php endif; ?>
  228. </td>
  229. <td>
  230. <?php echo $author; ?>
  231. </td>
  232. </tr>
  233. <?php
  234. $k = 1 - $k;
  235. }
  236. ?>
  237. </tbody>
  238. </table>
  239. <?php JHTML::_('content.legend'); ?>
  240. <input type="hidden" name="option" value="<?php echo $option;?>" />
  241. <input type="hidden" name="task" value="" />
  242. <input type="hidden" name="boxchecked" value="0" />
  243. <input type="hidden" name="filter_order" value="<?php echo $lists['order']; ?>" />
  244. <input type="hidden" name="filter_order_Dir" value="<?php echo $lists['order_Dir']; ?>" />
  245. <?php echo JHTML::_( 'form.token' ); ?>
  246. </form>
  247. <?php
  248. }
  249. }