diff --git a/admin/admin_header.php b/admin/admin_header.php index 1b8995b3..5f1cdd2b 100644 --- a/admin/admin_header.php +++ b/admin/admin_header.php @@ -18,14 +18,13 @@ * @author The SmartFactory */ - use XoopsModules\Publisher; -require_once dirname(dirname(dirname(__DIR__))) . '/include/cp_header.php'; +require_once dirname(dirname(dirname(__DIR__))) . '/include/cp_header.php'; //require_once $GLOBALS['xoops']->path('www/class/xoopsformloader.php'); require dirname(__DIR__) . '/preloads/autoloader.php'; -require_once dirname(__DIR__) . '/include/common.php'; +require_once dirname(__DIR__) . '/include/common.php'; $moduleDirName = basename(dirname(__DIR__)); @@ -34,8 +33,8 @@ /** @var Xmf\Module\Admin $adminObject */ $adminObject = \Xmf\Module\Admin::getInstance(); -$pathIcon16 = \Xmf\Module\Admin::iconUrl('', 16); -$pathIcon32 = \Xmf\Module\Admin::iconUrl('', 32); +$pathIcon16 = \Xmf\Module\Admin::iconUrl('', 16); +$pathIcon32 = \Xmf\Module\Admin::iconUrl('', 32); if (is_object($helper->getModule())) { $pathModIcon32 = $helper->getModule()->getInfo('modicons32'); } @@ -49,7 +48,7 @@ 'editimg' => "" . _AM_PUBLISHER_ICO_EDIT . "", 'deleteimg' => "" . _AM_PUBLISHER_ICO_DELETE . "", 'online' => "" . _AM_PUBLISHER_ICO_ONLINE . "", - 'offline' => "" . _AM_PUBLISHER_ICO_OFFLINE . "" + 'offline' => "" . _AM_PUBLISHER_ICO_OFFLINE . "", ]; $myts = \MyTextSanitizer::getInstance(); diff --git a/admin/blockform.php b/admin/blockform.php index f765f4ea..41b427ff 100644 --- a/admin/blockform.php +++ b/admin/blockform.php @@ -14,12 +14,10 @@ * @license GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html) */ - - require_once XOOPS_ROOT_PATH . '/class/xoopsformloader.php'; -$moduleDirName = basename(dirname(__DIR__)); -$moduleDirNameUpper = strtoupper($moduleDirName); //$capsDirName +$moduleDirName = basename(dirname(__DIR__)); +$moduleDirNameUpper = mb_strtoupper($moduleDirName); //$capsDirName $form = new \XoopsThemeForm($block['form_title'], 'blockform', 'blocksadmin.php', 'post', true); if (isset($block['name'])) { @@ -65,7 +63,7 @@ $form->addElement($ctype_select); } else { if ('' !== $block['template']) { - /** @var \XoopsTplfileHandler $tplfileHandler */ + /** @var \XoopsTplfileHandler $tplfileHandler */ $tplfileHandler = xoops_getHandler('tplfile'); $btemplate = $tplfileHandler->find($GLOBALS['xoopsConfig']['template_set'], 'block', $block['bid']); if (count($btemplate) > 0) { diff --git a/admin/blocksadmin.php b/admin/blocksadmin.php index fadd663b..87b435df 100644 --- a/admin/blocksadmin.php +++ b/admin/blocksadmin.php @@ -1,6 +1,5 @@ isAdmin($xoopsModule->mid())) { exit(constant('CO_' . $moduleDirNameUpper . '_' . 'ERROR403')); } @@ -49,16 +48,13 @@ $bid = Request::getInt('bid', 0, 'GET'); } - /** - * - */ function listBlocks() { global $xoopsModule, $pathIcon16; require_once XOOPS_ROOT_PATH . '/class/xoopslists.php'; - $moduleDirName = basename(dirname(__DIR__)); - $moduleDirNameUpper = strtoupper($moduleDirName); //$capsDirName - $db = \XoopsDatabaseFactory::getDatabaseConnection(); + $moduleDirName = basename(dirname(__DIR__)); + $moduleDirNameUpper = mb_strtoupper($moduleDirName); //$capsDirName + $db = \XoopsDatabaseFactory::getDatabaseConnection(); xoops_loadLanguage('admin', 'system'); xoops_loadLanguage('admin/blocksadmin', 'system'); xoops_loadLanguage('admin/groups', 'system'); @@ -120,7 +116,7 @@ function listBlocks() '86400' => _DAY, '259200' => sprintf(_DAYS, 3), '604800' => _WEEK, - '2592000' => _MONTH + '2592000' => _MONTH, ]; foreach ($block_arr as $i) { $groups_perms = $grouppermHandler->getGroupIds('block_read', $i->getVar('bid')); @@ -292,7 +288,7 @@ function cloneBlock($bid) /** @var \Xmf\Module\Admin $adminObject */ $adminObject = \Xmf\Module\Admin::getInstance(); $adminObject->displayNavigation(basename(__FILE__)); - $moduleDirName = basename(dirname(__DIR__)); + $moduleDirName = basename(dirname(__DIR__)); $moduleDirNameUpper = mb_strtoupper($moduleDirName); //$capsDirName xoops_loadLanguage('admin', 'system'); @@ -325,10 +321,10 @@ function cloneBlock($bid) 'bid' => $myblock->getVar('bid'), 'edit_form' => $myblock->getOptions(), 'template' => $myblock->getVar('template'), - 'options' => $myblock->getVar('options') + 'options' => $myblock->getVar('options'), ]; echo '' . constant('CO_' . $moduleDirNameUpper . '_' . 'BADMIN') . ' »» ' . _AM_SYSTEM_BLOCKS_CLONEBLOCK . '

'; - require_once __DIR__ . '/blockform.php'; + require_once __DIR__ . '/blockform.php'; $form->display(); // xoops_cp_footer(); require_once __DIR__ . '/admin_footer.php'; @@ -336,15 +332,15 @@ function cloneBlock($bid) } /** - * @param $bid - * @param $bside - * @param $bweight - * @param $bvisible - * @param $bcachetime - * @param $bmodule - * @param $options + * @param int $bid + * @param string $bside + * @param int $bweight + * @param bool $bvisible + * @param int $bcachetime + * @param string $bmodule + * @param null|array $options */ - function isBlockCloned($bid, $bside, $bweight, $bvisible, $bcachetime, $bmodule, $options) + function isBlockCloned($bid, $bside, $bweight, $bvisible, $bcachetime, $bmodule, $options = null) { xoops_loadLanguage('admin', 'system'); xoops_loadLanguage('admin/blocksadmin', 'system'); @@ -365,7 +361,7 @@ function isBlockCloned($bid, $bside, $bweight, $bvisible, $bcachetime, $bmodule, //$clone->setVar('content', $_POST['bcontent']); $clone->setVar('title', Request::getString('btitle', '', 'POST')); $clone->setVar('bcachetime', $bcachetime); - if (isset($options) && (0 < count($options))) { + if (null !== $options && (count($options) > 0)) { $options = implode('|', $options); $clone->setVar('options', $options); } @@ -386,7 +382,7 @@ function isBlockCloned($bid, $bside, $bweight, $bvisible, $bcachetime, $bmodule, /** @var \XoopsTplfileHandler $tplfileHandler */ $tplfileHandler = xoops_getHandler('tplfile'); $btemplate = $tplfileHandler->find($GLOBALS['xoopsConfig']['template_set'], 'block', $bid); - if (0 < count($btemplate)) { + if (count($btemplate) > 0) { $tplclone = $btemplate[0]->xoopsClone(); $tplclone->setVar('tpl_id', 0); $tplclone->setVar('tpl_refid', $newid); @@ -436,7 +432,7 @@ function xtubeEditBlock($bid) /** @var \Xmf\Module\Admin $adminObject */ $adminObject = \Xmf\Module\Admin::getInstance(); $adminObject->displayNavigation(basename(__FILE__)); - $moduleDirName = basename(dirname(__DIR__)); + $moduleDirName = basename(dirname(__DIR__)); $moduleDirNameUpper = mb_strtoupper($moduleDirName); //$capsDirName xoops_loadLanguage('admin', 'system'); @@ -468,10 +464,10 @@ function xtubeEditBlock($bid) 'bid' => $myblock->getVar('bid'), 'edit_form' => $myblock->getOptions(), 'template' => $myblock->getVar('template'), - 'options' => $myblock->getVar('options') + 'options' => $myblock->getVar('options'), ]; echo '' . constant('CO_' . $moduleDirNameUpper . '_' . 'BADMIN') . ' »» ' . _AM_SYSTEM_BLOCKS_EDITBLOCK . '

'; - require_once __DIR__ . '/blockform.php'; + require_once __DIR__ . '/blockform.php'; $form->display(); // xoops_cp_footer(); require_once __DIR__ . '/admin_footer.php'; @@ -499,7 +495,7 @@ function xtubeUpdateBlock($bid, $btitle, $bside, $bweight, $bvisible, $bcachetim $myblock->setVar('bcachetime', $bcachetime); $myblock->store(); - if (!empty($bmodule) && 0 < count($bmodule)) { + if (!empty($bmodule) && count($bmodule) > 0) { $sql = sprintf('DELETE FROM `%s` WHERE block_id = %u', $GLOBALS['xoopsDB']->prefix('block_module_link'), $bid); $GLOBALS['xoopsDB']->query($sql); if (in_array(0, $bmodule)) { @@ -541,7 +537,7 @@ function xtubeUpdateBlock($bid, $btitle, $bside, $bweight, $bvisible, $bcachetim || $oldbcachetime[$i] !== $bcachetime[$i]) { xtubeSetOrder($bid[$i], $title[$i], $weight[$i], $visible[$i], $side[$i], $bcachetime[$i], $bmodule[$i]); } - if (!empty($bmodule[$i]) && 0 < count($bmodule[$i])) { + if (!empty($bmodule[$i]) && count($bmodule[$i]) > 0) { $sql = sprintf('DELETE FROM `%s` WHERE block_id = %u', $GLOBALS['xoopsDB']->prefix('block_module_link'), $bid[$i]); $GLOBALS['xoopsDB']->query($sql); if (in_array(0, $bmodule[$i])) { diff --git a/admin/category.php b/admin/category.php index 24ce573a..4b30b707 100644 --- a/admin/category.php +++ b/admin/category.php @@ -43,7 +43,7 @@ // exit(); } redirect_header('category.php', 1, sprintf(_AM_PUBLISHER_COLISDELETED, $name)); - // exit(); + // exit(); } else { xoops_cp_header(); xoops_confirm(['op' => 'del', 'categoryid' => $categoryObj->categoryid(), 'confirm' => 1, 'name' => $categoryObj->name()], 'category.php', _AM_PUBLISHER_DELETECOL . " '" . $categoryObj->name() . "'.

