1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace XoopsModules\Tdmdownloads\Common; |
4
|
|
|
|
5
|
|
|
/* |
6
|
|
|
You may not change or alter any portion of this comment or credits |
7
|
|
|
of supporting developers from this source code or any supporting source code |
8
|
|
|
which is considered copyrighted (c) material of the original comment or credit authors. |
9
|
|
|
|
10
|
|
|
This program is distributed in the hope that it will be useful, |
11
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of |
12
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
13
|
|
|
*/ |
14
|
|
|
|
15
|
|
|
/** |
16
|
|
|
* @copyright 2019 XOOPS Project (https://xoops.org) |
17
|
|
|
* @license GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html) |
18
|
|
|
* @link https://xoops.org |
19
|
|
|
* @author Wedega - Email:<[email protected]> - Website:<https://wedega.com> |
20
|
|
|
*/ |
21
|
|
|
|
22
|
|
|
use XoopsModules\Tdmdownloads; |
23
|
|
|
|
24
|
|
|
defined('XOOPS_ROOT_PATH') || die('Restricted access'); |
25
|
|
|
|
26
|
|
|
/** |
27
|
|
|
* Class Object Handler Images |
28
|
|
|
*/ |
29
|
|
|
class ImagesHandler extends \XoopsPersistableObjectHandler |
30
|
|
|
{ |
31
|
|
|
/** |
32
|
|
|
* Constructor |
33
|
|
|
* |
34
|
|
|
* @param null|\XoopsDatabase $db |
35
|
|
|
*/ |
36
|
|
|
public function __construct(\XoopsDatabase $db = null) |
37
|
|
|
{ |
38
|
|
|
parent::__construct($db, 'tdmdownloads_images', Images::class, 'img_id', 'img_name'); |
39
|
|
|
} |
40
|
|
|
|
41
|
|
|
/** |
42
|
|
|
* retrieve a field |
43
|
|
|
* |
44
|
|
|
* @param int $i field id |
45
|
|
|
* @param null fields |
|
|
|
|
46
|
|
|
* @return mixed reference to the {@link Get} object |
47
|
|
|
*/ |
48
|
|
|
public function get($i = null, $fields = null) |
49
|
|
|
{ |
50
|
|
|
return parent::get($i, $fields); |
51
|
|
|
} |
52
|
|
|
|
53
|
|
|
/** |
54
|
|
|
* get inserted id |
55
|
|
|
* |
56
|
|
|
* @param null |
57
|
|
|
* @return integer reference to the {@link Get} object |
58
|
|
|
*/ |
59
|
|
|
public function getInsertId() |
60
|
|
|
{ |
61
|
|
|
return $this->db->getInsertId(); |
62
|
|
|
} |
63
|
|
|
|
64
|
|
|
/** |
65
|
|
|
* Get Count Images in the database |
66
|
|
|
* @param int $albId |
67
|
|
|
* @param int $start |
68
|
|
|
* @param int $limit |
69
|
|
|
* @param string $sort |
70
|
|
|
* @param string $order |
71
|
|
|
* @return int |
72
|
|
|
*/ |
73
|
|
|
public function getCountImages($albId = 0, $start = 0, $limit = 0, $sort = 'img_id ASC, img_name', $order = 'ASC') |
74
|
|
|
{ |
75
|
|
|
$crCountImages = new \CriteriaCompo(); |
76
|
|
|
$crCountImages = $this->getImagesCriteria($crCountImages, $albId, $start, $limit, $sort, $order); |
77
|
|
|
return parent::getCount($crCountImages); |
|
|
|
|
78
|
|
|
} |
79
|
|
|
|
80
|
|
|
/** |
81
|
|
|
* Get All Images in the database |
82
|
|
|
* @param int $start |
83
|
|
|
* @param int $limit |
84
|
|
|
* @param string $sort |
85
|
|
|
* @param string $order |
86
|
|
|
* @return array |
87
|
|
|
*/ |
88
|
|
|
public function getAllImages($start = 0, $limit = 0, $sort = 'img_id ASC, img_name', $order = 'ASC') |
89
|
|
|
{ |
90
|
|
|
$crAllImages = new \CriteriaCompo(); |
91
|
|
|
$crAllImages = $this->getImagesCriteria($crAllImages, 0, $start, $limit, $sort, $order); |
92
|
|
|
return parent::getAll($crAllImages); |
|
|
|
|
93
|
|
|
} |
94
|
|
|
|
95
|
|
|
/** |
96
|
|
|
* Get Criteria Images |
97
|
|
|
* @param $crImages |
98
|
|
|
* @param $albId |
99
|
|
|
* @param int $start |
100
|
|
|
* @param int $limit |
101
|
|
|
* @param string $sort |
102
|
|
|
* @param string $order |
103
|
|
|
* @return int |
104
|
|
|
*/ |
105
|
|
|
private function getImagesCriteria($crImages, $albId, $start, $limit, $sort, $order) |
106
|
|
|
{ |
107
|
|
|
if (0 < $albId) { |
108
|
|
|
$crImages->add(new \Criteria('img_albid', $albId)); |
109
|
|
|
} |
110
|
|
|
$crImages->setStart($start); |
111
|
|
|
$crImages->setLimit($limit); |
112
|
|
|
$crImages->setSort($sort); |
113
|
|
|
$crImages->setOrder($order); |
114
|
|
|
return $crImages; |
115
|
|
|
} |
116
|
|
|
|
117
|
|
|
/** |
118
|
|
|
* delete all copies of a specific image |
119
|
|
|
* @param $imageName |
120
|
|
|
* @return bool |
121
|
|
|
*/ |
122
|
|
|
public function unlinkImages($imageName) |
123
|
|
|
{ |
124
|
|
|
unlink(constant($moduleDirNameUpper . '_' . 'UPLOAD_IMAGE_PATH') . '/large/' . $imageName); |
|
|
|
|
125
|
|
|
if (file_exists(constant($moduleDirNameUpper . '_' . 'UPLOAD_IMAGE_PATH') . '/large/' . $imageName)) { |
126
|
|
|
return false; |
127
|
|
|
} |
128
|
|
|
unlink(constant($moduleDirNameUpper . '_' . 'UPLOAD_IMAGE_PATH') . '/medium/' . $imageName); |
129
|
|
|
if (file_exists(constant($moduleDirNameUpper . '_' . 'UPLOAD_IMAGE_PATH') . '/medium/' . $imageName)) { |
130
|
|
|
return false; |
131
|
|
|
} |
132
|
|
|
unlink(constant($moduleDirNameUpper . '_' . 'UPLOAD_IMAGE_PATH') . '/thumbs/' . $imageName); |
133
|
|
|
if (file_exists(constant($moduleDirNameUpper . '_' . 'UPLOAD_IMAGE_PATH') . '/thumbs/' . $imageName)) { |
134
|
|
|
return false; |
135
|
|
|
} |
136
|
|
|
|
137
|
|
|
return true; |
138
|
|
|
} |
139
|
|
|
} |
140
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths