|
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
|
|
|
include_once XOOPS_ROOT_PATH . '/modules/adslight/class/utilities.php'; |
|
24
|
|
|
/** |
|
25
|
|
|
* @param XoopsObject $xoopsModule |
|
26
|
|
|
* |
|
27
|
|
|
* @return bool |
|
28
|
|
|
*/ |
|
29
|
|
|
function xoops_module_update_adslight(XoopsObject $xoopsModule) |
|
|
|
|
|
|
30
|
|
|
{ |
|
31
|
|
|
global $xoopsDB; |
|
|
|
|
|
|
32
|
|
|
|
|
33
|
|
|
$sql = 'ALTER TABLE `' . $xoopsDB->prefix('adslight_listing') . "` MODIFY `price` decimal(20,2) NOT NULL default '0.00' AFTER `tel` ;"; |
|
34
|
|
|
$xoopsDB->query($sql); |
|
35
|
|
|
|
|
36
|
|
|
$sql = 'ALTER TABLE `' . $xoopsDB->prefix('adslight_listing') . "` MODIFY `photo` varchar(100) NOT NULL default '0';"; |
|
37
|
|
|
$xoopsDB->query($sql); |
|
38
|
|
|
|
|
39
|
|
|
// remove old html template files |
|
40
|
|
|
$template_directory = XOOPS_ROOT_PATH . '/modules/' . $xoopsModule->getVar('dirname', 'n') . '/templates/'; |
|
41
|
|
|
$template_list = array_diff(scandir($template_directory), array('..', '.')); |
|
42
|
|
View Code Duplication |
foreach ($template_list as $k => $v) { |
|
|
|
|
|
|
43
|
|
|
$fileinfo = new SplFileInfo($template_directory . $v); |
|
44
|
|
|
if ($fileinfo->getExtension() === 'html' && $fileinfo->getFilename() !== 'index.html') { |
|
45
|
|
|
@unlink($template_directory . $v); |
|
|
|
|
|
|
46
|
|
|
} |
|
47
|
|
|
} |
|
48
|
|
|
|
|
49
|
|
|
xoops_load('xoopsfile'); |
|
50
|
|
|
|
|
51
|
|
|
//remove /images directory |
|
52
|
|
|
$imagesDirectory = XOOPS_ROOT_PATH . '/modules/' . $xoopsModule->getVar('dirname', 'n') . '/images/'; |
|
53
|
|
|
$folderHandler = XoopsFile::getHandler('folder', $imagesDirectory); |
|
54
|
|
|
$folderHandler->delete($imagesDirectory); |
|
55
|
|
|
|
|
56
|
|
|
//delete .html entries from the tpl table |
|
57
|
|
|
$sql = 'DELETE FROM ' . $xoopsDB->prefix('tplfile') . " WHERE `tpl_module` = '" . $xoopsModule->getVar('dirname', 'n') . "' AND `tpl_file` LIKE '%.html%'"; |
|
58
|
|
|
$xoopsDB->queryF($sql); |
|
59
|
|
|
|
|
60
|
|
|
return true; |
|
61
|
|
|
} |
|
62
|
|
|
|
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.