$_view
$_view : \Horde_View
The parent view invoking the helper.
View helpers for text
All helpers hold a link back to the instance of the view. The undefined property handlers (get()/call() methods) are used to mix helpers together, effectively placing them on the same pane of glass (the view) and allowing any helper to call any other.
$_view : \Horde_View
The parent view invoking the helper.
__construct(\Horde_View $view)
Creates a helper for $view.
\Horde_View | $view | The view to help. |
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.
integer | $count | Count determines singular or plural. |
string | $singular | Singular form. |
string | $plural | Plural form (optional). |
cycle( $firstValue)
Creates a Cycle object whose __toString() method cycles through elements of an array every time it is called.
This can be used for example, to alternate classes for table rows:
<?php foreach($items as $item): ?>
<tr class="<?php echo $this->cycle("even", "odd") ?>">
<?php endforeach ?>
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:
<?php foreach($items as $item): ?>
<?php endforeach ?>
$firstValue |
highlight(string $text, string $phrase, string $highlighter = null) : string
Highlights a phrase where it is found in the text by surrounding it like <strong class="highlight">I'm highlighted</strong>.
The Highlighter can be customized by passing $highlighter as a string containing $1 as a placeholder where the phrase is supposed to be inserted.
string | $text | A text containing phrases to highlight. |
string | $phrase | A phrase to highlight in $text. |
string | $highlighter | A highlighting replacement. |
The highlighted text.
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.
$this->truncate('Once upon a time in a world far far away', 14);
// => Once upon a...
string | $text | A text to truncate. |
integer | $length | The maximum length of the text |
string | $truncateString | Replacement string for the truncated text. |
The truncated text.
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().
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.'
string | $str | A text to truncate. |
integer | $maxLength | The maximum length of the text |
string | $joiner | Replacement string for the truncated text. |
The truncated text.