Source for file list.php
Documentation is available at list.php
* @package Joomla.Libraries
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
* Utility class for creating different select lists
* @package Joomla.Libraries
* Build the select list to choose an image
* @param string $name The name of the field
* @param string $active The selected item
* @param string $javascript Alternative javascript
* @param string $directory Directory the images are stored in
* @param string $extensions Allowed extensions
* @return array Image names
public static function images($name, $active =
null, $javascript =
null, $directory =
null, $extensions =
"bmp|gif|jpg|png")
$javascript =
"onchange=\"if (document.forms.adminForm." .
$name
.
".options[selectedIndex].value!='') {document.imagelib.src='..$directory' + document.forms.adminForm." .
$name
.
".options[selectedIndex].value} else {document.imagelib.src='media/system/images/blank.png'}\"";
$imageFiles =
new DirectoryIterator(JPATH_SITE .
'/' .
$directory);
$images =
array(JHtml::_('select.option', '', JText::_('JOPTION_SELECT_IMAGE')));
foreach ($imageFiles as $file)
$fileName =
$file->getFilename();
if (preg_match('#(' .
$extensions .
')$#', $fileName))
$images[] =
JHtml::_('select.option', $fileName);
'list.attr' =>
'class="inputbox" size="1" ' .
$javascript,
* Returns an array of options
* @param string $query SQL with 'ordering' AS value and 'name field' AS text
* @param integer $chop The length of the truncated headline
* @return array An array of objects formatted for JHtml list processing
$items =
$db->loadObjectList();
$options[] =
JHtml::_('select.option', 1, JText::_('JOPTION_ORDER_FIRST'));
$options[] =
JHtml::_('select.option', 0, '0 ' .
JText::_('JOPTION_ORDER_FIRST'));
for ($i =
0, $n =
count($items); $i <
$n; $i++
)
$items[$i]->text =
JText::_($items[$i]->text);
$text =
$items[$i]->text;
$options[] =
JHtml::_('select.option', $items[$i]->value, $items[$i]->value .
'. ' .
$text);
$options[] =
JHtml::_('select.option', $items[$i -
1]->value +
1, ($items[$i -
1]->value +
1) .
' ' .
JText::_('JOPTION_ORDER_LAST'));
* Build the select list for Ordering derived from a query
* @param integer $name The scalar value
* @param string $query The query
* @param string $attribs HTML tag attributes
* @param string $selected The selected item
* @param integer $neworder 1 if new and first, -1 if new and last, 0 or null if existing item
* @return string HTML markup for the select list
public static function ordering($name, $query, $attribs =
null, $selected =
null, $neworder =
null)
$attribs =
'class="inputbox" size="1"';
$orders =
JHtml::_('list.genericordering', $query);
$html =
JHtml::_('select.genericlist', $orders, $name, array('list.attr' =>
$attribs, 'list.select' => (int)
$selected));
$text =
JText::_('JGLOBAL_NEWITEMSLAST_DESC');
$text =
JText::_('JGLOBAL_NEWITEMSFIRST_DESC');
$html =
'<input type="hidden" name="' .
$name .
'" value="' . (int)
$selected .
'" /><span class="readonly">' .
$text .
'</span>';
* Select list of active users
* @param string $name The name of the field
* @param string $active The active user
* @param integer $nouser If set include an option to select no user
* @param string $javascript Custom javascript
* @param string $order Specify a field to order by
* @return string The HTML for a list of users list of users
public static function users($name, $active, $nouser =
0, $javascript =
null, $order =
'name')
$query =
$db->getQuery(true)
->select('u.id AS value, u.name AS text')
->join('LEFT', '#__user_usergroup_map AS m ON m.user_id = u.id')
$users[] =
JHtml::_('select.option', '0', JText::_('JOPTION_NO_USER'));
$users =
$db->loadObjectList();
'list.attr' =>
'class="inputbox" size="1" ' .
$javascript,
* Select list of positions - generally used for location of images
* @param string $name Name of the field
* @param string $active The active value
* @param string $javascript Alternative javascript
* @param boolean $none Null if not assigned
* @param boolean $center Null if not assigned
* @param boolean $left Null if not assigned
* @param boolean $right Null if not assigned
* @param boolean $id Null if not assigned
* @return array The positions
public static function positions($name, $active =
null, $javascript =
null, $none =
true, $center =
true, $left =
true, $right =
true,
$pos['center'] =
JText::_('JGLOBAL_CENTER');
$pos['left'] =
JText::_('JGLOBAL_LEFT');
$pos['right'] =
JText::_('JGLOBAL_RIGHT');
'select.genericlist', $pos, $name,
'list.attr' =>
'class="inputbox" size="1"' .
$javascript,
'list.select' =>
$active,
Documentation generated on Tue, 19 Nov 2013 15:07:19 +0100 by phpDocumentor 1.4.3