Collections functions
Encryption functions
General functions
Render functions
Theme permission functions
Video functions
Resource functions

render_featured_collection()

Description

Render a featured collection (as tiles on the collections_featured.php page)

Parameters

ColumnTypeDefaultDescription
$ctx array Context data to allow caller code to decide rendering requirements
$fc array Featured collection data structure

Return

void

Location

include/render_functions.php lines 4612 to 4766

Definition

 
function render_featured_collection(array $ctx, array $fc)
    {
    if(empty(
$fc))
        {
        return;
        }

    global 
$baseurl_short$lang$k$flag_new_themes$flag_new_themes_age;

    
$is_smart_featured_collection = (isset($ctx["smart"]) ? (bool) $ctx["smart"] : false);
    
$full_width = (isset($ctx["full_width"]) && $ctx["full_width"]);
    
$general_url_params = (isset($ctx["general_url_params"]) && is_array($ctx["general_url_params"]) ? $ctx["general_url_params"] : array());
    
$show_resources_count = (isset($ctx["show_resources_count"]) ? (bool) $ctx["show_resources_count"] : false);


    
$html_container_class = array("FeaturedSimplePanel""HomePanel""DashTile""FeaturedSimpleTile");
    
$html_container_style = array();


    
// Set main featured collection URL (e.g for collections it's the !collection[ID], for categories it's for collection_featured.php)
    
$html_fc_a_href generateURL("{$baseurl_short}pages/search.php"$general_url_params, array("search" => "!collection{$fc["ref"]}"));
    
$html_fc_a_href = (isset($ctx["href"]) && trim($ctx["href"]) !== "" $ctx["href"] : $html_fc_a_href);


    
$html_contents_class = array("FeaturedSimpleTileContents");
    
$html_contents_icon = (isset($ctx["icon"]) && trim($ctx["icon"]) != "" $ctx["icon"] : ICON_CUBE);
    
$fc_display_name strip_prefix_chars(i18n_get_collection_name($fc),"*");
            
    
$html_contents_h2 $html_contents_icon $fc_display_name;
    
$html_contents_h2_style = array();
    if(!
$is_smart_featured_collection && $flag_new_themes && (time() - strtotime($fc["created"])) < (60 60 24 $flag_new_themes_age))
        {
        
$html_contents_h2 .= sprintf(' <div class="NewFlag">%s</div>'htmlspecialchars($lang['newflag']));
        }
    if(
$full_width)
        {
        
$html_container_class[] = "FullWidth";
        
$html_contents_h2_style[] = "max-width: unset;";

        
$action_selection_id "themes_action_selection{$fc["ref"]}_bottom_{$fc["ref"]}";
        
        if(
$show_resources_count && !$is_smart_featured_collection)
            {
            
$html_contents_h2 .= sprintf(
                
' <span data-tag="resources_count" data-fc-ref="%s">%s</span>',
                
htmlspecialchars($fc['ref']),
                
htmlspecialchars($lang['counting_resources']));
            }
        }


    
$theme_images = (isset($ctx["images"]) ? $ctx["images"] : array());
    if(!empty(
$theme_images))
        {
        
$html_container_class[] = "FeaturedSimpleTileImage";
        
$html_contents_class[] = "TileContentShadow";

        if(
count($theme_images) == 1)
            {
            
$theme_image_path $theme_images[0];
            
$html_container_style[] = "background: url({$theme_image_path});";
            
$html_container_style[] = "background-size: cover;";
            
$theme_images = array();
            }
        }


    
$tools = (isset($ctx["tools"]) && is_array($ctx["tools"]) && !$full_width $ctx["tools"] : array());
    
$html_actions_style = ['display: none;'];
    if(
count($tools) > 3)
        {
        
$html_actions_style[] = "height: 43px;";
        }


    
// DEVELOPER NOTE: anything past this point should be set. All logic is handled above
    
?>
    <div id="FeaturedSimpleTile_ echo md5($fc['ref']); ?>" class=" echo implode(" "$html_container_class); ?>" style=" echo implode(" "$html_container_style); ?>">
        <a href=" echo $html_fc_a_href?>" onclick="return CentralSpaceLoad(this, true);" id="featured_tile_ echo $fc["ref"]; ?>" class="FeaturedSimpleLink">
            <div id="FeaturedSimpleTileContents_ echo $fc["ref"]; ?>" class=" echo implode(" "$html_contents_class); ?>">
            
            
foreach($theme_images as $i => $theme_image)
                {
                
$gap 200 count($theme_images);
                
$space $i $gap;
                
$style = array(
                    
"left: {$space}px;",
                    
"transform: rotate(" . (20 - ($i 12)) . "deg);"
                
);
                
?>
                <img src=" echo $theme_image?>" class="TileGroupImageBase" style=" echo implode(" "$style); ?>">
                
                
}
                
?>
                <h2 style=" echo implode(" "$html_contents_h2_style); ?>"> echo $html_contents_h2?></h2>
            </div>
        </a>
    
    
if(!empty($tools))
        {
        
?>
        <div id="FeaturedSimpleTileActions_ echo md5($fc['ref']); ?>" class="FeaturedSimpleTileActions" style=" echo implode(" "$html_actions_style); ?>">
        
        
foreach($tools as $tool)
            {
            if(empty(
$tool))
                {
                continue;
                }

            
$href = (isset($tool["href"]) && trim($tool["href"]) != "" $tool["href"] : "#");
            
$text $tool["text"]; // if this is missing, code is wrong somewhere else

            
$tool_onclick = (isset($tool["modal_load"]) && $tool["modal_load"] ? 'return ModalLoad(this, true);' 'return CentralSpaceLoad(this, true);');
            if(isset(
$tool["custom_onclick"]) && trim($tool["custom_onclick"]) != "")
                {
                
$tool_onclick $tool["custom_onclick"];
                }
            
?>
            <div class="tool">
                <a href=" echo $href?>" onclick=" echo $tool_onclick?>">
                    <span> echo LINK_CARET?> echo htmlspecialchars($text); ?></span>
                </a>
            </div>
            
            
}
            
?>
        </div><!-- End of FeaturedSimpleTileActions_ echo md5($fc['ref']); ?> -->
        
        
}
    else if(
$full_width && !$is_smart_featured_collection)
        {
        
?>
        <div class="ListTools">
            <div class="ActionsContainer">
                <select id=" echo $action_selection_id?>" onchange="action_onchange_ echo $action_selection_id?>(this.value);">
                    <option> echo htmlspecialchars($lang["actions-select"]); ?></option>
                </select>
            </div>
            <script>
            jQuery('# echo $action_selection_id?>').bind({
                mouseenter: function(e)
                    {
                    LoadActions('themes', ' echo $action_selection_id?>', 'collection', ' echo $fc["ref"]; ?>');
                    }
            });
            </script>
        </div><!-- End of ListTools -->
        
        
}
        
?>
    </div><!-- End of FeaturedSimpleTile_ echo $fc["ref"]; ?>-->
    
    
return;
    }

This article was last updated 21st April 2021 18:35 Europe/London time based on the source file dated 15th April 2021 09:35 Europe/London time.