Resource icon

[OzzModz] XFRM Last Online Sort 1.0.0 Patch Level 3

No permission to download
Dont no why, but the filter doesn't work for me anymore.
But the code looks correct.
 
Last edited:
Every sort is shown in the filterbar, but i dont see last_update or last_activity if i choose them.
Checked the template (Downloads was commented, set back)
 
Now i remember. The default is never shown, what makes no sense.
It should be shown like all others. If i change asc/desc of the default it is shown in the filer_bar.
But the last_activity is not there, no asc/desc.
I will try to go back to the last version, but ...

1.0 2
Code:
        $sorts = parent::getAvailableResourceSorts();

        if (\XF::visitor()->hasPermission('resource', 'pb_xfrmlos_canUse'))
        {
            $sorts['last_activity'] = 'User.last_activity';
            return $sorts;
        }

        return $sorts;

and
1.0; dont know where i have the 1.0 1
Code:
        $sorts = parent::getAvailableResourceSorts();

        return $sorts + [
            'last_activity' => 'User.last_activity',
        ];
 
Hmm, have rebuild everything, now it seems to be ok.
Is this possible?

1. But there is still nothing shown in the filter_bar.
2. I muss the option to use it as default in acp.

I will look for both now.
 
When i try this:

Code:
        $sorts = parent::getAvailableResourceSorts();

        if (\XF::visitor()->hasPermission('resource', 'pb_xfrmlos_canUse'))
        {
            $sorts['last_activity'] = 'User.last_activity';
        }

        $visitor = \XF::visitor();
        if ($visitor->user_id == 1)
        {
            echo "<pre>";
            print_r($sorts);
            echo "</pre>";
        }


        return $sorts;
    }

I get four(!) times this:

Code:
Array
(
    [last_update] => last_update
    [resource_date] => resource_date
    [rating_weighted] => rating_weighted
    [download_count] => download_count
    [title] => title
    [last_activity] => User.last_activity
)

Why this is called four times?
Because other classes are used four times and every time we do again our function here?



Is there any reason to have the return twice times instead one time?

Code:
        $sorts = parent::getAvailableResourceSorts();

        if (\XF::visitor()->hasPermission('resource', 'pb_xfrmlos_canUse'))
        {
            $sorts['last_activity'] = 'User.last_activity';
           // =>  return $sorts; <=
        }

        return $sorts;
 
Last edited:
{{dump($filters.order)}} => last_activity
{{dump($sortOrders)}} => no last_activity

filter00.webp


Without $sortOrders, we dont have the text in the filterbar.
 
Last edited:
Found it!

xfrm_overview_macros

needs a template_mod to have:

Code:
<xf:macro name="list_filter_bar" arg-filters="!" arg-baseLinkPath="!" arg-category="{{ null }}" arg-creatorFilter="{{ null }}">
    <xf:set var="$sortOrders" value="{{ {
        'last_update': phrase('xfrm_last_update'),
        'resource_date': phrase('xfrm_submission_date'),
        'rating_weighted': phrase('rating'),
        'download_count': phrase('xfrm_downloads'),
        'title': phrase('title'),
        'last_activity': phrase('last_activity')                         
    } }}" />

Code:
  <modification type="public" template="xfrm_overview_macros" modification_key="pb_xfrmlos_overview_macros" execution_order="10" enabled="1" action="str_replace">
    <find><![CDATA['title': phrase('title')]]></find>
    <replace><![CDATA[$0,
        'last_activity': phrase('last_activity')]]></replace>
  </modification>


watcher.webp
 
Last edited:
Now there is still the problem with last_update DESC (not the fault of this addon)

{{dump($filters.order)}} is NULL for last_update DESC

While in xfrm/cp/overview we have
Code:
        $defaultOrder = $this->options()->xfrmListDefaultOrder ?: 'last_update';
        $defaultDir = $defaultOrder == 'title' ? 'asc' : 'desc';

        if (empty($filters['order']))
        {
            $filters['order'] = $defaultOrder;
        }
        if (empty($filters['direction']))
        {
            $filters['direction'] = $defaultDir;
        }

is checked

Code:
Array
(
    [order] => last_update
    [direction] => desc
)


there is still {{dump($filters.order)}} is NULL for last_update DESC

So it seems that we loose that on the way to the template?
 
But how this is possible? If $filters is empty, we fill it.

Code:
        if (empty($filters['order']))
        {
            $filters['order'] = $defaultOrder;
        }
        if (empty($filters['direction']))
        {
            $filters['direction'] = $defaultDir;
        }

        $viewParams = [
            'category' => $category,
            'prefixesGrouped' => $prefixes->groupBy('prefix_group_id'),
            'filters' => $filters,
            'creatorFilter' => $creatorFilter,
            'showTypeFilters' => $showTypeFilters
        ];
        return $this->view('XFRM:Filters', 'xfrm_filters', $viewParams);
 
The problem must be in

xfrm/cp/overview
public function getResourceFilterInput()

at the end $filters is empty, when last_update, desc
and not empty for last_update, asc and all others

Ok, found it:

Code:
            //if ($input['order'] != $defaultOrder || $input['direction'] != $defaultDir)
            if (1==1)
            {
                $filters['order'] = $input['order'];
                $filters['direction'] = $input['direction'];
            }

When filters == default and dir = default, we dont give filters back.
But why XF should do this? We we give infos about every filter, but not about the default one?
Makes no sense to me.
 
Back
Top Bottom