PHP Класс Contao\System

The class provides miscellaneous methods that are used all throughout the application. It is the base class of the Contao library which provides the central "import" method to load other library classes. Usage: class MyClass extends \System { public function __construct() { $this->import('Database'); } }
Показать файл Открыть проект Примеры использования класса

Защищенные свойства (Protected)

Свойство Тип Описание
$arrCache array Cache
$arrImageSizes array Available image sizes
$arrLanguageFiles array Loaded language files
$arrLanguages array Available languages
$arrObjects array Default libraries
$arrStaticObjects array Static objects
$objContainer Symfony\Component\DependencyInjection\ContainerInterface Container

Открытые методы

Метод Описание
__get ( string $strKey ) : mixed | null Get an object property
addToUrl ( string $strRequest ) : string Add a request string to the current URL
anonymizeIp ( string $strIp ) : string Anonymize an IP address by overriding the last chunk
convertXlfToPhp ( string $strName, string $strLanguage, boolean $blnLoad = false ) : string Convert an .xlf file into a PHP language file
disableModule ( ) : boolean Disable a back end module
enableModule ( ) : boolean Enable a back end module
getContainer ( ) : Symfony\Component\DependencyInjection\ContainerInterface Return the container object
getCountries ( ) : array Return the countries as array
getFormattedNumber ( mixed $varNumber, integer $intDecimals = 2 ) : mixed Format a number
getImageSizes ( ) : array Return all image sizes as array
getIndexFreeRequest ( boolean $blnAmpersand = true ) : string Return the request string without the script name
getLanguages ( boolean $blnInstalledOnly = false ) : array Return the available languages as array
getModelClassFromTable ( string $strTable ) : string Compile a Model class name from a table name (e.g. tl_form_field becomes FormFieldModel)
getReadableSize ( integer $intSize, integer $intDecimals = 1 ) : string Convert a byte value into a human readable format
getReferer ( boolean $blnEncodeAmpersands = false, string $strTable = null ) : string Return the referer URL and optionally encode ampersands
getSessionHash ( string $strCookie ) : string Return the session hash
getTimeZones ( ) : array Return the timezones as array
importStatic ( string $strClass, string $strKey = null, boolean $blnForce = false ) : object Import a library in non-object context
isInstalledLanguage ( boolean $strLanguage ) : boolean Check whether a language is installed
loadLanguageFile ( string $strName, boolean $strLanguage = null, boolean $blnNoCache = false ) Load a set of language files
log ( string $strText, string $strFunction, string $strCategory ) Add a log entry to the database
parseDate ( string $strFormat, integer $intTstamp = null ) : string Parse a date format string and translate textual representations
redirect ( string $strLocation, integer $intStatus = 303 ) Redirect to another page
reload ( ) Reload the current page
setContainer ( Symfony\Component\DependencyInjection\ContainerInterface $container ) Set the container object
setCookie ( string $strName, mixed $varValue, integer $intExpires, string $strPath = null, string $strDomain = null, boolean $blnSecure = false, boolean $blnHttpOnly = false ) Set a cookie
splitFriendlyName ( string $strEmail ) : array Split a friendly-name e-address and return name and e-mail as array
urlEncode ( string $strPath ) : string Urlencode a file path preserving slashes

Защищенные методы

Метод Описание
__construct ( ) Import the Config and Session instances
addConfirmationMessage ( string $strMessage ) Add a confirmation message
addErrorMessage ( string $strMessage ) Add an error message
addInfoMessage ( string $strMessage ) Add an info message
addMessage ( string $strMessage, string $strType ) Add a message
addNewMessage ( string $strMessage ) Add a new message
addRawMessage ( string $strMessage ) Add an unformatted message
getMessageTypes ( ) : array Return all available message types
getMessages ( string $strScope = TL_MODE ) : string Return all messages as HTML
idnaDecode ( string $strDomain ) : string Decode an internationalized domain name
idnaEncode ( string $strDomain ) : string Encode an internationalized domain name
idnaEncodeEmail ( string $strEmail ) : string Encode the domain in an e-mail address
idnaEncodeUrl ( string $strUrl ) : string Encode the domain in an URL
import ( string $strClass, string $strKey = null, boolean $blnForce = false ) Import a library and make it accessible by its name or an optional key
isValidEmailAddress ( string $strEmail ) : boolean Validate an e-mail address
readPhpFileWithoutTags ( string $strName ) : string Read the contents of a PHP file, stripping the opening and closing PHP tags
resetMessages ( ) Reset the message system

