Net_Growl
[ class tree: Net_Growl ] [ index: Net_Growl ] [ all elements ]

Class: Net_Growl

Source Location: /Net_Growl-2.7.0/Net/Growl.php

Class Overview


Sends notifications to Growl


Author(s):

Version:

  • Release: 2.7.0

Variables

Methods


Child classes:

Net_Growl_Udp
Growl implements UDP protocol
Net_Growl_GntpMock
Mock adapter intended for testing
Net_Growl_Gntp
Growl implements GNTP 1.0 protocol

Inherited Variables

Inherited Methods


Class Details

[line 74]
Sends notifications to Growl

This package makes it possible to easily send a notification from your PHP script to Growl.

Growl is a global notification system for Mac OS X. Any application can send a notification to Growl, which will display an attractive message on your screen. Growl currently works with a growing number of applications.

The class provides the following capabilities:

  • Register your PHP application in Growl.
  • Let Growl know what kind of notifications to expect.
  • Notify Growl.
  • Set a maximum number of notifications to be displayed (beware the loops !).



[ Top ]


Class Variables

$growlNotificationCallback = array()

[line 159]

Notification callback results
  • Since: 2.0.0b2
  • Access: protected

Type:   array


[ Top ]

$growlNotificationCount =  0

[line 138]

Current number of notification being displayed on user desktop
  • Access: protected

Type:   int


[ Top ]

$instance =  null

[line 167]

Notification unique instance

Type:   object


[ Top ]

$isRegistered =  false

[line 115]

Application is registered
  • Access: protected

Type:   bool


[ Top ]

$options = array(
        'host' => '127.0.0.1',
        'port' => self::UDP_PORT,
        'protocol' => 'udp',
        'timeout' => 30,
        'context' => array(),'passwordHashAlgorithm'=>'MD5','encryptionAlgorithm'=>'NONE','debug'=>false,'resourceDir'=>false,'defaultIcon'=>'growl.png')

[line 121]

Net_Growl connection options
  • Access: protected

Type:   array


[ Top ]



Method Detail

__construct (Constructor)   [line 269]

void __construct( mixed &$application, [array $notifications = array()], [string $password = ''], [array $options = array()])

Constructor

This method instantiate a new Net_Growl object and opens a socket connection to the specified Growl socket server. Currently, only UDP is supported by Growl. The constructor registers a shutdown function Net_Growl::_Net_Growl() that closes the socket if it is open.

Example 1.

  1.  require_once 'Net/Growl.php';
  2.  
  3.  $notifications = array('Errors''Messages');
  4.  $growl Net_Growl::singleton('My application'$notification);
  5.  $growl->notify'Messages',
  6.                  'My notification title',
  7.                  'My notification description');

  • Access: protected

Overridden in child classes as:

Net_Growl_Udp::__construct()
Class constructor
Net_Growl_GntpMock::__construct()
Class constructor
Net_Growl_Gntp::__construct()
Class constructor

Parameters:

mixed   &$application     Can be either a Net_Growl_Application object or the application name string
array   $notifications     (optional) List of notification types
string   $password     (optional) Password for Growl
array   $options     (optional) List of options : 'host', 'port', 'protocol', 'timeout' for Growl socket server. 'passwordHashAlgorithm', 'encryptionAlgorithm' to secure communications. 'debug' to know what data are sent and received.

[ Top ]

__destruct (Destructor)   [line 311]

void __destruct( )

Destructor
  • Since: 2.0.0b2
  • Access: public

[ Top ]

debug   [line 634]

void debug( string $message, [string $priority = 'debug'])

Logs GNTP IN/OUT messages
  • Access: protected

Parameters:

string   $message     String containing the message to log
string   $priority     (optional) String containing a priority name

[ Top ]

errorHandler   [line 659]

void errorHandler( int $errno, string $errstr, string $errfile, int $errline)

Converts standard error into exception
  • Since: 2.1.0
  • Throws: ErrorException when a standard error occured with severity level we are asking for (uses error_reporting)
  • Access: public

Parameters:

int   $errno     contains the level of the error raised
string   $errstr     contains the error message
string   $errfile     contains the filename that the error was raised in
int   $errline     contains the line number the error was raised at

