english/libraries/joomla/html/html/list.php
/**
	 * Returns an array of options
	 *
	 * @param   string   $sql		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
	 * @since   11.1
	 */
Returns an array of options
@param   string   $sql               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
@since   11.1
Returns an array of options @param string $sql 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 @since 11 . 1
public static function genericordering($sql, $chop = '30')
	{
		$db = JFactory::getDbo();
		$options	= array();
		$db->setQuery($sql);
		$items = $db->loadObjectList();
		if ($db->getErrorNum()) {
			JError::raiseNotice(500, $db->getErrorMsg());
			return false;
		}
		if (empty($items)) {
			$options[] = JHtml::_('select.option',  1, JText::_('JOPTION_ORDER_FIRST'));
			return $options;
		}
		$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);
			if (JString::strlen($items[$i]->text) > $chop) {
				$text = JString::substr($items[$i]->text,0,$chop)."...";
			} else {
				$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'));
		return $options;
	}
public static function genericordering ( $ sql , $ chop = '30' ) { $ db = JFactory :: getDbo ( ) ; $ options = array ( ) ; $ db -> setQuery ( $ sql ) ; $ items = $ db -> loadObjectList ( ) ; if ( $ db -> getErrorNum ( ) ) { JError :: raiseNotice ( 500 , $ db -> getErrorMsg ( ) ) ; return false ; } if ( empty ( $ items ) ) { $ options [ ] = JHtml :: _ ( 'select.option' , 1 , JText :: _ ( 'JOPTION_ORDER_FIRST' ) ) ; return $ options ; } $ 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 ) ; if ( JString :: strlen ( $ items [ $ i ] -> text ) > $ chop ) { $ text = JString :: substr ( $ items [ $ i ] -> text , 0 , $ chop ) . " ... " ; } else { $ 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' ) ) ; return $ options ; }
Returns an array of options
 @param   string   $sql               SQL with ordering As value and 'name field' AS text
 @param   integer  $chop      The length of the truncated headline
Returns an array of options @param string $sql SQL with ordering As value and ' name field ' AS text @param integer $chop The length of the truncated headline
// Check for a database error.