PHP Класс Habari\Theme

The Theme class is the behind-the-scenes representation of of a set of UI files that compose the visual theme of the blog
Наследование: extends Pluggable
Показать файл Открыть проект

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

Свойство Тип Описание
$config_vars
$context
$name
$template_engine TemplateEngine
$theme_dir
$valid_filters We build the Post filters by analyzing the handler_var data which is assigned to the handler ( by the Controller and also, optionally, by the Theme )
$version

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

Метод Описание
__call ( string $function, array $params ) Handle methods called on this class or its descendants that are not defined by this class.
__construct ( $themedata ) Constructor for theme
__get ( string $key ) : mixed Get a template variable value
__isset ( string $key ) : boolean Detects if a variable is assigned to the template engine for use in constructing the template's output.
__set ( string $key, mixed $value ) Set a template variable, a property alias for assign() This can only affect the current stack level!
__unset ( string $key ) Remove a template variable value This can only affect the current stack level!
act_display ( $paramarray = ['user_filters' => []] ) Grabs post data and inserts that data into the internal handler_vars array, which eventually gets extracted into the theme's ( and thereby the template_engine's ) local symbol table for use in the theme's templates
act_display_404 ( array $user_filters = [] ) Helper function: Display a 404 template
act_display_date ( array $user_filters = [] ) Helper function: Display the posts for a specific date
act_display_entries ( array $user_filters = [] ) Helper function: Displays multiple entries
act_display_home ( array $user_filters = [] ) Helper function: Displays the home page
act_display_post ( array $user_filters = [] ) Helper function: Display a post
act_display_tag ( array $user_filters = [] ) Helper function: Display the posts for a tag
act_search ( array $user_filters = [] ) Helper function: Display the posts for a specific criteria
action_template_footer_9 ( ) Load assets and add the javascript ones to the footer on the template_footer_javascript action hook.
action_template_header_9 ( ) Load assets and add the CSS ones to the header on the template_stylesheet action hook.
add_script ( string $value, string $where = 'header', string $name = null, string | array $requires = null ) : boolean Add javascript to the stack to be output in the theme.
add_style ( string $value, string $where = 'header', string $name = null, string | array $requires = null ) : boolean Add a stylesheet to the stack to be output in the theme.
add_template ( string $name, string $file, boolean $replace = false ) Add a template to the list of available templates
add_template_vars ( ) Assign the default variables that would be used in every template
assign ( $key, $value ) Helper function: Avoids having to call $theme->template_engine->key= 'value';
check_scope_criteria ( array $criteria ) : boolean Matches the scope criteria against the current request
dir_to_url ( string $dir ) : boolean | string Convert a theme directory or resource into a URL
display ( string $template_name ) Helper function: Avoids having to call $theme->template_engine->display( 'template_name' );
display_fallback ( array $template_list, $display_function = 'display' ) Find the first template that matches from the list provided and display it
end_buffer ( ) End the current template variable buffer
fetch ( string $template_name, boolean $unstack = false ) : string Helper function: Avoids having to call $theme->template_engine->fetch( 'template_name' );
fetch_unassigned ( string $template_name ) : string Calls the template engine's fetch() method without pre-assigning template variables.
filter_provided ( array $provided = [] ) : array Provide default Habari features for curious plugins
get_blocks ( string $area, string $scope, Theme $theme ) : array Retrieve the block objects for the current scope and specified area Incomplete!
get_scopes ( string $area ) : array Retrieve current scope data from the database based on the requested area
get_url ( boolean | string $resource = false, boolean $overrideok = true ) : string Get the URL for a resource in one of the directories used by the active theme, child theme directory first
get_version ( ) : string Provide a method to return the version number from the theme xml
info ( ) Loads a theme's metadata from an XML file in theme's directory.
load_assets ( boolean $refresh = false ) : array Load and return a list of all assets in the current theme chain's /assets/ directory
sort_scopes ( StdObject $scope1, StdObject $scope2 ) : integer Sort function for ordering scope object rows by priority
start_buffer ( ) Start a new template variable buffer
template_exists ( string $template_name ) : boolean Determine if a template exists in the current theme
theme_area ( Theme $theme, string $area, string $context = null, string $scope = null ) : string Displays blocks associated to the specified area and current scope.
theme_body_class ( Theme $theme, mixed $args = [] ) : string A theme function for outputting CSS classes based on the requested content
theme_comment_author_link ( Theme $theme, Comment $comment ) : string Returns a humane commenter's link for a comment if a URL is supplied, or just display the comment author's name
theme_comment_form_action ( Theme $theme, Post $post ) : string Returns the feedback URL to which comments should be submitted for the indicated Post
theme_comments_count ( Theme $theme, Post $post, string $zero = '', string $one = '', string $many = '' ) : string Returns a full qualified URL of the specified post based on the comments count.
theme_comments_link ( Theme $theme, Post $post, string $zero = '', string $one = '', string $many = '', string $fragment = 'comments' ) : string Returns a full qualified URL of the specified post based on the comments count, and links to the post.
theme_content ( Theme $theme, object $object, string $context = null ) Display an object using a template designed for the type of object it is The $object is assigned into the theme using the $content template variable
theme_feed_alternate ( Theme $theme ) : string Returns the appropriate alternate feed based on the currently matched rewrite rule.
theme_footer ( $theme ) Aggregates and echos the additional footer code by combining Plugins and Stack calls.
theme_has_context ( $theme, string $context ) : boolean Check to see if the theme is currently rendering a specific context
theme_header ( $theme ) Aggregates and echos the additional header code by combining Plugins and Stack calls.
theme_next_page_link ( $theme, string $text = null, $classes = ['next-page'] ) Provides a link to the next page
theme_page_selector ( $theme, $rr_name = null, $settings = [] ) : string Build a collection of paginated URLs to be used for pagination.
theme_page_title ( Theme $theme ) A Theme function to provide a page title
theme_prev_page_link ( $theme, string $text = null, $classes = ['prev-page'] ) Provides a link to the previous page
theme_query_count ( ) : integer Returns the count of queries executed
theme_query_time ( ) : float Returns total query execution time in seconds

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

