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

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 17th November 2024 15:35 Europe/London time based on the source file dated 6th March 2024 14:45 Europe/London time.