[ Top ]

getApplication   [line 351]

object Application getApplication( )

Returns the registered application object

[ Top ]

getDefaultGrowlIcon   [line 605]

string getDefaultGrowlIcon( )

Returns Growl default icon logo binary data
  • Throws: Net_Growl_Exception if cannot get icon resource contents
  • Access: public

[ Top ]

getOptions   [line 324]

array getOptions( )

Gets options used with current Growl object
  • Since: 2.6.0
  • Access: public

[ Top ]

notify   [line 390]

Net_Growl_Response notify( string $name, string $title, [string $description = ''], [string $options = array()])

Sends a notification to Growl

Growl notifications have a name, a title, a description and a few options, depending on the kind of display plugin you use. The bubble plugin is recommended, until there is a plugin more appropriate for these kind of notifications.

The current options supported by most Growl plugins are:

 array('priority' => 0, 'sticky' => false)
  • sticky: whether the bubble stays on screen until the user clicks on it.
  • priority: a number from -2 (low) to 2 (high), default is 0 (normal).

  • Return: | FALSE
  • Throws: Net_Growl_Exception if NOTIFY failed
  • Access: public

Parameters:

string   $name     Notification name
string   $title     Notification title
string   $description     (optional) Notification description
string   $options     (optional) few Notification options

[ Top ]

publish   [line 416]

Net_Growl_Response publish( string $name, string $title, [string $description = ''], [string $options = array()])

Alias of notify() method.
  • Return: | FALSE
  • Throws: Net_Growl_Exception if NOTIFY failed
  • Access: public

Parameters:

string   $name     Notification name
string   $title     Notification title
string   $description     (optional) Notification description
string   $options     (optional) few Notification options

[ Top ]

register   [line 362]

Net_Growl_Response register( )

Sends a application register to Growl
  • Throws: Net_Growl_Exception if REGISTER failed
  • Access: public

[ Top ]

reset   [line 232]

void reset( )

Resettable Singleton Solution

[ Top ]

sendRequest   [line 431]

Net_Growl_Response sendRequest( string $method, mixed $data, [bool $callback = false])

Send request to remote server
  • Return: | TRUE
  • Throws: Net_Growl_Exception if remote server communication failure
  • Access: protected

Overridden in child classes as:

Net_Growl_GntpMock::sendRequest()
Returns the next response from the queue built by addResponse()

Parameters:

string   $method     Either REGISTER, NOTIFY
mixed   $data     Data block to send
bool   $callback     (optional) Socket callback request

[ Top ]

setNotificationLimit   [line 340]

void setNotificationLimit( int $max)

Limit the number of notifications

This method limits the number of notifications to be displayed on the Growl user desktop. By default, there is no limit. It is used mostly to prevent problem with notifications within loops.

  • Access: public

Parameters:

int   $max     Maximum number of notifications

[ Top ]

singleton   [line 187]

object Net_Growl singleton( mixed &$application, array $notifications, [string $password = ''], [array $options = array()])

Singleton

Makes sure there is only one Growl connection open.

  • Throws: Net_Growl_Exception if class handler does not exists
  • Access: public

Parameters:

mixed   &$application     Can be either a Net_Growl_Application object or the application name string
array   $notifications     List of notification types
string   $password     (optional) Password for Growl
array   $options     (optional) List of options : 'host', 'port', 'protocol', 'timeout' for Growl socket server. 'passwordHashAlgorithm', 'encryptionAlgorithm' to secure communications. 'debug' to know what data are sent and received.

[ Top ]

strByteLen   [line 723]

The strByteLen( string $string)

Get string byte length
  • Return: byte length of the $string.
  • Access: protected

Parameters:

string   $string     The string being measured for byte length.

[ Top ]

utf8Encode   [line 707]

Returns utf8Encode( string $data)

Encodes a detect_order string to UTF-8

Parameters:

string   $data     an intended string.

[ Top ]


Documentation generated on Tue, 29 Jan 2013 18:30:05 +0000 by phpDocumentor 1.4.3. PEAR Logo Copyright © PHP Group 2004.