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

Description

Get images and resource count for search dash tile.
This has to work on a string because the dash tile does not yet exist when on dash creation page
For performance this function will return a maximum of 4 images

Parameters

ColumnTypeDefaultDescription
$link string '' Tile link URL
$promimg int 0 Promoted image ref

Return

array $searchdata Array containing the count of resources and details of preview images.

Location

include/dash_functions.php lines 2199 to 2259

Definition

 
function get_dash_search_data($link=''$promimg=0)
    {    
    global 
$search_all_workflow_states$view_title_field$lang;

    
$searchdata = [];
    
$searchdata["count"] = 0;
    
$searchdata["images"] = [];
    
    
$search_string explode('?',$link);
    
parse_str(str_replace("&","&",$search_string[1]),$search_string);
    
$search = isset($search_string["search"]) ? $search_string["search"] :"";
    
$restypes = isset($search_string["restypes"]) ? $search_string["restypes"] : "";
    
$order_by= isset($search_string["order_by"]) ? $search_string["order_by"] : "";
    
$archive = isset($search_string["archive"]) ? $search_string["archive"] : "";
    
$sort = isset($search_string["sort"]) ? $search_string["sort"] : "";

    if (
$archive !== ""){
        
$search_all_workflow_states false;
    }

    
$resultsdo_search($search,$restypes,$order_by,$archive,-1,$sort);    
    
$imagecount 0;
    if(
is_array($results))
        {
        
$resultcount count($results);
        
$searchdata["count"] = $resultcount;
        
$n 0;
        
// First see if we can get the promoted image by adding it to the front of the array
        
if($promimg != 0)
            {
            
$add get_resource_data($promimg);
            if(
is_array($add))
                {
                
array_unshift($results,$add);
                }
            }
        while(
$imagecount && $n $resultcount && $n 50// Don't keep trying to find images if none exist
            
{
            global 
$access// Needed by check_use_watermark()
            
$access=get_resource_access($results[$n]);
            if(
in_array($access,[RESOURCE_ACCESS_RESTRICTED,RESOURCE_ACCESS_FULL]))
                {
                
$use_watermark=check_use_watermark();
                if(
                    !
resource_has_access_denied_by_RT_size($results[$n]['resource_type'], 'pre')
                    && 
file_exists(get_resource_path($results[$n]['ref'], true'pre'false'jpg', -11$use_watermark))
                )
                    {
                    
$searchdata["images"][$imagecount]["ref"] = $results[$n]["ref"];
                    
$searchdata["images"][$imagecount]["thumb_width"] = $results[$n]["thumb_width"];
                    
$searchdata["images"][$imagecount]["thumb_height"] = $results[$n]["thumb_height"];
                    
$searchdata["images"][$imagecount]["url"] = get_resource_path($results[$n]["ref"],false,"pre",false,"jpg",-1,1,$use_watermark);
                    
$searchdata["images"][$imagecount]["title"] = escape($results[$n]["field".$view_title_field] ?? $lang["resource-1"] . " " $results[$n]["ref"]);
                    
$imagecount++;
                    }
                }
            
$n++;
            }
        }
    return 
$searchdata;
    }

This article was last updated 4th December 2024 08:35 Europe/London time based on the source file dated 13th November 2024 15:50 Europe/London time.