steffen: server/kolab-horde-framework/kolab-horde-framework/Notification/Notification/Listener javascript.php, NONE, 1.1 mobile.php, NONE, 1.1 status.php, NONE, 1.1
cvs at intevation.de
cvs at intevation.de
Fri Oct 14 16:33:11 CEST 2005
Author: steffen
Update of /kolabrepository/server/kolab-horde-framework/kolab-horde-framework/Notification/Notification/Listener
In directory doto:/tmp/cvs-serv28903/kolab-horde-framework/kolab-horde-framework/Notification/Notification/Listener
Added Files:
javascript.php mobile.php status.php
Log Message:
Separated Horde Framework from kolab-resource-handlers
--- NEW FILE: javascript.php ---
<?php
require_once 'Horde/Notification/Listener.php';
/**
* The Notification_Listener_javascript:: class provides functionality for
* inserting javascript code from the message stack into the page.
*
* $Horde: framework/Notification/Notification/Listener/javascript.php,v 1.7 2004/04/07 14:43:11 chuck Exp $
*
* Copyright 2004 Jan Schneider <jan at horde.org>
*
* See the enclosed file COPYING for license information (LGPL). If you
* did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
*
* @author Jan Schneider <jan at horde.org>
* @version $Revision: 1.1 $
* @since Horde 3.0
* @package Horde_Notification
*/
class Notification_Listener_javascript extends Notification_Listener {
/**
* Constructor
*
* @access public
*/
function Notification_Listener_javascript()
{
$this->_handles = array('javascript' => '');
}
/**
* Return a unique identifier for this listener.
*
* @access public
*
* @return string Unique id.
*/
function getName()
{
return 'javascript';
}
/**
* Outputs the javascript code if there are any messages on the
* 'javascript' message stack and if the 'notify_javascript' option is set.
*
* @access public
*
* @param array &$messageStack The stack of messages.
* @param optional array $options An array of options.
* Options: 'noscript'
*/
function notify(&$messageStack, $options = array())
{
if (count($messageStack)) {
if (empty($options['noscript'])) {
echo '<script language="JavaScript" type="text/javascript">';
echo "\n<!--\n";
}
while ($message = array_shift($messageStack)) {
$this->getMessage($message);
}
if (empty($options['noscript'])) {
echo "//-->\n</script>\n";
}
}
}
/**
* Outputs one message.
*
* @access public
*
* @param array $message One message hash from the stack.
*/
function getMessage($message)
{
$event = $this->getEvent($message);
echo $event->getMessage() . "\n";
}
}
--- NEW FILE: mobile.php ---
<?php
require_once 'Horde/Notification/Listener.php';
/**
* The Notification_Listener_mobile:: class provides functionality for
* displaying messages from the message stack on mobile devices.
*
* $Horde: framework/Notification/Notification/Listener/mobile.php,v 1.8 2004/04/07 14:43:11 chuck Exp $
*
* Copyright 2003-2004 Chuck Hagenbuch <chuck at horde.org>
*
* See the enclosed file COPYING for license information (LGPL). If you
* did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
*
* @author Chuck Hagenbuch <chuck at horde.org>
* @version $Revision: 1.1 $
* @since Horde 3.0
* @package Horde_Notification
*/
class Notification_Listener_mobile extends Notification_Listener {
/**
* The Horde_Mobile:: object that status lines should be added to.
*
* @var object Horde_Mobile $_mobile
*/
var $_mobile = null;
/**
* Constructor
*
* @access public
*/
function Notification_Listener_mobile()
{
$this->_handles = array('horde.error' => _("ERR"),
'horde.success' => _("SUCCESS"),
'horde.warning' => _("WARN"),
'horde.message' => _("MSG"));
}
/**
* Associate a Horde_Mobile:: object with the listener.
*
* @param object Horde_Mobile The Horde_Mobile:: object to send
* status lines to.
*/
function setMobileObject(&$mobile)
{
$this->_mobile = &$mobile;
}
/**
* Return a unique identifier for this listener.
*
* @access public
*
* @return string Unique id.
*/
function getName()
{
return 'mobile';
}
/**
* Outputs the status line if there are any messages on the 'mobile'
* message stack.
*
* @access public
*
* @param array &$messageStack The stack of messages.
* @param optional array $options An array of options.
* Options: 'nospace'
*/
function notify(&$messageStack, $options = array())
{
if (count($messageStack)) {
while ($message = array_shift($messageStack)) {
$this->getMessage($message);
}
$t = &$this->_mobile->add(new Horde_Mobile_text("\n"));
$t->set('linebreaks', true);
}
}
/**
* Outputs one message.
*
* @access public
*
* @param array $message One message hash from the stack.
*/
function getMessage($message)
{
$event = $this->getEvent($message);
$this->_mobile->add(new Horde_Mobile_text(sprintf(_("%s: %s"), $this->_handles[$message['type']], $event->getMessage())));
}
}
--- NEW FILE: status.php ---
<?php
require_once 'Horde/Notification/Listener.php';
/**
* The Notification_Listener_status:: class provides functionality for
* displaying messages from the message stack as a status line.
*
* $Horde: framework/Notification/Notification/Listener/status.php,v 1.22 2004/04/07 14:43:11 chuck Exp $
*
* Copyright 2001-2004 Jan Schneider <jan at horde.org>
*
* See the enclosed file COPYING for license information (LGPL). If you
* did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
*
* @author Jan Schneider <jan at horde.org>
* @version $Revision: 1.1 $
* @since Horde 2.1
* @package Horde_Notification
*/
class Notification_Listener_status extends Notification_Listener {
/**
* Constructor
*
* @access public
*/
function Notification_Listener_status()
{
$this->_handles = array('horde.error' => array('alerts/error.gif', _("Error")),
'horde.success' => array('alerts/success.gif', _("Success")),
'horde.warning' => array('alerts/warning.gif', _("Warning")),
'horde.message' => array('alerts/message.gif', _("Message")));
}
/**
* Return a unique identifier for this listener.
*
* @access public
*
* @return string Unique id.
*/
function getName()
{
return 'status';
}
/**
* Outputs the status line if there are any messages on the 'status'
* message stack.
*
* @access public
*
* @param array &$messageStack The stack of messages.
* @param optional array $options An array of options.
* Options: 'nospace'
*/
function notify(&$messageStack, $options = array())
{
if (count($messageStack)) {
echo '<table width="100%" border="0" cellpadding="0" cellspacing="0"><tr><td class="item"><table border="0" cellspacing="1" cellpadding="2" width="100%">';
while ($message = array_shift($messageStack)) {
$this->getMessage($message);
}
echo "</table></td></tr></table>\n";
if (empty($options['nospace'])) {
echo "<br />\n";
}
}
}
/**
* Outputs one message.
*
* @access public
*
* @param array $message One message hash from the stack.
*/
function getMessage($message)
{
global $registry;
$event = $this->getEvent($message);
$text = $event->getMessage();
if (!in_array('content.raw', $this->getFlags($message))) {
$text = htmlspecialchars($text);
}
echo '<tr><td class="notice">' . Horde::img($this->_handles[$message['type']][0], $this->_handles[$message['type']][1], '', $registry->getParam('graphics', 'horde')) . ' <b>' . $text . '</b></td></tr>';
}
}
More information about the commits
mailing list