| [ Index ] |
PHP Cross Reference of Joomla 1.5.26 DE |
[Summary view] [Print] [Text view]
1 <?php 2 /** 3 * @version $Id: list.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 15 // no direct access 16 defined( '_JEXEC' ) or die( 'Restricted access' ); 17 18 /** 19 * Utility class for creating different select lists 20 * 21 * @static 22 * @package Joomla.Framework 23 * @subpackage HTML 24 * @since 1.5 25 */ 26 class JHTMLList 27 { 28 /** 29 * Build the select list for access level 30 */ 31 function accesslevel( &$row ) 32 { 33 $db =& JFactory::getDBO(); 34 35 $query = 'SELECT id AS value, name AS text' 36 . ' FROM #__groups' 37 . ' ORDER BY id' 38 ; 39 $db->setQuery( $query ); 40 $groups = $db->loadObjectList(); 41 $access = JHTML::_('select.genericlist', $groups, 'access', 'class="inputbox" size="3"', 'value', 'text', intval( $row->access ), '', 1 ); 42 43 return $access; 44 } 45 46 /** 47 * Build the select list to choose an image 48 */ 49 function images( $name, $active = NULL, $javascript = NULL, $directory = NULL, $extensions = "bmp|gif|jpg|png" ) 50 { 51 if ( !$directory ) { 52 $directory = '/images/stories/'; 53 } 54 55 if ( !$javascript ) { 56 $javascript = "onchange=\"javascript:if (document.forms.adminForm." . $name . ".options[selectedIndex].value!='') {document.imagelib.src='..$directory' + document.forms.adminForm." . $name . ".options[selectedIndex].value} else {document.imagelib.src='../images/blank.png'}\""; 57 } 58 59 jimport( 'joomla.filesystem.folder' ); 60 $imageFiles = JFolder::files( JPATH_SITE.DS.$directory ); 61 $images = array( JHTML::_('select.option', '', '- '. JText::_( 'Select Image' ) .' -' ) ); 62 foreach ( $imageFiles as $file ) { 63 if ( preg_match( "#$extensions#i", $file ) ) { 64 $images[] = JHTML::_('select.option', $file ); 65 } 66 } 67 $images = JHTML::_('select.genericlist', $images, $name, 'class="inputbox" size="1" '. $javascript, 'value', 'text', $active ); 68 69 return $images; 70 } 71 72 /** 73 * Description 74 * 75 * @param string SQL with ordering As value and 'name field' AS text 76 * @param integer The length of the truncated headline 77 * @since 1.5 78 */ 79 function genericordering( $sql, $chop = '30' ) 80 { 81 $db =& JFactory::getDBO(); 82 $order = array(); 83 $db->setQuery( $sql ); 84 if (!($orders = $db->loadObjectList())) { 85 if ($db->getErrorNum()) { 86 echo $db->stderr(); 87 return false; 88 } else { 89 $order[] = JHTML::_('select.option', 1, JText::_( 'first' ) ); 90 return $order; 91 } 92 } 93 $order[] = JHTML::_('select.option', 0, '0 '. JText::_( 'first' ) ); 94 for ($i=0, $n=count( $orders ); $i < $n; $i++) { 95 96 if (JString::strlen($orders[$i]->text) > $chop) { 97 $text = JString::substr($orders[$i]->text,0,$chop)."..."; 98 } else { 99 $text = $orders[$i]->text; 100 } 101 102 $order[] = JHTML::_('select.option', $orders[$i]->value, $orders[$i]->value.' ('.$text.')' ); 103 } 104 $order[] = JHTML::_('select.option', $orders[$i-1]->value+1, ($orders[$i-1]->value+1).' '. JText::_( 'last' ) ); 105 106 return $order; 107 } 108 109 /** 110 * Build the select list for Ordering of a specified Table 111 */ 112 function specificordering( &$row, $id, $query, $neworder = 0 ) 113 { 114 $db =& JFactory::getDBO(); 115 116 if ( $id ) { 117 $order = JHTML::_('list.genericordering', $query ); 118 $ordering = JHTML::_('select.genericlist', $order, 'ordering', 'class="inputbox" size="1"', 'value', 'text', intval( $row->ordering ) ); 119 } else { 120 if ( $neworder ) { 121 $text = JText::_( 'descNewItemsFirst' ); 122 } else { 123 $text = JText::_( 'descNewItemsLast' ); 124 } 125 $ordering = '<input type="hidden" name="ordering" value="'. $row->ordering .'" />'. $text; 126 } 127 return $ordering; 128 } 129 130 /** 131 * Select list of active users 132 */ 133 function users( $name, $active, $nouser = 0, $javascript = NULL, $order = 'name', $reg = 1 ) 134 { 135 $db =& JFactory::getDBO(); 136 137 $and = ''; 138 if ( $reg ) { 139 // does not include registered users in the list 140 $and = ' AND gid > 18'; 141 } 142 143 $query = 'SELECT id AS value, name AS text' 144 . ' FROM #__users' 145 . ' WHERE block = 0' 146 . $and 147 . ' ORDER BY '. $order 148 ; 149 $db->setQuery( $query ); 150 if ( $nouser ) { 151 $users[] = JHTML::_('select.option', '0', '- '. JText::_( 'No User' ) .' -' ); 152 $users = array_merge( $users, $db->loadObjectList() ); 153 } else { 154 $users = $db->loadObjectList(); 155 } 156 157 $users = JHTML::_('select.genericlist', $users, $name, 'class="inputbox" size="1" '. $javascript, 'value', 'text', $active ); 158 159 return $users; 160 } 161 162 /** 163 * Select list of positions - generally used for location of images 164 */ 165 function positions( $name, $active = NULL, $javascript = NULL, $none = 1, $center = 1, $left = 1, $right = 1, $id = false ) 166 { 167 if ( $none ) { 168 $pos[] = JHTML::_('select.option', '', JText::_( 'None' ) ); 169 } 170 if ( $center ) { 171 $pos[] = JHTML::_('select.option', 'center', JText::_( 'Center' ) ); 172 } 173 if ( $left ) { 174 $pos[] = JHTML::_('select.option', 'left', JText::_( 'Left' ) ); 175 } 176 if ( $right ) { 177 $pos[] = JHTML::_('select.option', 'right', JText::_( 'Right' ) ); 178 } 179 180 $positions = JHTML::_('select.genericlist', $pos, $name, 'class="inputbox" size="1"'. $javascript, 'value', 'text', $active, $id ); 181 182 return $positions; 183 } 184 185 /** 186 * Select list of active categories for components 187 */ 188 function category( $name, $section, $active = NULL, $javascript = NULL, $order = 'ordering', $size = 1, $sel_cat = 1 ) 189 { 190 $db =& JFactory::getDBO(); 191 192 $query = 'SELECT id AS value, title AS text' 193 . ' FROM #__categories' 194 . ' WHERE section = '.$db->Quote($section) 195 . ' AND published = 1' 196 . ' ORDER BY '. $order 197 ; 198 $db->setQuery( $query ); 199 if ( $sel_cat ) { 200 $categories[] = JHTML::_('select.option', '0', '- '. JText::_( 'Select a Category' ) .' -' ); 201 $categories = array_merge( $categories, $db->loadObjectList() ); 202 } else { 203 $categories = $db->loadObjectList(); 204 } 205 206 $category = JHTML::_('select.genericlist', $categories, $name, 'class="inputbox" size="'. $size .'" '. $javascript, 'value', 'text', $active ); 207 return $category; 208 } 209 210 /** 211 * Select list of active sections 212 */ 213 function section( $name, $active = NULL, $javascript = NULL, $order = 'ordering', $uncategorized = true, $scope = 'content' ) 214 { 215 $db =& JFactory::getDBO(); 216 217 $categories[] = JHTML::_('select.option', '-1', '- '. JText::_( 'Select Section' ) .' -' ); 218 219 if ($uncategorized) { 220 $categories[] = JHTML::_('select.option', '0', JText::_( 'Uncategorized' ) ); 221 } 222 223 $query = 'SELECT id AS value, title AS text' 224 . ' FROM #__sections' 225 . ' WHERE published = 1' 226 . ' AND scope = ' . $db->Quote($scope) 227 . ' ORDER BY ' . $order 228 ; 229 $db->setQuery( $query ); 230 $sections = array_merge( $categories, $db->loadObjectList() ); 231 232 $category = JHTML::_('select.genericlist', $sections, $name, 'class="inputbox" size="1" '. $javascript, 'value', 'text', $active ); 233 234 return $category; 235 } 236 }
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 |