changed git call from https to git readonly
[atutor.git] / mods / phpdoc2 / PhpDocumentor / phpDocumentor / Publisher.inc
1 <?php\r
2 /**\r
3  * a class for handling the publishing of data\r
4  * \r
5  * phpDocumentor :: automatic documentation generator\r
6  * \r
7  * PHP versions 4 and 5\r
8  *\r
9  * Copyright (c) 2000-2007 Kellin, Joshua Eichorn\r
10  * \r
11  * LICENSE:\r
12  * \r
13  * This library is free software; you can redistribute it\r
14  * and/or modify it under the terms of the GNU Lesser General\r
15  * Public License as published by the Free Software Foundation;\r
16  * either version 2.1 of the License, or (at your option) any\r
17  * later version.\r
18  * \r
19  * This library is distributed in the hope that it will be useful,\r
20  * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
21  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r
22  * Lesser General Public License for more details.\r
23  * \r
24  * You should have received a copy of the GNU Lesser General Public\r
25  * License along with this library; if not, write to the Free Software\r
26  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\r
27  *\r
28  * @category  ToolsAndUtilities\r
29  * @package   phpDocumentor\r
30  * @author    Kellin <passionplay@hotmail.com>\r
31  * @author    Joshua Eichorn <jeichorn@phpdoc.org>\r
32  * @copyright 2000-2007 Kellin, Joshua Eichorn\r
33  * @license   http://www.opensource.org/licenses/lgpl-license.php LGPL\r
34  * @version   CVS: $Id: Publisher.inc,v 1.4 2007/10/11 03:30:34 ashnazg Exp $\r
35  * @link      http://www.phpdoc.org\r
36  * @link      http://pear.php.net/PhpDocumentor\r
37  * @since     0.1\r
38  * @todo      CS cleanup - change package to PhpDocumentor\r
39  */\r
40 /**\r
41  * a class for handling the publishing of data\r
42  *\r
43  * @category  ToolsAndUtilities\r
44  * @package   phpDocumentor\r
45  * @author    Kellin <passionplay@hotmail.com>\r
46  * @author    Joshua Eichorn <jeichorn@phpdoc.org>\r
47  * @copyright 2000-2007 Kellin, Joshua Eichorn\r
48  * @license   http://www.opensource.org/licenses/lgpl-license.php LGPL\r
49  * @version   Release: 1.4.1\r
50  * @link      http://www.phpdoc.org\r
51  * @link      http://pear.php.net/PhpDocumentor\r
52  * @todo      CS cleanup - change package to PhpDocumentor\r
53  */\r
54 class Publisher\r
55 {\r
56     /**#@+\r
57      * @var array\r
58      */\r
59     /**\r
60      * Array of references objects that have Subscribed to this publisher\r
61      */\r
62     var $subscriber    =    array();\r
63 \r
64     var $tokens    =    array();\r
65 \r
66     var $pushEvent    =    array();\r
67     var $popEvent    =    array();\r
68     /**#@-*/\r
69 \r
70 \r
71     /**\r
72      * Adds a subscriber to the {@link $subscriber} array().\r
73      * if $event is '*', the publisher will use $object as the default event handler\r
74      *\r
75      * @param integer $event   see {@link Parser.inc} PARSER_EVENT_* constants\r
76      * @param class   &$object any class that has a HandleEvent() method like \r
77      *                         {@link phpDocumentor_IntermediateParser::HandleEvent()}\r
78      *                         or {@link Classes::HandleEvent()}\r
79      *\r
80      * @return void\r
81      * @todo CS Cleanup - there's no way I can get the &$object desc under 85 chars\r
82      */\r
83     function subscribe($event, &$object)\r
84     {\r
85         $this->subscriber[$event] =& $object;\r
86     }\r
87 \r
88     /**\r
89      * Publish an event\r
90      *\r
91      * @param integer $event see {@link Parser.inc} PARSER_EVENT_* constants\r
92      * @param mixed   $data  anything the subscribed event handler is expecting\r
93      *\r
94      * @return void\r
95      */\r
96     function publishEvent($event,$data)\r
97     {\r
98         \r
99         // see if there is a specific event handler\r
100         if (!empty($this->subscriber[$event])) {\r
101             $this->subscriber[$event]->HandleEvent($event, $data);\r
102         } else if (isset($this->subscriber['*']) \r
103                    && is_object($this->subscriber['*'])) {\r
104             // check to see if a generic handler exists\r
105 \r
106             $this->subscriber['*']->HandleEvent($event, $data);\r
107         }\r
108     }    \r
109 }\r
110 ?>\r