Collections functions
General functions
Node functions
Render functions
Theme permission functions
User functions
Resource functions

get_filters()

Description

Get all defined filters (currently only used for search)

Parameters

ColumnTypeDefaultDescription
$order string "ref" column to order by
$sort string "ASC" sort order ("ASC" or "DESC")
$find string "" text to search for in filter

Return

array

Location

include/search_functions.php lines 2732 to 2763

Definition

 
function get_filters($order "ref"$sort "ASC"$find "")
    {
    
$validorder = array("ref","name");
    if(!
in_array($order,$validorder))
        {
        
$order "ref";
        }
        
    if(
$sort != "ASC")
        {
        
$sort "DESC";
        }
        
    
$condition "";
    
$join "";
    
$params = array();

    if(
trim($find) != "")
        {
        
$join " LEFT JOIN filter_rule_node fn ON fn.filter=f.ref LEFT JOIN node n ON n.ref = fn.node LEFT JOIN resource_type_field rtf ON rtf.ref=n.resource_type_field";
        
$condition " WHERE f.name LIKE ? OR n.name LIKE ? OR rtf.name LIKE ? OR rtf.title LIKE ?";

        
$params[]="s";$params[]="%" $find "%";
        
$params[]="s";$params[]="%" $find "%";
        
$params[]="s";$params[]="" $find "";
        
$params[]="s";$params[]="" $find "";
        }
        
    
$sql "SELECT f.ref, f.name FROM filter f {$join}{$condition} GROUP BY f.ref ORDER BY f.{$order} {$sort}"// $order and $sort are already confirmed to be valid.

    
return ps_query($sql$params);
    }

This article was last updated 19th March 2024 04:35 Europe/London time based on the source file dated 15th March 2024 17:00 Europe/London time.