PHP Класс Stash

Автор: Mark Croxton ([email protected])
Показать файл Открыть проект Примеры использования класса

Открытые свойства

Свойство Тип Описание
$EE
$context
$default_scope
$file_sync
$limit_bots
$path
$site_id
$stash_cookie
$stash_cookie_expire
$version

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

Свойство Тип Описание
$bundle_id
$bundles
$parse_complete
$parse_conditionals
$parse_depth
$parse_tags
$parse_vars
$priority
$process
$replace
$type
$xss_clean

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

Метод Описание
__call ( string $name, array $arguments ) : void Shortcut to stash:get or stash:set
__construct ( $calling_from_hook = FALSE ) * Constructor
_no_results ( ) : String parse and return no_results content
_prep_no_results ( string $prefix ) : String prep a prefixed no_results block in current template tagdata
append ( ) : void Append the specified value to an already existing variable.
append_list ( ) : string Append to array
append_value ( ) : void Single tag version of append()
block ( ) : string Define default/fallback content for a stash variable from enclosed tagdata
bundle ( array $params = [], array $dynamic = [] ) : void Bundle up a collection of variables and save in the database
cache ( ) : string Cache tagdata to db and link it to the current URL context
context ( ) : void Set the current context
copy ( ) : string Clone a variable / list
destroy ( mixed $params = [], string $type = 'variable', string $scope = 'user' ) : void Unset variable(s) in the current session, optionally flush from db
embed ( ) : string Embed a Stash template file in the current template
embed_extend ( ) : string Pass variables to an embed via variable pairs in tagdata
extend ( ) : string | void Inject a stash embed into a variable or block
final_output ( $output = '' ) : string Final parsing/cleanup of template tagdata before output
finish ( ) : string Tagb for cleaning up specific placeholders before final output
flatten_list ( $array ) : string Flattens an array into a quasi-serialized format suitable for saving as a stash variable
flush_cache ( ) : string Flush the variables database cache for the current site (Super Admins only)
get ( mixed $params = '', string $type = 'variable', string $scope = 'user' ) : string Get content from session, database, $_POST/$_GET superglobals or file
get_bundle ( $set = TRUE ) : string Restore values for a given bundle
get_list ( $params = [], $value = '', $type = 'variable', $scope = 'user' ) : string Retrieve a serialised array of items, explode and replace into tagdata
init ( boolean $calling_from_hook = FALSE ) : void Initialise tag parameters
is_empty ( $string = NULL ) : integer Checks if a variable or string has any content, handy for conditionals
join_lists ( ) : string Create a union of two or more existing lists Lists *must* share the same keys and be *already in memory*
list_count ( ) : string Retrieve the item count for a given list
not_empty ( $string = NULL ) : integer Checks if a variable or string is empty or non-existent, handy for conditionals
not_found ( ) : string Output the 404 template with the correct header and exit
parse ( array $params = [], string $value = NULL ) : string Parse tagdata
prepend ( ) : void Prepend the specified value to an already existing variable.
prepend_list ( ) : string Prepend to array
prepend_value ( ) : void Single tag version of prepend()
rebuild_list ( mixed $params = '', string $type = 'variable', string $scope = 'user' ) : array Retrieve and rebuild list, or optionally part of a list
save_output ( string $output = '' ) : string Save the final rendered template output to a static file
set ( mixed $params = [], string $value = '', string $type = 'variable', string $scope = 'user' ) : void Set content in the current session, optionally save to the database
set_bundle ( ) : void Set values into a bundle
set_list ( ) : string Serialize a multidimenisional array and save as a variable
set_parse_params ( ) : String set individual parse parameters if parse="yes"
set_value ( ) : void Single tag version of set(), for when you need to use a plugin as a tag parameter (always use with parse="inward")
shuffle_list_key ( $arr, $key ) : void Shuffle a stash list key
sort_by_key ( $arr, $key, $cmp = 'sort_by_integer' ) : void Sort a multi-dimensional array by key
split_list ( )
static_cache ( string $output = '' ) : string Cache a template to file and link it to the current URL context

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

Метод Описание
sort_by_integer ( $a, $b ) Sort callback function: sort by integer
sort_by_string ( $a, $b ) Sort callback function: sort by string

Приватные методы

