1
- <?php
2
- /**
3
- * This file is the ajax call processor.
4
- * It handles all the ajax calls. The specific processing done in the ajax call is
5
- * done in the tx_metafeedit_lib class.
6
- *
7
- * @author Christophe BALISKY <cbalisky@metaphore.fr>
8
- * @package TYPO3
9
- * @subpackage tx_metafeedit
10
- * @todo Mettre typoscript pour url pour fonctions d'impression
11
- * @todo Vérification cohérence des données
12
- **/
13
-
14
- /***************************************************************
15
- * Copyright notice
16
- *
17
- * (c) 2007 Christophe BALISKY (cbalisky@metaphore.fr)
18
- * All rights reserved
19
- *
20
- * This script is part of the TYPO3 project. The TYPO3 project is
21
- * free software; you can redistribute it and/or modify
22
- * it under the terms of the GNU General Public License as published by
23
- * the Free Software Foundation; either version 2 of the License, or
24
- * (at your option) any later version.
25
- * The GNU General Public License can be found at
26
- * http://www.gnu.org/copyleft/gpl.html.
27
- *
28
- * This script is distributed in the hope that it will be useful,
29
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
30
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
31
- * GNU General Public License for more details.
32
- *
33
- * This copyright notice MUST APPEAR in all copies of the script!
34
- *
35
- ***************************************************************/
36
- require_once (t3lib_extMgm::extPath ('meta_feedit ' ).'class.tx_metafeedit_ajaxlib.php ' );
37
- require_once (t3lib_extMgm::extPath ('meta_feedit ' ).'class.tx_metafeedit_widgets.php ' );
38
-
39
-
40
- /** Ajax call processor class.
41
- * It handles all the ajax calls. The specific processing done in the ajax call is
42
- * done in the tx_metafeedit_lib class.
43
- * @package TYPO3
44
- * @subpackage tx_metafeedit
45
- */
46
-
47
- class tx_metafeedit_ajax {
48
- // Private fields
49
- /**
50
- * @var string Prefix Id of the package
51
- **/
52
- var $ prefixId = 'tx_metafeedit ' ; // Same as class name
53
- /**
54
- * @var string Relative path to the class definition file */
55
- var $ scriptRelPath = 'class.tx_metafeedit_ajax.php ' ; // Path to this script relative to the extension dir.
56
- /**
57
- * @var string Extension Key */
58
- var $ extKey = 'meta_feedit ' ; // The extension key.
59
- /**
60
- * @var object Typo3 cObj Object */
61
- var $ cObj ;
62
- /**
63
- * @var conf Typo3 TS configuration array */
64
- var $ conf ;
65
- /**
66
- * @var boolean Xajax ??? */
67
- var $ xajax ;
68
- /**
69
- * @var string Mode the extension is in (Qui, Quoi , Qui Paie Quoi, Paiement ..) */
70
- var $ mode ;
71
- /**
72
- * @var object caller object.. */
73
- var $ caller ;
74
- /**
75
- * @var object feedit Functions Library called through Ajax */
76
- var $ metafeeditlib ;
77
-
78
- /** Basic Iniatialisation method
79
- * @param object caller object
80
- * @param array plugin TS configuration array
81
- * @return void
82
- */
83
-
84
- function init (&$ caller ,&$ conf ) {
85
- $ this ->cObj = &$ GLOBALS ['TSFE ' ]->cObj ;
86
- //echo "init";
87
- //print_r($conf);
88
- $ this ->conf =&$ conf ;
89
- $ this ->caller =$ caller ;
90
- $ this ->makeXajaxInstance ();
91
- }
92
-
93
- /** Instantiate the xajax object and configure it
94
- * @return void
95
- */
96
-
97
- function makeXajaxInstance () {
98
- require_once (t3lib_extMgm::extPath ('xajax ' ) . 'class.tx_xajax.php ' );
99
- // Make the instance
100
- $ this ->xajax = t3lib_div::makeInstance ('tx_xajax ' );
101
- $ this ->xajax ->setRequestURI ("?eID=tx_metafeedit_pi2 " );
102
- $ this ->xajax ->decodeUTF8InputOn ();
103
- $ this ->xajax ->setCharEncoding ('utf-8 ' );
104
- //$this->xajax->debugOn ();
105
-
106
- // To prevent conflicts, prepend the extension prefix
107
- $ this ->xajax ->setWrapperPrefix ($ this ->prefixId );
108
-
109
- // Do you want messages in the status bar?
110
- //$this->xajax->statusMessagesOn();
111
-
112
- // Register the names of the PHP functions you want to be able to call through xajax
113
- $ this ->xajax ->registerFunction (array ('processFormData ' , &$ this , 'processFormData ' ));
114
- $ this ->xajax ->registerFunction (array ('processErrors ' , &$ this , 'processErrors ' ));
115
-
116
- // If this is an xajax request, call our registered function, send output and exit
117
- $ this ->xajax ->processRequests ();
118
-
119
- // Else create javascript and add it to the header output
120
- if (!t3lib_div::_GP ('ajx ' )) $ GLOBALS ['TSFE ' ]->additionalHeaderData [$ this ->conf ['prefixId ' ]] = $ this ->xajax ->getJavascript (t3lib_extMgm::siteRelPath ('xajax ' ));
121
- }
122
-
123
-
124
- //****************************
125
- // REGISTERED FUNCTIONS
126
- //***************************
127
- /** Error processing method
128
- * @param array data array given by calling object
129
- * @return void
130
- */
131
- function processErrors ($ data ) {
132
- print_r ($ data );
133
- }
134
-
135
- /** Ajax call processing method
136
- * @param array data array given by calling object
137
- * @return void
138
- */
139
- function processFormData ($ data ) {
140
- $ content ='' ;
141
- $ metafeeditlib = t3lib_div::makeInstance ('tx_metafeedit_ajaxlib ' );
142
- $ this ->metafeeditlib =&$ metafeeditlib ;
143
- $ objResponse = new tx_xajax_response ();
144
- $ search =$ data [$ this ->prefixId ]['code ' ];
145
- $ mode =$ data [$ this ->prefixId ]['mode ' ];
146
- $ val =$ data [$ this ->prefixId ]['val ' ];
147
- $ cmd =$ data [$ this ->prefixId ]['cmd ' ];
148
-
149
- $ code =$ data [$ this ->prefixId ]['code ' ];
150
-
151
- switch ($ cmd ) {
152
- case "combolist " ;
153
- $ ajaxWidgets = t3lib_div::makeInstance ('tx_metafeedit_widgets ' );
154
- $ ajaxWidgets ->prefixId =$ this ->prefixId ;
155
- $ ajaxWidgets ->handleComboList ($ data ,$ objResponse ,$ metafeeditlib );
156
- break ;
157
- default :
158
- $ objResponse ->addAlert ('Commande : ' .$ cmd .' inconnue ! ' );
159
-
160
- }
161
- // Pour debugger
162
- $ debug =$ GLOBALS ["TSFE " ]->fe_user ->getKey ('ses ' ,'debugflag ' );
163
- //$debug=true;
164
- $ l =strlen (serialize ($ GLOBALS ["TSFE " ]->fe_user ->sesData ));
165
- $ GLOBALS ["TSFE " ]->fe_user ->storeSessionData ();
166
- if ($ debug ) {
167
- $ content ="<hr>len: $ l <br> " ;
168
- $ content .="debug<hr> " .$ GLOBALS ["TSFE " ]->fe_user ->getKey ('ses ' ,'dbg ' ).'<br> ' ;
169
-
170
- // TODO vérifier cohérence des données....
171
-
172
- $ objResponse ->addAssign ('debug ' , 'innerHTML ' , $ content );
173
- }
174
- return $ objResponse ->getXML ();
175
- }
176
- }
177
-
178
- if (defined ('TYPO3_MODE ' ) && $ TYPO3_CONF_VARS [TYPO3_MODE ]['XCLASS ' ]['ext/meta_feedit/class.tx_metafeedit_ajax.php ' ]) {
179
- include_once ($ TYPO3_CONF_VARS [TYPO3_MODE ]['XCLASS ' ]['ext/meta_feedit/class.tx_metafeedit_ajax.php ' ]);
180
- }
181
-
1
+ <?php
2
+ /**
3
+ * This file is the ajax call processor.
4
+ * It handles all the ajax calls. The specific processing done in the ajax call is
5
+ * done in the tx_metafeedit_lib class.
6
+ *
7
+ * @author Christophe BALISKY <cbalisky@metaphore.fr>
8
+ * @package TYPO3
9
+ * @subpackage tx_metafeedit
10
+ * @todo Mettre typoscript pour url pour fonctions d'impression
11
+ * @todo Vérification cohérence des données
12
+ **/
13
+
14
+ /***************************************************************
15
+ * Copyright notice
16
+ *
17
+ * (c) 2007 Christophe BALISKY (cbalisky@metaphore.fr)
18
+ * All rights reserved
19
+ *
20
+ * This script is part of the TYPO3 project. The TYPO3 project is
21
+ * free software; you can redistribute it and/or modify
22
+ * it under the terms of the GNU General Public License as published by
23
+ * the Free Software Foundation; either version 2 of the License, or
24
+ * (at your option) any later version.
25
+ * The GNU General Public License can be found at
26
+ * http://www.gnu.org/copyleft/gpl.html.
27
+ *
28
+ * This script is distributed in the hope that it will be useful,
29
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
30
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
31
+ * GNU General Public License for more details.
32
+ *
33
+ * This copyright notice MUST APPEAR in all copies of the script!
34
+ *
35
+ ***************************************************************/
36
+ require_once (t3lib_extMgm::extPath ('meta_feedit ' ).'class.tx_metafeedit_ajaxlib.php ' );
37
+ require_once (t3lib_extMgm::extPath ('meta_feedit ' ).'class.tx_metafeedit_widgets.php ' );
38
+
39
+
40
+ /** Ajax call processor class.
41
+ * It handles all the ajax calls. The specific processing done in the ajax call is
42
+ * done in the tx_metafeedit_lib class.
43
+ * @package TYPO3
44
+ * @subpackage tx_metafeedit
45
+ */
46
+
47
+ class tx_metafeedit_ajax {
48
+ // Private fields
49
+ /**
50
+ * @var string Prefix Id of the package
51
+ **/
52
+ var $ prefixId = 'tx_metafeedit ' ; // Same as class name
53
+ /**
54
+ * @var string Relative path to the class definition file */
55
+ var $ scriptRelPath = 'class.tx_metafeedit_ajax.php ' ; // Path to this script relative to the extension dir.
56
+ /**
57
+ * @var string Extension Key */
58
+ var $ extKey = 'meta_feedit ' ; // The extension key.
59
+ /**
60
+ * @var object Typo3 cObj Object */
61
+ var $ cObj ;
62
+ /**
63
+ * @var conf Typo3 TS configuration array */
64
+ var $ conf ;
65
+ /**
66
+ * @var boolean Xajax ??? */
67
+ var $ xajax ;
68
+ /**
69
+ * @var string Mode the extension is in (Qui, Quoi , Qui Paie Quoi, Paiement ..) */
70
+ var $ mode ;
71
+ /**
72
+ * @var object caller object.. */
73
+ var $ caller ;
74
+ /**
75
+ * @var object feedit Functions Library called through Ajax */
76
+ var $ metafeeditlib ;
77
+
78
+ /** Basic Iniatialisation method
79
+ * @param object caller object
80
+ * @param array plugin TS configuration array
81
+ * @return void
82
+ */
83
+
84
+ function init (&$ caller ,&$ conf ) {
85
+ $ this ->cObj = &$ GLOBALS ['TSFE ' ]->cObj ;
86
+ $ this ->conf =&$ conf ;
87
+ $ this ->caller =$ caller ;
88
+ $ this ->makeXajaxInstance ();
89
+ }
90
+
91
+ /** Instantiate the xajax object and configure it
92
+ * @return void
93
+ */
94
+
95
+ function makeXajaxInstance () {
96
+ require_once (t3lib_extMgm::extPath ('xajax ' ) . 'class.tx_xajax.php ' );
97
+ // Make the instance
98
+ $ this ->xajax = t3lib_div::makeInstance ('tx_xajax ' );
99
+ $ this ->xajax ->setRequestURI ("?eID=tx_metafeedit_pi2 " );
100
+ $ this ->xajax ->decodeUTF8InputOn ();
101
+ $ this ->xajax ->setCharEncoding ('utf-8 ' );
102
+ //$this->xajax->debugOn ();
103
+
104
+ // To prevent conflicts, prepend the extension prefix
105
+ $ this ->xajax ->setWrapperPrefix ($ this ->prefixId );
106
+
107
+ // Do you want messages in the status bar?
108
+ //$this->xajax->statusMessagesOn();
109
+
110
+ // Register the names of the PHP functions you want to be able to call through xajax
111
+ $ this ->xajax ->registerFunction (array ('processFormData ' , &$ this , 'processFormData ' ));
112
+ $ this ->xajax ->registerFunction (array ('processErrors ' , &$ this , 'processErrors ' ));
113
+
114
+ // If this is an xajax request, call our registered function, send output and exit
115
+ $ this ->xajax ->processRequests ();
116
+
117
+ // Else create javascript and add it to the header output
118
+ if (!t3lib_div::_GP ('ajx ' )) $ GLOBALS ['TSFE ' ]->additionalHeaderData [$ this ->conf ['prefixId ' ]] = $ this ->xajax ->getJavascript ('/ ' .t3lib_extMgm::siteRelPath ('xajax ' ));
119
+ }
120
+
121
+
122
+ //****************************
123
+ // REGISTERED FUNCTIONS
124
+ //***************************
125
+ /** Error processing method
126
+ * @param array data array given by calling object
127
+ * @return void
128
+ */
129
+ function processErrors ($ data ) {
130
+ print_r ($ data );
131
+ }
132
+
133
+ /** Ajax call processing method
134
+ * @param array data array given by calling object
135
+ * @return void
136
+ */
137
+ function processFormData ($ data ) {
138
+ $ content ='' ;
139
+ $ metafeeditlib = t3lib_div::makeInstance ('tx_metafeedit_ajaxlib ' );
140
+ $ this ->metafeeditlib =&$ metafeeditlib ;
141
+ $ objResponse = new tx_xajax_response ();
142
+ $ search =$ data [$ this ->prefixId ]['code ' ];
143
+ $ mode =$ data [$ this ->prefixId ]['mode ' ];
144
+ $ val =$ data [$ this ->prefixId ]['val ' ];
145
+ $ cmd =$ data [$ this ->prefixId ]['cmd ' ];
146
+
147
+ $ code =$ data [$ this ->prefixId ]['code ' ];
148
+
149
+ switch ($ cmd ) {
150
+ case "combolist " ;
151
+ $ ajaxWidgets = t3lib_div::makeInstance ('tx_metafeedit_widgets ' );
152
+ $ ajaxWidgets ->prefixId =$ this ->prefixId ;
153
+ $ ajaxWidgets ->handleComboList ($ data ,$ objResponse ,$ metafeeditlib );
154
+ break ;
155
+ default :
156
+ $ objResponse ->addAlert ('Commande : ' .$ cmd .' inconnue ! ' );
157
+
158
+ }
159
+ // Pour debugger
160
+ $ debug =$ GLOBALS ["TSFE " ]->fe_user ->getKey ('ses ' ,'debugflag ' );
161
+ //$debug=true;
162
+ $ l =strlen (serialize ($ GLOBALS ["TSFE " ]->fe_user ->sesData ));
163
+ $ GLOBALS ["TSFE " ]->fe_user ->storeSessionData ();
164
+ if ($ debug ) {
165
+ $ content ="<hr>len: $ l <br> " ;
166
+ $ content .="debug<hr> " .$ GLOBALS ["TSFE " ]->fe_user ->getKey ('ses ' ,'dbg ' ).'<br> ' ;
167
+
168
+ // TODO vérifier cohérence des données....
169
+
170
+ $ objResponse ->addAssign ('debug ' , 'innerHTML ' , $ content );
171
+ }
172
+ return $ objResponse ->getXML ();
173
+ }
174
+ }
175
+
176
+ if (defined ('TYPO3_MODE ' ) && $ TYPO3_CONF_VARS [TYPO3_MODE ]['XCLASS ' ]['ext/meta_feedit/class.tx_metafeedit_ajax.php ' ]) {
177
+ include_once ($ TYPO3_CONF_VARS [TYPO3_MODE ]['XCLASS ' ]['ext/meta_feedit/class.tx_metafeedit_ajax.php ' ]);
178
+ }
179
+
182
180
?>
0 commit comments