Files
@ 1db340eef40b
Branch filter:
Location: hot67beta/libraries/joomla/html/html/grid.php
1db340eef40b
5.2 KiB
text/x-php
add mtop
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 | <?php
/**
* @version $Id: grid.php 10381 2008-06-01 03:35:53Z pasamio $
* @package Joomla.Framework
* @subpackage HTML
* @copyright Copyright (C) 2005 - 2008 Open Source Matters. All rights reserved.
* @license GNU/GPL, see LICENSE.php
* Joomla! is free software. This version may have been modified pursuant
* to the GNU General Public License, and as distributed it includes or
* is derivative of works licensed under the GNU General Public License or
* other free or open source software licenses.
* See COPYRIGHT.php for copyright notices and details.
*/
/**
* Utility class for creating HTML Grids
*
* @static
* @package Joomla.Framework
* @subpackage HTML
* @since 1.5
*/
class JHTMLGrid
{
/**
* @param string The link title
* @param string The order field for the column
* @param string The current direction
* @param string The selected ordering
* @param string An optional task override
*/
function sort( $title, $order, $direction = 'asc', $selected = 0, $task=NULL )
{
$direction = strtolower( $direction );
$images = array( 'sort_asc.png', 'sort_desc.png' );
$index = intval( $direction == 'desc' );
$direction = ($direction == 'desc') ? 'asc' : 'desc';
$html = '<a href="javascript:tableOrdering(\''.$order.'\',\''.$direction.'\',\''.$task.'\');" title="'.JText::_( 'Click to sort this column' ).'">';
$html .= JText::_( $title );
if ($order == $selected ) {
$html .= JHTML::_('image.administrator', $images[$index], '/images/', NULL, NULL);
}
$html .= '</a>';
return $html;
}
/**
* @param int The row index
* @param int The record id
* @param boolean
* @param string The name of the form element
*
* @return string
*/
function id( $rowNum, $recId, $checkedOut=false, $name='cid' )
{
if ( $checkedOut ) {
return '';
} else {
return '<input type="checkbox" id="cb'.$rowNum.'" name="'.$name.'[]" value="'.$recId.'" onclick="isChecked(this.checked);" />';
}
}
function access( &$row, $i, $archived = NULL )
{
if ( !$row->access ) {
$color_access = 'style="color: green;"';
$task_access = 'accessregistered';
} else if ( $row->access == 1 ) {
$color_access = 'style="color: red;"';
$task_access = 'accessspecial';
} else {
$color_access = 'style="color: black;"';
$task_access = 'accesspublic';
}
if ($archived == -1)
{
$href = JText::_( $row->groupname );
}
else
{
$href = '
<a href="javascript:void(0);" onclick="return listItemTask(\'cb'. $i .'\',\''. $task_access .'\')" '. $color_access .'>
'. JText::_( $row->groupname ) .'</a>'
;
}
return $href;
}
function checkedOut( &$row, $i, $identifier = 'id' )
{
$user =& JFactory::getUser();
$userid = $user->get('id');
$result = false;
if(is_a($row, 'JTable')) {
$result = $row->isCheckedOut($userid);
} else {
$result = JTable::isCheckedOut($userid, $row->checked_out);
}
$checked = '';
if ( $result ) {
$checked = JHTMLGrid::_checkedOut( $row );
} else {
$checked = JHTML::_('grid.id', $i, $row->$identifier );
}
return $checked;
}
function published( &$row, $i, $imgY = 'tick.png', $imgX = 'publish_x.png', $prefix='' )
{
$img = $row->published ? $imgY : $imgX;
$task = $row->published ? 'unpublish' : 'publish';
$alt = $row->published ? JText::_( 'Published' ) : JText::_( 'Unpublished' );
$action = $row->published ? JText::_( 'Unpublish Item' ) : JText::_( 'Publish item' );
$href = '
<a href="javascript:void(0);" onclick="return listItemTask(\'cb'. $i .'\',\''. $prefix.$task .'\')" title="'. $action .'">
<img src="images/'. $img .'" border="0" alt="'. $alt .'" /></a>'
;
return $href;
}
function state( $filter_state='*', $published='Published', $unpublished='Unpublished', $archived=NULL, $trashed=NULL )
{
$state[] = JHTML::_('select.option', '', '- '. JText::_( 'Select State' ) .' -' );
//Jinx : Why is this used ?
//$state[] = JHTML::_('select.option', '*', JText::_( 'Any' ) );
$state[] = JHTML::_('select.option', 'P', JText::_( $published ) );
$state[] = JHTML::_('select.option', 'U', JText::_( $unpublished ) );
if ($archived) {
$state[] = JHTML::_('select.option', 'A', JText::_( $archived ) );
}
if ($trashed) {
$state[] = JHTML::_('select.option', 'T', JText::_( $trashed ) );
}
return JHTML::_('select.genericlist', $state, 'filter_state', 'class="inputbox" size="1" onchange="submitform( );"', 'value', 'text', $filter_state );
}
function order( $rows, $image='filesave.png', $task="saveorder" )
{
$image = JHTML::_('image.administrator', $image, '/images/', NULL, NULL, JText::_( 'Save Order' ) );
$href = '<a href="javascript:saveorder('.(count( $rows )-1).', \''.$task.'\')" title="'.JText::_( 'Save Order' ).'">'.$image.'</a>';
return $href;
}
function _checkedOut( &$row, $overlib = 1 )
{
$hover = '';
if ( $overlib )
{
$text = addslashes(htmlspecialchars($row->editor));
$date = JHTML::_('date', $row->checked_out_time, '%A, %d %B %Y' );
$time = JHTML::_('date', $row->checked_out_time, '%H:%M' );
$hover = '<span class="editlinktip hasTip" title="'. JText::_( 'Checked Out' ) .'::'. $text .'<br />'. $date .'<br />'. $time .'">';
}
$checked = $hover .'<img src="images/checked_out.png"/></span>';
return $checked;
}
}
|