@@ -19,118 +19,118 @@ discard block |
||
19 | 19 | */ |
20 | 20 | class SmartObjectExport |
21 | 21 | { |
22 | - public $handler; |
|
23 | - public $criteria; |
|
24 | - public $fields; |
|
25 | - public $format; |
|
26 | - public $filename; |
|
27 | - public $filepath; |
|
28 | - public $options; |
|
29 | - public $outputMethods = false; |
|
30 | - public $notDisplayFields; |
|
22 | + public $handler; |
|
23 | + public $criteria; |
|
24 | + public $fields; |
|
25 | + public $format; |
|
26 | + public $filename; |
|
27 | + public $filepath; |
|
28 | + public $options; |
|
29 | + public $outputMethods = false; |
|
30 | + public $notDisplayFields; |
|
31 | 31 | |
32 | - /** |
|
33 | - * Constructor |
|
34 | - * |
|
35 | - * @param SmartPersistableObjectHandler $objectHandler SmartObjectHandler handling the data we want to export |
|
36 | - * @param CriteriaElement $criteria containing the criteria of the query fetching the objects to be exported |
|
37 | - * @param array|bool $fields fields to be exported. If FALSE then all fields will be exported |
|
38 | - * @param bool|string $filename name of the file to be created |
|
39 | - * @param bool|string $filepath path where the file will be saved |
|
40 | - * @param string $format format of the ouputed export. Currently only supports CSV |
|
41 | - * @param array|bool $options options of the format to be exported in |
|
42 | - */ |
|
43 | - public function __construct( |
|
44 | - SmartPersistableObjectHandler $objectHandler, |
|
45 | - CriteriaElement $criteria = null, |
|
46 | - $fields = false, |
|
47 | - $filename = false, |
|
48 | - $filepath = false, |
|
49 | - $format = 'csv', |
|
50 | - $options = false |
|
51 | - ) { |
|
52 | - $this->handler = $objectHandler; |
|
53 | - $this->criteria = $criteria; |
|
54 | - $this->fields = $fields; |
|
55 | - $this->filename = $filename; |
|
56 | - $this->format = $format; |
|
57 | - $this->options = $options; |
|
58 | - $this->notDisplayFields = false; |
|
59 | - } |
|
32 | + /** |
|
33 | + * Constructor |
|
34 | + * |
|
35 | + * @param SmartPersistableObjectHandler $objectHandler SmartObjectHandler handling the data we want to export |
|
36 | + * @param CriteriaElement $criteria containing the criteria of the query fetching the objects to be exported |
|
37 | + * @param array|bool $fields fields to be exported. If FALSE then all fields will be exported |
|
38 | + * @param bool|string $filename name of the file to be created |
|
39 | + * @param bool|string $filepath path where the file will be saved |
|
40 | + * @param string $format format of the ouputed export. Currently only supports CSV |
|
41 | + * @param array|bool $options options of the format to be exported in |
|
42 | + */ |
|
43 | + public function __construct( |
|
44 | + SmartPersistableObjectHandler $objectHandler, |
|
45 | + CriteriaElement $criteria = null, |
|
46 | + $fields = false, |
|
47 | + $filename = false, |
|
48 | + $filepath = false, |
|
49 | + $format = 'csv', |
|
50 | + $options = false |
|
51 | + ) { |
|
52 | + $this->handler = $objectHandler; |
|
53 | + $this->criteria = $criteria; |
|
54 | + $this->fields = $fields; |
|
55 | + $this->filename = $filename; |
|
56 | + $this->format = $format; |
|
57 | + $this->options = $options; |
|
58 | + $this->notDisplayFields = false; |
|
59 | + } |
|
60 | 60 | |
61 | - /** |
|
62 | - * Renders the export |
|
63 | - * @param $filename |
|
64 | - */ |
|
65 | - public function render($filename) |
|
66 | - { |
|
67 | - $this->filename = $filename; |
|
61 | + /** |
|
62 | + * Renders the export |
|
63 | + * @param $filename |
|
64 | + */ |
|
65 | + public function render($filename) |
|
66 | + { |
|
67 | + $this->filename = $filename; |
|
68 | 68 | |
69 | - $objects = $this->handler->getObjects($this->criteria); |
|
70 | - $rows = array(); |
|
71 | - $columnsHeaders = array(); |
|
72 | - $firstObject = true; |
|
73 | - foreach ($objects as $object) { |
|
74 | - $row = array(); |
|
75 | - foreach ($object->vars as $key => $var) { |
|
76 | - if ((!$this->fields || in_array($key, $this->fields)) && !in_array($key, $this->notDisplayFields)) { |
|
77 | - if ($this->outputMethods && isset($this->outputMethods[$key]) |
|
78 | - && method_exists($object, $this->outputMethods[$key])) { |
|
79 | - $method = $this->outputMethods[$key]; |
|
80 | - $row[$key] = $object->$method(); |
|
81 | - } else { |
|
82 | - $row[$key] = $object->getVar($key); |
|
83 | - } |
|
84 | - if ($firstObject) { |
|
85 | - // then set the columnsHeaders array as well |
|
86 | - $columnsHeaders[$key] = $var['form_caption']; |
|
87 | - } |
|
88 | - } |
|
89 | - } |
|
90 | - $firstObject = false; |
|
91 | - $rows[] = $row; |
|
92 | - unset($row); |
|
93 | - } |
|
94 | - $data = array(); |
|
95 | - $data['rows'] = $rows; |
|
96 | - $data['columnsHeaders'] = $columnsHeaders; |
|
97 | - $smartExportRenderer = new SmartExportRenderer($data, $this->filename, $this->filepath, $this->format, $this->options); |
|
98 | - $smartExportRenderer->execute(); |
|
99 | - } |
|
69 | + $objects = $this->handler->getObjects($this->criteria); |
|
70 | + $rows = array(); |
|
71 | + $columnsHeaders = array(); |
|
72 | + $firstObject = true; |
|
73 | + foreach ($objects as $object) { |
|
74 | + $row = array(); |
|
75 | + foreach ($object->vars as $key => $var) { |
|
76 | + if ((!$this->fields || in_array($key, $this->fields)) && !in_array($key, $this->notDisplayFields)) { |
|
77 | + if ($this->outputMethods && isset($this->outputMethods[$key]) |
|
78 | + && method_exists($object, $this->outputMethods[$key])) { |
|
79 | + $method = $this->outputMethods[$key]; |
|
80 | + $row[$key] = $object->$method(); |
|
81 | + } else { |
|
82 | + $row[$key] = $object->getVar($key); |
|
83 | + } |
|
84 | + if ($firstObject) { |
|
85 | + // then set the columnsHeaders array as well |
|
86 | + $columnsHeaders[$key] = $var['form_caption']; |
|
87 | + } |
|
88 | + } |
|
89 | + } |
|
90 | + $firstObject = false; |
|
91 | + $rows[] = $row; |
|
92 | + unset($row); |
|
93 | + } |
|
94 | + $data = array(); |
|
95 | + $data['rows'] = $rows; |
|
96 | + $data['columnsHeaders'] = $columnsHeaders; |
|
97 | + $smartExportRenderer = new SmartExportRenderer($data, $this->filename, $this->filepath, $this->format, $this->options); |
|
98 | + $smartExportRenderer->execute(); |
|
99 | + } |
|
100 | 100 | |
101 | - /** |
|
102 | - * Set an array contaning the alternate methods to use instead of the default getVar() |
|
103 | - * |
|
104 | - * $outputMethods array example: 'uid' => 'getUserName'... |
|
105 | - * @param $outputMethods |
|
106 | - */ |
|
107 | - public function setOuptutMethods($outputMethods) |
|
108 | - { |
|
109 | - $this->outputMethods = $outputMethods; |
|
110 | - } |
|
101 | + /** |
|
102 | + * Set an array contaning the alternate methods to use instead of the default getVar() |
|
103 | + * |
|
104 | + * $outputMethods array example: 'uid' => 'getUserName'... |
|
105 | + * @param $outputMethods |
|
106 | + */ |
|
107 | + public function setOuptutMethods($outputMethods) |
|
108 | + { |
|
109 | + $this->outputMethods = $outputMethods; |
|
110 | + } |
|
111 | 111 | |
112 | - /* |
|
112 | + /* |
|
113 | 113 | * Set an array of fields that we don't want in export |
114 | 114 | */ |
115 | - /** |
|
116 | - * @param $fields |
|
117 | - */ |
|
118 | - public function setNotDisplayFields($fields) |
|
119 | - { |
|
120 | - if (!$this->notDisplayFields) { |
|
121 | - if (is_array($fields)) { |
|
122 | - $this->notDisplayFields = $fields; |
|
123 | - } else { |
|
124 | - $this->notDisplayFields = array($fields); |
|
125 | - } |
|
126 | - } else { |
|
127 | - if (is_array($fields)) { |
|
128 | - $this->notDisplayFields = array_merge($this->notDisplayFields, $fields); |
|
129 | - } else { |
|
130 | - $this->notDisplayFields[] = $fields; |
|
131 | - } |
|
132 | - } |
|
133 | - } |
|
115 | + /** |
|
116 | + * @param $fields |
|
117 | + */ |
|
118 | + public function setNotDisplayFields($fields) |
|
119 | + { |
|
120 | + if (!$this->notDisplayFields) { |
|
121 | + if (is_array($fields)) { |
|
122 | + $this->notDisplayFields = $fields; |
|
123 | + } else { |
|
124 | + $this->notDisplayFields = array($fields); |
|
125 | + } |
|
126 | + } else { |
|
127 | + if (is_array($fields)) { |
|
128 | + $this->notDisplayFields = array_merge($this->notDisplayFields, $fields); |
|
129 | + } else { |
|
130 | + $this->notDisplayFields[] = $fields; |
|
131 | + } |
|
132 | + } |
|
133 | + } |
|
134 | 134 | } |
135 | 135 | |
136 | 136 | /** |
@@ -144,186 +144,186 @@ discard block |
||
144 | 144 | */ |
145 | 145 | class SmartExportRenderer |
146 | 146 | { |
147 | - public $data; |
|
148 | - public $format; |
|
149 | - public $filename; |
|
150 | - public $filepath; |
|
151 | - public $options; |
|
147 | + public $data; |
|
148 | + public $format; |
|
149 | + public $filename; |
|
150 | + public $filepath; |
|
151 | + public $options; |
|
152 | 152 | |
153 | - /** |
|
154 | - * Constructor |
|
155 | - * |
|
156 | - * @param array $data contains the data to be exported |
|
157 | - * @param bool|string $filename name of the file in which the exported data will be saved |
|
158 | - * @param bool|string $filepath path where the file will be saved |
|
159 | - * @param string $format format of the ouputed export. Currently only supports CSV |
|
160 | - * @param array $options options of the format to be exported in |
|
161 | - */ |
|
162 | - public function __construct( |
|
163 | - $data, |
|
164 | - $filename = false, |
|
165 | - $filepath = false, |
|
166 | - $format = 'csv', |
|
167 | - $options = array('separator' => ';') |
|
168 | - ) { |
|
169 | - $this->data = $data; |
|
170 | - $this->format = $format; |
|
171 | - $this->filename = $filename; |
|
172 | - $this->filepath = $filepath; |
|
173 | - $this->options = $options; |
|
174 | - } |
|
153 | + /** |
|
154 | + * Constructor |
|
155 | + * |
|
156 | + * @param array $data contains the data to be exported |
|
157 | + * @param bool|string $filename name of the file in which the exported data will be saved |
|
158 | + * @param bool|string $filepath path where the file will be saved |
|
159 | + * @param string $format format of the ouputed export. Currently only supports CSV |
|
160 | + * @param array $options options of the format to be exported in |
|
161 | + */ |
|
162 | + public function __construct( |
|
163 | + $data, |
|
164 | + $filename = false, |
|
165 | + $filepath = false, |
|
166 | + $format = 'csv', |
|
167 | + $options = array('separator' => ';') |
|
168 | + ) { |
|
169 | + $this->data = $data; |
|
170 | + $this->format = $format; |
|
171 | + $this->filename = $filename; |
|
172 | + $this->filepath = $filepath; |
|
173 | + $this->options = $options; |
|
174 | + } |
|
175 | 175 | |
176 | - /** |
|
177 | - * @param $dataArray |
|
178 | - * @param $separator |
|
179 | - * @param string $trim |
|
180 | - * @param bool $removeEmptyLines |
|
181 | - * @return string |
|
182 | - */ |
|
183 | - public function arrayToCsvString($dataArray, $separator, $trim = 'both', $removeEmptyLines = true) |
|
184 | - { |
|
185 | - if (!is_array($dataArray) || empty($dataArray)) { |
|
186 | - return ''; |
|
187 | - } |
|
188 | - switch ($trim) { |
|
189 | - case 'none': |
|
190 | - $trimFunction = false; |
|
191 | - break; |
|
192 | - case 'left': |
|
193 | - $trimFunction = 'ltrim'; |
|
194 | - break; |
|
195 | - case 'right': |
|
196 | - $trimFunction = 'rtrim'; |
|
197 | - break; |
|
198 | - default: //'both': |
|
199 | - $trimFunction = 'trim'; |
|
200 | - break; |
|
201 | - } |
|
202 | - $ret = array(); |
|
203 | - foreach ($dataArray as $key => $field) { |
|
204 | - $ret[$key] = $this->valToCsvHelper($field, $separator, $trimFunction); |
|
205 | - } |
|
176 | + /** |
|
177 | + * @param $dataArray |
|
178 | + * @param $separator |
|
179 | + * @param string $trim |
|
180 | + * @param bool $removeEmptyLines |
|
181 | + * @return string |
|
182 | + */ |
|
183 | + public function arrayToCsvString($dataArray, $separator, $trim = 'both', $removeEmptyLines = true) |
|
184 | + { |
|
185 | + if (!is_array($dataArray) || empty($dataArray)) { |
|
186 | + return ''; |
|
187 | + } |
|
188 | + switch ($trim) { |
|
189 | + case 'none': |
|
190 | + $trimFunction = false; |
|
191 | + break; |
|
192 | + case 'left': |
|
193 | + $trimFunction = 'ltrim'; |
|
194 | + break; |
|
195 | + case 'right': |
|
196 | + $trimFunction = 'rtrim'; |
|
197 | + break; |
|
198 | + default: //'both': |
|
199 | + $trimFunction = 'trim'; |
|
200 | + break; |
|
201 | + } |
|
202 | + $ret = array(); |
|
203 | + foreach ($dataArray as $key => $field) { |
|
204 | + $ret[$key] = $this->valToCsvHelper($field, $separator, $trimFunction); |
|
205 | + } |
|
206 | 206 | |
207 | - return implode($separator, $ret); |
|
208 | - } |
|
207 | + return implode($separator, $ret); |
|
208 | + } |
|
209 | 209 | |
210 | - /** |
|
211 | - * @param $val |
|
212 | - * @param $separator |
|
213 | - * @param $trimFunction |
|
214 | - * @return mixed|string |
|
215 | - */ |
|
216 | - public function valToCsvHelper($val, $separator, $trimFunction) |
|
217 | - { |
|
218 | - if ($trimFunction) { |
|
219 | - $val = $trimFunction($val); |
|
220 | - } |
|
221 | - //If there is a separator (;) or a quote (") or a linebreak in the string, we need to quote it. |
|
222 | - $needQuote = false; |
|
223 | - do { |
|
224 | - if (strpos($val, '"') !== false) { |
|
225 | - $val = str_replace('"', '""', $val); |
|
226 | - $needQuote = true; |
|
227 | - break; |
|
228 | - } |
|
229 | - if (strpos($val, $separator) !== false) { |
|
230 | - $needQuote = true; |
|
231 | - break; |
|
232 | - } |
|
233 | - if ((strpos($val, "\n") !== false) || (strpos($val, "\r") !== false)) { // \r is for mac |
|
234 | - $needQuote = true; |
|
235 | - break; |
|
236 | - } |
|
237 | - } while (false); |
|
238 | - if ($needQuote) { |
|
239 | - $val = '"' . $val . '"'; |
|
240 | - } |
|
210 | + /** |
|
211 | + * @param $val |
|
212 | + * @param $separator |
|
213 | + * @param $trimFunction |
|
214 | + * @return mixed|string |
|
215 | + */ |
|
216 | + public function valToCsvHelper($val, $separator, $trimFunction) |
|
217 | + { |
|
218 | + if ($trimFunction) { |
|
219 | + $val = $trimFunction($val); |
|
220 | + } |
|
221 | + //If there is a separator (;) or a quote (") or a linebreak in the string, we need to quote it. |
|
222 | + $needQuote = false; |
|
223 | + do { |
|
224 | + if (strpos($val, '"') !== false) { |
|
225 | + $val = str_replace('"', '""', $val); |
|
226 | + $needQuote = true; |
|
227 | + break; |
|
228 | + } |
|
229 | + if (strpos($val, $separator) !== false) { |
|
230 | + $needQuote = true; |
|
231 | + break; |
|
232 | + } |
|
233 | + if ((strpos($val, "\n") !== false) || (strpos($val, "\r") !== false)) { // \r is for mac |
|
234 | + $needQuote = true; |
|
235 | + break; |
|
236 | + } |
|
237 | + } while (false); |
|
238 | + if ($needQuote) { |
|
239 | + $val = '"' . $val . '"'; |
|
240 | + } |
|
241 | 241 | |
242 | - return $val; |
|
243 | - } |
|
242 | + return $val; |
|
243 | + } |
|
244 | 244 | |
245 | - public function execute() |
|
246 | - { |
|
247 | - $exportFileData = ''; |
|
245 | + public function execute() |
|
246 | + { |
|
247 | + $exportFileData = ''; |
|
248 | 248 | |
249 | - switch ($this->format) { |
|
250 | - case 'csv': |
|
251 | - $separator = isset($this->options['separator']) ? $this->options['separator'] : ';'; |
|
252 | - $firstRow = implode($separator, $this->data['columnsHeaders']); |
|
253 | - $exportFileData .= $firstRow . "\r\n"; |
|
249 | + switch ($this->format) { |
|
250 | + case 'csv': |
|
251 | + $separator = isset($this->options['separator']) ? $this->options['separator'] : ';'; |
|
252 | + $firstRow = implode($separator, $this->data['columnsHeaders']); |
|
253 | + $exportFileData .= $firstRow . "\r\n"; |
|
254 | 254 | |
255 | - foreach ($this->data['rows'] as $cols) { |
|
256 | - $exportFileData .= $this->arrayToCsvString($cols, $separator) . "\r\n"; |
|
257 | - } |
|
258 | - break; |
|
259 | - } |
|
260 | - $this->saveExportFile($exportFileData); |
|
261 | - } |
|
255 | + foreach ($this->data['rows'] as $cols) { |
|
256 | + $exportFileData .= $this->arrayToCsvString($cols, $separator) . "\r\n"; |
|
257 | + } |
|
258 | + break; |
|
259 | + } |
|
260 | + $this->saveExportFile($exportFileData); |
|
261 | + } |
|
262 | 262 | |
263 | - /** |
|
264 | - * @param $content |
|
265 | - */ |
|
266 | - public function saveExportFile($content) |
|
267 | - { |
|
268 | - switch ($this->format) { |
|
269 | - case 'csv': |
|
270 | - $this->saveCsv($content); |
|
271 | - break; |
|
272 | - } |
|
273 | - } |
|
263 | + /** |
|
264 | + * @param $content |
|
265 | + */ |
|
266 | + public function saveExportFile($content) |
|
267 | + { |
|
268 | + switch ($this->format) { |
|
269 | + case 'csv': |
|
270 | + $this->saveCsv($content); |
|
271 | + break; |
|
272 | + } |
|
273 | + } |
|
274 | 274 | |
275 | - /** |
|
276 | - * @param $content |
|
277 | - */ |
|
278 | - public function saveCsv($content) |
|
279 | - { |
|
280 | - if (!$this->filepath) { |
|
281 | - $this->filepath = XOOPS_UPLOAD_PATH . '/'; |
|
282 | - } |
|
283 | - if (!$this->filename) { |
|
284 | - $this->filename .= time(); |
|
285 | - $this->filename .= '.csv'; |
|
286 | - } |
|
275 | + /** |
|
276 | + * @param $content |
|
277 | + */ |
|
278 | + public function saveCsv($content) |
|
279 | + { |
|
280 | + if (!$this->filepath) { |
|
281 | + $this->filepath = XOOPS_UPLOAD_PATH . '/'; |
|
282 | + } |
|
283 | + if (!$this->filename) { |
|
284 | + $this->filename .= time(); |
|
285 | + $this->filename .= '.csv'; |
|
286 | + } |
|
287 | 287 | |
288 | - $fullFileName = $this->filepath . $this->filename; |
|
288 | + $fullFileName = $this->filepath . $this->filename; |
|
289 | 289 | |
290 | - if (!$handle = fopen($fullFileName, 'a+')) { |
|
291 | - trigger_error('Unable to open ' . $fullFileName, E_USER_WARNING); |
|
292 | - } elseif (fwrite($handle, $content) === false) { |
|
293 | - trigger_error('Unable to write in ' . $fullFileName, E_USER_WARNING); |
|
294 | - } else { |
|
295 | - $mimeType = 'text/csv'; |
|
296 | - $file = strrev($this->filename); |
|
297 | - $temp_name = strtolower(strrev(substr($file, 0, strpos($file, '--')))); |
|
298 | - if ($temp_name === '') { |
|
299 | - $file_name = $this->filename; |
|
300 | - } else { |
|
301 | - $file_name = $temp_name; |
|
302 | - } |
|
303 | - $fullFileName = $this->filepath . stripslashes(trim($this->filename)); |
|
290 | + if (!$handle = fopen($fullFileName, 'a+')) { |
|
291 | + trigger_error('Unable to open ' . $fullFileName, E_USER_WARNING); |
|
292 | + } elseif (fwrite($handle, $content) === false) { |
|
293 | + trigger_error('Unable to write in ' . $fullFileName, E_USER_WARNING); |
|
294 | + } else { |
|
295 | + $mimeType = 'text/csv'; |
|
296 | + $file = strrev($this->filename); |
|
297 | + $temp_name = strtolower(strrev(substr($file, 0, strpos($file, '--')))); |
|
298 | + if ($temp_name === '') { |
|
299 | + $file_name = $this->filename; |
|
300 | + } else { |
|
301 | + $file_name = $temp_name; |
|
302 | + } |
|
303 | + $fullFileName = $this->filepath . stripslashes(trim($this->filename)); |
|
304 | 304 | |
305 | - if (ini_get('zlib.output_compression')) { |
|
306 | - ini_set('zlib.output_compression', 'Off'); |
|
307 | - } |
|
305 | + if (ini_get('zlib.output_compression')) { |
|
306 | + ini_set('zlib.output_compression', 'Off'); |
|
307 | + } |
|
308 | 308 | |
309 | - header('Pragma: public'); |
|
310 | - header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); |
|
311 | - header('Cache-Control: private', false); |
|
312 | - header('Content-Transfer-Encoding: binary'); |
|
313 | - if (isset($mimeType)) { |
|
314 | - header('Content-Type: ' . $mimeType); |
|
315 | - } |
|
309 | + header('Pragma: public'); |
|
310 | + header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); |
|
311 | + header('Cache-Control: private', false); |
|
312 | + header('Content-Transfer-Encoding: binary'); |
|
313 | + if (isset($mimeType)) { |
|
314 | + header('Content-Type: ' . $mimeType); |
|
315 | + } |
|
316 | 316 | |
317 | - header('Content-Disposition: attachment; filename=' . $file_name); |
|
317 | + header('Content-Disposition: attachment; filename=' . $file_name); |
|
318 | 318 | |
319 | - if (isset($mimeType) && false !== strpos($mimeType, 'text/')) { |
|
320 | - $fp = fopen($fullFileName, 'r'); |
|
321 | - } else { |
|
322 | - $fp = fopen($fullFileName, 'rb'); |
|
323 | - } |
|
324 | - fpassthru($fp); |
|
325 | - exit(); |
|
326 | - } |
|
327 | - fclose($handle); |
|
328 | - } |
|
319 | + if (isset($mimeType) && false !== strpos($mimeType, 'text/')) { |
|
320 | + $fp = fopen($fullFileName, 'r'); |
|
321 | + } else { |
|
322 | + $fp = fopen($fullFileName, 'rb'); |
|
323 | + } |
|
324 | + fpassthru($fp); |
|
325 | + exit(); |
|
326 | + } |
|
327 | + fclose($handle); |
|
328 | + } |
|
329 | 329 | } |
@@ -236,7 +236,7 @@ discard block |
||
236 | 236 | } |
237 | 237 | } while (false); |
238 | 238 | if ($needQuote) { |
239 | - $val = '"' . $val . '"'; |
|
239 | + $val = '"'.$val.'"'; |
|
240 | 240 | } |
241 | 241 | |
242 | 242 | return $val; |
@@ -250,10 +250,10 @@ discard block |
||
250 | 250 | case 'csv': |
251 | 251 | $separator = isset($this->options['separator']) ? $this->options['separator'] : ';'; |
252 | 252 | $firstRow = implode($separator, $this->data['columnsHeaders']); |
253 | - $exportFileData .= $firstRow . "\r\n"; |
|
253 | + $exportFileData .= $firstRow."\r\n"; |
|
254 | 254 | |
255 | 255 | foreach ($this->data['rows'] as $cols) { |
256 | - $exportFileData .= $this->arrayToCsvString($cols, $separator) . "\r\n"; |
|
256 | + $exportFileData .= $this->arrayToCsvString($cols, $separator)."\r\n"; |
|
257 | 257 | } |
258 | 258 | break; |
259 | 259 | } |
@@ -278,19 +278,19 @@ discard block |
||
278 | 278 | public function saveCsv($content) |
279 | 279 | { |
280 | 280 | if (!$this->filepath) { |
281 | - $this->filepath = XOOPS_UPLOAD_PATH . '/'; |
|
281 | + $this->filepath = XOOPS_UPLOAD_PATH.'/'; |
|
282 | 282 | } |
283 | 283 | if (!$this->filename) { |
284 | 284 | $this->filename .= time(); |
285 | 285 | $this->filename .= '.csv'; |
286 | 286 | } |
287 | 287 | |
288 | - $fullFileName = $this->filepath . $this->filename; |
|
288 | + $fullFileName = $this->filepath.$this->filename; |
|
289 | 289 | |
290 | 290 | if (!$handle = fopen($fullFileName, 'a+')) { |
291 | - trigger_error('Unable to open ' . $fullFileName, E_USER_WARNING); |
|
291 | + trigger_error('Unable to open '.$fullFileName, E_USER_WARNING); |
|
292 | 292 | } elseif (fwrite($handle, $content) === false) { |
293 | - trigger_error('Unable to write in ' . $fullFileName, E_USER_WARNING); |
|
293 | + trigger_error('Unable to write in '.$fullFileName, E_USER_WARNING); |
|
294 | 294 | } else { |
295 | 295 | $mimeType = 'text/csv'; |
296 | 296 | $file = strrev($this->filename); |
@@ -300,7 +300,7 @@ discard block |
||
300 | 300 | } else { |
301 | 301 | $file_name = $temp_name; |
302 | 302 | } |
303 | - $fullFileName = $this->filepath . stripslashes(trim($this->filename)); |
|
303 | + $fullFileName = $this->filepath.stripslashes(trim($this->filename)); |
|
304 | 304 | |
305 | 305 | if (ini_get('zlib.output_compression')) { |
306 | 306 | ini_set('zlib.output_compression', 'Off'); |
@@ -311,10 +311,10 @@ discard block |
||
311 | 311 | header('Cache-Control: private', false); |
312 | 312 | header('Content-Transfer-Encoding: binary'); |
313 | 313 | if (isset($mimeType)) { |
314 | - header('Content-Type: ' . $mimeType); |
|
314 | + header('Content-Type: '.$mimeType); |
|
315 | 315 | } |
316 | 316 | |
317 | - header('Content-Disposition: attachment; filename=' . $file_name); |
|
317 | + header('Content-Disposition: attachment; filename='.$file_name); |
|
318 | 318 | |
319 | 319 | if (isset($mimeType) && false !== strpos($mimeType, 'text/')) { |
320 | 320 | $fp = fopen($fullFileName, 'r'); |
@@ -24,82 +24,82 @@ discard block |
||
24 | 24 | */ |
25 | 25 | class SmartMlObject extends SmartObject |
26 | 26 | { |
27 | - /** |
|
28 | - * SmartMlObject constructor. |
|
29 | - */ |
|
30 | - public function __construct() |
|
31 | - { |
|
32 | - $this->initVar('language', XOBJ_DTYPE_TXTBOX, 'english', false, null, '', true, _CO_SOBJECT_LANGUAGE_CAPTION, _CO_SOBJECT_LANGUAGE_DSC, true, true); |
|
33 | - $this->setControl('language', 'language'); |
|
34 | - } |
|
35 | - |
|
36 | - /** |
|
37 | - * If object is not new, change the control of the not-multilanguage fields |
|
38 | - * |
|
39 | - * We need to intercept this function from SmartObject because if the object is not new... |
|
40 | - */ |
|
41 | - // function getForm() { |
|
42 | - |
|
43 | - //} |
|
44 | - |
|
45 | - /** |
|
46 | - * Strip Multilanguage Fields |
|
47 | - * |
|
48 | - * Get rid of all the multilanguage fields to have an object with only global fields. |
|
49 | - * This will be usefull when creating the ML object for the first time. Then we will be able |
|
50 | - * to create translations. |
|
51 | - */ |
|
52 | - public function stripMultilanguageFields() |
|
53 | - { |
|
54 | - $objectVars =& $this->getVars(); |
|
55 | - $newObjectVars = array(); |
|
56 | - foreach ($objectVars as $key => $var) { |
|
57 | - if (!$var['multilingual']) { |
|
58 | - $newObjectVars[$key] = $var; |
|
59 | - } |
|
60 | - } |
|
61 | - $this->vars = $newObjectVars; |
|
62 | - } |
|
63 | - |
|
64 | - public function stripNonMultilanguageFields() |
|
65 | - { |
|
66 | - $objectVars =& $this->getVars(); |
|
67 | - $newObjectVars = array(); |
|
68 | - foreach ($objectVars as $key => $var) { |
|
69 | - if ($var['multilingual'] || $key == $this->handler->keyName) { |
|
70 | - $newObjectVars[$key] = $var; |
|
71 | - } |
|
72 | - } |
|
73 | - $this->vars = $newObjectVars; |
|
74 | - } |
|
75 | - |
|
76 | - /** |
|
77 | - * Make non multilanguage fields read only |
|
78 | - * |
|
79 | - * This is used when we are creating/editing a translation. |
|
80 | - * We only want to edit the multilanguag fields, not the global one. |
|
81 | - */ |
|
82 | - public function makeNonMLFieldReadOnly() |
|
83 | - { |
|
84 | - foreach ($this->getVars() as $key => $var) { |
|
85 | - //if (($key == 'language') || (!$var['multilingual'] && $key <> $this->handler->keyName)) { |
|
86 | - if (!$var['multilingual'] && $key != $this->handler->keyName) { |
|
87 | - $this->setControl($key, 'label'); |
|
88 | - } |
|
89 | - } |
|
90 | - } |
|
91 | - |
|
92 | - /** |
|
93 | - * @param bool $onlyUrl |
|
94 | - * @param bool $withimage |
|
95 | - * @return string |
|
96 | - */ |
|
97 | - public function getEditLanguageLink($onlyUrl = false, $withimage = true) |
|
98 | - { |
|
99 | - $controller = new SmartObjectController($this->handler); |
|
100 | - |
|
101 | - return $controller->getEditLanguageLink($this, $onlyUrl, $withimage); |
|
102 | - } |
|
27 | + /** |
|
28 | + * SmartMlObject constructor. |
|
29 | + */ |
|
30 | + public function __construct() |
|
31 | + { |
|
32 | + $this->initVar('language', XOBJ_DTYPE_TXTBOX, 'english', false, null, '', true, _CO_SOBJECT_LANGUAGE_CAPTION, _CO_SOBJECT_LANGUAGE_DSC, true, true); |
|
33 | + $this->setControl('language', 'language'); |
|
34 | + } |
|
35 | + |
|
36 | + /** |
|
37 | + * If object is not new, change the control of the not-multilanguage fields |
|
38 | + * |
|
39 | + * We need to intercept this function from SmartObject because if the object is not new... |
|
40 | + */ |
|
41 | + // function getForm() { |
|
42 | + |
|
43 | + //} |
|
44 | + |
|
45 | + /** |
|
46 | + * Strip Multilanguage Fields |
|
47 | + * |
|
48 | + * Get rid of all the multilanguage fields to have an object with only global fields. |
|
49 | + * This will be usefull when creating the ML object for the first time. Then we will be able |
|
50 | + * to create translations. |
|
51 | + */ |
|
52 | + public function stripMultilanguageFields() |
|
53 | + { |
|
54 | + $objectVars =& $this->getVars(); |
|
55 | + $newObjectVars = array(); |
|
56 | + foreach ($objectVars as $key => $var) { |
|
57 | + if (!$var['multilingual']) { |
|
58 | + $newObjectVars[$key] = $var; |
|
59 | + } |
|
60 | + } |
|
61 | + $this->vars = $newObjectVars; |
|
62 | + } |
|
63 | + |
|
64 | + public function stripNonMultilanguageFields() |
|
65 | + { |
|
66 | + $objectVars =& $this->getVars(); |
|
67 | + $newObjectVars = array(); |
|
68 | + foreach ($objectVars as $key => $var) { |
|
69 | + if ($var['multilingual'] || $key == $this->handler->keyName) { |
|
70 | + $newObjectVars[$key] = $var; |
|
71 | + } |
|
72 | + } |
|
73 | + $this->vars = $newObjectVars; |
|
74 | + } |
|
75 | + |
|
76 | + /** |
|
77 | + * Make non multilanguage fields read only |
|
78 | + * |
|
79 | + * This is used when we are creating/editing a translation. |
|
80 | + * We only want to edit the multilanguag fields, not the global one. |
|
81 | + */ |
|
82 | + public function makeNonMLFieldReadOnly() |
|
83 | + { |
|
84 | + foreach ($this->getVars() as $key => $var) { |
|
85 | + //if (($key == 'language') || (!$var['multilingual'] && $key <> $this->handler->keyName)) { |
|
86 | + if (!$var['multilingual'] && $key != $this->handler->keyName) { |
|
87 | + $this->setControl($key, 'label'); |
|
88 | + } |
|
89 | + } |
|
90 | + } |
|
91 | + |
|
92 | + /** |
|
93 | + * @param bool $onlyUrl |
|
94 | + * @param bool $withimage |
|
95 | + * @return string |
|
96 | + */ |
|
97 | + public function getEditLanguageLink($onlyUrl = false, $withimage = true) |
|
98 | + { |
|
99 | + $controller = new SmartObjectController($this->handler); |
|
100 | + |
|
101 | + return $controller->getEditLanguageLink($this, $onlyUrl, $withimage); |
|
102 | + } |
|
103 | 103 | } |
104 | 104 | |
105 | 105 | /** |
@@ -107,60 +107,60 @@ discard block |
||
107 | 107 | */ |
108 | 108 | class SmartPersistableMlObjectHandler extends SmartPersistableObjectHandler |
109 | 109 | { |
110 | - /** |
|
111 | - * @param null $criteria |
|
112 | - * @param bool $id_as_key |
|
113 | - * @param bool $as_object |
|
114 | - * @param bool $debug |
|
115 | - * @param bool $language |
|
116 | - * @return array |
|
117 | - */ |
|
118 | - public function getObjects( |
|
119 | - $criteria = null, |
|
120 | - $id_as_key = false, |
|
121 | - $as_object = true, |
|
122 | - $debug = false, |
|
123 | - $language = false |
|
124 | - ) { |
|
125 | - // Create the first part of the SQL query to join the "_text" table |
|
126 | - $sql = 'SELECT * FROM ' . $this->table . ' AS ' . $this->_itemname . ' INNER JOIN ' . $this->table . '_text AS ' . $this->_itemname . '_text ON ' . $this->_itemname . '.' . $this->keyName . '=' . $this->_itemname . '_text.' . $this->keyName; |
|
127 | - |
|
128 | - if ($language) { |
|
129 | - // If a language was specified, then let's create a WHERE clause to only return the objects associated with this language |
|
130 | - |
|
131 | - // if no criteria was previously created, let's create it |
|
132 | - if (!$criteria) { |
|
133 | - $criteria = new CriteriaCompo(); |
|
134 | - } |
|
135 | - $criteria->add(new Criteria('language', $language)); |
|
136 | - |
|
137 | - return parent::getObjects($criteria, $id_as_key, $as_object, $debug, $sql); |
|
138 | - } |
|
139 | - |
|
140 | - return parent::getObjects($criteria, $id_as_key, $as_object, $debug, $sql); |
|
141 | - } |
|
142 | - |
|
143 | - /** |
|
144 | - * @param mixed $id |
|
145 | - * @param bool $language |
|
146 | - * @param bool $as_object |
|
147 | - * @param bool $debug |
|
148 | - * @return mixed |
|
149 | - */ |
|
150 | - public function &get($id, $language = false, $as_object = true, $debug = false) |
|
151 | - { |
|
152 | - if (!$language) { |
|
153 | - return parent::get($id, $as_object, $debug); |
|
154 | - } else { |
|
155 | - $criteria = new CriteriaCompo(); |
|
156 | - $criteria->add(new Criteria('language', $language)); |
|
157 | - |
|
158 | - return parent::get($id, $as_object, $debug, $criteria); |
|
159 | - } |
|
160 | - } |
|
161 | - |
|
162 | - public function changeTableNameForML() |
|
163 | - { |
|
164 | - $this->table = $this->db->prefix($this->_moduleName . '_' . $this->_itemname . '_text'); |
|
165 | - } |
|
110 | + /** |
|
111 | + * @param null $criteria |
|
112 | + * @param bool $id_as_key |
|
113 | + * @param bool $as_object |
|
114 | + * @param bool $debug |
|
115 | + * @param bool $language |
|
116 | + * @return array |
|
117 | + */ |
|
118 | + public function getObjects( |
|
119 | + $criteria = null, |
|
120 | + $id_as_key = false, |
|
121 | + $as_object = true, |
|
122 | + $debug = false, |
|
123 | + $language = false |
|
124 | + ) { |
|
125 | + // Create the first part of the SQL query to join the "_text" table |
|
126 | + $sql = 'SELECT * FROM ' . $this->table . ' AS ' . $this->_itemname . ' INNER JOIN ' . $this->table . '_text AS ' . $this->_itemname . '_text ON ' . $this->_itemname . '.' . $this->keyName . '=' . $this->_itemname . '_text.' . $this->keyName; |
|
127 | + |
|
128 | + if ($language) { |
|
129 | + // If a language was specified, then let's create a WHERE clause to only return the objects associated with this language |
|
130 | + |
|
131 | + // if no criteria was previously created, let's create it |
|
132 | + if (!$criteria) { |
|
133 | + $criteria = new CriteriaCompo(); |
|
134 | + } |
|
135 | + $criteria->add(new Criteria('language', $language)); |
|
136 | + |
|
137 | + return parent::getObjects($criteria, $id_as_key, $as_object, $debug, $sql); |
|
138 | + } |
|
139 | + |
|
140 | + return parent::getObjects($criteria, $id_as_key, $as_object, $debug, $sql); |
|
141 | + } |
|
142 | + |
|
143 | + /** |
|
144 | + * @param mixed $id |
|
145 | + * @param bool $language |
|
146 | + * @param bool $as_object |
|
147 | + * @param bool $debug |
|
148 | + * @return mixed |
|
149 | + */ |
|
150 | + public function &get($id, $language = false, $as_object = true, $debug = false) |
|
151 | + { |
|
152 | + if (!$language) { |
|
153 | + return parent::get($id, $as_object, $debug); |
|
154 | + } else { |
|
155 | + $criteria = new CriteriaCompo(); |
|
156 | + $criteria->add(new Criteria('language', $language)); |
|
157 | + |
|
158 | + return parent::get($id, $as_object, $debug, $criteria); |
|
159 | + } |
|
160 | + } |
|
161 | + |
|
162 | + public function changeTableNameForML() |
|
163 | + { |
|
164 | + $this->table = $this->db->prefix($this->_moduleName . '_' . $this->_itemname . '_text'); |
|
165 | + } |
|
166 | 166 | } |
@@ -11,7 +11,7 @@ discard block |
||
11 | 11 | */ |
12 | 12 | |
13 | 13 | // defined('XOOPS_ROOT_PATH') || exit('XOOPS root path not defined'); |
14 | -require_once XOOPS_ROOT_PATH . '/modules/smartobject/class/smartobject.php'; |
|
14 | +require_once XOOPS_ROOT_PATH.'/modules/smartobject/class/smartobject.php'; |
|
15 | 15 | |
16 | 16 | /** |
17 | 17 | * SmartObject base Multilanguage-enabled class |
@@ -51,7 +51,7 @@ discard block |
||
51 | 51 | */ |
52 | 52 | public function stripMultilanguageFields() |
53 | 53 | { |
54 | - $objectVars =& $this->getVars(); |
|
54 | + $objectVars = & $this->getVars(); |
|
55 | 55 | $newObjectVars = array(); |
56 | 56 | foreach ($objectVars as $key => $var) { |
57 | 57 | if (!$var['multilingual']) { |
@@ -63,7 +63,7 @@ discard block |
||
63 | 63 | |
64 | 64 | public function stripNonMultilanguageFields() |
65 | 65 | { |
66 | - $objectVars =& $this->getVars(); |
|
66 | + $objectVars = & $this->getVars(); |
|
67 | 67 | $newObjectVars = array(); |
68 | 68 | foreach ($objectVars as $key => $var) { |
69 | 69 | if ($var['multilingual'] || $key == $this->handler->keyName) { |
@@ -123,7 +123,7 @@ discard block |
||
123 | 123 | $language = false |
124 | 124 | ) { |
125 | 125 | // Create the first part of the SQL query to join the "_text" table |
126 | - $sql = 'SELECT * FROM ' . $this->table . ' AS ' . $this->_itemname . ' INNER JOIN ' . $this->table . '_text AS ' . $this->_itemname . '_text ON ' . $this->_itemname . '.' . $this->keyName . '=' . $this->_itemname . '_text.' . $this->keyName; |
|
126 | + $sql = 'SELECT * FROM '.$this->table.' AS '.$this->_itemname.' INNER JOIN '.$this->table.'_text AS '.$this->_itemname.'_text ON '.$this->_itemname.'.'.$this->keyName.'='.$this->_itemname.'_text.'.$this->keyName; |
|
127 | 127 | |
128 | 128 | if ($language) { |
129 | 129 | // If a language was specified, then let's create a WHERE clause to only return the objects associated with this language |
@@ -161,6 +161,6 @@ discard block |
||
161 | 161 | |
162 | 162 | public function changeTableNameForML() |
163 | 163 | { |
164 | - $this->table = $this->db->prefix($this->_moduleName . '_' . $this->_itemname . '_text'); |
|
164 | + $this->table = $this->db->prefix($this->_moduleName.'_'.$this->_itemname.'_text'); |
|
165 | 165 | } |
166 | 166 | } |
@@ -1,7 +1,7 @@ |
||
1 | 1 | <?php |
2 | 2 | // defined('XOOPS_ROOT_PATH') || exit('XOOPS root path not defined'); |
3 | 3 | |
4 | -require_once XOOPS_ROOT_PATH . '/modules/smartobject/class/basedurl.php'; |
|
4 | +require_once XOOPS_ROOT_PATH.'/modules/smartobject/class/basedurl.php'; |
|
5 | 5 | |
6 | 6 | /** |
7 | 7 | * Class SmartobjectFile |
@@ -37,115 +37,115 @@ discard block |
||
37 | 37 | */ |
38 | 38 | class SmartobjectCurrency extends SmartObject |
39 | 39 | { |
40 | - public $_modulePlugin = false; |
|
41 | - |
|
42 | - /** |
|
43 | - * SmartobjectCurrency constructor. |
|
44 | - */ |
|
45 | - public function __construct() |
|
46 | - { |
|
47 | - $this->quickInitVar('currencyid', XOBJ_DTYPE_INT, true); |
|
48 | - $this->quickInitVar('iso4217', XOBJ_DTYPE_TXTBOX, true, _CO_SOBJECT_CURRENCY_ISO4217, _CO_SOBJECT_CURRENCY_ISO4217_DSC); |
|
49 | - $this->quickInitVar('name', XOBJ_DTYPE_TXTBOX, true, _CO_SOBJECT_CURRENCY_NAME); |
|
50 | - $this->quickInitVar('symbol', XOBJ_DTYPE_TXTBOX, true, _CO_SOBJECT_CURRENCY_SYMBOL); |
|
51 | - $this->quickInitVar('rate', XOBJ_DTYPE_FLOAT, true, _CO_SOBJECT_CURRENCY_RATE, '', '1.0'); |
|
52 | - $this->quickInitVar('default_currency', XOBJ_DTYPE_INT, false, _CO_SOBJECT_CURRENCY_DEFAULT, '', false); |
|
53 | - |
|
54 | - $this->setControl('symbol', array( |
|
55 | - 'name' => 'text', |
|
56 | - 'size' => '15', |
|
57 | - 'maxlength' => '15' |
|
58 | - )); |
|
59 | - |
|
60 | - $this->setControl('iso4217', array( |
|
61 | - 'name' => 'text', |
|
62 | - 'size' => '5', |
|
63 | - 'maxlength' => '5' |
|
64 | - )); |
|
65 | - |
|
66 | - $this->setControl('rate', array( |
|
67 | - 'name' => 'text', |
|
68 | - 'size' => '5', |
|
69 | - 'maxlength' => '5' |
|
70 | - )); |
|
71 | - |
|
72 | - $this->setControl('rate', array( |
|
73 | - 'name' => 'text', |
|
74 | - 'size' => '5', |
|
75 | - 'maxlength' => '5' |
|
76 | - )); |
|
77 | - |
|
78 | - $this->hideFieldFromForm('default_currency'); |
|
79 | - } |
|
80 | - |
|
81 | - /** |
|
82 | - * @param string $key |
|
83 | - * @param string $format |
|
84 | - * @return mixed |
|
85 | - */ |
|
86 | - public function getVar($key, $format = 's') |
|
87 | - { |
|
88 | - if ($format === 's' && in_array($key, array('rate', 'default_currency'))) { |
|
89 | - // return call_user_func(array($this, $key)); |
|
90 | - return $this->{$key}(); |
|
91 | - } |
|
92 | - |
|
93 | - return parent::getVar($key, $format); |
|
94 | - } |
|
95 | - |
|
96 | - /** |
|
97 | - * @return mixed |
|
98 | - */ |
|
99 | - public function getCurrencyLink() |
|
100 | - { |
|
101 | - $ret = $this->getVar('name', 'e'); |
|
102 | - |
|
103 | - return $ret; |
|
104 | - } |
|
105 | - |
|
106 | - /** |
|
107 | - * @return mixed |
|
108 | - */ |
|
109 | - public function getCode() |
|
110 | - { |
|
111 | - $ret = $this->getVar('iso4217', 'e'); |
|
112 | - |
|
113 | - return $ret; |
|
114 | - } |
|
115 | - |
|
116 | - /** |
|
117 | - * @return float|int|mixed|string |
|
118 | - */ |
|
119 | - public function rate() |
|
120 | - { |
|
121 | - return smart_currency($this->getVar('rate', 'e')); |
|
122 | - } |
|
123 | - |
|
124 | - /** |
|
125 | - * @return string |
|
126 | - */ |
|
127 | - public function defaultCurrency() |
|
128 | - { |
|
129 | - if ($this->getVar('default_currency', 'e') === true) { |
|
130 | - return _YES; |
|
131 | - } else { |
|
132 | - return _NO; |
|
133 | - } |
|
134 | - } |
|
135 | - |
|
136 | - /** |
|
137 | - * @return string |
|
138 | - */ |
|
139 | - public function getDefaultCurrencyControl() |
|
140 | - { |
|
141 | - $radio_box = '<input name="default_currency" value="' . $this->getVar('currencyid') . '" type="radio"'; |
|
142 | - if ($this->getVar('default_currency', 'e')) { |
|
143 | - $radio_box .= 'checked'; |
|
144 | - } |
|
145 | - $radio_box .= '>'; |
|
146 | - |
|
147 | - return $radio_box; |
|
148 | - } |
|
40 | + public $_modulePlugin = false; |
|
41 | + |
|
42 | + /** |
|
43 | + * SmartobjectCurrency constructor. |
|
44 | + */ |
|
45 | + public function __construct() |
|
46 | + { |
|
47 | + $this->quickInitVar('currencyid', XOBJ_DTYPE_INT, true); |
|
48 | + $this->quickInitVar('iso4217', XOBJ_DTYPE_TXTBOX, true, _CO_SOBJECT_CURRENCY_ISO4217, _CO_SOBJECT_CURRENCY_ISO4217_DSC); |
|
49 | + $this->quickInitVar('name', XOBJ_DTYPE_TXTBOX, true, _CO_SOBJECT_CURRENCY_NAME); |
|
50 | + $this->quickInitVar('symbol', XOBJ_DTYPE_TXTBOX, true, _CO_SOBJECT_CURRENCY_SYMBOL); |
|
51 | + $this->quickInitVar('rate', XOBJ_DTYPE_FLOAT, true, _CO_SOBJECT_CURRENCY_RATE, '', '1.0'); |
|
52 | + $this->quickInitVar('default_currency', XOBJ_DTYPE_INT, false, _CO_SOBJECT_CURRENCY_DEFAULT, '', false); |
|
53 | + |
|
54 | + $this->setControl('symbol', array( |
|
55 | + 'name' => 'text', |
|
56 | + 'size' => '15', |
|
57 | + 'maxlength' => '15' |
|
58 | + )); |
|
59 | + |
|
60 | + $this->setControl('iso4217', array( |
|
61 | + 'name' => 'text', |
|
62 | + 'size' => '5', |
|
63 | + 'maxlength' => '5' |
|
64 | + )); |
|
65 | + |
|
66 | + $this->setControl('rate', array( |
|
67 | + 'name' => 'text', |
|
68 | + 'size' => '5', |
|
69 | + 'maxlength' => '5' |
|
70 | + )); |
|
71 | + |
|
72 | + $this->setControl('rate', array( |
|
73 | + 'name' => 'text', |
|
74 | + 'size' => '5', |
|
75 | + 'maxlength' => '5' |
|
76 | + )); |
|
77 | + |
|
78 | + $this->hideFieldFromForm('default_currency'); |
|
79 | + } |
|
80 | + |
|
81 | + /** |
|
82 | + * @param string $key |
|
83 | + * @param string $format |
|
84 | + * @return mixed |
|
85 | + */ |
|
86 | + public function getVar($key, $format = 's') |
|
87 | + { |
|
88 | + if ($format === 's' && in_array($key, array('rate', 'default_currency'))) { |
|
89 | + // return call_user_func(array($this, $key)); |
|
90 | + return $this->{$key}(); |
|
91 | + } |
|
92 | + |
|
93 | + return parent::getVar($key, $format); |
|
94 | + } |
|
95 | + |
|
96 | + /** |
|
97 | + * @return mixed |
|
98 | + */ |
|
99 | + public function getCurrencyLink() |
|
100 | + { |
|
101 | + $ret = $this->getVar('name', 'e'); |
|
102 | + |
|
103 | + return $ret; |
|
104 | + } |
|
105 | + |
|
106 | + /** |
|
107 | + * @return mixed |
|
108 | + */ |
|
109 | + public function getCode() |
|
110 | + { |
|
111 | + $ret = $this->getVar('iso4217', 'e'); |
|
112 | + |
|
113 | + return $ret; |
|
114 | + } |
|
115 | + |
|
116 | + /** |
|
117 | + * @return float|int|mixed|string |
|
118 | + */ |
|
119 | + public function rate() |
|
120 | + { |
|
121 | + return smart_currency($this->getVar('rate', 'e')); |
|
122 | + } |
|
123 | + |
|
124 | + /** |
|
125 | + * @return string |
|
126 | + */ |
|
127 | + public function defaultCurrency() |
|
128 | + { |
|
129 | + if ($this->getVar('default_currency', 'e') === true) { |
|
130 | + return _YES; |
|
131 | + } else { |
|
132 | + return _NO; |
|
133 | + } |
|
134 | + } |
|
135 | + |
|
136 | + /** |
|
137 | + * @return string |
|
138 | + */ |
|
139 | + public function getDefaultCurrencyControl() |
|
140 | + { |
|
141 | + $radio_box = '<input name="default_currency" value="' . $this->getVar('currencyid') . '" type="radio"'; |
|
142 | + if ($this->getVar('default_currency', 'e')) { |
|
143 | + $radio_box .= 'checked'; |
|
144 | + } |
|
145 | + $radio_box .= '>'; |
|
146 | + |
|
147 | + return $radio_box; |
|
148 | + } |
|
149 | 149 | } |
150 | 150 | |
151 | 151 | /** |
@@ -153,22 +153,22 @@ discard block |
||
153 | 153 | */ |
154 | 154 | class SmartObjectCurrencyHandler extends SmartPersistableObjectHandler |
155 | 155 | { |
156 | - /** |
|
157 | - * SmartObjectCurrencyHandler constructor. |
|
158 | - * @param XoopsDatabase $db |
|
159 | - */ |
|
160 | - public function __construct(XoopsDatabase $db) |
|
161 | - { |
|
162 | - parent::__construct($db, 'currency', 'currencyid', 'name', '', 'smartobject'); |
|
163 | - } |
|
164 | - |
|
165 | - /** |
|
166 | - * @return array |
|
167 | - */ |
|
168 | - public function getCurrencies() |
|
169 | - { |
|
170 | - $currenciesObj = $this->getObjects(null, true); |
|
171 | - |
|
172 | - return $currenciesObj; |
|
173 | - } |
|
156 | + /** |
|
157 | + * SmartObjectCurrencyHandler constructor. |
|
158 | + * @param XoopsDatabase $db |
|
159 | + */ |
|
160 | + public function __construct(XoopsDatabase $db) |
|
161 | + { |
|
162 | + parent::__construct($db, 'currency', 'currencyid', 'name', '', 'smartobject'); |
|
163 | + } |
|
164 | + |
|
165 | + /** |
|
166 | + * @return array |
|
167 | + */ |
|
168 | + public function getCurrencies() |
|
169 | + { |
|
170 | + $currenciesObj = $this->getObjects(null, true); |
|
171 | + |
|
172 | + return $currenciesObj; |
|
173 | + } |
|
174 | 174 | } |
@@ -29,8 +29,8 @@ discard block |
||
29 | 29 | |
30 | 30 | // defined('XOOPS_ROOT_PATH') || exit('XOOPS root path not defined'); |
31 | 31 | |
32 | -require_once XOOPS_ROOT_PATH . '/modules/smartobject/class/smartobject.php'; |
|
33 | -require_once XOOPS_ROOT_PATH . '/class/xoopsformloader.php'; |
|
32 | +require_once XOOPS_ROOT_PATH.'/modules/smartobject/class/smartobject.php'; |
|
33 | +require_once XOOPS_ROOT_PATH.'/class/xoopsformloader.php'; |
|
34 | 34 | |
35 | 35 | /** |
36 | 36 | * Class SmartobjectCurrency |
@@ -138,7 +138,7 @@ discard block |
||
138 | 138 | */ |
139 | 139 | public function getDefaultCurrencyControl() |
140 | 140 | { |
141 | - $radio_box = '<input name="default_currency" value="' . $this->getVar('currencyid') . '" type="radio"'; |
|
141 | + $radio_box = '<input name="default_currency" value="'.$this->getVar('currencyid').'" type="radio"'; |
|
142 | 142 | if ($this->getVar('default_currency', 'e')) { |
143 | 143 | $radio_box .= 'checked'; |
144 | 144 | } |
@@ -29,7 +29,7 @@ |
||
29 | 29 | |
30 | 30 | // defined('XOOPS_ROOT_PATH') || exit('XOOPS root path not defined'); |
31 | 31 | |
32 | -require_once XOOPS_ROOT_PATH . '/modules/smartobject/class/smartobject.php'; |
|
32 | +require_once XOOPS_ROOT_PATH.'/modules/smartobject/class/smartobject.php'; |
|
33 | 33 | |
34 | 34 | /** |
35 | 35 | * Class SmartobjectBasedUrl |
@@ -29,7 +29,7 @@ discard block |
||
29 | 29 | |
30 | 30 | // defined('XOOPS_ROOT_PATH') || exit('XOOPS root path not defined'); |
31 | 31 | |
32 | -require_once XOOPS_ROOT_PATH . '/modules/smartobject/include/projax/projax.php'; |
|
32 | +require_once XOOPS_ROOT_PATH.'/modules/smartobject/include/projax/projax.php'; |
|
33 | 33 | |
34 | 34 | /** |
35 | 35 | * Class SmartJax |
@@ -39,7 +39,7 @@ discard block |
||
39 | 39 | public function initiateFromUserside() |
40 | 40 | { |
41 | 41 | global $xoTheme; |
42 | - $xoTheme->addScript(SMARTOBJECT_URL . 'include/projax/js/prototype.js'); |
|
43 | - $xoTheme->addScript(SMARTOBJECT_URL . 'include/projax/js/scriptaculous.js'); |
|
42 | + $xoTheme->addScript(SMARTOBJECT_URL.'include/projax/js/prototype.js'); |
|
43 | + $xoTheme->addScript(SMARTOBJECT_URL.'include/projax/js/scriptaculous.js'); |
|
44 | 44 | } |
45 | 45 | } |
@@ -36,227 +36,227 @@ discard block |
||
36 | 36 | */ |
37 | 37 | class SmartobjectCustomtag extends SmartObject |
38 | 38 | { |
39 | - public $content = false; |
|
40 | - |
|
41 | - /** |
|
42 | - * SmartobjectCustomtag constructor. |
|
43 | - */ |
|
44 | - public function __construct() |
|
45 | - { |
|
46 | - $this->quickInitVar('customtagid', XOBJ_DTYPE_INT, true); |
|
47 | - $this->quickInitVar('name', XOBJ_DTYPE_TXTBOX, true, _CO_SOBJECT_CUSTOMTAG_NAME, _CO_SOBJECT_CUSTOMTAG_NAME_DSC); |
|
48 | - $this->quickInitVar('description', XOBJ_DTYPE_TXTAREA, false, _CO_SOBJECT_CUSTOMTAG_DESCRIPTION, _CO_SOBJECT_CUSTOMTAG_DESCRIPTION_DSC); |
|
49 | - $this->quickInitVar('content', XOBJ_DTYPE_TXTAREA, true, _CO_SOBJECT_CUSTOMTAG_CONTENT, _CO_SOBJECT_CUSTOMTAG_CONTENT_DSC); |
|
50 | - $this->quickInitVar('language', XOBJ_DTYPE_TXTBOX, true, _CO_SOBJECT_CUSTOMTAG_LANGUAGE, _CO_SOBJECT_CUSTOMTAG_LANGUAGE_DSC); |
|
51 | - |
|
52 | - $this->initNonPersistableVar('dohtml', XOBJ_DTYPE_INT, 'class', 'dohtml', '', true); |
|
53 | - $this->initNonPersistableVar('doimage', XOBJ_DTYPE_INT, 'class', 'doimage', '', true); |
|
54 | - $this->initNonPersistableVar('doxcode', XOBJ_DTYPE_INT, 'class', 'doxcode', '', true); |
|
55 | - $this->initNonPersistableVar('dosmiley', XOBJ_DTYPE_INT, 'class', 'dosmiley', '', true); |
|
56 | - |
|
57 | - $this->setControl('content', array( |
|
58 | - 'name' => 'textarea', |
|
59 | - 'form_editor' => 'textarea', |
|
60 | - 'form_rows' => 25 |
|
61 | - )); |
|
62 | - $this->setControl('language', array( |
|
63 | - 'name' => 'language', |
|
64 | - 'all' => true |
|
65 | - )); |
|
66 | - } |
|
67 | - |
|
68 | - /** |
|
69 | - * @param string $key |
|
70 | - * @param string $format |
|
71 | - * @return mixed |
|
72 | - */ |
|
73 | - public function getVar($key, $format = 's') |
|
74 | - { |
|
75 | - if ($format === 's' && in_array($key, array())) { |
|
76 | - // return call_user_func(array($this, $key)); |
|
77 | - return $this->{$key}(); |
|
78 | - } |
|
79 | - |
|
80 | - return parent::getVar($key, $format); |
|
81 | - } |
|
82 | - |
|
83 | - /** |
|
84 | - * @return bool|mixed |
|
85 | - */ |
|
86 | - public function render() |
|
87 | - { |
|
88 | - if (!$this->content) { |
|
89 | - $ret = $this->getVar('content'); |
|
90 | - $this->content = $ret; |
|
91 | - } |
|
92 | - |
|
93 | - return $this->content; |
|
94 | - } |
|
95 | - |
|
96 | - /** |
|
97 | - * @return bool|mixed|string |
|
98 | - */ |
|
99 | - public function renderWithPhp() |
|
100 | - { |
|
101 | - if (!$this->content) { |
|
102 | - $ret = $this->getVar('content'); |
|
103 | - $this->content = $ret; |
|
104 | - } else { |
|
105 | - $ret = $this->content; |
|
106 | - } |
|
107 | - |
|
108 | - // check for PHP if we are not on admin side |
|
109 | - if (!defined('XOOPS_CPFUNC_LOADED') && !(strpos($ret, '[php]') === false)) { |
|
110 | - $ret = str_replace('[php]', '', $ret); |
|
111 | - // we have PHP code, let's evaluate |
|
112 | - eval($ret); |
|
113 | - |
|
114 | - return ''; |
|
115 | - } |
|
116 | - |
|
117 | - return $this->content; |
|
118 | - } |
|
119 | - |
|
120 | - /** |
|
121 | - * @return string |
|
122 | - */ |
|
123 | - public function getXoopsCode() |
|
124 | - { |
|
125 | - $ret = '[customtag]' . $this->getVar('tag', 'n') . '[/customtag]'; |
|
126 | - |
|
127 | - return $ret; |
|
128 | - } |
|
129 | - |
|
130 | - /** |
|
131 | - * @return string |
|
132 | - */ |
|
133 | - public function getCloneLink() |
|
134 | - { |
|
135 | - $ret = '<a href="' . SMARTOBJECT_URL . 'admin/customtag.php?op=clone&customtagid=' . $this->id() . '"><img src="' . SMARTOBJECT_IMAGES_ACTIONS_URL . 'editcopy.png" style="vertical-align: middle;" alt="' . _CO_SOBJECT_CUSTOMTAG_CLONE . '" title="' . _CO_SOBJECT_CUSTOMTAG_CLONE . '"></a>'; |
|
136 | - |
|
137 | - return $ret; |
|
138 | - } |
|
139 | - |
|
140 | - /** |
|
141 | - * @param $var |
|
142 | - * @return bool |
|
143 | - */ |
|
144 | - public function emptyString($var) |
|
145 | - { |
|
146 | - return (strlen($var) > 0); |
|
147 | - } |
|
148 | - |
|
149 | - /** |
|
150 | - * @return mixed|string |
|
151 | - */ |
|
152 | - public function generateTag() |
|
153 | - { |
|
154 | - $title = rawurlencode(strtolower($this->getVar('description', 'e'))); |
|
155 | - $title = xoops_substr($title, 0, 10, ''); |
|
156 | - // Transformation des ponctuations |
|
157 | - $pattern = array( |
|
158 | - '/%09/', // Tab |
|
159 | - '/%20/', // Space |
|
160 | - '/%21/', // ! |
|
161 | - '/%22/', // " |
|
162 | - '/%23/', // # |
|
163 | - '/%25/', // % |
|
164 | - '/%26/', // & |
|
165 | - '/%27/', // ' |
|
166 | - '/%28/', // ( |
|
167 | - '/%29/', // ) |
|
168 | - '/%2C/', // , |
|
169 | - '/%2F/', // / |
|
170 | - '/%3A/', // : |
|
171 | - '/%3B/', // ; |
|
172 | - '/%3C/', // < |
|
173 | - '/%3D/', // = |
|
174 | - '/%3E/', // > |
|
175 | - '/%3F/', // ? |
|
176 | - '/%40/', // @ |
|
177 | - '/%5B/', // [ |
|
178 | - '/%5C/', // \ |
|
179 | - '/%5D/', // ] |
|
180 | - '/%5E/', // ^ |
|
181 | - '/%7B/', // { |
|
182 | - '/%7C/', // | |
|
183 | - '/%7D/', // } |
|
184 | - '/%7E/', // ~ |
|
185 | - "/\./" // . |
|
186 | - ); |
|
187 | - $rep_pat = array( |
|
188 | - '-', |
|
189 | - '-', |
|
190 | - '-', |
|
191 | - '-', |
|
192 | - '-', |
|
193 | - '-100', |
|
194 | - '-', |
|
195 | - '-', |
|
196 | - '-', |
|
197 | - '-', |
|
198 | - '-', |
|
199 | - '-', |
|
200 | - '-', |
|
201 | - '-', |
|
202 | - '-', |
|
203 | - '-', |
|
204 | - '-', |
|
205 | - '-', |
|
206 | - '-at-', |
|
207 | - '-', |
|
208 | - '-', |
|
209 | - '-', |
|
210 | - '-', |
|
211 | - '-', |
|
212 | - '-', |
|
213 | - '-', |
|
214 | - '-', |
|
215 | - '-' |
|
216 | - ); |
|
217 | - $title = preg_replace($pattern, $rep_pat, $title); |
|
218 | - |
|
219 | - // Transformation des caractères accentués |
|
220 | - $pattern = array( |
|
221 | - '/%B0/', // ° |
|
222 | - '/%E8/', // è |
|
223 | - '/%E9/', // é |
|
224 | - '/%EA/', // ê |
|
225 | - '/%EB/', // ë |
|
226 | - '/%E7/', // ç |
|
227 | - '/%E0/', // à |
|
228 | - '/%E2/', // â |
|
229 | - '/%E4/', // ä |
|
230 | - '/%EE/', // î |
|
231 | - '/%EF/', // ï |
|
232 | - '/%F9/', // ù |
|
233 | - '/%FC/', // ü |
|
234 | - '/%FB/', // û |
|
235 | - '/%F4/', // ô |
|
236 | - '/%F6/', // ö |
|
237 | - ); |
|
238 | - $rep_pat = array('-', 'e', 'e', 'e', 'e', 'c', 'a', 'a', 'a', 'i', 'i', 'u', 'u', 'u', 'o', 'o'); |
|
239 | - $title = preg_replace($pattern, $rep_pat, $title); |
|
240 | - |
|
241 | - $tableau = explode('-', $title); // Transforme la chaine de caract�res en tableau |
|
242 | - $tableau = array_filter($tableau, array($this, 'emptyString')); // Supprime les chaines vides du tableau |
|
243 | - $title = implode('-', $tableau); // Transforme un tableau en chaine de caract�res s�par� par un tiret |
|
244 | - |
|
245 | - $title .= time(); |
|
246 | - $title = md5($title); |
|
247 | - |
|
248 | - return $title; |
|
249 | - } |
|
250 | - |
|
251 | - /** |
|
252 | - * @return mixed |
|
253 | - */ |
|
254 | - public function getCustomtagName() |
|
255 | - { |
|
256 | - $ret = $this->getVar('name'); |
|
257 | - |
|
258 | - return $ret; |
|
259 | - } |
|
39 | + public $content = false; |
|
40 | + |
|
41 | + /** |
|
42 | + * SmartobjectCustomtag constructor. |
|
43 | + */ |
|
44 | + public function __construct() |
|
45 | + { |
|
46 | + $this->quickInitVar('customtagid', XOBJ_DTYPE_INT, true); |
|
47 | + $this->quickInitVar('name', XOBJ_DTYPE_TXTBOX, true, _CO_SOBJECT_CUSTOMTAG_NAME, _CO_SOBJECT_CUSTOMTAG_NAME_DSC); |
|
48 | + $this->quickInitVar('description', XOBJ_DTYPE_TXTAREA, false, _CO_SOBJECT_CUSTOMTAG_DESCRIPTION, _CO_SOBJECT_CUSTOMTAG_DESCRIPTION_DSC); |
|
49 | + $this->quickInitVar('content', XOBJ_DTYPE_TXTAREA, true, _CO_SOBJECT_CUSTOMTAG_CONTENT, _CO_SOBJECT_CUSTOMTAG_CONTENT_DSC); |
|
50 | + $this->quickInitVar('language', XOBJ_DTYPE_TXTBOX, true, _CO_SOBJECT_CUSTOMTAG_LANGUAGE, _CO_SOBJECT_CUSTOMTAG_LANGUAGE_DSC); |
|
51 | + |
|
52 | + $this->initNonPersistableVar('dohtml', XOBJ_DTYPE_INT, 'class', 'dohtml', '', true); |
|
53 | + $this->initNonPersistableVar('doimage', XOBJ_DTYPE_INT, 'class', 'doimage', '', true); |
|
54 | + $this->initNonPersistableVar('doxcode', XOBJ_DTYPE_INT, 'class', 'doxcode', '', true); |
|
55 | + $this->initNonPersistableVar('dosmiley', XOBJ_DTYPE_INT, 'class', 'dosmiley', '', true); |
|
56 | + |
|
57 | + $this->setControl('content', array( |
|
58 | + 'name' => 'textarea', |
|
59 | + 'form_editor' => 'textarea', |
|
60 | + 'form_rows' => 25 |
|
61 | + )); |
|
62 | + $this->setControl('language', array( |
|
63 | + 'name' => 'language', |
|
64 | + 'all' => true |
|
65 | + )); |
|
66 | + } |
|
67 | + |
|
68 | + /** |
|
69 | + * @param string $key |
|
70 | + * @param string $format |
|
71 | + * @return mixed |
|
72 | + */ |
|
73 | + public function getVar($key, $format = 's') |
|
74 | + { |
|
75 | + if ($format === 's' && in_array($key, array())) { |
|
76 | + // return call_user_func(array($this, $key)); |
|
77 | + return $this->{$key}(); |
|
78 | + } |
|
79 | + |
|
80 | + return parent::getVar($key, $format); |
|
81 | + } |
|
82 | + |
|
83 | + /** |
|
84 | + * @return bool|mixed |
|
85 | + */ |
|
86 | + public function render() |
|
87 | + { |
|
88 | + if (!$this->content) { |
|
89 | + $ret = $this->getVar('content'); |
|
90 | + $this->content = $ret; |
|
91 | + } |
|
92 | + |
|
93 | + return $this->content; |
|
94 | + } |
|
95 | + |
|
96 | + /** |
|
97 | + * @return bool|mixed|string |
|
98 | + */ |
|
99 | + public function renderWithPhp() |
|
100 | + { |
|
101 | + if (!$this->content) { |
|
102 | + $ret = $this->getVar('content'); |
|
103 | + $this->content = $ret; |
|
104 | + } else { |
|
105 | + $ret = $this->content; |
|
106 | + } |
|
107 | + |
|
108 | + // check for PHP if we are not on admin side |
|
109 | + if (!defined('XOOPS_CPFUNC_LOADED') && !(strpos($ret, '[php]') === false)) { |
|
110 | + $ret = str_replace('[php]', '', $ret); |
|
111 | + // we have PHP code, let's evaluate |
|
112 | + eval($ret); |
|
113 | + |
|
114 | + return ''; |
|
115 | + } |
|
116 | + |
|
117 | + return $this->content; |
|
118 | + } |
|
119 | + |
|
120 | + /** |
|
121 | + * @return string |
|
122 | + */ |
|
123 | + public function getXoopsCode() |
|
124 | + { |
|
125 | + $ret = '[customtag]' . $this->getVar('tag', 'n') . '[/customtag]'; |
|
126 | + |
|
127 | + return $ret; |
|
128 | + } |
|
129 | + |
|
130 | + /** |
|
131 | + * @return string |
|
132 | + */ |
|
133 | + public function getCloneLink() |
|
134 | + { |
|
135 | + $ret = '<a href="' . SMARTOBJECT_URL . 'admin/customtag.php?op=clone&customtagid=' . $this->id() . '"><img src="' . SMARTOBJECT_IMAGES_ACTIONS_URL . 'editcopy.png" style="vertical-align: middle;" alt="' . _CO_SOBJECT_CUSTOMTAG_CLONE . '" title="' . _CO_SOBJECT_CUSTOMTAG_CLONE . '"></a>'; |
|
136 | + |
|
137 | + return $ret; |
|
138 | + } |
|
139 | + |
|
140 | + /** |
|
141 | + * @param $var |
|
142 | + * @return bool |
|
143 | + */ |
|
144 | + public function emptyString($var) |
|
145 | + { |
|
146 | + return (strlen($var) > 0); |
|
147 | + } |
|
148 | + |
|
149 | + /** |
|
150 | + * @return mixed|string |
|
151 | + */ |
|
152 | + public function generateTag() |
|
153 | + { |
|
154 | + $title = rawurlencode(strtolower($this->getVar('description', 'e'))); |
|
155 | + $title = xoops_substr($title, 0, 10, ''); |
|
156 | + // Transformation des ponctuations |
|
157 | + $pattern = array( |
|
158 | + '/%09/', // Tab |
|
159 | + '/%20/', // Space |
|
160 | + '/%21/', // ! |
|
161 | + '/%22/', // " |
|
162 | + '/%23/', // # |
|
163 | + '/%25/', // % |
|
164 | + '/%26/', // & |
|
165 | + '/%27/', // ' |
|
166 | + '/%28/', // ( |
|
167 | + '/%29/', // ) |
|
168 | + '/%2C/', // , |
|
169 | + '/%2F/', // / |
|
170 | + '/%3A/', // : |
|
171 | + '/%3B/', // ; |
|
172 | + '/%3C/', // < |
|
173 | + '/%3D/', // = |
|
174 | + '/%3E/', // > |
|
175 | + '/%3F/', // ? |
|
176 | + '/%40/', // @ |
|
177 | + '/%5B/', // [ |
|
178 | + '/%5C/', // \ |
|
179 | + '/%5D/', // ] |
|
180 | + '/%5E/', // ^ |
|
181 | + '/%7B/', // { |
|
182 | + '/%7C/', // | |
|
183 | + '/%7D/', // } |
|
184 | + '/%7E/', // ~ |
|
185 | + "/\./" // . |
|
186 | + ); |
|
187 | + $rep_pat = array( |
|
188 | + '-', |
|
189 | + '-', |
|
190 | + '-', |
|
191 | + '-', |
|
192 | + '-', |
|
193 | + '-100', |
|
194 | + '-', |
|
195 | + '-', |
|
196 | + '-', |
|
197 | + '-', |
|
198 | + '-', |
|
199 | + '-', |
|
200 | + '-', |
|
201 | + '-', |
|
202 | + '-', |
|
203 | + '-', |
|
204 | + '-', |
|
205 | + '-', |
|
206 | + '-at-', |
|
207 | + '-', |
|
208 | + '-', |
|
209 | + '-', |
|
210 | + '-', |
|
211 | + '-', |
|
212 | + '-', |
|
213 | + '-', |
|
214 | + '-', |
|
215 | + '-' |
|
216 | + ); |
|
217 | + $title = preg_replace($pattern, $rep_pat, $title); |
|
218 | + |
|
219 | + // Transformation des caractères accentués |
|
220 | + $pattern = array( |
|
221 | + '/%B0/', // ° |
|
222 | + '/%E8/', // è |
|
223 | + '/%E9/', // é |
|
224 | + '/%EA/', // ê |
|
225 | + '/%EB/', // ë |
|
226 | + '/%E7/', // ç |
|
227 | + '/%E0/', // à |
|
228 | + '/%E2/', // â |
|
229 | + '/%E4/', // ä |
|
230 | + '/%EE/', // î |
|
231 | + '/%EF/', // ï |
|
232 | + '/%F9/', // ù |
|
233 | + '/%FC/', // ü |
|
234 | + '/%FB/', // û |
|
235 | + '/%F4/', // ô |
|
236 | + '/%F6/', // ö |
|
237 | + ); |
|
238 | + $rep_pat = array('-', 'e', 'e', 'e', 'e', 'c', 'a', 'a', 'a', 'i', 'i', 'u', 'u', 'u', 'o', 'o'); |
|
239 | + $title = preg_replace($pattern, $rep_pat, $title); |
|
240 | + |
|
241 | + $tableau = explode('-', $title); // Transforme la chaine de caract�res en tableau |
|
242 | + $tableau = array_filter($tableau, array($this, 'emptyString')); // Supprime les chaines vides du tableau |
|
243 | + $title = implode('-', $tableau); // Transforme un tableau en chaine de caract�res s�par� par un tiret |
|
244 | + |
|
245 | + $title .= time(); |
|
246 | + $title = md5($title); |
|
247 | + |
|
248 | + return $title; |
|
249 | + } |
|
250 | + |
|
251 | + /** |
|
252 | + * @return mixed |
|
253 | + */ |
|
254 | + public function getCustomtagName() |
|
255 | + { |
|
256 | + $ret = $this->getVar('name'); |
|
257 | + |
|
258 | + return $ret; |
|
259 | + } |
|
260 | 260 | } |
261 | 261 | |
262 | 262 | /** |
@@ -264,48 +264,48 @@ discard block |
||
264 | 264 | */ |
265 | 265 | class SmartobjectCustomtagHandler extends SmartPersistableObjectHandler |
266 | 266 | { |
267 | - public $objects = false; |
|
268 | - |
|
269 | - /** |
|
270 | - * SmartobjectCustomtagHandler constructor. |
|
271 | - * @param XoopsDatabase $db |
|
272 | - */ |
|
273 | - public function __construct(XoopsDatabase $db) |
|
274 | - { |
|
275 | - parent::__construct($db, 'customtag', 'customtagid', 'name', 'description', 'smartobject'); |
|
276 | - $this->addPermission('view', _CO_SOBJECT_CUSTOMTAG_PERMISSION_VIEW, _CO_SOBJECT_CUSTOMTAG_PERMISSION_VIEW_DSC); |
|
277 | - } |
|
278 | - |
|
279 | - /** |
|
280 | - * @return array|bool |
|
281 | - */ |
|
282 | - public function getCustomtagsByName() |
|
283 | - { |
|
284 | - if (!$this->objects) { |
|
285 | - global $xoopsConfig; |
|
286 | - |
|
287 | - $ret = array(); |
|
288 | - |
|
289 | - $criteria = new CriteriaCompo(); |
|
290 | - |
|
291 | - $criteria_language = new CriteriaCompo(); |
|
292 | - $criteria_language->add(new Criteria('language', $xoopsConfig['language'])); |
|
293 | - $criteria_language->add(new Criteria('language', 'all'), 'OR'); |
|
294 | - $criteria->add($criteria_language); |
|
295 | - |
|
296 | - $smartobjectPermissionsHandler = new SmartObjectPermissionHandler($this); |
|
297 | - $granted_ids = $smartobjectPermissionsHandler->getGrantedItems('view'); |
|
298 | - |
|
299 | - if ($granted_ids && count($granted_ids) > 0) { |
|
300 | - $criteria->add(new Criteria('customtagid', '(' . implode(', ', $granted_ids) . ')', 'IN')); |
|
301 | - $customtagsObj = $this->getObjects($criteria, true); |
|
302 | - foreach ($customtagsObj as $customtagObj) { |
|
303 | - $ret[$customtagObj->getVar('name')] = $customtagObj; |
|
304 | - } |
|
305 | - } |
|
306 | - $this->objects = $ret; |
|
307 | - } |
|
308 | - |
|
309 | - return $this->objects; |
|
310 | - } |
|
267 | + public $objects = false; |
|
268 | + |
|
269 | + /** |
|
270 | + * SmartobjectCustomtagHandler constructor. |
|
271 | + * @param XoopsDatabase $db |
|
272 | + */ |
|
273 | + public function __construct(XoopsDatabase $db) |
|
274 | + { |
|
275 | + parent::__construct($db, 'customtag', 'customtagid', 'name', 'description', 'smartobject'); |
|
276 | + $this->addPermission('view', _CO_SOBJECT_CUSTOMTAG_PERMISSION_VIEW, _CO_SOBJECT_CUSTOMTAG_PERMISSION_VIEW_DSC); |
|
277 | + } |
|
278 | + |
|
279 | + /** |
|
280 | + * @return array|bool |
|
281 | + */ |
|
282 | + public function getCustomtagsByName() |
|
283 | + { |
|
284 | + if (!$this->objects) { |
|
285 | + global $xoopsConfig; |
|
286 | + |
|
287 | + $ret = array(); |
|
288 | + |
|
289 | + $criteria = new CriteriaCompo(); |
|
290 | + |
|
291 | + $criteria_language = new CriteriaCompo(); |
|
292 | + $criteria_language->add(new Criteria('language', $xoopsConfig['language'])); |
|
293 | + $criteria_language->add(new Criteria('language', 'all'), 'OR'); |
|
294 | + $criteria->add($criteria_language); |
|
295 | + |
|
296 | + $smartobjectPermissionsHandler = new SmartObjectPermissionHandler($this); |
|
297 | + $granted_ids = $smartobjectPermissionsHandler->getGrantedItems('view'); |
|
298 | + |
|
299 | + if ($granted_ids && count($granted_ids) > 0) { |
|
300 | + $criteria->add(new Criteria('customtagid', '(' . implode(', ', $granted_ids) . ')', 'IN')); |
|
301 | + $customtagsObj = $this->getObjects($criteria, true); |
|
302 | + foreach ($customtagsObj as $customtagObj) { |
|
303 | + $ret[$customtagObj->getVar('name')] = $customtagObj; |
|
304 | + } |
|
305 | + } |
|
306 | + $this->objects = $ret; |
|
307 | + } |
|
308 | + |
|
309 | + return $this->objects; |
|
310 | + } |
|
311 | 311 | } |
@@ -29,7 +29,7 @@ discard block |
||
29 | 29 | |
30 | 30 | // defined('XOOPS_ROOT_PATH') || exit('XOOPS root path not defined'); |
31 | 31 | |
32 | -require_once XOOPS_ROOT_PATH . '/modules/smartobject/class/smartobject.php'; |
|
32 | +require_once XOOPS_ROOT_PATH.'/modules/smartobject/class/smartobject.php'; |
|
33 | 33 | |
34 | 34 | /** |
35 | 35 | * Class SmartobjectCustomtag |
@@ -122,7 +122,7 @@ discard block |
||
122 | 122 | */ |
123 | 123 | public function getXoopsCode() |
124 | 124 | { |
125 | - $ret = '[customtag]' . $this->getVar('tag', 'n') . '[/customtag]'; |
|
125 | + $ret = '[customtag]'.$this->getVar('tag', 'n').'[/customtag]'; |
|
126 | 126 | |
127 | 127 | return $ret; |
128 | 128 | } |
@@ -132,7 +132,7 @@ discard block |
||
132 | 132 | */ |
133 | 133 | public function getCloneLink() |
134 | 134 | { |
135 | - $ret = '<a href="' . SMARTOBJECT_URL . 'admin/customtag.php?op=clone&customtagid=' . $this->id() . '"><img src="' . SMARTOBJECT_IMAGES_ACTIONS_URL . 'editcopy.png" style="vertical-align: middle;" alt="' . _CO_SOBJECT_CUSTOMTAG_CLONE . '" title="' . _CO_SOBJECT_CUSTOMTAG_CLONE . '"></a>'; |
|
135 | + $ret = '<a href="'.SMARTOBJECT_URL.'admin/customtag.php?op=clone&customtagid='.$this->id().'"><img src="'.SMARTOBJECT_IMAGES_ACTIONS_URL.'editcopy.png" style="vertical-align: middle;" alt="'._CO_SOBJECT_CUSTOMTAG_CLONE.'" title="'._CO_SOBJECT_CUSTOMTAG_CLONE.'"></a>'; |
|
136 | 136 | |
137 | 137 | return $ret; |
138 | 138 | } |
@@ -297,7 +297,7 @@ discard block |
||
297 | 297 | $granted_ids = $smartobjectPermissionsHandler->getGrantedItems('view'); |
298 | 298 | |
299 | 299 | if ($granted_ids && count($granted_ids) > 0) { |
300 | - $criteria->add(new Criteria('customtagid', '(' . implode(', ', $granted_ids) . ')', 'IN')); |
|
300 | + $criteria->add(new Criteria('customtagid', '('.implode(', ', $granted_ids).')', 'IN')); |
|
301 | 301 | $customtagsObj = $this->getObjects($criteria, true); |
302 | 302 | foreach ($customtagsObj as $customtagObj) { |
303 | 303 | $ret[$customtagObj->getVar('name')] = $customtagObj; |
@@ -35,154 +35,154 @@ discard block |
||
35 | 35 | */ |
36 | 36 | class SmartobjectLink extends SmartObject |
37 | 37 | { |
38 | - /** |
|
39 | - * SmartobjectLink constructor. |
|
40 | - */ |
|
41 | - public function __construct() |
|
42 | - { |
|
43 | - $this->initVar('linkid', XOBJ_DTYPE_INT, '', true); |
|
44 | - $this->initVar('date', XOBJ_DTYPE_INT, 0, false, null, '', false, _CO_SOBJECT_LINK_DATE, '', true, true, false); |
|
45 | - $this->initVar('from_uid', XOBJ_DTYPE_INT, '', false, null, '', false, _CO_SOBJECT_LINK_FROM_UID, _CO_SOBJECT_LINK_FROM_UID_DSC); |
|
46 | - $this->initVar('from_email', XOBJ_DTYPE_TXTBOX, '', true, 255, '', false, _CO_SOBJECT_LINK_FROM_EMAIL, _CO_SOBJECT_LINK_FROM_EMAIL_DSC, true); |
|
47 | - $this->initVar('from_name', XOBJ_DTYPE_TXTBOX, '', true, 255, '', false, _CO_SOBJECT_LINK_FROM_NAME, _CO_SOBJECT_LINK_FROM_NAME_DSC, true); |
|
48 | - $this->initVar('to_uid', XOBJ_DTYPE_INT, '', false, null, '', false, _CO_SOBJECT_LINK_TO_UID, _CO_SOBJECT_LINK_TO_UID_DSC); |
|
49 | - $this->initVar('to_email', XOBJ_DTYPE_TXTBOX, '', true, 255, '', false, _CO_SOBJECT_LINK_TO_EMAIL, _CO_SOBJECT_LINK_TO_EMAIL_DSC, true); |
|
50 | - $this->initVar('to_name', XOBJ_DTYPE_TXTBOX, '', true, 255, '', false, _CO_SOBJECT_LINK_TO_NAME, _CO_SOBJECT_LINK_TO_NAME_DSC, true); |
|
51 | - $this->initVar('link', XOBJ_DTYPE_TXTBOX, '', false, 255, '', false, _CO_SOBJECT_LINK_LINK, _CO_SOBJECT_LINK_LINK_DSC, true); |
|
52 | - $this->initVar('subject', XOBJ_DTYPE_TXTBOX, '', true, 255, '', false, _CO_SOBJECT_LINK_SUBJECT, _CO_SOBJECT_LINK_SUBJECT_DSC, true); |
|
53 | - $this->initVar('body', XOBJ_DTYPE_TXTAREA, '', true, null, '', false, _CO_SOBJECT_LINK_BODY, _CO_SOBJECT_LINK_BODY_DSC); |
|
54 | - $this->initVar('mid', XOBJ_DTYPE_INT, '', false, null, '', false, _CO_SOBJECT_LINK_MID, _CO_SOBJECT_LINK_MID_DSC); |
|
55 | - $this->initVar('mid_name', XOBJ_DTYPE_TXTBOX, '', false, 255, '', false, _CO_SOBJECT_LINK_MID_NAME, _CO_SOBJECT_LINK_MID_NAME_DSC, true); |
|
56 | - } |
|
57 | - |
|
58 | - /** |
|
59 | - * returns a specific variable for the object in a proper format |
|
60 | - * |
|
61 | - * @access public |
|
62 | - * @param string $key key of the object's variable to be returned |
|
63 | - * @param string $format format to use for the output |
|
64 | - * @return mixed formatted value of the variable |
|
65 | - */ |
|
66 | - public function getVar($key, $format = 's') |
|
67 | - { |
|
68 | - if ($format === 's' && in_array($key, array('from_uid', 'to_uid', 'date', 'link'))) { |
|
69 | - // return call_user_func(array($this, $key)); |
|
70 | - return $this->{$key}(); |
|
71 | - } |
|
72 | - |
|
73 | - return parent::getVar($key, $format); |
|
74 | - } |
|
75 | - |
|
76 | - /** |
|
77 | - * @return string |
|
78 | - */ |
|
79 | - public function from_uid() |
|
80 | - { |
|
81 | - $ret = smart_getLinkedUnameFromId($this->getVar('from_uid', 'e'), 1, null, true); |
|
82 | - |
|
83 | - return $ret; |
|
84 | - } |
|
85 | - |
|
86 | - /** |
|
87 | - * @param bool $withContact |
|
88 | - * @return string |
|
89 | - */ |
|
90 | - public function to_uid($withContact = false) |
|
91 | - { |
|
92 | - $ret = smart_getLinkedUnameFromId($this->getVar('to_uid', 'e'), 1, null, true); |
|
93 | - |
|
94 | - return $ret; |
|
95 | - } |
|
96 | - |
|
97 | - /** |
|
98 | - * @return string |
|
99 | - */ |
|
100 | - public function date() |
|
101 | - { |
|
102 | - $ret = formatTimestamp($this->getVar('date', 'e')); |
|
103 | - |
|
104 | - return $ret; |
|
105 | - } |
|
106 | - |
|
107 | - /** |
|
108 | - * @param bool $full |
|
109 | - * @return mixed|string |
|
110 | - */ |
|
111 | - public function link($full = false) |
|
112 | - { |
|
113 | - $ret = $this->getVar('link', 'e'); |
|
114 | - if ($full) { |
|
115 | - $myts = MyTextSanitizer::getInstance(); |
|
116 | - $ret = $myts->displayTarea($ret); |
|
117 | - |
|
118 | - return $ret; |
|
119 | - } else { |
|
120 | - $ret = '<a href="' . $ret . '" alt="' . $this->getVar('link', 'e') . '" title="' . $this->getVar('link', 'e') . '">' . _AM_SOBJECT_SENT_LINKS_GOTO . '</a>'; |
|
121 | - |
|
122 | - return $ret; |
|
123 | - } |
|
124 | - } |
|
125 | - |
|
126 | - /** |
|
127 | - * @return string |
|
128 | - */ |
|
129 | - public function getViewItemLink() |
|
130 | - { |
|
131 | - $ret = '<a href="' . SMARTOBJECT_URL . 'admin/link.php?op=view&linkid=' . $this->getVar('linkid') . '"><img src="' . SMARTOBJECT_IMAGES_ACTIONS_URL . 'mail_find.png" alt="' . _AM_SOBJECT_SENT_LINK_VIEW . '" title="' . _AM_SOBJECT_SENT_LINK_VIEW . '"></a>'; |
|
132 | - |
|
133 | - return $ret; |
|
134 | - } |
|
135 | - |
|
136 | - /** |
|
137 | - * @return string |
|
138 | - */ |
|
139 | - public function getFromInfo() |
|
140 | - { |
|
141 | - // check if from_uid represent a user |
|
142 | - |
|
143 | - if ($this->getVar('from_uid')) { |
|
144 | - $user = smart_getLinkedUnameFromId($this->getVar('from_uid')); |
|
145 | - if ($user == $GLOBALS['xoopsConfig']['anonymous']) { |
|
146 | - $user = '<a href="mailto:' . $this->getVar('from_email') . '">' . $this->getVar('from_email') . '</a>'; |
|
147 | - } |
|
148 | - } else { |
|
149 | - $user = '<a href="mailto:' . $this->getVar('from_email') . '">' . $this->getVar('from_email') . '</a>'; |
|
150 | - } |
|
151 | - |
|
152 | - return $user; |
|
153 | - } |
|
154 | - |
|
155 | - /** |
|
156 | - * @return array |
|
157 | - */ |
|
158 | - public function toArray() |
|
159 | - { |
|
160 | - $ret = parent::toArray(); |
|
161 | - $ret['fromInfo'] = $this->getFromInfo(); |
|
162 | - $ret['toInfo'] = $this->getToInfo(); |
|
163 | - $ret['fullLink'] = $this->link(true); |
|
164 | - |
|
165 | - return $ret; |
|
166 | - } |
|
167 | - |
|
168 | - /** |
|
169 | - * @return string |
|
170 | - */ |
|
171 | - public function getToInfo() |
|
172 | - { |
|
173 | - // check if from_uid represent a user |
|
174 | - |
|
175 | - if ($this->getVar('to_uid')) { |
|
176 | - $user = smart_getLinkedUnameFromId($this->getVar('to_uid')); |
|
177 | - if ($user == $GLOBALS['xoopsConfig']['anonymous']) { |
|
178 | - $user = '<a href="mailto:' . $this->getVar('to_email') . '">' . $this->getVar('to_email') . '</a>'; |
|
179 | - } |
|
180 | - } else { |
|
181 | - $user = '<a href="mailto:' . $this->getVar('to_email') . '">' . $this->getVar('to_email') . '</a>'; |
|
182 | - } |
|
183 | - |
|
184 | - return $user; |
|
185 | - } |
|
38 | + /** |
|
39 | + * SmartobjectLink constructor. |
|
40 | + */ |
|
41 | + public function __construct() |
|
42 | + { |
|
43 | + $this->initVar('linkid', XOBJ_DTYPE_INT, '', true); |
|
44 | + $this->initVar('date', XOBJ_DTYPE_INT, 0, false, null, '', false, _CO_SOBJECT_LINK_DATE, '', true, true, false); |
|
45 | + $this->initVar('from_uid', XOBJ_DTYPE_INT, '', false, null, '', false, _CO_SOBJECT_LINK_FROM_UID, _CO_SOBJECT_LINK_FROM_UID_DSC); |
|
46 | + $this->initVar('from_email', XOBJ_DTYPE_TXTBOX, '', true, 255, '', false, _CO_SOBJECT_LINK_FROM_EMAIL, _CO_SOBJECT_LINK_FROM_EMAIL_DSC, true); |
|
47 | + $this->initVar('from_name', XOBJ_DTYPE_TXTBOX, '', true, 255, '', false, _CO_SOBJECT_LINK_FROM_NAME, _CO_SOBJECT_LINK_FROM_NAME_DSC, true); |
|
48 | + $this->initVar('to_uid', XOBJ_DTYPE_INT, '', false, null, '', false, _CO_SOBJECT_LINK_TO_UID, _CO_SOBJECT_LINK_TO_UID_DSC); |
|
49 | + $this->initVar('to_email', XOBJ_DTYPE_TXTBOX, '', true, 255, '', false, _CO_SOBJECT_LINK_TO_EMAIL, _CO_SOBJECT_LINK_TO_EMAIL_DSC, true); |
|
50 | + $this->initVar('to_name', XOBJ_DTYPE_TXTBOX, '', true, 255, '', false, _CO_SOBJECT_LINK_TO_NAME, _CO_SOBJECT_LINK_TO_NAME_DSC, true); |
|
51 | + $this->initVar('link', XOBJ_DTYPE_TXTBOX, '', false, 255, '', false, _CO_SOBJECT_LINK_LINK, _CO_SOBJECT_LINK_LINK_DSC, true); |
|
52 | + $this->initVar('subject', XOBJ_DTYPE_TXTBOX, '', true, 255, '', false, _CO_SOBJECT_LINK_SUBJECT, _CO_SOBJECT_LINK_SUBJECT_DSC, true); |
|
53 | + $this->initVar('body', XOBJ_DTYPE_TXTAREA, '', true, null, '', false, _CO_SOBJECT_LINK_BODY, _CO_SOBJECT_LINK_BODY_DSC); |
|
54 | + $this->initVar('mid', XOBJ_DTYPE_INT, '', false, null, '', false, _CO_SOBJECT_LINK_MID, _CO_SOBJECT_LINK_MID_DSC); |
|
55 | + $this->initVar('mid_name', XOBJ_DTYPE_TXTBOX, '', false, 255, '', false, _CO_SOBJECT_LINK_MID_NAME, _CO_SOBJECT_LINK_MID_NAME_DSC, true); |
|
56 | + } |
|
57 | + |
|
58 | + /** |
|
59 | + * returns a specific variable for the object in a proper format |
|
60 | + * |
|
61 | + * @access public |
|
62 | + * @param string $key key of the object's variable to be returned |
|
63 | + * @param string $format format to use for the output |
|
64 | + * @return mixed formatted value of the variable |
|
65 | + */ |
|
66 | + public function getVar($key, $format = 's') |
|
67 | + { |
|
68 | + if ($format === 's' && in_array($key, array('from_uid', 'to_uid', 'date', 'link'))) { |
|
69 | + // return call_user_func(array($this, $key)); |
|
70 | + return $this->{$key}(); |
|
71 | + } |
|
72 | + |
|
73 | + return parent::getVar($key, $format); |
|
74 | + } |
|
75 | + |
|
76 | + /** |
|
77 | + * @return string |
|
78 | + */ |
|
79 | + public function from_uid() |
|
80 | + { |
|
81 | + $ret = smart_getLinkedUnameFromId($this->getVar('from_uid', 'e'), 1, null, true); |
|
82 | + |
|
83 | + return $ret; |
|
84 | + } |
|
85 | + |
|
86 | + /** |
|
87 | + * @param bool $withContact |
|
88 | + * @return string |
|
89 | + */ |
|
90 | + public function to_uid($withContact = false) |
|
91 | + { |
|
92 | + $ret = smart_getLinkedUnameFromId($this->getVar('to_uid', 'e'), 1, null, true); |
|
93 | + |
|
94 | + return $ret; |
|
95 | + } |
|
96 | + |
|
97 | + /** |
|
98 | + * @return string |
|
99 | + */ |
|
100 | + public function date() |
|
101 | + { |
|
102 | + $ret = formatTimestamp($this->getVar('date', 'e')); |
|
103 | + |
|
104 | + return $ret; |
|
105 | + } |
|
106 | + |
|
107 | + /** |
|
108 | + * @param bool $full |
|
109 | + * @return mixed|string |
|
110 | + */ |
|
111 | + public function link($full = false) |
|
112 | + { |
|
113 | + $ret = $this->getVar('link', 'e'); |
|
114 | + if ($full) { |
|
115 | + $myts = MyTextSanitizer::getInstance(); |
|
116 | + $ret = $myts->displayTarea($ret); |
|
117 | + |
|
118 | + return $ret; |
|
119 | + } else { |
|
120 | + $ret = '<a href="' . $ret . '" alt="' . $this->getVar('link', 'e') . '" title="' . $this->getVar('link', 'e') . '">' . _AM_SOBJECT_SENT_LINKS_GOTO . '</a>'; |
|
121 | + |
|
122 | + return $ret; |
|
123 | + } |
|
124 | + } |
|
125 | + |
|
126 | + /** |
|
127 | + * @return string |
|
128 | + */ |
|
129 | + public function getViewItemLink() |
|
130 | + { |
|
131 | + $ret = '<a href="' . SMARTOBJECT_URL . 'admin/link.php?op=view&linkid=' . $this->getVar('linkid') . '"><img src="' . SMARTOBJECT_IMAGES_ACTIONS_URL . 'mail_find.png" alt="' . _AM_SOBJECT_SENT_LINK_VIEW . '" title="' . _AM_SOBJECT_SENT_LINK_VIEW . '"></a>'; |
|
132 | + |
|
133 | + return $ret; |
|
134 | + } |
|
135 | + |
|
136 | + /** |
|
137 | + * @return string |
|
138 | + */ |
|
139 | + public function getFromInfo() |
|
140 | + { |
|
141 | + // check if from_uid represent a user |
|
142 | + |
|
143 | + if ($this->getVar('from_uid')) { |
|
144 | + $user = smart_getLinkedUnameFromId($this->getVar('from_uid')); |
|
145 | + if ($user == $GLOBALS['xoopsConfig']['anonymous']) { |
|
146 | + $user = '<a href="mailto:' . $this->getVar('from_email') . '">' . $this->getVar('from_email') . '</a>'; |
|
147 | + } |
|
148 | + } else { |
|
149 | + $user = '<a href="mailto:' . $this->getVar('from_email') . '">' . $this->getVar('from_email') . '</a>'; |
|
150 | + } |
|
151 | + |
|
152 | + return $user; |
|
153 | + } |
|
154 | + |
|
155 | + /** |
|
156 | + * @return array |
|
157 | + */ |
|
158 | + public function toArray() |
|
159 | + { |
|
160 | + $ret = parent::toArray(); |
|
161 | + $ret['fromInfo'] = $this->getFromInfo(); |
|
162 | + $ret['toInfo'] = $this->getToInfo(); |
|
163 | + $ret['fullLink'] = $this->link(true); |
|
164 | + |
|
165 | + return $ret; |
|
166 | + } |
|
167 | + |
|
168 | + /** |
|
169 | + * @return string |
|
170 | + */ |
|
171 | + public function getToInfo() |
|
172 | + { |
|
173 | + // check if from_uid represent a user |
|
174 | + |
|
175 | + if ($this->getVar('to_uid')) { |
|
176 | + $user = smart_getLinkedUnameFromId($this->getVar('to_uid')); |
|
177 | + if ($user == $GLOBALS['xoopsConfig']['anonymous']) { |
|
178 | + $user = '<a href="mailto:' . $this->getVar('to_email') . '">' . $this->getVar('to_email') . '</a>'; |
|
179 | + } |
|
180 | + } else { |
|
181 | + $user = '<a href="mailto:' . $this->getVar('to_email') . '">' . $this->getVar('to_email') . '</a>'; |
|
182 | + } |
|
183 | + |
|
184 | + return $user; |
|
185 | + } |
|
186 | 186 | } |
187 | 187 | |
188 | 188 | /** |
@@ -190,12 +190,12 @@ discard block |
||
190 | 190 | */ |
191 | 191 | class SmartobjectLinkHandler extends SmartPersistableObjectHandler |
192 | 192 | { |
193 | - /** |
|
194 | - * SmartobjectLinkHandler constructor. |
|
195 | - * @param XoopsDatabase $db |
|
196 | - */ |
|
197 | - public function __construct(XoopsDatabase $db) |
|
198 | - { |
|
199 | - parent::__construct($db, 'link', 'linkid', 'subject', 'body', 'smartobject'); |
|
200 | - } |
|
193 | + /** |
|
194 | + * SmartobjectLinkHandler constructor. |
|
195 | + * @param XoopsDatabase $db |
|
196 | + */ |
|
197 | + public function __construct(XoopsDatabase $db) |
|
198 | + { |
|
199 | + parent::__construct($db, 'link', 'linkid', 'subject', 'body', 'smartobject'); |
|
200 | + } |
|
201 | 201 | } |
@@ -28,7 +28,7 @@ discard block |
||
28 | 28 | // -------------------------------------------------------------------------// |
29 | 29 | |
30 | 30 | // defined('XOOPS_ROOT_PATH') || exit('XOOPS root path not defined'); |
31 | -require_once XOOPS_ROOT_PATH . '/modules/smartobject/class/smartobject.php'; |
|
31 | +require_once XOOPS_ROOT_PATH.'/modules/smartobject/class/smartobject.php'; |
|
32 | 32 | |
33 | 33 | /** |
34 | 34 | * Class SmartobjectLink |
@@ -117,7 +117,7 @@ discard block |
||
117 | 117 | |
118 | 118 | return $ret; |
119 | 119 | } else { |
120 | - $ret = '<a href="' . $ret . '" alt="' . $this->getVar('link', 'e') . '" title="' . $this->getVar('link', 'e') . '">' . _AM_SOBJECT_SENT_LINKS_GOTO . '</a>'; |
|
120 | + $ret = '<a href="'.$ret.'" alt="'.$this->getVar('link', 'e').'" title="'.$this->getVar('link', 'e').'">'._AM_SOBJECT_SENT_LINKS_GOTO.'</a>'; |
|
121 | 121 | |
122 | 122 | return $ret; |
123 | 123 | } |
@@ -128,7 +128,7 @@ discard block |
||
128 | 128 | */ |
129 | 129 | public function getViewItemLink() |
130 | 130 | { |
131 | - $ret = '<a href="' . SMARTOBJECT_URL . 'admin/link.php?op=view&linkid=' . $this->getVar('linkid') . '"><img src="' . SMARTOBJECT_IMAGES_ACTIONS_URL . 'mail_find.png" alt="' . _AM_SOBJECT_SENT_LINK_VIEW . '" title="' . _AM_SOBJECT_SENT_LINK_VIEW . '"></a>'; |
|
131 | + $ret = '<a href="'.SMARTOBJECT_URL.'admin/link.php?op=view&linkid='.$this->getVar('linkid').'"><img src="'.SMARTOBJECT_IMAGES_ACTIONS_URL.'mail_find.png" alt="'._AM_SOBJECT_SENT_LINK_VIEW.'" title="'._AM_SOBJECT_SENT_LINK_VIEW.'"></a>'; |
|
132 | 132 | |
133 | 133 | return $ret; |
134 | 134 | } |
@@ -143,10 +143,10 @@ discard block |
||
143 | 143 | if ($this->getVar('from_uid')) { |
144 | 144 | $user = smart_getLinkedUnameFromId($this->getVar('from_uid')); |
145 | 145 | if ($user == $GLOBALS['xoopsConfig']['anonymous']) { |
146 | - $user = '<a href="mailto:' . $this->getVar('from_email') . '">' . $this->getVar('from_email') . '</a>'; |
|
146 | + $user = '<a href="mailto:'.$this->getVar('from_email').'">'.$this->getVar('from_email').'</a>'; |
|
147 | 147 | } |
148 | 148 | } else { |
149 | - $user = '<a href="mailto:' . $this->getVar('from_email') . '">' . $this->getVar('from_email') . '</a>'; |
|
149 | + $user = '<a href="mailto:'.$this->getVar('from_email').'">'.$this->getVar('from_email').'</a>'; |
|
150 | 150 | } |
151 | 151 | |
152 | 152 | return $user; |
@@ -175,10 +175,10 @@ discard block |
||
175 | 175 | if ($this->getVar('to_uid')) { |
176 | 176 | $user = smart_getLinkedUnameFromId($this->getVar('to_uid')); |
177 | 177 | if ($user == $GLOBALS['xoopsConfig']['anonymous']) { |
178 | - $user = '<a href="mailto:' . $this->getVar('to_email') . '">' . $this->getVar('to_email') . '</a>'; |
|
178 | + $user = '<a href="mailto:'.$this->getVar('to_email').'">'.$this->getVar('to_email').'</a>'; |
|
179 | 179 | } |
180 | 180 | } else { |
181 | - $user = '<a href="mailto:' . $this->getVar('to_email') . '">' . $this->getVar('to_email') . '</a>'; |
|
181 | + $user = '<a href="mailto:'.$this->getVar('to_email').'">'.$this->getVar('to_email').'</a>'; |
|
182 | 182 | } |
183 | 183 | |
184 | 184 | return $user; |
@@ -20,39 +20,39 @@ discard block |
||
20 | 20 | */ |
21 | 21 | class SmartObjectRow |
22 | 22 | { |
23 | - public $_keyname; |
|
24 | - public $_align; |
|
25 | - public $_customMethodForValue; |
|
26 | - public $_header; |
|
27 | - public $_class; |
|
23 | + public $_keyname; |
|
24 | + public $_align; |
|
25 | + public $_customMethodForValue; |
|
26 | + public $_header; |
|
27 | + public $_class; |
|
28 | 28 | |
29 | - /** |
|
30 | - * SmartObjectRow constructor. |
|
31 | - * @param $keyname |
|
32 | - * @param bool $customMethodForValue |
|
33 | - * @param bool $header |
|
34 | - * @param bool $class |
|
35 | - */ |
|
36 | - public function __construct($keyname, $customMethodForValue = false, $header = false, $class = false) |
|
37 | - { |
|
38 | - $this->_keyname = $keyname; |
|
39 | - $this->_customMethodForValue = $customMethodForValue; |
|
40 | - $this->_header = $header; |
|
41 | - $this->_class = $class; |
|
42 | - } |
|
29 | + /** |
|
30 | + * SmartObjectRow constructor. |
|
31 | + * @param $keyname |
|
32 | + * @param bool $customMethodForValue |
|
33 | + * @param bool $header |
|
34 | + * @param bool $class |
|
35 | + */ |
|
36 | + public function __construct($keyname, $customMethodForValue = false, $header = false, $class = false) |
|
37 | + { |
|
38 | + $this->_keyname = $keyname; |
|
39 | + $this->_customMethodForValue = $customMethodForValue; |
|
40 | + $this->_header = $header; |
|
41 | + $this->_class = $class; |
|
42 | + } |
|
43 | 43 | |
44 | - public function getKeyName() |
|
45 | - { |
|
46 | - return $this->_keyname; |
|
47 | - } |
|
44 | + public function getKeyName() |
|
45 | + { |
|
46 | + return $this->_keyname; |
|
47 | + } |
|
48 | 48 | |
49 | - /** |
|
50 | - * @return bool |
|
51 | - */ |
|
52 | - public function isHeader() |
|
53 | - { |
|
54 | - return $this->_header; |
|
55 | - } |
|
49 | + /** |
|
50 | + * @return bool |
|
51 | + */ |
|
52 | + public function isHeader() |
|
53 | + { |
|
54 | + return $this->_header; |
|
55 | + } |
|
56 | 56 | } |
57 | 57 | |
58 | 58 | /** |
@@ -66,94 +66,94 @@ discard block |
||
66 | 66 | */ |
67 | 67 | class SmartObjectSingleView |
68 | 68 | { |
69 | - public $_object; |
|
70 | - public $_userSide; |
|
71 | - public $_tpl; |
|
72 | - public $_rows; |
|
73 | - public $_actions; |
|
74 | - public $_headerAsRow = true; |
|
69 | + public $_object; |
|
70 | + public $_userSide; |
|
71 | + public $_tpl; |
|
72 | + public $_rows; |
|
73 | + public $_actions; |
|
74 | + public $_headerAsRow = true; |
|
75 | 75 | |
76 | - /** |
|
77 | - * Constructor |
|
78 | - * @param $object |
|
79 | - * @param bool $userSide |
|
80 | - * @param array $actions |
|
81 | - * @param bool $headerAsRow |
|
82 | - */ |
|
83 | - public function __construct($object, $userSide = false, $actions = array(), $headerAsRow = true) |
|
84 | - { |
|
85 | - $this->_object = $object; |
|
86 | - $this->_userSide = $userSide; |
|
87 | - $this->_actions = $actions; |
|
88 | - $this->_headerAsRow = $headerAsRow; |
|
89 | - } |
|
76 | + /** |
|
77 | + * Constructor |
|
78 | + * @param $object |
|
79 | + * @param bool $userSide |
|
80 | + * @param array $actions |
|
81 | + * @param bool $headerAsRow |
|
82 | + */ |
|
83 | + public function __construct($object, $userSide = false, $actions = array(), $headerAsRow = true) |
|
84 | + { |
|
85 | + $this->_object = $object; |
|
86 | + $this->_userSide = $userSide; |
|
87 | + $this->_actions = $actions; |
|
88 | + $this->_headerAsRow = $headerAsRow; |
|
89 | + } |
|
90 | 90 | |
91 | - /** |
|
92 | - * @param $rowObj |
|
93 | - */ |
|
94 | - public function addRow($rowObj) |
|
95 | - { |
|
96 | - $this->_rows[] = $rowObj; |
|
97 | - } |
|
91 | + /** |
|
92 | + * @param $rowObj |
|
93 | + */ |
|
94 | + public function addRow($rowObj) |
|
95 | + { |
|
96 | + $this->_rows[] = $rowObj; |
|
97 | + } |
|
98 | 98 | |
99 | - /** |
|
100 | - * @param bool $fetchOnly |
|
101 | - * @param bool $debug |
|
102 | - * @return mixed|string|void |
|
103 | - */ |
|
104 | - public function render($fetchOnly = false, $debug = false) |
|
105 | - { |
|
106 | - require_once XOOPS_ROOT_PATH . '/class/template.php'; |
|
99 | + /** |
|
100 | + * @param bool $fetchOnly |
|
101 | + * @param bool $debug |
|
102 | + * @return mixed|string|void |
|
103 | + */ |
|
104 | + public function render($fetchOnly = false, $debug = false) |
|
105 | + { |
|
106 | + require_once XOOPS_ROOT_PATH . '/class/template.php'; |
|
107 | 107 | |
108 | - $this->_tpl = new XoopsTpl(); |
|
109 | - $vars = $this->_object->vars; |
|
110 | - $smartobjectObjectArray = array(); |
|
108 | + $this->_tpl = new XoopsTpl(); |
|
109 | + $vars = $this->_object->vars; |
|
110 | + $smartobjectObjectArray = array(); |
|
111 | 111 | |
112 | - foreach ($this->_rows as $row) { |
|
113 | - $key = $row->getKeyName(); |
|
114 | - if ($row->_customMethodForValue && method_exists($this->_object, $row->_customMethodForValue)) { |
|
115 | - $method = $row->_customMethodForValue; |
|
116 | - $value = $this->_object->$method(); |
|
117 | - } else { |
|
118 | - $value = $this->_object->getVar($row->getKeyName()); |
|
119 | - } |
|
120 | - if ($row->isHeader()) { |
|
121 | - $this->_tpl->assign('smartobject_single_view_header_caption', $this->_object->vars[$key]['form_caption']); |
|
122 | - $this->_tpl->assign('smartobject_single_view_header_value', $value); |
|
123 | - } else { |
|
124 | - $smartobjectObjectArray[$key]['value'] = $value; |
|
125 | - $smartobjectObjectArray[$key]['header'] = $row->isHeader(); |
|
126 | - $smartobjectObjectArray[$key]['caption'] = $this->_object->vars[$key]['form_caption']; |
|
127 | - } |
|
128 | - } |
|
129 | - $action_row = ''; |
|
130 | - if (in_array('edit', $this->_actions)) { |
|
131 | - $action_row .= $this->_object->getEditItemLink(false, true, true); |
|
132 | - } |
|
133 | - if (in_array('delete', $this->_actions)) { |
|
134 | - $action_row .= $this->_object->getDeleteItemLink(false, true, true); |
|
135 | - } |
|
136 | - if ($action_row) { |
|
137 | - $smartobjectObjectArray['zaction']['value'] = $action_row; |
|
138 | - $smartobjectObjectArray['zaction']['caption'] = _CO_SOBJECT_ACTIONS; |
|
139 | - } |
|
112 | + foreach ($this->_rows as $row) { |
|
113 | + $key = $row->getKeyName(); |
|
114 | + if ($row->_customMethodForValue && method_exists($this->_object, $row->_customMethodForValue)) { |
|
115 | + $method = $row->_customMethodForValue; |
|
116 | + $value = $this->_object->$method(); |
|
117 | + } else { |
|
118 | + $value = $this->_object->getVar($row->getKeyName()); |
|
119 | + } |
|
120 | + if ($row->isHeader()) { |
|
121 | + $this->_tpl->assign('smartobject_single_view_header_caption', $this->_object->vars[$key]['form_caption']); |
|
122 | + $this->_tpl->assign('smartobject_single_view_header_value', $value); |
|
123 | + } else { |
|
124 | + $smartobjectObjectArray[$key]['value'] = $value; |
|
125 | + $smartobjectObjectArray[$key]['header'] = $row->isHeader(); |
|
126 | + $smartobjectObjectArray[$key]['caption'] = $this->_object->vars[$key]['form_caption']; |
|
127 | + } |
|
128 | + } |
|
129 | + $action_row = ''; |
|
130 | + if (in_array('edit', $this->_actions)) { |
|
131 | + $action_row .= $this->_object->getEditItemLink(false, true, true); |
|
132 | + } |
|
133 | + if (in_array('delete', $this->_actions)) { |
|
134 | + $action_row .= $this->_object->getDeleteItemLink(false, true, true); |
|
135 | + } |
|
136 | + if ($action_row) { |
|
137 | + $smartobjectObjectArray['zaction']['value'] = $action_row; |
|
138 | + $smartobjectObjectArray['zaction']['caption'] = _CO_SOBJECT_ACTIONS; |
|
139 | + } |
|
140 | 140 | |
141 | - $this->_tpl->assign('smartobject_header_as_row', $this->_headerAsRow); |
|
142 | - $this->_tpl->assign('smartobject_object_array', $smartobjectObjectArray); |
|
141 | + $this->_tpl->assign('smartobject_header_as_row', $this->_headerAsRow); |
|
142 | + $this->_tpl->assign('smartobject_object_array', $smartobjectObjectArray); |
|
143 | 143 | |
144 | - if ($fetchOnly) { |
|
145 | - return $this->_tpl->fetch('db:smartobject_singleview_display.tpl'); |
|
146 | - } else { |
|
147 | - $this->_tpl->display('db:smartobject_singleview_display.tpl'); |
|
148 | - } |
|
149 | - } |
|
144 | + if ($fetchOnly) { |
|
145 | + return $this->_tpl->fetch('db:smartobject_singleview_display.tpl'); |
|
146 | + } else { |
|
147 | + $this->_tpl->display('db:smartobject_singleview_display.tpl'); |
|
148 | + } |
|
149 | + } |
|
150 | 150 | |
151 | - /** |
|
152 | - * @param bool $debug |
|
153 | - * @return mixed|string|void |
|
154 | - */ |
|
155 | - public function fetch($debug = false) |
|
156 | - { |
|
157 | - return $this->render(true, $debug); |
|
158 | - } |
|
151 | + /** |
|
152 | + * @param bool $debug |
|
153 | + * @return mixed|string|void |
|
154 | + */ |
|
155 | + public function fetch($debug = false) |
|
156 | + { |
|
157 | + return $this->render(true, $debug); |
|
158 | + } |
|
159 | 159 | } |
@@ -103,7 +103,7 @@ |
||
103 | 103 | */ |
104 | 104 | public function render($fetchOnly = false, $debug = false) |
105 | 105 | { |
106 | - require_once XOOPS_ROOT_PATH . '/class/template.php'; |
|
106 | + require_once XOOPS_ROOT_PATH.'/class/template.php'; |
|
107 | 107 | |
108 | 108 | $this->_tpl = new XoopsTpl(); |
109 | 109 | $vars = $this->_object->vars; |