home *** CD-ROM | disk | FTP | other *** search
/ Enter 2004 June / ENTER.ISO / files / xampp-win32-1.4.5-installer.exe / xampp / Publisher.inc < prev    next >
Encoding:
Text File  |  2004-03-24  |  3.2 KB  |  85 lines

  1. <?php
  2. //
  3. // +------------------------------------------------------------------------+
  4. // | phpDocumentor                                                          |
  5. // +------------------------------------------------------------------------+
  6. // | Publisher Copyright 2000-2003 Kellin                                   |
  7. // | Email passionplay@hotmail.com                                          |
  8. // | phpDocumentor Copyright (c) 2000-2003 Joshua Eichorn, Gregory Beaver   |
  9. // | Email         jeichorn@phpdoc.org, cellog@phpdoc.org                   |
  10. // | Web           http://www.phpdoc.org                                    |
  11. // | Mirror        http://phpdocu.sourceforge.net/                          |
  12. // | PEAR          http://pear.php.net/package-info.php?pacid=137           |
  13. // +------------------------------------------------------------------------+
  14. // | This source file is subject to version 3.00 of the PHP License,        |
  15. // | that is available at http://www.php.net/license/3_0.txt.               |
  16. // | If you did not receive a copy of the PHP license and are unable to     |
  17. // | obtain it through the world-wide-web, please send a note to            |
  18. // | license@php.net so we can mail you a copy immediately.                 |
  19. // +------------------------------------------------------------------------+
  20. //
  21.  
  22. /**
  23.  * a class for handling the publishing of data
  24.  *
  25.  * @author Kellin <passionplay@hotmail.com>
  26.  * @author Joshua Eichorn <jeichorn@phpdoc.org>
  27.  * @version    $Id: Publisher.inc,v 1.11.2.1 2003/06/03 05:44:52 CelloG Exp $
  28.  * @package     phpDocumentor
  29.  */
  30. /**
  31.  * a class for handling the publishing of data
  32.  *
  33.  * @author Kellin <passionplay@hotmail.com>
  34.  * @author Joshua Eichorn <jeichorn@phpdoc.org>
  35.  * @version    $Id: Publisher.inc,v 1.11.2.1 2003/06/03 05:44:52 CelloG Exp $
  36.  * @package     phpDocumentor
  37.  */
  38. class Publisher
  39. {
  40.     /**#@+
  41.      * @var array
  42.      */
  43.     /**
  44.      * Array of references objects that have Subscribed to this publisher
  45.      */
  46.     var $subscriber    =    array();
  47.  
  48.     var $tokens    =    array();
  49.  
  50.     var $pushEvent    =    array();
  51.     var $popEvent    =    array();
  52.     /**#@-*/
  53.  
  54.  
  55.     /**
  56.      * Adds a subscriber to the {@link $subscriber} array().
  57.      * if $event is '*', the publisher will use $object as the default event handler
  58.      * @param integer $event see {@link Parser.inc} PARSER_EVENT_* constants
  59.      * @param class $object any class that has a HandleEvent() method like {@link phpDocumentor_IntermediateParser::HandleEvent()} or {@link Classes::HandleEvent()}
  60.      */
  61.     function subscribe($event, &$object)
  62.     {
  63.         $this->subscriber[$event] =& $object;
  64.     }
  65.  
  66.     /**
  67.      * @param integer $event see {@link Parser.inc} PARSER_EVENT_* constants
  68.      * @param mixed $data anything the subscribed event handler is expecting
  69.      */
  70.     function publishEvent($event,$data)
  71.     {
  72.         
  73.         // see if there is a specific event handler
  74.         if (!empty($this->subscriber[$event]))
  75.         {
  76.             $this->subscriber[$event]->HandleEvent($event,$data);
  77.         } 
  78.          else if (isset($this->subscriber['*']) && is_object($this->subscriber['*'])) // check to see if a generic handler exists
  79.         {
  80.             $this->subscriber['*']->HandleEvent($event,$data);
  81.         }
  82.     }    
  83. }
  84. ?>
  85.