Coding standards
Security in ResourceSpace
Developer reference
Database
Action functions
Admin functions
Ajax functions
Annotation functions
API functions
Collections functions
Comment functions
Config functions
CSV export functions
Dash functions
Debug functions
Encryption functions
Facial recognition functions
File functions
General functions
Language functions
Log functions
Login functions
Message functions
Migration functions
Node functions
PDF functions
Plugin functions
Render functions
Reporting functions
Request functions
Research functions
Slideshow functions
Theme permission functions
User functions
Video functions
Database functions
Metadata functions
Resource functions
Search functions
Map functions
Job functions
Tab functions
Test 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 4387 to 4418

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 15th December 2024 14:05 Europe/London time based on the source file dated 13th December 2024 14:45 Europe/London time.