Documentation

InitCMS
in package

Initialize the CMS

Tags
copyright

CLOUDREXX CMS - CLOUDREXX AG

author

Cloudrexx Development Team info@cloudrexx.com

access

public

version
3.0.0
subpackage

core

todo

Any methods handling content or language should be moved away from here to a distinct class!

todo

Most if not all of the properties and methods are potentially static.

Table of Contents

Properties

$arrBackendLang  : mixed
$arrBackendLangNames  : mixed
$arrLang  : mixed
$arrLangNames  : mixed
$arrModulePath  : mixed
$backendLangId  : mixed
$channelThemeId  : mixed
$currentThemesId  : mixed
$customContentTemplate  : mixed
$defaultBackendLangId  : mixed
$defaultFrontendLangId  : mixed
$frontendLangId  : mixed
$frontendLangName  : mixed
$mode  : string
Either "frontend" or "backend"
$pageThemeId  : mixed
ID of the theme that has been used for generating the response
$templates  : mixed
$userFrontendLangId  : mixed
$currentChannel  : string
Current view type(web, app, mobile, etc)
$em  : EntityManager
$moduleSpecificLanguageData  : array<string|int, mixed>
$themeRepository  : mixed
$isMobileDevice  : mixed
int $isMobileDevice whether we're dealing with a mobile device.
$themesPath  : mixed

Methods

__construct()  : mixed
Constructor
_initBackendLanguage()  : mixed
Backend language initialization
_is_mobile_phone()  : mixed
Returns true if the user agent is a mobile device (smart phone, PDA etc.)
_is_tablet()  : mixed
Returns true if the user agent is a tablet
_selectBestLanguage()  : int
Returns the locale ID best matching the client's request
checkForMobileDevice()  : mixed
getBackendDefaultLangId()  : mixed
Returns the default backend language ID
getBackendLangId()  : mixed
getComponentSpecificLanguageData()  : array<string|int, mixed>
Get component specific language data State of the init will be backedup and restored while loading the language data
getComponentSpecificLanguageDataByCode()  : array<string|int, mixed>
Return language data by component and language code
getCurrentChannel()  : string
Returns the current channel
getCurrentPageUri()  : mixed
getCurrentThemeId()  : int
Return the current theme id Note: This vaule is available only in frontend mode
getCurrentThemesPath()  : string
Return the current themes path
getCustomContentTemplatesForTheme()  : array<string|int, mixed>
Collects all custom content templates available for the theme specified
getDefaultBackendLangId()  : mixed
getDefaultFrontendLangId()  : mixed
getFallbackFrontendLangId()  : mixed
getFrontendDefaultLangId()  : mixed
Returns the default frontend language ID
getFrontendLangId()  : mixed
getFrontendLangName()  : mixed
getLanguageArray()  : array<string|int, mixed>
Returns an array of all languages
getPageUri()  : mixed
getTemplates()  : array<string|int, mixed>
Returns an array of all basic templates for the active theme
getUriBy()  : mixed
getUserFrontendLangId()  : string
Returns the selected User Frontend Language id
getUserFrontendLangMenu()  : string
Returns the HTML for the frontend language selection dropdown menu
hasCustomContent()  : bool
Returns true if there is custom content for this page
loadLanguageData()  : array<string|int, mixed>
Initializes the language array
loadModulePaths()  : mixed
setCurrentChannel()  : mixed
setCustomizedTheme()  : mixed
Sets the customized ThemesId and customContent template
setFrontendLangId()  : mixed
getFrontendTemplate()  : Theme
Load the frontend template
getLangFilePathByCode()  : mixed
loadLangFile()  : mixed
Loads the language file for the given file path
getThemeFileContent()  : string
Fetches the content of a themes file.
isInMobileView()  : bool
loadCustomContent()  : mixed

Properties

$arrBackendLang

public mixed $arrBackendLang = array()

$arrBackendLangNames

public mixed $arrBackendLangNames = array()

$arrLangNames

public mixed $arrLangNames = array()

$arrModulePath

public mixed $arrModulePath = array()

$customContentTemplate

public mixed $customContentTemplate = \null

$defaultBackendLangId

public mixed $defaultBackendLangId

$defaultFrontendLangId

public mixed $defaultFrontendLangId

$frontendLangName

public mixed $frontendLangName

$mode

