Methods

createAbsoluteUrl()

createAbsoluteUrl(  $relativePart,   $baseUrl) : string

Construct an absolute URL from a base URL and a relative part.

Parameters

$relativePart

relative part of the URL

$baseUrl

base URL

Returns

string —

absolute URL

createTranslator()

createTranslator(\OpenEstate\PhpExport\Environment  $env, string|null  $languageCode = null) : \OpenEstate\PhpExport\Translator

Create a translator for a certain language.

Parameters

\OpenEstate\PhpExport\Environment $env

export environment

string|null $languageCode

custom ISO language code

Returns

\OpenEstate\PhpExport\Translator

translator instance

encode()

encode(string  $input, string  $targetCharset) : string

Convert a string into another charset.

Parameters

string $input

input string

string $targetCharset

target encoding

Returns

string —

encoded output string

getAbbreviatedString()

getAbbreviatedString(string  $value, integer  $length, boolean  $singleLine = false) : string

Get an abbreviated string.

Parameters

string $value

string value to abbreviate

integer $length

maximum length of the abbreviated string

boolean $singleLine

remove line breaks before abbreviation

Returns

string —

abbreviated string

getAbsoluteUrl()

getAbsoluteUrl(  $url) : string

Convert a relative URL to an absolute URL.

Parameters

$url

relative URL

Returns

string —

absolute URL

getAttributeValue()

getAttributeValue(string  $group, string  $attribute, array  $value, string  $lang) : string

Get the value for an attribute.

Parameters

string $group

name of the attribute group

string $attribute

name of the attribute

array $value

attribute value

string $lang

language code

Returns

string —

readable output of the attribute value

getCaptchaHash()

getCaptchaHash(string  $captchaCode, integer  $stamp = null) : string

Generates a secure captcha has value.

Parameters

string $captchaCode

captcha code

integer $stamp

timestamp

Returns

string —

captcha hash value

getDefaultFilterObjects()

getDefaultFilterObjects(string  $basePath) : array

Get list of default filter objects.

Parameters

string $basePath

absolute path, that points to the root of the export environment

Returns

array —

list of filter objects

getDefaultOrderObjects()

getDefaultOrderObjects(string  $basePath) : array

Get list of default order objects.

Parameters

string $basePath

absolute path, that points to the root of the export environment

Returns

array —

list of order objects

getFileStamp()

getFileStamp(string  $file) : integer|null

Returns the timestamp, when a certain file was last modified.

Parameters

string $file

path to the file

Returns

integer|null —

timestamp of last modification or null, if the file is not available

getJson()

getJson(mixed  $obj, boolean  $json = true) : string

Convert a variable to JSON.

Parameters

mixed $obj

variable to convert

boolean $json

encode for JSON if true, otherwise encode for Javascript

Returns

string —

JSON string

getMinimizedHtml()

getMinimizedHtml(string  $html) : string

Returns minimized HTML code.

Parameters

string $html

HTML code to minimize

Returns

string —

minimized HTML code

getNumberOfPages()

getNumberOfPages(integer  $numberOfObjects, integer  $objectsPerPage) : integer

Returns the number of pages required to show a certain list of objects.

Parameters

integer $numberOfObjects

total number of objects

integer $objectsPerPage

number of objects visible on a page

Returns

integer —

number of pages

getRgbFromHex()

getRgbFromHex(string  $hex) : array

Converts a hexadecimal color code to an RGB array.

Parameters

string $hex

hexadecimal color code, e.g. #c0c0c0 or 1a2b3c

Returns

array —

associative array with separate RGB integer values or null, if the provided hexadecimal code is invalid

getUrlParameters()

getUrlParameters(array  $parameters) : string

Converts an array of parameters into a URL query string.

Parameters

array $parameters

associative array of parameters

Returns

string —

URL query string

getUserLanguages()

getUserLanguages() : array

Returns a list of preferred languages by the user's browser.

Returns

array —

list of language codes

isBlankString()

isBlankString(string  $string) : boolean

Tests, if a string value is blank.

Parameters

string $string

the string value to test

Returns

boolean —

true, if the provided value is not a string or it is an empty string or it contains only non-whitespaces

isEmptyArray()

isEmptyArray(array|null  $array) : boolean

Tests, if an array is empty.

Parameters

array|null $array

the array value to test

Returns

boolean —

true, if the provided value is not an array or it is doesn't contain any elements

isEmptyString()

isEmptyString(string  $string) : boolean

Tests, if a string value is empty.

Parameters

string $string

the string value to test

Returns

boolean —

true, if the provided value is not a string or it is an empty string

isFileOlderThen()

isFileOlderThen(string  $file, integer  $maxLifetime) : boolean

Tests, if a file is older then a certain lifetime.

Parameters

string $file

path to the file

integer $maxLifetime

maximum lifetime of the file in seconds

Returns

boolean —

true, if the file is older then the specified lifetime.

isFileYoungerThen()

isFileYoungerThen(string  $file, integer  $maxLifetime) : boolean

Tests, if a file is younger then a certain lifetime.

Parameters

string $file

