Collections functions
General functions
Node functions
Render functions
Theme permission functions
User 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 202

Definition

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

    
$annotations = array();
    
$can_view_fields canSeeAnnotationsFields();

    
/*
    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)
        {
        if(
in_array($annotation['resource_type_field'], $can_view_fields))
            {
            
$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 19th March 2024 05:05 Europe/London time based on the source file dated 6th March 2024 14:45 Europe/London time.