PHP Class Horde_View_Helper_Text, horde

Author: Mike Naberezny ([email protected])
Author: Derek DeVries ([email protected])
Author: Chuck Hagenbuch ([email protected])
Inheritance: extends Horde_View_Helper_Base
Exibir arquivo Open project: horde/horde

Protected Properties

Property Type Description
$_cycles array
$_inflector Horde_Support_Inflector

Public Methods

Method Description
cleanSmartQuotes ( string $str ) : string Removes smart quotes.
cycle ( $firstValue ) Creates a Cycle object whose __toString() method cycles through elements of an array every time it is called.
h ( mixed $var ) : mixed Escapes a value for output in a view template.
highlight ( string $text, string $phrase, string $highlighter = null ) : string Highlights a phrase where it is found in the text by surrounding it like I'm highlighted.
makeBreakable ( string $str ) : string Inserts HTML code to allow linebreaks in a string after slashes or underscores.
pluralize ( integer $count, string $singular, string $plural = null ) Pluralizes the $singular word unless $count is one. If $plural form is not supplied, inflector will be used.
resetCycle ( string $name = 'default' ) Resets a cycle so that it starts from the first element the next time it is called.
truncate ( string $text, integer $length = 30, string $truncateString = '...' ) : string If $text is longer than $length, $text will be truncated to the length of $length and the last three characters will be replaced with the $truncateString.
truncateMiddle ( string $str, integer $maxLength = 80, string $joiner = '...' ) : string Limits a string to a given maximum length in a smarter way than just using substr().

Method Details

cleanSmartQuotes() public method

Removes smart quotes.
See also: http://shiflett.org/blog/2005/oct/convert-smart-quotes-with-php
public cleanSmartQuotes ( string $str ) : string
$str string A string with potential smart quotes.
return string The cleaned-up string.

cycle() public method

This can be used for example, to alternate classes for table rows: "> item You can use named cycles to allow nesting in loops. Passing an array as the last parameter with a name key will create a named cycle. You can manually reset a cycle by calling resetCycle() and passing the name of the cycle: values as $value): ?> resetCycle('colors') ?>
public cycle ( $firstValue )

h() public method

h($this->templateVar) ?>

public h ( mixed $var ) : mixed
$var mixed The output to escape.
return mixed The escaped value.

highlight() public method

The Highlighter can be customized by passing $highlighter as a string containing $1 as a placeholder where the phrase is supposed to be inserted.
public highlight ( string $text, string $phrase, string $highlighter = null ) : string
$text string A text containing phrases to highlight.
$phrase string A phrase to highlight in $text.
$highlighter string A highlighting replacement.
return string The highlighted text.

makeBreakable() public method

Inserts HTML code to allow linebreaks in a string after slashes or underscores.
public makeBreakable ( string $str ) : string
$str string A string to mark up with linebreak markers.
return string The marked-up string.

pluralize() public method

Pluralizes the $singular word unless $count is one. If $plural form is not supplied, inflector will be used.
public pluralize ( integer $count, string $singular, string $plural = null )
$count integer Count determines singular or plural.
$singular string Singular form.
$plural string Plural form (optional).

resetCycle() public method

Pass in $name to reset a named cycle.
public resetCycle ( string $name = 'default' )
$name string Name of cycle to reset.

truncate() public method

$this->truncate('Once upon a time in a world far far away', 14); => Once upon a...
public truncate ( string $text, integer $length = 30, string $truncateString = '...' ) : string
$text string A text to truncate.
$length integer The maximum length of the text
$truncateString string Replacement string for the truncated text.
return string The truncated text.

truncateMiddle() public method

Namely, cut from the MIDDLE instead of from the end so that if we're doing this on (for instance) a bunch of binder names that start off with the same verbose description, and then are different only at the very end, they'll still be different from one another after truncating. $str = 'The quick brown fox jumps over the lazy dog tomorrow morning.'; $shortStr = $this->truncateMiddle($str, 40); $shortStr == 'The quick brown fox... tomorrow morning.'
public truncateMiddle ( string $str, integer $maxLength = 80, string $joiner = '...' ) : string
$str string A text to truncate.
$maxLength integer The maximum length of the text
$joiner string Replacement string for the truncated text.
return string The truncated text.

Property Details

$_cycles protected_oe property

protected array $_cycles
return array

$_inflector protected_oe property

protected Horde_Support_Inflector $_inflector
return Horde_Support_Inflector