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

Parameters

ColumnTypeDefaultDescription
$resource
$count

Location

include/resource_functions.php lines 3895 to 3930

Definition

 
function get_resource_top_keywords($resource,$count)
    {
    
# Return the top $count keywords (by hitcount) used by $resource.
    # This section is for the 'Find Similar' search.
    # Currently the date fields are not used for this feature

    
$return=array();

    
$keywords ps_query("SELECT DISTINCT n.ref, n.name, n.resource_type_field FROM node n INNER JOIN resource_node rn ON n.ref=rn.node WHERE (rn.resource = ? AND n.resource_type_field IN (SELECT rtf.ref FROM resource_type_field rtf WHERE use_for_similar=1) ) ORDER BY new_hit_count DESC LIMIT $count",["i",$resource]);

    foreach (
$keywords as $keyword )
        {
        
# Apply permissions and strip out any results the user does not have access to.
        
if (metadata_field_view_access($keyword["resource_type_field"]) && !checkperm("T" $resource))
            {
            
$r =  $keyword["name"] ;
            }

        if(isset(
$r) && trim($r) != '')
            {
            if (
substr($r,0,1)==","){$r=substr($r,1);}
            
$s=split_keywords(i18n_get_translated($r));
            
# Splitting keywords can result in break words being included in these results
            # These should be removed here otherwise they will show as keywords themselves which is incorrect
            
global $noadd;
            foreach (
$s as $a)
                {
                if(!empty(
$a) && !in_array($a,$noadd))
                    {
                    
$return[]=$a;
                    }
                }
            }
        }
    return 
$return;
    }

This article was last updated 24th September 2024 15:35 Europe/London time based on the source file dated 23rd September 2024 15:35 Europe/London time.