Completed
Pull Request — master (#599)
by Richard
17:07
created
htdocs/modules/publisher/src/Utils.php 1 patch
Spacing   +51 added lines, -51 removed lines patch added patch discarded remove patch
@@ -183,7 +183,7 @@  discard block
 block discarded – undo
183 183
             return $helper->getModule()->getVar('name');
184 184
         }
185 185
 
186
-        return '<a href="' . $xoops->url(\PUBLISHER_URL) . '/">' . $helper->getModule()->getVar('name') . '</a>';
186
+        return '<a href="'.$xoops->url(\PUBLISHER_URL).'/">'.$helper->getModule()->getVar('name').'</a>';
187 187
     }
188 188
 
189 189
     /**
@@ -260,10 +260,10 @@  discard block
 block discarded – undo
260 260
             $path_status = _AM_PUBLISHER_AVAILABLE;
261 261
         } elseif (!@\is_dir($thePath)) {
262 262
             $pathCheckResult = -1;
263
-            $path_status = _AM_PUBLISHER_NOTAVAILABLE . " <a href='" . $helper->url("admin/index.php?op=createdir&amp;path={$item}") . "'>" . _AM_PUBLISHER_CREATETHEDIR . '</a>';
263
+            $path_status = _AM_PUBLISHER_NOTAVAILABLE." <a href='".$helper->url("admin/index.php?op=createdir&amp;path={$item}")."'>"._AM_PUBLISHER_CREATETHEDIR.'</a>';
264 264
         } else {
265 265
             $pathCheckResult = -2;
266
-            $path_status = \_AM_PUBLISHER_NOTWRITABLE . " <a href='" . $helper->url("admin/index.php?op=setperm&amp;path={$item}") . "'>" . _AM_SCS_SETMPERM . '</a>';
266
+            $path_status = \_AM_PUBLISHER_NOTWRITABLE." <a href='".$helper->url("admin/index.php?op=setperm&amp;path={$item}")."'>"._AM_SCS_SETMPERM.'</a>';
267 267
         }
268 268
         if (!$getStatus) {
269 269
             return $path_status;
@@ -327,17 +327,17 @@  discard block
 block discarded – undo
327 327
             if ('root' === $item) {
328 328
                 $item = '';
329 329
             } else {
330
-                $item = $item . '/';
330
+                $item = $item.'/';
331 331
             }
332 332
         } else {
333 333
             $item = '';
334 334
         }
335 335
 
336 336
         if ($hasPath) {
337
-            return $xoops->path(\PUBLISHER_UPLOADS_PATH . '/' . $item);
337
+            return $xoops->path(\PUBLISHER_UPLOADS_PATH.'/'.$item);
338 338
         }
339 339
 
340
-        return $xoops->url(\PUBLISHER_UPLOADS_URL . '/' . $item);
340
+        return $xoops->url(\PUBLISHER_UPLOADS_URL.'/'.$item);
341 341
     }
342 342
 
343 343
     /**
@@ -362,7 +362,7 @@  discard block
 block discarded – undo
362 362
     {
363 363
         $ret = '';
364 364
         foreach ($errors as $value) {
365
-            $ret .= '<br> - ' . $value;
365
+            $ret .= '<br> - '.$value;
366 366
         }
367 367
 
368 368
         return $ret;
@@ -447,11 +447,11 @@  discard block
 block discarded – undo
447 447
             $display = 'block';
448 448
         }
449 449
 
450
-        echo "<h3 style=\"color: #2F5376; font-weight: bold; font-size: 14px; margin: 6px 0 0 0; \"><a href='javascript:;' onclick=\"toggle('" . $tablename . "'); toggleIcon('" . $iconname . "')\";>";
451
-        echo "<img id='" . $iconname . "' src='" . $helper->url('images/links/' . $image) . "' alt=''></a>&nbsp;" . $tabletitle . '</h3>';
452
-        echo "<div id='" . $tablename . "' style='display: " . $display . ";'>";
450
+        echo "<h3 style=\"color: #2F5376; font-weight: bold; font-size: 14px; margin: 6px 0 0 0; \"><a href='javascript:;' onclick=\"toggle('".$tablename."'); toggleIcon('".$iconname."')\";>";
451
+        echo "<img id='".$iconname."' src='".$helper->url('images/links/'.$image)."' alt=''></a>&nbsp;".$tabletitle.'</h3>';
452
+        echo "<div id='".$tablename."' style='display: ".$display.";'>";
453 453
         if ('' != $tabledsc) {
454
-            echo '<span style="color: #567; margin: 3px 0 12px 0; font-size: small; display: block; ">' . $tabledsc . '</span>';
454
+            echo '<span style="color: #567; margin: 3px 0 12px 0; font-size: small; display: block; ">'.$tabledsc.'</span>';
455 455
         }
456 456
     }
457 457
 
@@ -466,14 +466,14 @@  discard block
 block discarded – undo
466 466
         $urls = self::getCurrentUrls();
467 467
         $path = $urls['phpself'];
468 468
 
469
-        $cookie_name = $path . '_publisher_collaps_' . $name;
469
+        $cookie_name = $path.'_publisher_collaps_'.$name;
470 470
         $cookie_name = \str_replace('.', '_', $cookie_name);
471 471
         $cookie = self::getCookieVar($cookie_name, '');
472 472
 
473 473
         if ('none' === $cookie) {
474 474
             echo '
475 475
         <script type="text/javascript"><!--
476
-        toggle("' . $name . '"); toggleIcon("' . $icon . '");
476
+        toggle("' . $name.'"); toggleIcon("'.$icon.'");
477 477
         //-->
478 478
         </script>
479 479
         ';
@@ -516,10 +516,10 @@  discard block
 block discarded – undo
516 516
         $querystring = $_SERVER['QUERY_STRING'] ?? '';
517 517
 
518 518
         if ('' != $querystring) {
519
-            $querystring = '?' . $querystring;
519
+            $querystring = '?'.$querystring;
520 520
         }
521 521
 
522
-        $currenturl = $http . $httphost . $phpself . $querystring;
522
+        $currenturl = $http.$httphost.$phpself.$querystring;
523 523
 
524 524
         $urls = [];
525 525
         $urls['http'] = $http;
@@ -555,13 +555,13 @@  discard block
 block discarded – undo
555 555
             $spaces .= '--';
556 556
         }
557 557
 
558
-        $ret .= "<option value='" . $categoryObj->getVar('categoryid') . "'";
558
+        $ret .= "<option value='".$categoryObj->getVar('categoryid')."'";
559 559
         if (\is_array($selectedid) && \in_array($categoryObj->getVar('categoryid'), $selectedid)) {
560 560
             $ret .= " selected='selected'";
561 561
         } elseif ($categoryObj->getVar('categoryid') == $selectedid) {
562 562
             $ret .= " selected='selected'";
563 563
         }
564
-        $ret .= '>' . $spaces . $categoryObj->getVar('name') . "</option>\n";
564
+        $ret .= '>'.$spaces.$categoryObj->getVar('name')."</option>\n";
565 565
 
566 566
         $subCategoriesObj = $helper->getCategoryHandler()->getCategories(0, 0, $categoryObj->getVar('categoryid'));
567 567
         if (\count($subCategoriesObj) > 0) {
@@ -588,13 +588,13 @@  discard block
 block discarded – undo
588 588
 
589 589
         $selectedid = \explode(',', $selectedid);
590 590
 
591
-        $ret = "<select name='" . $selectname . "[]' multiple='multiple' size='10'>";
591
+        $ret = "<select name='".$selectname."[]' multiple='multiple' size='10'>";
592 592
         if ($allCatOption) {
593 593
             $ret .= "<option value='0'";
594 594
             if (\in_array(0, $selectedid)) {
595 595
                 $ret .= " selected='selected'";
596 596
             }
597
-            $ret .= '>' . _MB_PUBLISHER_ALLCAT . '</option>';
597
+            $ret .= '>'._MB_PUBLISHER_ALLCAT.'</option>';
598 598
         }
599 599
 
600 600
         // Creating category objects
@@ -624,7 +624,7 @@  discard block
 block discarded – undo
624 624
         $ret = '';
625 625
         if ($allCatOption) {
626 626
             $ret .= "<option value='0'";
627
-            $ret .= '>' . _MB_PUBLISHER_ALLCAT . "</option>\n";
627
+            $ret .= '>'._MB_PUBLISHER_ALLCAT."</option>\n";
628 628
         }
629 629
 
630 630
         // Creating category objects
@@ -647,12 +647,12 @@  discard block
 block discarded – undo
647 647
     public static function renderErrors(&$err_arr, $reseturl = ''): void
648 648
     {
649 649
         if (\is_array($err_arr) && \count($err_arr) > 0) {
650
-            echo '<div id="readOnly" class="errorMsg" style="border:1px solid #D24D00; background:#FEFECC url(' . \PUBLISHER_URL . '/images/important-32.png) no-repeat 7px 50%;color:#333;padding-left:45px;">';
650
+            echo '<div id="readOnly" class="errorMsg" style="border:1px solid #D24D00; background:#FEFECC url('.\PUBLISHER_URL.'/images/important-32.png) no-repeat 7px 50%;color:#333;padding-left:45px;">';
651 651
 
652
-            echo '<h4 style="text-align:left;margin:0; padding-top:0">' . _AM_PUBLISHER_MSG_SUBMISSION_ERR;
652
+            echo '<h4 style="text-align:left;margin:0; padding-top:0">'._AM_PUBLISHER_MSG_SUBMISSION_ERR;
653 653
 
654 654
             if ($reseturl) {
655
-                echo ' <a href="' . $reseturl . '">[' . _AM_PUBLISHER_TEXT_SESSION_RESET . ']</a>';
655
+                echo ' <a href="'.$reseturl.'">['._AM_PUBLISHER_TEXT_SESSION_RESET.']</a>';
656 656
             }
657 657
 
658 658
             echo '</h4><ul>';
@@ -660,10 +660,10 @@  discard block
 block discarded – undo
660 660
             foreach ($err_arr as $key => $error) {
661 661
                 if (\is_array($error)) {
662 662
                     foreach ($error as $err) {
663
-                        echo '<li><a href="#' . $key . '" onclick="var e = xoopsGetElementById(\'' . $key . '\'); e.focus();">' . \htmlspecialchars($err) . '</a></li>';
663
+                        echo '<li><a href="#'.$key.'" onclick="var e = xoopsGetElementById(\''.$key.'\'); e.focus();">'.\htmlspecialchars($err).'</a></li>';
664 664
                     }
665 665
                 } else {
666
-                    echo '<li><a href="#' . $key . '" onclick="var e = xoopsGetElementById(\'' . $key . '\'); e.focus();">' . \htmlspecialchars($error) . '</a></li>';
666
+                    echo '<li><a href="#'.$key.'" onclick="var e = xoopsGetElementById(\''.$key.'\'); e.focus();">'.\htmlspecialchars($error).'</a></li>';
667 667
                 }
668 668
             }
669 669
             echo '</ul></div><br>';
@@ -691,11 +691,11 @@  discard block
 block discarded – undo
691 691
 
692 692
         $qs = '';
693 693
         foreach ($vars as $key => $value) {
694
-            $qs .= $joinStr . $key . '=' . $value;
694
+            $qs .= $joinStr.$key.'='.$value;
695 695
             $joinStr = $amp;
696 696
         }
697 697
 
698
-        return $page . '?' . $qs;
698
+        return $page.'?'.$qs;
699 699
     }
700 700
 
701 701
     /**
@@ -709,7 +709,7 @@  discard block
 block discarded – undo
709 709
         }
710 710
         $target_uri = $xoops->url($_SERVER['REQUEST_URI']);
711 711
 
712
-        return $xoops->url('modules/tellafriend/index.php?target_uri=' . \rawurlencode($target_uri) . '&amp;subject=' . \rawurlencode($subject));
712
+        return $xoops->url('modules/tellafriend/index.php?target_uri='.\rawurlencode($target_uri).'&amp;subject='.\rawurlencode($subject));
713 713
     }
714 714
 
715 715
     /**
@@ -757,7 +757,7 @@  discard block
 block discarded – undo
757 757
 
758 758
                 $message = \sprintf(_CO_PUBLISHER_MESSAGE_FILE_ERROR, $errorstxt);
759 759
                 if ($withRedirect) {
760
-                    $xoops->redirect('file.php?op=mod&itemid=' . $itemid, 5, $message);
760
+                    $xoops->redirect('file.php?op=mod&itemid='.$itemid, 5, $message);
761 761
                 } else {
762 762
                     return $message;
763 763
                 }
@@ -767,15 +767,15 @@  discard block
 block discarded – undo
767 767
         // Storing the file
768 768
         if (!$fileObj->store($allowed_mimetypes)) {
769 769
             if ($withRedirect) {
770
-                $xoops->redirect('file.php?op=mod&itemid=' . $fileObj->getVar('itemid'), 3, _CO_PUBLISHER_FILEUPLOAD_ERROR . self::formatErrors($fileObj->getErrors()));
770
+                $xoops->redirect('file.php?op=mod&itemid='.$fileObj->getVar('itemid'), 3, _CO_PUBLISHER_FILEUPLOAD_ERROR.self::formatErrors($fileObj->getErrors()));
771 771
             } else {
772
-                return _CO_PUBLISHER_FILEUPLOAD_ERROR . self::formatErrors($fileObj->getErrors());
772
+                return _CO_PUBLISHER_FILEUPLOAD_ERROR.self::formatErrors($fileObj->getErrors());
773 773
             }
774 774
         }
775 775
 
776 776
         if ($withRedirect) {
777 777
             $redirect_page = $another ? 'file.php' : 'item.php';
778
-            $xoops->redirect($redirect_page . '?op=mod&itemid=' . $fileObj->getVar('itemid'), 2, _CO_PUBLISHER_FILEUPLOAD_SUCCESS);
778
+            $xoops->redirect($redirect_page.'?op=mod&itemid='.$fileObj->getVar('itemid'), 2, _CO_PUBLISHER_FILEUPLOAD_SUCCESS);
779 779
         }
780 780
 
781 781
         return true;
@@ -783,7 +783,7 @@  discard block
 block discarded – undo
783 783
 
784 784
     public static function newFeatureTag(): string
785 785
     {
786
-        $ret = '<span style="padding-right: 4px; font-weight: bold; color: #ff0000;">' . _CO_PUBLISHER_NEW_FEATURE . '</span>';
786
+        $ret = '<span style="padding-right: 4px; font-weight: bold; color: #ff0000;">'._CO_PUBLISHER_NEW_FEATURE.'</span>';
787 787
 
788 788
         return $ret;
789 789
     }
@@ -826,7 +826,7 @@  discard block
 block discarded – undo
826 826
                 $string = self::closeTags($string);
827 827
             }
828 828
 
829
-            return $string . $etc;
829
+            return $string.$etc;
830 830
         }
831 831
 
832 832
         return $string;
@@ -862,7 +862,7 @@  discard block
 block discarded – undo
862 862
 
863 863
             $complete_tags = \array_reverse($complete_tags);
864 864
             foreach ($complete_tags as $iValue) {
865
-                $string .= '</' . $iValue . '>';
865
+                $string .= '</'.$iValue.'>';
866 866
             }
867 867
         }
868 868
 
@@ -902,36 +902,36 @@  discard block
 block discarded – undo
902 902
         $tense = 1 == $count ? _MD_PUBLISHER_VOTE_lVOTE : _MD_PUBLISHER_VOTE_lVOTES; //plural form votes/vote
903 903
 
904 904
         // now draw the rating bar
905
-        $rating_width = @\number_format($count==0 ? 0 : ($current_rating / $count), 2) * $rating_unitwidth;
906
-        $rating1 = @\number_format($count==0 ? 0 : ($current_rating / $count), 1);
907
-        $rating2 = @\number_format($count==0 ? 0 : ($current_rating / $count), 2);
905
+        $rating_width = @\number_format($count == 0 ? 0 : ($current_rating / $count), 2) * $rating_unitwidth;
906
+        $rating1 = @\number_format($count == 0 ? 0 : ($current_rating / $count), 1);
907
+        $rating2 = @\number_format($count == 0 ? 0 : ($current_rating / $count), 2);
908 908
 
909 909
         $groups = $xoops->getUserGroups();
910 910
         $gpermHandler = $helper->getGrouppermHandler();
911 911
 
912 912
         if (!$gpermHandler->checkRight('global', \_PUBLISHER_RATE, $groups, $helper->getModule()->getVar('mid'))) {
913 913
             $static_rater = [];
914
-            $static_rater[] .= "\n" . '<div class="publisher_ratingblock">';
915
-            $static_rater[] .= '<div id="unit_long' . $itemid . '">';
916
-            $static_rater[] .= '<div id="unit_ul' . $itemid . '" class="publisher_unit-rating" style="width:' . $rating_unitwidth * $units . 'px;">';
917
-            $static_rater[] .= '<div class="publisher_current-rating" style="width:' . $rating_width . 'px;">' . _MD_PUBLISHER_VOTE_RATING . ' ' . $rating2 . '/' . $units . '</div>';
914
+            $static_rater[] .= "\n".'<div class="publisher_ratingblock">';
915
+            $static_rater[] .= '<div id="unit_long'.$itemid.'">';
916
+            $static_rater[] .= '<div id="unit_ul'.$itemid.'" class="publisher_unit-rating" style="width:'.$rating_unitwidth * $units.'px;">';
917
+            $static_rater[] .= '<div class="publisher_current-rating" style="width:'.$rating_width.'px;">'._MD_PUBLISHER_VOTE_RATING.' '.$rating2.'/'.$units.'</div>';
918 918
             $static_rater[] .= '</div>';
919
-            $static_rater[] .= '<div class="publisher_static">' . _MD_PUBLISHER_VOTE_RATING . ': <strong> ' . $rating1 . '</strong>/' . $units . ' (' . $count . ' ' . $tense . ') <br><em>' . _MD_PUBLISHER_VOTE_DISABLE . '</em></div>';
919
+            $static_rater[] .= '<div class="publisher_static">'._MD_PUBLISHER_VOTE_RATING.': <strong> '.$rating1.'</strong>/'.$units.' ('.$count.' '.$tense.') <br><em>'._MD_PUBLISHER_VOTE_DISABLE.'</em></div>';
920 920
             $static_rater[] .= '</div>';
921
-            $static_rater[] .= '</div>' . "\n\n";
921
+            $static_rater[] .= '</div>'."\n\n";
922 922
 
923 923
             return \implode("\n", $static_rater);
924 924
         }
925 925
 
926 926
         $rater = '';
927 927
         $rater .= '<div class="publisher_ratingblock">';
928
-        $rater .= '<div id="unit_long' . $itemid . '">';
929
-        $rater .= '<div id="unit_ul' . $itemid . '" class="publisher_unit-rating" style="width:' . $rating_unitwidth * $units . 'px;">';
930
-        $rater .= '<div class="publisher_current-rating" style="width:' . $rating_width . 'px;">' . _MD_PUBLISHER_VOTE_RATING . ' ' . $rating2 . '/' . $units . '</div>';
928
+        $rater .= '<div id="unit_long'.$itemid.'">';
929
+        $rater .= '<div id="unit_ul'.$itemid.'" class="publisher_unit-rating" style="width:'.$rating_unitwidth * $units.'px;">';
930
+        $rater .= '<div class="publisher_current-rating" style="width:'.$rating_width.'px;">'._MD_PUBLISHER_VOTE_RATING.' '.$rating2.'/'.$units.'</div>';
931 931
 
932 932
         for ($ncount = 1; $ncount <= $units; ++$ncount) { // loop from 1 to the number of units
933 933
             if (!$voted) { // if the user hasn't yet voted, draw the voting stars
934
-                $rater .= '<div><a href="' . \PUBLISHER_URL . '/rate.php?itemid=' . $itemid . '&amp;rating=' . $ncount . '" title="' . $ncount . ' ' . _MD_PUBLISHER_VOTE_OUTOF . ' ' . $units . '" class="publisher_r' . $ncount . '-unit rater" rel="nofollow">' . $ncount . '</a></div>';
934
+                $rater .= '<div><a href="'.\PUBLISHER_URL.'/rate.php?itemid='.$itemid.'&amp;rating='.$ncount.'" title="'.$ncount.' '._MD_PUBLISHER_VOTE_OUTOF.' '.$units.'" class="publisher_r'.$ncount.'-unit rater" rel="nofollow">'.$ncount.'</a></div>';
935 935
             }
936 936
         }
937 937
 
@@ -942,7 +942,7 @@  discard block
 block discarded – undo
942 942
             $rater .= ' class="publisher_voted"';
943 943
         }
944 944
 
945
-        $rater .= '>' . _MD_PUBLISHER_VOTE_RATING . ': <strong> ' . $rating1 . '</strong>/' . $units . ' (' . $count . ' ' . $tense . ')';
945
+        $rater .= '>'._MD_PUBLISHER_VOTE_RATING.': <strong> '.$rating1.'</strong>/'.$units.' ('.$count.' '.$tense.')';
946 946
         $rater .= '  </div>';
947 947
         $rater .= '</div>';
948 948
         $rater .= '</div>';
@@ -1152,12 +1152,12 @@  discard block
 block discarded – undo
1152 1152
         $helper = Helper::getInstance();
1153 1153
         if ('none' !== $helper->getConfig('seo_url_rewrite')) {
1154 1154
             if (!empty($short_url)) {
1155
-                $short_url = $short_url . '.html';
1155
+                $short_url = $short_url.'.html';
1156 1156
             }
1157 1157
 
1158 1158
             if ('htaccess' === $helper->getConfig('seo_url_rewrite')) {
1159 1159
                 // generate SEO url using htaccess
1160
-                return XoopsBaseConfig::get('url') . '/' . $helper->getConfig('seo_module_name') . ".${op}.${id}/${short_url}";
1160
+                return XoopsBaseConfig::get('url').'/'.$helper->getConfig('seo_module_name').".${op}.${id}/${short_url}";
1161 1161
             }
1162 1162
 
1163 1163
             if ('path-info' === $helper->getConfig('seo_url_rewrite')) {
Please login to merge, or discard this patch.