" . _AM_PUBLISHER_DELETE_CAT_CONFIRM, _AM_PUBLISHER_DELETE); diff --git a/admin/clone.php b/admin/clone.php index 8f90fe89..0825b00c 100644 --- a/admin/clone.php +++ b/admin/clone.php @@ -47,19 +47,19 @@ } $patterns = [ - strtolower(PUBLISHER_DIRNAME) => strtolower($clone), - strtoupper(PUBLISHER_DIRNAME) => strtoupper($clone), - ucfirst(strtolower(PUBLISHER_DIRNAME)) => ucfirst(strtolower($clone)) + mb_strtolower(PUBLISHER_DIRNAME) => mb_strtolower($clone), + mb_strtoupper(PUBLISHER_DIRNAME) => mb_strtoupper($clone), + ucfirst(mb_strtolower(PUBLISHER_DIRNAME)) => ucfirst(mb_strtolower($clone)), ]; $patKeys = array_keys($patterns); $patValues = array_values($patterns); PublisherClone::cloneFileFolder(PUBLISHER_ROOT_PATH); - $logocreated = PublisherClone::createLogo(strtolower($clone)); + $logocreated = PublisherClone::createLogo(mb_strtolower($clone)); $msg = ''; - if (is_dir($GLOBALS['xoops']->path('modules/' . strtolower($clone)))) { - $msg .= sprintf(_AM_PUBLISHER_CLONE_CONGRAT, "" . ucfirst(strtolower($clone)) . '') . "
\n"; + if (is_dir($GLOBALS['xoops']->path('modules/' . mb_strtolower($clone)))) { + $msg .= sprintf(_AM_PUBLISHER_CLONE_CONGRAT, "" . ucfirst(mb_strtolower($clone)) . '') . "
\n"; if (!$logocreated) { $msg .= _AM_PUBLISHER_CLONE_IMAGEFAIL; } @@ -114,12 +114,14 @@ public static function cloneFileFolder($path) if (is_dir($path)) { // create new dir - mkdir($newPath); + if (!mkdir($newPath) && !is_dir($newPath)) { + throw new \RuntimeException(sprintf('Directory "%s" was not created', $newPath)); + } // check all files in dir, and process it if ($handle = opendir($path)) { while (false !== ($file = readdir($handle))) { - if (0 !== strpos($file, '.')) { + if (0 !== mb_strpos($file, '.')) { self::cloneFileFolder("{$path}/{$file}"); } } @@ -127,7 +129,7 @@ public static function cloneFileFolder($path) } } else { $noChangeExtensions = ['jpeg', 'jpg', 'gif', 'png', 'zip', 'ttf']; - if (in_array(strtolower(pathinfo($path, PATHINFO_EXTENSION)), $noChangeExtensions)) { + if (in_array(mb_strtolower(pathinfo($path, PATHINFO_EXTENSION)), $noChangeExtensions, true)) { // image copy($path, $newPath); } else { @@ -148,24 +150,23 @@ public static function createLogo($dirname) { if (!extension_loaded('gd')) { return false; - } else { - $requiredFunctions = [ - 'imagecreatefrompng', - 'imagecolorallocate', - 'imagefilledrectangle', - 'imagepng', - 'imagedestroy', - 'imagefttext', - 'imagealphablending', - 'imagesavealpha' - ]; - foreach ($requiredFunctions as $func) { - if (!function_exists($func)) { - return false; - } + } + $requiredFunctions = [ + 'imagecreatefrompng', + 'imagecolorallocate', + 'imagefilledrectangle', + 'imagepng', + 'imagedestroy', + 'imagefttext', + 'imagealphablending', + 'imagesavealpha', + ]; + foreach ($requiredFunctions as $func) { + if (!function_exists($func)) { + return false; } - // unset($func); } + // unset($func); if (!file_exists($imageBase = $GLOBALS['xoops']->path('modules/' . $dirname . '/assets/images/logoModule.png')) || !file_exists($font = $GLOBALS['xoops']->path('modules/' . $dirname . '/assets/images/VeraBd.ttf'))) { @@ -183,7 +184,7 @@ public static function createLogo($dirname) // Write text $textColor = imagecolorallocate($imageModule, 0, 0, 0); - $spaceToBorder = (80 - strlen($dirname) * 6.5) / 2; + $spaceToBorder = (80 - mb_strlen($dirname) * 6.5) / 2; imagefttext($imageModule, 8.5, 0, $spaceToBorder, 45, $textColor, $font, ucfirst($dirname), []); // Set transparency color diff --git a/admin/file.php b/admin/file.php index d2f6623e..68e5ec7b 100644 --- a/admin/file.php +++ b/admin/file.php @@ -139,7 +139,7 @@ function publisher_editFile($showmenu = false, $fileid = 0, $itemid = 0) } redirect_header('item.php?op=mod&itemid=' . $fileObj->itemid() . '#tab_2', 2, sprintf(_AM_PUBLISHER_FILEISDELETED, $fileObj->name())); - // exit(); + // exit(); } else { // no confirm: show deletion condition $fileid = Request::getInt('fileid', 0, 'GET'); diff --git a/admin/import/ams.php b/admin/import/ams.php index 3988aa26..1010e12a 100644 --- a/admin/import/ams.php +++ b/admin/import/ams.php @@ -69,17 +69,18 @@ // $imagecategory->setVar('imgcat_name', $imgcat_name); $imagecategory->setVar('imgcat_name', PUBLISHER_DIRNAME); //$imgcat_name); $imagecategory->setVar('imgcat_maxsize', $GLOBALS['xoopsModuleConfig']['maximum_filesize']); //$imgcat_maxsize); - $imagecategory->setVar('imgcat_maxwidth', $GLOBALS['xoopsModuleConfig']['maximum_image_width']);//$imgcat_maxwidth); - $imagecategory->setVar('imgcat_maxheight', $GLOBALS['xoopsModuleConfig']['maximum_image_height']);//$imgcat_maxheight); + $imagecategory->setVar('imgcat_maxwidth', $GLOBALS['xoopsModuleConfig']['maximum_image_width']); //$imgcat_maxwidth); + $imagecategory->setVar('imgcat_maxheight', $GLOBALS['xoopsModuleConfig']['maximum_image_height']); //$imgcat_maxheight); // $imgcat_display = empty($imgcat_display) ? 0 : 1; - $imagecategory->setVar('imgcat_display', 1);//$imgcat_display); - $imagecategory->setVar('imgcat_weight', 0);//$imgcat_weight); - $imagecategory->setVar('imgcat_storetype', 'file');//$imgcat_storetype); + $imagecategory->setVar('imgcat_display', 1); //$imgcat_display); + $imagecategory->setVar('imgcat_weight', 0); //$imgcat_weight); + $imagecategory->setVar('imgcat_storetype', 'file'); //$imgcat_storetype); $imagecategory->setVar('imgcat_type', 'C'); try { $imageCategoryHandler->insert($imagecategory); // exit(); - } catch (\Exception $e) { + } + catch (\Exception $e) { echo 'Caught exception: could not insert Image Category' . $e->getMessage() . 'n'; } @@ -239,8 +240,8 @@ $imageHandler = xoops_getHandler('image'); $image = $imageHandler->create(); $image->setVar('image_name', $arrCat['topic_imgurl']);//'images/' . $uploader->getSavedFileName()); - $image->setVar('image_nicename', substr($arrCat['topic_imgurl'],-13)); //$image_nicename); - $image->setVar('image_mimetype', 'image/'. substr($arrCat['topic_imgurl'],-3));//$uploader->getMediaType()); + $image->setVar('image_nicename', mb_substr($arrCat['topic_imgurl'],-13)); //$image_nicename); + $image->setVar('image_mimetype', 'image/'. mb_substr($arrCat['topic_imgurl'],-3));//$uploader->getMediaType()); // $image->setVar('image_created', time()); // $image_display = empty($image_display) ? 0 : 1; $image->setVar('image_display', 1); //$image_display); @@ -347,42 +348,41 @@ if (!$itemObj->store()) { echo sprintf(' ' . _AM_PUBLISHER_IMPORT_ARTICLE_ERROR, $arrArticle['storyid'] . ' ' . $arrArticle['title']) . '
'; continue; - } else { - //-------------------------------------------- - // Linkes files - $sql = 'SELECT * FROM ' . $GLOBALS['xoopsDB']->prefix('ams_article_files') . ' WHERE storyid=' . $arrArticle['storyid']; - $resultFiles = $GLOBALS['xoopsDB']->query($sql); - $allowed_mimetypes = ''; - while (false !== ($arrFile = $GLOBALS['xoopsDB']->fetchArray($resultFiles))) { - $filename = $GLOBALS['xoops']->path('uploads/AMS/attached/' . $arrFile['downloadname']); - if (file_exists($filename)) { - if (copy($filename, $GLOBALS['xoops']->path('uploads/publisher/' . $arrFile['filerealname']))) { - /** @var Publisher\File $fileObj */ - $fileObj = $helper->getHandler('File')->create(); - $fileObj->setVar('name', $arrFile['filerealname']); - $fileObj->setVar('description', $arrFile['filerealname']); - $fileObj->setVar('status', Constants::PUBLISHER_STATUS_FILE_ACTIVE); - $fileObj->setVar('uid', $arrArticle['uid']); - $fileObj->setVar('itemid', $itemObj->itemid()); - $fileObj->setVar('mimetype', $arrFile['mimetype']); - $fileObj->setVar('datesub', $arrFile['date']); - $fileObj->setVar('counter', $arrFile['counter']); - $fileObj->setVar('filename', $arrFile['filerealname']); - $fileObj->setVar('short_url', $arrFile['filerealname']); - - if ($fileObj->store($allowed_mimetypes, true, false)) { - echo '    ' . sprintf(_AM_PUBLISHER_IMPORTED_ARTICLE_FILE, $arrFile['filerealname']) . '
'; - } + } + //-------------------------------------------- + // Linkes files + $sql = 'SELECT * FROM ' . $GLOBALS['xoopsDB']->prefix('ams_article_files') . ' WHERE storyid=' . $arrArticle['storyid']; + $resultFiles = $GLOBALS['xoopsDB']->query($sql); + $allowed_mimetypes = ''; + while (false !== ($arrFile = $GLOBALS['xoopsDB']->fetchArray($resultFiles))) { + $filename = $GLOBALS['xoops']->path('uploads/AMS/attached/' . $arrFile['downloadname']); + if (file_exists($filename)) { + if (copy($filename, $GLOBALS['xoops']->path('uploads/publisher/' . $arrFile['filerealname']))) { + /** @var Publisher\File $fileObj */ + $fileObj = $helper->getHandler('File')->create(); + $fileObj->setVar('name', $arrFile['filerealname']); + $fileObj->setVar('description', $arrFile['filerealname']); + $fileObj->setVar('status', Constants::PUBLISHER_STATUS_FILE_ACTIVE); + $fileObj->setVar('uid', $arrArticle['uid']); + $fileObj->setVar('itemid', $itemObj->itemid()); + $fileObj->setVar('mimetype', $arrFile['mimetype']); + $fileObj->setVar('datesub', $arrFile['date']); + $fileObj->setVar('counter', $arrFile['counter']); + $fileObj->setVar('filename', $arrFile['filerealname']); + $fileObj->setVar('short_url', $arrFile['filerealname']); + + if ($fileObj->store($allowed_mimetypes, true, false)) { + echo '    ' . sprintf(_AM_PUBLISHER_IMPORTED_ARTICLE_FILE, $arrFile['filerealname']) . '
'; } } } + } - //------------------------ + //------------------------ - $newArticleArray[$arrArticle['storyid']] = $itemObj->itemid(); - echo '  ' . sprintf(_AM_PUBLISHER_IMPORTED_ARTICLE, $itemObj->getTitle()) . '
'; - ++$cnt_imported_articles; - } + $newArticleArray[$arrArticle['storyid']] = $itemObj->itemid(); + echo '  ' . sprintf(_AM_PUBLISHER_IMPORTED_ARTICLE, $itemObj->getTitle()) . '
'; + ++$cnt_imported_articles; } // Saving category permissions diff --git a/admin/import/cjaycontent.php b/admin/import/cjaycontent.php index 0341cddb..376d5442 100644 --- a/admin/import/cjaycontent.php +++ b/admin/import/cjaycontent.php @@ -148,11 +148,10 @@ if (!$itemObj->store()) { echo sprintf(' ' . _AM_PUBLISHER_IMPORT_ARTICLE_ERROR, $arrArticle['title']) . '
'; continue; - } else { - $newArticleArray[$arrArticle['id']] = $itemObj->itemid(); - echo '  ' . sprintf(_AM_PUBLISHER_IMPORTED_ARTICLE, $itemObj->getTitle()) . '
'; - ++$cnt_imported_articles; } + $newArticleArray[$arrArticle['id']] = $itemObj->itemid(); + echo '  ' . sprintf(_AM_PUBLISHER_IMPORTED_ARTICLE, $itemObj->getTitle()) . '
'; + ++$cnt_imported_articles; } echo '
'; diff --git a/admin/import/fmcontent.php b/admin/import/fmcontent.php index 0df8a439..1f755211 100644 --- a/admin/import/fmcontent.php +++ b/admin/import/fmcontent.php @@ -101,7 +101,7 @@ $module = \XoopsModule::getByDirname($moduleDirName); if (Publisher\Utility::checkVerXoops($GLOBALS['xoopsModule'], '2.5.9')) { $catSelBox = $myObjTree->makeSelectElement('parent_category', 'name', '-', 0, true, 0, '', '')->render(); - //$form->addElement($catSelBox); + //$form->addElement($catSelBox); } else { $catSelBox = $myObjTree->makeSelBox('parent_category', 'name', '-', 0, true); } @@ -211,11 +211,10 @@ if (!$itemObj->store()) { echo sprintf(' ' . _AM_PUBLISHER_IMPORT_ARTICLE_ERROR, $thisFmContentObj->getVar('title')) . "
\n"; continue; - } else { - $newArticleArray[$thisFmContentObj->getVar('storyid')] = $itemObj->itemid(); - echo '  ' . sprintf(_AM_PUBLISHER_IMPORTED_ARTICLE, $itemObj->getTitle()) . "
\n"; - ++$cnt_imported_articles; } + $newArticleArray[$thisFmContentObj->getVar('storyid')] = $itemObj->itemid(); + echo '  ' . sprintf(_AM_PUBLISHER_IMPORTED_ARTICLE, $itemObj->getTitle()) . "
\n"; + ++$cnt_imported_articles; } // Saving category permissions @@ -307,11 +306,10 @@ if (!$itemObj->store()) { echo sprintf(' ' . _AM_PUBLISHER_IMPORT_ARTICLE_ERROR, $thisFmContentObj->getVar('title')) . "
\n"; continue; - } else { - $newArticleArray[$thisFmContentObj->getVar('storyid')] = $itemObj->itemid(); - echo '  ' . sprintf(_AM_PUBLISHER_IMPORTED_ARTICLE, $itemObj->getTitle()) . "
\n"; - ++$cnt_imported_articles; } + $newArticleArray[$thisFmContentObj->getVar('storyid')] = $itemObj->itemid(); + echo '  ' . sprintf(_AM_PUBLISHER_IMPORTED_ARTICLE, $itemObj->getTitle()) . "
\n"; + ++$cnt_imported_articles; } // Saving category permissions diff --git a/admin/import/news.php b/admin/import/news.php index 3989dcd1..2aac5e48 100644 --- a/admin/import/news.php +++ b/admin/import/news.php @@ -192,39 +192,38 @@ if (!$itemObj->store()) { echo sprintf(' ' . _AM_PUBLISHER_IMPORT_ARTICLE_ERROR, $arrArticle['title']) . '
'; continue; - } else { - /* - // Linkes files - $sql = 'SELECT * FROM '.$GLOBALS['xoopsDB']->prefix('wfs_files').' WHERE articleid=' . $arrArticle['articleid']; - $resultFiles = $GLOBALS['xoopsDB']->query ($sql); - $allowed_mimetypes = ''; - while (false !== ($arrFile = $GLOBALS['xoopsDB']->fetchArray ($resultFiles))) { - - $filename = $GLOBALS['xoops']->path('modules/wfsection/cache/uploaded/' . $arrFile['filerealname']); - if (file_exists($filename)) { - if (copy($filename, $GLOBALS['xoops']->path('uploads/publisher/' . $arrFile['filerealname']))) { - $fileObj = $publisher_fileHandler->create(); - $fileObj->setVar('name', $arrFile['fileshowname']); - $fileObj->setVar('description', $arrFile['filedescript']); - $fileObj->setVar('status', Constants::PUBLISHER_STATUS_FILE_ACTIVE); - $fileObj->setVar('uid', $arrArticle['uid']); - $fileObj->setVar('itemid', $itemObj->itemid()); - $fileObj->setVar('mimetype', $arrFile['minetype']); - $fileObj->setVar('datesub', $arrFile['date']); - $fileObj->setVar('counter', $arrFile['counter']); - $fileObj->setVar('filename', $arrFile['filerealname']); - - if ($fileObj->store($allowed_mimetypes, true, false)) { - echo '    ' . sprintf(_AM_PUBLISHER_IMPORTED_ARTICLE_FILE, $arrFile['filerealname']) . '
'; - } - } - } - } - */ - $newArticleArray[$arrArticle['storyid']] = $itemObj->itemid(); - echo '  ' . sprintf(_AM_PUBLISHER_IMPORTED_ARTICLE, $itemObj->getTitle()) . '
'; - ++$cnt_imported_articles; } + /* + // Linkes files + $sql = 'SELECT * FROM '.$GLOBALS['xoopsDB']->prefix('wfs_files').' WHERE articleid=' . $arrArticle['articleid']; + $resultFiles = $GLOBALS['xoopsDB']->query ($sql); + $allowed_mimetypes = ''; + while (false !== ($arrFile = $GLOBALS['xoopsDB']->fetchArray ($resultFiles))) { + + $filename = $GLOBALS['xoops']->path('modules/wfsection/cache/uploaded/' . $arrFile['filerealname']); + if (file_exists($filename)) { + if (copy($filename, $GLOBALS['xoops']->path('uploads/publisher/' . $arrFile['filerealname']))) { + $fileObj = $publisher_fileHandler->create(); + $fileObj->setVar('name', $arrFile['fileshowname']); + $fileObj->setVar('description', $arrFile['filedescript']); + $fileObj->setVar('status', Constants::PUBLISHER_STATUS_FILE_ACTIVE); + $fileObj->setVar('uid', $arrArticle['uid']); + $fileObj->setVar('itemid', $itemObj->itemid()); + $fileObj->setVar('mimetype', $arrFile['minetype']); + $fileObj->setVar('datesub', $arrFile['date']); + $fileObj->setVar('counter', $arrFile['counter']); + $fileObj->setVar('filename', $arrFile['filerealname']); + + if ($fileObj->store($allowed_mimetypes, true, false)) { + echo '    ' . sprintf(_AM_PUBLISHER_IMPORTED_ARTICLE_FILE, $arrFile['filerealname']) . '
'; + } + } + } + } + */ + $newArticleArray[$arrArticle['storyid']] = $itemObj->itemid(); + echo '  ' . sprintf(_AM_PUBLISHER_IMPORTED_ARTICLE, $itemObj->getTitle()) . '
'; + ++$cnt_imported_articles; } // Saving category permissions diff --git a/admin/import/smartsection.php b/admin/import/smartsection.php index 5b48224d..c74872b6 100644 --- a/admin/import/smartsection.php +++ b/admin/import/smartsection.php @@ -174,31 +174,30 @@ if (!$itemObj->store()) { echo sprintf(' ' . _AM_PUBLISHER_IMPORT_ARTICLE_ERROR, $arrArticle['title']) . '
'; continue; - } else { - // Linkes files - $sql = 'SELECT * FROM ' . $GLOBALS['xoopsDB']->prefix('smartsection_files') . ' WHERE itemid=' . $arrArticle['itemid']; - $resultFiles = $GLOBALS['xoopsDB']->query($sql); - $allowed_mimetypes = null; - while (false !== ($arrFile = $GLOBALS['xoopsDB']->fetchArray($resultFiles))) { - $filename = $GLOBALS['xoops']->path('uploads/smartsection/' . $arrFile['filename']); - if (file_exists($filename)) { - if (copy($filename, $GLOBALS['xoops']->path('uploads/publisher/' . $arrFile['filename']))) { - /** @var Publisher\File $fileObj */ - $fileObj = $helper->getHandler('File')->create(); - $fileObj->setVars($arrFile); - $fileObj->setVar('fileid', 0); - - if ($fileObj->store($allowed_mimetypes, true, false)) { - echo '    ' . sprintf(_AM_PUBLISHER_IMPORTED_ARTICLE_FILE, $arrFile['filename']) . '
'; - } + } + // Linkes files + $sql = 'SELECT * FROM ' . $GLOBALS['xoopsDB']->prefix('smartsection_files') . ' WHERE itemid=' . $arrArticle['itemid']; + $resultFiles = $GLOBALS['xoopsDB']->query($sql); + $allowed_mimetypes = null; + while (false !== ($arrFile = $GLOBALS['xoopsDB']->fetchArray($resultFiles))) { + $filename = $GLOBALS['xoops']->path('uploads/smartsection/' . $arrFile['filename']); + if (file_exists($filename)) { + if (copy($filename, $GLOBALS['xoops']->path('uploads/publisher/' . $arrFile['filename']))) { + /** @var Publisher\File $fileObj */ + $fileObj = $helper->getHandler('File')->create(); + $fileObj->setVars($arrFile); + $fileObj->setVar('fileid', 0); + + if ($fileObj->store($allowed_mimetypes, true, false)) { + echo '    ' . sprintf(_AM_PUBLISHER_IMPORTED_ARTICLE_FILE, $arrFile['filename']) . '
'; } } } - - $newArticleArray[$arrArticle['itemid']] = $itemObj->itemid(); - echo '  ' . sprintf(_AM_PUBLISHER_IMPORTED_ARTICLE, $itemObj->getTitle()) . '
'; - ++$cnt_imported_articles; } + + $newArticleArray[$arrArticle['itemid']] = $itemObj->itemid(); + echo '  ' . sprintf(_AM_PUBLISHER_IMPORTED_ARTICLE, $itemObj->getTitle()) . '
'; + ++$cnt_imported_articles; } // Saving category permissions diff --git a/admin/import/wfsection.php b/admin/import/wfsection.php index 15cf261d..a183326b 100644 --- a/admin/import/wfsection.php +++ b/admin/import/wfsection.php @@ -188,39 +188,38 @@ if (!$itemObj->store()) { echo sprintf(' ' . _AM_PUBLISHER_IMPORT_ARTICLE_ERROR, $arrArticle['title']) . '
'; continue; - } else { - // Linkes files - - $sql = 'SELECT * FROM ' . $GLOBALS['xoopsDB']->prefix('wfs_files') . ' WHERE articleid=' . $arrArticle['articleid']; - $resultFiles = $GLOBALS['xoopsDB']->query($sql); - $allowed_mimetypes = ''; - while (false !== ($arrFile = $GLOBALS['xoopsDB']->fetchArray($resultFiles))) { - $filename = $GLOBALS['xoops']->path('modules/wfsection/cache/uploaded/' . $arrFile['filerealname']); - if (file_exists($filename)) { - if (copy($filename, PUBLISHER_UPLOAD_PATH . '/' . $arrFile['filerealname'])) { - /** @var Publisher\File $fileObj */ - $fileObj = $helper->getHandler('File')->create(); - $fileObj->setVar('name', $arrFile['fileshowname']); - $fileObj->setVar('description', $arrFile['filedescript']); - $fileObj->setVar('status', Constants::PUBLISHER_STATUS_FILE_ACTIVE); - $fileObj->setVar('uid', $arrArticle['uid']); - $fileObj->setVar('itemid', $itemObj->itemid()); - $fileObj->setVar('mimetype', $arrFile['minetype']); - $fileObj->setVar('datesub', $arrFile['date']); - $fileObj->setVar('counter', $arrFile['counter']); - $fileObj->setVar('filename', $arrFile['filerealname']); - - if ($fileObj->store($allowed_mimetypes, true, false)) { - echo '    ' . sprintf(_AM_PUBLISHER_IMPORTED_ARTICLE_FILE, $arrFile['filerealname']) . '
'; - } + } + // Linkes files + + $sql = 'SELECT * FROM ' . $GLOBALS['xoopsDB']->prefix('wfs_files') . ' WHERE articleid=' . $arrArticle['articleid']; + $resultFiles = $GLOBALS['xoopsDB']->query($sql); + $allowed_mimetypes = ''; + while (false !== ($arrFile = $GLOBALS['xoopsDB']->fetchArray($resultFiles))) { + $filename = $GLOBALS['xoops']->path('modules/wfsection/cache/uploaded/' . $arrFile['filerealname']); + if (file_exists($filename)) { + if (copy($filename, PUBLISHER_UPLOAD_PATH . '/' . $arrFile['filerealname'])) { + /** @var Publisher\File $fileObj */ + $fileObj = $helper->getHandler('File')->create(); + $fileObj->setVar('name', $arrFile['fileshowname']); + $fileObj->setVar('description', $arrFile['filedescript']); + $fileObj->setVar('status', Constants::PUBLISHER_STATUS_FILE_ACTIVE); + $fileObj->setVar('uid', $arrArticle['uid']); + $fileObj->setVar('itemid', $itemObj->itemid()); + $fileObj->setVar('mimetype', $arrFile['minetype']); + $fileObj->setVar('datesub', $arrFile['date']); + $fileObj->setVar('counter', $arrFile['counter']); + $fileObj->setVar('filename', $arrFile['filerealname']); + + if ($fileObj->store($allowed_mimetypes, true, false)) { + echo '    ' . sprintf(_AM_PUBLISHER_IMPORTED_ARTICLE_FILE, $arrFile['filerealname']) . '
'; } } } - - $newArticleArray[$arrArticle['articleid']] = $itemObj->itemid(); - echo '  ' . sprintf(_AM_PUBLISHER_IMPORTED_ARTICLE, $itemObj->getTitle()) . '
'; - ++$cnt_imported_articles; } + + $newArticleArray[$arrArticle['articleid']] = $itemObj->itemid(); + echo '  ' . sprintf(_AM_PUBLISHER_IMPORTED_ARTICLE, $itemObj->getTitle()) . '
'; + ++$cnt_imported_articles; } $newCatArray[$newCat['oldid']] = $newCat; unset($newCat); diff --git a/admin/import/xfsection.php b/admin/import/xfsection.php index 97022a06..1c9b579c 100644 --- a/admin/import/xfsection.php +++ b/admin/import/xfsection.php @@ -187,39 +187,38 @@ if (!$itemObj->store()) { echo sprintf(' ' . _AM_PUBLISHER_IMPORT_ARTICLE_ERROR, $arrArticle['title']) . '
'; continue; - } else { - // Linkes files - - $sql = 'SELECT * FROM ' . $GLOBALS['xoopsDB']->prefix('xfs_files') . ' WHERE articleid=' . $arrArticle['articleid']; - $resultFiles = $GLOBALS['xoopsDB']->query($sql); - $allowed_mimetypes = ''; - while (false !== ($arrFile = $GLOBALS['xoopsDB']->fetchArray($resultFiles))) { - $filename = $GLOBALS['xoops']->path('modules/xfsection/cache/uploaded/' . $arrFile['filerealname']); - if (file_exists($filename)) { - if (copy($filename, PUBLISHER_UPLOAD_PATH . '/' . $arrFile['filerealname'])) { - /** @var Publisher\File $fileObj */ - $fileObj = $helper->getHandler('File')->create(); - $fileObj->setVar('name', $arrFile['fileshowname']); - $fileObj->setVar('description', $arrFile['filedescript']); - $fileObj->setVar('status', Constants::PUBLISHER_STATUS_FILE_ACTIVE); - $fileObj->setVar('uid', $arrArticle['uid']); - $fileObj->setVar('itemid', $itemObj->itemid()); - $fileObj->setVar('mimetype', $arrFile['minetype']); - $fileObj->setVar('datesub', $arrFile['date']); - $fileObj->setVar('counter', $arrFile['counter']); - $fileObj->setVar('filename', $arrFile['filerealname']); - - if ($fileObj->store($allowed_mimetypes, true, false)) { - echo '    ' . sprintf(_AM_PUBLISHER_IMPORTED_ARTICLE_FILE, $arrFile['filerealname']) . '
'; - } + } + // Linkes files + + $sql = 'SELECT * FROM ' . $GLOBALS['xoopsDB']->prefix('xfs_files') . ' WHERE articleid=' . $arrArticle['articleid']; + $resultFiles = $GLOBALS['xoopsDB']->query($sql); + $allowed_mimetypes = ''; + while (false !== ($arrFile = $GLOBALS['xoopsDB']->fetchArray($resultFiles))) { + $filename = $GLOBALS['xoops']->path('modules/xfsection/cache/uploaded/' . $arrFile['filerealname']); + if (file_exists($filename)) { + if (copy($filename, PUBLISHER_UPLOAD_PATH . '/' . $arrFile['filerealname'])) { + /** @var Publisher\File $fileObj */ + $fileObj = $helper->getHandler('File')->create(); + $fileObj->setVar('name', $arrFile['fileshowname']); + $fileObj->setVar('description', $arrFile['filedescript']); + $fileObj->setVar('status', Constants::PUBLISHER_STATUS_FILE_ACTIVE); + $fileObj->setVar('uid', $arrArticle['uid']); + $fileObj->setVar('itemid', $itemObj->itemid()); + $fileObj->setVar('mimetype', $arrFile['minetype']); + $fileObj->setVar('datesub', $arrFile['date']); + $fileObj->setVar('counter', $arrFile['counter']); + $fileObj->setVar('filename', $arrFile['filerealname']); + + if ($fileObj->store($allowed_mimetypes, true, false)) { + echo '    ' . sprintf(_AM_PUBLISHER_IMPORTED_ARTICLE_FILE, $arrFile['filerealname']) . '
'; } } } - - $newArticleArray[$arrArticle['articleid']] = $itemObj->itemid(); - echo '  ' . sprintf(_AM_PUBLISHER_IMPORTED_ARTICLE, $itemObj->getTitle()) . '
'; - ++$cnt_imported_articles; } + + $newArticleArray[$arrArticle['articleid']] = $itemObj->itemid(); + echo '  ' . sprintf(_AM_PUBLISHER_IMPORTED_ARTICLE, $itemObj->getTitle()) . '
'; + ++$cnt_imported_articles; } $newCatArray[$newCat['oldid']] = $newCat; unset($newCat); diff --git a/admin/import/xnews.php b/admin/import/xnews.php index 66eac640..290f0110 100644 --- a/admin/import/xnews.php +++ b/admin/import/xnews.php @@ -79,7 +79,8 @@ try { $imageCategoryHandler->insert($imagecategory); // exit(); - } catch (\Exception $e) { + } + catch (\Exception $e) { echo "Caught exception: : couldn't insert Image Category " . $e->getMessage() . 'n'; } @@ -239,8 +240,8 @@ $imageHandler = xoops_getHandler('image'); $image = $imageHandler->create(); $image->setVar('image_name', $arrCat['topic_imgurl']);//'images/' . $uploader->getSavedFileName()); - $image->setVar('image_nicename', substr($arrCat['topic_imgurl'],-13)); //$image_nicename); - $image->setVar('image_mimetype', 'image/'. substr($arrCat['topic_imgurl'],-3));//$uploader->getMediaType()); + $image->setVar('image_nicename', mb_substr($arrCat['topic_imgurl'],-13)); //$image_nicename); + $image->setVar('image_mimetype', 'image/'. mb_substr($arrCat['topic_imgurl'],-3));//$uploader->getMediaType()); // $image->setVar('image_created', time()); // $image_display = empty($image_display) ? 0 : 1; $image->setVar('image_display', 1); //$image_display); @@ -344,42 +345,41 @@ if (!$itemObj->store()) { echo sprintf(' ' . _AM_PUBLISHER_IMPORT_ARTICLE_ERROR, $arrArticle['storyid'] . ' ' . $arrArticle['title']) . '
'; continue; - } else { - //-------------------------------------------- - // Linkes files - $sql = 'SELECT * FROM ' . $GLOBALS['xoopsDB']->prefix('nw_stories_files') . ' WHERE storyid=' . $arrArticle['storyid']; - $resultFiles = $GLOBALS['xoopsDB']->query($sql); - $allowed_mimetypes = ''; - while (false !== ($arrFile = $GLOBALS['xoopsDB']->fetchArray($resultFiles))) { - $filename = $GLOBALS['xoops']->path('uploads/xnews/attached/' . $arrFile['downloadname']); - if (file_exists($filename)) { - if (copy($filename, $GLOBALS['xoops']->path('uploads/publisher/' . $arrFile['filerealname']))) { - /* @var $fileObj Publisher\File */ - $fileObj = $helper->getHandler('File')->create(); - $fileObj->setVar('name', $arrFile['filerealname']); - $fileObj->setVar('description', $arrFile['filerealname']); - $fileObj->setVar('status', Constants::PUBLISHER_STATUS_FILE_ACTIVE); - $fileObj->setVar('uid', $arrArticle['uid']); - $fileObj->setVar('itemid', $itemObj->itemid()); - $fileObj->setVar('mimetype', $arrFile['mimetype']); - $fileObj->setVar('datesub', $arrFile['date']); - $fileObj->setVar('counter', $arrFile['counter']); - $fileObj->setVar('filename', $arrFile['filerealname']); - $fileObj->setVar('short_url', $arrFile['filerealname']); - - if ($fileObj->store($allowed_mimetypes, true, false)) { - echo '    ' . sprintf(_AM_PUBLISHER_IMPORTED_ARTICLE_FILE, $arrFile['filerealname']) . '
'; - } + } + //-------------------------------------------- + // Linkes files + $sql = 'SELECT * FROM ' . $GLOBALS['xoopsDB']->prefix('nw_stories_files') . ' WHERE storyid=' . $arrArticle['storyid']; + $resultFiles = $GLOBALS['xoopsDB']->query($sql); + $allowed_mimetypes = ''; + while (false !== ($arrFile = $GLOBALS['xoopsDB']->fetchArray($resultFiles))) { + $filename = $GLOBALS['xoops']->path('uploads/xnews/attached/' . $arrFile['downloadname']); + if (file_exists($filename)) { + if (copy($filename, $GLOBALS['xoops']->path('uploads/publisher/' . $arrFile['filerealname']))) { + /* @var $fileObj Publisher\File */ + $fileObj = $helper->getHandler('File')->create(); + $fileObj->setVar('name', $arrFile['filerealname']); + $fileObj->setVar('description', $arrFile['filerealname']); + $fileObj->setVar('status', Constants::PUBLISHER_STATUS_FILE_ACTIVE); + $fileObj->setVar('uid', $arrArticle['uid']); + $fileObj->setVar('itemid', $itemObj->itemid()); + $fileObj->setVar('mimetype', $arrFile['mimetype']); + $fileObj->setVar('datesub', $arrFile['date']); + $fileObj->setVar('counter', $arrFile['counter']); + $fileObj->setVar('filename', $arrFile['filerealname']); + $fileObj->setVar('short_url', $arrFile['filerealname']); + + if ($fileObj->store($allowed_mimetypes, true, false)) { + echo '    ' . sprintf(_AM_PUBLISHER_IMPORTED_ARTICLE_FILE, $arrFile['filerealname']) . '
'; } } } + } - //------------------------ + //------------------------ - $newArticleArray[$arrArticle['storyid']] = $itemObj->itemid(); - echo '  ' . sprintf(_AM_PUBLISHER_IMPORTED_ARTICLE, $itemObj->getTitle()) . '
'; - ++$cnt_imported_articles; - } + $newArticleArray[$arrArticle['storyid']] = $itemObj->itemid(); + echo '  ' . sprintf(_AM_PUBLISHER_IMPORTED_ARTICLE, $itemObj->getTitle()) . '
'; + ++$cnt_imported_articles; } // Saving category permissions diff --git a/admin/index.php b/admin/index.php index 5a6b81f7..fe0832d7 100644 --- a/admin/index.php +++ b/admin/index.php @@ -30,7 +30,7 @@ $helper = Publisher\Helper::getInstance(); $helper->loadLanguage('main'); $adminObject = \Xmf\Module\Admin::getInstance(); -$utility = new Publisher\Utility(); +$utility = new Publisher\Utility(); /* foreach (array_keys($GLOBALS['uploadFolders']) as $i) { @@ -57,7 +57,7 @@ if ($helper->getConfig('displaySampleButton')) { xoops_loadLanguage('admin/modulesadmin', 'system'); - require_once dirname(__DIR__) . '/testdata/index.php'; + require_once dirname(__DIR__) . '/testdata/index.php'; $adminObject->addItemButton(constant('CO_' . $moduleDirNameUpper . '_' . 'ADD_SAMPLEDATA'), '__DIR__ . /../../testdata/index.php?op=load', 'add'); diff --git a/admin/item.php b/admin/item.php index ccd63089..ece50334 100644 --- a/admin/item.php +++ b/admin/item.php @@ -31,7 +31,7 @@ } $itemid = Request::getInt('itemid', Request::getInt('itemid', 0, 'POST'), 'GET'); -$op = ($itemid > 0 || Request::getString('editor', '', 'POST')) ? 'mod' : ''; +$op = ($itemid > 0 || Request::getString('editor', '', 'POST')) ? 'mod' : ''; //$op = Request::getString('op', $op, 'GET'); $op = Request::getString('op', Request::getString('op', $op, 'POST'), 'GET'); @@ -88,7 +88,7 @@ switch ($newStatus) { case Constants::PUBLISHER_STATUS_SUBMITTED: $error_msg = _AM_PUBLISHER_ITEMNOTCREATED; - if ($old_status == Constants::PUBLISHER_STATUS_NOTSET) { + if (Constants::PUBLISHER_STATUS_NOTSET == $old_status) { $error_msg = _AM_PUBLISHER_ITEMNOTUPDATED; } $redirect_msg = _AM_PUBLISHER_ITEM_RECEIVED_NEED_APPROVAL; @@ -106,7 +106,7 @@ case Constants::PUBLISHER_STATUS_OFFLINE: $redirect_msg = _AM_PUBLISHER_OFFLINE_MOD_SUCCESS; - if ($old_status == Constants::PUBLISHER_STATUS_NOTSET) { + if (Constants::PUBLISHER_STATUS_NOTSET == $old_status) { $redirect_msg = _AM_PUBLISHER_OFFLINE_CREATED_SUCCESS; } $error_msg = _AM_PUBLISHER_ITEMNOTUPDATED; @@ -114,7 +114,7 @@ case Constants::PUBLISHER_STATUS_REJECTED: $error_msg = _AM_PUBLISHER_ITEMNOTCREATED; - if ($old_status == Constants::PUBLISHER_STATUS_NOTSET) { + if (Constants::PUBLISHER_STATUS_NOTSET == $old_status) { $error_msg = _AM_PUBLISHER_ITEMNOTUPDATED; } $redirect_msg = _AM_PUBLISHER_ITEM_REJECTED; @@ -156,7 +156,7 @@ // exit(); } redirect_header('item.php', 2, sprintf(_AM_PUBLISHER_ITEMISDELETED, $itemObj->getTitle())); - // exit(); + // exit(); } else { xoops_cp_header(); xoops_confirm(['op' => 'del', 'itemid' => $itemObj->itemid(), 'confirm' => 1, 'name' => $itemObj->getTitle()], 'item.php', _AM_PUBLISHER_DELETETHISITEM . "
'" . $itemObj->getTitle() . "'.

