CakePHP
  • Documentation
    • Book
    • API
    • Videos
    • Reporting Security Issues
    • Privacy Policy
    • Logos & Trademarks
  • Business Solutions
  • Swag
  • Road Trip
  • Team
  • Community
    • Community
    • Get Involved
    • Issues (GitHub)
    • Bakery
    • Featured Resources
    • Training
    • Meetups
    • My CakePHP
    • CakeFest
    • Newsletter
    • Linkedin
    • YouTube
    • Facebook
    • Twitter
    • Mastodon
    • Help & Support
    • Forum
    • Stack Overflow
    • Slack
    • Paid Support
CakePHP

C CakePHP 1.2 API

  • Overview
  • Tree
  • Deprecated
  • Version:
    • 1.2
      • 4.2
      • 4.1
      • 4.0
      • 3.9
      • 3.8
      • 3.7
      • 3.6
      • 3.5
      • 3.4
      • 3.3
      • 3.2
      • 3.1
      • 3.0
      • 2.10
      • 2.9
      • 2.8
      • 2.7
      • 2.6
      • 2.5
      • 2.4
      • 2.3
      • 2.2
      • 2.1
      • 2.0
      • 1.3
      • 1.2

Classes

  • AclBase
  • AclBehavior
  • AclComponent
  • AclNode
  • AclShell
  • Aco
  • AcoAction
  • AjaxHelper
  • ApcEngine
  • ApiShell
  • App
  • AppController
  • AppHelper
  • AppModel
  • Aro
  • AuthComponent
  • BakeShell
  • BehaviorCollection
  • Cache
  • CacheEngine
  • CacheHelper
  • CakeErrorController
  • CakeLog
  • CakeSchema
  • CakeSession
  • CakeSocket
  • ClassRegistry
  • Component
  • Configure
  • ConnectionManager
  • ConsoleShell
  • ContainableBehavior
  • Controller
  • ControllerTask
  • CookieComponent
  • DataSource
  • DbAcl
  • DbAclSchema
  • DbConfigTask
  • DboAdodb
  • DboDb2
  • DboFirebird
  • DboMssql
  • DboMysql
  • DboMysqlBase
  • DboMysqli
  • DboOdbc
  • DboOracle
  • DboPostgres
  • DboSource
  • DboSqlite
  • DboSybase
  • Debugger
  • EmailComponent
  • ErrorHandler
  • ExtractTask
  • File
  • FileEngine
  • Flay
  • Folder
  • FormHelper
  • Helper
  • HtmlHelper
  • HttpSocket
  • I18n
  • I18nModel
  • i18nSchema
  • I18nShell
  • Inflector
  • IniAcl
  • JavascriptHelper
  • JsHelper
  • JsHelperObject
  • L10n
  • MagicDb
  • MagicFileResource
  • MediaView
  • MemcacheEngine
  • Model
  • ModelBehavior
  • ModelTask
  • Multibyte
  • NumberHelper
  • Object
  • Overloadable
  • Overloadable2
  • PagesController
  • PaginatorHelper
  • Permission
  • PluginTask
  • ProjectTask
  • RequestHandlerComponent
  • Router
  • RssHelper
  • Sanitize
  • Scaffold
  • ScaffoldView
  • SchemaShell
  • Security
  • SecurityComponent
  • SessionComponent
  • SessionHelper
  • SessionsSchema
  • Set
  • Shell
  • String
  • TestSuiteShell
  • TestTask
  • TextHelper
  • ThemeView
  • TimeHelper
  • TranslateBehavior
  • TreeBehavior
  • Validation
  • View
  • ViewTask
  • XcacheEngine
  • Xml
  • XmlElement
  • XmlHelper
  • XmlManager
  • XmlNode
  • XmlTextNode

Functions

  • __enclose
  • make_clean_css
  • mb_encode_mimeheader
  • mb_stripos
  • mb_stristr
  • mb_strlen
  • mb_strpos
  • mb_strrchr
  • mb_strrichr
  • mb_strripos
  • mb_strrpos
  • mb_strstr
  • mb_strtolower
  • mb_strtoupper
  • mb_substr
  • mb_substr_count
  • write_css_cache

Class TextHelper

Text helper library.

Text manipulations: Highlight, excerpt, truncate, strip of links, convert email addresses to mailto: links...

