Formatting


Functions

 format_rss_channel ($title, $link, $description, $items, $langcode=NULL, $args=array())
 format_rss_item ($title, $link, $description, $args=array())
 format_xml_elements ($array)
 format_plural ($count, $singular, $plural, $args=array(), $langcode=NULL)
 parse_size ($size)
 format_size ($size, $langcode=NULL)
 format_interval ($timestamp, $granularity=2, $langcode=NULL)
 format_date ($timestamp, $type= 'medium', $format= '', $timezone=NULL, $langcode=NULL)

Detailed Description

Functions to format numbers, strings, dates, etc.

Function Documentation

format_date ( timestamp,
type = 'medium',
format = '',
timezone = NULL,
langcode = NULL 
)

Format a date with the given configured format or a custom format string.

Drupal allows administrators to select formatting strings for 'small', 'medium' and 'large' date formats. This function can handle these formats, as well as any custom format.

Parameters:
$timestamp The exact date to format, as a UNIX timestamp.
$type The format to use. Can be "small", "medium" or "large" for the preconfigured date formats. If "custom" is specified, then $format is required as well.
$format A PHP date format string as required by date(). A backslash should be used before a character to avoid interpreting the character as part of a date format.
$timezone Time zone offset in seconds; if omitted, the user's time zone is used.
$langcode Optional language code to translate to a language other than what is used to display the page.
Returns:
A translated date string in the requested format.

Definition at line 1151 of file common.inc.

References $type, t(), and variable_get().

Referenced by comment_admin_overview(), dblog_event(), dblog_overview(), DrupalWebTestCase::drupalCreateNode(), expand_date(), garland_node_submitted(), map_month(), node_form(), node_object_prepare(), node_revision_delete_confirm(), node_revision_delete_confirm_submit(), node_revision_overview(), node_revision_revert_confirm(), node_revision_revert_confirm_submit(), phptemplate_comment_submitted(), statistics_access_log(), statistics_node_tracker(), statistics_recent_hits(), statistics_user_tracker(), system_date_time_lookup(), system_date_time_settings(), template_preprocess_aggregator_item(), template_preprocess_node(), template_preprocess_search_result(), theme_update_report(), theme_update_version(), and user_pass_reset().

Here is the call graph for this function:

format_interval ( timestamp,
granularity = 2,
langcode = NULL 
)

Format a time interval with the requested granularity.

Parameters:
$timestamp The length of the interval in seconds.
$granularity How many different units to display in the string.
$langcode Optional language code to translate to a language other than what is used to display the page.
Returns:
A translated string representation of the interval.

Definition at line 1109 of file common.inc.

References $output, $value, format_plural(), and t().

Referenced by aggregator_view(), statistics_top_pages(), statistics_top_referrers(), statistics_top_visitors(), template_preprocess_aggregator_feed_source(), template_preprocess_aggregator_item(), template_preprocess_aggregator_summary_item(), theme_update_report(), tracker_page(), and user_admin_account().

Here is the call graph for this function:

format_plural ( count,
singular,
plural,
args = array(),
langcode = NULL 
)

Format a string containing a count of items.

This function ensures that the string is pluralized correctly. Since t() is called by this function, make sure not to pass already-localized strings to it.

For example:

   $output = format_plural($node->comment_count, '1 comment', '@count comments');

Example with additional replacements:

   $output = format_plural($update_count,
     'Changed the content type of 1 post from %old-type to %new-type.',
     'Changed the content type of @count posts from %old-type to %new-type.',
     array('%old-type' => $info->old_type, '%new-type' => $info->new_type)));

Parameters:
$count The item count to display.
$singular The string for the singular case. Please make sure it is clear this is singular, to ease translation (e.g. use "1 new comment" instead of "1 new"). Do not use in the singular string.
$plural The string for the plural case. Please make sure it is clear this is plural, to ease translation. Use in place of the item count, as in " new comments".
$args An associative array of replacements to make after translation. Incidences of any key in this array are replaced with the corresponding value. Based on the first character of the key, the value is escaped and/or themed:
  • !variable: inserted as is
  • : escape plain text to HTML (check_plain)
  • variable: escape text and theme as a placeholder for user-submitted content (check_plain + theme_placeholder) Note that you do not need to include in this array. This replacement is done automatically for the plural case.
$langcode Optional language code to translate to a language other than what is used to display the page.
Returns:
A translated string.

Definition at line 1023 of file common.inc.

References t().

Referenced by _locale_batch_language_finished(), _locale_batch_system_finished(), _node_mass_update_batch_finished(), actions_synchronize(), aggregator_view(), format_interval(), format_size(), menu_delete_menu_confirm(), menu_edit_menu_validate(), node_node_type(), node_type_delete_confirm(), DrupalReporter::paintGroupEnd(), poll_page(), search_admin_settings(), system_modules_confirm_form(), and tracker_page().

Here is the call graph for this function:

format_rss_channel ( title,
link,
description,
items,
langcode = NULL,
args = array() 
)

Formats an RSS channel.

Arbitrary elements may be added using the $args associative array.

Definition at line 902 of file common.inc.

References $output, $title, check_plain(), check_url(), decode_entities(), and format_xml_elements().

Referenced by theme_aggregator_page_rss().

Here is the call graph for this function:

format_rss_item ( title,
link,
description,
args = array() 
)

Format a single RSS item.

Arbitrary elements may be added using the $args associative array.

Definition at line 927 of file common.inc.

References $output, $title, check_plain(), check_url(), and format_xml_elements().

Referenced by theme_aggregator_page_rss().

Here is the call graph for this function:

format_size ( size,
langcode = NULL 
)

Generate a string representation for the given byte count.

Parameters:
$size A size in bytes.
$langcode Optional language code to translate to a language other than what is used to display the page.
Returns:
A translated string representation of the size.

Definition at line 1081 of file common.inc.

References format_plural(), and t().

Referenced by file_save_upload(), file_validate_size(), upload_admin_settings(), and upload_admin_settings_validate().

Here is the call graph for this function:

format_xml_elements ( array  ) 

Format XML elements.

Parameters:
$array An array where each item represent an element and is either a:
  • (key => value) pair (<key>value</key>)
  • Associative array with fields:
    • 'key': element name
    • 'value': element contents
    • 'attributes': associative array of element attributes
In both cases, 'value' can be a simple string, or it can be another array with the same format as $array itself for nesting.

Definition at line 952 of file common.inc.

References $output, $value, check_plain(), and drupal_attributes().

Referenced by format_rss_channel(), and format_rss_item().

Here is the call graph for this function:

parse_size ( size  ) 

Parse a given byte count.

Parameters:
$size A size expressed as a number of bytes with optional SI size and unit suffix (e.g. 2, 3K, 5MB, 10G).
Returns:
An integer representation of the size.

Definition at line 1058 of file common.inc.

References drupal_strtolower().

Referenced by file_upload_max_size().

Here is the call graph for this function:


Generated on Mon Jun 2 15:08:37 2008 for SimpleTest by  1.5.5