PHP Class Phergie_Plugin_Url, phergie

Has an utility method accessible via $this->getPlugin('Url')->getTitle('http://foo..').
Author: Phergie Development Team ([email protected])
Inheritance: extends Phergie_Plugin_Abstract
Afficher le fichier Open project: phergie/phergie

Protected Properties

Свойство Type Description
$cache Phergie_Plugin_Cache Cache object to store cached URLs to prevent spamming, especially with more than one bot on the same channel.
$errorMessage
$errorStatus boolean Flag that is set to true by the custom error handler if an HTTP error code has been received
$expire integer Setting it to 0 or below disables the cache expiration
$limit integer Setting it to 0 or below disables the cache limit
$renderers Array of renderers
$shortener Shortener object
$sslFallback boolean Flag that determines if the plugin will fall back to using an HTTP stream when a URL using SSL is detected and OpenSSL support isn't available in the PHP installation in use

Méthodes publiques

Méthode Description
findUrls ( string $message ) : array Detect URLs in a given string.
getTitle ( string $url ) : string Returns the title of the given page
onAction ( ) : void Checks an incoming message for the presence of a URL and, if one is found, responds with its title if it is an HTML document and the shortened equivalent of its original URL if it meets length requirements.
onLoad ( ) : void Checks for dependencies.
onPrivmsg ( ) : void Checks an incoming message for the presence of a URL and, if one is found, responds with its title if it is an HTML document and the shortened equivalent of its original URL if it meets length requirements.
preDispatch ( ) : void Processes events before they are dispatched and tries to shorten any urls in the text
registerRenderer ( object $obj ) : void Add a renderer to the stack

Méthodes protégées

Méthode Description
checkUrlCache ( string $url, string $shortenedUrl ) : boolean Checks a given URL (+shortened) against the cache to verify if they were previously posted on the channel.
checkValidIP ( string $ip ) : boolean Checks the given string to see if its a valid IP4 address
debug ( string $msg ) : void Output a debug message
decode ( string $str, integer $trim = null ) : string Transliterates a UTF-8 string into corresponding ASCII characters and truncates and appends an ellipsis to the string if it exceeds a given length.
getUrlChecksum ( string $url ) : string Takes a url, parses and cleans the URL without of all the junk and then return the hex checksum of the url.
glueUrl ( string $uri, string $base = false ) : string Parses a given URI and then glues it back together in the proper format.
handleMsg ( ) : void Handles message events and responds with url titles.
parseUrl ( string $url ) : array Parses a given URI and procceses the output to remove redundant or missing values.
updateUrlCache ( string $url, string $shortenedUrl ) : boolean Updates the cache and adds the given URL (+shortened) to the cache. It also handles cleaning the cache of old entries as well.

Method Details

checkUrlCache() protected méthode

Checks a given URL (+shortened) against the cache to verify if they were previously posted on the channel.
protected checkUrlCache ( string $url, string $shortenedUrl ) : boolean
$url string The URL to check against
$shortenedUrl string The shortened URL to check against
Résultat boolean

checkValidIP() protected méthode

Checks the given string to see if its a valid IP4 address
protected checkValidIP ( string $ip ) : boolean
$ip string the ip to validate
Résultat boolean

debug() protected méthode

Output a debug message
protected debug ( string $msg ) : void
$msg string the message to output
Résultat void

decode() protected méthode

Transliterates a UTF-8 string into corresponding ASCII characters and truncates and appends an ellipsis to the string if it exceeds a given length.
protected decode ( string $str, integer $trim = null ) : string
$str string String to decode
$trim integer Maximum string length, optional
Résultat string

findUrls() public méthode

Detect URLs in a given string.
public findUrls ( string $message ) : array
$message string the string to detect urls in
Résultat array the array of urls found

getTitle() public méthode

Returns the title of the given page
public getTitle ( string $url ) : string
$url string url to the page
Résultat string title

getUrlChecksum() protected méthode

Takes a url, parses and cleans the URL without of all the junk and then return the hex checksum of the url.
protected getUrlChecksum ( string $url ) : string
$url string url to checksum
Résultat string the hex checksum of the cleaned url

glueUrl() protected méthode

If base is set, then it chops off the scheme, user and pass and fragment information to return a more unique base URI.
protected glueUrl ( string $uri, string $base = false ) : string
$uri string uri to rebuild
$base string set to true to only return the base components
Résultat string the rebuilt uri

handleMsg() protected méthode

Handles message events and responds with url titles.
protected handleMsg ( ) : void
Résultat void

onAction() public méthode

Checks an incoming message for the presence of a URL and, if one is found, responds with its title if it is an HTML document and the shortened equivalent of its original URL if it meets length requirements.
public onAction ( ) : void
Résultat void

onLoad() public méthode

Checks for dependencies.
public onLoad ( ) : void
Résultat void

onPrivmsg() public méthode

Checks an incoming message for the presence of a URL and, if one is found, responds with its title if it is an HTML document and the shortened equivalent of its original URL if it meets length requirements.
public onPrivmsg ( ) : void
Résultat void

parseUrl() protected méthode

Parses a given URI and procceses the output to remove redundant or missing values.
protected parseUrl ( string $url ) : array
$url string the url to parse
Résultat array the url components

preDispatch() public méthode

Processes events before they are dispatched and tries to shorten any urls in the text
public preDispatch ( ) : void
Résultat void

registerRenderer() public méthode

Add a renderer to the stack
public registerRenderer ( object $obj ) : void
$obj object the renderer to add
Résultat void

updateUrlCache() protected méthode

Updates the cache and adds the given URL (+shortened) to the cache. It also handles cleaning the cache of old entries as well.
protected updateUrlCache ( string $url, string $shortenedUrl ) : boolean
$url string The URL to add to the cache
$shortenedUrl string The shortened to add to the cache
Résultat boolean

Property Details

$cache protected_oe property

Cache object to store cached URLs to prevent spamming, especially with more than one bot on the same channel.
protected Phergie_Plugin_Cache $cache
Résultat Phergie_Plugin_Cache

$errorMessage protected_oe property

protected $errorMessage

$errorStatus protected_oe property

Flag that is set to true by the custom error handler if an HTTP error code has been received
protected bool $errorStatus
Résultat boolean

$expire protected_oe property

Setting it to 0 or below disables the cache expiration
protected int $expire
Résultat integer

$limit protected_oe property

Setting it to 0 or below disables the cache limit
protected int $limit
Résultat integer

$renderers protected_oe property

Array of renderers
protected $renderers

$shortener protected_oe property

Shortener object
protected $shortener

$sslFallback protected_oe property

Flag that determines if the plugin will fall back to using an HTTP stream when a URL using SSL is detected and OpenSSL support isn't available in the PHP installation in use
protected bool $sslFallback
Résultat boolean