getResourceAnnotations()

Description

Get annotations for a specific resource

Parameters

ColumnTypeDefaultDescription
$resource integer Resource ID
$page integer 0 Page number of a document. Non documents will have 0

Return

array

Location

include/annotation_functions.php lines 163 to 189

Definition

 
function getResourceAnnotations($resource$page 0)
{
    if (
>= $resource) {
        return array();
    }

    
$parameters = array("i",$resource);
    
$sql_page_filter 'AND `page` IS NULL';

    if (
$page) {
        
$sql_page_filter "AND `page` IS NOT NULL AND `page` = ?";
        
$parameters array_merge($parameters, array("i",$page));
    }

    return 
ps_query(
        
sprintf(
            
'SELECT %s, c.body AS "text"
                 FROM annotation AS a
            LEFT JOIN `comment` AS c ON a.ref = c.annotation
                WHERE resource = ?
                %s'
,
            
columns_in('annotation''a'),
            
$sql_page_filter
        
),
        
$parameters
    
);
}

This article was last updated 15th July 2025 09:05 Europe/London time based on the source file dated 4th July 2025 10:35 Europe/London time.