Метод Описание
play_var_stack ( ) Play back the full stack of template variables to assign them into the template

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

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

Allow plugins to provide additional theme actions, like a custom act_display_*()
public __call ( string $function, array $params )
$function string The method that was called.
$params array An array of parameters passed to the method

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

If no parameter is supplied, then the constructor Loads the active theme from the database. If no theme option is set, a fatal error is thrown
public __construct ( $themedata )

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

Get a template variable value
public __get ( string $key ) : mixed
$key string The template variable name to get
Результат mixed The value of the variable

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

Detects if a variable is assigned to the template engine for use in constructing the template's output.
public __isset ( string $key ) : boolean
$key string name of variable
Результат boolean true if name is set, false if not set

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

Set a template variable, a property alias for assign() This can only affect the current stack level!
public __set ( string $key, mixed $value )
$key string The template variable to set
$value mixed The value of the variable

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

Remove a template variable value This can only affect the current stack level!
public __unset ( string $key )
$key string The template variable name to unset

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

This is the default, generic function to grab posts. To "filter" the posts retrieved, simply pass any filters to the handler_vars variables associated with the post retrieval. For instance, to filter by tag, ensure that handler_vars['tag'] contains the tag to filter by. Simple as that.
public act_display ( $paramarray = ['user_filters' => []] )

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

Helper function: Display a 404 template
public act_display_404 ( array $user_filters = [] )
$user_filters array Additional arguments user to get the page content

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

Helper function: Display the posts for a specific date
public act_display_date ( array $user_filters = [] )
$user_filters array Additional arguments used to get the page content

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

Helper function: Displays multiple entries
public act_display_entries ( array $user_filters = [] )
$user_filters array Additional arguments used to get the page content

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

