Class Format

Description

Habari Format Class

Provides formatting functions for use in themes. Extendable.

Located in /system/classes/format.php (line 9)


	
			
Method Summary
static void and_list (array $array, [string $between = ', '], [string $between_last = NULL])
static void apply (string $format, string $onwhat)
static void apply_with_hook_params (string $format, string $onwhat)
static string autop (string $value)
static Format by_index (integer $index)
static string html_messages (array $notices, array $errors)
static string humane_messages (array $notices, array $errors)
static string json_messages (array $notices, array $errors)
static void load_all ()
static string more (string $content, Post $post, [string $more_text = 'Read More »'], [integer $max_words = null], [integer $max_paragraphs = null])
static string nice_date (HabariDateTime $date, [string $dateformat = 'F j, Y'])
static string nice_time (HabariDateTime $date, [string $dateformat = 'H:i:s'])
static string summarize ( $text, [integer $count = 100], [integer $maxparagraphs = 1], string $value)
static string tag_and_list (array $array, [string $between = ', '], [string $between_last = NULL])
Methods
static method and_list (line 170)

function and_list

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

  • access: public
static void and_list (array $array, [string $between = ', '], [string $between_last = NULL])
  • 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
static method apply (line 18)

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

  • access: public
static void apply (string $format, string $onwhat)
  • 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
static method apply_with_hook_params (line 47)

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

  • access: public
static void apply_with_hook_params (string $format, string $onwhat)
  • 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
static method autop (line 111)

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.

  • return: The formatted string
  • access: public
static string autop (string $value)
  • string $value: The string to apply the formatting
static method by_index (line 78)

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

  • return: The formatter object requested
  • access: public
static Format by_index (integer $index)
  • integer $index: The index of the formatter object to return.
static method html_messages (line 363)

html_messages

Creates an HTML unordered list of an array of messages

  • return: HTML output
  • access: public
static string html_messages (array $notices, array $errors)
  • array $notices: a list of success messages
  • array $errors: a list of error messages
static method humane_messages (line 391)

humane_messages

Creates JS calls to display session messages

  • return: JS output
  • access: public
static string humane_messages (array $notices, array $errors)
  • array $notices: a list of success messages
  • array $errors: a list of error messages
static method json_messages (line 417)

json_messages

Creates a JSON list of session messages

  • return: JS output
  • access: public
static string json_messages (array $notices, array $errors)
  • array $notices: a list of success messages
  • array $errors: a list of error messages
static method load_all (line 87)

function load_all

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

  • access: public
static void load_all ()
static method more (line 330)

Returns a truncated version of post content when the post isn't being displayed on its own.

Posts are split either at the comment <!--more--> or at the specified maximums. Use only after applying autop or other paragrpah styling methods. Apply to posts using:

  1. Format::apply_with_hook_params'more''post_content_out' );

  • return: The post content, suitable for display
  • access: public
static string more (string $content, Post $post, [string $more_text = 'Read More &raquo;'], [integer $max_words = null], [integer $max_paragraphs = null])
  • 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
static method nice_date (line 220)

function nice_date

Formats a date using a date format string

  • return: The date formatted as a string
  • access: public
static string nice_date (HabariDateTime $date, [string $dateformat = 'F j, Y'])
  • HabariDateTime $date: A date as a HabariDateTime object
  • string $dateformat: A date format string
static method nice_time (line 235)

function nice_time

Formats a time using a date format string

  • return: The time formatted as a string
  • access: public
static string nice_time (HabariDateTime $date, [string $dateformat = 'H:i:s'])
  • HabariDateTime $date: A date as a HabariDateTime object
  • string $dateformat: A date format string
static method summarize (line 250)

Returns a shortened version of whatever is passed in.

  • return: The string, shortened
  • access: public
static string summarize ( $text, [integer $count = 100], [integer $maxparagraphs = 1], string $value)
  • string $value: A string to shorten
  • integer $count: Maximum words to display [100]
  • integer $maxparagraphs: Maximum paragraphs to display [1]
  • $text
static method tag_and_list (line 195)

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".

  • return: HTML links with specified separators.
  • access: public
static string tag_and_list (array $array, [string $between = ', '], [string $between_last = NULL])
  • 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

Documentation generated on Thu, 30 Oct 2008 20:31:11 +0100 by phpDocumentor 1.3.2