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_featured_collection_categ_sub_fcs()

Description

Get a list of featured collections based on a higher level featured collection category. This returns all direct/indirect
collections under that category.

Parameters

ColumnTypeDefaultDescription
$c array Collection data structure
$ctx array array Contextual data (e.g disable access control). This param MUST NOT get exposed over the API

Return

array

Location

include/collections_functions.php lines 3061 to 3130

Definition

 
function get_featured_collection_categ_sub_fcs(array $c, array $ctx = array())
    {
    global 
$CACHE_FC_CATEG_SUB_FCS;
    
$CACHE_FC_CATEG_SUB_FCS = (!is_null($CACHE_FC_CATEG_SUB_FCS) && is_array($CACHE_FC_CATEG_SUB_FCS) ? $CACHE_FC_CATEG_SUB_FCS : array());
    if(isset(
$CACHE_FC_CATEG_SUB_FCS[$c["ref"]]))
        {
        return 
$CACHE_FC_CATEG_SUB_FCS[$c["ref"]];
        }

    
$access_control = (isset($ctx["access_control"]) && is_bool($ctx["access_control"]) ? $ctx["access_control"] : true);
    
$all_fcs = (isset($ctx["all_fcs"]) && is_array($ctx["all_fcs"]) && !empty($ctx["all_fcs"]) ? $ctx["all_fcs"] : get_all_featured_collections());

    
$collections = array();

    
$allowed_fcs = ($access_control compute_featured_collections_access_control() : true);
    if(
$allowed_fcs === false)
        {
        
$CACHE_FC_CATEG_SUB_FCS[$c["ref"]] = $collections;
        return 
$collections;
        }
    elseif(
is_array($allowed_fcs))
        {
        
$allowed_fcs_flipped array_flip($allowed_fcs);
        
        
// Collection is not allowed
        
if(!isset($allowed_fcs_flipped[$c['ref']]))
            {
            
$CACHE_FC_CATEG_SUB_FCS[$c["ref"]] = $collections;
            return 
$collections;
            }
        }

    
$all_fcs_rp reshape_array_by_value_keys($all_fcs'ref''parent');
    
$all_fcs array_flip_by_value_key($all_fcs'ref');

    
$queue = new SplQueue();
    
$queue->setIteratorMode(SplQueue::IT_MODE_DELETE);
    
$queue->enqueue($c['ref']);

    while(!
$queue->isEmpty())
        {
        
$fc $queue->dequeue();
        
$fc_children = array();

        if(
            
$all_fcs[$fc]['has_resources'] > 0
            
&& (
                
$allowed_fcs === true
                
|| (is_array($allowed_fcs) && isset($allowed_fcs_flipped[$fc]))
            )
        )
            {
            
$collections[] = $fc;
            }
        elseif(
$all_fcs[$fc]['has_children'] > 0)
            {
            
$fc_children array_keys($all_fcs_rp$fc);
            }

        foreach(
$fc_children as $fc_child_ref)
            {
            
$queue->enqueue($fc_child_ref);
            }
        }

    
$CACHE_FC_CATEG_SUB_FCS[$c["ref"]] = $collections;

    
debug("get_featured_collection_categ_sub_fcs(ref = {$c["ref"]}): returned collections: " implode(", "$collections));
    return 
$collections;
    }

This article was last updated 4th December 2024 09:05 Europe/London time based on the source file dated 27th November 2024 15:30 Europe/London time.