Описание методов

__construct() защищенный Метод

Import the Config and Session instances
protected __construct ( )

__get() публичный Метод

Lazy load the Input and Environment libraries (which are now static) and only include them as object property if an old module requires it
public __get ( string $strKey ) : mixed | null
$strKey string The property name
Результат mixed | null The property value or null

addConfirmationMessage() защищенный Метод

Add a confirmation message
Устаревший: Deprecated since Contao 4.0, to be removed in Contao 5.0. Use Message::addConfirmation() instead.
protected addConfirmationMessage ( string $strMessage )
$strMessage string The confirmation

addErrorMessage() защищенный Метод

Add an error message
Устаревший: Deprecated since Contao 4.0, to be removed in Contao 5.0. Use Message::addError() instead.
protected addErrorMessage ( string $strMessage )
$strMessage string The error message

addInfoMessage() защищенный Метод

Add an info message
Устаревший: Deprecated since Contao 4.0, to be removed in Contao 5.0. Use Message::addInfo() instead.
protected addInfoMessage ( string $strMessage )
$strMessage string The info message

addMessage() защищенный Метод

Add a message
Устаревший: Deprecated since Contao 4.0, to be removed in Contao 5.0. Use Message::add() instead.
protected addMessage ( string $strMessage, string $strType )
$strMessage string The message
$strType string The message type

addNewMessage() защищенный Метод

Add a new message
Устаревший: Deprecated since Contao 4.0, to be removed in Contao 5.0. Use Message::addNew() instead.
protected addNewMessage ( string $strMessage )
$strMessage string The new message

addRawMessage() защищенный Метод

Add an unformatted message
Устаревший: Deprecated since Contao 4.0, to be removed in Contao 5.0. Use Message::addRaw() instead.
protected addRawMessage ( string $strMessage )
$strMessage string The unformatted message

addToUrl() публичный статический Метод

Add a request string to the current URL
Устаревший: Deprecated since Contao 4.0, to be removed in Contao 5.0. Use Controller::addToUrl() instead.
public static addToUrl ( string $strRequest ) : string
$strRequest string The string to be added
Результат string The new URL

anonymizeIp() публичный статический Метод

Anonymize an IP address by overriding the last chunk
public static anonymizeIp ( string $strIp ) : string
$strIp string The IP address
Результат string The encoded IP address

convertXlfToPhp() публичный статический Метод

Convert an .xlf file into a PHP language file
Устаревший: Deprecated since Contao 4.0, to be removed in Contao 5.0. Use the Contao\CoreBundle\Config\Loader\XliffFileLoader instead.
public static convertXlfToPhp ( string $strName, string $strLanguage, boolean $blnLoad = false ) : string
$strName string The name of the .xlf file
$strLanguage string The language code
$blnLoad boolean Add the labels to the global language array
Результат string The PHP code

disableModule() публичный статический Метод

Disable a back end module
Устаревший: Deprecated since Contao 4.0, to be removed in Contao 5.0. Use Composer to add or remove modules.
public static disableModule ( ) : boolean
Результат boolean True if the module was disabled

enableModule() публичный статический Метод

Enable a back end module
Устаревший: Deprecated since Contao 4.0, to be removed in Contao 5.0. Use Composer to add or remove modules.
public static enableModule ( ) : boolean
Результат boolean True if the module was enabled

getContainer() публичный статический Метод

Return the container object
public static getContainer ( ) : Symfony\Component\DependencyInjection\ContainerInterface
Результат Symfony\Component\DependencyInjection\ContainerInterface The container object

getCountries() публичный статический Метод

Return the countries as array
public static getCountries ( ) : array
Результат array An array of country names

getFormattedNumber() публичный статический Метод

Format a number
public static getFormattedNumber ( mixed $varNumber, integer $intDecimals = 2 ) : mixed
$varNumber mixed An integer or float number
$intDecimals integer The number of decimals to show
Результат mixed The formatted number

getImageSizes() публичный статический Метод

Return all image sizes as array
Устаревший: Deprecated since Contao 4.1, to be removed in Contao 5. Use the contao.image.image_sizes service instead.
public static getImageSizes ( ) : array
Результат array The available image sizes

getIndexFreeRequest() публичный статический Метод

