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
파일 보기 프로젝트 열기: habari/system

공개 프로퍼티들

프로퍼티 타입 설명
$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