Collections functions
Encryption functions
General functions
Render functions
Theme permission functions
Video 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 3731 to 3767

Definition

 
function get_themes_by_resource($ref)
    {
    global 
$lang;

    
$sql sprintf(
                
"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 = '%s' AND c.`type` IN (%s)
        LEFT OUTER JOIN user AS u ON c.user = u.ref
                  %s # access control filter (ok if empty - it means we don't want permission checks or there's nothing to filter out)"
,
        
escape_check($ref),
        
COLLECTION_TYPE_FEATURED ", " COLLECTION_TYPE_PUBLIC,
        
trim(featured_collections_permissions_filter_sql("WHERE""c.ref"))
    );

    
$results sql_query($sql);
    
$branch_path_fct = function($carry$item) { return sprintf("%s / %s"$carryi18n_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 29th November 2020 05:05 Europe/London time based on the source file dated 27th November 2020 14:50 Europe/London time.