本文整理汇总了PHP中JArrayHelper::sortObjects方法的典型用法代码示例。如果您正苦于以下问题:PHP JArrayHelper::sortObjects方法的具体用法?PHP JArrayHelper::sortObjects怎么用?PHP JArrayHelper::sortObjects使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JArrayHelper
的用法示例。
在下文中一共展示了JArrayHelper::sortObjects方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getInput
/**
* Method to get the field input.
*
* @return string The field input.
*/
protected function getInput()
{
$attributes = '';
if ($v = (string) $this->element['onchange']) {
$attributes .= ' onchange="' . $v . '"';
}
if ($this->value == '_thirdparty') {
$attributes .= ' class="' . (string) $this->element['class'] . ' iconlist-16-thirdparty"';
} elseif ($this->value == '_override') {
$attributes .= ' class="' . (string) $this->element['class'] . ' iconlist-16-override"';
} else {
$attributes .= ' class="' . (string) $this->element['class'] . '"';
}
$options = array();
foreach ($this->element->children() as $option) {
$options[] = JHtml::_('select.option', $option->attributes('value'), JText::_(trim($option)), array('option.attr' => 'attributes', 'attr' => ''));
}
$packages = LocaliseHelper::getPackages();
$packages_options = array();
foreach ($packages as $package) {
$packages_options[] = JHtml::_('select.option', $package->name, JText::_($package->title), array('option.attr' => 'attributes', 'attr' => 'class="localise-icon" style="background-image: url(' . JURI::root(true) . $package->icon . ');"'));
if ($this->value == $package->name) {
$attributes .= ' style="background-image: url(' . JURI::root(true) . $package->icon . ');"';
}
}
$packages_options = JArrayHelper::sortObjects($packages_options, 'text');
$thirdparty = JHtml::_('select.option', '_thirdparty', JText::sprintf('COM_LOCALISE_OPTION_TRANSLATIONS_ORIGIN_THIRDPARTY'), array('option.attr' => 'attributes', 'attr' => 'class="iconlist-16-thirdparty"'));
$override = JHtml::_('select.option', '_override', JText::sprintf('COM_LOCALISE_OPTION_TRANSLATIONS_ORIGIN_OVERRIDE'), array('option.attr' => 'attributes', 'attr' => 'class="iconlist-16-override"'));
$return = JHtml::_('select.genericlist', array_merge($options, $packages_options, array($thirdparty), array($override)), $this->name, array('id' => $this->id, 'list.select' => $this->value, 'option.attr' => 'attributes', 'list.attr' => $attributes, 'group.items' => null));
return $return;
}
示例2: getInput
/**
* Method to get the field input.
*
* @return string The field input.
*/
protected function getInput()
{
$attributes = '';
if ($v = (string) $this->element['onchange']) {
$attributes .= ' onchange="' . $v . '"';
}
$params = JComponentHelper::getParams('com_localise');
$reference = $params->get('reference', 'en-GB');
$admin = JLanguage::getKnownLanguages(LOCALISEPATH_ADMINISTRATOR);
$site = JLanguage::getKnownLanguages(LOCALISEPATH_SITE);
if (JFolder::exists(LOCALISEPATH_INSTALLATION)) {
$install = JLanguage::getKnownLanguages(LOCALISEPATH_INSTALLATION);
} else {
$install = array();
}
$languages = array_merge($admin, $site, $install);
$attributes .= ' class="' . (string) $this->element['class'] . ($this->value == $reference ? ' iconlist-16-reference"' : '"');
foreach ($languages as $i => $language) {
$languages[$i] = JArrayHelper::toObject($language);
}
JArrayHelper::sortObjects($languages, 'name');
$options = array();
foreach ($this->element->children() as $option) {
$options[] = JHtml::_('select.option', $option->attributes('value'), JText::_(trim($option)), array('option.attr' => 'attributes', 'attr' => ''));
}
foreach ($languages as $language) {
$options[] = JHtml::_('select.option', $language->tag, $language->name, array('option.attr' => 'attributes', 'attr' => 'class="' . ($language->tag == $reference ? 'iconlist-16-reference" title="' . JText::_('COM_LOCALISE_TOOLTIP_FIELD_LANGUAGE_REFERENCE') . '"' : '"')));
}
$return = JHtml::_('select.genericlist', $options, $this->name, array('id' => $this->id, 'list.select' => $this->value, 'option.attr' => 'attributes', 'list.attr' => $attributes));
return $return;
}
示例3: reasons
public static function reasons($selected = null, $id = 'reason', $attribs = array())
{
$reasons = array('other', 'adminpw', 'ipwl', 'ipbl', 'sqlishield', 'antispam', 'tpone', 'tmpl', 'template', 'muashield', 'csrfshield', 'badbehaviour', 'geoblocking', 'rfishield', 'dfishield', 'uploadshield', 'sessionshield', 'httpbl', 'loginfailure', 'securitycode', 'external', 'awayschedule', 'admindir');
$options = array();
foreach ($reasons as $reason) {
$options[] = JHTML::_('select.option', $reason, JText::_('ATOOLS_LBL_REASON_' . strtoupper($reason)));
}
// Enable miscellaneous reasons, for use in email templates
if (isset($attribs['misc'])) {
$options[] = JHTML::_('select.option', 'user-reactivate', JText::_('ATOOLS_LBL_USER_REACTIVATE'));
$options[] = JHTML::_('select.option', 'adminloginfail', JText::_('COM_ADMINTOOLS_EMAILTEMPLATE_REASON_ADMINLOGINFAIL'));
$options[] = JHTML::_('select.option', 'adminloginsuccess', JText::_('COM_ADMINTOOLS_EMAILTEMPLATE_REASON_ADMINLOGINSUCCESS'));
$options[] = JHTML::_('select.option', 'ipautoban', JText::_('COM_ADMINTOOLS_EMAILTEMPLATE_REASON_IPAUTOBAN'));
unset($attribs['misc']);
}
// Let's sort the list alphabetically
JArrayHelper::sortObjects($options, 'text');
if (isset($attribs['all'])) {
array_unshift($options, JHTML::_('select.option', 'all', JText::_('ATOOLS_LBL_REASON_ALL')));
unset($attribs['all']);
}
if (!isset($attribs['hideEmpty'])) {
array_unshift($options, JHTML::_('select.option', '', '- ' . JText::_('ATOOLS_LBL_REASON_SELECT') . ' -'));
} else {
unset($attribs['hideEmpty']);
}
return self::genericlist($options, $id, $attribs, $selected, $id);
}
示例4: _getList
/**
* Returns an object list
*
* @param string The query
* @param int Offset
* @param int The number of records
* @return array
*/
protected function _getList($query, $limitstart = 0, $limit = 0)
{
$ordering = $this->getState('list.ordering');
$search = $this->getState('filter.search');
// Replace slashes so preg_match will work
$search = str_replace('/', ' ', $search);
$db = $this->getDbo();
if ($ordering == 'name' || !empty($search) && stripos($search, 'id:') !== 0) {
$db->setQuery($query);
$result = $db->loadObjectList();
$lang = JFactory::getLanguage();
$this->translate($result);
if (!empty($search)) {
foreach ($result as $i => $item) {
if (!preg_match("/{$search}/i", $item->name)) {
unset($result[$i]);
}
}
}
JArrayHelper::sortObjects($result, $this->getState('list.ordering'), $this->getState('list.direction') == 'desc' ? -1 : 1, true, $lang->getLocale());
$total = count($result);
$this->cache[$this->getStoreId('getTotal')] = $total;
if ($total < $limitstart) {
$limitstart = 0;
$this->setState('list.start', 0);
}
return array_slice($result, $limitstart, $limit ? $limit : null);
} else {
$query->order($db->quoteName($ordering) . ' ' . $this->getState('list.direction'));
$result = parent::_getList($query, $limitstart, $limit);
$this->translate($result);
return $result;
}
}
示例5: _getList
protected function _getList($query, $limitstart = 0, $limit = 0)
{
$ordering = $this->getState('list.ordering', 'ordering');
if (in_array($ordering, array('pages', 'name'))) {
$this->_db->setQuery($query);
$result = $this->_db->loadObjectList();
$this->translate($result);
$lang = JFactory::getLanguage();
JArrayHelper::sortObjects($result, $ordering, $this->getState('list.direction') == 'desc' ? -1 : 1, true, $lang->getLocale());
$total = count($result);
$this->cache[$this->getStoreId('getTotal')] = $total;
if ($total < $limitstart) {
$limitstart = 0;
$this->setState('list.start', 0);
}
return array_slice($result, $limitstart, $limit ? $limit : null);
} else {
if ($ordering == 'ordering') {
$query->order('position ASC');
}
$query->order($this->_db->quoteName($ordering) . ' ' . $this->getState('list.direction'));
if ($ordering == 'position') {
$query->order('ordering ASC');
}
$result = parent::_getList($query, $limitstart, $limit);
$this->translate($result);
return $result;
}
}
示例6: getData
/**
* Method to get cache data
*
* @return array
*/
public function getData()
{
if (empty($this->_data)) {
$cache = $this->getCache();
$data = $cache->getAll();
if ($data != false) {
$this->_data = $data;
$this->_total = count($data);
if ($this->_total) {
// Apply custom ordering
$ordering = $this->getState('list.ordering');
$direction = $this->getState('list.direction') == 'asc' ? 1 : -1;
jimport('joomla.utilities.arrayhelper');
$this->_data = JArrayHelper::sortObjects($data, $ordering, $direction);
// Apply custom pagination
if ($this->_total > $this->getState('list.limit') && $this->getState('list.limit')) {
$this->_data = array_slice($this->_data, $this->getState('list.start'), $this->getState('list.limit'));
}
}
} else {
$this->_data = array();
}
}
return $this->_data;
}
示例7: fetchElement
function fetchElement($name, $value, &$node, $control_name, $raw = false)
{
// Must load admin language files
$lang =& JFactory::getLanguage();
$lang->load("com_jevents", JPATH_ADMINISTRATOR);
$db =& JFactory::getDBO();
if (JVersion::isCompatible("1.6.0")) {
$extension = $node->getAttribute('extension');
} else {
$section = $node->attributes('section');
if (!isset($section)) {
// alias for section
$section = $node->attributes('scope');
if (!isset($section)) {
$section = 'content';
}
}
}
$class = $node->attributes('class');
if (!$class) {
$class = "inputbox";
}
$query = 'SELECT c.id, c.title as ctitle,p.title as ptitle, gp.title as gptitle, ggp.title as ggptitle, ' . ' CASE WHEN CHAR_LENGTH(p.title) THEN CONCAT_WS(" => ", p.title, c.title) ELSE c.title END as title' . ' FROM #__categories AS c' . ' LEFT JOIN #__categories AS p ON p.id=c.parent_id' . ' LEFT JOIN #__categories AS gp ON gp.id=p.parent_id ' . ' LEFT JOIN #__categories AS ggp ON ggp.id=gp.parent_id ' . ' WHERE c.published = 1 ';
if (JVersion::isCompatible("1.6.0")) {
$query .= ' AND c.extension = ' . $db->Quote($extension);
} else {
$query .= ' AND c.section = ' . $db->Quote($section);
}
$db->setQuery($query);
$options = $db->loadObjectList();
echo $db->getErrorMsg();
foreach ($options as $key => $option) {
$title = $option->ctitle;
if (!is_null($option->ptitle)) {
$title = $option->ptitle . "=>" . $title;
}
if (!is_null($option->gptitle)) {
$title = $option->gptitle . "=>" . $title;
}
if (!is_null($option->ggptitle)) {
$title = $option->ggptitle . "=>" . $title;
}
/*
if (!is_null($option->gggptitle)){
$title = $option->gggptitle."=>".$title;
}
*/
$options[$key]->title = $title;
}
JArrayHelper::sortObjects($options, "title");
if ($raw) {
return $options;
} else {
array_unshift($options, JHTML::_('select.option', '0', '- ' . JText::_('JEV_SELECT_CATEGORY') . ' -', 'id', 'title'));
return JHTML::_('select.genericlist', $options, '' . $control_name . '[' . $name . ']', 'class="' . $class . '"', 'id', 'title', $value, $control_name . $name);
}
}
示例8: _getComponents
protected function _getComponents()
{
$lang = JFactory::getLanguage();
// Get the list of components.
$db = JFactory::getDBO();
$db->setQuery('SELECT extension_id, name, element ' . ' FROM #__extensions' . ' WHERE type = ' . $db->quote('component') . ' AND enabled = 1' . ' ORDER BY name');
$components = $db->loadObjectList();
$components = JArrayHelper::sortObjects($components, 'name', 1, true, $lang->getLocale());
return $components;
}
示例9: getFilter
/**
* Get the table filter for the element
* @param int counter
* @param bol do we render as a normal filter or as an advanced search filter
* if normal include the hidden fields as well (default true, use false for advanced filter rendering)
* @return string filter html
*/
function getFilter($counter = 0, $normal = true)
{
$element = $this->getElement();
$values = $this->getSubOptionValues();
$default = $this->getDefaultFilterVal($normal, $counter);
$elName = $this->getFullName(false, true, false);
$htmlid = $this->getHTMLId() . 'value';
$table =& $this->getlistModel()->getTable();
$params =& $this->getParams();
$v = 'fabrik___filter[list_' . $table->id . '][value]';
$v .= $normal ? '[' . $counter . ']' : '[]';
if (in_array($element->filter_type, array('range', 'dropdown', ''))) {
$rows = $this->filterValueList($normal);
JArrayHelper::sortObjects($rows, $params->get('filter_groupby', 'text'));
if (!in_array('', $values)) {
array_unshift($rows, JHTML::_('select.option', '', $this->filterSelectLabel()));
}
}
$attribs = 'class="inputbox fabrik_filter" size="1" ';
$size = $params->get('filter_length', 20);
switch ($element->filter_type) {
case "range":
$default1 = is_array($default) ? $default[0] : '';
$return = JHTML::_('select.genericlist', $rows, $v . '[]', $attribs, 'value', 'text', $default1, $element->name . "_filter_range_0");
$default1 = is_array($default) ? $default[1] : '';
$return .= JHTML::_('select.genericlist', $rows, $v . '[]', $attribs, 'value', 'text', $default1, $element->name . "_filter_range_1");
break;
case "dropdown":
default:
$return = JHTML::_('select.genericlist', $rows, $v, $attribs, 'value', 'text', $default, $htmlid);
break;
case "field":
if (get_magic_quotes_gpc()) {
$default = stripslashes($default);
}
$default = htmlspecialchars($default);
$return = "<input type=\"text\" name=\"{$v}\" class=\"inputbox fabrik_filter\" size=\"{$size}\" value=\"{$default}\" id=\"{$htmlid}\" />";
break;
case 'auto-complete':
if (get_magic_quotes_gpc()) {
$default = stripslashes($default);
}
$default = htmlspecialchars($default);
$return = "<input type=\"hidden\" name=\"{$v}\" class=\"inputbox fabrik_filter\" value=\"{$default}\" id=\"{$htmlid}\" />";
$return .= "<input type=\"text\" name=\"{$v}-auto-complete\" class=\"inputbox fabrik_filter autocomplete-trigger\" size=\"{$size}\" value=\"{$default}\" id=\"{$htmlid}-auto-complete\" />";
FabrikHelperHTML::autoComplete($htmlid, $this->getElement()->id, $element->plugin);
break;
}
if ($normal) {
$return .= $this->getFilterHiddenFields($counter, $elName);
} else {
$return .= $this->getAdvancedFilterHiddenFields();
}
return $return;
}
示例10: _getList
protected function _getList($query, $limitstart = 0, $limit = 0)
{
$ordering = $this->getState('list.ordering', 'ordering');
$this->_db->setQuery($query);
$result = $this->_db->loadObjectList();
JArrayHelper::sortObjects($result, $ordering, $this->getState('list.direction') == 'desc' ? -1 : 1, true, true);
$total = count($result);
$this->cache[$this->getStoreId('getTotal')] = $total;
if ($total < $limitstart) {
$limitstart = 0;
$this->setState('list.start', 0);
}
return array_slice($result, $limitstart, $limit ? $limit : null);
}
示例11: jl_birthday_sort
function jl_birthday_sort($array, $sort)
{
/**
* Utility function to sort an array of objects on a given field
*
* @param array &$a An array of objects
* @param mixed $k The key (string) or a array of key to sort on
* @param mixed $direction Direction (integer) or an array of direction to sort in [1 = Ascending] [-1 = Descending]
* @param mixed $caseSensitive Boolean or array of booleans to let sort occur case sensitive or insensitive
* @param mixed $locale Boolean or array of booleans to let sort occur using the locale language or not
*
* @return array The sorted array of objects
*
* @since 11.1
*/
$res = JArrayHelper::sortObjects($array, 'age', $sort);
return $res;
}
示例12: getFilters
public function getFilters($rows)
{
$filters = array();
$cats = array();
$options = array();
if ($rows) {
foreach ($rows as $row) {
if ($row->ostcat_id && !in_array($row->ostcat_id, $cats)) {
$cats[] = $row->ostcat_id;
$options[] = JHtml::_('select.option', $row->ostcat_id, $row->ostcat_name);
}
}
}
JArrayHelper::sortObjects($options, 'text');
array_unshift($options, JHtml::_('select.option', '', 'All'));
$attributes = "class='inputbox' onchange='document.adminForm.submit();'";
$filters['category'] = JHtml::_('select.genericlist', $options, 'category', $attributes, 'value', 'text', $this->getState('category'));
return $filters;
}
示例13: getOptions
/**
* Method to get the field input.
*
* @return string The field input.
*/
protected function getOptions()
{
$admin = JLanguage::getKnownLanguages(LOCALISEPATH_ADMINISTRATOR);
$site = JLanguage::getKnownLanguages(LOCALISEPATH_SITE);
if (JFolder::exists(LOCALISEPATH_INSTALLATION)) {
$installation = JLanguage::getKnownLanguages(LOCALISEPATH_INSTALLATION);
$languages = array_intersect_key($admin, $site, $installation);
} else {
$languages = array_intersect_key($admin, $site);
}
foreach ($languages as $i => $language) {
$languages[$i] = JArrayHelper::toObject($language);
}
JArrayHelper::sortObjects($languages, 'name');
$options = parent::getOptions();
foreach ($languages as $language) {
$options[] = JHtml::_('select.option', $language->tag, $language->name);
}
return $options;
}
示例14: getComponents
/**
* Get a list of the components.
*
* @return array
* @since 1.6
*/
public static function getComponents()
{
// Initialise variable.
$db = JFactory::getDbo();
$query = $db->getQuery(true)->select('name AS text, element AS value')->from('#__extensions')->where('enabled >= 1')->where('type =' . $db->quote('component'));
$items = $db->setQuery($query)->loadObjectList();
if (count($items)) {
$lang = JFactory::getLanguage();
foreach ($items as &$item) {
// Load language
$extension = $item->value;
$source = JPATH_ADMINISTRATOR . '/components/' . $extension;
$lang->load("{$extension}.sys", JPATH_ADMINISTRATOR, null, false, true) || $lang->load("{$extension}.sys", $source, null, false, true);
// Translate component name
$item->text = JText::_($item->text);
}
// Sort by component name
JArrayHelper::sortObjects($items, 'text', 1, true, true);
}
return $items;
}
示例15: fetchElementOLD
function fetchElementOLD($name, $value, &$node, $control_name)
{
$options = array();
$menu =& JApplication::getMenu('site', $options);
$items = $menu->getMenu();
$items2 = $menu->getItems("component", "com_joomleague");
JArrayHelper::sortObjects($items2, "menutype");
foreach ($items2 as &$item) {
$item->title = $item->name . " (" . $item->menutype . " - " . $item->component . ")";
unset($item);
}
JArrayHelper::sortObjects($items, "menutype");
foreach ($items as &$item) {
if ($item->component != "com_joomleague") {
$item->title = $item->name . " (" . $item->menutype . " - " . $item->component . ")";
$items2[] = $item;
unset($item);
}
}
return JHTML::_('select.genericlist', $items2, '' . $control_name . '[' . $name . ']', '', 'id', 'title', $value, $control_name . $name);
}