Skip to content

Commit 85f1754

Browse files
committed
update modulbuilder itself - correction 2
1 parent 6bc7427 commit 85f1754

6 files changed

Lines changed: 63 additions & 17 deletions

File tree

admin/fields.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@
209209
if ($order > 0) {
210210
$fieldsObj = $fieldsHandler->get($order);
211211
$fieldsObj->setVar('field_order', $i);
212-
if ($fieldsHandler->insert($fieldsObj)) {
212+
if (!$fieldsHandler->insert($fieldsObj)) {
213213
$error = true;
214214
}
215215
++$i;

class/Common/Resizer.php

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,15 @@ public function mergeImage(): void
203203
$dest = \imagecreatefromjpeg($this->endFile);
204204
$src = \imagecreatefromjpeg($this->sourceFile);
205205
break;
206-
// ... etc
206+
case 'image/gif':
207+
$dest = \imagecreatefromgif($this->endFile);
208+
$src = \imagecreatefromgif($this->sourceFile);
209+
break;
210+
default:
211+
return;
212+
}
213+
if (!$dest || !$src) {
214+
return;
207215
}
208216
if (4 == $this->mergeType) {
209217
$imgWidth = (int)\round($this->maxWidth / 2 - 1);
@@ -253,7 +261,18 @@ public function mergeImage(): void
253261
break;
254262
}
255263
}
256-
\imagejpeg($dest, $this->endFile);
264+
// image output
265+
switch ($this->imageMimetype) {
266+
case 'image/png':
267+
\imagepng($dest, $this->endFile, 0);
268+
break;
269+
case 'image/jpeg':
270+
\imagejpeg($dest, $this->endFile, $this->jpgQuality);
271+
break;
272+
case 'image/gif':
273+
\imagegif($dest, $this->endFile);
274+
break;
275+
}
257276

258277
\imagedestroy($src);
259278
\imagedestroy($dest);

files/commonfiles/class/Common/Resizer.php

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,15 @@ public function mergeImage(): void
203203
$dest = \imagecreatefromjpeg($this->endFile);
204204
$src = \imagecreatefromjpeg($this->sourceFile);
205205
break;
206-
// ... etc
206+
case 'image/gif':
207+
$dest = \imagecreatefromgif($this->endFile);
208+
$src = \imagecreatefromgif($this->sourceFile);
209+
break;
210+
default:
211+
return;
212+
}
213+
if (!$dest || !$src) {
214+
return;
207215
}
208216
if (4 == $this->mergeType) {
209217
$imgWidth = (int)\round($this->maxWidth / 2 - 1);
@@ -253,7 +261,18 @@ public function mergeImage(): void
253261
break;
254262
}
255263
}
256-
\imagejpeg($dest, $this->endFile);
264+
// image output
265+
switch ($this->imageMimetype) {
266+
case 'image/png':
267+
\imagepng($dest, $this->endFile, 0);
268+
break;
269+
case 'image/jpeg':
270+
\imagejpeg($dest, $this->endFile, $this->jpgQuality);
271+
break;
272+
case 'image/gif':
273+
\imagegif($dest, $this->endFile);
274+
break;
275+
}
257276

258277
\imagedestroy($src);
259278
\imagedestroy($dest);

files/commonfiles/include/install.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,12 @@ function xoops_module_install_modulebuilder(\XoopsModule $module)
7272
continue;
7373
}
7474
}
75-
if (!\chmod($path, 0775) && !\is_writable($path)) {
76-
$success = false;
75+
if (!@\is_writable($path)) {
76+
\chmod($path, 0775);
77+
\clearstatcache(false, $path);
78+
if (!@\is_writable($path)) {
79+
$success = false;
80+
}
7781
}
7882
}
7983
}

files/ratingfiles/class/RatingsHandler.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -120,15 +120,15 @@ public function getItemRating(int $itemid = 0, int $source = 0)
120120
$ItemRating['avg_rate_value'] = \number_format($current_rating / $count, 2);
121121
}
122122
if (1 == $count) {
123-
$text = \str_replace('%c', $ItemRating['avg_rate_value'], \_MA_MODULEBUILDER_RATING_CURRENT_1);
124-
$shorttext = \str_replace('%c', $ItemRating['avg_rate_value'], \_MA_MODULEBUILDER_RATING_CURRENT_SHORT_1);
123+
$text = \str_replace('%c', (string)$ItemRating['avg_rate_value'], \_MA_MODULEBUILDER_RATING_CURRENT_1);
124+
$shorttext = \str_replace('%c', (string)$ItemRating['avg_rate_value'], \_MA_MODULEBUILDER_RATING_CURRENT_SHORT_1);
125125
} else {
126-
$text = \str_replace('%c', $ItemRating['avg_rate_value'], \_MA_MODULEBUILDER_RATING_CURRENT_X);
127-
$shorttext = \str_replace('%c', $ItemRating['avg_rate_value'], \_MA_MODULEBUILDER_RATING_CURRENT_SHORT_X);
126+
$text = \str_replace('%c', (string)$ItemRating['avg_rate_value'], \_MA_MODULEBUILDER_RATING_CURRENT_X);
127+
$shorttext = \str_replace('%c', (string)$ItemRating['avg_rate_value'], \_MA_MODULEBUILDER_RATING_CURRENT_SHORT_X);
128128
}
129-
$text = \str_replace('%m', $max_units, $text);
130-
$text = \str_replace('%t', $ItemRating['nb_ratings'], $text);
131-
$shorttext = \str_replace('%t', $ItemRating['nb_ratings'], $shorttext);
129+
$text = \str_replace('%m', (string)$max_units, $text);
130+
$text = \str_replace('%t', (string)$ItemRating['nb_ratings'], $text);
131+
$shorttext = \str_replace('%t', (string)$ItemRating['nb_ratings'], $shorttext);
132132
$ItemRating['text'] = $text;
133133
$ItemRating['shorttext'] = $shorttext;
134134
$ItemRating['size'] = ($ItemRating['avg_rate_value'] * $rating_unitwidth) . 'px';

include/update.php

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,29 +33,33 @@
3333
*/
3434
function xoops_module_update_modulebuilder($module, $prev_version = null)
3535
{
36-
$ret = null;
36+
$ret = true;
3737
if ($prev_version < 191) {
3838
update_modulebuilder_v191($module);
3939
}
4040

4141
if (!modulebuilder_check_db($module)) {
42+
$ret = false;
4243
print_r($module->getErrors());
4344
}
4445

4546
if (!clean_index_files()) {
47+
$ret = false;
4648
print_r($module->getErrors());
4749
}
4850

4951
//check upload directory
5052
require_once __DIR__ . '/install.php';
51-
xoops_module_install_modulebuilder($module);
53+
if (!xoops_module_install_modulebuilder($module)) {
54+
$ret = false;
55+
}
5256

5357
$errors = $module->getErrors();
5458
if (!empty($errors)) {
5559
print_r($errors);
5660
}
5761

58-
return null;
62+
return $ret;
5963
}
6064

6165
// irmtfan bug fix: solve templates duplicate issue

0 commit comments

Comments
 (0)