PHP Class Stash

Author: Mark Croxton ([email protected])
Afficher le fichier Open project: croxton/stash Class Usage Examples

Méthodes publiques

Свойство Type Description
$EE
$context
$default_scope
$file_sync
$limit_bots
$path
$site_id
$stash_cookie
$stash_cookie_expire
$version

Protected Properties

Свойство Type Description
$bundle_id
$bundles
$parse_complete
$parse_conditionals
$parse_depth
$parse_tags
$parse_vars
$priority
$process
$replace
$type
$xss_clean

Méthodes publiques

Méthode Description
__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

Méthodes protégées

Méthode Description
sort_by_integer ( $a, $b ) Sort callback function: sort by integer
sort_by_string ( $a, $b ) Sort callback function: sort by string

Private Methods

Méthode Description
_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

Method Details

__call() public méthode

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
Résultat void

__construct() public méthode

* Constructor
public __construct ( $calling_from_hook = FALSE )

_no_results() public méthode

parse and return no_results content
public _no_results ( ) : String
Résultat String

_prep_no_results() public méthode

prep a prefixed no_results block in current template tagdata
public _prep_no_results ( string $prefix ) : String
$prefix string
Résultat String

append() public méthode

Append the specified value to an already existing variable.
public append ( ) : void
Résultat void

append_list() public méthode

Append to array
public append_list ( ) : string
Résultat string

append_value() public méthode

Single tag version of append()
public append_value ( ) : void
Résultat void

block() public méthode

Define default/fallback content for a stash variable from enclosed tagdata
public block ( ) : string
Résultat string

bundle() public méthode

Bundle up a collection of variables and save in the database
public bundle ( array $params = [], array $dynamic = [] ) : void
$params array
$dynamic array
Résultat void

cache() public méthode

Cache tagdata to db and link it to the current URL context
public cache ( ) : string
Résultat string

context() public méthode

Set the current context
public context ( ) : void
Résultat void

copy() public méthode

Clone a variable / list
public copy ( ) : string
Résultat string

destroy() public méthode

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
Résultat void

embed() public méthode

Embed a Stash template file in the current template
public embed ( ) : string
Résultat string

embed_extend() public méthode

Pass variables to an embed via variable pairs in tagdata
public embed_extend ( ) : string
Résultat string

extend() public méthode

Inject a stash embed into a variable or block
public extend ( ) : string | void
Résultat string | void

final_output() public méthode

Final parsing/cleanup of template tagdata before output
public final_output ( $output = '' ) : string
Résultat string

finish() public méthode

Tagb for cleaning up specific placeholders before final output
public finish ( ) : string
Résultat string

flatten_list() public static méthode

Flattens an array into a quasi-serialized format suitable for saving as a stash variable
public static flatten_list ( $array ) : string
Résultat string The imploded string

flush_cache() public méthode

Flush the variables database cache for the current site (Super Admins only)
public flush_cache ( ) : string
Résultat string

get() public méthode

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
Résultat string

get_bundle() public méthode

Restore values for a given bundle
public get_bundle ( $set = TRUE ) : string
Résultat string

get_list() public méthode

Retrieve a serialised array of items, explode and replace into tagdata
public get_list ( $params = [], $value = '', $type = 'variable', $scope = 'user' ) : string
Résultat string

init() public méthode

Initialise tag parameters
public init ( boolean $calling_from_hook = FALSE ) : void
$calling_from_hook boolean Is method being called by an extension hook?
Résultat void

is_empty() public méthode

Checks if a variable or string has any content, handy for conditionals
public is_empty ( $string = NULL ) : integer
$string a string to test
Résultat integer

join_lists() public méthode

Create a union of two or more existing lists Lists *must* share the same keys and be *already in memory*
public join_lists ( ) : string
Résultat string

list_count() public méthode

Retrieve the item count for a given list
public list_count ( ) : string
Résultat string

not_empty() public méthode

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
Résultat integer

not_found() public méthode

Output the 404 template with the correct header and exit
public not_found ( ) : string
Résultat string

parse() public méthode

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
Résultat string

prepend() public méthode

Prepend the specified value to an already existing variable.
public prepend ( ) : void
Résultat void

prepend_list() public méthode

Prepend to array
public prepend_list ( ) : string
Résultat string

prepend_value() public méthode

Single tag version of prepend()
public prepend_value ( ) : void
Résultat void

rebuild_list() public méthode

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
Résultat array

save_output() public méthode

Save the final rendered template output to a static file
public save_output ( string $output = '' ) : string
$output string the rendered template
Résultat string

set() public méthode

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
Résultat void

set_bundle() public méthode

Set values into a bundle
public set_bundle ( ) : void
Résultat void

set_list() public méthode

Serialize a multidimenisional array and save as a variable
public set_list ( ) : string
Résultat string

set_parse_params() public méthode

set individual parse parameters if parse="yes"
public set_parse_params ( ) : String
Résultat String

set_value() public méthode

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
Résultat void

shuffle_list_key() public méthode

Shuffle a stash list key
public shuffle_list_key ( $arr, $key ) : void
Résultat void

sort_by_integer() protected méthode

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

sort_by_key() public méthode

Sort a multi-dimensional array by key
public sort_by_key ( $arr, $key, $cmp = 'sort_by_integer' ) : void
Résultat void

sort_by_string() protected méthode

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

split_list() public méthode

public split_list ( )

static_cache() public méthode

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
Résultat string

Property Details

$EE public_oe property

public $EE

$bundle_id protected_oe property

protected $bundle_id

$bundles protected_oe static_oe property

protected static $bundles

$context public_oe static_oe property

public static $context

$default_scope public_oe property

public $default_scope

$file_sync public_oe property

public $file_sync

$limit_bots public_oe property

public $limit_bots

$parse_complete protected_oe property

protected $parse_complete

$parse_conditionals protected_oe property

protected $parse_conditionals

$parse_depth protected_oe property

protected $parse_depth

$parse_tags protected_oe property

protected $parse_tags

$parse_vars protected_oe property

protected $parse_vars

$path public_oe property

public $path

$priority protected_oe property

protected $priority

$process protected_oe property

protected $process

$replace protected_oe property

protected $replace

$site_id public_oe property

public $site_id

$type protected_oe property

protected $type

$version public_oe property

public $version

$xss_clean protected_oe property

protected $xss_clean