Static Public Member Functions

Format Class Reference

List of all members.

Static Public Member Functions

static apply ($format, $onwhat)
static apply_with_hook_params ($format, $onwhat)
static by_index ($index)
static load_all ()
static autop ($value)
static and_list ($array, $between= ', ', $between_last=null)
static tag_and_list ($terms, $between= ', ', $between_last=null, $sort_alphabetical=false)
static format_date ($date, $format)
static nice_date ($date, $dateformat= 'F j, Y')
static nice_time ($date, $dateformat= 'H:i:s')
static summarize ($text, $count=100, $max_paragraphs=1)
static more ($content, $post, $properties=array())
static html_messages ($notices, $errors)
static humane_messages ($notices, $errors)
static json_messages ($notices, $errors)
static term_tree ($terms, $tree_name, $config=array())

Detailed Description

Habari Format Class

Provides formatting functions for use in themes. Extendable.

Definition at line 15 of file format.php.


Member Function Documentation

static Format::and_list ( array,
between = ',
,
between_last = null 
) [static]

function and_list Turns an array of strings into a friendly delimited string separated by commas and an "and"

Parameters:
array $array An array of strings
string $between Text to put between each element
string $between_last Text to put between the next-to-last element and the last element string The constructed string

Definition at line 256 of file format.php.

Referenced by DateTime::friendly(), and FormValidators::validate_url().

static Format::apply ( format,
onwhat 
) [static]

Called to register a format function to a plugin hook, only passing the hook's first parameter to the Format function.

Parameters:
string $format A function name that exists in a Format class
string $onwhat A plugin hook to apply that Format function to as a filter

Definition at line 24 of file format.php.

Referenced by Charcoal::action_init_theme().

static Format::apply_with_hook_params ( format,
onwhat 
) [static]

Called to register a format function to a plugin hook, and passes all of the hook's parameters to the Format function.

Parameters:
string $format A function name that exists in a Format class
string $onwhat A plugin hook to apply that Format function to as a filter

Definition at line 69 of file format.php.

Referenced by Charcoal::action_init_theme().

static Format::autop ( value  )  [static]

DEFAULT FORMAT FUNCTIONS function autop Converts non-HTML paragraphs separated with 2 or more new lines into HTML paragraphs while preserving any internal HTML. New lines within the text of block elements are converted to linebreaks. New lines before and after tags are stripped.

If you make changes to this, PLEASE add test cases here: http://svn.habariproject.org/habari/trunk/tests/data/autop/

Parameters:
string $value The string to apply the formatting
Returns:
string The formatted string

Definition at line 153 of file format.php.

Referenced by Pluggable::get_xml_text().

static Format::by_index ( index  )  [static]

function by_index Returns an indexed formatter object, for use by lambda functions created to supply additional parameters to plugin filters.

Parameters:
integer $index The index of the formatter object to return.
Returns:
Format The formatter object requested

Definition at line 116 of file format.php.

static Format::format_date ( date,
format 
) [static]

Format a date using a specially formatted string Useful for using a single string to format multiple date components. Example: If $dt is a DateTime for December 10, 2008... echo $dt->format_date('

{F} {j}, {Y}

'); // Output:

December 10, 2008
Parameters:
DateTime $date The date to format
string $format A string with date()-like letters within braces to replace with date components
Returns:
string The formatted string

Definition at line 326 of file format.php.

static Format::html_messages ( notices,
errors 
) [static]

html_messages Creates an HTML unordered list of an array of messages

Parameters:
array $notices a list of success messages
array $errors a list of error messages
Returns:
string HTML output

Definition at line 572 of file format.php.

Referenced by Session::messages_get().

static Format::humane_messages ( notices,
errors 
) [static]

humane_messages Creates JS calls to display session messages

Parameters:
array $notices a list of success messages
array $errors a list of error messages
Returns:
string JS output

Definition at line 600 of file format.php.

static Format::json_messages ( notices,
errors 
) [static]

json_messages Creates a JSON list of session messages

Parameters:
array $notices a list of success messages
array $errors a list of error messages
Returns:
string JS output

Definition at line 626 of file format.php.

static Format::load_all (  )  [static]

function load_all Loads and stores an instance of all declared Format classes for future use

Definition at line 125 of file format.php.

Referenced by apply(), and apply_with_hook_params().

static Format::more ( content,
post,
properties = array() 
) [static]

Returns a truncated version of post content when the post isn't being displayed on its own. Posts are split either at the comment or at the specified maximums. Use only after applying autop or other paragrpah styling methods. Apply to posts using: Format::apply_with_hook_params( 'more', 'post_content_out' );

Parameters:
string $content The post content
Post $post The Post object of the post
string $more_text The text to use in the "read more" link.
integer $max_words null or the maximum number of words to use before showing the more link
integer $max_paragraphs null or the maximum number of paragraphs to use before showing the more link
boolean $inside_last Should the link be placed inside the last element, or not? Default: true
Returns:
string The post content, suitable for display

Definition at line 459 of file format.php.

Referenced by Post::__get().

static Format::nice_date ( date,
dateformat = 'F j,
Y'   
) [static]

function nice_date Formats a date using a date format string

Parameters:
DateTime $date A date as a DateTime object
string $dateformat A date format string
Returns:
string The date formatted as a string

Definition at line 341 of file format.php.

static Format::nice_time ( date,
dateformat = 'H:i:s' 
) [static]

function nice_time Formats a time using a date format string

Parameters:
DateTime $date A date as a DateTime object
string $dateformat A date format string
Returns:
string The time formatted as a string

Definition at line 356 of file format.php.

static Format::summarize ( text,
count = 100,
max_paragraphs = 1 
) [static]

Returns a shortened version of whatever is passed in.

Parameters:
string $value A string to shorten
integer $count Maximum words to display [100]
integer $max_paragraphs Maximum paragraphs to display [1]
Returns:
string The string, shortened

Definition at line 371 of file format.php.

Referenced by more().

static Format::tag_and_list ( terms,
between = ',
,
between_last = null,
sort_alphabetical = false 
) [static]

function tag_and_list Formatting function (should be in Format class?) Turns an array of tag names into an HTML-linked list with commas and an "and".

Parameters:
array $array An array of tag names
string $between Text to put between each element
string $between_last Text to put between the next to last element and the last element
boolean $sort_alphabetical Should the tags be sorted alphabetically by `term` first?
Returns:
string HTML links with specified separators.

Definition at line 283 of file format.php.

Referenced by MzingiHi::action_add_template_vars(), and Charcoal::add_template_vars().

static Format::term_tree ( terms,
tree_name,
config = array() 
) [static]

function term_tree Create nested HTML lists from a hierarchical vocabulary.

Turns Terms or an array of terms from a hierarchical vocabulary into a ordered HTML list with list items for each term.

Parameters:
mixed $terms An array of Term objects or a Terms object.
string $tree_name The name of the tree, used for unique node id's
array $config an array of values to use to configure the output of this function
Returns:
string The transformed vocabulary.

Definition at line 642 of file format.php.


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