TextAnnotationApiHandler
in package
Handler for annotation CRUD and print items operations.
Table of Contents
Methods
- editTermForm() : string
- Full form for terms edition in a given text.
- formatEditTermForm() : array{html: string}
- Format response for edit term form HTML.
- formatGetAnnotation() : array{items: array|null, config: array}|array{error: string}
- Format response for getting annotation.
- formatGetPrintItems() : array{items: array, config: array}|array{error: string}
- Format response for getting print items.
- formatSetAnnotation() : array{save_impr_text?: string|null, error?: string}
- Format response for setting annotation.
- getAnnotation() : array{items: array|null, config: array}|array{error: string}
- Get annotation items for improved/annotated text view.
- getPrintItems() : array{items: array, config: array}|array{error: string}
- Get print items and configuration for a text.
- makeTrans() : string
- Make the translations choices for a term.
- saveImprText() : array{error?: string, success?: string}
- Save a text with improved annotations.
- saveImprTextData() : array{success: bool, error?: string, requested?: int, available?: int, position?: int, found?: int}
- Save data from printed text.
- formatAnnotationError() : string
- Format annotation save error into human-readable message.
Methods
editTermForm()
Full form for terms edition in a given text.
public
editTermForm(int $textid) : string
Parameters
- $textid : int
-
Text ID.
Return values
string —HTML table for all terms
formatEditTermForm()
Format response for edit term form HTML.
public
formatEditTermForm(int $textId) : array{html: string}
Parameters
- $textId : int
-
Text ID
Return values
array{html: string}formatGetAnnotation()
Format response for getting annotation.
public
formatGetAnnotation(int $textId) : array{items: array|null, config: array}|array{error: string}
Parameters
- $textId : int
-
Text ID
Return values
array{items: array|null, config: array}|array{error: string}formatGetPrintItems()
Format response for getting print items.
public
formatGetPrintItems(int $textId) : array{items: array, config: array}|array{error: string}
Parameters
- $textId : int
-
Text ID
Return values
array{items: array, config: array}|array{error: string}formatSetAnnotation()
Format response for setting annotation.
public
formatSetAnnotation(int $textId, string $elem, string $data) : array{save_impr_text?: string|null, error?: string}
Parameters
- $textId : int
-
Text ID
- $elem : string
-
Element selector
- $data : string
-
JSON-encoded data
Return values
array{save_impr_text?: string|null, error?: string}getAnnotation()
Get annotation items for improved/annotated text view.
public
getAnnotation(int $textId) : array{items: array|null, config: array}|array{error: string}
Parameters
- $textId : int
-
Text ID
Return values
array{items: array|null, config: array}|array{error: string}getPrintItems()
Get print items and configuration for a text.
public
getPrintItems(int $textId) : array{items: array, config: array}|array{error: string}
Parameters
- $textId : int
-
Text ID
Return values
array{items: array, config: array}|array{error: string}makeTrans()
Make the translations choices for a term.
public
makeTrans(int $i, int|null $wid, string $trans, string $word, int $lang) : string
Parameters
- $i : int
-
Word unique index in the form
- $wid : int|null
-
Word ID or null
- $trans : string
-
Current translation set for the term, may be empty
- $word : string
-
Term text
- $lang : int
-
Language ID
Return values
string —HTML-formatted string
saveImprText()
Save a text with improved annotations.
public
saveImprText(int $textid, string $elem, object $data) : array{error?: string, success?: string}
Parameters
- $textid : int
-
Text ID
- $elem : string
-
Element to select
- $data : object
-
Data element
Return values
array{error?: string, success?: string}saveImprTextData()
Save data from printed text.
public
saveImprTextData(int $textid, int $line, string $val) : array{success: bool, error?: string, requested?: int, available?: int, position?: int, found?: int}
Parameters
- $textid : int
-
Text ID
- $line : int
-
Line number to save
- $val : string
-
Proposed new annotation for the term
Return values
array{success: bool, error?: string, requested?: int, available?: int, position?: int, found?: int}formatAnnotationError()
Format annotation save error into human-readable message.
private
formatAnnotationError(array{success: bool, error?: string, requested?: int, available?: int, position?: int, found?: int} $result) : string
Parameters
- $result : array{success: bool, error?: string, requested?: int, available?: int, position?: int, found?: int}
Return values
string —Formatted error message