Skip to content

Commit 7f7149f

Browse files
authored
Merge pull request #114 from mambax7/master
updates/cosmetics
2 parents 5b35f2e + 3e92fcb commit 7f7149f

23 files changed

Lines changed: 251 additions & 245 deletions

blocks/newbb_block.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ function b_newbb_show($options)
188188
// START irmtfan remove hardcoded html in URLs - add $seo_topic_url
189189
//$seo_url = XOOPS_URL . '/' . SEO_MODULE_NAME . '/viewtopic.php?post_id=' . $topic['post_id'];
190190
//BigKev73 > Change to support jumping directly to that post, vs just the page that the topic is on
191-
$seo_url = XOOPS_URL . '/' . SEO_MODULE_NAME . '/viewtopic.php?topic_id=' . $topic['id'] . '&post_id=' . $topic['post_id']."#forumpost" . $topic['post_id'];
191+
$seo_url = XOOPS_URL . '/' . SEO_MODULE_NAME . '/viewtopic.php?topic_id=' . $topic['id'] . '&post_id=' . $topic['post_id'] . '#forumpost' . $topic['post_id'];
192192
$seo_topic_url = XOOPS_URL . '/' . SEO_MODULE_NAME . '/viewtopic.php?topic_id=' . $topic['id'];
193193
$seo_forum_url = XOOPS_URL . '/' . SEO_MODULE_NAME . '/viewforum.php?forum=' . $topic['forum_id'];
194194
if (!empty($newbbConfig['do_rewrite'])) {

class/Common/Breadcrumb.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ class Breadcrumb
3939

4040
public function __construct()
4141
{
42-
$this->dirname = \basename(dirname(__DIR__, 2));
42+
$this->dirname = \basename(\dirname(__DIR__, 2));
4343
}
4444

4545
/**

class/Common/Configurator.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,10 @@ class Configurator
4242
*/
4343
public function __construct()
4444
{
45-
$moduleDirName = \basename(dirname(__DIR__, 2));
45+
$moduleDirName = \basename(\dirname(__DIR__, 2));
4646
$moduleDirNameUpper = mb_strtoupper($moduleDirName);
4747

48-
$config = require dirname(__DIR__, 2) . '/config/config.php';
48+
$config = require \dirname(__DIR__, 2) . '/config/config.php';
4949

5050
$this->name = $config->name;
5151
$this->paths = $config->paths;

class/Common/FilesManagement.php

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,9 @@ trait FilesManagement
3131
public static function createFolder($folder)
3232
{
3333
try {
34-
if (!is_dir($folder)) {
35-
if (!is_dir($folder) && !mkdir($folder) && !is_dir($folder)) {
36-
throw new \RuntimeException(sprintf('Unable to create the %s directory', $folder));
34+
if (!\is_dir($folder)) {
35+
if (!\is_dir($folder) && !\mkdir($folder) && !\is_dir($folder)) {
36+
throw new \RuntimeException(\sprintf('Unable to create the %s directory', $folder));
3737
}
3838

3939
file_put_contents($folder . '/index.html', '<script>history.go(-1);</script>');
@@ -50,7 +50,7 @@ public static function createFolder($folder)
5050
*/
5151
public static function copyFile($file, $folder)
5252
{
53-
return copy($file, $folder);
53+
return \copy($file, $folder);
5454
}
5555

5656
/**
@@ -59,21 +59,21 @@ public static function copyFile($file, $folder)
5959
*/
6060
public static function recurseCopy($src, $dst)
6161
{
62-
$dir = opendir($src);
62+
$dir = \opendir($src);
6363
// @mkdir($dst);
64-
if (!@mkdir($dst) && !is_dir($dst)) {
64+
if (!@\mkdir($dst) && !\is_dir($dst)) {
6565
throw new \RuntimeException('The directory ' . $dst . ' could not be created.');
6666
}
67-
while (false !== ($file = readdir($dir))) {
67+
while (false !== ($file = \readdir($dir))) {
6868
if (('.' !== $file) && ('..' !== $file)) {
69-
if (is_dir($src . '/' . $file)) {
69+
if (\is_dir($src . '/' . $file)) {
7070
self::recurseCopy($src . '/' . $file, $dst . '/' . $file);
7171
} else {
72-
copy($src . '/' . $file, $dst . '/' . $file);
72+
\copy($src . '/' . $file, $dst . '/' . $file);
7373
}
7474
}
7575
}
76-
closedir($dir);
76+
\closedir($dir);
7777
}
7878

7979
/**
@@ -98,21 +98,21 @@ public static function deleteDirectory($src)
9898
$dirInfo = new \SplFileInfo($src);
9999
// validate is a directory
100100
if ($dirInfo->isDir()) {
101-
$fileList = array_diff(scandir($src, SCANDIR_SORT_NONE), ['..', '.']);
101+
$fileList = \array_diff(\scandir($src, \SCANDIR_SORT_NONE), ['..', '.']);
102102
foreach ($fileList as $k => $v) {
103103
$fileInfo = new \SplFileInfo("{$src}/{$v}");
104104
if ($fileInfo->isDir()) {
105105
// recursively handle subdirectories
106106
if (!$success = self::deleteDirectory($fileInfo->getRealPath())) {
107107
break;
108108
}
109-
} elseif (!($success = unlink($fileInfo->getRealPath()))) {
109+
} elseif (!($success = \unlink($fileInfo->getRealPath()))) {
110110
break;
111111
}
112112
}
113113
// now delete this (sub)directory if all the files are gone
114114
if ($success) {
115-
$success = rmdir($dirInfo->getRealPath());
115+
$success = \rmdir($dirInfo->getRealPath());
116116
}
117117
} else {
118118
// input is not a valid directory
@@ -139,7 +139,7 @@ public static function rrmdir($src)
139139
}
140140

141141
// If source is not a directory stop processing
142-
if (!is_dir($src)) {
142+
if (!\is_dir($src)) {
143143
return false;
144144
}
145145

@@ -151,7 +151,7 @@ public static function rrmdir($src)
151151
if ($fObj->isFile()) {
152152
$filename = $fObj->getPathname();
153153
$fObj = null; // clear this iterator object to close the file
154-
if (!unlink($filename)) {
154+
if (!\unlink($filename)) {
155155
return false; // couldn't delete the file
156156
}
157157
} elseif (!$fObj->isDot() && $fObj->isDir()) {
@@ -160,7 +160,7 @@ public static function rrmdir($src)
160160
}
161161
}
162162
$iterator = null; // clear iterator Obj to close file/directory
163-
return rmdir($src); // remove the directory & return results
163+
return \rmdir($src); // remove the directory & return results
164164
}
165165

166166
/**
@@ -179,28 +179,28 @@ public static function rmove($src, $dest)
179179
}
180180

181181
// If source is not a directory stop processing
182-
if (!is_dir($src)) {
182+
if (!\is_dir($src)) {
183183
return false;
184184
}
185185

186186
// If the destination directory does not exist and could not be created stop processing
187-
if (!is_dir($dest) && !mkdir($dest) && !is_dir($dest)) {
187+
if (!\is_dir($dest) && !\mkdir($dest) && !\is_dir($dest)) {
188188
return false;
189189
}
190190

191191
// Open the source directory to read in files
192192
$iterator = new \DirectoryIterator($src);
193193
foreach ($iterator as $fObj) {
194194
if ($fObj->isFile()) {
195-
rename($fObj->getPathname(), "{$dest}/" . $fObj->getFilename());
195+
\rename($fObj->getPathname(), "{$dest}/" . $fObj->getFilename());
196196
} elseif (!$fObj->isDot() && $fObj->isDir()) {
197197
// Try recursively on directory
198198
self::rmove($fObj->getPathname(), "{$dest}/" . $fObj->getFilename());
199199
// rmdir($fObj->getPath()); // now delete the directory
200200
}
201201
}
202202
$iterator = null; // clear iterator Obj to close file/directory
203-
return rmdir($src); // remove the directory & return results
203+
return \rmdir($src); // remove the directory & return results
204204
}
205205

206206
/**
@@ -222,20 +222,20 @@ public static function rcopy($src, $dest)
222222
}
223223

224224
// If source is not a directory stop processing
225-
if (!is_dir($src)) {
225+
if (!\is_dir($src)) {
226226
return false;
227227
}
228228

229229
// If the destination directory does not exist and could not be created stop processing
230-
if (!is_dir($dest) && !mkdir($dest) && !is_dir($dest)) {
230+
if (!\is_dir($dest) && !\mkdir($dest) && !\is_dir($dest)) {
231231
return false;
232232
}
233233

234234
// Open the source directory to read in files
235235
$iterator = new \DirectoryIterator($src);
236236
foreach ($iterator as $fObj) {
237237
if ($fObj->isFile()) {
238-
copy($fObj->getPathname(), "{$dest}/" . $fObj->getFilename());
238+
\copy($fObj->getPathname(), "{$dest}/" . $fObj->getFilename());
239239
} elseif (!$fObj->isDot() && $fObj->isDir()) {
240240
self::rcopy($fObj->getPathname(), "{$dest}/" . $fObj->getFilename());
241241
}

class/Common/Migrate.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public function __construct(Newbb\Common\Configurator $configurator)
3939
{
4040
$this->renameTables = $configurator->renameTables;
4141

42-
$moduleDirName = basename(dirname(__DIR__, 2));
42+
$moduleDirName = \basename(\dirname(__DIR__, 2));
4343
parent::__construct($moduleDirName);
4444
}
4545

@@ -67,7 +67,7 @@ private function changePrefix()
6767
. '</span>'
6868
);
6969

70-
trigger_error('Could not migrate table: ' . $oldName . '! The table ' . $newName . ' already exist!');
70+
\trigger_error('Could not migrate table: ' . $oldName . '! The table ' . $newName . ' already exist!');
7171
}
7272
}
7373
}

class/Common/ServerStats.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ trait ServerStats
2727
public static function getServerStats()
2828
{
2929
//mb $wfdownloads = WfdownloadsWfdownloads::getInstance();
30-
$moduleDirName = \basename(dirname(__DIR__, 2));
30+
$moduleDirName = \basename(\dirname(__DIR__, 2));
3131
$moduleDirNameUpper = mb_strtoupper($moduleDirName);
3232
\xoops_loadLanguage('common', $moduleDirName);
3333
$html = '';

class/Common/SysUtility.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -214,11 +214,11 @@ public static function cloneRecord($tableName, $id_field, $id)
214214
$new_id = false;
215215
$table = $GLOBALS['xoopsDB']->prefix($tableName);
216216
// copy content of the record you wish to clone
217-
$tempTable = $GLOBALS['xoopsDB']->fetchArray($GLOBALS['xoopsDB']->query("SELECT * FROM $table WHERE $id_field='$id' "), MYSQLI_ASSOC) or exit('Could not select record');
217+
$tempTable = $GLOBALS['xoopsDB']->fetchArray($GLOBALS['xoopsDB']->query("SELECT * FROM $table WHERE $id_field='$id' "), \MYSQLI_ASSOC) or exit('Could not select record');
218218
// set the auto-incremented id's value to blank.
219219
unset($tempTable[$id_field]);
220220
// insert cloned copy of the original record
221-
$result = $GLOBALS['xoopsDB']->queryF("INSERT INTO $table (" . implode(', ', array_keys($tempTable)) . ") VALUES ('" . implode("', '", array_values($tempTable)) . "')") or exit ($GLOBALS['xoopsDB']->error());
221+
$result = $GLOBALS['xoopsDB']->queryF("INSERT INTO $table (" . \implode(', ', \array_keys($tempTable)) . ") VALUES ('" . \implode("', '", \array_values($tempTable)) . "')") or exit ($GLOBALS['xoopsDB']->error());
222222

223223
if ($result) {
224224
// Return the new id

class/Common/VersionChecks.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ trait VersionChecks
2929
*/
3030
public static function checkVerXoops(\XoopsModule $module = null, $requiredVer = null)
3131
{
32-
$moduleDirName = \basename(dirname(__DIR__, 2));
32+
$moduleDirName = \basename(\dirname(__DIR__, 2));
3333
$moduleDirNameUpper = mb_strtoupper($moduleDirName);
3434
if (null === $module) {
3535
$module = \XoopsModule::getByDirname($moduleDirName);
@@ -61,7 +61,7 @@ public static function checkVerXoops(\XoopsModule $module = null, $requiredVer =
6161
*/
6262
public static function checkVerPhp(\XoopsModule $module = null)
6363
{
64-
$moduleDirName = \basename(dirname(__DIR__, 2));
64+
$moduleDirName = \basename(\dirname(__DIR__, 2));
6565
$moduleDirNameUpper = mb_strtoupper($moduleDirName);
6666
if (null === $module) {
6767
$module = \XoopsModule::getByDirname($moduleDirName);
@@ -98,7 +98,7 @@ public static function checkVerPhp(\XoopsModule $module = null)
9898

9999
public static function checkVerModule($helper, $source = 'github', $default = 'master')
100100
{
101-
$moduleDirName = \basename(dirname(__DIR__, 2));
101+
$moduleDirName = \basename(\dirname(__DIR__, 2));
102102
$moduleDirNameUpper = mb_strtoupper($moduleDirName);
103103
$update = '';
104104
$repository = 'XoopsModules25x/' . $moduleDirName;

class/ForumHandler.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -362,7 +362,7 @@ public function getAllTopics($forum, $criteria = null)
362362
$forum_link = '<a href="' . XOOPS_URL . '/modules/newbb/viewforum.php?forum=' . $myrow['forum_id'] . '">' . $viewAllForums[$myrow['forum_id']]['forum_name'] . '</a>';
363363
}
364364

365-
$topic_title = htmlspecialchars($myrow['topic_title'], ENT_QUOTES | ENT_HTML5);
365+
$topic_title = \htmlspecialchars($myrow['topic_title'], \ENT_QUOTES | \ENT_HTML5);
366366
// irmtfan remove here and move to for loop
367367
//if ($myrow['type_id'] > 0) {
368368
//$topic_title = '<span style="color:'.$typen[$myrow["type_id"]]["type_color"].'">['.$typen[$myrow["type_id"]]["type_name"].']</span> '.$topic_title.'';
@@ -377,15 +377,15 @@ public function getAllTopics($forum, $criteria = null)
377377
$topic_excerpt = '';
378378
} else {
379379
$topic_excerpt = \xoops_substr(\newbbHtml2text($myts->displayTarea($myrow['post_text'])), 0, $excerpt);
380-
$topic_excerpt = \str_replace('[', '&#91;', htmlspecialchars($topic_excerpt, ENT_QUOTES | ENT_HTML5));
380+
$topic_excerpt = \str_replace('[', '&#91;', \htmlspecialchars($topic_excerpt, \ENT_QUOTES | \ENT_HTML5));
381381
}
382382
// START irmtfan move here
383383

384384
//BigKev73 > Adding this code to support jumping directly to the last read post if that value exists for a user, block also would need to change to support same functionality
385385
$topicLink ='viewtopic.php?topic_id=' . $myrow['topic_id'];
386386

387387
if ($xoopsUser){
388-
$lastRead = newbbGetRead('topic', $myrow['topic_id']);
388+
$lastRead = \newbbGetRead('topic', $myrow['topic_id']);
389389
if (isset($lastRead)){
390390
if (!empty($lastRead)){
391391
if ($lastRead<$myrow['topic_last_post_id']){
@@ -421,12 +421,12 @@ public function getAllTopics($forum, $criteria = null)
421421
//mb
422422

423423
'topic_poster_uid' => $myrow['topic_poster'],
424-
'topic_poster_name' => htmlspecialchars($myrow['poster_name'] ?: $GLOBALS['xoopsConfig']['anonymous'], ENT_QUOTES | ENT_HTML5),
424+
'topic_poster_name' => \htmlspecialchars($myrow['poster_name'] ?: $GLOBALS['xoopsConfig']['anonymous'], \ENT_QUOTES | \ENT_HTML5),
425425
'topic_views' => $myrow['topic_views'],
426426
'topic_time' => \newbbFormatTimestamp($myrow['topic_time']),
427427
'topic_last_posttime' => \newbbFormatTimestamp($myrow['last_post_time']),
428428
'topic_last_poster_uid' => $myrow['uid'],
429-
'topic_last_poster_name' => htmlspecialchars($myrow['last_poster_name'] ?: $GLOBALS['xoopsConfig']['anonymous'], ENT_QUOTES | ENT_HTML5),
429+
'topic_last_poster_name' => \htmlspecialchars($myrow['last_poster_name'] ?: $GLOBALS['xoopsConfig']['anonymous'], \ENT_QUOTES | \ENT_HTML5),
430430
'topic_forum_link' => $forum_link,
431431
'topic_excerpt' => $topic_excerpt,
432432
'stick' => empty($myrow['topic_sticky']),
@@ -897,7 +897,7 @@ public function &display($forums, $length_title_index = 30, $count_subforum = 1)
897897
$users_linked = \newbbGetUnameFromIds(\array_unique($users), !empty($GLOBALS['xoopsModuleConfig']['show_realname']), true);
898898

899899
$forums_array = [];
900-
$name_anonymous = htmlspecialchars($GLOBALS['xoopsConfig']['anonymous'], ENT_QUOTES | ENT_HTML5);
900+
$name_anonymous = \htmlspecialchars($GLOBALS['xoopsConfig']['anonymous'], \ENT_QUOTES | \ENT_HTML5);
901901

902902
foreach (\array_keys($forums) as $id) {
903903
$forum = &$forums[$id];

class/IconHandler.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -97,12 +97,12 @@ public function getPath($type, $dirname = 'newbb', $default = '', $endDir = 'ima
9797
$rel_dir = "modules/{$dirname}/{$endDir}";
9898
// START irmtfan add default for all pathes
9999
if (empty($default)) {
100-
$path = \is_dir($theme_path . "/{$rel_dir}/{$type}/") ? $theme_path . "/{$rel_dir}/{$type}" : (\is_dir(XOOPS_THEME_PATH . "/default/{$rel_dir}/{$type}/") ? XOOPS_THEME_PATH . "/default/{$rel_dir}/{$type}" : $GLOBALS['xoops']->path("modules/{$dirname}/templates/{$endDir}/{$type}"));
100+
$path = \is_dir($theme_path . "/{$rel_dir}/{$type}/") ? $theme_path . "/{$rel_dir}/{$type}" : (\is_dir(\XOOPS_THEME_PATH . "/default/{$rel_dir}/{$type}/") ? \XOOPS_THEME_PATH . "/default/{$rel_dir}/{$type}" : $GLOBALS['xoops']->path("modules/{$dirname}/templates/{$endDir}/{$type}"));
101101
} else {
102-
$path = \is_dir($theme_path . "/{$rel_dir}/{$type}/") ? $theme_path . "/{$rel_dir}/{$type}" : (\is_dir($theme_path . "/{$rel_dir}/{$default}/") ? $theme_path . "/{$rel_dir}/{$default}" : (\is_dir(XOOPS_THEME_PATH . "/default/{$rel_dir}/{$type}/") ? XOOPS_THEME_PATH
103-
. "/default/{$rel_dir}/{$type}" : (\is_dir(
104-
XOOPS_THEME_PATH . "/default/{$rel_dir}/{$default}/"
105-
) ? XOOPS_THEME_PATH . "/default/{$rel_dir}/{$default}" : (\is_dir($GLOBALS['xoops']->path("modules/{$dirname}/templates/{$endDir}/{$type}/")) ? $GLOBALS['xoops']->path("modules/{$dirname}/templates/{$endDir}/{$type}") : $GLOBALS['xoops']->path(
102+
$path = \is_dir($theme_path . "/{$rel_dir}/{$type}/") ? $theme_path . "/{$rel_dir}/{$type}" : (\is_dir($theme_path . "/{$rel_dir}/{$default}/") ? $theme_path . "/{$rel_dir}/{$default}" : (\is_dir(\XOOPS_THEME_PATH . "/default/{$rel_dir}/{$type}/") ? \XOOPS_THEME_PATH
103+
. "/default/{$rel_dir}/{$type}" : (\is_dir(
104+
\XOOPS_THEME_PATH . "/default/{$rel_dir}/{$default}/"
105+
) ? \XOOPS_THEME_PATH . "/default/{$rel_dir}/{$default}" : (\is_dir($GLOBALS['xoops']->path("modules/{$dirname}/templates/{$endDir}/{$type}/")) ? $GLOBALS['xoops']->path("modules/{$dirname}/templates/{$endDir}/{$type}") : $GLOBALS['xoops']->path(
106106
"modules/{$dirname}/templates/{$endDir}/{$default}"
107107
)) // XOOPS_ROOT_PATH
108108
) // XOOPS_THEME_PATH {$default}
@@ -198,7 +198,7 @@ public function assignImages($images)
198198
}
199199

200200
/**
201-
* @return int|void
201+
* @return int
202202
*/
203203
public function render()
204204
{

0 commit comments

Comments
 (0)