3 * @version $Id: grid.php 1795 2009-04-24 09:29:31Z fishbone $
4 * @package Joomla.Framework
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.
16 * Utility class for creating HTML Grids
19 * @package Joomla.Framework
26 * @param string The link title
27 * @param string The order field for the column
28 * @param string The current direction
29 * @param string The selected ordering
30 * @param string An optional task override
32 function sort( $title, $order, $direction = 'asc', $selected = 0, $task=NULL )
34 $direction = strtolower( $direction );
35 $images = array( 'sort_asc.png', 'sort_desc.png' );
36 $index = intval( $direction == 'desc' );
37 $direction = ($direction == 'desc') ? 'asc' : 'desc';
39 $html = '<a href="javascript:tableOrdering(\''.$order.'\',\''.$direction.'\',\''.$task.'\');" title="'.JText::_( 'Click to sort this column' ).'">';
40 $html .= JText::_( $title );
41 if ($order == $selected ) {
42 $html .= JHTML::_('image.administrator', $images[$index], '/images/', NULL, NULL);
49 * @param int The row index
50 * @param int The record id
52 * @param string The name of the form element
56 function id( $rowNum, $recId, $checkedOut=false, $name='cid' )
61 return '<input type="checkbox" id="cb'.$rowNum.'" name="'.$name.'[]" value="'.$recId.'" onclick="isChecked(this.checked);" />';
65 function access( &$row, $i, $archived = NULL )
67 if ( !$row->access ) {
68 $color_access = 'style="color: green;"';
69 $task_access = 'accessregistered';
70 } else if ( $row->access == 1 ) {
71 $color_access = 'style="color: red;"';
72 $task_access = 'accessspecial';
74 $color_access = 'style="color: black;"';
75 $task_access = 'accesspublic';
80 $href = JText::_( $row->groupname );
85 <a href="javascript:void(0);" onclick="return listItemTask(\'cb'. $i .'\',\''. $task_access .'\')" '. $color_access .'>
86 '. JText::_( $row->groupname ) .'</a>'
93 function checkedOut( &$row, $i, $identifier = 'id' )
95 $user =& JFactory::getUser();
96 $userid = $user->get('id');
99 if(is_a($row, 'JTable')) {
100 $result = $row->isCheckedOut($userid);
102 $result = JTable::isCheckedOut($userid, $row->checked_out);
107 $checked = JHTMLGrid::_checkedOut( $row );
109 $checked = JHTML::_('grid.id', $i, $row->$identifier );
115 function published( &$row, $i, $imgY = 'tick.png', $imgX = 'publish_x.png', $prefix='' )
117 $img = $row->published ? $imgY : $imgX;
118 $task = $row->published ? 'unpublish' : 'publish';
119 $alt = $row->published ? JText::_( 'Published' ) : JText::_( 'Unpublished' );
120 $action = $row->published ? JText::_( 'Unpublish Item' ) : JText::_( 'Publish item' );
123 <a href="javascript:void(0);" onclick="return listItemTask(\'cb'. $i .'\',\''. $prefix.$task .'\')" title="'. $action .'">
124 <img src="images/'. $img .'" border="0" alt="'. $alt .'" /></a>'
130 function state( $filter_state='*', $published='Published', $unpublished='Unpublished', $archived=NULL, $trashed=NULL )
132 $state[] = JHTML::_('select.option', '', '- '. JText::_( 'Select State' ) .' -' );
133 //Jinx : Why is this used ?
134 //$state[] = JHTML::_('select.option', '*', JText::_( 'Any' ) );
135 $state[] = JHTML::_('select.option', 'P', JText::_( $published ) );
136 $state[] = JHTML::_('select.option', 'U', JText::_( $unpublished ) );
139 $state[] = JHTML::_('select.option', 'A', JText::_( $archived ) );
143 $state[] = JHTML::_('select.option', 'T', JText::_( $trashed ) );
146 return JHTML::_('select.genericlist', $state, 'filter_state', 'class="inputbox" size="1" onchange="submitform( );"', 'value', 'text', $filter_state );
149 function order( $rows, $image='filesave.png', $task="saveorder" )
151 $image = JHTML::_('image.administrator', $image, '/images/', NULL, NULL, JText::_( 'Save Order' ) );
152 $href = '<a href="javascript:saveorder('.(count( $rows )-1).', \''.$task.'\')" title="'.JText::_( 'Save Order' ).'">'.$image.'</a>';
157 function _checkedOut( &$row, $overlib = 1 )
162 $text = addslashes(htmlspecialchars($row->editor));
164 $date = JHTML::_('date', $row->checked_out_time, JText::_('DATE_FORMAT_LC1') );
165 $time = JHTML::_('date', $row->checked_out_time, '%H:%M' );
167 $hover = '<span class="editlinktip hasTip" title="'. JText::_( 'Checked Out' ) .'::'. $text .'<br />'. $date .'<br />'. $time .'">';
169 $checked = $hover .'<img src="images/checked_out.png"/></span>';