PHP 클래스 Twitter_Autolink, twitter-text-php

Parses tweets and generates HTML anchor tags around URLs, usernames, username/list pairs and hashtags. Originally written by {@link http://github.com/mikenz Mike Cochrane}, this is based on code by {@link http://github.com/mzsanford Matt Sanford} and heavily modified by {@link http://github.com/ngnpope Nick Pope}.
저자: Mike Cochrane ([email protected])
저자: Nick Pope ([email protected])
상속: extends Twitter_Regex
파일 보기 프로젝트 열기: ngnpope/twitter-text-php 1 사용 예제들

보호된 프로퍼티들

프로퍼티 타입 설명
$class_cash string CSS class for auto-linked cashtag URLs.
$class_hash string CSS class for auto-linked hashtag URLs.
$class_list string CSS class for auto-linked list URLs.
$class_url string CSS class for auto-linked URLs.
$class_user string CSS class for auto-linked username URLs.
$external boolean Often this is used to be matched on in JavaScript for dynamically adding the 'target' attribute which is deprecated in HTML 4.01. In HTML 5 it has been undeprecated and thus the 'target' attribute can be used. If this is set to false then the 'target' attribute will be output.
$nofollow boolean Whether to include the value 'nofollow' in the 'rel' attribute.
$target string Support for the 'target' attribute was deprecated in HTML 4.01 but has since been reinstated in HTML 5. To output the 'target' attribute you must disable the adding of the string 'external' to the 'rel' attribute.
$url_base_cash string URL base for cashtag links (the hashtag without the $ will be appended).
$url_base_hash string URL base for hashtag links (the hashtag without the # will be appended).
$url_base_list string URL base for list links (the username/list without the @ will be appended).
$url_base_user string URL base for username links (the username without the @ will be appended).

공개 메소드들

메소드 설명
__construct ( string $tweet, boolean $escape = true, boolean $full_encode = false ) Reads in a tweet to be parsed and converted to contain links.
addLinks ( ) : string Adds links to all elements in the tweet.
addLinksToCashtags ( ) : string Adds links to cashtag elements in the tweet.
addLinksToHashtags ( ) : string Adds links to hashtag elements in the tweet.
addLinksToURLs ( ) : string Adds links to URL elements in the tweet.
addLinksToUsernamesAndLists ( ) : string Adds links to username/list elements in the tweet.
create ( string $tweet, boolean $full_encode = false ) : Twitter_Autolink Provides fluent method chaining.
getCashtagClass ( ) : string CSS class for auto-linked cashtag URLs.
getExternal ( ) : boolean Whether to include the value 'external' in the 'rel' attribute.
getHashtagClass ( ) : string CSS class for auto-linked hashtag URLs.
getListClass ( ) : string CSS class for auto-linked username/list URLs.
getNoFollow ( ) : boolean Whether to include the value 'nofollow' in the 'rel' attribute.
getTarget ( ) : string The scope to open the link in.
getURLClass ( ) : string CSS class for auto-linked URLs.
getUsernameClass ( ) : string CSS class for auto-linked username URLs.
setCashtagClass ( string $v ) : Twitter_Autolink CSS class for auto-linked cashtag URLs.
setExternal ( boolean $v ) : Twitter_Autolink Whether to include the value 'external' in the 'rel' attribute.
setHashtagClass ( string $v ) : Twitter_Autolink CSS class for auto-linked hashtag URLs.
setListClass ( string $v ) : Twitter_Autolink CSS class for auto-linked username/list URLs.
setNoFollow ( boolean $v ) : Twitter_Autolink Whether to include the value 'nofollow' in the 'rel' attribute.
setTarget ( string $v ) : Twitter_Autolink The scope to open the link in.
setURLClass ( string $v ) : Twitter_Autolink CSS class for auto-linked URLs.
setUsernameClass ( string $v ) : Twitter_Autolink CSS class for auto-linked username URLs.

보호된 메소드들

메소드 설명
_addLinksToCashtags ( array $matches ) : string Callback used by the method that adds links to cashtags.
_addLinksToHashtags ( array $matches ) : string Callback used by the method that adds links to hashtags.
_addLinksToURLs ( array $matches ) : string Callback used by the method that adds links to URLs.
_addLinksToUsernamesAndLists ( array $matches ) : string Callback used by the method that adds links to username/list pairs.
wrap ( string $url, string $class, string $element ) : string Wraps a tweet element in an HTML anchor tag using the provided URL.
wrapHash ( string $url, string $class, string $element ) : string Wraps a tweet element in an HTML anchor tag using the provided URL.

메소드 상세

__construct() 공개 메소드

As the intent is to produce links and output the modified tweet to the user, we take this opportunity to ensure that we escape user input.
또한 보기: htmlspecialchars()
public __construct ( string $tweet, boolean $escape = true, boolean $full_encode = false )
$tweet string The tweet to be converted.
$escape boolean Whether to escape the tweet (default: true).
$full_encode boolean Whether to encode all special characters.

_addLinksToCashtags() 보호된 메소드

Callback used by the method that adds links to cashtags.
또한 보기: addLinksToCashtags()
protected _addLinksToCashtags ( array $matches ) : string
$matches array The regular expression matches.
리턴 string The link-wrapped cashtag.

_addLinksToHashtags() 보호된 메소드

Callback used by the method that adds links to hashtags.
또한 보기: addLinksToHashtags()
protected _addLinksToHashtags ( array $matches ) : string
$matches array The regular expression matches.
리턴 string The link-wrapped hashtag.

_addLinksToURLs() 보호된 메소드

Callback used by the method that adds links to URLs.
또한 보기: addLinksToURLs()
protected _addLinksToURLs ( array $matches ) : string
$matches array The regular expression matches.
리턴 string The link-wrapped URL.

_addLinksToUsernamesAndLists() 보호된 메소드

Callback used by the method that adds links to username/list pairs.
또한 보기: addLinksToUsernamesAndLists()
protected _addLinksToUsernamesAndLists ( array $matches ) : string
$matches array The regular expression matches.
리턴 string The link-wrapped username/list pair.

addLinksToCashtags() 공개 메소드

Adds links to cashtag elements in the tweet.
public addLinksToCashtags ( ) : string
리턴 string The modified tweet.

addLinksToHashtags() 공개 메소드

Adds links to hashtag elements in the tweet.
public addLinksToHashtags ( ) : string
리턴 string The modified tweet.

addLinksToURLs() 공개 메소드

Adds links to URL elements in the tweet.
public addLinksToURLs ( ) : string
리턴 string The modified tweet.

addLinksToUsernamesAndLists() 공개 메소드

Adds links to username/list elements in the tweet.
public addLinksToUsernamesAndLists ( ) : string
리턴 string The modified tweet.

create() 공개 정적인 메소드

Provides fluent method chaining.
또한 보기: __construct()
public static create ( string $tweet, boolean $full_encode = false ) : Twitter_Autolink
$tweet string The tweet to be converted.
$full_encode boolean Whether to encode all special characters.
리턴 Twitter_Autolink

getCashtagClass() 공개 메소드

CSS class for auto-linked cashtag URLs.
public getCashtagClass ( ) : string
리턴 string CSS class for cashtag links.

getExternal() 공개 메소드

Often this is used to be matched on in JavaScript for dynamically adding the 'target' attribute which is deprecated in HTML 4.01. In HTML 5 it has been undeprecated and thus the 'target' attribute can be used. If this is set to false then the 'target' attribute will be output.
public getExternal ( ) : boolean
리턴 boolean Whether to add 'external' to the 'rel' attribute.

getHashtagClass() 공개 메소드

CSS class for auto-linked hashtag URLs.
public getHashtagClass ( ) : string
리턴 string CSS class for hashtag links.

getListClass() 공개 메소드

CSS class for auto-linked username/list URLs.
public getListClass ( ) : string
리턴 string CSS class for username/list links.

getNoFollow() 공개 메소드

Whether to include the value 'nofollow' in the 'rel' attribute.
public getNoFollow ( ) : boolean
리턴 boolean Whether to add 'nofollow' to the 'rel' attribute.

getTarget() 공개 메소드

Support for the 'target' attribute was deprecated in HTML 4.01 but has since been reinstated in HTML 5. To output the 'target' attribute you must disable the adding of the string 'external' to the 'rel' attribute.
public getTarget ( ) : string
리턴 string The value to add to the 'target' attribute.

getURLClass() 공개 메소드

CSS class for auto-linked URLs.
public getURLClass ( ) : string
리턴 string CSS class for URL links.

getUsernameClass() 공개 메소드

CSS class for auto-linked username URLs.
public getUsernameClass ( ) : string
리턴 string CSS class for username links.

setCashtagClass() 공개 메소드

CSS class for auto-linked cashtag URLs.
public setCashtagClass ( string $v ) : Twitter_Autolink
$v string CSS class for cashtag links.
리턴 Twitter_Autolink Fluid method chaining.

setExternal() 공개 메소드

Often this is used to be matched on in JavaScript for dynamically adding the 'target' attribute which is deprecated in HTML 4.01. In HTML 5 it has been undeprecated and thus the 'target' attribute can be used. If this is set to false then the 'target' attribute will be output.
public setExternal ( boolean $v ) : Twitter_Autolink
$v boolean The value to add to the 'target' attribute.
리턴 Twitter_Autolink Fluid method chaining.

setHashtagClass() 공개 메소드

CSS class for auto-linked hashtag URLs.
public setHashtagClass ( string $v ) : Twitter_Autolink
$v string CSS class for hashtag links.
리턴 Twitter_Autolink Fluid method chaining.

setListClass() 공개 메소드

CSS class for auto-linked username/list URLs.
public setListClass ( string $v ) : Twitter_Autolink
$v string CSS class for username/list links.
리턴 Twitter_Autolink Fluid method chaining.

setNoFollow() 공개 메소드

Whether to include the value 'nofollow' in the 'rel' attribute.
public setNoFollow ( boolean $v ) : Twitter_Autolink
$v boolean The value to add to the 'target' attribute.
리턴 Twitter_Autolink Fluid method chaining.

setTarget() 공개 메소드

Support for the 'target' attribute was deprecated in HTML 4.01 but has since been reinstated in HTML 5. To output the 'target' attribute you must disable the adding of the string 'external' to the 'rel' attribute.
public setTarget ( string $v ) : Twitter_Autolink
$v string The value to add to the 'target' attribute.
리턴 Twitter_Autolink Fluid method chaining.

setURLClass() 공개 메소드

CSS class for auto-linked URLs.
public setURLClass ( string $v ) : Twitter_Autolink
$v string CSS class for URL links.
리턴 Twitter_Autolink Fluid method chaining.

setUsernameClass() 공개 메소드

CSS class for auto-linked username URLs.
public setUsernameClass ( string $v ) : Twitter_Autolink
$v string CSS class for username links.
리턴 Twitter_Autolink Fluid method chaining.

wrap() 보호된 메소드

This is a helper function to perform the generation of the link.
protected wrap ( string $url, string $class, string $element ) : string
$url string The URL to use as the href.
$class string The CSS class(es) to apply (space separated).
$element string The tweet element to wrap.
리턴 string The tweet element with a link applied.

wrapHash() 보호된 메소드

This is a helper function to perform the generation of the hashtag link.
protected wrapHash ( string $url, string $class, string $element ) : string
$url string The URL to use as the href.
$class string The CSS class(es) to apply (space separated).
$element string The tweet element to wrap.
리턴 string The tweet element with a link applied.

프로퍼티 상세

$class_cash 보호되어 있는 프로퍼티

CSS class for auto-linked cashtag URLs.
protected string $class_cash
리턴 string

$class_hash 보호되어 있는 프로퍼티

CSS class for auto-linked hashtag URLs.
protected string $class_hash
리턴 string

$class_list 보호되어 있는 프로퍼티

CSS class for auto-linked list URLs.
protected string $class_list
리턴 string

$class_url 보호되어 있는 프로퍼티

CSS class for auto-linked URLs.
protected string $class_url
리턴 string

$class_user 보호되어 있는 프로퍼티

CSS class for auto-linked username URLs.
protected string $class_user
리턴 string

$external 보호되어 있는 프로퍼티

Often this is used to be matched on in JavaScript for dynamically adding the 'target' attribute which is deprecated in HTML 4.01. In HTML 5 it has been undeprecated and thus the 'target' attribute can be used. If this is set to false then the 'target' attribute will be output.
protected bool $external
리턴 boolean

$nofollow 보호되어 있는 프로퍼티

Whether to include the value 'nofollow' in the 'rel' attribute.
protected bool $nofollow
리턴 boolean

$target 보호되어 있는 프로퍼티

Support for the 'target' attribute was deprecated in HTML 4.01 but has since been reinstated in HTML 5. To output the 'target' attribute you must disable the adding of the string 'external' to the 'rel' attribute.
protected string $target
리턴 string

$url_base_cash 보호되어 있는 프로퍼티

URL base for cashtag links (the hashtag without the $ will be appended).
protected string $url_base_cash
리턴 string

$url_base_hash 보호되어 있는 프로퍼티

URL base for hashtag links (the hashtag without the # will be appended).
protected string $url_base_hash
리턴 string

$url_base_list 보호되어 있는 프로퍼티

URL base for list links (the username/list without the @ will be appended).
protected string $url_base_list
리턴 string

$url_base_user 보호되어 있는 프로퍼티

URL base for username links (the username without the @ will be appended).
protected string $url_base_user
리턴 string