Skip to content

Commit 2e8b8e3

Browse files
committed
2 parents a5ff56f + 7615dee commit 2e8b8e3

7 files changed

Lines changed: 71 additions & 28 deletions

File tree

class/Building.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,18 @@ public function clearDir($dir, $pattern = '*'): void
100100
\unlink($file);
101101
}
102102
}
103+
$file = $dir . '/.gitignore';
104+
if (is_file($file)) {
105+
\unlink($file);
106+
}
107+
$file = $dir . '/.gitattributes';
108+
if (is_file($file)) {
109+
\unlink($file);
110+
}
111+
$file = $dir . '/.scrutinizer.yml';
112+
if (is_file($file)) {
113+
\unlink($file);
114+
}
103115
if (\is_dir($dir)) {
104116
\rmdir($dir);
105117
}

class/Files/CreateArchitecture.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,10 @@ public function setBaseFoldersFiles($module): void
160160
\copy($copyFile, $copyNewFile);
161161
} else {
162162
// Copy file
163+
if (!\file_exists($logoPng)) {
164+
$logoPng = 'tdmxoops_logo.png';
165+
$logoGifFrom = TDMC_UPLOAD_IMGMOD_PATH . '/' . $logoPng;
166+
}
163167
$copyFile = TDMC_IMAGES_LOGOS_URL . '/' . $logoPng;
164168
$copyNewFile = $logoGifFrom;
165169
\copy($copyFile, $copyNewFile);

class/Files/CreateFile.php

Lines changed: 32 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -329,7 +329,11 @@ public function getLanguage($moduleDirname, $prefix = '', $suffix = '', $addFq =
329329
*/
330330
public function getLeftString($string)
331331
{
332-
return \mb_substr($string, 0, (int)\mb_strpos($string, '_'));
332+
$ret = '';
333+
if ('' != $string) {
334+
$ret .= \mb_substr($string, 0, (int)\mb_strpos($string, '_'));
335+
}
336+
return $ret;
333337
}
334338

335339
/**
@@ -340,12 +344,14 @@ public function getLeftString($string)
340344
*/
341345
public function getRightString($string = null)
342346
{
343-
if (\mb_strpos($string, '_')) {
344-
$str = \mb_strpos($string, '_');
345-
if (false !== $str) {
346-
$ret = \mb_substr($string, $str + 1, \mb_strlen($string));
347+
if ('' != $string) {
348+
if (\mb_strpos($string, '_')) {
349+
$str = \mb_strpos($string, '_');
350+
if (false !== $str) {
351+
$ret = \mb_substr($string, $str + 1, \mb_strlen($string));
347352

348-
return $ret;
353+
return $ret;
354+
}
349355
}
350356
}
351357

@@ -382,7 +388,11 @@ public function getCamelCase($string, $ucfirst = false, $lcfirst = false)
382388
*/
383389
public function getUcfirst($string)
384390
{
385-
return \ucfirst($string);
391+
$ret = '';
392+
if ('' != $string) {
393+
$ret .= \ucfirst($string);
394+
}
395+
return $ret;
386396
}
387397

388398
/**
@@ -393,7 +403,11 @@ public function getUcfirst($string)
393403
*/
394404
public function getLcfirst($string)
395405
{
396-
return \lcfirst($string);
406+
$ret = '';
407+
if ('' != $string) {
408+
$ret .= \lcfirst($string);
409+
}
410+
return $ret;
397411
}
398412

399413
/**
@@ -404,7 +418,11 @@ public function getLcfirst($string)
404418
*/
405419
public function getStrToUpper($string)
406420
{
407-
return \mb_strtoupper($string);
421+
$ret = '';
422+
if ('' != $string) {
423+
$ret .= \mb_strtoupper($string);
424+
}
425+
return $ret;
408426
}
409427

410428
/**
@@ -415,7 +433,11 @@ public function getStrToUpper($string)
415433
*/
416434
public function getStrToLower($string)
417435
{
418-
return \mb_strtolower($string);
436+
$ret = '';
437+
if ('' != $string) {
438+
$ret .= \mb_strtolower($string);
439+
}
440+
return $ret;
419441
}
420442

421443
/**

class/Form/FormRadio.php

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ public function render()
3131
{
3232
$ret = '';
3333
$ele_name = $this->getName();
34-
$ele_title = $this->getTitle();
35-
$ele_value = $this->getValue();
34+
$ele_title = (string)$this->getTitle();
35+
$ele_value = (string)$this->getValue();
3636
$ele_options = $this->getOptions();
3737
$ele_extra = $this->getExtra();
3838
$ele_delimeter = empty($this->columns) ? $this->getDelimeter() : '';
@@ -41,6 +41,12 @@ public function render()
4141
}
4242
$i = 0;
4343
$id_ele = 0;
44+
if ('' != $ele_title) {
45+
$ele_title = htmlspecialchars($ele_title, ENT_QUOTES);
46+
}
47+
if ('' != $ele_value) {
48+
$ele_value = htmlspecialchars($ele_value, ENT_QUOTES);
49+
}
4450
foreach ($ele_options as $value => $name) {
4551
++$id_ele;
4652
if (!empty($this->columns)) {
@@ -49,7 +55,7 @@ public function render()
4955
}
5056
$ret .= '<td class="radio">';
5157
}
52-
$ret .= '<input type="radio" name="' . $ele_name . '" id="' . $ele_name . '[' . $value . ']' . $id_ele . '" title = "' . htmlspecialchars($ele_title, ENT_QUOTES) . '" value="' . htmlspecialchars($value, ENT_QUOTES) . '"';
58+
$ret .= '<input type="radio" name="' . $ele_name . '" id="' . $ele_name . '[' . $value . ']' . $id_ele . '" title = "' . $ele_title . '" value="' . $ele_value . '"';
5359
if (isset($ele_value) && $value == $ele_value) {
5460
$ret .= ' checked';
5561
}

class/LogoGenerator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ public static function createLogo($logoIcon, $moduleName)
8585

8686
// Write text
8787
$textColor = imagecolorallocate($imageModule, 0, 0, 0);
88-
$spaceToBorder = (92 - mb_strlen($moduleName) * 7.5) / 2;
88+
$spaceToBorder = (int)\floor((92 - mb_strlen($moduleName) * 7.5) / 2);
8989
imagefttext($imageModule, 8.5, 0, $spaceToBorder, 45, $textColor, $font, $moduleName, []);
9090

9191
imagecopy($imageModule, $imageIcon, 29, 2, 0, 0, 32, 32);

docs/changelog.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@
1717
- replaced Common/XoopsConfirm by Common/Confirm(mamba/goffy)
1818
- table renaming in fieldelements (goffy)
1919
- added new fieldelements integer/float (goffy)
20+
- uninstall with bak-file creation (mamba/goffy)
21+
- module update to php8 (mamba)
22+
- fix bug in type cast (liomj/goffy)
2023

2124
<h5>3.5.1 Beta 1 [NOT RELEASED]</h5> Dev: XOOPS 2.5.11, PHP 7.4.25, PHP 8.0.12, PHP 8.1.0 Beta 4
2225
- semantic versioning (mamba)

files/commonfiles/include/uninstall.php

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -36,27 +36,23 @@ function xoops_module_uninstall_modulebuilder(\XoopsModule $module)
3636

3737
$helper = Modulebuilder\Helper::getInstance();
3838

39-
$utility = new Modulebuilder\Utility();
40-
4139
$success = true;
4240
$helper->loadLanguage('admin');
4341

4442
//------------------------------------------------------------------
45-
// Remove uploads folder (and all subfolders) if they exist
43+
// Rename uploads folder to BAK and add date to name
4644
//------------------------------------------------------------------
47-
48-
$old_directories = [$GLOBALS['xoops']->path("uploads/{$moduleDirName}")];
49-
foreach ($old_directories as $old_dir) {
50-
$dirInfo = new \SplFileInfo($old_dir);
51-
if ($dirInfo->isDir()) {
52-
// The directory exists so delete it
53-
if (!$utility::rrmdir($old_dir)) {
54-
$module->setErrors(\sprintf(\constant('CO_' . $moduleDirNameUpper . '_ERROR_BAD_DEL_PATH'), $old_dir));
55-
$success = false;
56-
}
45+
$uploadDirectory = $GLOBALS['xoops']->path("uploads/$moduleDirName");
46+
$dirInfo = new \SplFileInfo($uploadDirectory);
47+
if ($dirInfo->isDir()) {
48+
// The directory exists so rename it
49+
$date = date('Y-m-d');
50+
if (!rename($uploadDirectory, $uploadDirectory . "_bak_$date")) {
51+
$module->setErrors(sprintf(constant('CO_' . $moduleDirNameUpper . '_ERROR_BAD_DEL_PATH'), $uploadDirectory));
52+
$success = false;
5753
}
58-
unset($dirInfo);
5954
}
55+
unset($dirInfo);
6056
/*
6157
//------------ START ----------------
6258
//------------------------------------------------------------------

0 commit comments

Comments
 (0)