", _AM_PUBLISHER_DELETE); diff --git a/admin/main.php b/admin/main.php index 9992c22e..daabc32b 100644 --- a/admin/main.php +++ b/admin/main.php @@ -26,7 +26,7 @@ require_once $GLOBALS['xoops']->path('class/xoopslists.php'); require_once $GLOBALS['xoops']->path('class/pagenav.php'); // require_once dirname(__DIR__) . '/class/Utility.php'; -require_once dirname(__DIR__) . '/include/common.php'; +require_once dirname(__DIR__) . '/include/common.php'; $itemid = Request::getInt('itemid', 0, 'POST'); @@ -38,7 +38,7 @@ $module_id = $helper->getModule()->mid(); /* @var $grouppermHandler XoopsGroupPermHandler */ $grouppermHandler = xoops_getHandler('groupperm'); -$groups = $GLOBALS['xoopsUser'] ? $GLOBALS['xoopsUser']->getGroups() : XOOPS_GROUP_ANONYMOUS; +$groups = $GLOBALS['xoopsUser'] ? $GLOBALS['xoopsUser']->getGroups() : XOOPS_GROUP_ANONYMOUS; // Code for the page @@ -292,17 +292,7 @@ case Constants::PUBLISHER_STATUS_REJECTED: $statustxt = _CO_PUBLISHER_REJECTED; $approve = ''; - $modify = "getModule()->dirname() - . "/assets/images/links/edit.gif' title='" - . _AM_PUBLISHER_REJECTED_EDIT - . "' alt='" - . _AM_PUBLISHER_REJECTED_EDIT - . "'> "; + $modify = "getModule()->dirname() . "/assets/images/links/edit.gif' title='" . _AM_PUBLISHER_REJECTED_EDIT . "' alt='" . _AM_PUBLISHER_REJECTED_EDIT . "'> "; $delete = "getModule()->dirname() . "/assets/images/links/delete.png' title='" . _AM_PUBLISHER_DELETEITEM . "' alt='" . _AM_PUBLISHER_DELETEITEM . "'> "; $clone = "getModule()->dirname() . "/assets/images/links/clone.gif' title='" . _AM_PUBLISHER_CLONE_ITEM . "' alt='" . _AM_PUBLISHER_CLONE_ITEM . "'> "; break; @@ -312,17 +302,7 @@ $statustxt = _AM_PUBLISHER_STATUS0; $approve = ''; $clone = ''; - $modify = "getModule()->dirname() - . "/assets/images/links/edit.gif' title='" - . _AM_PUBLISHER_REJECTED_EDIT - . "' alt='" - . _AM_PUBLISHER_REJECTED_EDIT - . "'> "; + $modify = "getModule()->dirname() . "/assets/images/links/edit.gif' title='" . _AM_PUBLISHER_REJECTED_EDIT . "' alt='" . _AM_PUBLISHER_REJECTED_EDIT . "'> "; $delete = "getModule()->dirname() . "/assets/images/links/delete.png' title='" . _AM_PUBLISHER_DELETEITEM . "' alt='" . _AM_PUBLISHER_DELETEITEM . "'>"; break; } diff --git a/admin/menu.php b/admin/menu.php index 8b49d595..9a81f54b 100644 --- a/admin/menu.php +++ b/admin/menu.php @@ -29,55 +29,55 @@ $helper = Publisher\Helper::getInstance(); // get path to icons -$pathIcon32 = \Xmf\Module\Admin::menuIconPath(''); +$pathIcon32 = \Xmf\Module\Admin::menuIconPath(''); $pathModIcon32 = $helper->getModule()->getInfo('modicons32'); $adminmenu = [ [ 'title' => _MI_PUBLISHER_ADMENU0, 'link' => 'admin/index.php', - 'icon' => $pathIcon32 . '/home.png' + 'icon' => $pathIcon32 . '/home.png', ], [ 'title' => _MI_PUBLISHER_ADMENU1, 'link' => 'admin/main.php', - 'icon' => $pathIcon32 . '/manage.png' + 'icon' => $pathIcon32 . '/manage.png', ], // Category [ 'title' => _MI_PUBLISHER_ADMENU2, 'link' => 'admin/category.php', - 'icon' => $pathIcon32 . '/category.png' + 'icon' => $pathIcon32 . '/category.png', ], // Items [ 'title' => _MI_PUBLISHER_ADMENU3, 'link' => 'admin/item.php', - 'icon' => $pathIcon32 . '/content.png' + 'icon' => $pathIcon32 . '/content.png', ], // Permissions [ 'title' => _MI_PUBLISHER_ADMENU4, 'link' => 'admin/permissions.php', - 'icon' => $pathIcon32 . '/permissions.png' + 'icon' => $pathIcon32 . '/permissions.png', ], -// Blocks Admin + // Blocks Admin [ 'title' => _MI_PUBLISHER_ADMENU5, 'link' => 'admin/blocksadmin.php', - 'icon' => $pathIcon32 . '/block.png' + 'icon' => $pathIcon32 . '/block.png', ], // Mimetypes [ 'title' => _MI_PUBLISHER_ADMENU6, 'link' => 'admin/mimetypes.php', - 'icon' => $pathIcon32 . '/type.png' + 'icon' => $pathIcon32 . '/type.png', ], // Preferences @@ -98,27 +98,27 @@ [ 'title' => _MI_PUBLISHER_IMPORT, 'link' => 'admin/import.php', - 'icon' => $pathIcon32 . '/download.png' + 'icon' => $pathIcon32 . '/download.png', ], //Clone [ 'title' => _MI_PUBLISHER_MENU_CLONE, 'link' => 'admin/clone.php', - 'icon' => $pathModIcon32 . '/editcopy.png' + 'icon' => $pathModIcon32 . '/editcopy.png', ], -// [ -// 'title' => _MI_PUBLISHER_MENU_HISTORY, -// 'link' => 'admin/history.php', -// 'icon' => $pathModIcon32 . '/editcopy.png' -// ], + // [ + // 'title' => _MI_PUBLISHER_MENU_HISTORY, + // 'link' => 'admin/history.php', + // 'icon' => $pathModIcon32 . '/editcopy.png' + // ], //About [ 'title' => _MI_PUBLISHER_ABOUT, 'link' => 'admin/about.php', - 'icon' => $pathIcon32 . '/about.png' - ] + 'icon' => $pathIcon32 . '/about.png', + ], ]; $GLOBALS['xoTheme']->addStylesheet('modules/' . $moduleDirName . '/assets/css/style.css'); diff --git a/admin/mimetypes.php b/admin/mimetypes.php index 7ccd67be..c9b156c1 100644 --- a/admin/mimetypes.php +++ b/admin/mimetypes.php @@ -33,7 +33,7 @@ 'mime_name' => _AM_PUBLISHER_MIME_NAME, 'mime_ext' => _AM_PUBLISHER_MIME_EXT, 'mime_admin' => _AM_PUBLISHER_MIME_ADMIN, - 'mime_user' => _AM_PUBLISHER_MIME_USER + 'mime_user' => _AM_PUBLISHER_MIME_USER, ]; $aOrderBy = ['ASC' => _AM_PUBLISHER_TEXT_ASCENDING, 'DESC' => _AM_PUBLISHER_TEXT_DESCENDING]; $aLimitBy = ['10' => 10, '15' => 15, '20' => 20, '25' => 25, '50' => 50, '100' => 100]; @@ -774,9 +774,9 @@ public static function confirmUpdateMimeValue() $helper = Publisher\Helper::getInstance(); /** @var Publisher\MimetypeHandler $mimetypeHandler */ $mimetypeHandler = $helper->getHandler('Mimetype'); - $limit = Request::getInt('limit', 0, 'POST'); - $start = Request::getInt('start', 0, 'POST'); - $mimeId = Request::getInt('id', 0, 'POST'); + $limit = Request::getInt('limit', 0, 'POST'); + $start = Request::getInt('start', 0, 'POST'); + $mimeId = Request::getInt('id', 0, 'POST'); if (0 === $mimeId) { redirect_header(PUBLISHER_ADMIN_URL . '/mimetypes.php', 3, _AM_PUBLISHER_MESSAGE_NO_ID); } diff --git a/admin/pagewrap.php b/admin/pagewrap.php index 84f0f26c..40095295 100644 --- a/admin/pagewrap.php +++ b/admin/pagewrap.php @@ -29,7 +29,7 @@ $dir = Publisher\Utility::getUploadDir(true, 'content'); -if (false !== strpos(decoct(fileperms($dir)), '777')) { +if (false !== mb_strpos(decoct(fileperms($dir)), '777')) { echo "

