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

get_themes_by_resource()

Description

Determine the featured collections and public collections a resource is associated with.

Parameters

ColumnTypeDefaultDescription
$ref integer Resource ref

Return

array

Location

include/resource_functions.php lines 4320 to 4351

Definition

 
function get_themes_by_resource($ref)
    {
    global 
$lang;

    
$sql "SELECT c.ref, c.`name`, c.`type`, u.fullname FROM collection_resource AS cr
            JOIN collection AS c ON cr.collection = c.ref AND cr.resource = ? AND c.`type` IN (?, ?)
            LEFT OUTER JOIN user AS u ON c.user = u.ref
            "
trim(featured_collections_permissions_filter_sql("WHERE""c.ref",true)) ." # access control filter (ok if empty - it means we don't want permission checks or there's nothing to filter out)";


    
$results ps_query($sql, ['i'$ref'i'COLLECTION_TYPE_FEATURED'i'COLLECTION_TYPE_PUBLIC]);
    
$branch_path_fct = function($carry$item) { return sprintf("%s / %s"$carrystrip_prefix_chars(i18n_get_translated($item["name"]),"*")); };

    foreach(
$results as $i => $col)
        {
        
$path sprintf("%s: %s"$lang["public"], i18n_get_translated($col["name"]));

        if(
$col["type"] == COLLECTION_TYPE_FEATURED)
            {
            
$branch_path get_featured_collection_category_branch_by_leaf($col["ref"], array());
            
$branch_path_str array_reduce($branch_path$branch_path_fct"");
            
$path mb_substr($branch_path_str2mb_strlen($branch_path_str));
            }

        
$results[$i]["path"] = trim($path);
        }

    
// Order by resulting path
    
usort($results, function($a$b) { return strnatcasecmp($a["path"], $b["path"]); });

    return 
$results;
    }

This article was last updated 19th March 2024 13:35 Europe/London time based on the source file dated 11th March 2024 14:25 Europe/London time.