Format_Frontend
A trait containing various formatting and utility functions for frontend operations
The Format_Frontend
trait provides a collection of utility functions for handling dates, timezones, string manipulations, PDF text extraction, and JSON operations. This trait is designed to be used in frontend-related classes to enhance their functionality.
Date Formatting
getCorrectDateArticle
Formats a given date according to the current language settings.
The formatted date string
This function uses the IntlDateFormatter
to format the date based on the current language setting. It supports both German (de_DE) and English (en_US) locales.
Timezone Handling
timezone
Sets the user’s timezone in the session.
This function reads the timezone from the $_GET['time']
parameter and sets it in the user’s session.
String Manipulation
decodeFlate
Decompresses a string using gzip compression.
The decompressed string
pdf2text
Extracts text content from a PDF file.
The extracted text content from the PDF
This function reads the PDF file, processes its objects and streams, and extracts the text content.
This function relies on several helper functions to process PDF content, including getObjectOptions
, getDecodedStream
, getDirtyTexts
, getCharTransformations
, and getTextUsingTransformations
.
PDF Content Processing
getTextUsingTransformations
Analyzes text blocks from a PDF, taking into account character transformations.
The processed and transformed text content
decodeAsciiHex
Decodes ASCII hexadecimal encoded content.
The decoded string
decodeAscii85
Decodes ASCII85 encoded content.
The decoded string
getDecodedStream
Decodes a stream of data based on the provided options.
The decoded stream data
getDirtyTexts
Extracts text content from text containers in a PDF.
getCharTransformations
Extracts character transformations from a PDF stream.
JSON Processing
convertJSON
Loads and processes a JSON file, then displays the data in a view.
This function reads a JSON file from items/frontend/js/json.json
, decodes it, and passes the data to the frontend/json
view.
Object Processing
getObjectOptions
Extracts options from a PDF object string.
An array of extracted options
This function parses the PDF object string and extracts key-value pairs of options.