Either "frontend" or "backend"

public string $mode

$pageThemeId

ID of the theme that has been used for generating the response

public mixed $pageThemeId

$userFrontendLangId

public mixed $userFrontendLangId

$currentChannel

Current view type(web, app, mobile, etc)

protected string $currentChannel

$moduleSpecificLanguageData

protected array<string|int, mixed> $moduleSpecificLanguageData = array()

Language var cache

$themeRepository

protected mixed $themeRepository

Methods

__construct()

Constructor

public __construct([mixed $mode = CxCoreCoreControllerCx::MODE_FRONTEND ][, mixed $entityManager = null ]) : mixed
Parameters
$mode : mixed = CxCoreCoreControllerCx::MODE_FRONTEND
$entityManager : mixed = null

_initBackendLanguage()

Backend language initialization

public _initBackendLanguage() : mixed

_is_mobile_phone()

Returns true if the user agent is a mobile device (smart phone, PDA etc.)

public static _is_mobile_phone() : mixed

Use \Cx\Core\Routing\Model\Entity\Request::isMobilePhone() instead

_is_tablet()

Returns true if the user agent is a tablet

public static _is_tablet() : mixed

Use \Cx\Core\Routing\Model\Entity\Request::isTablet() instead

_selectBestLanguage()

Returns the locale ID best matching the client's request

public _selectBestLanguage() : int

If no match can be found, returns the default locale ID.

Return values
int

The locale ID

checkForMobileDevice()

public checkForMobileDevice() : mixed

getBackendDefaultLangId()

Returns the default backend language ID

public getBackendDefaultLangId() : mixed
Tags
access

public

getBackendLangId()

public getBackendLangId() : mixed

getComponentSpecificLanguageData()

Get component specific language data State of the init will be backedup and restored while loading the language data

public getComponentSpecificLanguageData(string $componentName[, bool|true $frontend = true ][, int $languageId = 0 ][, bool $loadFromYaml = true ]) : array<string|int, mixed>
Parameters
$componentName : string

Name of the desired component

$frontend : bool|true = true

true if desired mode is frontend false otherwise

$languageId : int = 0

Id of the desired language i.e. 1 for german

$loadFromYaml : bool = true

Wether to load customized placeholders from yaml or not

Return values
array<string|int, mixed>

The language data which has been loaded

getComponentSpecificLanguageDataByCode()

Return language data by component and language code

public getComponentSpecificLanguageDataByCode(string $componentName, mixed $langCode[, bool $frontend = true ][, bool $loadFromYaml = true ]) : array<string|int, mixed>

The global $_ARRAYLANG remains unchanged, as it's backed up and restored.

Parameters
$componentName : string
$langCode : mixed
$frontend : bool = true

Defaults to true

$loadFromYaml : bool = true

Defaults to true; include custom YAML

Return values
array<string|int, mixed>

getCurrentChannel()

Returns the current channel

public getCurrentChannel() : string
Tags
throws
Exception

If channel is not yet set, call setFrontendLangId() to set it

Return values
string

Channel

getCurrentPageUri()

public getCurrentPageUri() : mixed

getCurrentThemeId()

Return the current theme id Note: This vaule is available only in frontend mode

public getCurrentThemeId() : int
Return values
int

getCurrentThemesPath()

Return the current themes path

public getCurrentThemesPath() : string
Tags
access

public

author

Stefan Heinemann

Return values
string

getCustomContentTemplatesForTheme()

Collects all custom content templates available for the theme specified

public getCustomContentTemplatesForTheme(int $themeId) : array<string|int, mixed>

Used by @link ContentManager::ajaxGetCustomContentTemplate(). On failure, returns the empty array. The array returned looks like array( 'content_xy.html', 'home_xy.html' , [... more ...] )

Parameters
$themeId : int

The theme ID

Return values
array<string|int, mixed>

The custom content template filename array

getDefaultBackendLangId()

public getDefaultBackendLangId() : mixed

getDefaultFrontendLangId()

public getDefaultFrontendLangId() : mixed

getFallbackFrontendLangId()

public getFallbackFrontendLangId() : mixed

getFrontendDefaultLangId()

Returns the default frontend language ID

public getFrontendDefaultLangId() : mixed
Tags
access

public

getFrontendLangId()

public getFrontendLangId() : mixed

getFrontendLangName()