Метод Описание
_api_call ( string $method, mixed $params, string $type = 'variable', string $scope = 'user', string $value = NULL ) : void API: call a Stash method directly
_api_static_call ( string $method, mixed $params, string $type = 'variable', string $scope = 'user', string $value = NULL ) : void API: call a Stash method statically (DEPRECATED, PHP <5.6 only)
_clean_string ( string $value = NULL ) : string String manipulations
_get_boolean_config_item ( string $item, boolean $default = TRUE ) : boolean get the boolean value of a config item, with the desired fallback value
_get_stash_cookie ( ) : boolean/array get the stash cookie
_get_users_vars ( ) : array return the standard set of user variables
_is_bot ( ) : void Check if the user agent is a bot
_is_cacheable ( boolean $check_request_type = TRUE ) : string Check to see if a template (not a fragment) is suitable for caching
_lcd ( $array, $x = 1 ) : integer get the least common denominator for a given array of numbers
_list_row_explode ( string $string ) : array
_list_row_implode ( array $array ) : string
_load_EE_TMPL ( ) : void Load the EE Template class and register the Stash module Used when Stash is instantiated outside of an EE template
_matches ( string $match, string/array $against ) : boolean Match a regex against a string or array of strings
_normalize ( $str ) : string Normalize characters in a string (the dirty way)
_parse_context ( string $name, $disable_query_str = FALSE ) : string Replace the current context in a variable name
_parse_fraction ( $fraction, $offset, $total ) : integer get a fraction from a parameter value
_parse_output ( string $value = NULL, string $match = NULL, string $filter = NULL, string $default = NULL ) : string Final parsing of the stash variable before output to the template
_parse_sub_template ( boolean $tags = TRUE, boolean $vars = TRUE, boolean $conditionals = FALSE, integer $depth = 1, $nocache_id = FALSE ) : string Parse template data
_parse_template_vars ( string $template = '' ) : string Parse global vars inside a string
_placeholders ( array $matches ) : string Replaces nested tag content with placeholders
_post_parse ( $method ) : Mixed Delay processing a tag until template_post_parse hook
_prep_in_conditionals ( string $tagdata = '' ) : String Prep {if var IN (array)} conditionals
_run_tag ( string $method, array $params = [] ) : string Run a Stash module tag with a known set of parameters
_serialize_stash_tag_pairs ( ) : void Retrieve {stash:var}{/stash:var} tag pairs and serialize
_set_stash_cookie ( string $unique_id ) : void set the stash cookie
_un_prefix ( string $prefix, string $template ) : String remove a given prefix from common variables in the template tagdata
_update_list ( boolean $append = TRUE ) : string Append / prepend to array

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

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

Shortcut to stash:get or stash:set
public __call ( string $name, array $arguments ) : void
$name string The method name being called or context if third tagpart
$arguments array The method call arguments
Результат void

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

* Constructor
public __construct ( $calling_from_hook = FALSE )

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

parse and return no_results content
public _no_results ( ) : String
Результат String

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

prep a prefixed no_results block in current template tagdata
public _prep_no_results ( string $prefix ) : String
$prefix string
Результат String

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

Append the specified value to an already existing variable.
public append ( ) : void
Результат void

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

Append to array
public append_list ( ) : string
Результат string

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

Single tag version of append()
public append_value ( ) : void
Результат void

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

Define default/fallback content for a stash variable from enclosed tagdata
public block ( ) : string
Результат string

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

Bundle up a collection of variables and save in the database
public bundle ( array $params = [], array $dynamic = [] ) : void
$params array
$dynamic array
Результат void

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

Cache tagdata to db and link it to the current URL context
public cache ( ) : string
Результат string

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

Set the current context
public context ( ) : void
Результат void

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

Clone a variable / list
public copy ( ) : string
Результат string

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

Unset variable(s) in the current session, optionally flush from db
public destroy ( mixed $params = [], string $type = 'variable', string $scope = 'user' ) : void
$params mixed The name of the variable to unset, or an array of key => value pairs
$type string The type of variable
$scope string The scope of the variable
Результат void

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

Embed a Stash template file in the current template
public embed ( ) : string
Результат string

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

Pass variables to an embed via variable pairs in tagdata
public embed_extend ( ) : string
Результат string

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

Inject a stash embed into a variable or block
public extend ( ) : string | void
Результат string | void

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

Final parsing/cleanup of template tagdata before output
public final_output ( $output = '' ) : string
Результат string

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

Tagb for cleaning up specific placeholders before final output
public finish ( ) : string
Результат string

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

