1: <?php
2: /*
3: File: xajaxPlugin.inc.php
4:
5: Contains the xajaxPlugin class
6:
7: Title: xajaxPlugin class
8:
9: Please see <copyright.inc.php> for a detailed description, copyright
10: and license information.
11: */
12:
13: /*
14: @package xajax
15: @version $Id: xajaxPlugin.inc.php 362 2007-05-29 15:32:24Z calltoconstruct $
16: @copyright Copyright (c) 2005-2007 by Jared White & J. Max Wilson
17: @copyright Copyright (c) 2008-2010 by Joseph Woolley, Steffen Konerow, Jared White & J. Max Wilson
18: @license http://www.xajaxproject.org/bsd_license.txt BSD License
19: */
20:
21: /*
22: Class: xajaxPlugin
23:
24: The base class for all xajax plugins.
25: */
26: class xajaxPlugin
27: {
28: }
29:
30: /*
31: Class: xajaxRequestPlugin
32:
33: The base class for all xajax request plugins.
34:
35: Request plugins handle the registration, client script generation and processing of
36: xajax enabled requests. Each plugin should have a unique signature for both
37: the registration and processing of requests. During registration, the user will
38: specify a type which will allow the plugin to detect and handle it. During client
39: script generation, the plugin will generate a <xajax.request> stub with the
40: prescribed call options and request signature. During request processing, the
41: plugin will detect the signature generated previously and process the request
42: accordingly.
43: */
44: class xajaxRequestPlugin extends xajaxPlugin
45: {
46: /*
47: Function: configure
48:
49: Called by the <xajaxPluginManager> when a configuration setting is changing.
50: Plugins should store a local copy of the settings they wish to use during
51: registration, client script generation or request processing.
52: */
53: function configure($sName, $mValue)
54: {
55: }
56:
57: /*
58: Function: register
59:
60: Called by the <xajaxPluginManager> when a user script when a function, event
61: or callable object is to be registered. Additional plugins may support other
62: registration types.
63: */
64: function register($aArgs)
65: {
66: return false;
67: }
68:
69: /*
70: Function: generateClientScript
71:
72: Called by <xajaxPluginManager> when the page's HTML is being sent to the browser.
73: This allows each plugin to inject some script / style or other appropriate tags
74: into the HEAD of the document. Each block must be appropriately enclosed, meaning
75: javascript code must be enclosed in SCRIPT and /SCRIPT tags.
76: */
77: function generateClientScript()
78: {
79: }
80:
81: /*
82: Function: canProcessRequest
83:
84: Called by the <xajaxPluginManager> when a request has been received to determine
85: if the request is for a xajax enabled function or for the initial page load.
86: */
87: function canProcessRequest()
88: {
89: return false;
90: }
91:
92: /*
93: Function: processRequest
94:
95: Called by the <xajaxPluginManager> when a request is being processed. This
96: will only occur when <xajax> has determined that the current request is a valid
97: (registered) xajax enabled function via <xajax->canProcessRequest>.
98:
99: Returns:
100: false
101: */
102: function processRequest()
103: {
104: return false;
105: }
106: }
107:
108: /*
109: Class: xajaxResponsePlugin
110:
111: Base class for all xajax response plugins.
112:
113: A response plugin provides additional services not already provided by the
114: <xajaxResponse> class with regard to sending response commands to the
115: client. In addition, a response command may send javascript to the browser
116: at page load to aid in the processing of it's response commands.
117: */
118: class xajaxResponsePlugin extends xajaxPlugin
119: {
120: /*
121: Object: objResponse
122:
123: A reference to the current <xajaxResponse> object that is being used
124: to build the response that will be sent to the client browser.
125: */
126: var $objResponse;
127:
128: /*
129: Function: setResponse
130:
131: Called by the <xajaxResponse> object that is currently being used
132: to build the response that will be sent to the client browser.
133:
134: Parameters:
135:
136: objResponse - (object): A reference to the <xajaxResponse> object
137: */
138: function setResponse($objResponse)
139: {
140: $this->objResponse = $objResponse;
141: }
142:
143: /*
144: Function: addCommand
145:
146: Used internally to add a command to the response command list. This
147: will call <xajaxResponse->addPluginCommand> using the reference provided
148: in <xajaxResponsePlugin->setResponse>.
149: */
150: function addCommand($aAttributes, $sData)
151: {
152: $this->objResponse->addPluginCommand($this, $aAttributes, $sData);
153: }
154:
155: /*
156: Function: getName
157:
158: Called by the <xajaxPluginManager> when the user script requests a plugin.
159: This name must match the plugin name requested in the called to
160: <xajaxResponse->plugin>.
161: */
162: function getName()
163: {
164: //SkipDebug
165: $objLanguageManager = xajaxLanguageManager::getInstance();
166: trigger_error(
167: $objLanguageManager->getText('XJXPLG:GNERR:01')
168: , E_USER_ERROR
169: );
170: //EndSkipDebug
171: }
172:
173: /*
174: Function: process
175:
176: Called by <xajaxResponse> when a user script requests the service of a
177: response plugin. The parameters provided by the user will be used to
178: determine which response command and parameters will be sent to the
179: client upon completion of the xajax request process.
180: */
181: function process()
182: {
183: //SkipDebug
184: $objLanguageManager = xajaxLanguageManager::getInstance();
185: trigger_error(
186: $objLanguageManager->getText('XJXPLG:PERR:01')
187: , E_USER_ERROR
188: );
189: //EndSkipDebug
190: }
191: }
192: