Public Member Functions | Static Public Member Functions | Public Attributes | Protected Member Functions

Theme Class Reference

Inheritance diagram for Theme:
Collaboration diagram for Theme:

List of all members.

Public Member Functions

 __construct ($themedata)
 info ()
 add_template_vars ()
 display_fallback ($template_list, $display_function= 'display')
 template_exists ($template_name)
 act_display ($paramarray=array( 'user_filters'=> array()))
 act_display_home ($user_filters=array())
 act_display_entries ($user_filters=array())
 act_display_post ($user_filters=array())
 act_display_tag ($user_filters=array())
 act_display_date ($user_filters=array())
 act_search ($user_filters=array())
 act_display_404 ($user_filters=array())
 display ($template_name)
 fetch ($template_name, $unstack=false)
 fetch_unassigned ($template_name)
 assign ($key, $value)
 theme_header ($theme)
 theme_footer ($theme)
 theme_content ($theme, $object, $context=null)
 theme_has_context ($theme, $context)
 theme_feed_alternate ($theme)
 theme_comment_form_action ($theme, $post)
 theme_prev_page_link ($theme, $text=null, $classes=array( 'prev-page'))
 theme_next_page_link ($theme, $text=null, $classes=array( 'next-page'))
 theme_comments_link ($theme, $post, $zero= '', $one= '', $many= '', $fragment= 'comments')
 theme_comments_count ($theme, $post, $zero= '', $one= '', $many= '')
 theme_query_count ()
 theme_query_time ()
 theme_comment_author_link ($theme, $comment)
 __isset ($key)
 __set ($key, $value)
 __get ($key)
 __unset ($key)
 start_buffer ()
 end_buffer ()
 __call ($function, $params)
 get_blocks ($area, $scope, $theme)
 check_scope_criteria ($criteria)
 get_scopes ($area)
 sort_scopes ($scope1, $scope2)
 theme_area ($theme, $area, $context=null, $scope=null)
 theme_body_class ($theme, $args=array())
 theme_page_title ($theme)
 add_script ($value, $where= 'header', $name=null, $requires=null)
 add_style ($value, $where= 'header', $name=null, $requires=null)
 get_version ()
 load_assets ($refresh=false)
 action_template_header_9 ()
 action_template_footer_9 ()
 get_url ($resource=false, $overrideok=true)
 dir_to_url ($dir)
 add_template ($name, $file, $replace=false)

Static Public Member Functions

static theme_page_selector ($theme, $rr_name=null, $settings=array())
static filter_provided ($provided=array())

Public Attributes

 $name = null
 $version = null
 $template_engine = null
 $theme_dir = null
 $config_vars = array()
 $context = array()
 $valid_filters

Protected Member Functions

 play_var_stack ()

Detailed Description

Habari Theme Class

The Theme class is the behind-the-scenes representation of of a set of UI files that compose the visual theme of the blog

Definition at line 16 of file theme.php.


Constructor & Destructor Documentation

Theme::__construct ( themedata  ) 

Constructor for theme

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

Parameters:
name ( optional ) override the default theme lookup
template_engine ( optional ) specify a template engine
theme_dir ( optional ) specify a theme directory

Definition at line 76 of file theme.php.


Member Function Documentation

Theme::__call ( function,
params 
)

Handle methods called on this class or its descendants that are not defined by this class. Allow plugins to provide additional theme actions, like a custom act_display_*()

Parameters:
string $function The method that was called.
array $params An array of parameters passed to the method

Definition at line 1069 of file theme.php.

Theme::__get ( key  ) 

Get a template variable value

Parameters:
string $key The template variable name to get
Returns:
mixed The value of the variable

Definition at line 1024 of file theme.php.

Theme::__isset ( key  ) 

Detects if a variable is assigned to the template engine for use in constructing the template's output.

Parameters:
string $key name of variable
Returns:
bool true if name is set, false if not set

Definition at line 1000 of file theme.php.

Theme::__set ( key,
value 
)

Set a template variable, a property alias for assign() This can only affect the current stack level!

Parameters:
string $key The template variable to set
mixed $value The value of the variable

Definition at line 1013 of file theme.php.

Theme::__unset ( key  ) 

Remove a template variable value This can only affect the current stack level!

Parameters:
string $key The template variable name to unset

Definition at line 1039 of file theme.php.

Theme::act_display ( paramarray = array( 'user_filters'=> array() )  ) 

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

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.

Definition at line 196 of file theme.php.

Theme::act_display_404 ( user_filters = array()  ) 

Helper function: Display a 404 template

Parameters:
array $user_filters Additional arguments user to get the page content

Definition at line 534 of file theme.php.

Theme::act_display_date ( user_filters = array()  ) 

Helper function: Display the posts for a specific date

Parameters:
array $user_filters Additional arguments used to get the page content

Definition at line 440 of file theme.php.

Theme::act_display_entries ( user_filters = array()  ) 

Helper function: Displays multiple entries

Parameters:
array $user_filters Additional arguments used to get the page content

Definition at line 360 of file theme.php.

Theme::act_display_home ( user_filters = array()  ) 

Helper function: Displays the home page

Parameters:
array $user_filters Additional arguments used to get the page content

Reimplemented in MzingiHi.

Definition at line 339 of file theme.php.

Theme::act_display_post ( user_filters = array()  ) 

Helper function: Display a post

Parameters:
array $user_filters Additional arguments used to get the page content

Definition at line 381 of file theme.php.

Theme::act_display_tag ( user_filters = array()  ) 

Helper function: Display the posts for a tag

Parameters:
array $user_filters Additional arguments used to get the page content

Definition at line 412 of file theme.php.

Theme::act_search ( user_filters = array()  ) 

Helper function: Display the posts for a specific criteria

Parameters:
array $user_filters Additional arguments used to get the page content

Definition at line 511 of file theme.php.

Theme::action_template_footer_9 (  ) 

Load assets and add the javascript ones to the footer on the template_footer_javascript action hook.

Definition at line 1475 of file theme.php.

Theme::action_template_header_9 (  ) 

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

Definition at line 1464 of file theme.php.

Theme::add_script ( value,
where = 'header',
name = null,
requires = null 
)

Add javascript to the stack to be output in the theme.

Parameters:
string $value Either a URL or raw JS to be output inline.
string $where Where should it be output? Options are header and footer.
string $name A name to reference this script by. Used for removing or using in $requires by other scripts.
string|array $requires Either a string or an array of strings of $name's for scripts this script requires.
Returns:
boolean True if added successfully, false otherwise.

Definition at line 1372 of file theme.php.

Theme::add_style ( value,
where = 'header',
name = null,
requires = null 
)

Add a stylesheet to the stack to be output in the theme.

Parameters:
string $value Either a URL or raw CSS to be output inline.
string $where Where should it be output? Options are header and footer.
string $name A name to reference this script by. Used for removing or using in $after by other scripts.
string|array $requires Either a string or an array of strings of $name's for scripts this script requires.
Returns:
boolean True if added successfully, false otherwise.

Definition at line 1402 of file theme.php.

Theme::add_template ( name,
file,
replace = false 
)

Add a template to the list of available templates

Parameters:
string $name Name of the new template
string $file File of the template to add
boolean $replace If true, replace any existing template with this name

Reimplemented from Pluggable.

Definition at line 1543 of file theme.php.

Referenced by Charcoal::action_init_theme().

Theme::add_template_vars (  ) 

Assign the default variables that would be used in every template

Reimplemented in InstallerTheme, and Charcoal.

Definition at line 123 of file theme.php.

Theme::assign ( key,
value 
)

Helper function: Avoids having to call $theme->template_engine->key= 'value';

Definition at line 608 of file theme.php.

Referenced by act_display(), Charcoal::add_template_vars(), and display_fallback().

Theme::check_scope_criteria ( criteria  ) 

Matches the scope criteria against the current request

Parameters:
array $criteria An array of scope criteria data in RPN, where values are arrays and operators are strings
Returns:
boolean True if the criteria matches the current request

Definition at line 1129 of file theme.php.

Theme::dir_to_url ( dir  ) 

Convert a theme directory or resource into a URL

Parameters:
string $dir The pathname to convert
Returns:
bool|string The URL to use, or false if none was found

Definition at line 1517 of file theme.php.

Theme::display ( template_name  ) 

Helper function: Avoids having to call $theme->template_engine->display( 'template_name' );

Parameters:
string $template_name The name of the template to display

Definition at line 549 of file theme.php.

Referenced by Menus::action_admin_theme_get_menu_iframe(), and Menus::action_admin_theme_get_menus().

Theme::display_fallback ( template_list,
display_function = 'display' 
)

Find the first template that matches from the list provided and display it

Parameters:
array $template_list The list of templates to search for

Definition at line 161 of file theme.php.

Theme::end_buffer (  ) 

End the current template variable buffer

Definition at line 1056 of file theme.php.

Theme::fetch ( template_name,
unstack = false 
)

Helper function: Avoids having to call $theme->template_engine->fetch( 'template_name' );

Parameters:
string $template_name The name of the template to display
boolean $unstack If true, end the current template variable buffer upon returning
Returns:
string The content of the template

Definition at line 564 of file theme.php.

Theme::fetch_unassigned ( template_name  ) 

Calls the template engine's fetch() method without pre-assigning template variables. Assumes that the template variables have already been set.

Parameters:
string $template_name The name of the template to display
Returns:
string The content of the template

Definition at line 600 of file theme.php.

static Theme::filter_provided ( provided = array()  )  [static]

Provide default Habari features for curious plugins

Parameters:
array $provided Features already collected from interrogated plugins
Returns:
array Plugin Features plus Habari Features

Definition at line 1553 of file theme.php.

Theme::get_blocks ( area,
scope,
theme 
)

Retrieve the block objects for the current scope and specified area Incomplete!

Parameters:
string $area The area to which blocks will be output
string $scope The scope to which blocks will be output
Theme $theme The theme that is outputting these blocks
Returns:
array An array of Block instances to render
Todo:
Finish this function to pull data from a block_instances table

Reimplemented in Monolith.

Definition at line 1116 of file theme.php.

Referenced by Charcoal::action_theme_activated().

Theme::get_scopes ( area  ) 

Retrieve current scope data from the database based on the requested area

Parameters:
string $area The area for which a scope may be applied
Returns:
array An array of scope data

Definition at line 1184 of file theme.php.

Theme::get_url ( resource = false,
overrideok = true 
)

Get the URL for a resource in one of the directories used by the active theme, child theme directory first

Parameters:
bool|string $resource The resource name
bool $overrideok If false, find only the parent theme resources
Returns:
string The URL of the requested resource
Todo:
This method needs to be aware of the class that called it so that it can find the right directory to use

Definition at line 1490 of file theme.php.

Referenced by Charcoal::add_template_vars().

Theme::get_version (  ) 

Provide a method to return the version number from the theme xml

Returns:
string The theme version from XML

Reimplemented from Pluggable.

Definition at line 1427 of file theme.php.

Theme::info (  ) 

Loads a theme's metadata from an XML file in theme's directory.

Definition at line 100 of file theme.php.

Theme::load_assets ( refresh = false  ) 

Load and return a list of all assets in the current theme chain's /assets/ directory

Parameters:
bool $refresh If True, clear and reload all assets
Returns:
array An array of URLs of assets in the assets directories of the active theme chain

Definition at line 1437 of file theme.php.

Theme::play_var_stack (  )  [protected]

Play back the full stack of template variables to assign them into the template

Definition at line 580 of file theme.php.

Theme::sort_scopes ( scope1,
scope2 
)

Sort function for ordering scope object rows by priority

Parameters:
StdObject $scope1 A scope to compare
StdObject $scope2 A scope to compare
Returns:
integer A sort return value, -1 to 1

Definition at line 1202 of file theme.php.

Theme::start_buffer (  ) 

Start a new template variable buffer

Definition at line 1047 of file theme.php.

Theme::template_exists ( template_name  ) 

Determine if a template exists in the current theme

Parameters:
string $template_name The name of the template to detect
Returns:
boolean True if template exists

Definition at line 179 of file theme.php.

Referenced by act_display(), and display_fallback().

Theme::theme_area ( theme,
area,
context = null,
scope = null 
)

Displays blocks associated to the specified area and current scope.

Parameters:
Theme $theme The theme with which this area will be output
string $area The area to which blocks will be output
string $context The area of context within the theme that could adjust the template used
string $scope Used to force a specific scope
Returns:
string the output of all the blocks

Definition at line 1219 of file theme.php.

Theme::theme_body_class ( theme,
args = array() 
)

A theme function for outputting CSS classes based on the requested content

Parameters:
Theme $theme A Theme object instance
mixed $args Additional classes that should be added to the ones generated
Returns:
string The resultant classes

Definition at line 1328 of file theme.php.

Theme::theme_comment_author_link ( theme,
comment 
)

Returns a humane commenter's link for a comment if a URL is supplied, or just display the comment author's name

Parameters:
Theme $theme The current theme
Comment $comment The comment object
Returns:
string A link to the comment author or the comment author's name with no link

Definition at line 973 of file theme.php.

Theme::theme_comment_form_action ( theme,
post 
)

Returns the feedback URL to which comments should be submitted for the indicated Post

Parameters:
Theme $theme The current theme
Post $post The post object to get the feedback URL for
Returns:
string The URL to the feedback entrypoint for this comment

Definition at line 753 of file theme.php.

Theme::theme_comments_count ( theme,
post,
zero = '',
one = '',
many = '' 
)

Returns a full qualified URL of the specified post based on the 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.

Parameters:
Theme $theme The current theme object
Post $post Post object used to build the comments link
string $zero String to return when there are no comments
string $one String to return when there is one comment
string $many String to return when there are more than one comment
Returns:
string String to display for comment count

Definition at line 922 of file theme.php.

Theme::theme_comments_link ( theme,
post,
zero = '',
one = '',
many = '',
fragment = 'comments' 
)

Returns a full qualified URL of the specified post based on the comments count, and links to the post.

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.

Parameters:
Theme $theme The current theme object
Post $post Post object used to build the comments link
string $zero String to return when there are no comments
string $one String to return when there is one comment
string $many String to return when there are more than one comment
string $fragment Fragment (bookmark) portion of the URL to append to the link
string $title Fragment (bookmark) portion of the URL to append to the link
Returns:
string Linked string to display for comment count
See also:
Theme::theme_comments_count()

Definition at line 902 of file theme.php.

Theme::theme_content ( theme,
object,
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

Parameters:
Theme $theme The theme used to display the object
object $object An object to display
string $context The context in which the object will be displayed
Returns:

Definition at line 659 of file theme.php.

Theme::theme_feed_alternate ( theme  ) 

Returns the appropriate alternate feed based on the currently matched rewrite rule.

Parameters:
mixed $return Incoming return value from other plugins
Theme $theme The current theme object
Returns:
string Link to the appropriate alternate Atom feed

Definition at line 719 of file theme.php.

Theme::theme_footer ( theme  ) 

Aggregates and echos the additional footer code by combining Plugins and Stack calls.

Definition at line 640 of file theme.php.

Theme::theme_has_context ( theme,
context 
)

Check to see if the theme is currently rendering a specific context

Parameters:
string $context The context to check for.
Returns:
bool True if the context is active.

Definition at line 704 of file theme.php.

Theme::theme_header ( theme  ) 

Aggregates and echos the additional header code by combining Plugins and Stack calls.

Definition at line 616 of file theme.php.

Theme::theme_next_page_link ( theme,
text = null,
classes = array( 'next-page' ) 
)

Provides a link to the next page

Parameters:
string $text text to display for link

Definition at line 863 of file theme.php.

static Theme::theme_page_selector ( theme,
rr_name = null,
settings = array() 
) [static]

Build a collection of paginated URLs to be used for pagination.

Parameters:
string The RewriteRule name used to build the links.
array Various settings used by the method and the RewriteRule.
Returns:
string Collection of paginated URLs built by the RewriteRule.

Definition at line 765 of file theme.php.

Theme::theme_page_title ( theme  ) 

A Theme function to provide a page title

Parameters:
Theme $theme The current theme

Definition at line 1347 of file theme.php.

Theme::theme_prev_page_link ( theme,
text = null,
classes = array( 'prev-page' ) 
)

Provides a link to the previous page

Parameters:
string $text text to display for link

Definition at line 840 of file theme.php.

Theme::theme_query_count (  ) 

Returns the count of queries executed

Returns:
integer The query count

Definition at line 951 of file theme.php.

Theme::theme_query_time (  ) 

Returns total query execution time in seconds

Returns:
float Query execution time in seconds, with fractions.

Definition at line 961 of file theme.php.


Member Data Documentation

Theme::$valid_filters
Initial value:
 array(
    'preset',
    'content_type',
    'not:content_type',
    'slug',
    'not:slug',
    'user_id',
    'vocabulary',
    'status',
    'page',
    'tag',
    'not:tag',
    'month',
    'year',
    'day',
    'criteria',
    'limit',
    'nolimit',
    'offset',
    'fetch_fn',
    'id',
    'info',
    'has:info',
    'all:info',
    'any:info',
    'not:info',
    'not:all:info',
    'not:any:info',
  )

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 )

Definition at line 34 of file theme.php.


The documentation for this class was generated from the following file: