TextPrintService
in package
Service class for managing text printing operations.
Tags
Table of Contents
Constants
- ANN_PLACEMENT_BEHIND = 0
- Annotation placement - behind the term.
- ANN_PLACEMENT_INFRONT = 1
- Annotation placement - in front of the term.
- ANN_PLACEMENT_RUBY = 2
- Annotation placement - above the term (ruby).
- ANN_SHOW_ROM = 2
- Annotation options - show romanization.
- ANN_SHOW_TAGS = 4
- Annotation options - show tags.
- ANN_SHOW_TRANS = 1
- Annotation options - show translation.
Methods
- checkStatusInRange() : bool
- Check if a word status is within the given range.
- deleteAnnotation() : bool
- Delete annotated text for a text.
- getAnnotatedText() : string|null
- Get annotated text for a text ID.
- getAnnotationForApi() : array<string|int, mixed>|null
- Get annotated text items formatted for API response.
- getAnnotationPlacementSetting() : int
- Get current annotation placement setting.
- getAnnotationSetting() : int
- Get current print annotation setting.
- getLanguageData() : array<string|int, mixed>|null
- Get language data for a text.
- getStatusRangeSetting() : int
- Get current print status range setting.
- getTextData() : array<string|int, mixed>|null
- Get basic text data for printing.
- getTextItems() : array<string|int, mixed>
- Get text items for plain print display.
- getTextItemsForApi() : array<string|int, mixed>
- Get text items formatted for API response.
- getTtsClass() : string|null
- Extract TTS language code from Google Translate URI.
- getWordTags() : string
- Get word tags for a word ID.
- hasAnnotation() : bool
- Check if annotated text exists for a text.
- parseAnnotation() : array<string|int, mixed>
- Parse annotation string into structured items.
- prepareAnnotatedPrintData() : array<string|int, mixed>|null
- Prepare data for improved/annotated text print view.
- preparePlainPrintData() : array<string|int, mixed>|null
- Prepare data for plain text print view.
- savePrintSettings() : void
- Save current print settings.
- setCurrentText() : void
- Save current text setting only.
Constants
ANN_PLACEMENT_BEHIND
Annotation placement - behind the term.
public
mixed
ANN_PLACEMENT_BEHIND
= 0
ANN_PLACEMENT_INFRONT
Annotation placement - in front of the term.
public
mixed
ANN_PLACEMENT_INFRONT
= 1
ANN_PLACEMENT_RUBY
Annotation placement - above the term (ruby).
public
mixed
ANN_PLACEMENT_RUBY
= 2
ANN_SHOW_ROM
Annotation options - show romanization.
public
mixed
ANN_SHOW_ROM
= 2
ANN_SHOW_TAGS
Annotation options - show tags.
public
mixed
ANN_SHOW_TAGS
= 4
ANN_SHOW_TRANS
Annotation options - show translation.
public
mixed
ANN_SHOW_TRANS
= 1
Methods
checkStatusInRange()
Check if a word status is within the given range.
public
checkStatusInRange(int $status, int $statusRange) : bool
Parameters
- $status : int
-
Word status
- $statusRange : int
-
Status range flags
Return values
bool —True if status is in range
deleteAnnotation()
Delete annotated text for a text.
public
deleteAnnotation(int $textId) : bool
Parameters
- $textId : int
-
Text ID
Return values
bool —True if deletion was successful
getAnnotatedText()
Get annotated text for a text ID.
public
getAnnotatedText(int $textId) : string|null
Parameters
- $textId : int
-
Text ID
Return values
string|null —Annotated text or null if not found/empty
getAnnotationForApi()
Get annotated text items formatted for API response.
public
getAnnotationForApi(int $textId) : array<string|int, mixed>|null
Parses the stored annotation string into structured data.
Parameters
- $textId : int
-
Text ID
Return values
array<string|int, mixed>|null —Array of annotation items or null if no annotation
getAnnotationPlacementSetting()
Get current annotation placement setting.
public
getAnnotationPlacementSetting(string|null $requestValue) : int
Parameters
- $requestValue : string|null
-
Value from request
Return values
int —Placement code
getAnnotationSetting()
Get current print annotation setting.
public
getAnnotationSetting(string|null $requestValue) : int
Parameters
- $requestValue : string|null
-
Value from request
Return values
int —Annotation flags
getLanguageData()
Get language data for a text.
public
getLanguageData(int $langId) : array<string|int, mixed>|null
Parameters
- $langId : int
-
Language ID
Return values
array<string|int, mixed>|null —Language data or null if not found
getStatusRangeSetting()
Get current print status range setting.
public
getStatusRangeSetting(string|null $requestValue) : int
Parameters
- $requestValue : string|null
-
Value from request
Return values
int —Status range
getTextData()
Get basic text data for printing.
public
getTextData(int $textId) : array<string|int, mixed>|null
Parameters
- $textId : int
-
Text ID
Return values
array<string|int, mixed>|null —Text data or null if not found
getTextItems()
Get text items for plain print display.
public
getTextItems(int $textId) : array<string|int, mixed>
Parameters
- $textId : int
-
Text ID
Return values
array<string|int, mixed> —Array of text items with word data
getTextItemsForApi()
Get text items formatted for API response.
public
getTextItemsForApi(int $textId) : array<string|int, mixed>
Returns structured data with word tags included, suitable for client-side rendering of the print view.
Parameters
- $textId : int
-
Text ID
Return values
array<string|int, mixed> —Array of text items with full word data
getTtsClass()
Extract TTS language code from Google Translate URI.
public
getTtsClass(string $googleTranslateUri) : string|null
Parameters
- $googleTranslateUri : string
-
Google Translate URI
Return values
string|null —TTS class suffix or null
getWordTags()
Get word tags for a word ID.
public
getWordTags(int $wordId) : string
Parameters
- $wordId : int
-
Word ID
Return values
string —Tags list
hasAnnotation()
Check if annotated text exists for a text.
public
hasAnnotation(int $textId) : bool
Parameters
- $textId : int
-
Text ID
Return values
bool —True if annotated text exists
parseAnnotation()
Parse annotation string into structured items.
public
parseAnnotation(string $annotation) : array<string|int, mixed>
Parameters
- $annotation : string
-
Annotation string
Return values
array<string|int, mixed> —Array of parsed annotation items
prepareAnnotatedPrintData()
Prepare data for improved/annotated text print view.
public
prepareAnnotatedPrintData(int $textId) : array<string|int, mixed>|null
Parameters
- $textId : int
-
Text ID
Return values
array<string|int, mixed>|null —View data or null if text not found
preparePlainPrintData()
Prepare data for plain text print view.
public
preparePlainPrintData(int $textId) : array<string|int, mixed>|null
Parameters
- $textId : int
-
Text ID
Return values
array<string|int, mixed>|null —View data or null if text not found
savePrintSettings()
Save current print settings.
public
savePrintSettings(int $textId, int $annotation, int $statusRange, int $placement) : void
Parameters
- $textId : int
-
Text ID
- $annotation : int
-
Annotation flags
- $statusRange : int
-
Status range
- $placement : int
-
Annotation placement
setCurrentText()
Save current text setting only.
public
setCurrentText(int $textId) : void
Parameters
- $textId : int
-
Text ID