| Total Complexity | 197 |
| Total Lines | 1426 |
| Duplicated Lines | 0 % |
| Changes | 11 | ||
| Bugs | 4 | Features | 0 |
Complex classes like Utility often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes.
Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.
While breaking up the class, it is a good idea to analyze how other classes use Utility, and based on these observations, apply Extract Interface, too.
| 1 | <?php |
||
| 31 | class Utility extends Common\SysUtility |
||
| 32 | { |
||
| 33 | //--------------- Custom module methods ----------------------------- |
||
| 34 | /** |
||
| 35 | * Function responsible for checking if a directory exists, we can also write in and create an index.html file |
||
| 36 | * |
||
| 37 | * @param string $folder The full path of the directory to check |
||
| 38 | */ |
||
| 39 | public static function createFolder($folder) |
||
| 40 | { |
||
| 41 | try { |
||
| 42 | if (!\is_dir($folder)) { |
||
| 43 | if (!\is_dir($folder) && !\mkdir($folder) && !\is_dir($folder)) { |
||
| 44 | throw new \RuntimeException(\sprintf('Unable to create the %s directory', $folder)); |
||
| 45 | } |
||
| 46 | file_put_contents($folder . '/index.html', '<script>history.go(-1);</script>'); |
||
| 47 | } |
||
| 48 | } catch (\Throwable $e) { |
||
| 49 | echo 'Caught exception: ', $e->getMessage(), "\n", '<br>'; |
||
| 50 | } |
||
| 51 | } |
||
| 52 | |||
| 53 | /** |
||
| 54 | * @param $file |
||
| 55 | * @param $folder |
||
| 56 | * @return bool |
||
| 57 | */ |
||
| 58 | public static function copyFile($file, $folder) |
||
| 59 | { |
||
| 60 | return \copy($file, $folder); |
||
| 61 | // try { |
||
| 62 | // if (!is_dir($folder)) { |
||
| 63 | // throw new \RuntimeException(sprintf('Unable to copy file as: %s ', $folder)); |
||
| 64 | // } else { |
||
| 65 | // return copy($file, $folder); |
||
| 66 | // } |
||
| 67 | // } catch (\Exception $e) { |
||
| 68 | // echo 'Caught exception: ', $e->getMessage(), "\n", "<br>"; |
||
| 69 | // } |
||
| 70 | // return false; |
||
| 71 | } |
||
| 72 | |||
| 73 | /** |
||
| 74 | * @param $src |
||
| 75 | * @param $dst |
||
| 76 | */ |
||
| 77 | public static function recurseCopy($src, $dst) |
||
| 78 | { |
||
| 79 | $dir = \opendir($src); |
||
| 80 | // @mkdir($dst); |
||
| 81 | while (false !== ($file = \readdir($dir))) { |
||
|
|
|||
| 82 | if (('.' !== $file) && ('..' !== $file)) { |
||
| 83 | if (\is_dir($src . '/' . $file)) { |
||
| 84 | self::recurseCopy($src . '/' . $file, $dst . '/' . $file); |
||
| 85 | } else { |
||
| 86 | \copy($src . '/' . $file, $dst . '/' . $file); |
||
| 87 | } |
||
| 88 | } |
||
| 89 | } |
||
| 90 | \closedir($dir); |
||
| 91 | } |
||
| 92 | |||
| 93 | // auto create folders---------------------------------------- |
||
| 94 | //TODO rename this function? And exclude image folder? |
||
| 95 | public static function createDir() |
||
| 96 | { |
||
| 97 | // auto crate folders |
||
| 98 | // $thePath = static::getUploadDir(); |
||
| 99 | |||
| 100 | if (static::getPathStatus('root', true) < 0) { |
||
| 101 | $thePath = static::getUploadDir(); |
||
| 102 | $res = static::mkdir($thePath); |
||
| 103 | $msg = $res ? \_AM_PUBLISHER_DIRCREATED : \_AM_PUBLISHER_DIRNOTCREATED; |
||
| 104 | } |
||
| 105 | |||
| 106 | if (static::getPathStatus('images', true) < 0) { |
||
| 107 | $thePath = static::getImageDir(); |
||
| 108 | $res = static::mkdir($thePath); |
||
| 109 | |||
| 110 | if ($res) { |
||
| 111 | $source = PUBLISHER_ROOT_PATH . '/assets/images/blank.png'; |
||
| 112 | $dest = $thePath . 'blank.png'; |
||
| 113 | static::copyr($source, $dest); |
||
| 114 | } |
||
| 115 | $msg = $res ? \_AM_PUBLISHER_DIRCREATED : \_AM_PUBLISHER_DIRNOTCREATED; |
||
| 116 | } |
||
| 117 | |||
| 118 | if (static::getPathStatus('images/category', true) < 0) { |
||
| 119 | $thePath = static::getImageDir('category'); |
||
| 120 | $res = static::mkdir($thePath); |
||
| 121 | |||
| 122 | if ($res) { |
||
| 123 | $source = PUBLISHER_ROOT_PATH . '/assets/images/blank.png'; |
||
| 124 | $dest = $thePath . 'blank.png'; |
||
| 125 | static::copyr($source, $dest); |
||
| 126 | } |
||
| 127 | $msg = $res ? \_AM_PUBLISHER_DIRCREATED : \_AM_PUBLISHER_DIRNOTCREATED; |
||
| 128 | } |
||
| 129 | |||
| 130 | if (static::getPathStatus('images/item', true) < 0) { |
||
| 131 | $thePath = static::getImageDir('item'); |
||
| 132 | $res = static::mkdir($thePath); |
||
| 133 | |||
| 134 | if ($res) { |
||
| 135 | $source = PUBLISHER_ROOT_PATH . '/assets/images/blank.png'; |
||
| 136 | $dest = $thePath . 'blank.png'; |
||
| 137 | static::copyr($source, $dest); |
||
| 138 | } |
||
| 139 | $msg = $res ? \_AM_PUBLISHER_DIRCREATED : \_AM_PUBLISHER_DIRNOTCREATED; |
||
| 140 | } |
||
| 141 | |||
| 142 | if (static::getPathStatus('content', true) < 0) { |
||
| 143 | $thePath = static::getUploadDir(true, 'content'); |
||
| 144 | $res = static::mkdir($thePath); |
||
| 145 | $msg = $res ? \_AM_PUBLISHER_DIRCREATED : \_AM_PUBLISHER_DIRNOTCREATED; |
||
| 146 | } |
||
| 147 | } |
||
| 148 | |||
| 149 | public static function buildTableItemTitleRow() |
||
| 167 | } |
||
| 168 | |||
| 169 | /** |
||
| 170 | * @param Category $categoryObj |
||
| 171 | * @param int $level |
||
| 172 | */ |
||
| 173 | public static function displayCategory(Category $categoryObj, $level = 0) |
||
| 174 | { |
||
| 175 | $helper = Helper::getInstance(); |
||
| 176 | $configurator = new Common\Configurator(); |
||
| 177 | $icons = $configurator->icons; |
||
| 178 | |||
| 179 | $description = $categoryObj->description; |
||
| 180 | if (!XOOPS_USE_MULTIBYTES && !empty($description)) { |
||
| 181 | if (\mb_strlen($description) >= 100) { |
||
| 182 | $description = \mb_substr($description, 0, 100 - 1) . '...'; |
||
| 183 | } |
||
| 184 | } |
||
| 185 | $modify = "<a href='category.php?op=mod&categoryid=" . $categoryObj->categoryid() . '&parentid=' . $categoryObj->parentid() . "'>" . $icons->edit . '</a>'; |
||
| 186 | $delete = "<a href='category.php?op=del&categoryid=" . $categoryObj->categoryid() . "'>" . $icons->delete . '</a>'; |
||
| 187 | $spaces = \str_repeat(' ', ($level * 3)); |
||
| 188 | /* |
||
| 189 | $spaces = ''; |
||
| 190 | for ($j = 0; $j < $level; ++$j) { |
||
| 191 | $spaces .= ' '; |
||
| 192 | } |
||
| 193 | */ |
||
| 194 | echo "<tr>\n" |
||
| 195 | . "<td class='even center'>" |
||
| 196 | . $categoryObj->categoryid() |
||
| 197 | . "</td>\n" |
||
| 198 | . "<td class='even left'>" |
||
| 199 | . $spaces |
||
| 200 | . "<a href='" |
||
| 201 | . PUBLISHER_URL |
||
| 202 | . '/category.php?categoryid=' |
||
| 203 | . $categoryObj->categoryid() |
||
| 204 | . "'><img src='" |
||
| 205 | . PUBLISHER_URL |
||
| 206 | . "/assets/images/links/subcat.gif' alt=''> " |
||
| 207 | . $categoryObj->name() |
||
| 208 | . "</a></td>\n" |
||
| 209 | . "<td class='even center'>" |
||
| 210 | . $categoryObj->weight() |
||
| 211 | . "</td>\n" |
||
| 212 | . "<td class='even center'> {$modify} {$delete} </td>\n" |
||
| 213 | . "</tr>\n"; |
||
| 214 | $subCategoriesObj = $helper->getHandler('Category')->getCategories(0, 0, $categoryObj->categoryid()); |
||
| 215 | if (\count($subCategoriesObj) > 0) { |
||
| 216 | ++$level; |
||
| 217 | foreach ($subCategoriesObj as $thiscat) { |
||
| 218 | self::displayCategory($thiscat, $level); |
||
| 219 | } |
||
| 220 | unset($key); |
||
| 221 | } |
||
| 222 | // unset($categoryObj); |
||
| 223 | } |
||
| 224 | |||
| 225 | |||
| 226 | /** |
||
| 227 | * @param bool $showmenu |
||
| 228 | * @param int $fileid |
||
| 229 | * @param int $itemId |
||
| 230 | */ |
||
| 231 | public static function editFile($showmenu = false, $fileid = 0, $itemId = 0) |
||
| 232 | { |
||
| 233 | $helper = Helper::getInstance(); |
||
| 234 | require_once $GLOBALS['xoops']->path('class/xoopsformloader.php'); |
||
| 235 | |||
| 236 | // if there is a parameter, and the id exists, retrieve data: we're editing a file |
||
| 237 | if (0 != $fileid) { |
||
| 238 | // Creating the File object |
||
| 239 | /** @var \XoopsModules\Publisher\File $fileObj */ |
||
| 240 | $fileObj = $helper->getHandler('File')->get($fileid); |
||
| 241 | |||
| 242 | if ($fileObj->notLoaded()) { |
||
| 243 | redirect_header('<script>javascript:history.go(-1)</script>', 1, _AM_PUBLISHER_NOFILESELECTED); |
||
| 244 | } |
||
| 245 | |||
| 246 | echo "<br>\n"; |
||
| 247 | echo "<span style='color: #2F5376; font-weight: bold; font-size: 16px; margin: 6px 6px 0 0; '>" . _AM_PUBLISHER_FILE_EDITING . '</span>'; |
||
| 248 | echo '<span style="color: #567; margin: 3px 0 12px 0; font-size: small; display: block; ">' . _AM_PUBLISHER_FILE_EDITING_DSC . '</span>'; |
||
| 249 | static::openCollapsableBar('editfile', 'editfileicon', _AM_PUBLISHER_FILE_INFORMATIONS); |
||
| 250 | } else { |
||
| 251 | // there's no parameter, so we're adding an item |
||
| 252 | $fileObj = $helper->getHandler('File')->create(); |
||
| 253 | $fileObj->setVar('itemid', $itemId); |
||
| 254 | echo "<span style='color: #2F5376; font-weight: bold; font-size: 16px; margin: 6px 6px 0 0; '>" . _AM_PUBLISHER_FILE_ADDING . '</span>'; |
||
| 255 | echo '<span style="color: #567; margin: 3px 0 12px 0; font-size: small; display: block; ">' . _AM_PUBLISHER_FILE_ADDING_DSC . '</span>'; |
||
| 256 | static::openCollapsableBar('addfile', 'addfileicon', _AM_PUBLISHER_FILE_INFORMATIONS); |
||
| 257 | } |
||
| 258 | |||
| 259 | // FILES UPLOAD FORM |
||
| 260 | /** @var File $fileObj */ |
||
| 261 | $uploadForm = $fileObj->getForm(); |
||
| 262 | $uploadForm->display(); |
||
| 263 | |||
| 264 | if (0 != $fileid) { |
||
| 265 | static::closeCollapsableBar('editfile', 'editfileicon'); |
||
| 266 | } else { |
||
| 267 | static::closeCollapsableBar('addfile', 'addfileicon'); |
||
| 268 | } |
||
| 269 | } |
||
| 270 | |||
| 271 | /** |
||
| 272 | * @param bool $showmenu |
||
| 273 | * @param int $categoryId |
||
| 274 | * @param int $nbSubCats |
||
| 275 | * @param Category|null $categoryObj |
||
| 276 | */ |
||
| 277 | public static function editCategory($showmenu = false, $categoryId = 0, $nbSubCats = 4, $categoryObj = null) |
||
| 278 | { |
||
| 279 | $helper = Helper::getInstance(); |
||
| 280 | |||
| 281 | // if there is a parameter, and the id exists, retrieve data: we're editing a category |
||
| 282 | /** @var Category $categoryObj */ |
||
| 283 | if (0 != $categoryId) { |
||
| 284 | // Creating the category object for the selected category |
||
| 285 | $categoryObj = $helper->getHandler('Category')->get($categoryId); |
||
| 286 | if ($categoryObj->notLoaded()) { |
||
| 287 | \redirect_header('category.php', 1, \_AM_PUBLISHER_NOCOLTOEDIT); |
||
| 288 | } |
||
| 289 | } elseif (null === $categoryObj) { |
||
| 290 | $categoryObj = $helper->getHandler('Category')->create(); |
||
| 291 | } |
||
| 292 | |||
| 293 | if (0 != $categoryId) { |
||
| 294 | echo "<br>\n"; |
||
| 295 | static::openCollapsableBar('edittable', 'edittableicon', \_AM_PUBLISHER_EDITCOL, \_AM_PUBLISHER_CATEGORY_EDIT_INFO); |
||
| 296 | } else { |
||
| 297 | static::openCollapsableBar('createtable', 'createtableicon', \_AM_PUBLISHER_CATEGORY_CREATE, \_AM_PUBLISHER_CATEGORY_CREATE_INFO); |
||
| 298 | } |
||
| 299 | |||
| 300 | $sform = $categoryObj->getForm($nbSubCats); |
||
| 301 | $sform->display(); |
||
| 302 | |||
| 303 | if ($categoryId) { |
||
| 304 | static::closeCollapsableBar('edittable', 'edittableicon'); |
||
| 305 | } else { |
||
| 306 | static::closeCollapsableBar('createtable', 'createtableicon'); |
||
| 307 | } |
||
| 308 | |||
| 309 | //Added by fx2024 |
||
| 310 | if ($categoryId) { |
||
| 311 | $selCat = $categoryId; |
||
| 312 | |||
| 313 | static::openCollapsableBar('subcatstable', 'subcatsicon', \_AM_PUBLISHER_SUBCAT_CAT, \_AM_PUBLISHER_SUBCAT_CAT_DSC); |
||
| 314 | // Get the total number of sub-categories |
||
| 315 | $categoriesObj = $helper->getHandler('Category')->get($selCat); |
||
| 316 | $totalsubs = $helper->getHandler('Category')->getCategoriesCount($selCat); |
||
| 317 | // creating the categories objects that are published |
||
| 318 | $subcatsObj = $helper->getHandler('Category')->getCategories(0, 0, $categoriesObj->categoryid()); |
||
| 319 | $totalSCOnPage = \count($subcatsObj); |
||
| 320 | echo "<table width='100%' cellspacing=1 cellpadding=3 border=0 class = outer>"; |
||
| 321 | echo '<tr>'; |
||
| 322 | echo "<td width='60' class='bg3' align='left'><strong>" . \_AM_PUBLISHER_CATID . '</strong></td>'; |
||
| 323 | echo "<td width='20%' class='bg3' align='left'><strong>" . \_AM_PUBLISHER_CATCOLNAME . '</strong></td>'; |
||
| 324 | echo "<td class='bg3' align='left'><strong>" . \_AM_PUBLISHER_SUBDESCRIPT . '</strong></td>'; |
||
| 325 | echo "<td width='60' class='bg3' align='right'><strong>" . \_AM_PUBLISHER_ACTION . '</strong></td>'; |
||
| 326 | echo '</tr>'; |
||
| 327 | if ($totalsubs > 0) { |
||
| 328 | foreach ($subcatsObj as $subcat) { |
||
| 329 | $modify = "<a href='category.php?op=mod&categoryid=" . $subcat->categoryid() . "'>" . $icons->edit . '</a>'; |
||
| 330 | $delete = "<a href='category.php?op=del&categoryid=" . $subcat->categoryid() . "'>" . $icons->delete . '</a>'; |
||
| 331 | echo '<tr>'; |
||
| 332 | echo "<td class='head' align='left'>" . $subcat->categoryid() . '</td>'; |
||
| 333 | echo "<td class='even' align='left'><a href='" . XOOPS_URL . '/modules/' . $helper->getModule()->dirname() . '/category.php?categoryid=' . $subcat->categoryid() . '&parentid=' . $subcat->parentid() . "'>" . $subcat->name() . '</a></td>'; |
||
| 334 | echo "<td class='even' align='left'>" . $subcat->description() . '</td>'; |
||
| 335 | echo "<td class='even' align='right'> {$modify} {$delete} </td>"; |
||
| 336 | echo '</tr>'; |
||
| 337 | } |
||
| 338 | // unset($subcat); |
||
| 339 | } else { |
||
| 340 | echo '<tr>'; |
||
| 341 | echo "<td class='head' align='center' colspan= '7'>" . \_AM_PUBLISHER_NOSUBCAT . '</td>'; |
||
| 342 | echo '</tr>'; |
||
| 343 | } |
||
| 344 | echo "</table>\n"; |
||
| 345 | echo "<br>\n"; |
||
| 346 | static::closeCollapsableBar('subcatstable', 'subcatsicon'); |
||
| 347 | |||
| 348 | static::openCollapsableBar('bottomtable', 'bottomtableicon', \_AM_PUBLISHER_CAT_ITEMS, \_AM_PUBLISHER_CAT_ITEMS_DSC); |
||
| 349 | $startitem = Request::getInt('startitem'); |
||
| 350 | // Get the total number of published ITEMS |
||
| 351 | $totalitems = $helper->getHandler('Item')->getItemsCount($selCat, [Constants::PUBLISHER_STATUS_PUBLISHED]); |
||
| 352 | // creating the items objects that are published |
||
| 353 | $itemsObj = $helper->getHandler('Item')->getAllPublished($helper->getConfig('idxcat_perpage'), $startitem, $selCat); |
||
| 354 | $allcats = $helper->getHandler('Category')->getObjects(null, true); |
||
| 355 | echo "<table width='100%' cellspacing=1 cellpadding=3 border=0 class = outer>"; |
||
| 356 | echo '<tr>'; |
||
| 357 | echo "<td width='40' class='bg3' align='center'><strong>" . \_AM_PUBLISHER_ITEMID . '</strong></td>'; |
||
| 358 | echo "<td width='20%' class='bg3' align='left'><strong>" . \_AM_PUBLISHER_ITEMCOLNAME . '</strong></td>'; |
||
| 359 | echo "<td class='bg3' align='left'><strong>" . \_AM_PUBLISHER_ITEMDESC . '</strong></td>'; |
||
| 360 | echo "<td width='90' class='bg3' align='center'><strong>" . \_AM_PUBLISHER_CREATED . '</strong></td>'; |
||
| 361 | echo "<td width='60' class='bg3' align='center'><strong>" . \_AM_PUBLISHER_ACTION . '</strong></td>'; |
||
| 362 | echo '</tr>'; |
||
| 363 | if ($totalitems > 0) { |
||
| 364 | foreach ($itemsObj as $iValue) { |
||
| 365 | $categoryObj = $allcats[$iValue->categoryid()]; |
||
| 366 | $modify = "<a href='item.php?op=mod&itemid=" . $iValue->itemid() . "'>" . $icons->edit . '</a>'; |
||
| 367 | $delete = "<a href='item.php?op=del&itemid=" . $iValue->itemid() . "'>" . $icons->delete . '</a>'; |
||
| 368 | echo '<tr>'; |
||
| 369 | echo "<td class='head' align='center'>" . $iValue->itemid() . '</td>'; |
||
| 370 | echo "<td class='even' align='left'>" . $categoryObj->name() . '</td>'; |
||
| 371 | echo "<td class='even' align='left'>" . $iValue->getitemLink() . '</td>'; |
||
| 372 | echo "<td class='even' align='center'>" . $iValue->getDatesub('s') . '</td>'; |
||
| 373 | echo "<td class='even' align='center'> $modify $delete </td>"; |
||
| 374 | echo '</tr>'; |
||
| 375 | } |
||
| 376 | } else { |
||
| 377 | $itemId = -1; |
||
| 378 | echo '<tr>'; |
||
| 379 | echo "<td class='head' align='center' colspan= '7'>" . \_AM_PUBLISHER_NOITEMS . '</td>'; |
||
| 380 | echo '</tr>'; |
||
| 381 | } |
||
| 382 | echo "</table>\n"; |
||
| 383 | echo "<br>\n"; |
||
| 384 | $parentid = Request::getInt('parentid', 0, 'GET'); |
||
| 385 | $pagenavExtraArgs = "op=mod&categoryid=$selCat&parentid=$parentid"; |
||
| 386 | \xoops_load('XoopsPageNav'); |
||
| 387 | $pagenav = new \XoopsPageNav($totalitems, $helper->getConfig('idxcat_perpage'), $startitem, 'startitem', $pagenavExtraArgs); |
||
| 388 | echo '<div style="text-align:right;">' . $pagenav->renderNav() . '</div>'; |
||
| 389 | echo "<input type='button' name='button' onclick=\"location='item.php?op=mod&categoryid=" . $selCat . "'\" value='" . \_AM_PUBLISHER_CREATEITEM . "'> "; |
||
| 390 | echo '</div>'; |
||
| 391 | } |
||
| 392 | //end of fx2024 code |
||
| 393 | } |
||
| 394 | |||
| 395 | //======================== FUNCTIONS ================================= |
||
| 396 | |||
| 397 | /** |
||
| 398 | * Includes scripts in HTML header |
||
| 399 | */ |
||
| 400 | public static function cpHeader() |
||
| 401 | { |
||
| 402 | \xoops_cp_header(); |
||
| 403 | |||
| 404 | //cannot use xoTheme, some conflit with admin gui |
||
| 405 | echo '<link type="text/css" href="' . XOOPS_URL . '/modules/system/css/ui/' . \xoops_getModuleOption('jquery_theme', 'system') . '/ui.all.css" rel="stylesheet"> |
||
| 406 | <link type="text/css" href="' . PUBLISHER_URL . '/assets/css/publisher.css" rel="stylesheet"> |
||
| 407 | <script type="text/javascript" src="' . PUBLISHER_URL . '/assets/js/funcs.js"></script> |
||
| 408 | <script type="text/javascript" src="' . PUBLISHER_URL . '/assets/js/cookies.js"></script> |
||
| 409 | <script type="text/javascript" src="' . XOOPS_URL . '/browse.php?Frameworks/jquery/jquery.js"></script> |
||
| 410 | <!-- <script type="text/javascript" src="' . XOOPS_URL . '/browse.php?Frameworks/jquery/jquery-migrate-1.2.1.js"></script> --> |
||
| 411 | <script type="text/javascript" src="' . XOOPS_URL . '/browse.php?Frameworks/jquery/plugins/jquery.ui.js"></script> |
||
| 412 | <script type="text/javascript" src="' . PUBLISHER_URL . '/assets/js/ajaxupload.3.9.js"></script> |
||
| 413 | <script type="text/javascript" src="' . PUBLISHER_URL . '/assets/js/publisher.js"></script> |
||
| 414 | '; |
||
| 415 | } |
||
| 416 | |||
| 417 | /** |
||
| 418 | * Default sorting for a given order |
||
| 419 | * |
||
| 420 | * @param string $sort |
||
| 421 | * @return string |
||
| 422 | */ |
||
| 423 | public static function getOrderBy($sort) |
||
| 424 | { |
||
| 425 | if ('datesub' === $sort) { |
||
| 426 | return 'DESC'; |
||
| 427 | } |
||
| 428 | if ('counter' === $sort) { |
||
| 429 | return 'DESC'; |
||
| 430 | } |
||
| 431 | if ('weight' === $sort) { |
||
| 432 | return 'ASC'; |
||
| 433 | } |
||
| 434 | if ('votes' === $sort) { |
||
| 435 | return 'DESC'; |
||
| 436 | } |
||
| 437 | if ('rating' === $sort) { |
||
| 438 | return 'DESC'; |
||
| 439 | } |
||
| 440 | if ('comments' === $sort) { |
||
| 441 | return 'DESC'; |
||
| 442 | } |
||
| 443 | |||
| 444 | return null; |
||
| 445 | } |
||
| 446 | |||
| 447 | /** |
||
| 448 | * @credits Thanks to Mithandir |
||
| 449 | * @param string $str |
||
| 450 | * @param int $start |
||
| 451 | * @param int $length |
||
| 452 | * @param string $trimMarker |
||
| 453 | * @return string |
||
| 454 | */ |
||
| 455 | public static function substr($str, $start, $length, $trimMarker = '...') |
||
| 456 | { |
||
| 457 | // if the string is empty, let's get out ;-) |
||
| 458 | if ('' == $str) { |
||
| 459 | return $str; |
||
| 460 | } |
||
| 461 | |||
| 462 | // reverse a string that is shortened with '' as trimmarker |
||
| 463 | $reversedString = \strrev(\xoops_substr($str, $start, $length, '')); |
||
| 464 | |||
| 465 | // find first space in reversed string |
||
| 466 | $positionOfSpace = \mb_strpos($reversedString, ' ', 0); |
||
| 467 | |||
| 468 | // truncate the original string to a length of $length |
||
| 469 | // minus the position of the last space |
||
| 470 | // plus the length of the $trimMarker |
||
| 471 | $truncatedString = \xoops_substr($str, $start, $length - $positionOfSpace + \mb_strlen($trimMarker), $trimMarker); |
||
| 472 | |||
| 473 | return $truncatedString; |
||
| 474 | } |
||
| 475 | |||
| 476 | /** |
||
| 477 | * @param string $document |
||
| 478 | * @return mixed |
||
| 479 | */ |
||
| 480 | public static function html2text($document) |
||
| 481 | { |
||
| 482 | // PHP Manual:: function preg_replace |
||
| 483 | // $document should contain an HTML document. |
||
| 484 | // This will remove HTML tags, javascript sections |
||
| 485 | // and white space. It will also convert some |
||
| 486 | // common HTML entities to their text equivalent. |
||
| 487 | // Credits : newbb2 |
||
| 488 | $search = [ |
||
| 489 | "'<script[^>]*?>.*?</script>'si", // Strip out javascript |
||
| 490 | "'<img.*?>'si", // Strip out img tags |
||
| 491 | "'<[\/\!]*?[^<>]*?>'si", // Strip out HTML tags |
||
| 492 | "'([\r\n])[\s]+'", // Strip out white space |
||
| 493 | "'&(quot|#34);'i", // Replace HTML entities |
||
| 494 | "'&(amp|#38);'i", |
||
| 495 | "'&(lt|#60);'i", |
||
| 496 | "'&(gt|#62);'i", |
||
| 497 | "'&(nbsp|#160);'i", |
||
| 498 | "'&(iexcl|#161);'i", |
||
| 499 | "'&(cent|#162);'i", |
||
| 500 | "'&(pound|#163);'i", |
||
| 501 | "'&(copy|#169);'i", |
||
| 502 | ]; // evaluate as php |
||
| 503 | |||
| 504 | $replace = [ |
||
| 505 | '', |
||
| 506 | '', |
||
| 507 | '', |
||
| 508 | '\\1', |
||
| 509 | '"', |
||
| 510 | '&', |
||
| 511 | '<', |
||
| 512 | '>', |
||
| 513 | ' ', |
||
| 514 | \chr(161), |
||
| 515 | \chr(162), |
||
| 516 | \chr(163), |
||
| 517 | \chr(169), |
||
| 518 | ]; |
||
| 519 | |||
| 520 | $text = \preg_replace($search, $replace, $document); |
||
| 521 | |||
| 522 | \preg_replace_callback( |
||
| 523 | '/&#(\d+);/', |
||
| 524 | static function ($matches) { |
||
| 525 | return \chr($matches[1]); |
||
| 526 | }, |
||
| 527 | $document |
||
| 528 | ); |
||
| 529 | |||
| 530 | return $text; |
||
| 531 | //<?php |
||
| 532 | } |
||
| 533 | |||
| 534 | /** |
||
| 535 | * @return array |
||
| 536 | */ |
||
| 537 | public static function getAllowedImagesTypes() |
||
| 538 | { |
||
| 539 | return ['jpg/jpeg', 'image/bmp', 'image/gif', 'image/jpeg', 'image/jpg', 'image/x-png', 'image/png', 'image/pjpeg']; |
||
| 540 | } |
||
| 541 | |||
| 542 | /** |
||
| 543 | * @param bool $withLink |
||
| 544 | * @return string |
||
| 545 | */ |
||
| 546 | public static function moduleHome($withLink = true) |
||
| 547 | { |
||
| 548 | $helper = Helper::getInstance(); |
||
| 549 | |||
| 550 | if (!$helper->getConfig('format_breadcrumb_modname')) { |
||
| 551 | return ''; |
||
| 552 | } |
||
| 553 | |||
| 554 | if (!$withLink) { |
||
| 555 | return $helper->getModule()->getVar('name'); |
||
| 556 | } |
||
| 557 | |||
| 558 | return '<a href="' . PUBLISHER_URL . '/">' . $helper->getModule()->getVar('name') . '</a>'; |
||
| 559 | } |
||
| 560 | |||
| 561 | /** |
||
| 562 | * Copy a file, or a folder and its contents |
||
| 563 | * |
||
| 564 | * @param string $source The source |
||
| 565 | * @param string $dest The destination |
||
| 566 | * @return bool Returns true on success, false on failure |
||
| 567 | * @version 1.0.0 |
||
| 568 | * @author Aidan Lister <[email protected]> |
||
| 569 | */ |
||
| 570 | public static function copyr($source, $dest) |
||
| 571 | { |
||
| 572 | // Simple copy for a file |
||
| 573 | if (\is_file($source)) { |
||
| 574 | return \copy($source, $dest); |
||
| 575 | } |
||
| 576 | |||
| 577 | // Make destination directory |
||
| 578 | if (!\is_dir($dest) && !\mkdir($dest) && !\is_dir($dest)) { |
||
| 579 | throw new \RuntimeException(\sprintf('Directory "%s" was not created', $dest)); |
||
| 580 | } |
||
| 581 | |||
| 582 | // Loop through the folder |
||
| 583 | $dir = \dir($source); |
||
| 584 | while (false !== ($entry = $dir->read())) { |
||
| 585 | // Skip pointers |
||
| 586 | if ('.' === $entry || '..' === $entry) { |
||
| 587 | continue; |
||
| 588 | } |
||
| 589 | |||
| 590 | // Deep copy directories |
||
| 591 | if (("$source/$entry" !== $dest) && \is_dir("$source/$entry")) { |
||
| 592 | static::copyr("$source/$entry", "$dest/$entry"); |
||
| 593 | } else { |
||
| 594 | \copy("$source/$entry", "$dest/$entry"); |
||
| 595 | } |
||
| 596 | } |
||
| 597 | |||
| 598 | // Clean up |
||
| 599 | $dir->close(); |
||
| 600 | |||
| 601 | return true; |
||
| 602 | } |
||
| 603 | |||
| 604 | /** |
||
| 605 | * .* @credits Thanks to the NewBB2 Development Team |
||
| 606 | * @param string $item |
||
| 607 | * @param bool $getStatus |
||
| 608 | * @return bool|int|string |
||
| 609 | */ |
||
| 610 | public static function getPathStatus($item, $getStatus = false) |
||
| 611 | { |
||
| 612 | $path = ''; |
||
| 613 | if ('root' !== $item) { |
||
| 614 | $path = $item; |
||
| 615 | } |
||
| 616 | |||
| 617 | $thePath = static::getUploadDir(true, $path); |
||
| 618 | |||
| 619 | if (empty($thePath)) { |
||
| 620 | return false; |
||
| 621 | } |
||
| 622 | if (\is_writable($thePath)) { |
||
| 623 | $pathCheckResult = 1; |
||
| 624 | $pathStatus = \_AM_PUBLISHER_AVAILABLE; |
||
| 625 | } elseif (@\is_dir($thePath)) { |
||
| 626 | $pathCheckResult = -2; |
||
| 627 | $pathStatus = \_AM_PUBLISHER_NOTWRITABLE . " <a href='" . PUBLISHER_ADMIN_URL . "/index.php?op=setperm&path={$item}'>" . \_AM_PUBLISHER_SETMPERM . '</a>'; |
||
| 628 | } else { |
||
| 629 | $pathCheckResult = -1; |
||
| 630 | $pathStatus = \_AM_PUBLISHER_NOTAVAILABLE . " <a href='" . PUBLISHER_ADMIN_URL . "/index.php?op=createdir&path={$item}'>" . \_AM_PUBLISHER_CREATETHEDIR . '</a>'; |
||
| 631 | } |
||
| 632 | if (!$getStatus) { |
||
| 633 | return $pathStatus; |
||
| 634 | } |
||
| 635 | |||
| 636 | return $pathCheckResult; |
||
| 637 | } |
||
| 638 | |||
| 639 | /** |
||
| 640 | * @credits Thanks to the NewBB2 Development Team |
||
| 641 | * @param string $target |
||
| 642 | * @return bool |
||
| 643 | */ |
||
| 644 | public static function mkdir($target) |
||
| 645 | { |
||
| 646 | // http://www.php.net/manual/en/function.mkdir.php |
||
| 647 | // saint at corenova.com |
||
| 648 | // bart at cdasites dot com |
||
| 649 | if (empty($target) || \is_dir($target)) { |
||
| 650 | return true; // best case check first |
||
| 651 | } |
||
| 652 | |||
| 653 | if (\is_dir($target) && !\is_dir($target)) { |
||
| 654 | return false; |
||
| 655 | } |
||
| 656 | |||
| 657 | if (static::mkdir(\mb_substr($target, 0, \mb_strrpos($target, '/')))) { |
||
| 658 | if (!\is_dir($target)) { |
||
| 659 | $res = \mkdir($target, 0777); // crawl back up & create dir tree |
||
| 660 | static::chmod($target); |
||
| 661 | |||
| 662 | return $res; |
||
| 663 | } |
||
| 664 | } |
||
| 665 | $res = \is_dir($target); |
||
| 666 | |||
| 667 | return $res; |
||
| 668 | } |
||
| 669 | |||
| 670 | /** |
||
| 671 | * @credits Thanks to the NewBB2 Development Team |
||
| 672 | * @param string $target |
||
| 673 | * @param int $mode |
||
| 674 | * @return bool |
||
| 675 | */ |
||
| 676 | public static function chmod($target, $mode = 0777) |
||
| 677 | { |
||
| 678 | return @\chmod($target, $mode); |
||
| 679 | } |
||
| 680 | |||
| 681 | /** |
||
| 682 | * @param bool $hasPath |
||
| 683 | * @param string $item |
||
| 684 | * @return string |
||
| 685 | */ |
||
| 686 | public static function getUploadDir($hasPath = true, $item = '') |
||
| 687 | { |
||
| 688 | if ('' !== $item) { |
||
| 689 | if ('root' === $item) { |
||
| 690 | $item = ''; |
||
| 691 | } else { |
||
| 692 | $item .= '/'; |
||
| 693 | } |
||
| 694 | } |
||
| 695 | |||
| 696 | if ($hasPath) { |
||
| 697 | return PUBLISHER_UPLOAD_PATH . '/' . $item; |
||
| 698 | } |
||
| 699 | |||
| 700 | return PUBLISHER_UPLOAD_URL . '/' . $item; |
||
| 701 | } |
||
| 702 | |||
| 703 | /** |
||
| 704 | * @param string $item |
||
| 705 | * @param bool $hasPath |
||
| 706 | * @return string |
||
| 707 | */ |
||
| 708 | public static function getImageDir($item = '', $hasPath = true) |
||
| 709 | { |
||
| 710 | if ($item) { |
||
| 711 | $item = "images/{$item}"; |
||
| 712 | } else { |
||
| 713 | $item = 'images'; |
||
| 714 | } |
||
| 715 | |||
| 716 | return static::getUploadDir($hasPath, $item); |
||
| 717 | } |
||
| 718 | |||
| 719 | /** |
||
| 720 | * @param array $errors |
||
| 721 | * @return string |
||
| 722 | */ |
||
| 723 | public static function formatErrors($errors = []) |
||
| 724 | { |
||
| 725 | $ret = ''; |
||
| 726 | foreach ($errors as $key => $value) { |
||
| 727 | $ret .= '<br> - ' . $value; |
||
| 728 | } |
||
| 729 | |||
| 730 | return $ret; |
||
| 731 | } |
||
| 732 | |||
| 733 | /** |
||
| 734 | * Checks if a user is admin of Publisher |
||
| 735 | * |
||
| 736 | * @return bool |
||
| 737 | */ |
||
| 738 | public static function userIsAdmin() |
||
| 739 | { |
||
| 740 | $helper = Helper::getInstance(); |
||
| 741 | |||
| 742 | static $publisherIsAdmin; |
||
| 743 | |||
| 744 | if (null !== $publisherIsAdmin) { |
||
| 745 | return $publisherIsAdmin; |
||
| 746 | } |
||
| 747 | |||
| 748 | if ($GLOBALS['xoopsUser']) { |
||
| 749 | // $publisherIsAdmin = $GLOBALS['xoopsUser']->isAdmin($helper->getModule()->getVar('mid')); |
||
| 750 | $publisherIsAdmin = $helper->isUserAdmin(); |
||
| 751 | } else { |
||
| 752 | $publisherIsAdmin = false; |
||
| 753 | } |
||
| 754 | |||
| 755 | return $publisherIsAdmin; |
||
| 756 | } |
||
| 757 | |||
| 758 | /** |
||
| 759 | * Check is current user is author of a given article |
||
| 760 | * |
||
| 761 | * @param \XoopsObject $itemObj |
||
| 762 | * @return bool |
||
| 763 | */ |
||
| 764 | public static function userIsAuthor($itemObj) |
||
| 765 | { |
||
| 766 | return (\is_object($GLOBALS['xoopsUser']) && \is_object($itemObj) && ($GLOBALS['xoopsUser']->uid() == $itemObj->uid())); |
||
| 767 | } |
||
| 768 | |||
| 769 | /** |
||
| 770 | * Check is current user is moderator of a given article |
||
| 771 | * |
||
| 772 | * @param \XoopsObject $itemObj |
||
| 773 | * @return bool |
||
| 774 | */ |
||
| 775 | public static function userIsModerator($itemObj) |
||
| 776 | { |
||
| 777 | $helper = Helper::getInstance(); |
||
| 778 | $categoriesGranted = $helper->getHandler('Permission')->getGrantedItems('category_moderation'); |
||
| 779 | |||
| 780 | return (\is_object($itemObj) && \in_array($itemObj->categoryid(), $categoriesGranted, true)); |
||
| 781 | } |
||
| 782 | |||
| 783 | /** |
||
| 784 | * Saves permissions for the selected category |
||
| 785 | * |
||
| 786 | * @param null|array $groups : group with granted permission |
||
| 787 | * @param int $categoryId : categoryid on which we are setting permissions |
||
| 788 | * @param string $permName : name of the permission |
||
| 789 | * @return bool : TRUE if the no errors occured |
||
| 790 | */ |
||
| 791 | public static function saveCategoryPermissions($groups, $categoryId, $permName) |
||
| 792 | { |
||
| 793 | $helper = Helper::getInstance(); |
||
| 794 | |||
| 795 | $result = true; |
||
| 796 | |||
| 797 | $moduleId = $helper->getModule()->getVar('mid'); |
||
| 798 | /** @var \XoopsGroupPermHandler $grouppermHandler */ |
||
| 799 | $grouppermHandler = \xoops_getHandler('groupperm'); |
||
| 800 | // First, if the permissions are already there, delete them |
||
| 801 | $grouppermHandler->deleteByModule($moduleId, $permName, $categoryId); |
||
| 802 | |||
| 803 | // Save the new permissions |
||
| 804 | if (\count($groups) > 0) { |
||
| 805 | foreach ($groups as $groupId) { |
||
| 806 | $grouppermHandler->addRight($permName, $categoryId, $groupId, $moduleId); |
||
| 807 | } |
||
| 808 | } |
||
| 809 | |||
| 810 | return $result; |
||
| 811 | } |
||
| 812 | |||
| 813 | /** |
||
| 814 | * @param string $tablename |
||
| 815 | * @param string $iconname |
||
| 816 | * @param string $tabletitle |
||
| 817 | * @param string $tabledsc |
||
| 818 | * @param bool $open |
||
| 819 | */ |
||
| 820 | public static function openCollapsableBar($tablename = '', $iconname = '', $tabletitle = '', $tabledsc = '', $open = true) |
||
| 821 | { |
||
| 822 | $image = 'open12.gif'; |
||
| 823 | $display = 'none'; |
||
| 824 | if ($open) { |
||
| 825 | $image = 'close12.gif'; |
||
| 826 | $display = 'block'; |
||
| 827 | } |
||
| 828 | |||
| 829 | echo "<h3 style=\"color: #2F5376; font-weight: bold; font-size: 14px; margin: 6px 0 0 0; \"><a href='javascript:;' onclick=\"toggle('" . $tablename . "'); toggleIcon('" . $iconname . "')\">"; |
||
| 830 | echo "<img id='" . $iconname . "' src='" . PUBLISHER_URL . '/assets/images/links/' . $image . "' alt=''></a> " . $tabletitle . '</h3>'; |
||
| 831 | echo "<div id='" . $tablename . "' style='display: " . $display . ";'>"; |
||
| 832 | if ('' != $tabledsc) { |
||
| 833 | echo '<span style="color: #567; margin: 3px 0 12px 0; font-size: small; display: block; ">' . $tabledsc . '</span>'; |
||
| 834 | } |
||
| 835 | } |
||
| 836 | |||
| 837 | /** |
||
| 838 | * @param string $name |
||
| 839 | * @param string $icon |
||
| 840 | */ |
||
| 841 | public static function closeCollapsableBar($name, $icon) |
||
| 842 | { |
||
| 843 | echo '</div>'; |
||
| 844 | |||
| 845 | $urls = static::getCurrentUrls(); |
||
| 846 | $path = $urls['phpself']; |
||
| 847 | |||
| 848 | $cookieName = $path . '_publisher_collaps_' . $name; |
||
| 849 | $cookieName = \str_replace('.', '_', $cookieName); |
||
| 850 | $cookie = static::getCookieVar($cookieName, ''); |
||
| 851 | |||
| 852 | if ('none' === $cookie) { |
||
| 853 | echo ' |
||
| 854 | <script type="text/javascript"> |
||
| 855 | <!-- |
||
| 856 | toggle("' . $name . '"); |
||
| 857 | toggleIcon("' . $icon . '"); |
||
| 858 | --> |
||
| 859 | </script> |
||
| 860 | '; |
||
| 861 | } |
||
| 862 | } |
||
| 863 | |||
| 864 | /** |
||
| 865 | * @param string $name |
||
| 866 | * @param string $value |
||
| 867 | * @param int $time |
||
| 868 | */ |
||
| 869 | public static function setCookieVar($name, $value, $time = 0) |
||
| 870 | { |
||
| 871 | if (0 === $time) { |
||
| 872 | $time = \time() + 3600 * 24 * 365; |
||
| 873 | } |
||
| 874 | // setcookie($name, $value, $time, '/'); |
||
| 875 | setcookie($name, $value, $time, '/', ini_get('session.cookie_domain'), (bool)ini_get('session.cookie_secure'), (bool)ini_get('session.cookie_httponly')); |
||
| 876 | } |
||
| 877 | |||
| 878 | /** |
||
| 879 | * @param string $name |
||
| 880 | * @param string $default |
||
| 881 | * @return string |
||
| 882 | */ |
||
| 883 | public static function getCookieVar($name, $default = '') |
||
| 884 | { |
||
| 885 | // if (isset($_COOKIE[$name]) && ($_COOKIE[$name] > '')) { |
||
| 886 | // return $_COOKIE[$name]; |
||
| 887 | // } else { |
||
| 888 | // return $default; |
||
| 889 | // } |
||
| 890 | return Request::getString($name, $default, 'COOKIE'); |
||
| 891 | } |
||
| 892 | |||
| 893 | /** |
||
| 894 | * @return array |
||
| 895 | */ |
||
| 896 | public static function getCurrentUrls() |
||
| 897 | { |
||
| 898 | $http = false === \mb_strpos(XOOPS_URL, 'https://') ? 'http://' : 'https://'; |
||
| 899 | // $phpself = $_SERVER['SCRIPT_NAME']; |
||
| 900 | // $httphost = $_SERVER['HTTP_HOST']; |
||
| 901 | // $querystring = isset($_SERVER['QUERY_STRING']) ? $_SERVER['QUERY_STRING'] : ''; |
||
| 902 | $phpself = Request::getString('SCRIPT_NAME', '', 'SERVER'); |
||
| 903 | $httphost = Request::getString('HTTP_HOST', '', 'SERVER'); |
||
| 904 | $querystring = Request::getString('QUERY_STRING', '', 'SERVER'); |
||
| 905 | |||
| 906 | if ('' != $querystring) { |
||
| 907 | $querystring = '?' . $querystring; |
||
| 908 | } |
||
| 909 | |||
| 910 | $currenturl = $http . $httphost . $phpself . $querystring; |
||
| 911 | |||
| 912 | $urls = []; |
||
| 913 | $urls['http'] = $http; |
||
| 914 | $urls['httphost'] = $httphost; |
||
| 915 | $urls['phpself'] = $phpself; |
||
| 916 | $urls['querystring'] = $querystring; |
||
| 917 | $urls['full'] = $currenturl; |
||
| 918 | |||
| 919 | return $urls; |
||
| 920 | } |
||
| 921 | |||
| 922 | /** |
||
| 923 | * @return string |
||
| 924 | */ |
||
| 925 | public static function getCurrentPage() |
||
| 926 | { |
||
| 927 | $urls = static::getCurrentUrls(); |
||
| 928 | |||
| 929 | return $urls['full']; |
||
| 930 | } |
||
| 931 | |||
| 932 | /** |
||
| 933 | * @param null|Category $categoryObj |
||
| 934 | * @param int|array $selectedId |
||
| 935 | * @param int $level |
||
| 936 | * @param string $ret |
||
| 937 | * @return string |
||
| 938 | */ |
||
| 939 | public static function addCategoryOption(Category $categoryObj, $selectedId = 0, $level = 0, $ret = '') |
||
| 940 | { |
||
| 941 | $helper = Helper::getInstance(); |
||
| 942 | |||
| 943 | $spaces = ''; |
||
| 944 | for ($j = 0; $j < $level; ++$j) { |
||
| 945 | $spaces .= '--'; |
||
| 946 | } |
||
| 947 | |||
| 948 | $ret .= "<option value='" . $categoryObj->categoryid() . "'"; |
||
| 949 | if (\is_array($selectedId) && \in_array($categoryObj->categoryid(), $selectedId, true)) { |
||
| 950 | $ret .= ' selected'; |
||
| 951 | } elseif ($categoryObj->categoryid() == $selectedId) { |
||
| 952 | $ret .= ' selected'; |
||
| 953 | } |
||
| 954 | $ret .= '>' . $spaces . $categoryObj->name() . "</option>\n"; |
||
| 955 | |||
| 956 | $subCategoriesObj = $helper->getHandler('Category')->getCategories(0, 0, $categoryObj->categoryid()); |
||
| 957 | if (\count($subCategoriesObj) > 0) { |
||
| 958 | ++$level; |
||
| 959 | foreach ($subCategoriesObj as $catId => $subCategoryObj) { |
||
| 960 | $ret .= static::addCategoryOption($subCategoryObj, $selectedId, $level); |
||
| 961 | } |
||
| 962 | } |
||
| 963 | |||
| 964 | return $ret; |
||
| 965 | } |
||
| 966 | |||
| 967 | /** |
||
| 968 | * @param int|array $selectedId |
||
| 969 | * @param int $parentcategory |
||
| 970 | * @param bool $allCatOption |
||
| 971 | * @param string $selectname |
||
| 972 | * @param bool $multiple |
||
| 973 | * @return string |
||
| 974 | */ |
||
| 975 | public static function createCategorySelect($selectedId = 0, $parentcategory = 0, $allCatOption = true, $selectname = 'options[1]', $multiple = true) |
||
| 976 | { |
||
| 977 | $helper = Helper::getInstance(); |
||
| 978 | |||
| 979 | $selectedId = \explode(',', $selectedId); |
||
| 980 | $selectedId = \array_map('\intval', $selectedId); |
||
| 981 | $selMultiple = ''; |
||
| 982 | if ($multiple) { |
||
| 983 | $selMultiple = " multiple='multiple'"; |
||
| 984 | } |
||
| 985 | $ret = "<select name='" . $selectname . "[]'" . $selMultiple . " size='10'>"; |
||
| 986 | if ($allCatOption) { |
||
| 987 | $ret .= "<option value='0'"; |
||
| 988 | if (\in_array(0, $selectedId, true)) { |
||
| 989 | $ret .= ' selected'; |
||
| 990 | } |
||
| 991 | $ret .= '>' . \_MB_PUBLISHER_ALLCAT . '</option>'; |
||
| 992 | } |
||
| 993 | |||
| 994 | // Creating category objects |
||
| 995 | $categoriesObj = $helper->getHandler('Category')->getCategories(0, 0, $parentcategory); |
||
| 996 | |||
| 997 | if (\count($categoriesObj) > 0) { |
||
| 998 | foreach ($categoriesObj as $catId => $categoryObj) { |
||
| 999 | $ret .= static::addCategoryOption($categoryObj, $selectedId); |
||
| 1000 | } |
||
| 1001 | } |
||
| 1002 | $ret .= '</select>'; |
||
| 1003 | |||
| 1004 | return $ret; |
||
| 1005 | } |
||
| 1006 | |||
| 1007 | /** |
||
| 1008 | * @param int $selectedId |
||
| 1009 | * @param int $parentcategory |
||
| 1010 | * @param bool $allCatOption |
||
| 1011 | * @return string |
||
| 1012 | */ |
||
| 1013 | public static function createCategoryOptions($selectedId = 0, $parentcategory = 0, $allCatOption = true) |
||
| 1014 | { |
||
| 1015 | $helper = Helper::getInstance(); |
||
| 1016 | |||
| 1017 | $ret = ''; |
||
| 1018 | if ($allCatOption) { |
||
| 1019 | $ret .= "<option value='0'"; |
||
| 1020 | $ret .= '>' . \_MB_PUBLISHER_ALLCAT . "</option>\n"; |
||
| 1021 | } |
||
| 1022 | |||
| 1023 | // Creating category objects |
||
| 1024 | $categoriesObj = $helper->getHandler('Category')->getCategories(0, 0, $parentcategory); |
||
| 1025 | if (\count($categoriesObj) > 0) { |
||
| 1026 | foreach ($categoriesObj as $catId => $categoryObj) { |
||
| 1027 | $ret .= static::addCategoryOption($categoryObj, $selectedId); |
||
| 1028 | } |
||
| 1029 | } |
||
| 1030 | |||
| 1031 | return $ret; |
||
| 1032 | } |
||
| 1033 | |||
| 1034 | /** |
||
| 1035 | * @param array $errArray |
||
| 1036 | * @param string $reseturl |
||
| 1037 | */ |
||
| 1038 | public static function renderErrors($errArray, $reseturl = '') |
||
| 1039 | { |
||
| 1040 | if ($errArray && \is_array($errArray)) { |
||
| 1041 | echo '<div id="readOnly" class="errorMsg" style="border:1px solid #D24D00; background:#FEFECC url(' . PUBLISHER_URL . '/assets/images/important-32.png) no-repeat 7px 50%;color:#333;padding-left:45px;">'; |
||
| 1042 | |||
| 1043 | echo '<h4 style="text-align:left;margin:0; padding-top:0;">' . \_AM_PUBLISHER_MSG_SUBMISSION_ERR; |
||
| 1044 | |||
| 1045 | if ($reseturl) { |
||
| 1046 | echo ' <a href="' . $reseturl . '">[' . \_AM_PUBLISHER_TEXT_SESSION_RESET . ']</a>'; |
||
| 1047 | } |
||
| 1048 | |||
| 1049 | echo '</h4><ul>'; |
||
| 1050 | |||
| 1051 | foreach ($errArray as $key => $error) { |
||
| 1052 | if (\is_array($error)) { |
||
| 1053 | foreach ($error as $err) { |
||
| 1054 | echo '<li><a href="#' . $key . '" onclick="var e = xoopsGetElementById(\'' . $key . '\'); e.focus();">' . \htmlspecialchars($err, \ENT_QUOTES | \ENT_HTML5) . '</a></li>'; |
||
| 1055 | } |
||
| 1056 | } else { |
||
| 1057 | echo '<li><a href="#' . $key . '" onclick="var e = xoopsGetElementById(\'' . $key . '\'); e.focus();">' . \htmlspecialchars($error, \ENT_QUOTES | \ENT_HTML5) . '</a></li>'; |
||
| 1058 | } |
||
| 1059 | } |
||
| 1060 | echo '</ul></div><br>'; |
||
| 1061 | } |
||
| 1062 | } |
||
| 1063 | |||
| 1064 | /** |
||
| 1065 | * Generate publisher URL |
||
| 1066 | * |
||
| 1067 | * @param string $page |
||
| 1068 | * @param array $vars |
||
| 1069 | * @param bool $encodeAmp |
||
| 1070 | * @return string |
||
| 1071 | * |
||
| 1072 | * @credit : xHelp module, developped by 3Dev |
||
| 1073 | */ |
||
| 1074 | public static function makeUri($page, $vars = [], $encodeAmp = true) |
||
| 1075 | { |
||
| 1076 | $joinStr = ''; |
||
| 1077 | |||
| 1078 | $amp = ($encodeAmp ? '&' : '&'); |
||
| 1079 | |||
| 1080 | if (!\count($vars)) { |
||
| 1081 | return $page; |
||
| 1082 | } |
||
| 1083 | |||
| 1084 | $qs = ''; |
||
| 1085 | foreach ($vars as $key => $value) { |
||
| 1086 | $qs .= $joinStr . $key . '=' . $value; |
||
| 1087 | $joinStr = $amp; |
||
| 1088 | } |
||
| 1089 | |||
| 1090 | return $page . '?' . $qs; |
||
| 1091 | } |
||
| 1092 | |||
| 1093 | /** |
||
| 1094 | * @param string $subject |
||
| 1095 | * @return string |
||
| 1096 | */ |
||
| 1097 | public static function tellAFriend($subject = '') |
||
| 1098 | { |
||
| 1099 | if (false !== \mb_strpos($subject, '%')) { |
||
| 1100 | $subject = \rawurldecode($subject); |
||
| 1101 | } |
||
| 1102 | |||
| 1103 | $targetUri = XOOPS_URL . Request::getString('REQUEST_URI', '', 'SERVER'); |
||
| 1104 | |||
| 1105 | return XOOPS_URL . '/modules/tellafriend/index.php?target_uri=' . \rawurlencode($targetUri) . '&subject=' . \rawurlencode($subject); |
||
| 1106 | } |
||
| 1107 | |||
| 1108 | /** |
||
| 1109 | * @param bool $another |
||
| 1110 | * @param bool $withRedirect |
||
| 1111 | * @param Item|null $itemObj |
||
| 1112 | * @return bool|string|null |
||
| 1113 | */ |
||
| 1114 | public static function uploadFile($another, $withRedirect, &$itemObj=null) |
||
| 1115 | { |
||
| 1116 | \xoops_load('XoopsMediaUploader'); |
||
| 1117 | // require_once PUBLISHER_ROOT_PATH . '/class/uploader.php'; |
||
| 1118 | |||
| 1119 | // global $publisherIsAdmin; |
||
| 1120 | $helper = Helper::getInstance(); |
||
| 1121 | |||
| 1122 | $itemId = Request::getInt('itemid', 0, 'POST'); |
||
| 1123 | $uid = \is_object($GLOBALS['xoopsUser']) ? $GLOBALS['xoopsUser']->uid() : 0; |
||
| 1124 | $session = Session::getInstance(); |
||
| 1125 | $session->set('publisher_file_filename', Request::getString('item_file_name', '', 'POST')); |
||
| 1126 | $session->set('publisher_file_description', Request::getString('item_file_description', '', 'POST')); |
||
| 1127 | $session->set('publisher_file_status', Request::getInt('item_file_status', 1, 'POST')); |
||
| 1128 | $session->set('publisher_file_uid', $uid); |
||
| 1129 | $session->set('publisher_file_itemid', $itemId); |
||
| 1130 | |||
| 1131 | if (!\is_object($itemObj) && 0 !== $itemId) { |
||
| 1132 | $itemObj = $helper->getHandler('Item')->get($itemId); |
||
| 1133 | } |
||
| 1134 | |||
| 1135 | $fileObj = $helper->getHandler('File')->create(); |
||
| 1136 | $fileObj->setVar('name', Request::getString('item_file_name', '', 'POST')); |
||
| 1137 | $fileObj->setVar('description', Request::getString('item_file_description', '', 'POST')); |
||
| 1138 | $fileObj->setVar('status', Request::getInt('item_file_status', 1, 'POST')); |
||
| 1139 | $fileObj->setVar('uid', $uid); |
||
| 1140 | $fileObj->setVar('itemid', $itemObj->getVar('itemid')); |
||
| 1141 | $fileObj->setVar('datesub', \time()); |
||
| 1142 | |||
| 1143 | // Get available mimetypes for file uploading |
||
| 1144 | $allowedMimetypes = $helper->getHandler('Mimetype')->getArrayByType(); |
||
| 1145 | // TODO : display the available mimetypes to the user |
||
| 1146 | $errors = []; |
||
| 1147 | if ($helper->getConfig('perm_upload') && \is_uploaded_file($_FILES['item_upload_file']['tmp_name'])) { |
||
| 1148 | if (!$ret = $fileObj->checkUpload('item_upload_file', $allowedMimetypes, $errors)) { |
||
| 1149 | $errorstxt = \implode('<br>', $errors); |
||
| 1150 | |||
| 1151 | $message = \sprintf(\_CO_PUBLISHER_MESSAGE_FILE_ERROR, $errorstxt); |
||
| 1152 | if ($withRedirect) { |
||
| 1153 | \redirect_header('file.php?op=mod&itemid=' . $itemId, 5, $message); |
||
| 1154 | } else { |
||
| 1155 | return $message; |
||
| 1156 | } |
||
| 1157 | } |
||
| 1158 | } |
||
| 1159 | |||
| 1160 | // Storing the file |
||
| 1161 | if (!$fileObj->store($allowedMimetypes)) { |
||
| 1162 | // if ($withRedirect) { |
||
| 1163 | // redirect_header("file.php?op=mod&itemid=" . $fileObj->itemid(), 3, _CO_PUBLISHER_FILEUPLOAD_ERROR . static::formatErrors($fileObj->getErrors())); |
||
| 1164 | // } |
||
| 1165 | try { |
||
| 1166 | if ($withRedirect) { |
||
| 1167 | throw new \RuntimeException(\_CO_PUBLISHER_FILEUPLOAD_ERROR . static::formatErrors($fileObj->getErrors())); |
||
| 1168 | } |
||
| 1169 | } catch (\Throwable $e) { |
||
| 1170 | $helper->addLog($e); |
||
| 1171 | \redirect_header('file.php?op=mod&itemid=' . $fileObj->itemid(), 3, \_CO_PUBLISHER_FILEUPLOAD_ERROR . static::formatErrors($fileObj->getErrors())); |
||
| 1172 | } |
||
| 1173 | // } else { |
||
| 1174 | // return _CO_PUBLISHER_FILEUPLOAD_ERROR . static::formatErrors($fileObj->getErrors()); |
||
| 1175 | } |
||
| 1176 | |||
| 1177 | if ($withRedirect) { |
||
| 1178 | $redirectPage = $another ? 'file.php' : 'item.php'; |
||
| 1179 | \redirect_header($redirectPage . '?op=mod&itemid=' . $fileObj->itemid(), 2, \_CO_PUBLISHER_FILEUPLOAD_SUCCESS); |
||
| 1180 | } else { |
||
| 1181 | return true; |
||
| 1182 | } |
||
| 1183 | |||
| 1184 | return null; |
||
| 1185 | } |
||
| 1186 | |||
| 1187 | /** |
||
| 1188 | * @return string |
||
| 1189 | */ |
||
| 1190 | public static function newFeatureTag() |
||
| 1191 | { |
||
| 1192 | $ret = '<span style="padding-right: 4px; font-weight: bold; color: #ff0000;">' . \_CO_PUBLISHER_NEW_FEATURE . '</span>'; |
||
| 1193 | |||
| 1194 | return $ret; |
||
| 1195 | } |
||
| 1196 | |||
| 1197 | /** |
||
| 1198 | * Smarty truncate_tagsafe modifier plugin |
||
| 1199 | * |
||
| 1200 | * Type: modifier<br> |
||
| 1201 | * Name: truncate_tagsafe<br> |
||
| 1202 | * Purpose: Truncate a string to a certain length if necessary, |
||
| 1203 | * optionally splitting in the middle of a word, and |
||
| 1204 | * appending the $etc string or inserting $etc into the middle. |
||
| 1205 | * Makes sure no tags are left half-open or half-closed |
||
| 1206 | * (e.g. "Banana in a <a...") |
||
| 1207 | * @param mixed $string |
||
| 1208 | * @param mixed $length |
||
| 1209 | * @param mixed $etc |
||
| 1210 | * @param mixed $breakWords |
||
| 1211 | * @return string |
||
| 1212 | * @author Monte Ohrt <monte at ohrt dot com>, modified by Amos Robinson |
||
| 1213 | * <amos dot robinson at gmail dot com> |
||
| 1214 | */ |
||
| 1215 | public static function truncateTagSafe($string, $length = 80, $etc = '...', $breakWords = false) |
||
| 1216 | { |
||
| 1217 | if (0 == $length) { |
||
| 1218 | return ''; |
||
| 1219 | } |
||
| 1220 | |||
| 1221 | if (\mb_strlen($string) > $length) { |
||
| 1222 | $length -= \mb_strlen($etc); |
||
| 1223 | if (!$breakWords) { |
||
| 1224 | $string = \preg_replace('/\s+?(\S+)?$/', '', \mb_substr($string, 0, $length + 1)); |
||
| 1225 | $string = \preg_replace('/<[^>]*$/', '', $string); |
||
| 1226 | $string = static::closeTags($string); |
||
| 1227 | } |
||
| 1228 | |||
| 1229 | return $string . $etc; |
||
| 1230 | } |
||
| 1231 | |||
| 1232 | return $string; |
||
| 1233 | } |
||
| 1234 | |||
| 1235 | /** |
||
| 1236 | * @param string $string |
||
| 1237 | * @return string |
||
| 1238 | * @author Monte Ohrt <monte at ohrt dot com>, modified by Amos Robinson |
||
| 1239 | * <amos dot robinson at gmail dot com> |
||
| 1240 | */ |
||
| 1241 | public static function closeTags($string) |
||
| 1242 | { |
||
| 1243 | // match opened tags |
||
| 1244 | if (\preg_match_all('/<([a-z\:\-]+)[^\/]>/', $string, $startTags)) { |
||
| 1245 | $startTags = $startTags[1]; |
||
| 1246 | // match closed tags |
||
| 1247 | if (\preg_match_all('/<\/([a-z]+)>/', $string, $endTags)) { |
||
| 1248 | $completeTags = []; |
||
| 1249 | $endTags = $endTags[1]; |
||
| 1250 | |||
| 1251 | foreach ($startTags as $key => $val) { |
||
| 1252 | $posb = \array_search($val, $endTags, true); |
||
| 1253 | if (\is_int($posb)) { |
||
| 1254 | unset($endTags[$posb]); |
||
| 1255 | } else { |
||
| 1256 | $completeTags[] = $val; |
||
| 1257 | } |
||
| 1258 | } |
||
| 1259 | } else { |
||
| 1260 | $completeTags = $startTags; |
||
| 1261 | } |
||
| 1262 | |||
| 1263 | $completeTags = \array_reverse($completeTags); |
||
| 1264 | foreach ($completeTags as $iValue) { |
||
| 1265 | $string .= '</' . $iValue . '>'; |
||
| 1266 | } |
||
| 1267 | } |
||
| 1268 | |||
| 1269 | return $string; |
||
| 1270 | } |
||
| 1271 | |||
| 1272 | /** |
||
| 1273 | * Get the rating for 5 stars (the original rating) |
||
| 1274 | * @param int $itemId |
||
| 1275 | * @return string |
||
| 1276 | */ |
||
| 1277 | public static function ratingBar($itemId) |
||
| 1278 | { |
||
| 1279 | $helper = Helper::getInstance(); |
||
| 1280 | $ratingUnitWidth = 30; |
||
| 1281 | $units = 5; |
||
| 1282 | |||
| 1283 | $criteria = new \Criteria('itemid', $itemId); |
||
| 1284 | $ratingObjs = $helper->getHandler('Rating')->getObjects($criteria); |
||
| 1285 | unset($criteria); |
||
| 1286 | |||
| 1287 | $uid = \is_object($GLOBALS['xoopsUser']) ? $GLOBALS['xoopsUser']->getVar('uid') : 0; |
||
| 1288 | $count = \count($ratingObjs); |
||
| 1289 | $currentRating = 0; |
||
| 1290 | $voted = false; |
||
| 1291 | $ip = \getenv('REMOTE_ADDR'); |
||
| 1292 | $rating1 = $rating2 = $ratingWidth = 0; |
||
| 1293 | |||
| 1294 | foreach ($ratingObjs as $ratingObj) { |
||
| 1295 | $currentRating += $ratingObj->getVar('rate'); |
||
| 1296 | if ($ratingObj->getVar('ip') == $ip || ($uid > 0 && $uid == $ratingObj->getVar('uid'))) { |
||
| 1297 | $voted = true; |
||
| 1298 | } |
||
| 1299 | } |
||
| 1300 | |||
| 1301 | $tense = 1 == $count ? \_MD_PUBLISHER_VOTE_VOTE : \_MD_PUBLISHER_VOTE_VOTES; //plural form votes/vote |
||
| 1302 | |||
| 1303 | // now draw the rating bar |
||
| 1304 | if (0 != $count) { |
||
| 1305 | $ratingWidth = \number_format($currentRating / $count, 2) * $ratingUnitWidth; |
||
| 1306 | $rating1 = \number_format($currentRating / $count, 1); |
||
| 1307 | $rating2 = \number_format($currentRating / $count, 2); |
||
| 1308 | } |
||
| 1309 | $groups = $GLOBALS['xoopsUser'] ? $GLOBALS['xoopsUser']->getGroups() : XOOPS_GROUP_ANONYMOUS; |
||
| 1310 | /** @var GroupPermHandler $grouppermHandler */ |
||
| 1311 | $grouppermHandler = $helper->getHandler('GroupPerm'); |
||
| 1312 | |||
| 1313 | if (!$grouppermHandler->checkRight('global', Constants::PUBLISHER_RATE, $groups, $helper->getModule()->getVar('mid'))) { |
||
| 1314 | $staticRater = []; |
||
| 1315 | $staticRater[] .= "\n" . '<div class="publisher_ratingblock">'; |
||
| 1316 | $staticRater[] .= '<div id="unit_long' . $itemId . '">'; |
||
| 1317 | $staticRater[] .= '<div id="unit_ul' . $itemId . '" class="publisher_unit-rating" style="width:' . $ratingUnitWidth * $units . 'px;">'; |
||
| 1318 | $staticRater[] .= '<div class="publisher_current-rating" style="width:' . $ratingWidth . 'px;">' . \_MD_PUBLISHER_VOTE_RATING . ' ' . $rating2 . '/' . $units . '</div>'; |
||
| 1319 | $staticRater[] .= '</div>'; |
||
| 1320 | $staticRater[] .= '<div class="publisher_static">' . \_MD_PUBLISHER_VOTE_RATING . ': <strong> ' . $rating1 . '</strong>/' . $units . ' (' . $count . ' ' . $tense . ') <br><em>' . \_MD_PUBLISHER_VOTE_DISABLE . '</em></div>'; |
||
| 1321 | $staticRater[] .= '</div>'; |
||
| 1322 | $staticRater[] .= '</div>' . "\n\n"; |
||
| 1323 | |||
| 1324 | return \implode("\n", $staticRater); |
||
| 1325 | } |
||
| 1326 | $rater = ''; |
||
| 1327 | $rater .= '<div class="publisher_ratingblock">'; |
||
| 1328 | $rater .= '<div id="unit_long' . $itemId . '">'; |
||
| 1329 | $rater .= '<div id="unit_ul' . $itemId . '" class="publisher_unit-rating" style="width:' . $ratingUnitWidth * $units . 'px;">'; |
||
| 1330 | $rater .= '<div class="publisher_current-rating" style="width:' . $ratingWidth . 'px;">' . \_MD_PUBLISHER_VOTE_RATING . ' ' . $rating2 . '/' . $units . '</div>'; |
||
| 1331 | |||
| 1332 | for ($ncount = 1; $ncount <= $units; ++$ncount) { |
||
| 1333 | // loop from 1 to the number of units |
||
| 1334 | if (!$voted) { |
||
| 1335 | // if the user hasn't yet voted, draw the voting stars |
||
| 1336 | $rater .= '<div><a href="' . PUBLISHER_URL . '/rate.php?itemid=' . $itemId . '&rating=' . $ncount . '" title="' . $ncount . ' ' . \_MD_PUBLISHER_VOTE_OUTOF . ' ' . $units . '" class="publisher_r' . $ncount . '-unit rater" rel="nofollow">' . $ncount . '</a></div>'; |
||
| 1337 | } |
||
| 1338 | } |
||
| 1339 | |||
| 1340 | $ncount = 0; // resets the count |
||
| 1341 | $rater .= ' </div>'; |
||
| 1342 | $rater .= ' <div'; |
||
| 1343 | |||
| 1344 | if ($voted) { |
||
| 1345 | $rater .= ' class="publisher_voted"'; |
||
| 1346 | } |
||
| 1347 | |||
| 1348 | $rater .= '>' . \_MD_PUBLISHER_VOTE_RATING . ': <strong> ' . $rating1 . '</strong>/' . $units . ' (' . $count . ' ' . $tense . ')'; |
||
| 1349 | $rater .= ' </div>'; |
||
| 1350 | $rater .= '</div>'; |
||
| 1351 | $rater .= '</div>'; |
||
| 1352 | |||
| 1353 | return $rater; |
||
| 1354 | } |
||
| 1355 | |||
| 1356 | /** |
||
| 1357 | * @param array|null $allowedEditors |
||
| 1358 | * @return array |
||
| 1359 | */ |
||
| 1360 | public static function getEditors($allowedEditors = null) |
||
| 1361 | { |
||
| 1362 | $ret = []; |
||
| 1363 | $nohtml = false; |
||
| 1364 | \xoops_load('XoopsEditorHandler'); |
||
| 1365 | $editorHandler = \XoopsEditorHandler::getInstance(); |
||
| 1366 | // $editors = array_flip($editorHandler->getList()); //$editorHandler->getList($nohtml); |
||
| 1367 | $editors = $editorHandler->getList($nohtml); |
||
| 1368 | foreach ($editors as $name => $title) { |
||
| 1369 | $key = static::stringToInt($name); |
||
| 1370 | if (\is_array($allowedEditors)) { |
||
| 1371 | //for submit page |
||
| 1372 | if (\in_array($key, $allowedEditors, true)) { |
||
| 1373 | $ret[] = $name; |
||
| 1374 | } |
||
| 1375 | } else { |
||
| 1376 | //for admin permissions page |
||
| 1377 | $ret[$key]['name'] = $name; |
||
| 1378 | $ret[$key]['title'] = $title; |
||
| 1379 | } |
||
| 1380 | } |
||
| 1381 | |||
| 1382 | return $ret; |
||
| 1383 | } |
||
| 1384 | |||
| 1385 | /** |
||
| 1386 | * @param string $string |
||
| 1387 | * @param int $length |
||
| 1388 | * @return int |
||
| 1389 | */ |
||
| 1390 | public static function stringToInt($string = '', $length = 5) |
||
| 1399 | } |
||
| 1400 | |||
| 1401 | /** |
||
| 1402 | * @param string $item |
||
| 1403 | * @return string |
||
| 1404 | */ |
||
| 1405 | public static function convertCharset($item) |
||
| 1421 | } |
||
| 1422 | |||
| 1423 | /** |
||
| 1424 | * @return array |
||
| 1425 | */ |
||
| 1426 | public static function getModuleStats() |
||
| 1427 | { |
||
| 1428 | $helper = Helper::getInstance(); |
||
| 1429 | // $moduleStats = []; |
||
| 1430 | // if (\count($configurator->moduleStats) > 0) { |
||
| 1431 | // foreach (\array_keys($configurator->moduleStats) as $i) { |
||
| 1432 | // $moduleStats[$i] = $configurator->moduleStats[$i]; |
||
| 1433 | // } |
||
| 1434 | // } |
||
| 1435 | |||
| 1436 | $moduleStats = [ |
||
| 1437 | 'totalcategories' => $helper->getHandler('Category')->getCategoriesCount(-1), |
||
| 1438 | 'totalitems' => $helper->getHandler('Item')->getItemsCount(), |
||
| 1439 | 'totalsubmitted' => $helper->getHandler('Item')->getItemsCount(-1, Constants::PUBLISHER_STATUS_SUBMITTED), |
||
| 1440 | 'totalpublished' => $helper->getHandler('Item')->getItemsCount(-1, Constants::PUBLISHER_STATUS_PUBLISHED), |
||
| 1441 | 'totaloffline' => $helper->getHandler('Item')->getItemsCount(-1, Constants::PUBLISHER_STATUS_OFFLINE), |
||
| 1442 | 'totalrejected' => $helper->getHandler('Item')->getItemsCount(-1, Constants::PUBLISHER_STATUS_REJECTED), |
||
| 1443 | ]; |
||
| 1444 | |||
| 1445 | return $moduleStats; |
||
| 1446 | } |
||
| 1447 | |||
| 1448 | /** |
||
| 1449 | * @param $path |
||
| 1450 | * @param $image |
||
| 1451 | * @param $alt |
||
| 1452 | * @return string |
||
| 1453 | */ |
||
| 1454 | public static function iconSourceTag($path, $image, $alt){ |
||
| 1457 | } |
||
| 1458 | } |
||
| 1459 |