Collections functions
General functions
Render functions
Theme permission functions
Resource functions

getAnnotoriousResourceAnnotations()

Description

Create an array of Annotorious annotation objects which can be JSON encoded and passed
directly to Annotorious

Parameters

ColumnTypeDefaultDescription
$resource integer Resource ID
$page integer 0 Page number of a document

Return

array

Location

include/annotation_functions.php lines 156 to 198

Definition

 
function getAnnotoriousResourceAnnotations($resource$page 0)
    {
    global 
$baseurl;

    
$annotations = array();

    
/*
    Build an annotations array of Annotorious annotation objects

    IMPORTANT: until ResourceSpace will have text fields implemented as nodes, text should be left blank.
    
    NOTE: src attribute is generated per resource (dummy source) to avoid issues when source is
    loaded from download.php
    */
    
foreach(getResourceAnnotations($resource$page) as $annotation)
        {
        
$annotations[] = array(
                
'src'    => "{$baseurl}/annotation/resource/{$resource}",
                
'text'   => '',
                
'shapes' => array(
                    array(
                        
'type'     => 'rect',
                        
'geometry' => array(
                            
'x'      => (float) $annotation['x'],
                            
'y'      => (float) $annotation['y'],
                            
'width'  => (float) $annotation['width'],
                            
'height' => (float) $annotation['height'],
                        )
                    )
                ),
                
'editable' => annotationEditable($annotation),

                
// Custom ResourceSpace properties for Annotation object
                
'ref'                 => (int) $annotation['ref'],
                
'resource'            => (int) $annotation['resource'],
                
'resource_type_field' => (int) $annotation['resource_type_field'],
                
'page'                => (int) $annotation['page'],
                
'tags'                => getAnnotationTags($annotation),
            );
        }

    return 
$annotations;
    }

This article was last updated 2nd October 2022 18:05 Europe/London time based on the source file dated 29th July 2022 11:20 Europe/London time.