Collections functions
Encryption functions
General functions
Render functions
Theme permission functions
Video 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 161 to 203

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 26th November 2020 04:35 Europe/London time based on the source file dated 17th January 2020 16:11 Europe/London time.