Abstract Class JHtmlString

Description

HTML helper class for rendering manipulated strings.

  • abstract:
  • since: 1.6

Located in /libraries/cms/html/string.php (line 19)


	
			
Method Summary
 static string abridge (string $text, [integer $length = 50], [integer $intro = 30])
 static string truncate (string $text, [integer $length = 0], [boolean $noSplit = true], [boolean $allowHtml = true])
 static string truncateComplex (string $html, [integer $maxLength = 0], [boolean $noSplit = true])
Methods
static abridge (line 278)

Abridges text strings over the specified character limit. The behavior will insert an ellipsis into the text replacing a section of variable size to ensure the string does not exceed the defined maximum length. This method is UTF-8 safe.

For example, it transforms "Really long title" to "Really...title".

Note that this method does not scan for HTML tags so will potentially break them.

  • return: The abridged text.
  • since: 1.6
  • access: public
static string abridge (string $text, [integer $length = 50], [integer $intro = 30])
  • string $text: The text to abridge.
  • integer $length: The maximum length of the text (default is 50).
  • integer $intro: The maximum length of the intro text (default is 30).
static truncate (line 36)

Truncates text blocks over the specified character limit and closes all open HTML tags. The method will optionally not truncate an individual word, it will find the first space that is within the limit and truncate at that point. This method is UTF-8 safe.

  • return: The truncated text.
  • since: 1.6
  • access: public
static string truncate (string $text, [integer $length = 0], [boolean $noSplit = true], [boolean $allowHtml = true])
  • string $text: The text to truncate.
  • integer $length: The maximum length of the text.
  • boolean $noSplit: Don't split a word if that is where the cutoff occurs (default: true).
  • boolean $allowHtml: Allow HTML tags in the output, and close any open tags (default: true).
static truncateComplex (line 162)

Method to extend the truncate method to more complex situations

The goal is to get the proper length plain text string with as much of the html intact as possible with all tags properly closed.

  • return: The truncated string. If the string is truncated an ellipsis (...) will be appended.
  • since: 3.1
  • access: public
static string truncateComplex (string $html, [integer $maxLength = 0], [boolean $noSplit = true])
  • string $html: The content of the introtext to be truncated
  • integer $maxLength: The maximum number of characters to render
  • boolean $noSplit: Don't split a word if that is where the cutoff occurs (default: true).

Documentation generated on Tue, 19 Nov 2013 15:14:32 +0100 by phpDocumentor 1.4.3