Folge dem Video um zu sehen, wie unsere Website als Web-App auf dem Startbildschirm installiert werden kann.
Anmerkung: Diese Funktion ist in einigen Browsern möglicherweise nicht verfügbar.
<?php
class CB_EventHandler {
private $eventStack;
private $processOutput = array();
private static $listenerCounter = 0;
private static $eventsThrown = 0;
public function __construct() {
$this->eventStack = array();
}
/**
* CB_EventHandler::addListener()
*
* @param $event
* @param $callbackInfo
* @return
**/
public function addListener(CB_EventListenerAPI $listener) {
$this->eventStack[$listener->getListenerEvent()][] = $listener;
$this->listenerCounter++;
}
/**
* CB_EventHandler::throwEvent()
*
* @param $event
* @param $eventInformation
* @return
**/
public function throwEvent(CB_Event $event) {
$eventID = $event->getEventID();
if(is_array($this->eventStack[$eventID])) {
foreach($this->eventStack[$eventID] as $listener) {
$output = $listener->processOnEvent($event);
if($output != false) {
$this->processOutput[] = $output;
}
}
}
$this->eventsThrown++;
}
public function getProcessOutput() {
return $this->processOutput;
}
}
/**
* CB_Event
*
* @package CB_Event
* @author FoG
* @copyright Copyright (c) 2004
* @version $Id: CB_Event.class.php,v 1.1 2005/06/11 14:10:53 jstoeber Exp $
* @access public
**/
class CB_Event {
private $eventID;
private $eventInformation;
/**
* CB_Event::__construct()
*
* @param $eventID
* @param $eventInformation
* @return
**/
public function __construct($eventID, $eventInformation) {
$this->eventID = stripslashes($eventID);
if(is_array($eventInformation)) {
$this->eventInformation = $eventInformation;
}
}
/**
* CB_Event::getEventID()
*
* @return
**/
public function getEventID() {
return $this->eventID;
}
/**
* CB_Event::getEventData()
*
* @return
**/
public function getEventData() {
return $this->eventInformation;
}
}
?>
<?php
interface CB_EventListenerAPI {
/**
* getListenerEvent()
* auf welchen Event soll gelauscht werden?
*
* @return string Event ID
**/
function getListenerEvent();
/**
* processOnEvent()
* Definiert, wie auf den Event reagiert werden soll
*
* @param $event Event Objekt mit Informationen über den Event
* @return $result
**/
function processOnEvent(CB_Event $event);
}
?>
class CB_EventListener_article_folderDelete implements CB_EventListenerAPI {
private $listenerID;
private $tpl;
public function __construct($tpl) {
$this->tpl = $tpl;
$this->listenerID = "folderDelete";
}
public function getListenerEvent() {
return $this->listenerID;
}
public function processOnEvent(CB_Event $event) {
$eventData = $event->getEventData();
if($eventData['id'] != "") {
$output = "Rubrik gelöscht";
return $output;
}
}
}
if($cbEventHandler instanceof CB_EventHandler) {
$cbEventHandler->addListener(new CB_EventListener_article_folderDelete($tpl));
}