AppHelper
Extended by TextHelper
Package: cake\cake\libs\view\helpers
Copyright: Copyright 2005-2012, Cake Software Foundation, Inc. (http://cakefoundation.org)
License: The MIT License
Location: view/helpers/text.php

Method Summary

  • autoLink() public
    Convert all links and email adresses to HTML links.
  • autoLinkEmails() public
    Adds email links (<a href="mailto:....) to a given text.
  • autoLinkUrls() public

    Adds links (<a href=....) to a given text, by finding text that begins with strings like http:// and ftp://.

  • excerpt() public
    Extracts an excerpt from the text surrounding the phrase with a number of characters on each side determined by radius.
  • flay() public
    Text-to-html parser, similar to Textile or RedCloth, only with a little different syntax.
  • highlight() public

    Highlights a given phrase in a text. You can specify any expression in highlighter that may include the \1 expression to include the $phrase found.

  • stripLinks() public
    Strips given text of all links (<a href=....)
  • toList() public
    Creates a comma separated list where the last two items are joined with 'and', forming natural English
  • trim() public
    Alias for truncate().
  • truncate() public
    Truncates text.

Method Detail

autoLink() public ¶

autoLink( string $text , array $htmlOptions = array() )

Convert all links and email adresses to HTML links.

Parameters
string $text
Text
array $htmlOptions optional array()
Array of HTML options.
Returns
string
The text with links

autoLinkEmails() public ¶

autoLinkEmails( string $text , array $htmlOptions = array() )

Adds email links (<a href="mailto:....) to a given text.

Parameters
string $text
Text
array $htmlOptions optional array()
Array of HTML options.
Returns
string
The text with links

autoLinkUrls() public ¶

autoLinkUrls( string $text , array $htmlOptions = array() )

Adds links (<a href=....) to a given text, by finding text that begins with strings like http:// and ftp://.

Parameters
string $text
Text to add links to
array $htmlOptions optional array()
Array of HTML options.
Returns
string
The text with links

excerpt() public ¶

excerpt( string $text , string $phrase , integer $radius = 100 , string $ending = "..." )

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

Parameters
string $text
String to search the phrase in
string $phrase
Phrase that will be searched for
integer $radius optional 100
The amount of characters that will be returned on each side of the founded phrase
string $ending optional "..."
Ending that will be appended
Returns
string
Modified string

flay() public ¶

flay( string $text , boolean $allowHtml = false )

Text-to-html parser, similar to Textile or RedCloth, only with a little different syntax.

Parameters
string $text
String to "flay"
boolean $allowHtml optional false
Set to true if if html is allowed
Returns
string
"Flayed" text
Codecoverageignorestart

highlight() public ¶

highlight( string $text , string $phrase , string $highlighter = '<span class="highlight">\1</span>' , boolean $considerHtml = false )

Highlights a given phrase in a text. You can specify any expression in highlighter that may include the \1 expression to include the $phrase found.

Parameters
string $text
Text to search the phrase in
string $phrase
The phrase that will be searched
string $highlighter optional '<span class="highlight">\1</span>'
The piece of html with that the phrase will be highlighted
boolean $considerHtml optional false
If true, will ignore any HTML tags, ensuring that only the correct text is highlighted
Returns
string
The highlighted text

stripLinks() public ¶

stripLinks( string $text )

Strips given text of all links (<a href=....)

Parameters
string $text
Text
Returns
string
The text without links

toList() public ¶

toList( array $list , $and = 'and' )

Creates a comma separated list where the last two items are joined with 'and', forming natural English

Parameters
array $list
The list to be joined
$and optional 'and'
Returns
string

trim() public ¶

trim( )

Alias for truncate().

See
TextHelper::truncate()

truncate() public ¶

truncate( string $text , integer $length = 100 , mixed $ending = '...' , boolean $exact = true , boolean $considerHtml = false )

Truncates text.

Cuts a string to the length of $length and replaces the last characters with the ending if the text is longer than length.

Parameters
string $text
String to truncate.
integer $length optional 100
Length of returned string, including ellipsis.
mixed $ending optional '...'
If string, will be used as Ending and appended to the trimmed string. Can also be an associative array that can contain the last three params of this method.
boolean $exact optional true
If false, $text will not be cut mid-word
boolean $considerHtml optional false
If true, HTML tags would be handled correctly
Returns
string
Trimmed string.
OpenHub
Rackspace
Rackspace
  • Business Solutions
  • Showcase
  • Documentation
  • Book
  • API
  • Videos
  • Reporting Security Issues
  • Privacy Policy
  • Logos & Trademarks
  • Community
  • Get Involved
  • Issues (GitHub)
  • Bakery
  • Featured Resources
  • Training
  • Meetups
  • My CakePHP
  • CakeFest
  • Newsletter
  • Linkedin
  • YouTube
  • Facebook
  • Twitter
  • Mastodon
  • Help & Support
  • Forum
  • Stack Overflow
  • Slack
  • Paid Support

Generated using CakePHP API Docs