| [ Index ] |
PHP Cross Reference of Akelos Framework |
[Source view] [Print]
(no description)
| Author: | Jose Salavert |
| Author: | Bermi Ferrer |
| Copyright: | Copyright (c) 2002-2006, Akelos Media, S.L. http://www.akelos.org |
| License: | GNU Lesser General Public License |
| File Size: | 698 lines (24 kb) |
| Included or required: | 4 times |
| Referenced: | 0 times |
| Includes or requires: | 0 files |
TextHelper:: (34 methods):
setController()
TextHelper()
truncate()
highlight()
excerpt()
pluralize()
word_wrap()
format()
textilize()
textilize_without_paragraph()
simple_format()
auto_link()
strip_tags()
strip_links()
auto_link_email_addresses()
strip_selected_tags()
auto_link_urls()
_replace_url_with_link_callback()
get_urls_from_text()
get_linked_urls_from_text()
get_image_urls_from_html()
cycle()
reset_cycle()
markdown()
locale()
translate()
t()
humanize()
titleize()
flash()
utf8()
close_unmatched_html()
html_escape()
h()
Class: TextHelper - X-Ref
Provides a set of methods for working with text strings that can help unburden| setController(&$controller) X-Ref |
| No description |
| TextHelper() X-Ref |
| No description |
| truncate($text, $length = 30, $truncate_string = '...', $break = false) X-Ref |
| Truncates "$text" to the length of "length" and replaces the last three characters with the "$truncate_string" if the "$text" is longer than "$length" and the last characters will be replaced with the +truncate_string+. If +break+ is specified and if it's present in +text+ and if its position is lesser than +length+, then the truncated +text+ will be limited to +break+. |
| highlight($text, $phrase, $highlighter = '<strong class="highlight">\1</strong>') X-Ref |
| Highlights the string or array of strings "$phrase" where it is found in the "$text" by surrounding it like <strong class="highlight">I'm a highlight phrase</strong>. The highlighter can be specialized by passing "$highlighter" as string with \1 where the phrase is supposed to be inserted. Note: The "$phrase" is sanitized with preg_quote before use. Examples: <?=$text_helper->highlight('I am highlighting the phrase','highlighting');?> //outputs: I am <strong class="highlight">highlighting</strong> the phrase <?=$text_helper->highlight('I am highlighting the phrase', array('highlighting','the')?> //outputs: I am <strong class="highlight">highlighting</strong> <strong class="highlight">the</strong> phrase |
| excerpt($text, $phrase, $radius = 100, $excerpt_string = '...') X-Ref |
| 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, '' is returned. Example: <?=$text_helper->excerpt("hello my world", "my", 3);?> //outputs: ...lo my wo... |
| pluralize($count, $singular, $plural = null) X-Ref |
| Attempts to pluralize the "$singular" word unless "$count" is 1. |
| word_wrap($text, $line_width = 80, $break = "\n") X-Ref |
| Word wrap long lines to line_width. |
| format($text, $options = array() X-Ref |
| Like word wrap but allows defining text indenting and boby indenting |
| textilize($text, $options = array() X-Ref |
| Returns the "$text" with all the Textile codes turned into HTML-tags. |
| textilize_without_paragraph($text, $options = array() X-Ref |
| Returns the "$text" with all the Textile codes turned into HTML-tags, but without the regular bounding <p> tag. |
| simple_format($text) X-Ref |
| Returns "$text" transformed into HTML using very simple formatting rules Surrounds paragraphs with <tt><p></tt> tags, and converts line breaks into <tt><br /></tt> Two consecutive newlines(<tt>\n\n</tt>) are considered as a paragraph, one newline (<tt>\n</tt>) is considered a linebreak, three or more consecutive newlines are turned into two newlines |
| auto_link($text, $link = 'all', $href_options = array() X-Ref |
| 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: <?=$text_helper->auto_link("Go to http://www.akelos.org and say hello to bermi@example.com");?> //outputs: Go to <a href="http://www.akelos.org">http://www.akelos.org</a> and say hello to <a href="mailto:example.com">bermi@example.com</a> |
| strip_tags($html) X-Ref |
| Strips all HTML tags from the input, including comments. Returns the tag free text. |
| strip_links($text) X-Ref |
| Turns all links into words, like "<a href="something">else</a>" to "else". |
| auto_link_email_addresses($text, $email_options = array() X-Ref |
| Turns all email addresses into clickable links. You can provide an options array in order to generate links using UrlHelper::mail_to() Example: $text_helper->auto_link_email_addresses($post->body); |
| strip_selected_tags($text, $tags = array() X-Ref |
| Works like PHP function strip_tags, but it only removes selected tags. Example: <?=$text_helper->strip_selected_tags( '<b>Person:</b> <strong>Salavert</strong>', 'strong');?> //outputs: <b>Person:</b> Salavert |
| auto_link_urls($text, $href_options = array() X-Ref |
| Turns all urls into clickable links. Example: <?=$text_helper->auto_link_urls($post->body, array('all', 'target' => '_blank'));?> |
| _replace_url_with_link_callback($matched, $extra_options) X-Ref |
| No description |
| get_urls_from_text($text) X-Ref |
| Returns an array with all the urls found as key and their valid link url as value Example: $text_helper->get_urls_from_text('www.akelos.com'); //returns: array('www.akelos.com'=>'http://www.akelos.com'); |
| get_linked_urls_from_text($text) X-Ref |
| Returns an array with the linked urls found on a text Example: $text_helper->get_linked_urls_from_text('<a href="http://akelos.com">Akelos.com</a>'); //returns: array('http://akelos.com'); |
| get_image_urls_from_html($text) X-Ref |
| Returns an array with the image urls found on a text Example: $text_helper->get_linked_urls_from_text('<a href="http://akelos.com">Akelos.com</a>'); //returns: array('http://akelos.com/images/logo.gif'); |
| cycle($first_value, $values = null) X-Ref |
| Cycles through items of an array every time it is called. This can be used to alternate classes for table rows: {loop items} <tr class="<?=$text_helper->cycle("even", "odd")?>"> ... use $item ... </tr> {end} You can use named cycles to prevent clashes in nested loops. You'll have to reset the inner cycle, manually: {loop items} <tr class="<?=$text_helper->cycle("even", "odd", array('name' => "row_class"))?> <td> {loop values} <span style="color:'<?=$text_helper->cycle("red", "green", "blue",array('name' => "colors"))?>'"> ... use $item ... </span> {end} <php $text_helper->reset_cycle("colors"); ?> </td> </tr> {end} |
| reset_cycle($name) X-Ref |
| No description |
| markdown($text) X-Ref |
| Returns the text with all the Markdown codes turned into HTML-tags. |
| locale($locale_setting, $locale = null) X-Ref |
| Gets a localized setting (date format,...). |
| translate($string, $args = null, $locale_namespace = null) X-Ref |
| Translate strings to the current locale. |
| t($string, $args = null, $locale_namespace = null) X-Ref |
| Alias for translate |
| humanize($text) X-Ref |
| No description |
| titleize($text, $uppercase = '') X-Ref |
| Converts an underscored or CamelCase word into a English sentence. The titleize function converts text like "WelcomePage", "welcome_page" or "welcome page" to this "Welcome Page". If second parameter is set to 'first' it will only capitalize the first character of the title. param: string $word Word to format as tile param: string $uppercase If set to 'first' it will only uppercase the return: string Text formatted as title |
| flash($message = null, $options = array() X-Ref |
| Use this function to automatically handle flash messages. Examples: <?=$text_helper->flash();?> //will handle all flash messages automatically <?=$text_helper->flash(null,array('secconds_to_close'=>5));?> //will handle all flash messages automatically and will close in 5 secconds. NOTE. you need to include javascript dependencies for using interactive options |
| utf8($text, $input_string_encoding = null) X-Ref |
| Recodes "$text" into utf-8 from "$input_string_encoding" |
| close_unmatched_html($html) X-Ref |
| Will atempt to close unmatched tags. This is useful for truncating messages and not breaking the layout. |
| html_escape($html) X-Ref |
| No description |
| h($html) X-Ref |
| No description |
| Generated: Mon Oct 27 12:43:49 2008 | Cross-referenced by PHPXref 0.6 |