1
|
|
|
<?php |
|
|
|
|
2
|
|
|
/* |
3
|
|
|
------------------------------------------------------------------------- |
4
|
|
|
ADSLIGHT 2 : Module for Xoops |
5
|
|
|
|
6
|
|
|
Redesigned and ameliorate By Luc Bizet user at www.frxoops.org |
7
|
|
|
Started with the Classifieds module and made MANY changes |
8
|
|
|
Website : http://www.luc-bizet.fr |
9
|
|
|
Contact : [email protected] |
10
|
|
|
------------------------------------------------------------------------- |
11
|
|
|
Original credits below Version History |
12
|
|
|
########################################################################## |
13
|
|
|
# Classified Module for Xoops # |
14
|
|
|
# By John Mordo user jlm69 at www.xoops.org and www.jlmzone.com # |
15
|
|
|
# Started with the MyAds module and made MANY changes # |
16
|
|
|
########################################################################## |
17
|
|
|
Original Author: Pascal Le Boustouller |
18
|
|
|
Author Website : [email protected] |
19
|
|
|
Licence Type : GPL |
20
|
|
|
------------------------------------------------------------------------- |
21
|
|
|
*/ |
22
|
|
|
|
23
|
|
|
$moduleDirName = basename(dirname(__DIR__)); |
24
|
|
|
$main_lang = '_' . strtoupper($moduleDirName); |
25
|
|
|
require_once XOOPS_ROOT_PATH . '/modules/adslight/include/gtickets.php'; |
26
|
|
|
include_once XOOPS_ROOT_PATH . '/class/xoopstree.php'; |
27
|
|
|
$myts = MyTextSanitizer::getInstance(); |
28
|
|
|
|
29
|
|
|
function ExpireAd() |
30
|
|
|
{ |
31
|
|
|
global $xoopsDB, $xoopsConfig, $xoopsModule, $xoopsModuleConfig, $myts, $meta, $moduleDirName, $main_lang; |
|
|
|
|
32
|
|
|
|
33
|
|
|
$datenow = time(); |
34
|
|
|
|
35
|
|
|
$result5 = $xoopsDB->query('SELECT lid, title, expire, type, desctext, date, email, submitter, photo, valid, hits, comments, remind FROM ' |
36
|
|
|
. $xoopsDB->prefix('adslight_listing') |
37
|
|
|
. " WHERE valid='Yes'"); |
38
|
|
|
|
39
|
|
|
while (list($lids, $title, $expire, $type, $desctext, $dateann, $email, $submitter, $photo, $valid, $hits, $comments, $remind) = $xoopsDB->fetchRow($result5)) { |
|
|
|
|
40
|
|
|
$title = $myts->htmlSpecialChars($title); |
41
|
|
|
$expire = $myts->htmlSpecialChars($expire); |
42
|
|
|
$type = $myts->htmlSpecialChars($type); |
43
|
|
|
$desctext = $myts->displayTarea($desctext, 1, 1, 1, 1, 1); |
44
|
|
|
$submitter = $myts->htmlSpecialChars($submitter); |
45
|
|
|
$remind = $myts->htmlSpecialChars($remind); |
46
|
|
|
$supprdate = $dateann + ($expire * 86400); |
47
|
|
|
$almost = $xoopsModuleConfig['adslight_almost']; |
48
|
|
|
|
49
|
|
|
// give warning that add is about to expire |
50
|
|
|
|
51
|
|
|
if ($almost > 0 && ($supprdate - $almost * 86400) < $datenow && $valid === 'Yes' && $remind == 0) { |
52
|
|
|
$xoopsDB->queryF('UPDATE ' . $xoopsDB->prefix('adslight_listing') . " SET remind='1' WHERE lid=$lids"); |
53
|
|
|
|
54
|
|
View Code Duplication |
if ($email) { |
|
|
|
|
55
|
|
|
$tags = array(); |
56
|
|
|
$subject = '' . _ADSLIGHT_ALMOST . ''; |
57
|
|
|
$tags['TITLE'] = $title; |
58
|
|
|
$tags['HELLO'] = '' . _ADSLIGHT_HELLO . ''; |
59
|
|
|
$tags['YOUR_AD_ON'] = '' . _ADSLIGHT_YOUR_AD_ON . ''; |
60
|
|
|
$tags['VEDIT_AD'] = '' . _ADSLIGHT_VEDIT_AD . ''; |
61
|
|
|
$tags['YOUR_AD'] = '' . _ADSLIGHT_YOUR_AD . ''; |
62
|
|
|
$tags['SOON'] = '' . _ADSLIGHT_SOON . ''; |
63
|
|
|
$tags['VIEWED'] = '' . _ADSLIGHT_VU . ''; |
64
|
|
|
$tags['TIMES'] = '' . _ADSLIGHT_TIMES . ''; |
65
|
|
|
$tags['WEBMASTER'] = '' . _ADSLIGHT_WEBMASTER . ''; |
66
|
|
|
$tags['THANKS'] = '' . _ADSLIGHT_THANKS . ''; |
67
|
|
|
$tags['TYPE'] = adslight_NameType($type); |
68
|
|
|
$tags['DESCTEXT'] = $desctext; |
69
|
|
|
$tags['HITS'] = $hits; |
70
|
|
|
$tags['META_TITLE'] = $meta['title']; |
71
|
|
|
$tags['SUBMITTER'] = $submitter; |
72
|
|
|
$tags['DURATION'] = $expire; |
73
|
|
|
$tags['LINK_URL'] = XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . '/viewads.php?' . '&lid=' . $lids; |
74
|
|
|
$mail =& getMailer(); |
75
|
|
|
$mail->setTemplateDir(XOOPS_ROOT_PATH . '/modules/' . $xoopsModule->getVar('dirname') . '/language/' . $xoopsConfig['language'] . '/mail_template/'); |
76
|
|
|
$mail->setTemplate('listing_expires.tpl'); |
77
|
|
|
$mail->useMail(); |
78
|
|
|
$mail->multimailer->isHTML(true); |
79
|
|
|
$mail->setFromName($meta['title']); |
80
|
|
|
$mail->setFromEmail($xoopsConfig['adminmail']); |
81
|
|
|
$mail->setToEmails($email); |
82
|
|
|
$mail->setSubject($subject); |
83
|
|
|
$mail->assign($tags); |
84
|
|
|
$mail->send(); |
85
|
|
|
echo $mail->getErrors(); |
86
|
|
|
} |
87
|
|
|
} |
88
|
|
|
|
89
|
|
|
// expire ad |
90
|
|
|
|
91
|
|
|
if ($supprdate < $datenow) { |
92
|
|
|
if ($photo != 0) { |
93
|
|
|
$result2 = $xoopsDB->query('SELECT url FROM ' . $xoopsDB->prefix('adslight_pictures') . ' WHERE lid=' . $xoopsDB->escape($lids) . ''); |
94
|
|
|
|
95
|
|
|
while (list($url) = $xoopsDB->fetchRow($result2)) { |
96
|
|
|
$destination = XOOPS_ROOT_PATH . '/uploads/AdsLight'; |
97
|
|
|
$destination2 = XOOPS_ROOT_PATH . '/uploads/AdsLight/thumbs'; |
98
|
|
|
$destination3 = XOOPS_ROOT_PATH . '/uploads/AdsLight/midsize'; |
99
|
|
|
if (file_exists("$destination/$url")) { |
100
|
|
|
unlink("$destination/$url"); |
101
|
|
|
} |
102
|
|
|
if (file_exists("$destination2/thumb_$url")) { |
103
|
|
|
unlink("$destination2/thumb_$url"); |
104
|
|
|
} |
105
|
|
|
if (file_exists("$destination3/resized_$url")) { |
106
|
|
|
unlink("$destination3/resized_$url"); |
107
|
|
|
} |
108
|
|
|
} |
109
|
|
|
} |
110
|
|
|
|
111
|
|
|
$xoopsDB->queryF('DELETE FROM ' . $xoopsDB->prefix('adslight_listing') . ' WHERE lid=' . $xoopsDB->escape($lids) . ''); |
112
|
|
|
|
113
|
|
|
// Specification for Japan: |
114
|
|
|
// $message = ""._ADS_HELLO." $submitter,\n\n"._ADS_STOP2."\n $type : $title\n $desctext\n"._ADS_STOP3."\n\n"._ADS_VU." $lu "._ADS_VU2."\n\n"._ADS_OTHER." ".XOOPS_URL."/modules/myAds\n\n"._ADS_THANK."\n\n"._ADS_TEAM." ".$meta['title']."\n".XOOPS_URL.""; |
115
|
|
View Code Duplication |
if ($email) { |
|
|
|
|
116
|
|
|
$tags = array(); |
117
|
|
|
$subject = '' . _ADSLIGHT_STOP . ''; |
118
|
|
|
$tags['TITLE'] = $title; |
119
|
|
|
$tags['HELLO'] = '' . _ADSLIGHT_HELLO . ''; |
120
|
|
|
$tags['TYPE'] = adslight_NameType($type); |
121
|
|
|
$tags['DESCTEXT'] = $desctext; |
122
|
|
|
$tags['HITS'] = $hits; |
123
|
|
|
$tags['META_TITLE'] = $meta['title']; |
124
|
|
|
$tags['SUBMITTER'] = $submitter; |
125
|
|
|
$tags['YOUR_AD_ON'] = '' . _ADSLIGHT_YOUR_AD_ON . ''; |
126
|
|
|
$tags['EXPIRED'] = '' . _ADSLIGHT_EXPIRED . ''; |
127
|
|
|
$tags['MESSTEXT'] = stripslashes($message); |
|
|
|
|
128
|
|
|
$tags['OTHER'] = '' . _ADSLIGHT_OTHER . ''; |
129
|
|
|
$tags['WEBMASTER'] = '' . _ADSLIGHT_WEBMASTER . ''; |
130
|
|
|
$tags['THANKS'] = '' . _ADSLIGHT_THANKS . ''; |
131
|
|
|
$tags['VIEWED'] = '' . _ADSLIGHT_VU . ''; |
132
|
|
|
$tags['TIMES'] = '' . _ADSLIGHT_TIMES . ''; |
133
|
|
|
$tags['TEAM'] = '' . _ADSLIGHT_TEAM . ''; |
134
|
|
|
$tags['DURATION'] = $expire; |
135
|
|
|
$tags['LINK_URL'] = XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . '/viewads.php?' . '&lid=' . $lids; |
136
|
|
|
$mail =& getMailer(); |
137
|
|
|
$mail->setTemplateDir(XOOPS_ROOT_PATH . '/modules/' . $xoopsModule->getVar('dirname') . '/language/' . $xoopsConfig['language'] . '/mail_template/'); |
138
|
|
|
$mail->setTemplate('listing_expired.tpl'); |
139
|
|
|
$mail->useMail(); |
140
|
|
|
$mail->multimailer->isHTML(true); |
141
|
|
|
$mail->setFromName($meta['title']); |
142
|
|
|
$mail->setFromEmail($xoopsConfig['adminmail']); |
143
|
|
|
$mail->setToEmails($email); |
144
|
|
|
$mail->setSubject($subject); |
145
|
|
|
$mail->assign($tags); |
146
|
|
|
$mail->send(); |
147
|
|
|
echo $mail->getErrors(); |
148
|
|
|
} |
149
|
|
|
} |
150
|
|
|
} |
151
|
|
|
} |
152
|
|
|
|
153
|
|
|
//updates rating data in itemtable for a given user |
154
|
|
|
/** |
155
|
|
|
* @param $sel_id |
156
|
|
|
*/ |
157
|
|
View Code Duplication |
function updateUrating($sel_id) |
|
|
|
|
158
|
|
|
{ |
159
|
|
|
global $xoopsDB, $xoopsUser, $moduleDirName, $main_lang; |
|
|
|
|
160
|
|
|
|
161
|
|
|
if (isset($_GET['usid'])) { |
162
|
|
|
$usid = (int)$_GET['usid']; |
|
|
|
|
163
|
|
|
} else { |
164
|
|
|
$usid = 0; |
|
|
|
|
165
|
|
|
} |
166
|
|
|
$query = 'SELECT rating FROM ' . $xoopsDB->prefix('adslight_user_votedata') . ' WHERE usid=' . $xoopsDB->escape($sel_id) . ''; |
167
|
|
|
//echo $query; |
168
|
|
|
$voteresult = $xoopsDB->query($query); |
169
|
|
|
$votesDB = $xoopsDB->getRowsNum($voteresult); |
170
|
|
|
$totalrating = 0; |
171
|
|
|
while (list($rating) = $xoopsDB->fetchRow($voteresult)) { |
172
|
|
|
$totalrating += $rating; |
173
|
|
|
} |
174
|
|
|
$finalrating = $totalrating / $votesDB; |
175
|
|
|
$finalrating = number_format($finalrating, 4); |
176
|
|
|
$query = 'UPDATE ' . $xoopsDB->prefix('adslight_listing') . " SET user_rating=$finalrating, user_votes=$votesDB WHERE usid=" . $xoopsDB->escape($sel_id) . ''; |
177
|
|
|
//echo $query; |
178
|
|
|
$xoopsDB->query($query) || exit(); |
|
|
|
|
179
|
|
|
} |
180
|
|
|
|
181
|
|
|
//updates rating data in itemtable for a given user |
182
|
|
|
/** |
183
|
|
|
* @param $sel_id |
184
|
|
|
*/ |
185
|
|
View Code Duplication |
function updateIrating($sel_id) |
|
|
|
|
186
|
|
|
{ |
187
|
|
|
global $xoopsDB, $xoopsUser, $moduleDirName, $main_lang; |
|
|
|
|
188
|
|
|
|
189
|
|
|
if (isset($_GET['lid'])) { |
190
|
|
|
$lid = (int)$_GET['lid']; |
|
|
|
|
191
|
|
|
} else { |
192
|
|
|
$lid = 0; |
|
|
|
|
193
|
|
|
} |
194
|
|
|
$query = 'SELECT rating FROM ' . $xoopsDB->prefix('adslight_item_votedata') . ' WHERE lid=' . $xoopsDB->escape($sel_id) . ''; |
195
|
|
|
//echo $query; |
196
|
|
|
$voteresult = $xoopsDB->query($query); |
197
|
|
|
$votesDB = $xoopsDB->getRowsNum($voteresult); |
198
|
|
|
$totalrating = 0; |
199
|
|
|
while (list($rating) = $xoopsDB->fetchRow($voteresult)) { |
200
|
|
|
$totalrating += $rating; |
201
|
|
|
} |
202
|
|
|
$finalrating = $totalrating / $votesDB; |
203
|
|
|
$finalrating = number_format($finalrating, 4); |
204
|
|
|
$query = 'UPDATE ' . $xoopsDB->prefix('adslight_listing') . " SET item_rating=$finalrating, item_votes=$votesDB WHERE lid=" . $xoopsDB->escape($sel_id) . ''; |
205
|
|
|
//echo $query; |
206
|
|
|
$xoopsDB->query($query) || exit(); |
|
|
|
|
207
|
|
|
} |
208
|
|
|
|
209
|
|
|
/** |
210
|
|
|
* @param $sel_id |
211
|
|
|
* @param string $status |
212
|
|
|
* |
213
|
|
|
* @return int |
214
|
|
|
*/ |
215
|
|
|
function adslight_getTotalItems($sel_id, $status = '') |
|
|
|
|
216
|
|
|
{ |
217
|
|
|
global $xoopsDB, $mytree, $moduleDirName; |
|
|
|
|
218
|
|
|
$categories = adslight_MygetItemIds('adslight_view'); |
219
|
|
|
$count = 0; |
220
|
|
|
$arr = array(); |
|
|
|
|
221
|
|
|
if (in_array($sel_id, $categories)) { |
222
|
|
|
$query = 'SELECT SQL_CACHE count(*) FROM ' . $xoopsDB->prefix('adslight_listing') . ' WHERE cid=' . (int)$sel_id . " and valid='Yes' AND status!='1'"; |
223
|
|
|
|
224
|
|
|
$result = $xoopsDB->query($query); |
225
|
|
|
list($thing) = $xoopsDB->fetchRow($result); |
226
|
|
|
$count = $thing; |
227
|
|
|
$arr = $mytree->getAllChildId($sel_id); |
228
|
|
|
$size = count($arr); |
229
|
|
|
for ($i = 0; $i < $size; ++$i) { |
230
|
|
|
if (in_array($arr[$i], $categories)) { |
231
|
|
|
$query2 = 'SELECT SQL_CACHE count(*) FROM ' . $xoopsDB->prefix('adslight_listing') . ' WHERE cid=' . (int)$arr[$i] . " and valid='Yes' AND status!='1'"; |
232
|
|
|
|
233
|
|
|
$result2 = $xoopsDB->query($query2); |
234
|
|
|
list($thing) = $xoopsDB->fetchRow($result2); |
235
|
|
|
$count += $thing; |
236
|
|
|
} |
237
|
|
|
} |
238
|
|
|
} |
239
|
|
|
|
240
|
|
|
return $count; |
241
|
|
|
} |
242
|
|
|
|
243
|
|
|
/** |
244
|
|
|
* @param $permtype |
245
|
|
|
* |
246
|
|
|
* @return mixed |
247
|
|
|
*/ |
248
|
|
|
function adslight_MygetItemIds($permtype) |
249
|
|
|
{ |
250
|
|
|
global $xoopsUser, $moduleDirName; |
|
|
|
|
251
|
|
|
static $permissions = array(); |
252
|
|
|
if (is_array($permissions) && array_key_exists($permtype, $permissions)) { |
253
|
|
|
return $permissions[$permtype]; |
254
|
|
|
} |
255
|
|
|
|
256
|
|
|
/** @var XoopsModuleHandler $moduleHandler */ |
257
|
|
|
$moduleHandler = xoops_getHandler('module'); |
258
|
|
|
$myModule = $moduleHandler->getByDirname('adslight'); |
259
|
|
|
$groups = is_object($xoopsUser) ? $xoopsUser->getGroups() : XOOPS_GROUP_ANONYMOUS; |
260
|
|
|
$gperm_handler = xoops_getHandler('groupperm'); |
261
|
|
|
$categories = $gperm_handler->getItemIds($permtype, $groups, $myModule->getVar('mid')); |
262
|
|
|
$permissions[$permtype] = $categories; |
263
|
|
|
|
264
|
|
|
return $categories; |
265
|
|
|
} |
266
|
|
|
|
267
|
|
|
/** |
268
|
|
|
* @param $option |
269
|
|
|
* @param string $repmodule |
270
|
|
|
* |
271
|
|
|
* @return bool |
272
|
|
|
*/ |
273
|
|
|
function adslight_getmoduleoption($option, $repmodule = 'adslight') |
|
|
|
|
274
|
|
|
{ |
275
|
|
|
global $xoopsModuleConfig, $xoopsModule; |
|
|
|
|
276
|
|
|
static $tbloptions = array(); |
277
|
|
|
if (is_array($tbloptions) && array_key_exists($option, $tbloptions)) { |
278
|
|
|
return $tbloptions[$option]; |
279
|
|
|
} |
280
|
|
|
|
281
|
|
|
$retval = false; |
282
|
|
|
if (isset($xoopsModuleConfig) |
283
|
|
|
&& (is_object($xoopsModule) && $xoopsModule->getVar('dirname') == $repmodule |
284
|
|
|
&& $xoopsModule->getVar('isactive')) |
285
|
|
|
) { |
286
|
|
|
if (isset($xoopsModuleConfig[$option])) { |
287
|
|
|
$retval = $xoopsModuleConfig[$option]; |
288
|
|
|
} |
289
|
|
|
} else { |
290
|
|
|
/** @var XoopsModuleHandler $moduleHandler */ |
291
|
|
|
$moduleHandler = xoops_getHandler('module'); |
292
|
|
|
$module = $moduleHandler->getByDirname($repmodule); |
293
|
|
|
$config_handler = xoops_getHandler('config'); |
294
|
|
|
if ($module) { |
295
|
|
|
$moduleConfig =& $config_handler->getConfigsByCat(0, $GLOBALS['xoopsModule']->getVar('mid')); |
296
|
|
|
if (isset($moduleConfig[$option])) { |
297
|
|
|
$retval = $moduleConfig[$option]; |
298
|
|
|
} |
299
|
|
|
} |
300
|
|
|
} |
301
|
|
|
$tbloptions[$option] = $retval; |
302
|
|
|
|
303
|
|
|
return $retval; |
304
|
|
|
} |
305
|
|
|
|
306
|
|
|
function ShowImg() |
307
|
|
|
{ |
308
|
|
|
global $moduleDirName; |
|
|
|
|
309
|
|
|
echo "<script type=\"text/javascript\">\n"; |
310
|
|
|
echo "<!--\n\n"; |
311
|
|
|
echo "function showimage() {\n"; |
312
|
|
|
echo "if (!document.images)\n"; |
313
|
|
|
echo "return\n"; |
314
|
|
|
echo "document.images.avatar.src=\n"; |
315
|
|
|
echo "'" . XOOPS_URL . "/modules/adslight/assets/images/img_cat/' + document.imcat.img.options[document.imcat.img.selectedIndex].value\n"; |
316
|
|
|
echo "}\n\n"; |
317
|
|
|
echo "//-->\n"; |
318
|
|
|
echo "</script>\n"; |
319
|
|
|
} |
320
|
|
|
|
321
|
|
|
//Reusable Link Sorting Functions |
322
|
|
|
/** |
323
|
|
|
* @param $orderby |
324
|
|
|
* |
325
|
|
|
* @return string |
326
|
|
|
*/ |
327
|
|
|
function adslight_convertorderbyin($orderby) |
328
|
|
|
{ |
329
|
|
|
switch (trim($orderby)) { |
330
|
|
|
case 'titleA': |
331
|
|
|
$orderby = 'title ASC'; |
332
|
|
|
break; |
333
|
|
|
case 'dateA': |
334
|
|
|
$orderby = 'date ASC'; |
335
|
|
|
break; |
336
|
|
|
case 'hitsA': |
337
|
|
|
$orderby = 'hits ASC'; |
338
|
|
|
break; |
339
|
|
|
case 'priceA': |
340
|
|
|
$orderby = 'price ASC'; |
341
|
|
|
break; |
342
|
|
|
case 'titleD': |
343
|
|
|
$orderby = 'title DESC'; |
344
|
|
|
break; |
345
|
|
|
case 'hitsD': |
346
|
|
|
$orderby = 'hits DESC'; |
347
|
|
|
break; |
348
|
|
|
case 'priceD': |
349
|
|
|
$orderby = 'price DESC'; |
350
|
|
|
break; |
351
|
|
|
case'dateD': |
|
|
|
|
352
|
|
|
default: |
353
|
|
|
$orderby = 'date DESC'; |
354
|
|
|
break; |
355
|
|
|
} |
356
|
|
|
|
357
|
|
|
return $orderby; |
358
|
|
|
} |
359
|
|
|
|
360
|
|
|
/** |
361
|
|
|
* @param $orderby |
362
|
|
|
* |
363
|
|
|
* @return string |
364
|
|
|
*/ |
365
|
|
|
function adslight_convertorderbytrans($orderby) |
366
|
|
|
{ |
367
|
|
|
global $main_lang; |
|
|
|
|
368
|
|
|
|
369
|
|
|
if ($orderby === 'hits ASC') { |
370
|
|
|
$orderbyTrans = '' . _ADSLIGHT_POPULARITYLTOM . ''; |
371
|
|
|
} |
372
|
|
|
if ($orderby === 'hits DESC') { |
373
|
|
|
$orderbyTrans = '' . _ADSLIGHT_POPULARITYMTOL . ''; |
374
|
|
|
} |
375
|
|
|
if ($orderby === 'title ASC') { |
376
|
|
|
$orderbyTrans = '' . _ADSLIGHT_TITLEATOZ . ''; |
377
|
|
|
} |
378
|
|
|
if ($orderby === 'title DESC') { |
379
|
|
|
$orderbyTrans = '' . _ADSLIGHT_TITLEZTOA . ''; |
380
|
|
|
} |
381
|
|
|
if ($orderby === 'date ASC') { |
382
|
|
|
$orderbyTrans = '' . _ADSLIGHT_DATEOLD . ''; |
383
|
|
|
} |
384
|
|
|
if ($orderby === 'date DESC') { |
385
|
|
|
$orderbyTrans = '' . _ADSLIGHT_DATENEW . ''; |
386
|
|
|
} |
387
|
|
|
if ($orderby === 'price ASC') { |
388
|
|
|
$orderbyTrans = _ADSLIGHT_PRICELTOH; |
389
|
|
|
} |
390
|
|
|
if ($orderby === 'price DESC') { |
391
|
|
|
$orderbyTrans = '' . _ADSLIGHT_PRICEHTOL . ''; |
392
|
|
|
} |
393
|
|
|
|
394
|
|
|
return $orderbyTrans; |
|
|
|
|
395
|
|
|
} |
396
|
|
|
|
397
|
|
|
/** |
398
|
|
|
* @param $orderby |
399
|
|
|
* |
400
|
|
|
* @return string |
401
|
|
|
*/ |
402
|
|
|
function adslight_convertorderbyout($orderby) |
403
|
|
|
{ |
404
|
|
|
if ($orderby === 'title ASC') { |
405
|
|
|
$orderby = 'titleA'; |
406
|
|
|
} |
407
|
|
|
if ($orderby === 'date ASC') { |
408
|
|
|
$orderby = 'dateA'; |
409
|
|
|
} |
410
|
|
|
if ($orderby === 'hits ASC') { |
411
|
|
|
$orderby = 'hitsA'; |
412
|
|
|
} |
413
|
|
|
if ($orderby === 'price ASC') { |
414
|
|
|
$orderby = 'priceA'; |
415
|
|
|
} |
416
|
|
|
if ($orderby === 'title DESC') { |
417
|
|
|
$orderby = 'titleD'; |
418
|
|
|
} |
419
|
|
|
if ($orderby === 'date DESC') { |
420
|
|
|
$orderby = 'dateD'; |
421
|
|
|
} |
422
|
|
|
if ($orderby === 'hits DESC') { |
423
|
|
|
$orderby = 'hitsD'; |
424
|
|
|
} |
425
|
|
|
if ($orderby === 'price DESC') { |
426
|
|
|
$orderby = 'priceD'; |
427
|
|
|
} |
428
|
|
|
|
429
|
|
|
return $orderby; |
430
|
|
|
} |
431
|
|
|
|
432
|
|
|
/** |
433
|
|
|
* @param $caption |
434
|
|
|
* @param $name |
435
|
|
|
* @param string $value |
436
|
|
|
* @param string $width |
437
|
|
|
* @param string $height |
438
|
|
|
* @param string $supplemental |
439
|
|
|
* |
440
|
|
|
* @return bool|XoopsFormDhtmlTextArea|XoopsFormEditor|XoopsFormFckeditor|XoopsFormTextArea|XoopsFormTinymce |
|
|
|
|
441
|
|
|
*/ |
442
|
|
View Code Duplication |
function adslight_getEditor($caption, $name, $value = '', $width = '100%', $height = '300px', $supplemental = '') |
|
|
|
|
443
|
|
|
{ |
444
|
|
|
global $xoopsModuleConfig, $moduleDirName; |
|
|
|
|
445
|
|
|
$editor = false; |
|
|
|
|
446
|
|
|
$x22 = false; |
447
|
|
|
$xv = str_replace('XOOPS ', '', XOOPS_VERSION); |
448
|
|
|
if (substr($xv, 2, 1) == '2') { |
449
|
|
|
$x22 = true; |
450
|
|
|
} |
451
|
|
|
$editor_configs = array(); |
452
|
|
|
$editor_configs['name'] = $name; |
453
|
|
|
$editor_configs['value'] = $value; |
454
|
|
|
$editor_configs['rows'] = 25; |
455
|
|
|
$editor_configs['cols'] = 80; |
456
|
|
|
$editor_configs['width'] = '100%'; |
457
|
|
|
$editor_configs['height'] = '300px'; |
458
|
|
|
|
459
|
|
|
switch (strtolower($xoopsModuleConfig['adslight_form_options'])) { |
460
|
|
|
|
461
|
|
|
case 'tinymce' : |
|
|
|
|
462
|
|
|
if (!$x22) { |
463
|
|
|
if (is_readable(XOOPS_ROOT_PATH . '/class/xoopseditor/tinymce/formtinymce.php')) { |
464
|
|
|
include_once XOOPS_ROOT_PATH . '/class/xoopseditor/tinymce/formtinymce.php'; |
465
|
|
|
$editor = new XoopsFormTinymce(array( |
466
|
|
|
'caption' => $caption, |
467
|
|
|
'name' => $name, |
468
|
|
|
'value' => $value, |
469
|
|
|
'width' => '100%', |
470
|
|
|
'height' => '300px' |
471
|
|
|
)); |
472
|
|
|
} else { |
473
|
|
|
if ($dhtml) { |
|
|
|
|
474
|
|
|
$editor = new XoopsFormDhtmlTextArea($caption, $name, $value, 20, 60); |
475
|
|
|
} else { |
476
|
|
|
$editor = new XoopsFormTextArea($caption, $name, $value, 7, 60); |
477
|
|
|
} |
478
|
|
|
} |
479
|
|
|
} else { |
480
|
|
|
$editor = new XoopsFormEditor($caption, 'tinyeditor', $editor_configs); |
481
|
|
|
} |
482
|
|
|
break; |
483
|
|
|
|
484
|
|
|
case 'fckeditor' : |
|
|
|
|
485
|
|
|
if (!$x22) { |
486
|
|
|
if (is_readable(XOOPS_ROOT_PATH . '/class/xoopseditor/fckeditor/formfckeditor.php')) { |
487
|
|
|
include_once XOOPS_ROOT_PATH . '/class/xoopseditor/fckeditor/formfckeditor.php'; |
488
|
|
|
$editor = new XoopsFormFckeditor($editor_configs, true); |
489
|
|
|
} else { |
490
|
|
|
if ($dhtml) { |
491
|
|
|
$editor = new XoopsFormDhtmlTextArea($caption, $name, $value, 20, 60); |
492
|
|
|
} else { |
493
|
|
|
$editor = new XoopsFormTextArea($caption, $name, $value, 7, 60); |
494
|
|
|
} |
495
|
|
|
} |
496
|
|
|
} else { |
497
|
|
|
$editor = new XoopsFormEditor($caption, 'fckeditor', $editor_configs); |
498
|
|
|
} |
499
|
|
|
break; |
500
|
|
|
|
501
|
|
|
case 'koivi' : |
|
|
|
|
502
|
|
|
if (!$x22) { |
503
|
|
|
if (is_readable(XOOPS_ROOT_PATH . '/class/xoopseditor/koivi/formkoivi.php')) { |
504
|
|
|
include_once XOOPS_ROOT_PATH . '/class/xoopseditor/koivi/formkoivi.php'; |
505
|
|
|
include_once XOOPS_ROOT_PATH . '/class/xoopseditor/koivi/language/english.php'; |
506
|
|
|
$editor = new XoopsFormKoivi($editor_configs, true); |
507
|
|
|
} else { |
508
|
|
|
if ($dhtml) { |
509
|
|
|
$editor = new XoopsFormDhtmlTextArea($caption, $name, $value, 20, 60); |
510
|
|
|
} else { |
511
|
|
|
$editor = new XoopsFormTextArea($caption, $name, $value, 7, 60); |
512
|
|
|
} |
513
|
|
|
} |
514
|
|
|
} else { |
515
|
|
|
$editor = new XoopsFormEditor($caption, 'koivi', $editor_configs); |
516
|
|
|
} |
517
|
|
|
break; |
518
|
|
|
|
519
|
|
|
case 'textarea': |
520
|
|
|
if (!$x22) { |
521
|
|
|
if (is_readable(XOOPS_ROOT_PATH . '/class/xoopseditor/textarea/textarea.php')) { |
522
|
|
|
include_once XOOPS_ROOT_PATH . '/class/xoopseditor/textarea/textarea.php'; |
523
|
|
|
$editor = new FormTextArea($caption, $name, $value); |
524
|
|
|
} else { |
525
|
|
|
if ($dhtml) { |
526
|
|
|
$editor = new XoopsFormDhtmlTextArea($caption, $name, $value, 20, 60); |
527
|
|
|
} else { |
528
|
|
|
$editor = new XoopsFormTextArea($caption, $name, $value, 7, 60); |
529
|
|
|
} |
530
|
|
|
} |
531
|
|
|
} else { |
532
|
|
|
$editor = new XoopsFormEditor($caption, 'htmlarea', $editor_configs); |
533
|
|
|
} |
534
|
|
|
break; |
535
|
|
|
|
536
|
|
|
default : |
|
|
|
|
537
|
|
|
// if ($dhtml) { |
|
|
|
|
538
|
|
|
include_once XOOPS_ROOT_PATH . '/class/xoopseditor/dhtmltextarea/dhtmltextarea.php'; |
539
|
|
|
$editor = new XoopsFormDhtmlTextArea($caption, $name, $value, 20, 40, $supplemental); |
540
|
|
|
// } else { |
|
|
|
|
541
|
|
|
// $editor = new XoopsFormEditor($caption, 'dhtmltextarea', $editor_configs); |
|
|
|
|
542
|
|
|
// } |
543
|
|
|
|
544
|
|
|
break; |
545
|
|
|
} |
546
|
|
|
|
547
|
|
|
return $editor; |
548
|
|
|
} |
549
|
|
|
|
550
|
|
|
/** |
551
|
|
|
* @param $caption |
552
|
|
|
* @param $name |
553
|
|
|
* @param string $value |
554
|
|
|
* @param string $width |
555
|
|
|
* @param string $height |
556
|
|
|
* @param string $supplemental |
557
|
|
|
* |
558
|
|
|
* @return bool|XoopsFormDhtmlTextArea|XoopsFormEditor|XoopsFormFckeditor|XoopsFormTextArea|XoopsFormTinymce |
|
|
|
|
559
|
|
|
*/ |
560
|
|
View Code Duplication |
function adslight_adminEditor($caption, $name, $value = '', $width = '100%', $height = '300px', $supplemental = '') |
|
|
|
|
561
|
|
|
{ |
562
|
|
|
global $xoopsModuleConfig, $moduleDirName; |
|
|
|
|
563
|
|
|
$editor = false; |
|
|
|
|
564
|
|
|
$x22 = false; |
565
|
|
|
$xv = str_replace('XOOPS ', '', XOOPS_VERSION); |
566
|
|
|
if (substr($xv, 2, 1) == '2') { |
567
|
|
|
$x22 = true; |
568
|
|
|
} |
569
|
|
|
$editor_configs = array(); |
570
|
|
|
$editor_configs['name'] = $name; |
571
|
|
|
$editor_configs['value'] = $value; |
572
|
|
|
$editor_configs['rows'] = 35; |
573
|
|
|
$editor_configs['cols'] = 60; |
574
|
|
|
$editor_configs['width'] = '100%'; |
575
|
|
|
$editor_configs['height'] = '300px'; |
576
|
|
|
|
577
|
|
|
switch (strtolower($xoopsModuleConfig['adslight_admin_editor'])) { |
578
|
|
|
|
579
|
|
|
case 'tinymce' : |
|
|
|
|
580
|
|
|
if (!$x22) { |
581
|
|
|
if (is_readable(XOOPS_ROOT_PATH . '/class/xoopseditor/tinymce/formtinymce.php')) { |
582
|
|
|
include_once XOOPS_ROOT_PATH . '/class/xoopseditor/tinymce/formtinymce.php'; |
583
|
|
|
$editor = new XoopsFormTinymce(array( |
584
|
|
|
'caption' => $caption, |
585
|
|
|
'name' => $name, |
586
|
|
|
'value' => $value, |
587
|
|
|
'width' => '100%', |
588
|
|
|
'height' => '300px' |
589
|
|
|
)); |
590
|
|
|
} else { |
591
|
|
|
if ($dhtml) { |
|
|
|
|
592
|
|
|
$editor = new XoopsFormDhtmlTextArea($caption, $name, $value, 20, 60); |
593
|
|
|
} else { |
594
|
|
|
$editor = new XoopsFormTextArea($caption, $name, $value, 7, 60); |
595
|
|
|
} |
596
|
|
|
} |
597
|
|
|
} else { |
598
|
|
|
$editor = new XoopsFormEditor($caption, 'tinyeditor', $editor_configs); |
599
|
|
|
} |
600
|
|
|
break; |
601
|
|
|
|
602
|
|
|
case 'fckeditor' : |
|
|
|
|
603
|
|
|
if (!$x22) { |
604
|
|
|
if (is_readable(XOOPS_ROOT_PATH . '/class/xoopseditor/fckeditor/formfckeditor.php')) { |
605
|
|
|
include_once XOOPS_ROOT_PATH . '/class/xoopseditor/fckeditor/formfckeditor.php'; |
606
|
|
|
$editor = new XoopsFormFckeditor($editor_configs, true); |
607
|
|
|
} else { |
608
|
|
|
if ($dhtml) { |
609
|
|
|
$editor = new XoopsFormDhtmlTextArea($caption, $name, $value, 20, 60); |
610
|
|
|
} else { |
611
|
|
|
$editor = new XoopsFormTextArea($caption, $name, $value, 7, 60); |
612
|
|
|
} |
613
|
|
|
} |
614
|
|
|
} else { |
615
|
|
|
$editor = new XoopsFormEditor($caption, 'fckeditor', $editor_configs); |
616
|
|
|
} |
617
|
|
|
break; |
618
|
|
|
|
619
|
|
|
case 'koivi' : |
|
|
|
|
620
|
|
|
if (!$x22) { |
621
|
|
|
if (is_readable(XOOPS_ROOT_PATH . '/class/xoopseditor/koivi/formkoivi.php')) { |
622
|
|
|
include_once XOOPS_ROOT_PATH . '/class/xoopseditor/koivi/formkoivi.php'; |
623
|
|
|
include_once XOOPS_ROOT_PATH . '/class/xoopseditor/koivi/language/english.php'; |
624
|
|
|
$editor = new XoopsFormKoivi($editor_configs, true); |
625
|
|
|
} else { |
626
|
|
|
if ($dhtml) { |
627
|
|
|
$editor = new XoopsFormDhtmlTextArea($caption, $name, $value, 20, 60); |
628
|
|
|
} else { |
629
|
|
|
$editor = new XoopsFormTextArea($caption, $name, $value, 7, 60); |
630
|
|
|
} |
631
|
|
|
} |
632
|
|
|
} else { |
633
|
|
|
$editor = new XoopsFormEditor($caption, 'koivi', $editor_configs); |
634
|
|
|
} |
635
|
|
|
break; |
636
|
|
|
|
637
|
|
|
case 'textarea': |
638
|
|
|
if (!$x22) { |
639
|
|
|
if (is_readable(XOOPS_ROOT_PATH . '/class/xoopseditor/textarea/textarea.php')) { |
640
|
|
|
include_once XOOPS_ROOT_PATH . '/class/xoopseditor/textarea/textarea.php'; |
641
|
|
|
$editor = new FormTextArea($caption, $name, $value); |
642
|
|
|
} else { |
643
|
|
|
if ($dhtml) { |
644
|
|
|
$editor = new XoopsFormDhtmlTextArea($caption, $name, $value, 20, 60); |
645
|
|
|
} else { |
646
|
|
|
$editor = new XoopsFormTextArea($caption, $name, $value, 7, 60); |
647
|
|
|
} |
648
|
|
|
} |
649
|
|
|
} else { |
650
|
|
|
$editor = new XoopsFormEditor($caption, 'textarea', $editor_configs); |
651
|
|
|
} |
652
|
|
|
break; |
653
|
|
|
|
654
|
|
|
default : |
|
|
|
|
655
|
|
|
|
656
|
|
|
include_once XOOPS_ROOT_PATH . '/class/xoopseditor/dhtmltextarea/dhtmltextarea.php'; |
657
|
|
|
$editor = new XoopsFormDhtmlTextArea($caption, $name, $value, 20, 40, $supplemental); |
658
|
|
|
|
659
|
|
|
break; |
660
|
|
|
} |
661
|
|
|
|
662
|
|
|
return $editor; |
663
|
|
|
} |
664
|
|
|
|
665
|
|
|
/** |
666
|
|
|
* @param $tablename |
667
|
|
|
* |
668
|
|
|
* @return bool |
669
|
|
|
*/ |
670
|
|
|
function jlm_ads_TableExists($tablename) |
671
|
|
|
{ |
672
|
|
|
global $xoopsDB; |
|
|
|
|
673
|
|
|
$result = $xoopsDB->queryF("SHOW TABLES LIKE '$tablename'"); |
674
|
|
|
|
675
|
|
|
return ($xoopsDB->getRowsNum($result) > 0); |
676
|
|
|
} |
677
|
|
|
|
678
|
|
|
/** |
679
|
|
|
* @param $fieldname |
680
|
|
|
* @param $table |
681
|
|
|
* |
682
|
|
|
* @return bool |
683
|
|
|
*/ |
684
|
|
|
function jlm_ads_FieldExists($fieldname, $table) |
685
|
|
|
{ |
686
|
|
|
global $xoopsDB; |
|
|
|
|
687
|
|
|
$result = $xoopsDB->queryF("SHOW COLUMNS FROM $table LIKE '$fieldname'"); |
688
|
|
|
|
689
|
|
|
return ($xoopsDB->getRowsNum($result) > 0); |
690
|
|
|
} |
691
|
|
|
|
692
|
|
|
/** |
693
|
|
|
* @param $field |
694
|
|
|
* @param $table |
695
|
|
|
* |
696
|
|
|
* @return mixed |
697
|
|
|
*/ |
698
|
|
|
function jlm_ads_AddField($field, $table) |
699
|
|
|
{ |
700
|
|
|
global $xoopsDB; |
|
|
|
|
701
|
|
|
$result = $xoopsDB->queryF('ALTER TABLE ' . $table . " ADD $field;"); |
702
|
|
|
|
703
|
|
|
return $result; |
704
|
|
|
} |
705
|
|
|
|
706
|
|
|
/** |
707
|
|
|
* @param $cid |
708
|
|
|
* |
709
|
|
|
* @return bool |
710
|
|
|
*/ |
711
|
|
|
function adslight_getCatNameFromId($cid) |
712
|
|
|
{ |
713
|
|
|
global $xoopsDB, $xoopsConfig, $myts, $xoopsUser, $moduleDirName; |
|
|
|
|
714
|
|
|
|
715
|
|
|
$sql = 'SELECT SQL_CACHE title FROM ' . $xoopsDB->prefix('adslight_categories') . " WHERE cid = '$cid'"; |
716
|
|
|
|
717
|
|
|
if (!$result = $xoopsDB->query($sql)) { |
718
|
|
|
return false; |
719
|
|
|
} |
720
|
|
|
|
721
|
|
|
if (!$arr = $xoopsDB->fetchArray($result)) { |
722
|
|
|
return false; |
723
|
|
|
} |
724
|
|
|
|
725
|
|
|
$title = $arr['title']; |
726
|
|
|
|
727
|
|
|
return $title; |
728
|
|
|
} |
729
|
|
|
|
730
|
|
|
/** |
731
|
|
|
* @return mixed |
732
|
|
|
*/ |
733
|
|
View Code Duplication |
function adslight_gocategory() |
|
|
|
|
734
|
|
|
{ |
735
|
|
|
global $xoopsDB; |
|
|
|
|
736
|
|
|
|
737
|
|
|
$xt = new XoopsTree($xoopsDB->prefix('adslight_categories'), 'cid', 'pid'); |
738
|
|
|
$jump = XOOPS_URL . '/modules/adslight/viewcats.php?cid='; |
739
|
|
|
ob_start(); |
740
|
|
|
$xt->makeMySelBox('title', 'title', 0, 1, 'pid', "location=\"" . $jump . "\"+this.options[this.selectedIndex].value"); |
741
|
|
|
$block['selectbox'] = ob_get_contents(); |
|
|
|
|
742
|
|
|
ob_end_clean(); |
743
|
|
|
|
744
|
|
|
return $block; |
745
|
|
|
} |
746
|
|
|
|
747
|
|
|
// ADSLIGHT Version 2 // |
748
|
|
|
// Fonction rss.php RSS par categories |
749
|
|
|
/** |
750
|
|
|
* @return array |
751
|
|
|
*/ |
752
|
|
|
function returnAllAdsRss() |
|
|
|
|
753
|
|
|
{ |
754
|
|
|
global $xoopsDB, $xoopsModuleConfig, $xoopsUser; |
|
|
|
|
755
|
|
|
|
756
|
|
|
$cid = !isset($_GET['cid']) ? null : $_GET['cid']; |
757
|
|
|
|
758
|
|
|
$result = array(); |
759
|
|
|
|
760
|
|
|
$sql = 'SELECT lid, title, price, date, town FROM ' . $xoopsDB->prefix('adslight_listing') . " WHERE valid='yes' AND cid=" . $xoopsDB->escape($cid) . ' ORDER BY date DESC'; |
761
|
|
|
|
762
|
|
|
$resultValues = $xoopsDB->query($sql); |
763
|
|
|
while (($resultTemp = $xoopsDB->fetchBoth($resultValues)) !== false) { |
764
|
|
|
array_push($result, $resultTemp); |
765
|
|
|
} |
766
|
|
|
|
767
|
|
|
return $result; |
768
|
|
|
} |
769
|
|
|
|
770
|
|
|
// Fonction fluxrss.php RSS Global |
771
|
|
|
/** |
772
|
|
|
* @return array |
773
|
|
|
*/ |
774
|
|
|
function returnAllAdsFluxRss() |
775
|
|
|
{ |
776
|
|
|
global $xoopsDB, $xoopsModuleConfig, $xoopsUser; |
|
|
|
|
777
|
|
|
|
778
|
|
|
$result = array(); |
779
|
|
|
|
780
|
|
|
$sql = 'SELECT lid, title, price, desctext, date, town FROM ' . $xoopsDB->prefix('adslight_listing') . " WHERE valid='yes' ORDER BY date DESC LIMIT 0,15"; |
781
|
|
|
|
782
|
|
|
$resultValues = $xoopsDB->query($sql); |
783
|
|
|
while (($resultTemp = $xoopsDB->fetchBoth($resultValues)) !== false) { |
784
|
|
|
array_push($result, $resultTemp); |
785
|
|
|
} |
786
|
|
|
|
787
|
|
|
return $result; |
788
|
|
|
} |
789
|
|
|
|
790
|
|
|
/** |
791
|
|
|
* @param $type |
792
|
|
|
* |
793
|
|
|
* @return mixed |
794
|
|
|
*/ |
795
|
|
|
function adslight_NameType($type) |
796
|
|
|
{ |
797
|
|
|
global $xoopsDB; |
|
|
|
|
798
|
|
|
$sql = $xoopsDB->query('SELECT nom_type FROM ' . $xoopsDB->prefix('adslight_type') . ' WHERE id_type=' . $xoopsDB->escape($type) . ''); |
799
|
|
|
list($nom_type) = $xoopsDB->fetchRow($sql); |
800
|
|
|
|
801
|
|
|
return $nom_type; |
802
|
|
|
} |
803
|
|
|
|
804
|
|
|
/** |
805
|
|
|
* @param $format |
806
|
|
|
* @param $number |
807
|
|
|
* |
808
|
|
|
* @return mixed |
809
|
|
|
*/ |
810
|
|
|
function money_format($format, $number) |
811
|
|
|
{ |
812
|
|
|
$regex = '/%((?:[\^!\-]|\+|\(|\=.)*)([0-9]+)?' . '(?:#([0-9]+))?(?:\.([0-9]+))?([in%])/'; |
813
|
|
|
if (setlocale(LC_MONETARY, 0) === 'C') { |
814
|
|
|
setlocale(LC_MONETARY, ''); |
815
|
|
|
} |
816
|
|
|
|
817
|
|
|
setlocale(LC_ALL, 'en_US'); |
818
|
|
|
$locale = localeconv(); |
819
|
|
|
preg_match_all($regex, $format, $matches, PREG_SET_ORDER); |
820
|
|
|
foreach ($matches as $fmatch) { |
|
|
|
|
821
|
|
|
$value = (float)$number; |
822
|
|
|
$flags = array( |
823
|
|
|
'fillchar' => preg_match('/\=(.)/', $fmatch[1], $match) ? $match[1] : ' ', |
824
|
|
|
'nogroup' => preg_match('/\^/', $fmatch[1]) > 0, |
825
|
|
|
'usesignal' => preg_match('/\+|\(/', $fmatch[1], $match) ? $match[0] : '+', |
826
|
|
|
'nosimbol' => preg_match('/\!/', $fmatch[1]) > 0, |
827
|
|
|
'isleft' => preg_match('/\-/', $fmatch[1]) > 0 |
828
|
|
|
); |
829
|
|
|
$width = trim($fmatch[2]) ? (int)$fmatch[2] : 0; |
830
|
|
|
$left = trim($fmatch[3]) ? (int)$fmatch[3] : 0; |
831
|
|
|
$right = trim($fmatch[4]) ? (int)$fmatch[4] : $locale['int_frac_digits']; |
832
|
|
|
$conversion = $fmatch[5]; |
833
|
|
|
|
834
|
|
|
$positive = true; |
835
|
|
|
if ($value < 0) { |
836
|
|
|
$positive = false; |
837
|
|
|
$value *= -1; |
838
|
|
|
} |
839
|
|
|
$letter = $positive ? 'p' : 'n'; |
840
|
|
|
|
841
|
|
|
$prefix = $suffix = $cprefix = $csuffix = $signal = ''; |
|
|
|
|
842
|
|
|
|
843
|
|
|
$signal = $positive ? $locale['positive_sign'] : $locale['negative_sign']; |
844
|
|
|
switch (true) { |
845
|
|
View Code Duplication |
case $locale["{$letter}_sign_posn"] == 1 && $flags['usesignal'] == '+': |
|
|
|
|
846
|
|
|
$prefix = $signal; |
847
|
|
|
break; |
848
|
|
View Code Duplication |
case $locale["{$letter}_sign_posn"] == 2 && $flags['usesignal'] == '+': |
|
|
|
|
849
|
|
|
$suffix = $signal; |
850
|
|
|
break; |
851
|
|
View Code Duplication |
case $locale["{$letter}_sign_posn"] == 3 && $flags['usesignal'] == '+': |
|
|
|
|
852
|
|
|
$cprefix = $signal; |
853
|
|
|
break; |
854
|
|
View Code Duplication |
case $locale["{$letter}_sign_posn"] == 4 && $flags['usesignal'] == '+': |
|
|
|
|
855
|
|
|
$csuffix = $signal; |
856
|
|
|
break; |
857
|
|
|
case $flags['usesignal'] === '(': |
858
|
|
|
case $locale["{$letter}_sign_posn"] == 0: |
859
|
|
|
$prefix = '('; |
860
|
|
|
$suffix = ')'; |
861
|
|
|
break; |
862
|
|
|
} |
863
|
|
|
if (!$flags['nosimbol']) { |
864
|
|
|
$currency = $cprefix . ($conversion === 'i' ? $locale['int_curr_symbol'] : $locale['currency_symbol']) . $csuffix; |
865
|
|
|
} else { |
866
|
|
|
$currency = ''; |
867
|
|
|
} |
868
|
|
|
$space = $locale["{$letter}_sep_by_space"] ? ' ' : ''; |
869
|
|
|
|
870
|
|
|
$value = number_format($value, $right, $locale['mon_decimal_point'], $flags['nogroup'] ? '' : $locale['mon_thousands_sep']); |
871
|
|
|
$value = @explode($locale['mon_decimal_point'], $value); |
872
|
|
|
|
873
|
|
|
$n = strlen($prefix) + strlen($currency) + strlen($value[0]); |
874
|
|
|
if ($left > 0 && $left > $n) { |
875
|
|
|
$value[0] = str_repeat($flags['fillchar'], $left - $n) . $value[0]; |
876
|
|
|
} |
877
|
|
|
$value = implode($locale['mon_decimal_point'], $value); |
878
|
|
|
if ($locale["{$letter}_cs_precedes"]) { |
879
|
|
|
$value = $prefix . $currency . $space . $value . $suffix; |
880
|
|
|
} else { |
881
|
|
|
$value = $prefix . $value . $space . $currency . $suffix; |
882
|
|
|
} |
883
|
|
|
if ($width > 0) { |
884
|
|
|
$value = str_pad($value, $width, $flags['fillchar'], $flags['isleft'] ? STR_PAD_RIGHT : STR_PAD_LEFT); |
885
|
|
|
} |
886
|
|
|
|
887
|
|
|
$format = str_replace($fmatch[0], $value, $format); |
888
|
|
|
} |
889
|
|
|
|
890
|
|
|
return $format; |
891
|
|
|
} |
892
|
|
|
|
The PSR-1: Basic Coding Standard recommends that a file should either introduce new symbols, that is classes, functions, constants or similar, or have side effects. Side effects are anything that executes logic, like for example printing output, changing ini settings or writing to a file.
The idea behind this recommendation is that merely auto-loading a class should not change the state of an application. It also promotes a cleaner style of programming and makes your code less prone to errors, because the logic is not spread out all over the place.
To learn more about the PSR-1, please see the PHP-FIG site on the PSR-1.