path to the file

integer $maxLifetime

maximum lifetime of the file in seconds

Returns

boolean —

true, if the file is younger then the specified lifetime.

isGdExtensionAvailable()

isGdExtensionAvailable() : boolean

Tests, if the GD extension is available in the PHP environment.

Returns

boolean —

true, if the GD extension is available

isNotBlankString()

isNotBlankString(string  $string) : boolean

Tests, if a string value is not blank.

Parameters

string $string

the string value to test

Returns

boolean —

true, if the provided value is a string and contains at least one non-whitespace character

isNotEmptyArray()

isNotEmptyArray(array|null  $array) : boolean

Tests, if an array is not empty.

Parameters

array|null $array

the array value to test

Returns

boolean —

true, if the provided value is an array and contains at least one element

isNotEmptyString()

isNotEmptyString(string  $string) : boolean

Tests, if a string value is not empty.

Parameters

string $string

the string value to test

Returns

boolean —

true, if the provided value is a string and contains at least one character

isNotValidCaptcha()

isNotValidCaptcha(string  $captchaCode, string  $captchaHash, integer  $maxAge = 3600) : boolean

Tests, if a captcha code does not match against a captcha hash.

Parameters

string $captchaCode

captcha code

string $captchaHash

captcha hash

integer $maxAge

maximum age, a captcha code is considered valid (in seconds)

Returns

boolean —

true, if the captcha code matches the hash

isNotValidEmail()

isNotValidEmail(string  $email) : boolean

Tests, if an email address is not valid.

Parameters

string $email

email address to test

Returns

boolean —

true, if the provided email address is valid

isValidCaptcha()

isValidCaptcha(string  $captchaCode, string  $captchaHash, integer  $maxAge = 1800) : boolean

Tests, if a captcha code matches against a captcha hash.

Parameters

string $captchaCode

captcha code

string $captchaHash

captcha hash

integer $maxAge

maximum age, a captcha code is considered valid (in seconds)

Returns

boolean —

true, if the captcha code matches the hash

isValidEmail()

isValidEmail(string  $email) : boolean

Tests, if an email address is valid.

Parameters

string $email

email address to test

Returns

boolean —

true, if the provided email address is valid

joinPath()

joinPath(string  $path, array|null  $children) : string

Join a path with a file or subfolder name.

Parameters

string $path

parent path

array|null $children

child elements within the path

Returns

string —

joined path

lastModified()

lastModified(integer  $timestamp, string  $identifier = "", boolean  $strict = false) : boolean

Sets http response headers "last-modified" and "etag"

This function also checks if the client cached version of the requested site is still up to date by comparing last-modified and/or etag headers of server and client (in stict mode both have to match) for a given last modification timestamp and identifier (optional). If this client cached version is up to date the status header 304 (not modified) will be set and the program will be terminated.

Parameters

integer $timestamp

late modification timestamp

string $identifier

additional identifier (optional, default: "")

boolean $strict

use strict mode (optional, default: false)

Returns

boolean —

true if headers could be set, otherwise false

listDirectory()

listDirectory(string  $directory) : array

List names of files and sub-folders in a directory.

Parameters

string $directory

path to the directory

Returns

array —

names of files and sub-folders in the directory

logDeprecated()

logDeprecated(string  $msg) 

Log a deprecation notice.

Parameters

string $msg

message

logError()

logError(string  $msg) 

Log an error.

Parameters

string $msg

message

logNotice()

logNotice(string  $msg) 

Log a notice.

Parameters

string $msg

message

logWarning()

logWarning(string  $msg) 

Log a warning.

Parameters

string $msg

message

printErrorException()

printErrorException(\Exception  $exception) 

Print an error exception.

Parameters

\Exception $exception

exception to print

printErrorMessage()

printErrorMessage(string  $message) 

Print an error message.

Parameters

string $message

error message to print

readFile()

readFile(string  $file) : string|null

Returns the contents of a file as string.

Parameters

string $file

path to the file

Returns

string|null —

file contents or null, if the file is not loadable

replaceLinks()

replaceLinks(string  $text) : string

Replace URL's in a text with HTML links.

Parameters

string $text

text

Returns

string —

HTML code of the text with replaced links

writeBytes()

writeBytes(integer  $bytes) : string

Write number of bytes in readable form.

Parameters

integer $bytes

number of bytes

Returns

string —

readable number of bytes

writeObjectField()

writeObjectField(array  $object, string  $field, array  $i18n, string  $lang, boolean  $valueOnly = false) : null|string

Write a certain object attribute.

Parameters

array $object

object data

string $field

name of the field to show

array $i18n

translations

string $lang

language code

boolean $valueOnly

only write the attribute value

Returns

null|string —

HTML encoded output for the requested field

writeStatistics()

writeStatistics(integer  $buildTime) : string

Write statistics.

Parameters

integer $buildTime

page generation time in milliseconds

Returns

string —

HTML code with statistics

log()

log(string|\Throwable  $msg, integer  $type) 

Send a PHP log message.

Parameters

string|\Throwable $msg

message or exception

integer $type

log level