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

process_posted_featured_collection_categories()

Description

Process POSTed featured collections categories data for a collection


then can be provided to {@see save_collection()} as: $coldata["featured_collections_changes"]

Parameters

ColumnTypeDefaultDescription
$depth integer The depth from which to start from. Usually zero.
$branch_path array A full branch path of the collection. {@see get_featured_collection_category_branch_by_leaf()}

Return

array Returns changes done regarding the collection featured collection category structure. This information

Location

include/collections_functions.php lines 5825 to 5891

Definition

 
function process_posted_featured_collection_categories(int $depth, array $branch_path)
    {
    global 
$enable_themes$FEATURED_COLLECTION_BG_IMG_SELECTION_OPTIONS;

    if(!(
$enable_themes && checkperm("h")))
        {
        return array();
        }

    if(
$depth 0)
        {
        return array();
        }

    
debug("process_posted_featured_collection_categories: Processing at \$depth = {$depth}");

    
// For public collections, the branch path doesn't exist (why would it?) in which case only root categories are valid
    
$current_lvl_parent = (!empty($branch_path) ? (int) $branch_path[$depth]["parent"] : 0);
    
debug("process_posted_featured_collection_categories: \$current_lvl_parent: " gettype($current_lvl_parent) . " = " json_encode($current_lvl_parent));

    
$selected_fc_category getval("selected_featured_collection_category_{$depth}"nulltrue);
    
debug("process_posted_featured_collection_categories: \$selected_fc_category: " gettype($selected_fc_category) . " = " json_encode($selected_fc_category));

    
$force_featured_collection_type = (getval("force_featured_collection_type""") == "true");
    
debug("process_posted_featured_collection_categories: \$force_featured_collection_type: " gettype($force_featured_collection_type) . " = " json_encode($force_featured_collection_type));

    
// Validate the POSTed featured collection category for this depth level
    
$valid_categories array_merge(array(0), array_column(get_featured_collection_categories($current_lvl_parent, array()), "ref"));
    if(
        !
is_null($selected_fc_category)
        && isset(
$branch_path[$depth])
        && !
in_array($selected_fc_category$valid_categories))
        {
        return array();
        }

    
$fc_category_at_level = (empty($branch_path) ? null $branch_path[$depth]["ref"]);
    
debug("process_posted_featured_collection_categories: \$fc_category_at_level: " gettype($fc_category_at_level) . " = " json_encode($fc_category_at_level));

    if(
$selected_fc_category != $fc_category_at_level || $force_featured_collection_type)
        {
        
$new_parent = ($selected_fc_category == $current_lvl_parent $selected_fc_category);
        
debug("process_posted_featured_collection_categories: \$new_parent: " gettype($new_parent) . " = " json_encode($new_parent));

        
$fc_update = array("update_parent" => $new_parent);

        if(
$force_featured_collection_type)
            {
            
$fc_update["force_featured_collection_type"] = true;
            }

        
// When moving a public collection to featured, default to most popular image
        
if($depth == && is_null($fc_category_at_level) && (int) $new_parent 0)
            {
            
$fc_update["thumbnail_selection_method"] = $FEATURED_COLLECTION_BG_IMG_SELECTION_OPTIONS["most_popular_image"];
            }

        return 
$fc_update;
        }

    if(
is_null($selected_fc_category))
        {
        return array();
        }

    return 
process_posted_featured_collection_categories(++$depth$branch_path);
    }

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