model/modx/modlexicon.class.php

Classes 
package
modx
Classes
modLexicon

Description

modLexicon

\modLexicon

package
modx
Properties
$_lexicon
$_loadedTopics
$_paths
$modx
Methods
__construct
_parse
clearCache
exists
fetch
getCacheKey
getFileTopic
getLanguageList
getNamespacePath
getTopicList
load
loadCache
process
set

Description

The lexicon handling class.

Eventually needs to be reworked to allow for context/area-specific lexicons.

Properties

$_lexicon

array $_lexicon = 'array'

The actual language array.

Details

array
visibility
protected
default
array
final
false
static
false
access
protected
todo
Separate into separate arrays for each namespace (and maybe topic) so that no namespacing in lexicon entries is needed. Maybe keep a master array of entries, but then have subarrays for topic-specific referencing.

$_loadedTopics

array $_loadedTopics = 'array'

An array of loaded topic strings

Details

array
visibility
protected
default
array
final
false
static
false

$_paths

array $_paths = 'array'

Directories to search for language strings in.

Details

array
visibility
protected
default
array
final
false
static
false
access
protected
deprecated

$modx

\modX $modx = 'null'

Reference to the MODX instance.

Details

\modX
visibility
public
default
null
final
false
static
false
access
protected

Methods

__construct

__construct( \modX $modx,  $config = array ) : \modLexicon

Creates the modLexicon instance.

Arguments
$modx
\modX
&$modx A reference to the modX instance.
$config
Output
\modLexicon
Details
visibility
public
final
false
static
false
constructor

_parse

_parse( string $str, array $params ) : string

Parses a lexicon string, replacing placeholders with specified strings.

Arguments
$str
string
The string to parse
$params
array
An associative array of keys to replace
Output
string
The processed string
Details
visibility
private
final
false
static
false
access
private

clearCache

clearCache( string $path ) : string

Clears the lexicon cache for the specified path.

Arguments
$path
string
The path to clear.
Output
string
The results of the cache clearing.
Details
visibility
public
final
false
static
false
access
public

exists

exists( string $index ) : boolean

Returns if the key exists in the lexicon.

Arguments
$index
string
Output
boolean
True if exists.
Details
visibility
public
final
false
static
false
access
public

fetch

fetch( string $prefix, boolean $removePrefix = false ) : array

Accessor method for the lexicon array.

Arguments
$prefix
string
If set, will only return the lexicon entries with this prefix.
$removePrefix
boolean
If true, will strip the prefix from the returned indexes
Output
array
The internal lexicon.
Details
visibility
public
final
false
static
false
access
public

getCacheKey

getCacheKey( string $namespace = core, string $topic = default, string $language ) : string

Return the cache key representing the specified lexicon topic.

Arguments
$namespace
string
The namespace for the topic
$topic
string
The topic to grab
$language
string
The language for the topic
Output
string
The cache key for the specified topic
Details
visibility
public
final
false
static
false
access
public

getFileTopic

getFileTopic( string $language = en, string $namespace = core, string $topic = default ) : array

Get entries from file-based lexicon topic

Arguments
$language
string
The language to filter by.
$namespace
string
The namespace to filter by.
$topic
string
The topic to filter by.
Output
array
An array of lexicon entries in key - value pairs for the specified filter.
Details
visibility
public
final
false
static
false

getLanguageList

getLanguageList( string $namespace = core ) : array

Get a list of available languages for a Namespace.

Arguments
$namespace
string
The Namespace to filter by.
Output
array
An array of available languages
Details
visibility
public
final
false
static
false

getNamespacePath

getNamespacePath( string $namespace = core ) : string

Get the path of the specified Namespace

Arguments
$namespace
string
The key of the Namespace
Output
string
The path for the Namespace
Details
visibility
public
final
false
static
false

getTopicList

getTopicList( string $language = en, string $namespace = core ) : array

Get a list of available Topics when given a Language and Namespace.

Arguments
$language
string
The language to filter by.
$namespace
string
The language to filter by.
Output
array
An array of Topic names.
Details
visibility
public
final
false
static
false

load

load( ) :

Loads a variable number of topic areas. They must reside as topicname.

inc.php files in their proper culture directory. Can load an infinite number of topic areas via a dynamic number of arguments.

They are loaded by language:namespace:topic, namespace:topic, or just topic. Examples: $modx->lexicon->load('en:core:snippet'); $modx->lexicon-

load ('demo:test'); $modx->lexicon->load('chunk');

Details
visibility
public
final
false
static
false
access
public

loadCache

loadCache( string $namespace = core, string $topic = default, string $language ) : array

Loads a lexicon topic from the cache. If not found, tries to generate a cache file from the database.

Arguments
$namespace
string
The namespace to load from. Defaults to 'core'.
$topic
string
The topic to load. Defaults to 'default'.
$language
string
The language to load. Defaults to 'en'.
Output
array
The loaded lexicon array.
Details
visibility
public
final
false
static
false
access
public

process

process( string $key, array $params = array ) : string

Get a lexicon string by its index.

Arguments
$key
string
The key of the lexicon string.
$params
array
An assocative array of placeholder keys and values to parse
Output
string
The text of the lexicon key, blank if not found.
Details
visibility
public
final
false
static
false
access
public

set

set( \string/array $keys, string $text ) :

Sets a lexicon key to a value. Not recommended, since doesn't query the database.

Arguments
$keys
\string/array
Either an array of array pairs of key/values or a key string.
$text
string
The text to set, if the first parameter is a string.
Details
visibility
public
final
false
static
false
access
public
Documentation was generated by DocBlox 0.11.2.