Files
@ 7ec91347b83f
Branch filter:
Location: hot67beta/libraries/joomla/html/html/list.php
7ec91347b83f
6.9 KiB
text/x-php
there we go
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 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 | <?php
/**
* @version $Id: list.php 10713 2008-08-21 10:09:57Z eddieajau $
* @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.
*/
// no direct access
defined( '_JEXEC' ) or die( 'Restricted access' );
/**
* Utility class for creating different select lists
*
* @static
* @package Joomla.Framework
* @subpackage HTML
* @since 1.5
*/
class JHTMLList
{
/**
* Build the select list for access level
*/
function accesslevel( &$row )
{
$db =& JFactory::getDBO();
$query = 'SELECT id AS value, name AS text'
. ' FROM #__groups'
. ' ORDER BY id'
;
$db->setQuery( $query );
$groups = $db->loadObjectList();
$access = JHTML::_('select.genericlist', $groups, 'access', 'class="inputbox" size="3"', 'value', 'text', intval( $row->access ), '', 1 );
return $access;
}
/**
* Build the select list to choose an image
*/
function images( $name, $active = NULL, $javascript = NULL, $directory = NULL, $extensions = "bmp|gif|jpg|png" )
{
if ( !$directory ) {
$directory = '/images/stories/';
}
if ( !$javascript ) {
$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'}\"";
}
jimport( 'joomla.filesystem.folder' );
$imageFiles = JFolder::files( JPATH_SITE.DS.$directory );
$images = array( JHTML::_('select.option', '', '- '. JText::_( 'Select Image' ) .' -' ) );
foreach ( $imageFiles as $file ) {
if ( eregi( $extensions, $file ) ) {
$images[] = JHTML::_('select.option', $file );
}
}
$images = JHTML::_('select.genericlist', $images, $name, 'class="inputbox" size="1" '. $javascript, 'value', 'text', $active );
return $images;
}
/**
* Description
*
* @param string SQL with ordering As value and 'name field' AS text
* @param integer The length of the truncated headline
* @since 1.5
*/
function genericordering( $sql, $chop = '30' )
{
$db =& JFactory::getDBO();
$order = array();
$db->setQuery( $sql );
if (!($orders = $db->loadObjectList())) {
if ($db->getErrorNum()) {
echo $db->stderr();
return false;
} else {
$order[] = JHTML::_('select.option', 1, JText::_( 'first' ) );
return $order;
}
}
$order[] = JHTML::_('select.option', 0, '0 '. JText::_( 'first' ) );
for ($i=0, $n=count( $orders ); $i < $n; $i++) {
if (JString::strlen($orders[$i]->text) > $chop) {
$text = JString::substr($orders[$i]->text,0,$chop)."...";
} else {
$text = $orders[$i]->text;
}
$order[] = JHTML::_('select.option', $orders[$i]->value, $orders[$i]->value.' ('.$text.')' );
}
$order[] = JHTML::_('select.option', $orders[$i-1]->value+1, ($orders[$i-1]->value+1).' '. JText::_( 'last' ) );
return $order;
}
/**
* Build the select list for Ordering of a specified Table
*/
function specificordering( &$row, $id, $query, $neworder = 0 )
{
$db =& JFactory::getDBO();
if ( $id ) {
$order = JHTML::_('list.genericordering', $query );
$ordering = JHTML::_('select.genericlist', $order, 'ordering', 'class="inputbox" size="1"', 'value', 'text', intval( $row->ordering ) );
} else {
if ( $neworder ) {
$text = JText::_( 'descNewItemsFirst' );
} else {
$text = JText::_( 'descNewItemsLast' );
}
$ordering = '<input type="hidden" name="ordering" value="'. $row->ordering .'" />'. $text;
}
return $ordering;
}
/**
* Select list of active users
*/
function users( $name, $active, $nouser = 0, $javascript = NULL, $order = 'name', $reg = 1 )
{
$db =& JFactory::getDBO();
$and = '';
if ( $reg ) {
// does not include registered users in the list
$and = ' AND gid > 18';
}
$query = 'SELECT id AS value, name AS text'
. ' FROM #__users'
. ' WHERE block = 0'
. $and
. ' ORDER BY '. $order
;
$db->setQuery( $query );
if ( $nouser ) {
$users[] = JHTML::_('select.option', '0', '- '. JText::_( 'No User' ) .' -' );
$users = array_merge( $users, $db->loadObjectList() );
} else {
$users = $db->loadObjectList();
}
$users = JHTML::_('select.genericlist', $users, $name, 'class="inputbox" size="1" '. $javascript, 'value', 'text', $active );
return $users;
}
/**
* Select list of positions - generally used for location of images
*/
function positions( $name, $active = NULL, $javascript = NULL, $none = 1, $center = 1, $left = 1, $right = 1, $id = false )
{
if ( $none ) {
$pos[] = JHTML::_('select.option', '', JText::_( 'None' ) );
}
if ( $center ) {
$pos[] = JHTML::_('select.option', 'center', JText::_( 'Center' ) );
}
if ( $left ) {
$pos[] = JHTML::_('select.option', 'left', JText::_( 'Left' ) );
}
if ( $right ) {
$pos[] = JHTML::_('select.option', 'right', JText::_( 'Right' ) );
}
$positions = JHTML::_('select.genericlist', $pos, $name, 'class="inputbox" size="1"'. $javascript, 'value', 'text', $active, $id );
return $positions;
}
/**
* Select list of active categories for components
*/
function category( $name, $section, $active = NULL, $javascript = NULL, $order = 'ordering', $size = 1, $sel_cat = 1 )
{
$db =& JFactory::getDBO();
$query = 'SELECT id AS value, title AS text'
. ' FROM #__categories'
. ' WHERE section = '.$db->Quote($section)
. ' AND published = 1'
. ' ORDER BY '. $order
;
$db->setQuery( $query );
if ( $sel_cat ) {
$categories[] = JHTML::_('select.option', '0', '- '. JText::_( 'Select a Category' ) .' -' );
$categories = array_merge( $categories, $db->loadObjectList() );
} else {
$categories = $db->loadObjectList();
}
$category = JHTML::_('select.genericlist', $categories, $name, 'class="inputbox" size="'. $size .'" '. $javascript, 'value', 'text', $active );
return $category;
}
/**
* Select list of active sections
*/
function section( $name, $active = NULL, $javascript = NULL, $order = 'ordering', $uncategorized = true )
{
$db =& JFactory::getDBO();
$categories[] = JHTML::_('select.option', '-1', '- '. JText::_( 'Select Section' ) .' -' );
if ($uncategorized) {
$categories[] = JHTML::_('select.option', '0', JText::_( 'Uncategorized' ) );
}
$query = 'SELECT id AS value, title AS text'
. ' FROM #__sections'
. ' WHERE published = 1'
. ' ORDER BY ' . $order
;
$db->setQuery( $query );
$sections = array_merge( $categories, $db->loadObjectList() );
$category = JHTML::_('select.genericlist', $sections, $name, 'class="inputbox" size="1" '. $javascript, 'value', 'text', $active );
return $category;
}
}
|