Return the request string without the script name
Устаревший: Deprecated since Contao 4.0, to be removed in Contao 5.0. Use Environment::get("indexFreeRequest") instead.
public static getIndexFreeRequest ( boolean $blnAmpersand = true ) : string
$blnAmpersand boolean If true, ampersands will be encoded
Результат string The request string

getLanguages() публичный статический Метод

Return the available languages as array
public static getLanguages ( boolean $blnInstalledOnly = false ) : array
$blnInstalledOnly boolean If true, return only installed languages
Результат array An array of languages

getMessageTypes() защищенный Метод

Return all available message types
Устаревший: Deprecated since Contao 4.0, to be removed in Contao 5.0. Use Message::getTypes() instead.
protected getMessageTypes ( ) : array
Результат array An array of message types

getMessages() защищенный Метод

Return all messages as HTML
Устаревший: Deprecated since Contao 4.0, to be removed in Contao 5.0. Use Message::generate() instead.
protected getMessages ( string $strScope = TL_MODE ) : string
$strScope string An optional message scope
Результат string The messages HTML markup

getModelClassFromTable() публичный статический Метод

Compile a Model class name from a table name (e.g. tl_form_field becomes FormFieldModel)
Устаревший: Deprecated since Contao 4.0, to be removed in Contao 5.0. Use Model::getClassFromTable() instead.
public static getModelClassFromTable ( string $strTable ) : string
$strTable string The table name
Результат string The model class name

getReadableSize() публичный статический Метод

Convert a byte value into a human readable format
public static getReadableSize ( integer $intSize, integer $intDecimals = 1 ) : string
$intSize integer The size in bytes
$intDecimals integer The number of decimals to show
Результат string The human readable size

getReferer() публичный статический Метод

Return the referer URL and optionally encode ampersands
public static getReferer ( boolean $blnEncodeAmpersands = false, string $strTable = null ) : string
$blnEncodeAmpersands boolean If true, ampersands will be encoded
$strTable string An optional table name
Результат string The referer URL

getSessionHash() публичный статический Метод

Return the session hash
public static getSessionHash ( string $strCookie ) : string
$strCookie string The cookie name
Результат string The session hash

getTimeZones() публичный статический Метод

Return the timezones as array
public static getTimeZones ( ) : array
Результат array An array of timezones

idnaDecode() защищенный Метод

Decode an internationalized domain name
Устаревший: Deprecated since Contao 4.0, to be removed in Contao 5.0. Use Idna::decode() instead.
protected idnaDecode ( string $strDomain ) : string
$strDomain string The domain name
Результат string The decoded domain name

idnaEncode() защищенный Метод

Encode an internationalized domain name
Устаревший: Deprecated since Contao 4.0, to be removed in Contao 5.0. Use Idna::encode() instead.
protected idnaEncode ( string $strDomain ) : string
$strDomain string The domain name
Результат string The encoded domain name

idnaEncodeEmail() защищенный Метод

Encode the domain in an e-mail address
Устаревший: Deprecated since Contao 4.0, to be removed in Contao 5.0. Use Idna::encodeEmail() instead.
protected idnaEncodeEmail ( string $strEmail ) : string
$strEmail string The e-mail address
Результат string The encoded e-mail address

idnaEncodeUrl() защищенный Метод

Encode the domain in an URL
Устаревший: Deprecated since Contao 4.0, to be removed in Contao 5.0. Use Idna::encodeUrl() instead.
protected idnaEncodeUrl ( string $strUrl ) : string
$strUrl string The URL
Результат string The encoded URL

import() защищенный Метод

Import a library and make it accessible by its name or an optional key
protected import ( string $strClass, string $strKey = null, boolean $blnForce = false )
$strClass string The class name
$strKey string An optional key to store the object under
$blnForce boolean If true, existing objects will be overridden

importStatic() публичный статический Метод

Import a library in non-object context
public static importStatic ( string $strClass, string $strKey = null, boolean $blnForce = false ) : object
$strClass string The class name
$strKey string An optional key to store the object under
$blnForce boolean If true, existing objects will be overridden
Результат object The imported object

isInstalledLanguage() публичный статический Метод

Check whether a language is installed
public static isInstalledLanguage ( boolean $strLanguage ) : boolean
$strLanguage boolean The language code
Результат boolean True if the language is installed

isValidEmailAddress() защищенный Метод