Helper function: Displays the home page
public act_display_home ( array $user_filters = [] )
$user_filters array Additional arguments used to get the page content

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

Helper function: Display a post
public act_display_post ( array $user_filters = [] )
$user_filters array Additional arguments used to get the page content

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

Helper function: Display the posts for a tag
public act_display_tag ( array $user_filters = [] )
$user_filters array Additional arguments used to get the page content

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

Load assets and add the CSS ones to the header on the template_stylesheet action hook.

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

Add javascript to the stack to be output in the theme.
public add_script ( string $value, string $where = 'header', string $name = null, string | array $requires = null ) : boolean
$value string Either a URL or raw JS to be output inline.
$where string Where should it be output? Options are header and footer.
$name string A name to reference this script by. Used for removing or using in $requires by other scripts.
$requires string | array Either a string or an array of strings of $name's for scripts this script requires.
Результат boolean True if added successfully, false otherwise.

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

Add a stylesheet to the stack to be output in the theme.
public add_style ( string $value, string $where = 'header', string $name = null, string | array $requires = null ) : boolean
$value string Either a URL or raw CSS to be output inline.
$where string Where should it be output? Options are header and footer.
$name string A name to reference this script by. Used for removing or using in $after by other scripts.
$requires string | array Either a string or an array of strings of $name's for scripts this script requires.
Результат boolean True if added successfully, false otherwise.

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

Add a template to the list of available templates
public add_template ( string $name, string $file, boolean $replace = false )
$name string Name of the new template
$file string File of the template to add
$replace boolean If true, replace any existing template with this name

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

Assign the default variables that would be used in every template
public add_template_vars ( )

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

Helper function: Avoids having to call $theme->template_engine->key= 'value';
public assign ( $key, $value )

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

Matches the scope criteria against the current request
public check_scope_criteria ( array $criteria ) : boolean
$criteria array An array of scope criteria data in RPN, where values are arrays and operators are strings
Результат boolean True if the criteria matches the current request

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

Convert a theme directory or resource into a URL
public dir_to_url ( string $dir ) : boolean | string
$dir string The pathname to convert
Результат boolean | string The URL to use, or false if none was found

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

Helper function: Avoids having to call $theme->template_engine->display( 'template_name' );
public display ( string $template_name )
$template_name string The name of the template to display

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

Find the first template that matches from the list provided and display it
public display_fallback ( array $template_list, $display_function = 'display' )
$template_list array The list of templates to search for

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

End the current template variable buffer
public end_buffer ( )

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

Helper function: Avoids having to call $theme->template_engine->fetch( 'template_name' );
public fetch ( string $template_name, boolean $unstack = false ) : string
$template_name string The name of the template to display
$unstack boolean If true, end the current template variable buffer upon returning
Результат string The content of the template

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

Assumes that the template variables have already been set.
public fetch_unassigned ( string $template_name ) : string
$template_name string The name of the template to display
Результат string The content of the template

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

Provide default Habari features for curious plugins
public static filter_provided ( array $provided = [] ) : array
$provided array Features already collected from interrogated plugins
Результат array Plugin Features plus Habari Features

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

Retrieve the block objects for the current scope and specified area Incomplete!
public get_blocks ( string $area, string $scope, Theme $theme ) : array
$area string The area to which blocks will be output
$scope string The scope to which blocks will be output
$theme Theme The theme that is outputting these blocks
Результат array An array of Block instances to render

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

Retrieve current scope data from the database based on the requested area
public get_scopes ( string $area ) : array
$area string The area for which a scope may be applied
Результат array An array of scope data

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

Get the URL for a resource in one of the directories used by the active theme, child theme directory first
public get_url ( boolean | string $resource = false, boolean $overrideok = true ) : string
$resource boolean | string The resource name
$overrideok boolean If false, find only the parent theme resources
Результат string The URL of the requested resource

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

