public static function ordering($name, $query, $attribs = null, $selected = null, $neworder = null, $chop = null)
	{
		if (empty($attribs))
		{
			$attribs = 'class="inputbox" size="1"';
		}

		if (empty($neworder))
		{
			$db = \App::get('db');
			$db->setQuery($query);

			$items = $db->loadObjectList();

			if (empty($items))
			{
				$options[] = self::option(1, Lang::txt('JOPTION_ORDER_FIRST'));
			}
			else
			{
				$chop = '30';

				$options[] = self::option(0, '0 ' . Lang::txt('JOPTION_ORDER_FIRST'));
				for ($i = 0, $n = count($items); $i < $n; $i++)
				{
					$items[$i]->text = Lang::txt($items[$i]->text);

					if (strlen($items[$i]->text) > $chop)
					{
						$text = substr($items[$i]->text, 0, $chop) . "...";
					}
					else
					{
						$text = $items[$i]->text;
					}

					$options[] = self::option($items[$i]->value, $items[$i]->value . '. ' . $text);
				}
				$options[] = self::option($items[$i - 1]->value + 1, ($items[$i - 1]->value + 1) . ' ' . Lang::txt('JOPTION_ORDER_LAST'));
			}

			$html = self::genericlist($options, $name, array('list.attr' => $attribs, 'list.select' => (int) $selected));
		}
		else
		{
			if ($neworder > 0)
			{
				$text = Lang::txt('JGLOBAL_NEWITEMSLAST_DESC');
			}
			elseif ($neworder <= 0)
			{
				$text = Lang::txt('JGLOBAL_NEWITEMSFIRST_DESC');
			}
			$html = '<input type="hidden" name="' . $name . '" value="' . (int) $selected . '" />' . '<span class="readonly">' . $text . '</span>';
		}
		return $html;
	}