Skip to content

Commit

Permalink
Merge branch '4.0-dev' into 390-merge14
Browse files Browse the repository at this point in the history
  • Loading branch information
wilsonge committed Apr 11, 2019
2 parents 494a567 + 2670763 commit 6ef06c8
Show file tree
Hide file tree
Showing 4 changed files with 150 additions and 100 deletions.
18 changes: 18 additions & 0 deletions administrator/components/com_contact/config.xml
Expand Up @@ -827,6 +827,23 @@
<option value="1">JSHOW</option>
</field>

<field
name="contacts_display_num"
type="list"
label="COM_CONTACT_NUMBER_CONTACTS_LIST_LABEL"
default="10"
>
<option value="5">J5</option>
<option value="10">J10</option>
<option value="15">J15</option>
<option value="20">J20</option>
<option value="25">J25</option>
<option value="30">J30</option>
<option value="50">J50</option>
<option value="100">J100</option>
<option value="0">JALL</option>
</field>

<field
name="initial_sort"
type="list"
Expand All @@ -837,6 +854,7 @@
<option value="name">COM_CONTACT_FIELD_VALUE_NAME</option>
<option value="sortname">COM_CONTACT_FIELD_VALUE_SORT_NAME</option>
<option value="ordering">COM_CONTACT_FIELD_VALUE_ORDERING</option>
<option value="featuredordering">COM_CONTACT_FIELD_VALUE_ORDERING_FEATURED</option>
</field>

</fieldset>
Expand Down
2 changes: 2 additions & 0 deletions administrator/language/en-GB/en-GB.com_contact.ini
Expand Up @@ -127,6 +127,7 @@ COM_CONTACT_FIELD_VALUE_NAME="Name"
COM_CONTACT_FIELD_VALUE_NO_LINK="Show Without Link"
COM_CONTACT_FIELD_VALUE_NONE="None"
COM_CONTACT_FIELD_VALUE_ORDERING="Ordering"
COM_CONTACT_FIELD_VALUE_ORDERING_FEATURED="Featured Contacts Ordering"
COM_CONTACT_FIELD_VALUE_PLAIN="Plain"
COM_CONTACT_FIELD_VALUE_SLIDERS="Sliders"
COM_CONTACT_FIELD_VALUE_SORT_NAME="Sort Name"
Expand Down Expand Up @@ -171,6 +172,7 @@ COM_CONTACT_N_ITEMS_UNPUBLISHED="%d contacts unpublished."
COM_CONTACT_N_ITEMS_UNPUBLISHED_1="%d contact unpublished."
COM_CONTACT_NEW_CONTACT="New Contact"
COM_CONTACT_NO_ITEM_SELECTED="No contacts selected."
COM_CONTACT_NUMBER_CONTACTS_LIST_LABEL="# Contacts to List"
COM_CONTACT_SAVE_SUCCESS="Contact saved."
COM_CONTACT_SEARCH_IN_NAME="Search contacts by name"
COM_CONTACT_SELECT_A_CONTACT="Select a Contact"
Expand Down
36 changes: 24 additions & 12 deletions components/com_contact/Model/CategoryModel.php
Expand Up @@ -82,7 +82,8 @@ public function __construct($config = array())
'sortname',
'sortname1', 'a.sortname1',
'sortname2', 'a.sortname2',
'sortname3', 'a.sortname3'
'sortname3', 'a.sortname3',
'featuredordering', 'a.featured'
);
}

Expand Down Expand Up @@ -205,6 +206,11 @@ protected function getListQuery()
->order($db->escape('a.sortname2') . ' ' . $db->escape($this->getState('list.direction', 'ASC')))
->order($db->escape('a.sortname3') . ' ' . $db->escape($this->getState('list.direction', 'ASC')));
}
elseif ($this->getState('list.ordering') === 'featuredordering')
{
$query->order($db->escape('a.featured') . ' DESC')
->order($db->escape('a.ordering') . ' ASC');
}
else
{
$query->order($db->escape($this->getState('list.ordering', 'a.ordering')) . ' ' . $db->escape($this->getState('list.direction', 'ASC')));
Expand All @@ -230,13 +236,30 @@ protected function populateState($ordering = null, $direction = null)
$app = Factory::getApplication();
$params = ComponentHelper::getParams('com_contact');

// Get list ordering default from the parameters
$menuParams = new Registry;

if ($menu = $app->getMenu()->getActive())
{
$menuParams->loadString($menu->params);
}

$mergedParams = clone $params;
$mergedParams->merge($menuParams);

// List state information
$format = $app->input->getWord('format');

$numberOfContactsToDisplay = $mergedParams->get('contacts_display_num');

if ($format === 'feed')
{
$limit = $app->get('feed_limit');
}
elseif (isset($numberOfContactsToDisplay))
{
$limit = $numberOfContactsToDisplay;
}
else
{
$limit = $app->getUserStateFromRequest('global.list.limit', 'limit', $app->get('list_limit'), 'uint');
Expand All @@ -252,17 +275,6 @@ protected function populateState($ordering = null, $direction = null)
$search = $app->getUserStateFromRequest('com_contact.category.list.' . $itemid . '.filter-search', 'filter-search', '', 'string');
$this->setState('list.filter', $search);

// Get list ordering default from the parameters
$menuParams = new Registry;

if ($menu = $app->getMenu()->getActive())
{
$menuParams->loadString($menu->params);
}

$mergedParams = clone $params;
$mergedParams->merge($menuParams);

$orderCol = $app->input->get('filter_order', $mergedParams->get('initial_sort', 'ordering'));

if (!in_array($orderCol, $this->filter_fields))
Expand Down

0 comments on commit 6ef06c8

Please sign in to comment.