Provide a method to return the version number from the theme xml
public get_version ( ) : string
Результат string The theme version from XML

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

Loads a theme's metadata from an XML file in theme's directory.
public info ( )

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

Load and return a list of all assets in the current theme chain's /assets/ directory
public load_assets ( boolean $refresh = false ) : array
$refresh boolean If True, clear and reload all assets
Результат array An array of URLs of assets in the assets directories of the active theme chain

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

Play back the full stack of template variables to assign them into the template
protected play_var_stack ( )

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

Sort function for ordering scope object rows by priority
public sort_scopes ( StdObject $scope1, StdObject $scope2 ) : integer
$scope1 StdObject A scope to compare
$scope2 StdObject A scope to compare
Результат integer A sort return value, -1 to 1

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

Start a new template variable buffer
public start_buffer ( )

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

Determine if a template exists in the current theme
public template_exists ( string $template_name ) : boolean
$template_name string The name of the template to detect
Результат boolean True if template exists

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

Displays blocks associated to the specified area and current scope.
public theme_area ( Theme $theme, string $area, string $context = null, string $scope = null ) : string
$theme Theme The theme with which this area will be output
$area string The area to which blocks will be output
$context string The area of context within the theme that could adjust the template used
$scope string Used to force a specific scope
Результат string the output of all the blocks

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

A theme function for outputting CSS classes based on the requested content
public theme_body_class ( Theme $theme, mixed $args = [] ) : string
$theme Theme A Theme object instance
$args mixed Additional classes that should be added to the ones generated
Результат string The resultant classes

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

Returns the feedback URL to which comments should be submitted for the indicated Post
public theme_comment_form_action ( Theme $theme, Post $post ) : string
$theme Theme The current theme
$post Post The post object to get the feedback URL for
Результат string The URL to the feedback entrypoint for this comment

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

Passed strings are localized prior to parsing therefore to localize "%d Comments" in french, it would be "%d Commentaires". Since we use sprintf() in the final concatenation, you must format passed strings accordingly.
public theme_comments_count ( Theme $theme, Post $post, string $zero = '', string $one = '', string $many = '' ) : string
$theme Theme The current theme object
$post Post Post object used to build the comments link
$zero string String to return when there are no comments
$one string String to return when there is one comment
$many string String to return when there are more than one comment
Результат string String to display for comment count

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

Display an object using a template designed for the type of object it is The $object is assigned into the theme using the $content template variable
public theme_content ( Theme $theme, object $object, string $context = null )
$theme Theme The theme used to display the object
$object object An object to display
$context string The context in which the object will be displayed

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

Returns the appropriate alternate feed based on the currently matched rewrite rule.
public theme_feed_alternate ( Theme $theme ) : string
$theme Theme The current theme object
Результат string Link to the appropriate alternate Atom feed

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

Check to see if the theme is currently rendering a specific context
public theme_has_context ( $theme, string $context ) : boolean
$context string The context to check for.
Результат boolean True if the context is active.

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

Aggregates and echos the additional header code by combining Plugins and Stack calls.
public theme_header ( $theme )

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

Build a collection of paginated URLs to be used for pagination.
public static theme_page_selector ( $theme, $rr_name = null, $settings = [] ) : string
Результат string Collection of paginated URLs built by the RewriteRule.

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

A Theme function to provide a page title
public theme_page_title ( Theme $theme )
$theme Theme The current theme

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

Returns the count of queries executed
public theme_query_count ( ) : integer
Результат integer The query count

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

Returns total query execution time in seconds
public theme_query_time ( ) : float
Результат float Query execution time in seconds, with fractions.

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

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

public $config_vars

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

public $context

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

public $name

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

public TemplateEngine,habari $template_engine
Результат TemplateEngine

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

public $theme_dir

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

We build the Post filters by analyzing the handler_var data which is assigned to the handler ( by the Controller and also, optionally, by the Theme )
public $valid_filters

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

public $version