" . _AM_PUBLISHER_PERMERROR . '

'; } diff --git a/admin/permissions.php b/admin/permissions.php index 5d090faa..a0abf804 100644 --- a/admin/permissions.php +++ b/admin/permissions.php @@ -22,7 +22,7 @@ use XoopsModules\Publisher\Constants; require_once __DIR__ . '/admin_header.php'; -require_once dirname(__DIR__) . '/include/common.php'; +require_once dirname(__DIR__) . '/include/common.php'; require_once $GLOBALS['xoops']->path('class/xoopsform/grouppermform.php'); $myts = \MyTextSanitizer::getInstance(); @@ -107,7 +107,7 @@ Constants::PUBLISHER_DOLINEBREAK => _CO_PUBLISHER_DOLINEBREAK, Constants::PUBLISHER_NOTIFY => _AM_PUBLISHER_NOTIFY, Constants::PUBLISHER_SUBTITLE => _CO_PUBLISHER_SUBTITLE, - Constants::PUBLISHER_AUTHOR_ALIAS => _CO_PUBLISHER_AUTHOR_ALIAS + Constants::PUBLISHER_AUTHOR_ALIAS => _CO_PUBLISHER_AUTHOR_ALIAS, ]; $form_submit = new \XoopsGroupPermForm('', $helper->getModule()->mid(), 'form_view', '', 'admin/permissions.php'); foreach ($form_options as $key => $value) { @@ -134,7 +134,7 @@ Publisher\Utility::openCollapsableBar('permissionstable_global', 'permissionsicon_global', _AM_PUBLISHER_PERMISSIONS_GLOBAL, _AM_PUBLISHER_PERMISSIONS_GLOBAL_DSC); $form_options = [ Constants::PUBLISHER_SEARCH => _AM_PUBLISHER_SEARCH, - Constants::PUBLISHER_RATE => _AM_PUBLISHER_RATE + Constants::PUBLISHER_RATE => _AM_PUBLISHER_RATE, ]; $form_submit = new \XoopsGroupPermForm('', $helper->getModule()->mid(), 'global', '', 'admin/permissions.php'); foreach ($form_options as $key => $value) { diff --git a/admin/preferences.php b/admin/preferences.php index 9025e603..b48741a8 100644 --- a/admin/preferences.php +++ b/admin/preferences.php @@ -27,12 +27,12 @@ $helper = Publisher\Helper::getInstance(); $module = $helper->getModule(); -$modId = $module->mid(); +$modId = $module->mid(); $modname = $module->name(); $dirName = $helper->getDirname(); $moduleHandler = xoops_getHandler('module'); -$xoopsModule0 = $moduleHandler->getByDirname(basename(dirname(__DIR__))); +$xoopsModule0 = $moduleHandler->getByDirname(basename(dirname(__DIR__))); global $xoopsModule; xoops_loadLanguage('admin', 'system'); @@ -65,7 +65,7 @@ if (!array_key_exists('others', $config_cats)) { $config_cats['others'] = [ 'name' => _MI_PUBLISHER_CONFCAT_OTHERS, - 'description' => _MI_PUBLISHER_CONFCAT_OTHERS_DSC + 'description' => _MI_PUBLISHER_CONFCAT_OTHERS_DSC, ]; } $cat_others_used = false; diff --git a/admin/pw_delete_file.php b/admin/pw_delete_file.php index 4194ae24..b6a79195 100644 --- a/admin/pw_delete_file.php +++ b/admin/pw_delete_file.php @@ -36,7 +36,8 @@ $path_file = realpath($dir . '/' . $filename); try { Assert::startsWith($path_file, $check_path, _AM_PUBLISHER_FILE_DELETE_ERROR); - } catch (\InvalidArgumentException $e) { + } + catch (\InvalidArgumentException $e) { // handle the exception redirect_header(XOOPS_URL . '/modules/publisher/admin/item.php', 2, $e->getMessage()); } diff --git a/admin/pw_upload_file.php b/admin/pw_upload_file.php index 84690b68..fa1eef58 100644 --- a/admin/pw_upload_file.php +++ b/admin/pw_upload_file.php @@ -44,7 +44,7 @@ function publisher_pagewrap_upload(&$errors) xoops_load('XoopsMediaUploader'); /** @var Publisher\Helper $helper */ - $helper = Publisher\Helper::getInstance(); + $helper = Publisher\Helper::getInstance(); $postField = 'fileupload'; $maxFileSize = $helper->getConfig('maximum_filesize'); @@ -52,7 +52,9 @@ function publisher_pagewrap_upload(&$errors) $maxImageHeight = $helper->getConfig('maximum_image_height'); if (!is_dir(Publisher\Utility::getUploadDir(true, 'content'))) { - mkdir(Publisher\Utility::getUploadDir(true, 'content'), 0757); + if (!mkdir($concurrentDirectory = Publisher\Utility::getUploadDir(true, 'content'), 0757) && !is_dir($concurrentDirectory)) { + throw new \RuntimeException(sprintf('Directory "%s" was not created', $concurrentDirectory)); + } } $allowedMimeTypes = ['text/html', 'text/plain', 'application/xhtml+xml']; $uploader = new \XoopsMediaUploader(Publisher\Utility::getUploadDir(true, 'content') . '/', $allowedMimeTypes, $maxFileSize, $maxImageWidth, $maxImageHeight); @@ -60,14 +62,12 @@ function publisher_pagewrap_upload(&$errors) $uploader->setTargetFileName($uploader->getMediaName()); if ($uploader->upload()) { return true; - } else { - $errors = array_merge($errors, $uploader->getErrors(false)); - - return false; } - } else { $errors = array_merge($errors, $uploader->getErrors(false)); return false; } + $errors = array_merge($errors, $uploader->getErrors(false)); + + return false; } diff --git a/archive.php b/archive.php index 539624ff..49c9af5f 100644 --- a/archive.php +++ b/archive.php @@ -47,7 +47,7 @@ 9 => _CAL_SEPTEMBER, 10 => _CAL_OCTOBER, 11 => _CAL_NOVEMBER, - 12 => _CAL_DECEMBER + 12 => _CAL_DECEMBER, ]; $fromyear = Request::getInt('year'); $frommonth = Request::getInt('month'); diff --git a/author_items.php b/author_items.php index 115ebe3a..6c5069d7 100644 --- a/author_items.php +++ b/author_items.php @@ -74,7 +74,7 @@ 'count_items' => 0, 'count_hits' => 0, 'title' => $item->getCategoryName(), - 'link' => $item->getCategoryLink() + 'link' => $item->getCategoryLink(), ]; } @@ -86,7 +86,7 @@ 'link' => $item->getItemLink(), 'published' => $item->getDatesub(_SHORTDATESTRING), //'rating' => $xoopsLocal->number_format((float)$item->rating()) - 'rating' => $item->rating() + 'rating' => $item->rating(), ]; } } diff --git a/backend.php b/backend.php index bfe42a2a..31811faa 100644 --- a/backend.php +++ b/backend.php @@ -89,7 +89,7 @@ 'title' => htmlspecialchars($item->getTitle(), ENT_QUOTES), 'link' => $item->getItemUrl(), 'guid' => $item->getItemUrl(), -//mb 'pubdate' => XoopsLocal::formatTimestamp($item->getVar('datesub'), 'rss'), + //mb 'pubdate' => XoopsLocal::formatTimestamp($item->getVar('datesub'), 'rss'), 'pubdate' => formatTimestamp($item->getVar('datesub'), 'rss'), 'description' => htmlspecialchars($item->getBlockSummary(300, true), ENT_QUOTES) ]); diff --git a/blocks/category_items_sel.php b/blocks/category_items_sel.php index f9fec6ca..c64ea1c8 100644 --- a/blocks/category_items_sel.php +++ b/blocks/category_items_sel.php @@ -23,7 +23,7 @@ // defined('XOOPS_ROOT_PATH') || die('Restricted access'); -require_once dirname(__DIR__) . '/include/common.php'; +require_once dirname(__DIR__) . '/include/common.php'; /** * @param $options @@ -61,7 +61,7 @@ function publisher_category_items_sel_show($options) $criteria = new \Criteria('categoryid', $catID); /** @var Publisher\ItemHandler $itemHandler */ $itemHandler = $helper->getHandler('Item'); - $items = $itemHandler->getItems($limit, $start, [Constants::PUBLISHER_STATUS_PUBLISHED], -1, $sort, $order, '', true, $criteria, true); + $items = $itemHandler->getItems($limit, $start, [Constants::PUBLISHER_STATUS_PUBLISHED], -1, $sort, $order, '', true, $criteria, true); unset($criteria); if (0 === count($items)) { @@ -106,7 +106,7 @@ function publisher_category_items_sel_edit($options) $orderEle->addOptionArray([ 'datesub' => _MB_PUBLISHER_DATE, 'counter' => _MB_PUBLISHER_HITS, - 'weight' => _MB_PUBLISHER_WEIGHT + 'weight' => _MB_PUBLISHER_WEIGHT, ]); $dispEle = new \XoopsFormText(_MB_PUBLISHER_DISP, 'options[2]', 10, 255, $options[2]); $charsEle = new \XoopsFormText(_MB_PUBLISHER_CHARS, 'options[3]', 10, 255, $options[3]); diff --git a/blocks/date_to_date.php b/blocks/date_to_date.php index 78691568..28ab1fe5 100644 --- a/blocks/date_to_date.php +++ b/blocks/date_to_date.php @@ -23,7 +23,7 @@ // defined('XOOPS_ROOT_PATH') || die('Restricted access'); -require_once dirname(__DIR__) . '/include/common.php'; +require_once dirname(__DIR__) . '/include/common.php'; /** * @param $options @@ -32,7 +32,7 @@ */ function publisher_date_to_date_show($options) { - $myts = \MyTextSanitizer::getInstance(); + $myts = \MyTextSanitizer::getInstance(); /** @var Publisher\Helper $helper */ $helper = Publisher\Helper::getInstance(); @@ -49,15 +49,15 @@ function publisher_date_to_date_show($options) $totalItems = count($itemsObj); if ($itemsObj) { - for ($i = 0; $i < $totalItems; ++$i) { - $newItems['itemid'] = $itemsObj[$i]->itemid(); - $newItems['title'] = $itemsObj[$i]->getTitle(); - $newItems['categoryname'] = $itemsObj[$i]->getCategoryName(); - $newItems['categoryid'] = $itemsObj[$i]->categoryid(); - $newItems['date'] = $itemsObj[$i]->getDatesub(); - $newItems['poster'] = $itemsObj[$i]->getLinkedPosterName(); - $newItems['itemlink'] = $itemsObj[$i]->getItemLink(false, isset($options[3]) ? $options[3] : 65); - $newItems['categorylink'] = $itemsObj[$i]->getCategoryLink(); + foreach ($itemsObj as $iValue) { + $newItems['itemid'] = $iValue->itemid(); + $newItems['title'] = $iValue->getTitle(); + $newItems['categoryname'] = $iValue->getCategoryName(); + $newItems['categoryid'] = $iValue->categoryid(); + $newItems['date'] = $iValue->getDatesub(); + $newItems['poster'] = $iValue->getLinkedPosterName(); + $newItems['itemlink'] = $iValue->getItemLink(false, isset($options[3]) ? $options[3] : 65); + $newItems['categorylink'] = $iValue->getCategoryLink(); $block['items'][] = $newItems; } diff --git a/blocks/items_columns.php b/blocks/items_columns.php index 0b2d3b48..def91d75 100644 --- a/blocks/items_columns.php +++ b/blocks/items_columns.php @@ -23,7 +23,7 @@ // defined('XOOPS_ROOT_PATH') || die('Restricted access'); -require_once dirname(__DIR__) . '/include/common.php'; +require_once dirname(__DIR__) . '/include/common.php'; /*** * Function To Show Publisher Items From Categories In Their Own Columns @@ -54,7 +54,7 @@ function publisher_items_columns_show($options) //get permited categories only once /** @var Publisher\CategoryHandler $categoryHandler */ $categoryHandler = $helper->getHandler('Category'); - $categoriesObj = $categoryHandler->getCategories(0, 0, -1); + $categoriesObj = $categoryHandler->getCategories(0, 0, -1); //if not selected 'all', let's get the selected ones if (!in_array(0, $selCategories)) { @@ -111,7 +111,8 @@ function publisher_items_columns_show($options) //The Rest if ($scount > 1) { // while ((list($itemid, $thisitem) = each($categoryItemsObj)) !== false) { - foreach ($categoryItemsObj as $itemid => $thisitem) { //TODO do I need to start with 2nd element? + foreach ($categoryItemsObj as $itemid => $thisitem) { + //TODO do I need to start with 2nd element? $subItem['title'] = $thisitem->getTitle(); $subItem['cleantitle'] = strip_tags($thisitem->getTitle()); $subItem['link'] = $thisitem->getItemLink(); @@ -160,7 +161,7 @@ function publisher_items_columns_edit($options) '2' => 2, '3' => 3, '4' => 4, - '5' => 5 + '5' => 5, ]); $catEle = new \XoopsFormLabel(_MB_PUBLISHER_SELECTCAT, Publisher\Utility::createCategorySelect($options[1], 0, true, 'options[1]')); $cItemsEle = new \XoopsFormText(_MB_PUBLISHER_NUMBER_ITEMS_CAT, 'options[2]', 4, 255, $options[2]); @@ -169,7 +170,7 @@ function publisher_items_columns_edit($options) $tempEle = new \XoopsFormSelect(_MB_PUBLISHER_TEMPLATE, 'options[4]', $options[4]); $tempEle->addOptionArray([ 'normal' => _MB_PUBLISHER_TEMPLATE_NORMAL, - 'extended' => _MB_PUBLISHER_TEMPLATE_EXTENDED + 'extended' => _MB_PUBLISHER_TEMPLATE_EXTENDED, ]); $form->addElement($colEle); diff --git a/blocks/items_menu.php b/blocks/items_menu.php index f607d468..8140bbea 100644 --- a/blocks/items_menu.php +++ b/blocks/items_menu.php @@ -24,7 +24,7 @@ // defined('XOOPS_ROOT_PATH') || die('Restricted access'); -require_once dirname(__DIR__) . '/include/common.php'; +require_once dirname(__DIR__) . '/include/common.php'; /** * @param $options @@ -40,7 +40,7 @@ function publisher_items_menu_show($options) // Getting all top cats /** @var Publisher\CategoryHandler $categoryHandler */ - $categoryHandler = $helper->getHandler('Category'); + $categoryHandler = $helper->getHandler('Category'); $blockCategoriesObj = $categoryHandler->getCategories(0, 0, 0); if (0 == count($blockCategoriesObj)) { @@ -92,7 +92,7 @@ function publisher_items_menu_edit($options) $orderEle->addOptionArray([ 'datesub' => _MB_PUBLISHER_DATE, 'counter' => _MB_PUBLISHER_HITS, - 'weight' => _MB_PUBLISHER_WEIGHT + 'weight' => _MB_PUBLISHER_WEIGHT, ]); $dispEle = new \XoopsFormText(_MB_PUBLISHER_DISP, 'options[2]', 10, 255, $options[2]); diff --git a/blocks/items_new.php b/blocks/items_new.php index 20bff2a2..53ac799a 100644 --- a/blocks/items_new.php +++ b/blocks/items_new.php @@ -24,7 +24,7 @@ // defined('XOOPS_ROOT_PATH') || die('Restricted access'); -require_once dirname(__DIR__) . '/include/common.php'; +require_once dirname(__DIR__) . '/include/common.php'; /** * @param $options @@ -63,16 +63,16 @@ function publisher_items_new_show($options) $totalitems = count($itemsObj); if ($totalitems > 0) { - for ($i = 0; $i < $totalitems; ++$i) { + foreach ($itemsObj as $iValue) { $item = []; - $item['link'] = $itemsObj[$i]->getItemLink(false, isset($options[4]) ? $options[4] : 65); - $item['id'] = $itemsObj[$i]->itemid(); - $item['poster'] = $itemsObj[$i]->posterName(); // for make poster name linked, use getLinkedPosterName() instead of posterName() + $item['link'] = $iValue->getItemLink(false, isset($options[4]) ? $options[4] : 65); + $item['id'] = $iValue->itemid(); + $item['poster'] = $iValue->posterName(); // for make poster name linked, use getLinkedPosterName() instead of posterName() if ('article' === $image) { $item['image'] = XOOPS_URL . '/uploads/blank.gif'; $item['image_name'] = ''; - $images = $itemsObj[$i]->getImages(); + $images = $iValue->getImages(); if (is_object($images['main'])) { // check to see if GD function exist if (!function_exists('imagecreatetruecolor')) { @@ -83,12 +83,12 @@ function publisher_items_new_show($options) $item['image_name'] = $images['main']->getVar('image_nicename'); } } elseif ('category' === $image) { - $item['image'] = $itemsObj[$i]->getCategoryImagePath(); - $item['image_name'] = $itemsObj[$i]->getCategoryName(); + $item['image'] = $iValue->getCategoryImagePath(); + $item['image_name'] = $iValue->getCategoryName(); } elseif ('avatar' === $image) { - if ('0' == $itemsObj[$i]->uid()) { + if ('0' == $iValue->uid()) { $item['image'] = XOOPS_URL . '/uploads/blank.gif'; - $images = $itemsObj[$i]->getImages(); + $images = $iValue->getImages(); if (is_object($images['main'])) { // check to see if GD function exist if (!function_exists('imagecreatetruecolor')) { @@ -100,28 +100,28 @@ function publisher_items_new_show($options) } else { // check to see if GD function exist if (!function_exists('imagecreatetruecolor')) { - $item['image'] = XOOPS_URL . '/uploads/' . $itemsObj[$i]->posterAvatar(); + $item['image'] = XOOPS_URL . '/uploads/' . $iValue->posterAvatar(); } else { - $item['image'] = PUBLISHER_URL . '/thumb.php?src=' . XOOPS_URL . '/uploads/' . $itemsObj[$i]->posterAvatar() . '&w=50'; + $item['image'] = PUBLISHER_URL . '/thumb.php?src=' . XOOPS_URL . '/uploads/' . $iValue->posterAvatar() . '&w=50'; } } - $item['image_name'] = $itemsObj[$i]->posterName(); + $item['image_name'] = $iValue->posterName(); } - $item['title'] = $itemsObj[$i]->getTitle(); + $item['title'] = $iValue->getTitle(); if ('datesub' === $sort) { - $item['new'] = $itemsObj[$i]->getDatesub(); + $item['new'] = $iValue->getDatesub(); } elseif ('counter' === $sort) { - $item['new'] = $itemsObj[$i]->counter(); + $item['new'] = $iValue->counter(); } elseif ('weight' === $sort) { - $item['new'] = $itemsObj[$i]->weight(); + $item['new'] = $iValue->weight(); } elseif ('rating' === $sort) { - $item['new'] = $itemsObj[$i]->rating(); + $item['new'] = $iValue->rating(); } elseif ('votes' === $sort) { - $item['new'] = $itemsObj[$i]->votes(); + $item['new'] = $iValue->votes(); } elseif ('comments' === $sort) { - $item['new'] = $itemsObj[$i]->comments(); + $item['new'] = $iValue->comments(); } $block['newitems'][] = $item; @@ -153,7 +153,7 @@ function publisher_items_new_edit($options) 'weight' => _MB_PUBLISHER_WEIGHT, 'rating' => _MI_PUBLISHER_ORDERBY_RATING, 'votes' => _MI_PUBLISHER_ORDERBY_VOTES, - 'comments' => _MI_PUBLISHER_ORDERBY_COMMENTS + 'comments' => _MI_PUBLISHER_ORDERBY_COMMENTS, ]); $showEle = new \XoopsFormRadioYN(_MB_PUBLISHER_ORDER_SHOW, 'options[2]', $options[2]); @@ -165,7 +165,7 @@ function publisher_items_new_edit($options) 'none' => _NONE, 'article' => _MB_PUBLISHER_IMAGE_ARTICLE, 'category' => _MB_PUBLISHER_IMAGE_CATEGORY, - 'avatar' => _MB_PUBLISHER_IMAGE_AVATAR + 'avatar' => _MB_PUBLISHER_IMAGE_AVATAR, ]); $form->addElement($catEle); diff --git a/blocks/items_random_item.php b/blocks/items_random_item.php index a8dd7d69..781ed665 100644 --- a/blocks/items_random_item.php +++ b/blocks/items_random_item.php @@ -24,7 +24,7 @@ // defined('XOOPS_ROOT_PATH') || die('Restricted access'); -require_once dirname(__DIR__) . '/include/common.php'; +require_once dirname(__DIR__) . '/include/common.php'; /** * @param $options @@ -33,7 +33,7 @@ */ function publisher_items_random_item_show($options) { - $block = []; + $block = []; /** @var Publisher\Helper $helper */ $helper = Publisher\Helper::getInstance(); /** @var Publisher\ItemHandler $itemHandler */ diff --git a/blocks/items_recent.php b/blocks/items_recent.php index 16d1fe8c..6c0c1ef2 100644 --- a/blocks/items_recent.php +++ b/blocks/items_recent.php @@ -24,7 +24,7 @@ // defined('XOOPS_ROOT_PATH') || die('Restricted access'); -require_once dirname(__DIR__) . '/include/common.php'; +require_once dirname(__DIR__) . '/include/common.php'; /** * @param $options @@ -37,7 +37,7 @@ function publisher_items_recent_show($options) $helper = Publisher\Helper::getInstance(); /** @var Publisher\ItemHandler $itemHandler */ $itemHandler = $helper->getHandler('Item'); - $myts = \MyTextSanitizer::getInstance(); + $myts = \MyTextSanitizer::getInstance(); $block = $newItems = []; @@ -65,15 +65,15 @@ function publisher_items_recent_show($options) $totalItems = count($itemsObj); if ($itemsObj && $totalItems > 0) { - for ($i = 0; $i < $totalItems; ++$i) { - $newItems['itemid'] = $itemsObj[$i]->itemid(); - $newItems['title'] = $itemsObj[$i]->getTitle(); - $newItems['categoryname'] = $itemsObj[$i]->getCategoryName(); - $newItems['categoryid'] = $itemsObj[$i]->categoryid(); - $newItems['date'] = $itemsObj[$i]->getDatesub(); - $newItems['poster'] = $itemsObj[$i]->getLinkedPosterName(); - $newItems['itemlink'] = $itemsObj[$i]->getItemLink(false, isset($options[3]) ? $options[3] : 65); - $newItems['categorylink'] = $itemsObj[$i]->getCategoryLink(); + foreach ($itemsObj as $iValue) { + $newItems['itemid'] = $iValue->itemid(); + $newItems['title'] = $iValue->getTitle(); + $newItems['categoryname'] = $iValue->getCategoryName(); + $newItems['categoryid'] = $iValue->categoryid(); + $newItems['date'] = $iValue->getDatesub(); + $newItems['poster'] = $iValue->getLinkedPosterName(); + $newItems['itemlink'] = $iValue->getItemLink(false, isset($options[3]) ? $options[3] : 65); + $newItems['categorylink'] = $iValue->getCategoryLink(); $block['items'][] = $newItems; } @@ -106,7 +106,7 @@ function publisher_items_recent_edit($options) $orderEle->addOptionArray([ 'datesub' => _MB_PUBLISHER_DATE, 'counter' => _MB_PUBLISHER_HITS, - 'weight' => _MB_PUBLISHER_WEIGHT + 'weight' => _MB_PUBLISHER_WEIGHT, ]); $dispEle = new \XoopsFormText(_MB_PUBLISHER_DISP, 'options[2]', 10, 255, $options[2]); $charsEle = new \XoopsFormText(_MB_PUBLISHER_CHARS, 'options[3]', 10, 255, $options[3]); diff --git a/blocks/items_spot.php b/blocks/items_spot.php index b13edb56..04d16adc 100644 --- a/blocks/items_spot.php +++ b/blocks/items_spot.php @@ -8,6 +8,7 @@ but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. */ + /** * @copyright The XUUPS Project http://sourceforge.net/projects/xuups/ * @license http://www.fsf.org/copyleft/gpl.html GNU public license @@ -22,7 +23,7 @@ // defined('XOOPS_ROOT_PATH') || die('Restricted access'); -require_once dirname(__DIR__) . '/include/common.php'; +require_once dirname(__DIR__) . '/include/common.php'; /** * @param $options @@ -35,7 +36,7 @@ function publisher_items_spot_show($options) /** @var Publisher\Helper $helper */ $helper = Publisher\Helper::getInstance(); /** @var Publisher\CategoryHandler $categoryHandler */ - $categoryHandler = $helper->getHandler('Category'); + $categoryHandler = $helper->getHandler('Category'); $optDisplayLast = $options[0]; $optItemsCount = $options[1]; $optCategoryId = $options[2]; @@ -126,15 +127,15 @@ function publisher_items_spot_edit($options) { // require_once PUBLISHER_ROOT_PATH . '/class/blockform.php'; xoops_load('XoopsFormLoader'); - $form = new Publisher\BlockForm(); - $autoEle = new \XoopsFormRadioYN(_MB_PUBLISHER_AUTO_LAST_ITEMS, 'options[0]', $options[0]); - $countEle = new \XoopsFormText(_MB_PUBLISHER_LAST_ITEMS_COUNT, 'options[1]', 2, 255, $options[1]); - $catEle = new \XoopsFormLabel(_MB_PUBLISHER_SELECTCAT, Publisher\Utility::createCategorySelect($options[2], 0, true, 'options[2]')); + $form = new Publisher\BlockForm(); + $autoEle = new \XoopsFormRadioYN(_MB_PUBLISHER_AUTO_LAST_ITEMS, 'options[0]', $options[0]); + $countEle = new \XoopsFormText(_MB_PUBLISHER_LAST_ITEMS_COUNT, 'options[1]', 2, 255, $options[1]); + $catEle = new \XoopsFormLabel(_MB_PUBLISHER_SELECTCAT, Publisher\Utility::createCategorySelect($options[2], 0, true, 'options[2]')); /** @var Publisher\Helper $helper */ $helper = Publisher\Helper::getInstance(); /** @var Publisher\ItemHandler $itemHandler */ $itemHandler = $helper->getHandler('Item'); - $criteria = new \CriteriaCompo(); + $criteria = new \CriteriaCompo(); $criteria->setSort('datesub'); $criteria->setOrder('DESC'); $itemsObj = $itemHandler->getList($criteria); @@ -152,7 +153,7 @@ function publisher_items_spot_edit($options) $typeEle = new \XoopsFormSelect(_MB_PUBLISHER_DISPLAY_TYPE, 'options[6]', $options[6]); $typeEle->addOptionArray([ 'block' => _MB_PUBLISHER_DISPLAY_TYPE_BLOCK, - 'bullet' => _MB_PUBLISHER_DISPLAY_TYPE_BULLET + 'bullet' => _MB_PUBLISHER_DISPLAY_TYPE_BULLET, ]); $truncateEle = new \XoopsFormText(_MB_PUBLISHER_TRUNCATE, 'options[7]', 4, 255, $options[7]); $imageEle = new \XoopsFormRadioYN(_MB_PUBLISHER_DISPLAY_CATIMAGE, 'options[8]', $options[8]); diff --git a/blocks/latest_files.php b/blocks/latest_files.php index 83a9f7ad..2b2a4354 100644 --- a/blocks/latest_files.php +++ b/blocks/latest_files.php @@ -24,7 +24,7 @@ // defined('XOOPS_ROOT_PATH') || die('Restricted access'); -require_once dirname(__DIR__) . '/include/common.php'; +require_once dirname(__DIR__) . '/include/common.php'; /** * @param $options @@ -87,7 +87,7 @@ function publisher_latest_files_edit($options) $orderEle->addOptionArray([ 'datesub' => _MB_PUBLISHER_DATE, 'counter' => _MB_PUBLISHER_HITS, - 'weight' => _MB_PUBLISHER_WEIGHT + 'weight' => _MB_PUBLISHER_WEIGHT, ]); $dispEle = new \XoopsFormText(_MB_PUBLISHER_DISP, 'options[2]', 10, 255, $options[2]); $directEle = new \XoopsFormRadioYN(_MB_PUBLISHER_DIRECTDOWNLOAD, 'options[3]', $options[3]); diff --git a/blocks/latest_news.php b/blocks/latest_news.php index 2e033157..ea7174ef 100644 --- a/blocks/latest_news.php +++ b/blocks/latest_news.php @@ -25,7 +25,7 @@ // defined('XOOPS_ROOT_PATH') || die('Restricted access'); -require_once dirname(__DIR__) . '/include/common.php'; +require_once dirname(__DIR__) . '/include/common.php'; /** * @param $options @@ -41,8 +41,7 @@ function publisher_latest_news_show($options) $helper->loadLanguage('main'); /** @var Publisher\ItemHandler $itemHandler */ $itemHandler = $helper->getHandler('Item'); -// xoops_loadLanguage('main', 'publisher'); - + // xoops_loadLanguage('main', 'publisher'); $start = $options[0]; // You can show articles from specified range $limit = $options[1]; @@ -385,7 +384,7 @@ function publisher_latest_news_edit($options) 'extended' => _MB_PUBLISHER_TEMPLATE_EXTENDED, 'ticker' => _MB_PUBLISHER_TEMPLATE_TICKER, 'slider1' => _MB_PUBLISHER_TEMPLATE_SLIDER1, - 'slider2' => _MB_PUBLISHER_TEMPLATE_SLIDER2 + 'slider2' => _MB_PUBLISHER_TEMPLATE_SLIDER2, ]; foreach ($templates as $key => $value) { $form .= "