|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace XoopsModules\Adslight; |
|
4
|
|
|
|
|
5
|
|
|
/* |
|
6
|
|
|
------------------------------------------------------------------------- |
|
7
|
|
|
ADSLIGHT 2 : Module for Xoops |
|
8
|
|
|
|
|
9
|
|
|
Redesigned and ameliorate By Luc Bizet user at www.frxoops.org |
|
10
|
|
|
Started with the Classifieds module and made MANY changes |
|
11
|
|
|
Website : http://www.luc-bizet.fr |
|
12
|
|
|
Contact : [email protected] |
|
13
|
|
|
------------------------------------------------------------------------- |
|
14
|
|
|
Original credits below Version History |
|
15
|
|
|
########################################################################## |
|
16
|
|
|
# Classified Module for Xoops # |
|
17
|
|
|
# By John Mordo user jlm69 at www.xoops.org and www.jlmzone.com # |
|
18
|
|
|
# Started with the MyAds module and made MANY changes # |
|
19
|
|
|
########################################################################## |
|
20
|
|
|
Original Author: Pascal Le Boustouller |
|
21
|
|
|
Author Website : [email protected] |
|
22
|
|
|
Licence Type : GPL |
|
23
|
|
|
------------------------------------------------------------------------- |
|
24
|
|
|
*/ |
|
25
|
|
|
|
|
26
|
|
|
/** |
|
27
|
|
|
* Protection against inclusion outside the site |
|
28
|
|
|
*/ |
|
29
|
|
|
// defined('XOOPS_ROOT_PATH') || die('Restricted access'); |
|
30
|
|
|
|
|
31
|
|
|
/** |
|
32
|
|
|
* Includes of form objects and uploader |
|
33
|
|
|
*/ |
|
34
|
|
|
require_once XOOPS_ROOT_PATH . '/class/uploader.php'; |
|
35
|
|
|
require_once XOOPS_ROOT_PATH . '/kernel/object.php'; |
|
36
|
|
|
require_once XOOPS_ROOT_PATH . '/class/xoopsformloader.php'; |
|
37
|
|
|
require_once XOOPS_ROOT_PATH . '/kernel/object.php'; |
|
38
|
|
|
|
|
39
|
|
|
/** |
|
40
|
|
|
* light_pictures class. |
|
41
|
|
|
* $this class is responsible for providing data access mechanisms to the data source |
|
42
|
|
|
* of XOOPS user class objects. |
|
43
|
|
|
*/ |
|
44
|
|
|
class Pictures extends \XoopsObject |
|
45
|
|
|
{ |
|
46
|
|
|
/** @var \XoopsMySQLDatabase $db */ |
|
47
|
|
|
public $db; |
|
48
|
|
|
// constructor |
|
49
|
|
|
|
|
50
|
|
|
/** |
|
51
|
|
|
* @param null $id |
|
|
|
|
|
|
52
|
|
|
* @param null|array $lid |
|
53
|
|
|
*/ |
|
54
|
|
|
public function __construct($id = null, $lid = null) |
|
|
|
|
|
|
55
|
|
|
{ |
|
56
|
|
|
$this->db = \XoopsDatabaseFactory::getDatabaseConnection(); |
|
57
|
|
|
$this->initVar('cod_img', XOBJ_DTYPE_INT, null, false, 10); |
|
58
|
|
|
$this->initVar('title', XOBJ_DTYPE_TXTBOX, null, false); |
|
59
|
|
|
$this->initVar('date_added', XOBJ_DTYPE_TXTBOX, null, false); |
|
60
|
|
|
$this->initVar('date_modified', XOBJ_DTYPE_TXTBOX, null, false); |
|
61
|
|
|
$this->initVar('lid', XOBJ_DTYPE_INT, null, false, 10); |
|
62
|
|
|
$this->initVar('uid_owner', XOBJ_DTYPE_TXTBOX, null, false); |
|
63
|
|
|
$this->initVar('url', XOBJ_DTYPE_TXTBOX, null, false); |
|
64
|
|
|
if (!empty($lid)) { |
|
65
|
|
|
if (is_array($lid)) { |
|
|
|
|
|
|
66
|
|
|
$this->assignVars($lid); |
|
67
|
|
|
} else { |
|
68
|
|
|
$this->load((int)$lid); |
|
69
|
|
|
} |
|
70
|
|
|
} else { |
|
71
|
|
|
$this->setNew(); |
|
72
|
|
|
} |
|
73
|
|
|
} |
|
74
|
|
|
|
|
75
|
|
|
/** |
|
76
|
|
|
* @param $id |
|
77
|
|
|
*/ |
|
78
|
|
|
public function load($id) |
|
79
|
|
|
{ |
|
80
|
|
|
global $moduleDirName; |
|
81
|
|
|
$sql = 'SELECT * FROM ' . $this->db->prefix('adslight_pictures') . ' WHERE cod_img=' . $id . ' '; |
|
82
|
|
|
$myrow = $this->db->fetchArray($this->db->query($sql)); |
|
|
|
|
|
|
83
|
|
|
$this->assignVars($myrow); |
|
84
|
|
|
if (!$myrow) { |
|
85
|
|
|
$this->setNew(); |
|
86
|
|
|
} |
|
87
|
|
|
} |
|
88
|
|
|
|
|
89
|
|
|
/** |
|
90
|
|
|
* @param array $criteria |
|
91
|
|
|
* @param bool $asobject |
|
92
|
|
|
* @param string $sort |
|
93
|
|
|
* @param string $cat_order |
|
94
|
|
|
* @param int $limit |
|
95
|
|
|
* @param int $start |
|
96
|
|
|
* @return array |
|
97
|
|
|
* @internal param string $order |
|
98
|
|
|
* @deprecated this should be handled through {@see PicturesHandler} |
|
99
|
|
|
*/ |
|
100
|
|
|
public function getAllPictures($criteria = [], $asobject = false, $sort = 'cod_img', $cat_order = 'ASC', $limit = 0, $start = 0) |
|
101
|
|
|
{ |
|
102
|
|
|
global $moduleDirName; |
|
103
|
|
|
/** @var \XoopsMySQLDatabase $db */ |
|
104
|
|
|
$db = \XoopsDatabaseFactory::getDatabaseConnection(); |
|
105
|
|
|
$ret = []; |
|
106
|
|
|
$where_query = ''; |
|
107
|
|
|
if (is_array($criteria) && count($criteria) > 0) { |
|
108
|
|
|
$where_query = ' WHERE'; |
|
109
|
|
|
foreach ($criteria as $c) { |
|
110
|
|
|
$where_query .= " {$c} AND"; |
|
111
|
|
|
} |
|
112
|
|
|
$where_query = mb_substr($where_query, 0, -4); |
|
113
|
|
|
} elseif (!is_array($criteria) && $criteria) { |
|
114
|
|
|
$where_query = " WHERE {$criteria}"; |
|
115
|
|
|
} |
|
116
|
|
|
if (!$asobject) { |
|
117
|
|
|
$sql = 'SELECT cod_img FROM ' . $db->prefix('adslight_pictures') . "$where_query ORDER BY $sort $cat_order"; |
|
118
|
|
|
$result = $db->query($sql, $limit, $start); |
|
|
|
|
|
|
119
|
|
|
while (false !== ($myrow = $db->fetchArray($result))) { |
|
120
|
|
|
$ret[] = $myrow['cog_img']; |
|
121
|
|
|
} |
|
122
|
|
|
} else { |
|
123
|
|
|
$sql = 'SELECT * FROM ' . $db->prefix('adslight_pictures') . "$where_query ORDER BY $sort $cat_order"; |
|
124
|
|
|
$result = $db->query($sql, $limit, $start); |
|
|
|
|
|
|
125
|
|
|
while (false !== ($myrow = $db->fetchArray($result))) { |
|
126
|
|
|
$ret[] = new self($myrow); |
|
127
|
|
|
} |
|
128
|
|
|
} |
|
129
|
|
|
|
|
130
|
|
|
return $ret; |
|
131
|
|
|
} |
|
132
|
|
|
} |
|
133
|
|
|
|
|
134
|
|
|
// ------------------------------------------------------------------------- |
|
135
|
|
|
// ------------------light_pictures user handler class ------------------- |
|
136
|
|
|
// ------------------------------------------------------------------------- |
|
137
|
|
|
|