public getFrontendLangName() : mixed

getLanguageArray()

Returns an array of all languages

public getLanguageArray() : array<string|int, mixed>
Tags
access

public

Return values
array<string|int, mixed>

$arrLang

getTemplates()

Returns an array of all basic templates for the active theme

public getTemplates(mixed $page) : array<string|int, mixed>
Parameters
$page : mixed
Tags
access

public

Return values
array<string|int, mixed>

The array of template strings

getUriBy()

public getUriBy([mixed $key = '' ][, mixed $value = '' ]) : mixed

Use \Cx\Core\Routing\Url::fromRequest() instead.

Parameters
$key : mixed = ''
$value : mixed = ''

getUserFrontendLangId()

Returns the selected User Frontend Language id

public getUserFrontendLangId() : string

Backend use only!

Return values
string

$this->userFrontendLangId

getUserFrontendLangMenu()

Returns the HTML for the frontend language selection dropdown menu

public getUserFrontendLangMenu([bool $force = false ]) : string

Backend use only.

Parameters
$force : bool = false

(optional) Wheter to force a non-empty return value, default false

Tags
internal

Note to Shop (and other newish module) programmers: Registers javascript for handling the currently active tab.

Return values
string

The HTML language dropdown menu code

hasCustomContent()

Returns true if there is custom content for this page

public hasCustomContent() : bool
Return values
bool

True if there is custom content, false otherwise

loadLanguageData()

Initializes the language array

public loadLanguageData([string $module = '' ][, bool $loadFromYaml = true ][, mixed $mode = '' ]) : array<string|int, mixed>
Parameters
$module : string = ''

The component to load the language data from

$loadFromYaml : bool = true

Wether to load customized placeholders from yaml or not

$mode : mixed = ''
Return values
array<string|int, mixed>

The language array, either local $_ARRAYLANG or the global $_CORELANG

loadModulePaths()

public loadModulePaths() : mixed

setCurrentChannel()

public setCurrentChannel(mixed $channel) : mixed
Parameters
$channel : mixed

setCustomizedTheme()

Sets the customized ThemesId and customContent template

public setCustomizedTheme([int $themesId = 0 ][, string $customContent = '' ][, mixed $useThemeForAllChannels = false ]) : mixed

This method sets the currentThemesId if a customized themesId is set in the navigation table.

Parameters
$themesId : int = 0

The optional theme ID

$customContent : string = ''

The optional custom content template (like 'content_without_h1.html')

$useThemeForAllChannels : mixed = false

setFrontendLangId()

public setFrontendLangId(mixed $langId) : mixed
Parameters
$langId : mixed

getFrontendTemplate()

Load the frontend template

protected getFrontendTemplate() : Theme
Tags
throws
Exception

Throws exception when no template was found

Return values
Theme

Template instance

getLangFilePathByCode()

protected getLangFilePathByCode(mixed $module, mixed $langCode, mixed $mode) : mixed
Parameters
$module : mixed
$langCode : mixed
$mode : mixed

loadLangFile()

Loads the language file for the given file path

protected loadLangFile(string $path[, bool $loadFromYaml = true ][, string $componentName = 'Core' ][, mixed $mode = '' ]) : mixed

Note that no replacements are made to the entries' contents. If your strings don't work as expected, fix them.

Parameters
$path : string

The path of the language file

$loadFromYaml : bool = true

Wether to load customized placeholders from yaml or not

$componentName : string = 'Core'

The name of the language file's component

$mode : mixed = ''

getThemeFileContent()

Fetches the content of a themes file.

private getThemeFileContent(string $themesPath, string $file) : string

The content is first fetched from the website's data directory: Cx\Core\Core\Controller\Cx::getWebsiteThemesPath() If the file is not present in the website's data directory, then the content is fetch from the file in the code base directory: Cx\Core\Core\Controller\Cx::getCodeBaseThemesPath()

Parameters
$themesPath : string

Path to the themes folder

$file : string

Name of the file to fetch the content from

Return values
string

The content of the file specified by $themesPath and $file

isInMobileView()

private isInMobileView() : bool
Tags
access

private

Return values
bool

Return TRUE if the user is in "Mobile View"-mode, otherwise FALSE

loadCustomContent()

private loadCustomContent(mixed $page) : mixed
Parameters
$page : mixed

        
On this page

Search results