mirror of https://github.com/movim/movim
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
69 lines
1.6 KiB
69 lines
1.6 KiB
<?php
|
|
|
|
/**
|
|
* @package Widgets
|
|
*
|
|
* @file Notifs.php
|
|
* This file is part of MOVIM.
|
|
*
|
|
* @brief The notification widget
|
|
*
|
|
* @author Timothée Jaussoin <edhelas@gmail.com>
|
|
*
|
|
* @version 1.0
|
|
* @date 16 juin 2011
|
|
*
|
|
* Copyright (C)2010 MOVIM project
|
|
*
|
|
* See COPYING for licensing information.
|
|
*/
|
|
|
|
class Notification extends WidgetCommon
|
|
{
|
|
function load()
|
|
{
|
|
$this->addcss('notification.css');
|
|
$this->addjs('notification.js');
|
|
$this->registerEvent('pubsuberror', 'onPubsubError');
|
|
$this->registerEvent('moxlerror', 'onMoxlError');
|
|
}
|
|
|
|
static function appendNotification($message, $type = 'info')
|
|
{
|
|
$id = md5($message.$type);
|
|
|
|
switch($type) {
|
|
case 'success':
|
|
$icon = 'fa-check-circle';
|
|
break;
|
|
case 'info':
|
|
$icon = 'fa-info-circle';
|
|
break;
|
|
case 'warning':
|
|
$icon = 'fa-warning';
|
|
break;
|
|
case 'error':
|
|
$icon = 'fa-times-circle';
|
|
break;
|
|
default:
|
|
$icon = 'fa-info-circle';
|
|
break;
|
|
}
|
|
|
|
$html = '
|
|
<div class="notif notificationAnim '.$type.'" id="'.$id.'">
|
|
<i class="fa '.$icon.'"></i> '.$message.'
|
|
</div>';
|
|
|
|
RPC::call('removeDiff', 'notification_widget', $html, $id);
|
|
RPC::commit();
|
|
}
|
|
|
|
function onPubsubError($error) {
|
|
Notification::appendNotification($error, 'error');
|
|
}
|
|
|
|
function onMoxlError($arr) {
|
|
Notification::appendNotification($arr[1], 'error');
|
|
}
|
|
}
|