| [ Index ] |
PHP Cross Reference of Joomla 1.5.26 DE |
[Summary view] [Print] [Text view]
1 <?php 2 /** 3 * @version $Id: grid.php 14401 2010-01-26 14:10:00Z louis $ 4 * @package Joomla.Framework 5 * @subpackage HTML 6 * @copyright Copyright (C) 2005 - 2010 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 defined('JPATH_BASE') or die(); 15 /** 16 * Utility class for creating HTML Grids 17 * 18 * @static 19 * @package Joomla.Framework 20 * @subpackage HTML 21 * @since 1.5 22 */ 23 class JHTMLGrid 24 { 25 /** 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 31 */ 32 function sort( $title, $order, $direction = 'asc', $selected = 0, $task=NULL ) 33 { 34 $direction = strtolower( $direction ); 35 $images = array( 'sort_asc.png', 'sort_desc.png' ); 36 $index = intval( $direction == 'desc' ); 37 $direction = ($direction == 'desc') ? 'asc' : 'desc'; 38 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); 43 } 44 $html .= '</a>'; 45 return $html; 46 } 47 48 /** 49 * @param int The row index 50 * @param int The record id 51 * @param boolean 52 * @param string The name of the form element 53 * 54 * @return string 55 */ 56 function id( $rowNum, $recId, $checkedOut=false, $name='cid' ) 57 { 58 if ( $checkedOut ) { 59 return ''; 60 } else { 61 return '<input type="checkbox" id="cb'.$rowNum.'" name="'.$name.'[]" value="'.$recId.'" onclick="isChecked(this.checked);" />'; 62 } 63 } 64 65 function access( &$row, $i, $archived = NULL ) 66 { 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'; 73 } else { 74 $color_access = 'style="color: black;"'; 75 $task_access = 'accesspublic'; 76 } 77 78 if ($archived == -1) 79 { 80 $href = JText::_( $row->groupname ); 81 } 82 else 83 { 84 $href = ' 85 <a href="javascript:void(0);" onclick="return listItemTask(\'cb'. $i .'\',\''. $task_access .'\')" '. $color_access .'> 86 '. JText::_( $row->groupname ) .'</a>' 87 ; 88 } 89 90 return $href; 91 } 92 93 function checkedOut( &$row, $i, $identifier = 'id' ) 94 { 95 $user =& JFactory::getUser(); 96 $userid = $user->get('id'); 97 98 $result = false; 99 if(is_a($row, 'JTable')) { 100 $result = $row->isCheckedOut($userid); 101 } else { 102 $result = JTable::isCheckedOut($userid, $row->checked_out); 103 } 104 105 $checked = ''; 106 if ( $result ) { 107 $checked = JHTMLGrid::_checkedOut( $row ); 108 } else { 109 $checked = JHTML::_('grid.id', $i, $row->$identifier ); 110 } 111 112 return $checked; 113 } 114 115 function published( &$row, $i, $imgY = 'tick.png', $imgX = 'publish_x.png', $prefix='' ) 116 { 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' ); 121 122 $href = ' 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>' 125 ; 126 127 return $href; 128 } 129 130 function state( $filter_state='*', $published='Published', $unpublished='Unpublished', $archived=NULL, $trashed=NULL ) 131 { 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 ) ); 137 138 if ($archived) { 139 $state[] = JHTML::_('select.option', 'A', JText::_( $archived ) ); 140 } 141 142 if ($trashed) { 143 $state[] = JHTML::_('select.option', 'T', JText::_( $trashed ) ); 144 } 145 146 return JHTML::_('select.genericlist', $state, 'filter_state', 'class="inputbox" size="1" onchange="submitform( );"', 'value', 'text', $filter_state ); 147 } 148 149 function order( $rows, $image='filesave.png', $task="saveorder" ) 150 { 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>'; 153 return $href; 154 } 155 156 157 function _checkedOut( &$row, $overlib = 1 ) 158 { 159 $hover = ''; 160 if ( $overlib ) 161 { 162 $text = addslashes(htmlspecialchars($row->editor)); 163 164 $date = JHTML::_('date', $row->checked_out_time, JText::_('DATE_FORMAT_LC1') ); 165 $time = JHTML::_('date', $row->checked_out_time, '%H:%M' ); 166 167 $hover = '<span class="editlinktip hasTip" title="'. JText::_( 'Checked Out' ) .'::'. $text .'<br />'. $date .'<br />'. $time .'">'; 168 } 169 $checked = $hover .'<img src="images/checked_out.png"/></span>'; 170 171 return $checked; 172 } 173 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Wed Mar 28 15:54:07 2012 | Cross-referenced by PHPXref 0.7.1 |