Flattens an array into a quasi-serialized format suitable for saving as a stash variable
public static flatten_list ( $array ) : string
Результат string The imploded string

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

Flush the variables database cache for the current site (Super Admins only)
public flush_cache ( ) : string
Результат string

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

Get content from session, database, $_POST/$_GET superglobals or file
public get ( mixed $params = '', string $type = 'variable', string $scope = 'user' ) : string
$params mixed The name of the variable to retrieve, or an array of key => value pairs
$type string The type of variable
$scope string The scope of the variable
Результат string

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

Restore values for a given bundle
public get_bundle ( $set = TRUE ) : string
Результат string

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

Retrieve a serialised array of items, explode and replace into tagdata
public get_list ( $params = [], $value = '', $type = 'variable', $scope = 'user' ) : string
Результат string

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

Initialise tag parameters
public init ( boolean $calling_from_hook = FALSE ) : void
$calling_from_hook boolean Is method being called by an extension hook?
Результат void

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

Checks if a variable or string has any content, handy for conditionals
public is_empty ( $string = NULL ) : integer
$string a string to test
Результат integer

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

Create a union of two or more existing lists Lists *must* share the same keys and be *already in memory*
public join_lists ( ) : string
Результат string

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

Retrieve the item count for a given list
public list_count ( ) : string
Результат string

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

Checks if a variable or string is empty or non-existent, handy for conditionals
public not_empty ( $string = NULL ) : integer
$string a string to test
Результат integer

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

Output the 404 template with the correct header and exit
public not_found ( ) : string
Результат string

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

Parse tagdata
public parse ( array $params = [], string $value = NULL ) : string
$params array an array of key => value pairs representing tag parameters
$value string string to parse, defaults to template tagdata
Результат string

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

Prepend the specified value to an already existing variable.
public prepend ( ) : void
Результат void

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

Prepend to array
public prepend_list ( ) : string
Результат string

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

Single tag version of prepend()
public prepend_value ( ) : void
Результат void

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

Retrieve and rebuild list, or optionally part of a list
public rebuild_list ( mixed $params = '', string $type = 'variable', string $scope = 'user' ) : array
$params mixed The name of the variable to retrieve, or an array of key => value pairs
$type string The type of variable
$scope string The scope of the variable
Результат array

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

Save the final rendered template output to a static file
public save_output ( string $output = '' ) : string
$output string the rendered template
Результат string

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

Set content in the current session, optionally save to the database
public set ( mixed $params = [], string $value = '', string $type = 'variable', string $scope = 'user' ) : void
$params mixed The name of the variable to retrieve, or an array of key => value pairs
$value string The value of the variable
$type string The type of variable
$scope string The scope of the variable
Результат void

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

Set values into a bundle
public set_bundle ( ) : void
Результат void

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

Serialize a multidimenisional array and save as a variable
public set_list ( ) : string
Результат string

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

set individual parse parameters if parse="yes"
public set_parse_params ( ) : String
Результат String

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

Single tag version of set(), for when you need to use a plugin as a tag parameter (always use with parse="inward")
public set_value ( ) : void
Результат void

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

Shuffle a stash list key
public shuffle_list_key ( $arr, $key ) : void
Результат void

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

Sort callback function: sort by integer
protected sort_by_integer ( $a, $b )

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

Sort a multi-dimensional array by key
public sort_by_key ( $arr, $key, $cmp = 'sort_by_integer' ) : void
Результат void

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

Sort callback function: sort by string
protected sort_by_string ( $a, $b )

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

public split_list ( )

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

Cache a template to file and link it to the current URL context
public static_cache ( string $output = '' ) : string
$output string additional tagdata to return to the template along with the placeholder
Результат string

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

$EE публичное свойство

public $EE

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

protected $bundle_id

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

protected static $bundles

$context публичное статическое свойство

public static $context

$default_scope публичное свойство

public $default_scope

$file_sync публичное свойство

public $file_sync

$limit_bots публичное свойство

public $limit_bots

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

protected $parse_complete

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

protected $parse_conditionals

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

protected $parse_depth

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

protected $parse_tags

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

protected $parse_vars

$path публичное свойство

public $path

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

protected $priority

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

protected $process

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

protected $replace

$site_id публичное свойство

public $site_id

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

protected $type

$version публичное свойство

public $version

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

protected $xss_clean