Validate an e-mail address
Устаревший: Deprecated since Contao 4.0, to be removed in Contao 5.0. Use Validator::isEmail() instead.
protected isValidEmailAddress ( string $strEmail ) : boolean
$strEmail string The e-mail address
Результат boolean True if it is a valid e-mail address

loadLanguageFile() публичный статический Метод

Load a set of language files
public static loadLanguageFile ( string $strName, boolean $strLanguage = null, boolean $blnNoCache = false )
$strName string The table name
$strLanguage boolean An optional language code
$blnNoCache boolean If true, the cache will be bypassed

log() публичный статический Метод

Add a log entry to the database
Устаревший: Deprecated since Contao 4.2, to be removed in Contao 5. Use the logger service instead.
public static log ( string $strText, string $strFunction, string $strCategory )
$strText string The log message
$strFunction string The function name
$strCategory string The category name

parseDate() публичный статический Метод

Parse a date format string and translate textual representations
Устаревший: Deprecated since Contao 4.0, to be removed in Contao 5.0. Use Date::parse() instead.
public static parseDate ( string $strFormat, integer $intTstamp = null ) : string
$strFormat string The date format string
$intTstamp integer An optional timestamp
Результат string The textual representation of the date

readPhpFileWithoutTags() защищенный статический Метод

Read the contents of a PHP file, stripping the opening and closing PHP tags
Устаревший: Deprecated since Contao 4.0, to be removed in Contao 5.0. Use the Contao\CoreBundle\Config\Loader\PhpFileLoader instead.
protected static readPhpFileWithoutTags ( string $strName ) : string
$strName string The name of the PHP file
Результат string The PHP code without the PHP tags

redirect() публичный статический Метод

Redirect to another page
Устаревший: Deprecated since Contao 4.0, to be removed in Contao 5.0. Use Controller::redirect() instead.
public static redirect ( string $strLocation, integer $intStatus = 303 )
$strLocation string The target URL
$intStatus integer The HTTP status code (defaults to 303)

reload() публичный статический Метод

Reload the current page
Устаревший: Deprecated since Contao 4.0, to be removed in Contao 5.0. Use Controller::reload() instead.
public static reload ( )

resetMessages() защищенный Метод

Reset the message system
Устаревший: Deprecated since Contao 4.0, to be removed in Contao 5.0. Use Message::reset() instead.
protected resetMessages ( )

setContainer() публичный статический Метод

Set the container object
public static setContainer ( Symfony\Component\DependencyInjection\ContainerInterface $container )
$container Symfony\Component\DependencyInjection\ContainerInterface The container object

setCookie() публичный статический Метод

Set a cookie
public static setCookie ( string $strName, mixed $varValue, integer $intExpires, string $strPath = null, string $strDomain = null, boolean $blnSecure = false, boolean $blnHttpOnly = false )
$strName string The cookie name
$varValue mixed The cookie value
$intExpires integer The expiration date
$strPath string An optional path
$strDomain string An optional domain name
$blnSecure boolean If true, the secure flag will be set
$blnHttpOnly boolean If true, the http-only flag will be set

splitFriendlyName() публичный статический Метод

Split a friendly-name e-address and return name and e-mail as array
Устаревший: Deprecated since Contao 4.0, to be removed in Contao 5.0. Use StringUtil::splitFriendlyEmail() instead.
public static splitFriendlyName ( string $strEmail ) : array
$strEmail string A friendly-name e-mail address
Результат array An array with name and e-mail address

urlEncode() публичный статический Метод

Urlencode a file path preserving slashes
public static urlEncode ( string $strPath ) : string
$strPath string The file path
Результат string The encoded file path

Описание свойств

$arrCache защищенное свойство

Cache
Устаревший: Deprecated since Contao 4.0, to be removed in Contao 5.0.
protected array $arrCache
Результат array

$arrImageSizes защищенное статическое свойство

Available image sizes
protected static array $arrImageSizes
Результат array

$arrLanguageFiles защищенное статическое свойство

Loaded language files
protected static array $arrLanguageFiles
Результат array

$arrLanguages защищенное статическое свойство

Available languages
protected static array $arrLanguages
Результат array

$arrObjects защищенное свойство

Default libraries
protected array $arrObjects
Результат array

$arrStaticObjects защищенное статическое свойство

Static objects
protected static array $arrStaticObjects
Результат array

$objContainer защищенное статическое свойство

Container
protected static ContainerInterface,Symfony\Component\DependencyInjection $objContainer
Результат Symfony\Component\DependencyInjection\ContainerInterface