symfony API

TextHelper Functions

You are currently browsing
the website for symfony 1

Visit the Symfony2 website


« Back to API menu

1.0 API OpenSearch

Packages

You are currently browsing the symfony API for the 1.0 version. Switch to:
This version of symfony is not maintained anymore.
If some of your projects still use this version, consider upgrading as soon as possible.

TextHelper.

Function Summary

  • auto_link_text()
    Turns all urls and email addresses into clickable links. The +link+ parameter can limit what should be linked.
  • excerpt_text()
    Extracts an excerpt from the +text+ surrounding the +phrase+ with a number of characters on each side determined
  • highlight_text()
    Highlights the +phrase+ where it is found in the +text+ by surrounding it like
  • simple_format_text()
  • strip_links_text()
  • truncate_text()
    Truncates +text+ to the length of +length+ and replaces the last three characters with the +truncate_string+
  • wrap_text()
    Word wrap long lines to line_width.
  • _auto_link_email_addresses()
    Turns all email addresses into clickable links.
  • _auto_link_urls()
    Turns all urls into clickable links.

Function Details

  • auto_link_text () Browse code

    Turns all urls and email addresses into clickable links. The +link+ parameter can limit what should be linked.

    Options are :all (default), :email_addresses, and :urls.

    Example:
    auto_link("Go to http://www.symfony-project.com and say hello to fabien.potencier@example.com") =>
    Go to http://www.symfony-project.com and
    say hello to fabien.potencier@example.com

  • excerpt_text () Browse code

    Extracts an excerpt from the +text+ surrounding the +phrase+ with a number of characters on each side determined

    by +radius+. If the phrase isn't found, nil is returned. Ex:
    excerpt("hello my world", "my", 3) => "...lo my wo..."
    If +excerpt_space+ is true the text will only be truncated on whitespace, never inbetween words.
    This might return a smaller radius than specified.
    excerpt("hello my world", "my", 3, "...", true) => "... my ..."

  • highlight_text () Browse code

    Highlights the +phrase+ where it is found in the +text+ by surrounding it like

    I'm a highlight phrase. The highlighter can be specialized by
    passing +highlighter+ as single-quoted string with \1 where the phrase is supposed to be inserted.
    N.B.: The +phrase+ is sanitized to include only letters, digits, and spaces before use.

  • simple_format_text () Browse code

  • strip_links_text () Browse code

  • truncate_text () Browse code

    Truncates +text+ to the length of +length+ and replaces the last three characters with the +truncate_string+

    if the +text+ is longer than +length+.

  • wrap_text () Browse code

    Word wrap long lines to line_width.

  • _auto_link_email_addresses () Browse code

    Turns all email addresses into clickable links.

  • _auto_link_urls () Browse code

    Turns all urls into clickable links.