From 55b6326c67068774d58ae394a41843d69e55686d Mon Sep 17 00:00:00 2001 From: mambax7 Date: Sat, 4 Jul 2020 16:34:22 -0400 Subject: [PATCH] cosmetics --- admin/about.php | 1 - admin/admin_footer.php | 2 - admin/admin_header.php | 10 +- admin/blockform.php | 34 +- admin/blocksadmin.php | 138 +- admin/category.php | 29 +- admin/clone.php | 9 +- admin/feedback.php | 38 +- admin/file.php | 3 +- admin/import.php | 31 +- admin/import/ams.php | 43 +- admin/import/cjaycontent.php | 13 +- admin/import/fmcontent.php | 135 +- admin/import/news.php | 27 +- admin/import/smartsection.php | 31 +- admin/import/wfsection.php | 29 +- admin/import/xfsection.php | 29 +- admin/import/xnews.php | 55 +- admin/index.php | 13 +- admin/item.php | 86 +- admin/main.php | 99 +- admin/menu.php | 54 +- admin/migrate.php | 12 +- admin/mimetypes.php | 16 +- admin/pagewrap.php | 3 +- admin/permissions.php | 53 +- admin/preferences.php | 31 +- admin/pw_delete_file.php | 5 +- admin/pw_upload_file.php | 11 +- archive.php | 125 +- author_items.php | 66 +- backend.php | 23 +- blocks/category_items_sel.php | 30 +- blocks/date_to_date.php | 34 +- blocks/items_columns.php | 75 +- blocks/items_menu.php | 12 +- blocks/items_new.php | 140 +- blocks/items_random_item.php | 134 +- blocks/items_recent.php | 127 +- blocks/items_spot.php | 157 ++- blocks/latest_files.php | 18 +- blocks/latest_news.php | 126 +- blocks/search.php | 42 +- category.php | 34 +- class/BaseObjectHandler.php | 21 +- class/BlockForm.php | 3 - class/Category.php | 51 +- class/CategoryHandler.php | 22 +- class/Cloner.php | 4 +- class/Common/Breadcrumb.php | 4 +- class/Common/Configurator.php | 32 +- class/Common/FilesManagement.php | 8 +- class/Common/Meta.php | 62 +- class/Common/Migrate.php | 8 +- class/Common/ModuleFeedback.php | 30 +- class/Common/ModuleStats.php | 1 + class/Common/ServerStats.php | 6 +- class/Common/SysUtility.php | 27 +- class/Common/VersionChecks.php | 22 +- class/Constants.php | 3 - class/File.php | 21 +- class/FileHandler.php | 22 +- class/Form/CategoryForm.php | 39 +- class/Form/FileForm.php | 10 +- class/Form/ItemForm.php | 91 +- class/FormDateTime.php | 7 +- class/GroupPermHandler.php | 4 - class/Helper.php | 9 +- class/Highlighter.php | 12 +- class/Item.php | 203 +-- class/ItemHandler.php | 69 +- class/Metagen.php | 51 +- class/Mimetype.php | 4 - class/MimetypeHandler.php | 20 +- class/MimetypesUtility.php | 103 +- class/MyTextSanitizerExtension.php | 143 +-- class/PermissionHandler.php | 29 +- class/Rating.php | 3 - class/RatingHandler.php | 4 - class/Resizer.php | 51 +- class/Seo.php | 10 +- class/Session.php | 3 - class/ThemeTabForm.php | 59 +- class/Utility.php | 140 +- comment_delete.php | 2 - comment_edit.php | 2 - comment_new.php | 6 +- comment_post.php | 2 - comment_reply.php | 2 - config/config.php | 33 +- config/icons.php | 23 +- config/paths.php | 16 +- file.php | 3 +- footer.php | 4 - header.php | 5 - include/ajax_rating.php | 24 +- include/ajax_upload.php | 34 +- include/comment_functions.php | 7 +- include/common.php | 24 +- include/config.php | 45 +- include/notification.inc.php | 22 +- include/oninstall.php | 8 +- include/onupdate.php | 4 +- include/plugin.tag.php | 23 +- include/search.inc.php | 42 +- include/seo.inc.php | 22 +- index.php | 24 +- item.php | 134 +- language/english/common.php | 2 +- language/english/feedback.php | 4 +- language/english/modinfo.php | 2 - list.tag.php | 2 - makepdf.php | 24 +- notification_update.php | 2 - pop.php | 6 +- print.php | 18 +- rate.php | 19 +- search.php | 74 +- submit.php | 28 +- testdata/index.php | 15 +- thumb.php | 154 +-- view.tag.php | 2 - visit.php | 2 - xoops_version.php | 1892 ++++++++++++++-------------- 124 files changed, 3044 insertions(+), 3307 deletions(-) diff --git a/admin/about.php b/admin/about.php index e1976516..0dd8b4d8 100644 --- a/admin/about.php +++ b/admin/about.php @@ -16,7 +16,6 @@ * * @copyright The XOOPS Project (https://xoops.org) * @license GNU GPL (https://www.gnu.org/licenses/gpl-2.0.html/) - * @package Publisher * @since 1.0 * @author Mage, Mamba */ diff --git a/admin/admin_footer.php b/admin/admin_footer.php index d3a25775..e872fea6 100644 --- a/admin/admin_footer.php +++ b/admin/admin_footer.php @@ -14,11 +14,9 @@ /** * @copyright XOOPS Project (https://xoops.org) * @license GNU GPL 2 or later (https://www.gnu.org/licenses/gpl-2.0.html) - * @package * @since * @author XOOPS Development Team */ - $pathIcon32 = \Xmf\Module\Admin::iconUrl('', 32); echo "
\n" . "
\n" . " XOOPS\n" . "
\n" . ' ' . _AM_MODULEADMIN_ADMIN_FOOTER . "\n" . '
'; diff --git a/admin/admin_header.php b/admin/admin_header.php index cd31ce63..fc5a9f79 100644 --- a/admin/admin_header.php +++ b/admin/admin_header.php @@ -14,14 +14,10 @@ /** * @copyright The XUUPS Project http://sourceforge.net/projects/xuups/ * @license http://www.fsf.org/copyleft/gpl.html GNU public license - * @package Publisher * @since 1.0 * @author trabis * @author The SmartFactory */ - -use XoopsModules\Publisher; - require dirname(__DIR__) . '/preloads/autoloader.php'; require_once dirname(dirname(dirname(__DIR__))) . '/include/cp_header.php'; @@ -48,10 +44,10 @@ $helper->loadLanguage('main'); $imagearray = [ - 'editimg' => "" . _AM_PUBLISHER_ICO_EDIT . "", + 'editimg' => "" . _AM_PUBLISHER_ICO_EDIT . "", 'deleteimg' => "" . _AM_PUBLISHER_ICO_DELETE . "", - 'online' => "" . _AM_PUBLISHER_ICO_ONLINE . "", - 'offline' => "" . _AM_PUBLISHER_ICO_OFFLINE . "", + 'online' => "" . _AM_PUBLISHER_ICO_ONLINE . "", + 'offline' => "" . _AM_PUBLISHER_ICO_OFFLINE . "", ]; $myts = \MyTextSanitizer::getInstance(); diff --git a/admin/blockform.php b/admin/blockform.php index e8cca8b6..2229eeda 100644 --- a/admin/blockform.php +++ b/admin/blockform.php @@ -17,7 +17,7 @@ */ require_once XOOPS_ROOT_PATH . '/class/xoopsformloader.php'; -$moduleDirName = basename(dirname(__DIR__)); +$moduleDirName = basename(dirname(__DIR__)); $moduleDirNameUpper = mb_strtoupper($moduleDirName); //$capsDirName $form = new \XoopsThemeForm($block['form_title'], 'blockform', 'blocksadmin.php', 'post', true); @@ -43,11 +43,11 @@ $mod_select = new \XoopsFormSelect(constant('CO_' . $moduleDirNameUpper . '_' . 'VISIBLEIN'), 'bmodule', $block['modules'], 5, true); /** @var \XoopsModuleHandler $moduleHandler */ $moduleHandler = xoops_getHandler('module'); -$criteria = new \CriteriaCompo(new \Criteria('hasmain', 1)); +$criteria = new \CriteriaCompo(new \Criteria('hasmain', 1)); $criteria->add(new \Criteria('isactive', 1)); -$module_list = $moduleHandler->getList($criteria); +$module_list = $moduleHandler->getList($criteria); $module_list[-1] = _AM_SYSTEM_BLOCKS_TOPPAGE; -$module_list[0] = _AM_SYSTEM_BLOCKS_ALLPAGES; +$module_list[0] = _AM_SYSTEM_BLOCKS_ALLPAGES; ksort($module_list); $mod_select->addOptionArray($module_list); $form->addElement($mod_select); @@ -70,7 +70,7 @@ if ('' !== $block['template']) { /** @var \XoopsTplfileHandler $tplfileHandler */ $tplfileHandler = xoops_getHandler('tplfile'); - $btemplate = $tplfileHandler->find($GLOBALS['xoopsConfig']['template_set'], 'block', $block['bid']); + $btemplate = $tplfileHandler->find($GLOBALS['xoopsConfig']['template_set'], 'block', $block['bid']); if (count($btemplate) > 0) { $form->addElement(new \XoopsFormLabel(_AM_SYSTEM_BLOCKS_CONTENT, '' . _AM_SYSTEM_BLOCKS_EDITTPL . '')); } else { @@ -87,16 +87,16 @@ $cache_select = new \XoopsFormSelect(_AM_SYSTEM_BLOCKS_BCACHETIME, 'bcachetime', $block['bcachetime']); $cache_select->addOptionArray( [ - '0' => _NOCACHE, - '30' => sprintf(_SECONDS, 30), - '60' => _MINUTE, - '300' => sprintf(_MINUTES, 5), - '1800' => sprintf(_MINUTES, 30), - '3600' => _HOUR, - '18000' => sprintf(_HOURS, 5), - '86400' => _DAY, - '259200' => sprintf(_DAYS, 3), - '604800' => _WEEK, + '0' => _NOCACHE, + '30' => sprintf(_SECONDS, 30), + '60' => _MINUTE, + '300' => sprintf(_MINUTES, 5), + '1800' => sprintf(_MINUTES, 30), + '3600' => _HOUR, + '18000' => sprintf(_HOURS, 5), + '86400' => _DAY, + '259200' => sprintf(_DAYS, 3), + '604800' => _WEEK, '2592000' => _MONTH, ] ); @@ -104,7 +104,7 @@ /** @var \XoopsGroupPermHandler $grouppermHandler */ $grouppermHandler = xoops_getHandler('groupperm'); -$groups = $grouppermHandler->getGroupIds('block_read', $block['bid']); +$groups = $grouppermHandler->getGroupIds('block_read', $block['bid']); $form->addElement(new \XoopsFormSelectGroup(_AM_SYSTEM_BLOCKS_GROUP, 'groups', true, $groups, 5, true)); @@ -119,7 +119,7 @@ } //Submit buttons -$buttonTray = new \XoopsFormElementTray('', ''); +$buttonTray = new \XoopsFormElementTray('', ''); $submit_button = new \XoopsFormButton('', 'submitblock', _SUBMIT, 'submit'); $buttonTray->addElement($submit_button); diff --git a/admin/blocksadmin.php b/admin/blocksadmin.php index 13045ac2..ad9bccbd 100644 --- a/admin/blocksadmin.php +++ b/admin/blocksadmin.php @@ -20,7 +20,7 @@ require __DIR__ . '/admin_header.php'; -$moduleDirName = basename(dirname(__DIR__)); +$moduleDirName = basename(dirname(__DIR__)); $moduleDirNameUpper = mb_strtoupper($moduleDirName); //$capsDirName if (!is_object($xoopsModule) || !is_object($GLOBALS['xoopsUser']) @@ -47,7 +47,7 @@ */ $op = Request::getString('op', $op); - if (in_array($op, ['edit', 'delete', 'delete_ok', 'clone'])) { + if (in_array($op, ['edit', 'delete', 'delete_ok', 'clone'], true)) { $bid = Request::getInt('bid', 0, 'GET'); } @@ -57,7 +57,7 @@ function listBlocks() // require_once XOOPS_ROOT_PATH . '/class/xoopslists.php'; xoops_load('xoopslist'); require_once XOOPS_ROOT_PATH . '/class/xoopsblock.php'; - $moduleDirName = basename(dirname(__DIR__)); + $moduleDirName = basename(dirname(__DIR__)); $moduleDirNameUpper = mb_strtoupper($moduleDirName); //$capsDirName /** @var \XoopsDatabase $db */ $db = \XoopsDatabaseFactory::getDatabaseConnection(); @@ -71,12 +71,12 @@ function listBlocks() $memberHandler = xoops_getHandler('member'); /** @var \XoopsGroupPermHandler $grouppermHandler */ $grouppermHandler = xoops_getHandler('groupperm'); - $groups = $memberHandler->getGroups(); - $criteria = new \CriteriaCompo(new \Criteria('hasmain', 1)); + $groups = $memberHandler->getGroups(); + $criteria = new \CriteriaCompo(new \Criteria('hasmain', 1)); $criteria->add(new \Criteria('isactive', 1)); - $module_list = $moduleHandler->getList($criteria); + $module_list = $moduleHandler->getList($criteria); $module_list[-1] = _AM_SYSTEM_BLOCKS_TOPPAGE; - $module_list[0] = _AM_SYSTEM_BLOCKS_ALLPAGES; + $module_list[0] = _AM_SYSTEM_BLOCKS_ALLPAGES; ksort($module_list); echo "

" . constant('CO_' . $moduleDirNameUpper . '_' . 'BADMIN') . '

'; @@ -110,27 +110,27 @@ function listBlocks() . constant('CO_' . $moduleDirNameUpper . '_' . 'ACTION') . ' '; - $block_arr = \XoopsBlock::getByModule($xoopsModule->mid()); + $block_arr = \XoopsBlock::getByModule($xoopsModule->mid()); $block_count = count($block_arr); - $class = 'even'; - $cachetimes = [ - '0' => _NOCACHE, - '30' => sprintf(_SECONDS, 30), - '60' => _MINUTE, - '300' => sprintf(_MINUTES, 5), - '1800' => sprintf(_MINUTES, 30), - '3600' => _HOUR, - '18000' => sprintf(_HOURS, 5), - '86400' => _DAY, - '259200' => sprintf(_DAYS, 3), - '604800' => _WEEK, + $class = 'even'; + $cachetimes = [ + '0' => _NOCACHE, + '30' => sprintf(_SECONDS, 30), + '60' => _MINUTE, + '300' => sprintf(_MINUTES, 5), + '1800' => sprintf(_MINUTES, 30), + '3600' => _HOUR, + '18000' => sprintf(_HOURS, 5), + '86400' => _DAY, + '259200' => sprintf(_DAYS, 3), + '604800' => _WEEK, '2592000' => _MONTH, ]; foreach ($block_arr as $i) { $groups_perms = $grouppermHandler->getGroupIds('block_read', $i->getVar('bid')); - $sql = 'SELECT module_id FROM ' . $db->prefix('block_module_link') . ' WHERE block_id=' . $i->getVar('bid'); - $result = $db->query($sql); - $modules = []; + $sql = 'SELECT module_id FROM ' . $db->prefix('block_module_link') . ' WHERE block_id=' . $i->getVar('bid'); + $result = $db->query($sql); + $modules = []; while (false !== ($row = $db->fetchArray($result))) { $modules[] = (int)$row['module_id']; } @@ -240,13 +240,13 @@ function listBlocks() echo "'; echo "'; @@ -296,7 +296,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'); @@ -305,35 +305,35 @@ function cloneBlock($bid) // mpu_adm_menu(); $myblock = new \XoopsBlock($bid); - $db = \XoopsDatabaseFactory::getDatabaseConnection(); - $sql = 'SELECT module_id FROM ' . $db->prefix('block_module_link') . ' WHERE block_id=' . (int)$bid; - $result = $db->query($sql); + $db = \XoopsDatabaseFactory::getDatabaseConnection(); + $sql = 'SELECT module_id FROM ' . $db->prefix('block_module_link') . ' WHERE block_id=' . (int)$bid; + $result = $db->query($sql); $modules = []; while (false !== ($row = $db->fetchArray($result))) { $modules[] = (int)$row['module_id']; } $is_custom = ('C' === $myblock->getVar('block_type') || 'E' === $myblock->getVar('block_type')); - $block = [ - 'title' => $myblock->getVar('title') . ' Clone', + $block = [ + 'title' => $myblock->getVar('title') . ' Clone', 'form_title' => constant('CO_' . $moduleDirNameUpper . '_' . 'BLOCKS_CLONEBLOCK'), - 'name' => $myblock->getVar('name'), - 'side' => $myblock->getVar('side'), - 'weight' => $myblock->getVar('weight'), - 'visible' => $myblock->getVar('visible'), - 'content' => $myblock->getVar('content', 'N'), - 'modules' => $modules, - 'is_custom' => $is_custom, - 'ctype' => $myblock->getVar('c_type'), + 'name' => $myblock->getVar('name'), + 'side' => $myblock->getVar('side'), + 'weight' => $myblock->getVar('weight'), + 'visible' => $myblock->getVar('visible'), + 'content' => $myblock->getVar('content', 'N'), + 'modules' => $modules, + 'is_custom' => $is_custom, + 'ctype' => $myblock->getVar('c_type'), 'bcachetime' => $myblock->getVar('bcachetime'), - 'op' => 'clone_ok', - 'bid' => $myblock->getVar('bid'), - 'edit_form' => $myblock->getOptions(), - 'template' => $myblock->getVar('template'), - 'options' => $myblock->getVar('options'), + 'op' => 'clone_ok', + 'bid' => $myblock->getVar('bid'), + 'edit_form' => $myblock->getOptions(), + 'template' => $myblock->getVar('template'), + 'options' => $myblock->getVar('options'), ]; echo '' . constant('CO_' . $moduleDirNameUpper . '_' . 'BADMIN') . ' »» ' . _AM_SYSTEM_BLOCKS_CLONEBLOCK . '

'; require_once __DIR__ . '/blockform.php'; - /* @var XoopsThemeForm $form */ + /** @var XoopsThemeForm $form */ $form->display(); // xoops_cp_footer(); require_once __DIR__ . '/admin_footer.php'; @@ -390,7 +390,7 @@ function isBlockCloned($bid, $bside, $bweight, $bvisible, $bcachetime, $bmodule, if ('' !== $clone->getVar('template')) { /** @var \XoopsTplfileHandler $tplfileHandler */ $tplfileHandler = xoops_getHandler('tplfile'); - $btemplate = $tplfileHandler->find($GLOBALS['xoopsConfig']['template_set'], 'block', $bid); + $btemplate = $tplfileHandler->find($GLOBALS['xoopsConfig']['template_set'], 'block', $bid); if (count($btemplate) > 0) { $tplclone = $btemplate[0]->xoopsClone(); $tplclone->setVar('tpl_id', 0); @@ -404,7 +404,7 @@ function isBlockCloned($bid, $bside, $bweight, $bvisible, $bcachetime, $bmodule, $db->query($sql); } $groups = &$GLOBALS['xoopsUser']->getGroups(); - $count = count($groups); + $count = count($groups); for ($i = 0; $i < $count; ++$i) { $sql = 'INSERT INTO ' . $db->prefix('group_permission') . ' (gperm_groupid, gperm_itemid, gperm_modid, gperm_name) VALUES (' . $groups[$i] . ', ' . $newid . ", 1, 'block_read')"; $db->query($sql); @@ -441,7 +441,7 @@ function editBlock($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'); @@ -449,35 +449,35 @@ function editBlock($bid) xoops_loadLanguage('admin/groups', 'system'); // mpu_adm_menu(); $myblock = new \XoopsBlock($bid); - $db = \XoopsDatabaseFactory::getDatabaseConnection(); - $sql = 'SELECT module_id FROM ' . $db->prefix('block_module_link') . ' WHERE block_id=' . (int)$bid; - $result = $db->query($sql); + $db = \XoopsDatabaseFactory::getDatabaseConnection(); + $sql = 'SELECT module_id FROM ' . $db->prefix('block_module_link') . ' WHERE block_id=' . (int)$bid; + $result = $db->query($sql); $modules = []; while (false !== ($row = $db->fetchArray($result))) { $modules[] = (int)$row['module_id']; } $is_custom = ('C' === $myblock->getVar('block_type') || 'E' === $myblock->getVar('block_type')); - $block = [ - 'title' => $myblock->getVar('title'), + $block = [ + 'title' => $myblock->getVar('title'), 'form_title' => constant('CO_' . $moduleDirNameUpper . '_' . 'BLOCKS_EDITBLOCK'), // 'name' => $myblock->getVar('name'), - 'side' => $myblock->getVar('side'), - 'weight' => $myblock->getVar('weight'), - 'visible' => $myblock->getVar('visible'), - 'content' => $myblock->getVar('content', 'N'), - 'modules' => $modules, - 'is_custom' => $is_custom, - 'ctype' => $myblock->getVar('c_type'), + 'side' => $myblock->getVar('side'), + 'weight' => $myblock->getVar('weight'), + 'visible' => $myblock->getVar('visible'), + 'content' => $myblock->getVar('content', 'N'), + 'modules' => $modules, + 'is_custom' => $is_custom, + 'ctype' => $myblock->getVar('c_type'), 'bcachetime' => $myblock->getVar('bcachetime'), - 'op' => 'edit_ok', - 'bid' => $myblock->getVar('bid'), - 'edit_form' => $myblock->getOptions(), - 'template' => $myblock->getVar('template'), - 'options' => $myblock->getVar('options'), + 'op' => 'edit_ok', + 'bid' => $myblock->getVar('bid'), + 'edit_form' => $myblock->getOptions(), + 'template' => $myblock->getVar('template'), + 'options' => $myblock->getVar('options'), ]; echo '' . constant('CO_' . $moduleDirNameUpper . '_' . 'BADMIN') . ' »» ' . _AM_SYSTEM_BLOCKS_EDITBLOCK . '

'; require_once __DIR__ . '/blockform.php'; - /* @var XoopsThemeForm $form */ + /** @var XoopsThemeForm $form */ $form->display(); // xoops_cp_footer(); require_once __DIR__ . '/admin_footer.php'; @@ -519,13 +519,13 @@ function updateBlock($bid, $btitle, $bside, $bweight, $bvisible, $bcachetime, $b } } $myblock->store(); - $moduleDirName = basename(dirname(__DIR__)); + $moduleDirName = basename(dirname(__DIR__)); $moduleDirNameUpper = mb_strtoupper($moduleDirName); 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)) { + if (in_array(0, $bmodule, true)) { $sql = sprintf('INSERT INTO `%s` (block_id, module_id) VALUES (%u, %d)', $GLOBALS['xoopsDB']->prefix('block_module_link'), $bid, 0); $GLOBALS['xoopsDB']->query($sql); } else { @@ -567,7 +567,7 @@ function updateBlock($bid, $btitle, $bside, $bweight, $bvisible, $bcachetime, $b 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])) { + if (in_array(0, $bmodule[$i], true)) { $sql = sprintf('INSERT INTO `%s` (block_id, module_id) VALUES (%u, %d)', $GLOBALS['xoopsDB']->prefix('block_module_link'), $bid[$i], 0); $GLOBALS['xoopsDB']->query($sql); } else { diff --git a/admin/category.php b/admin/category.php index 2c299266..01ecb5bc 100644 --- a/admin/category.php +++ b/admin/category.php @@ -14,7 +14,6 @@ /** * @copyright The XUUPS Project http://sourceforge.net/projects/xuups/ * @license http://www.fsf.org/copyleft/gpl.html GNU public license - * @package Publisher * @since 1.0 * @author trabis * @author The SmartFactory @@ -32,13 +31,13 @@ // Where do we start ? $startcategory = Request::getInt('startcategory', 0, 'GET'); -$categoryid = Request::getInt('categoryid', null); +$categoryid = Request::getInt('categoryid', null); switch ($op) { case 'del': $categoryObj = $helper->getHandler('Category')->get($categoryid); - $confirm = Request::getString('confirm', '', 'POST'); - $name = Request::getString('name', '', 'POST'); + $confirm = Request::getString('confirm', '', 'POST'); + $name = Request::getString('name', '', 'POST'); if ($confirm) { if (!$helper->getHandler('Category')->delete($categoryObj)) { redirect_header('category.php', 1, _AM_PUBLISHER_DELETE_CAT_ERROR); @@ -71,17 +70,17 @@ // Uploading the image, if any // Retreive the filename to be uploaded - $temp = Request::getArray('image_file', '', 'FILES'); + $temp = Request::getArray('image_file', '', 'FILES'); $image_file = $temp['name']; if ($image_file) { // $filename = Request::getArray('xoops_upload_file', array(), 'POST')[0]; - $temp2 = Request::getArray('xoops_upload_file', [], 'POST'); + $temp2 = Request::getArray('xoops_upload_file', [], 'POST'); $filename = $temp2[0]; if ($filename) { // TODO : implement publisher mimetype management - $max_size = $helper->getConfig('maximum_filesize'); - $max_imgwidth = $helper->getConfig('maximum_image_width'); - $max_imgheight = $helper->getConfig('maximum_image_height'); + $max_size = $helper->getConfig('maximum_filesize'); + $max_imgwidth = $helper->getConfig('maximum_image_width'); + $max_imgheight = $helper->getConfig('maximum_image_height'); $allowed_mimetypes = Publisher\Utility::getAllowedImagesTypes(); if (('' == $temp['tmp_name']) || !is_readable($temp['tmp_name'])) { redirect_header('', 2, _AM_PUBLISHER_FILEUPLOAD_ERROR); @@ -104,8 +103,8 @@ $categoryObj->setVar('weight', Request::getInt('weight', 1, 'POST')); // Groups and permissions - $grpread = Request::getArray('groupsRead', [], 'POST'); - $grpsubmit = Request::getArray('groupsSubmit', [], 'POST'); + $grpread = Request::getArray('groupsRead', [], 'POST'); + $grpsubmit = Request::getArray('groupsSubmit', [], 'POST'); $grpmoderation = Request::getArray('groupsModeration', [], 'POST'); $categoryObj->setVar('name', Request::getString('name', '', 'POST')); @@ -121,10 +120,10 @@ if ($categoryObj->isNew()) { $redirect_msg = _AM_PUBLISHER_CATCREATED; - $redirect_to = 'category.php?op=mod'; + $redirect_to = 'category.php?op=mod'; } else { $redirect_msg = _AM_PUBLISHER_COLMODIFIED; - $redirect_to = 'category.php'; + $redirect_to = 'category.php'; } if (!$categoryObj->store()) { @@ -137,12 +136,12 @@ //Added by fx2024 $parentCat = $categoryObj->categoryid(); - $sizeof = count(Request::getArray('scname', [], 'POST')); + $sizeof = count(Request::getArray('scname', [], 'POST')); for ($i = 0; $i < $sizeof; ++$i) { $temp = Request::getArray('scname', [], 'POST'); if ('' != $temp[$i]) { $categoryObj = $helper->getHandler('Category')->create(); - $temp2 = Request::getArray('scname', [], 'POST'); + $temp2 = Request::getArray('scname', [], 'POST'); $categoryObj->setVar('name', $temp2[$i]); $categoryObj->setVar('parentid', $parentCat); diff --git a/admin/clone.php b/admin/clone.php index 8155e5ef..ee7d5993 100644 --- a/admin/clone.php +++ b/admin/clone.php @@ -14,7 +14,6 @@ /** * @copyright The XUUPS Project http://sourceforge.net/projects/xuups/ * @license http://www.fsf.org/copyleft/gpl.html GNU public license - * @package Publisher * @since 1.0 * @author trabis */ @@ -47,12 +46,12 @@ } $patterns = [ - mb_strtolower(PUBLISHER_DIRNAME) => mb_strtolower($clone), - mb_strtoupper(PUBLISHER_DIRNAME) => mb_strtoupper($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); + $patKeys = array_keys($patterns); $patValues = array_values($patterns); Publisher\Cloner::cloneFileFolder(PUBLISHER_ROOT_PATH); $logocreated = Publisher\Cloner::createLogo(mb_strtolower($clone)); @@ -69,7 +68,7 @@ echo $msg; } else { require_once $GLOBALS['xoops']->path('class/xoopsformloader.php'); - $form = new \XoopsThemeForm(sprintf(_AM_PUBLISHER_CLONE_TITLE, $helper->getModule()->getVar('name', 'E')), 'clone', 'clone.php', 'post', true); + $form = new \XoopsThemeForm(sprintf(_AM_PUBLISHER_CLONE_TITLE, $helper->getModule()->getVar('name', 'E')), 'clone', 'clone.php', 'post', true); $clone = new \XoopsFormText(_AM_PUBLISHER_CLONE_NAME, 'clone', 20, 20, ''); $clone->setDescription(_AM_PUBLISHER_CLONE_NAME_DSC); $form->addElement($clone, true); diff --git a/admin/feedback.php b/admin/feedback.php index d18a1cfe..587e0adc 100644 --- a/admin/feedback.php +++ b/admin/feedback.php @@ -30,8 +30,8 @@ $feedback = new \XoopsModules\Publisher\Common\ModuleFeedback(); // It recovered the value of argument op in URL$ -$op = Request::getString('op', 'list'); -$moduleDirName = $GLOBALS['xoopsModule']->getVar('dirname'); +$op = Request::getString('op', 'list'); +$moduleDirName = $GLOBALS['xoopsModule']->getVar('dirname'); $moduleDirNameUpper = mb_strtoupper($moduleDirName); xoops_loadLanguage('feedback', $moduleDirName); @@ -41,9 +41,9 @@ case 'list': default: $GLOBALS['xoopsTpl']->assign('navigation', $adminObject->displayNavigation('feedback.php')); - $feedback->name = $GLOBALS['xoopsUser']->getVar('name'); + $feedback->name = $GLOBALS['xoopsUser']->getVar('name'); $feedback->email = $GLOBALS['xoopsUser']->getVar('email'); - $feedback->site = XOOPS_URL; + $feedback->site = XOOPS_URL; /** @var \XoopsThemeForm $form */ $form = $feedback->getFormFeedback(); echo $form->display(); @@ -56,20 +56,20 @@ $GLOBALS['xoopsTpl']->assign('navigation', $adminObject->displayNavigation('feedback.php')); - $your_name = Request::getString('your_name', ''); - $your_site = Request::getString('your_site', ''); - $your_mail = Request::getString('your_mail', ''); - $fb_type = Request::getString('fb_type', ''); + $your_name = Request::getString('your_name', ''); + $your_site = Request::getString('your_site', ''); + $your_mail = Request::getString('your_mail', ''); + $fb_type = Request::getString('fb_type', ''); $fb_content = Request::getText('fb_content', ''); $fb_content = str_replace(["\r\n", "\n", "\r"], '
', $fb_content); //clean line break from dhtmltextarea - $title = constant('CO_' . $moduleDirNameUpper . '_' . 'FB_SEND_FOR') . $GLOBALS['xoopsModule']->getVar('dirname'); - $body = constant('CO_' . $moduleDirNameUpper . '_' . 'FB_NAME') . ': ' . $your_name . '
'; - $body .= constant('CO_' . $moduleDirNameUpper . '_' . 'FB_MAIL') . ': ' . $your_mail . '
'; - $body .= constant('CO_' . $moduleDirNameUpper . '_' . 'FB_SITE') . ': ' . $your_site . '
'; - $body .= constant('CO_' . $moduleDirNameUpper . '_' . 'FB_TYPE') . ': ' . $fb_type . '

'; - $body .= constant('CO_' . $moduleDirNameUpper . '_' . 'FB_TYPE_CONTENT') . ':
'; - $body .= $fb_content; + $title = constant('CO_' . $moduleDirNameUpper . '_' . 'FB_SEND_FOR') . $GLOBALS['xoopsModule']->getVar('dirname'); + $body = constant('CO_' . $moduleDirNameUpper . '_' . 'FB_NAME') . ': ' . $your_name . '
'; + $body .= constant('CO_' . $moduleDirNameUpper . '_' . 'FB_MAIL') . ': ' . $your_mail . '
'; + $body .= constant('CO_' . $moduleDirNameUpper . '_' . 'FB_SITE') . ': ' . $your_site . '
'; + $body .= constant('CO_' . $moduleDirNameUpper . '_' . 'FB_TYPE') . ': ' . $fb_type . '

'; + $body .= constant('CO_' . $moduleDirNameUpper . '_' . 'FB_TYPE_CONTENT') . ':
'; + $body .= $fb_content; $xoopsMailer = xoops_getMailer(); $xoopsMailer->useMail(); $xoopsMailer->setToEmails($GLOBALS['xoopsModule']->getInfo('author_mail')); @@ -84,10 +84,10 @@ } // show form with content again - $feedback->name = $your_name; - $feedback->email = $your_mail; - $feedback->site = $your_site; - $feedback->type = $fb_type; + $feedback->name = $your_name; + $feedback->email = $your_mail; + $feedback->site = $your_site; + $feedback->type = $fb_type; $feedback->content = $fb_content; echo '

' . constant('CO_' . $moduleDirNameUpper . '_' . 'FB_SEND_ERROR') . '

diff --git a/admin/file.php b/admin/file.php index 329e6729..02d0718c 100644 --- a/admin/file.php +++ b/admin/file.php @@ -14,7 +14,6 @@ /** * @copyright The XUUPS Project http://sourceforge.net/projects/xuups/ * @license http://www.fsf.org/copyleft/gpl.html GNU public license - * @package Publisher * @since 1.0 * @author trabis * @author The SmartFactory @@ -125,7 +124,7 @@ function publisher_editFile($showmenu = false, $fileid = 0, $itemid = 0) $fileObj = $helper->getHandler('File')->get($fileid); $confirm = Request::getInt('confirm', 0, 'POST'); - $title = Request::getString('title', '', 'POST'); + $title = Request::getString('title', '', 'POST'); if ($confirm) { if (!$helper->getHandler('File')->delete($fileObj)) { diff --git a/admin/import.php b/admin/import.php index 51016110..89f36c4b 100644 --- a/admin/import.php +++ b/admin/import.php @@ -14,7 +14,6 @@ /** * @copyright The XUUPS Project http://sourceforge.net/projects/xuups/ * @license http://www.fsf.org/copyleft/gpl.html GNU public license - * @package Publisher * @since 1.0 * @author trabis * @author The SmartFactory @@ -29,7 +28,7 @@ switch ($op) { case 'importExecute': - $importfile = Request::getString('importfile', 'nonselected', 'POST'); + $importfile = Request::getString('importfile', 'nonselected', 'POST'); $importfile_path = $GLOBALS['xoops']->path('modules/' . $helper->getModule()->dirname() . '/admin/import/' . $importfile . '.php'); require_once $importfile_path; break; @@ -43,7 +42,7 @@ Publisher\Utility::openCollapsableBar('import', 'importicon', _AM_PUBLISHER_IMPORT_TITLE, _AM_PUBLISHER_IMPORT_INFO); xoops_load('XoopsFormLoader'); - /* @var \XoopsModuleHandler $moduleHandler */ + /** @var \XoopsModuleHandler $moduleHandler */ $moduleHandler = xoops_getHandler('module'); // WF-Section @@ -59,67 +58,67 @@ // News $news_version = 0; - $moduleObj = $moduleHandler->getByDirname('news'); + $moduleObj = $moduleHandler->getByDirname('news'); if ($moduleObj) { $from_module_version = round($moduleObj->getVar('version') / 100, 2); if ($from_module_version >= 1.1) { $importfile_select_array['news'] = 'News ' . $from_module_version; - $news_version = $from_module_version; + $news_version = $from_module_version; } } // xNews $xnews_version = 0; - $moduleObj = $moduleHandler->getByDirname('xnews'); + $moduleObj = $moduleHandler->getByDirname('xnews'); if ($moduleObj) { $from_module_version = round($moduleObj->getVar('version') / 100, 2); if ($from_module_version >= 1.1) { $importfile_select_array['xnews'] = 'xNews ' . $from_module_version; - $xnews_version = $from_module_version; + $xnews_version = $from_module_version; } } // AMS $ams_version = 0; - $moduleObj = $moduleHandler->getByDirname('AMS'); + $moduleObj = $moduleHandler->getByDirname('AMS'); if ($moduleObj) { $from_module_version = round($moduleObj->getVar('version') / 100, 2); if ($from_module_version >= 1.1) { $importfile_select_array['ams'] = 'AMS ' . $from_module_version; - $ams_version = $from_module_version; + $ams_version = $from_module_version; } } // Smartsection $smartsection_version = 0; - $moduleObj = $moduleHandler->getByDirname('smartsection'); + $moduleObj = $moduleHandler->getByDirname('smartsection'); if ($moduleObj) { $from_module_version = round($moduleObj->getVar('version') / 100, 2); if ($from_module_version >= 1.1) { $importfile_select_array['smartsection'] = 'Smartsection ' . $from_module_version; - $smartsection_version = $from_module_version; + $smartsection_version = $from_module_version; } } // C-Jay Content $cjaycontent_version = 0; - $moduleObj = $moduleHandler->getByDirname('cjaycontent'); + $moduleObj = $moduleHandler->getByDirname('cjaycontent'); if ($moduleObj) { $from_module_version = round($moduleObj->getVar('version') / 100, 2); if ($from_module_version >= 1.1) { $importfile_select_array['cjaycontent'] = 'C-Jay Content ' . $from_module_version; - $cjaycontent_version = $from_module_version; + $cjaycontent_version = $from_module_version; } } // FmContent $fmcontent_version = 0; - $moduleObj = $moduleHandler->getByDirname('fmcontent'); + $moduleObj = $moduleHandler->getByDirname('fmcontent'); if ($moduleObj) { $from_module_version = round($moduleObj->getVar('version') / 100, 2); if ($from_module_version >= 1.1) { $importfile_select_array['fmcontent'] = 'FmContent ' . $from_module_version; - $fmcontent_version = $from_module_version; + $fmcontent_version = $from_module_version; } } @@ -148,7 +147,7 @@ // Buttons $buttonTray = new \XoopsFormElementTray('', ''); - $hidden = new \XoopsFormHidden('op', 'importExecute'); + $hidden = new \XoopsFormHidden('op', 'importExecute'); $buttonTray->addElement($hidden); $butt_import = new \XoopsFormButton('', '', _AM_PUBLISHER_IMPORT, 'submit'); diff --git a/admin/import/ams.php b/admin/import/ams.php index 0cfb57ce..89bb830e 100644 --- a/admin/import/ams.php +++ b/admin/import/ams.php @@ -14,7 +14,6 @@ /** * @copyright The XUUPS Project http://sourceforge.net/projects/xuups/ * @license http://www.fsf.org/copyleft/gpl.html GNU public license - * @package Publisher * @since 1.0 * @author trabis * @author The SmartFactory @@ -67,7 +66,7 @@ // } $imageCategoryHandler = xoops_getHandler('imagecategory'); - $imagecategory = $imageCategoryHandler->create(); + $imagecategory = $imageCategoryHandler->create(); // $imagecategory->setVar('imgcat_name', $imgcat_name); $imagecategory->setVar('imgcat_name', PUBLISHER_DIRNAME); //$imgcat_name); $imagecategory->setVar('imgcat_maxsize', $GLOBALS['xoopsModuleConfig']['maximum_filesize']); //$imgcat_maxsize); @@ -81,16 +80,16 @@ try { $imageCategoryHandler->insert($imagecategory); - } catch (\Exception $e) { + } catch (\Throwable $e) { echo 'Caught exception: could not insert Image Category' . $e->getMessage() . 'n'; } - $newid = $imagecategory->getVar('imgcat_id'); + $newid = $imagecategory->getVar('imgcat_id'); $imagecategorypermHandler = xoops_getHandler('groupperm'); if (!isset($readgroup)) { $readgroup = []; } - if (!in_array(XOOPS_GROUP_ADMIN, $readgroup)) { + if (!in_array(XOOPS_GROUP_ADMIN, $readgroup, true)) { $readgroup[] = XOOPS_GROUP_ADMIN; } foreach ($readgroup as $rgroup) { @@ -106,7 +105,7 @@ if (!isset($writegroup)) { $writegroup = []; } - if (!in_array(XOOPS_GROUP_ADMIN, $writegroup)) { + if (!in_array(XOOPS_GROUP_ADMIN, $writegroup, true)) { $writegroup[] = XOOPS_GROUP_ADMIN; } foreach ($writegroup as $wgroup) { @@ -125,11 +124,11 @@ // Categories to be imported $sql = 'SELECT cat.topic_id, cat.topic_pid, cat.topic_title, COUNT(art.storyid) FROM ' . $GLOBALS['xoopsDB']->prefix('ams_topics') . ' AS cat INNER JOIN ' . $GLOBALS['xoopsDB']->prefix('nw_stories') . ' AS art ON cat.topic_id=art.topicid GROUP BY art.topicid'; - $result = $GLOBALS['xoopsDB']->query($sql); + $result = $GLOBALS['xoopsDB']->query($sql); $cat_cbox_options = []; while (list($cid, $pid, $cat_title, $art_count) = $GLOBALS['xoopsDB']->fetchRow($result)) { - $cat_title = $myts->displayTarea($cat_title); + $cat_title = $myts->displayTarea($cat_title); $cat_cbox_options[$cid] = "$cat_title ($art_count)"; } @@ -165,15 +164,15 @@ //publisher_adminMenu(-1, _AM_PUBLISHER_IMPORT); // require_once dirname(dirname(__DIR__)) . '/include/common.php'; Publisher\Utility::openCollapsableBar('amsimportgo', 'amsimportgoicon', sprintf(_AM_PUBLISHER_IMPORT_FROM, $importFromModuleName), _AM_PUBLISHER_IMPORT_RESULT); - /* @var XoopsModuleHandler $moduleHandler */ + /** @var XoopsModuleHandler $moduleHandler */ $moduleHandler = xoops_getHandler('module'); - $moduleObj = $moduleHandler->getByDirname('ams'); + $moduleObj = $moduleHandler->getByDirname('ams'); $ams_module_id = $moduleObj->getVar('mid'); - /* @var XoopsGroupPermHandler $grouppermHandler */ + /** @var XoopsGroupPermHandler $grouppermHandler */ $grouppermHandler = xoops_getHandler('groupperm'); - $cnt_imported_cat = 0; + $cnt_imported_cat = 0; $cnt_imported_articles = 0; $parentId = Request::getInt('parent_category', 0, 'POST'); @@ -182,7 +181,7 @@ $resultCat = $GLOBALS['xoopsDB']->query($sql); - $newCatArray = []; + $newCatArray = []; $newArticleArray = []; /** @var \XoopsImagecategoryHandler $imageCategoryHandler */ @@ -194,7 +193,7 @@ // $criteria->add(new \Criteria('imagecategory', $catObj->getVar('cid'), '=')); // $childCount = (int)($mylinksCatHandler->getCount($criteria)); - $criteria = new \Criteria('imgcat_name', PUBLISHER_DIRNAME); + $criteria = new \Criteria('imgcat_name', PUBLISHER_DIRNAME); $imageCategoryId = $imageCategoryHandler->getObjects($criteria); // $criteria = new \CriteriaCompo(); @@ -216,10 +215,10 @@ $oldToNew = []; while (false !== ($arrCat = $GLOBALS['xoopsDB']->fetchArray($resultCat))) { - $newCat = []; - $newCat['oldid'] = $arrCat['topic_id']; + $newCat = []; + $newCat['oldid'] = $arrCat['topic_id']; $newCat['oldpid'] = $arrCat['topic_pid']; - /* @var Publisher\Category $categoryObj */ + /** @var Publisher\Category $categoryObj */ $categoryObj = $helper->getHandler('Category')->create(); $categoryObj->setVar('parentid', $arrCat['topic_pid']); @@ -290,7 +289,7 @@ echo sprintf(_AM_PUBLISHER_IMPORT_CATEGORY_SUCCESS, $categoryObj->name()) . '
'; - $sql = 'SELECT * FROM ' . $GLOBALS['xoopsDB']->prefix('ams_article') . ' WHERE topicid=' . $arrCat['topic_id']; + $sql = 'SELECT * FROM ' . $GLOBALS['xoopsDB']->prefix('ams_article') . ' WHERE topicid=' . $arrCat['topic_id']; $resultArticles = $GLOBALS['xoopsDB']->query($sql); while (false !== ($arrArticle = $GLOBALS['xoopsDB']->fetchArray($resultArticles))) { // insert article @@ -319,7 +318,7 @@ $imgHandler = xoops_getHandler('image'); // $criteria = new \Criteria('image_name', $arrArticle['picture']); - $imageId = $imgHandler->getObjects($criteria); + $imageId = $imgHandler->getObjects($criteria); $newImageId = $imageId[0]->vars['image_id']['value']; $itemObj->setVar('image', $newImageId); $itemObj->setVar('images', $newImageId); @@ -351,8 +350,8 @@ } //-------------------------------------------- // Linkes files - $sql = 'SELECT * FROM ' . $GLOBALS['xoopsDB']->prefix('ams_article_files') . ' WHERE storyid=' . $arrArticle['storyid']; - $resultFiles = $GLOBALS['xoopsDB']->query($sql); + $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']); @@ -421,7 +420,7 @@ /** @var \XoopsCommentHandler $commentHandler */ $commentHandler = xoops_getHandler('comment'); - $criteria = new \CriteriaCompo(); + $criteria = new \CriteriaCompo(); $criteria->add(new \Criteria('com_modid', $ams_module_id)); $comments = $commentHandler->getObjects($criteria); /** @var \XoopsComment $comment */ diff --git a/admin/import/cjaycontent.php b/admin/import/cjaycontent.php index a4dee646..fad72696 100644 --- a/admin/import/cjaycontent.php +++ b/admin/import/cjaycontent.php @@ -14,7 +14,6 @@ /** * @copyright The XUUPS Project http://sourceforge.net/projects/xuups/ * @license http://www.fsf.org/copyleft/gpl.html GNU public license - * @package Publisher * @since 1.0 * @author trabis * @author The SmartFactory @@ -91,11 +90,11 @@ //publisher_adminMenu(-1, _AM_PUBLISHER_IMPORT); // require_once dirname(dirname(__DIR__)) . '/include/common.php'; Publisher\Utility::openCollapsableBar('cjaycontentimportgo', 'cjaycontentimportgoicon', sprintf(_AM_PUBLISHER_IMPORT_FROM, $importFromModuleName), _AM_PUBLISHER_IMPORT_RESULT); - /* @var XoopsModuleHandler $moduleHandler */ - $moduleHandler = xoops_getHandler('module'); - $moduleObj = $moduleHandler->getByDirname('cjaycontent'); + /** @var XoopsModuleHandler $moduleHandler */ + $moduleHandler = xoops_getHandler('module'); + $moduleObj = $moduleHandler->getByDirname('cjaycontent'); $cjaycontent_module_id = $moduleObj->getVar('mid'); - /* @var XoopsGroupPermHandler $grouppermHandler */ + /** @var XoopsGroupPermHandler $grouppermHandler */ $grouppermHandler = xoops_getHandler('groupperm'); $cnt_imported_articles = 0; @@ -104,7 +103,7 @@ $oldToNew = []; - $sql = 'SELECT * FROM ' . $GLOBALS['xoopsDB']->prefix('cjaycontent'); + $sql = 'SELECT * FROM ' . $GLOBALS['xoopsDB']->prefix('cjaycontent'); $resultArticles = $GLOBALS['xoopsDB']->query($sql); while (false !== ($arrArticle = $GLOBALS['xoopsDB']->fetchArray($resultArticles))) { // insert article @@ -164,7 +163,7 @@ $publisher_module_id = $helper->getModule()->mid(); /** @var \XoopsCommentHandler $commentHandler */ $commentHandler = xoops_getHandler('comment'); - $criteria = new \CriteriaCompo(); + $criteria = new \CriteriaCompo(); $criteria->add(new \Criteria('com_modid', $cjaycontent_module_id)); /** @var \XoopsComment $comment */ $comments = $commentHandler->getObjects($criteria); diff --git a/admin/import/fmcontent.php b/admin/import/fmcontent.php index 40f8547e..ffda3d67 100644 --- a/admin/import/fmcontent.php +++ b/admin/import/fmcontent.php @@ -14,7 +14,6 @@ /** * @copyright The XUUPS Project http://sourceforge.net/projects/xuups/ * @license http://www.fsf.org/copyleft/gpl.html GNU public license - * @package Publisher * @since 1.02 Beta 4 * @author trabis * @author The SmartFactory @@ -41,20 +40,20 @@ Publisher\Utility::cpHeader(); //publisher_adminMenu(-1, _AM_PUBLISHER_IMPORT); Publisher\Utility::openCollapsableBar('fmimport', 'fmimporticon', sprintf(_AM_PUBLISHER_IMPORT_FROM, $importFromModuleName), _AM_PUBLISHER_IMPORT_INFO); - /* @var XoopsModuleHandler $moduleHandler */ + /** @var XoopsModuleHandler $moduleHandler */ $moduleHandler = xoops_getHandler('module'); - $moduleObj = $moduleHandler->getByDirname('fmcontent'); - $fm_module_id = $moduleObj->getVar('mid'); + $moduleObj = $moduleHandler->getByDirname('fmcontent'); + $fm_module_id = $moduleObj->getVar('mid'); /** @var \XoopsPersistableObjectHandler $fmTopicHdlr */ - $fmTopicHdlr = xoops_getModuleHandler('topic', 'fmcontent'); + $fmTopicHdlr = xoops_getModuleHandler('topic', 'fmcontent'); $fmTopicCount = $fmTopicHdlr->getCount(new \Criteria('topic_modid', $fm_module_id)); if (empty($fmTopicCount)) { echo "" . _AM_PUBLISHER_IMPORT_NO_CATEGORY . ''; } else { require_once $GLOBALS['xoops']->path('www/class/xoopstree.php'); - $fmContentHdlr = xoops_getModuleHandler('page', 'fmcontent'); + $fmContentHdlr = xoops_getModuleHandler('page', 'fmcontent'); $fmContentCount = $fmContentHdlr->getCount(new \Criteria('content_modid', $fm_module_id)); if (empty($fmContentCount)) { @@ -71,11 +70,11 @@ . $GLOBALS['xoopsDB']->prefix('fmcontent_content') . " AS art ON ((cat.topic_id=art.content_topic) AND (cat.topic_modid=art.content_modid)) WHERE cat.topic_modid={$fm_module_id} GROUP BY art.content_topic"; - $result = $GLOBALS['xoopsDB']->query($sql); + $result = $GLOBALS['xoopsDB']->query($sql); $cat_cbox_options = []; while (list($cid, $pid, $cat_title, $art_count) = $GLOBALS['xoopsDB']->fetchRow($result)) { - $cat_title = $myts->displayTarea($cat_title); + $cat_title = $myts->displayTarea($cat_title); $cat_cbox_options[$cid] = "{$cat_title} ($art_count)"; } // now get articles in the top level category (content_topic=0) @@ -97,14 +96,14 @@ // Publisher parent category xoops_load('tree'); - $categoryHdlr = $helper->getHandler('Category'); - $catObjs = $categoryHdlr->getAll(); - $myObjTree = new \XoopsObjectTree($catObjs, 'categoryid', 'parentid'); + $categoryHdlr = $helper->getHandler('Category'); + $catObjs = $categoryHdlr->getAll(); + $myObjTree = new \XoopsObjectTree($catObjs, 'categoryid', 'parentid'); $moduleDirName = basename(dirname(__DIR__)); - $module = \XoopsModule::getByDirname($moduleDirName); + $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); } @@ -140,12 +139,12 @@ Publisher\Utility::openCollapsableBar('fmimportgo', 'fmimportgoicon', sprintf(_AM_PUBLISHER_IMPORT_FROM, $importFromModuleName), _AM_PUBLISHER_IMPORT_RESULT); $moduleHandler = xoops_getHandler('module'); - $moduleObj = $moduleHandler->getByDirname('fmcontent'); - $fm_module_id = $moduleObj->getVar('mid'); - /* @var XoopsGroupPermHandler $grouppermHandler */ + $moduleObj = $moduleHandler->getByDirname('fmcontent'); + $fm_module_id = $moduleObj->getVar('mid'); + /** @var XoopsGroupPermHandler $grouppermHandler */ $grouppermHandler = xoops_getHandler('groupperm'); - $cnt_imported_cat = 0; + $cnt_imported_cat = 0; $cnt_imported_articles = 0; $parentId = Request::getInt('parent_category', 0, 'POST'); @@ -162,17 +161,17 @@ ++$cnt_imported_cat; //count category if there was content to import // create Publsher category to hold FmContent Content items with no Topic (content_topic=0) - /* @var Publisher\Category $categoryObj */ + /** @var Publisher\Category $categoryObj */ $categoryObj = $helper->getHandler('Category')->create(); $categoryObj->setVars( [ - 'parentid' => $parentId, - 'name' => _AM_PUBLISHER_IMPORT_FMCONTENT_NAME, + 'parentid' => $parentId, + 'name' => _AM_PUBLISHER_IMPORT_FMCONTENT_NAME, 'description' => _AM_PUBLISHER_IMPORT_FMCONTENT_TLT, - 'image' => '', - 'total' => 0, - 'weight' => 1, - 'created' => time(), + 'image' => '', + 'total' => 0, + 'weight' => 1, + 'created' => time(), 'moderator', $GLOBALS['xoopsUser']->getVar('uid'), ] @@ -186,24 +185,24 @@ $itemObj = $helper->getHandler('Item')->create(); $itemObj->setVars( [ - 'categoryid' => $categoryObj->categoryid(), - 'title' => $thisFmContentObj->getVar('content_title'), - 'uid' => $thisFmContentObj->getVar('content_uid'), - 'summary' => $thisFmContentObj->getVar('content_short'), - 'body' => $thisFmContentObj->getVar('content_text'), - 'datesub' => $thisFmContentObj->getVar('content_create'), - 'dohtml' => $thisFmContentObj->getVar('dohtml'), - 'dosmiley' => $thisFmContentObj->getVar('dosmiley'), - 'doxcode' => $thisFmContentObj->getVar('doxcode'), - 'doimage' => $thisFmContentObj->getVar('doimage'), - 'dobr' => $thisFmContentObj->getVar('dobr'), - 'weight' => $thisFmContentObj->getVar('content_order'), - 'status' => $thisFmContentObj->getVar('content_status') ? Constants::PUBLISHER_STATUS_PUBLISHED : Constants::PUBLISHER_STATUS_OFFLINE, - 'counter' => $thisFmContentObj->getVar('content_hits'), - 'rating' => 0, - 'votes' => 0, - 'comments' => $thisFmContentObj->getVar('content_comments'), - 'meta_keywords' => $thisFmContentObj->getVar('content_words'), + 'categoryid' => $categoryObj->categoryid(), + 'title' => $thisFmContentObj->getVar('content_title'), + 'uid' => $thisFmContentObj->getVar('content_uid'), + 'summary' => $thisFmContentObj->getVar('content_short'), + 'body' => $thisFmContentObj->getVar('content_text'), + 'datesub' => $thisFmContentObj->getVar('content_create'), + 'dohtml' => $thisFmContentObj->getVar('dohtml'), + 'dosmiley' => $thisFmContentObj->getVar('dosmiley'), + 'doxcode' => $thisFmContentObj->getVar('doxcode'), + 'doimage' => $thisFmContentObj->getVar('doimage'), + 'dobr' => $thisFmContentObj->getVar('dobr'), + 'weight' => $thisFmContentObj->getVar('content_order'), + 'status' => $thisFmContentObj->getVar('content_status') ? Constants::PUBLISHER_STATUS_PUBLISHED : Constants::PUBLISHER_STATUS_OFFLINE, + 'counter' => $thisFmContentObj->getVar('content_hits'), + 'rating' => 0, + 'votes' => 0, + 'comments' => $thisFmContentObj->getVar('content_comments'), + 'meta_keywords' => $thisFmContentObj->getVar('content_words'), 'meta_description' => $thisFmContentObj->getVar('content_desc'), ] ); @@ -212,7 +211,7 @@ $itemObj->setVars( [ 'images' => 1, - 'image' => $thisFmContentObj->getVar('content_img'), + 'image' => $thisFmContentObj->getVar('content_img'), ] ); } @@ -237,16 +236,16 @@ } // Process all "normal" Topics (categories) from FmContent - $newCatArray = []; + $newCatArray = []; $newArticleArray = []; - $oldToNew = []; + $oldToNew = []; $fmTopicObjs = $fmTopicHdlr->getAll(new \Criteria('topic_modid', $fm_module_id)); // first create FmContent Topics as Publisher Categories foreach ($fmTopicObjs as $thisFmTopicObj) { $catIds = [ - 'oldid' => $thisFmTopicObj->getVar('topic_id'), + 'oldid' => $thisFmTopicObj->getVar('topic_id'), 'oldpid' => $thisFmTopicObj->getVar('topic_pid'), ]; @@ -254,9 +253,9 @@ $categoryObj->setVars( [ - 'parentid' => $thisFmTopicObj->getVar('topic_pid'), - 'weight' => $thisFmTopicObj->getVar('topic_weight'), - 'name' => $thisFmTopicObj->getVar('topic_title'), + 'parentid' => $thisFmTopicObj->getVar('topic_pid'), + 'weight' => $thisFmTopicObj->getVar('topic_weight'), + 'name' => $thisFmTopicObj->getVar('topic_title'), 'description' => $thisFmTopicObj->getVar('topic_desc'), ] ); @@ -289,24 +288,24 @@ $itemObj = $helper->getHandler('Item')->create(); $itemObj->setVars( [ - 'categoryid' => $catIds['newid'], - 'title' => $thisFmContentObj->getVar('content_title'), - 'uid' => $thisFmContentObj->getVar('content_uid'), - 'summary' => $thisFmContentObj->getVar('content_short'), - 'body' => $thisFmContentObj->getVar('content_text'), - 'counter' => $thisFmContentObj->getVar('content_hits'), - 'datesub' => $thisFmContentObj->getVar('content_create'), - 'dohtml' => $thisFmContentObj->getVar('dohtml'), - 'dosmiley' => $thisFmContentObj->getVar('dosmiley'), - 'doxcode' => $thisFmContentObj->getVar('doxcode'), - 'doimage' => $thisFmContentObj->getVar('doimage'), - 'dobr' => $thisFmContentObj->getVar('dobr'), - 'weight' => $thisFmContentObj->getVar('content_order'), - 'status' => $thisFmContentObj->getVar('content_status') ? Constants::PUBLISHER_STATUS_PUBLISHED : Constants::PUBLISHER_STATUS_OFFLINE, - 'rating' => 0, - 'votes' => 0, - 'comments' => $thisFmContentObj->getVar('content_comments'), - 'meta_keywords' => $thisFmContentObj->getVar('content_words'), + 'categoryid' => $catIds['newid'], + 'title' => $thisFmContentObj->getVar('content_title'), + 'uid' => $thisFmContentObj->getVar('content_uid'), + 'summary' => $thisFmContentObj->getVar('content_short'), + 'body' => $thisFmContentObj->getVar('content_text'), + 'counter' => $thisFmContentObj->getVar('content_hits'), + 'datesub' => $thisFmContentObj->getVar('content_create'), + 'dohtml' => $thisFmContentObj->getVar('dohtml'), + 'dosmiley' => $thisFmContentObj->getVar('dosmiley'), + 'doxcode' => $thisFmContentObj->getVar('doxcode'), + 'doimage' => $thisFmContentObj->getVar('doimage'), + 'dobr' => $thisFmContentObj->getVar('dobr'), + 'weight' => $thisFmContentObj->getVar('content_order'), + 'status' => $thisFmContentObj->getVar('content_status') ? Constants::PUBLISHER_STATUS_PUBLISHED : Constants::PUBLISHER_STATUS_OFFLINE, + 'rating' => 0, + 'votes' => 0, + 'comments' => $thisFmContentObj->getVar('content_comments'), + 'meta_keywords' => $thisFmContentObj->getVar('content_words'), 'meta_description' => $thisFmContentObj->getVar('content_desc'), ] ); @@ -354,7 +353,7 @@ $publisher_module_id = $helper->getModule()->mid(); /** @var \XoopsCommentHandler $commentHandler */ $commentHandler = xoops_getHandler('comment'); - $criteria = new \CriteriaCompo(); + $criteria = new \CriteriaCompo(); $criteria->add(new \Criteria('com_modid', $fm_module_id)); /** @var \XoopsComment $comment */ $comments = $commentHandler->getObjects($criteria); diff --git a/admin/import/news.php b/admin/import/news.php index 76936b5e..9376a9af 100644 --- a/admin/import/news.php +++ b/admin/import/news.php @@ -14,7 +14,6 @@ /** * @copyright The XUUPS Project http://sourceforge.net/projects/xuups/ * @license http://www.fsf.org/copyleft/gpl.html GNU public license - * @package Publisher * @since 1.0 * @author trabis * @author The SmartFactory @@ -62,11 +61,11 @@ // Categories to be imported $sql = 'SELECT cat.topic_id, cat.topic_pid, cat.topic_title, COUNT(art.storyid) FROM ' . $GLOBALS['xoopsDB']->prefix('news_topics') . ' AS cat INNER JOIN ' . $GLOBALS['xoopsDB']->prefix('news_stories') . ' AS art ON cat.topic_id=art.topicid GROUP BY art.topicid'; - $result = $GLOBALS['xoopsDB']->query($sql); + $result = $GLOBALS['xoopsDB']->query($sql); $cat_cbox_options = []; while (list($cid, $pid, $cat_title, $art_count) = $GLOBALS['xoopsDB']->fetchRow($result)) { - $cat_title = $myts->displayTarea($cat_title); + $cat_title = $myts->displayTarea($cat_title); $cat_cbox_options[$cid] = "$cat_title ($art_count)"; } @@ -101,14 +100,14 @@ Publisher\Utility::cpHeader(); //publisher_adminMenu(-1, _AM_PUBLISHER_IMPORT); Publisher\Utility::openCollapsableBar('newsimportgo', 'newsimportgoicon', sprintf(_AM_PUBLISHER_IMPORT_FROM, $importFromModuleName), _AM_PUBLISHER_IMPORT_RESULT); - /* @var XoopsModuleHandler $moduleHandler */ - $moduleHandler = xoops_getHandler('module'); - $moduleObj = $moduleHandler->getByDirname('news'); + /** @var XoopsModuleHandler $moduleHandler */ + $moduleHandler = xoops_getHandler('module'); + $moduleObj = $moduleHandler->getByDirname('news'); $news_module_id = $moduleObj->getVar('mid'); - /* @var XoopsGroupPermHandler $grouppermHandler */ + /** @var XoopsGroupPermHandler $grouppermHandler */ $grouppermHandler = xoops_getHandler('groupperm'); - $cnt_imported_cat = 0; + $cnt_imported_cat = 0; $cnt_imported_articles = 0; $parentId = Request::getInt('parent_category', 0, 'POST'); @@ -117,15 +116,15 @@ $resultCat = $GLOBALS['xoopsDB']->query($sql); - $newCatArray = []; + $newCatArray = []; $newArticleArray = []; $oldToNew = []; while (false !== ($arrCat = $GLOBALS['xoopsDB']->fetchArray($resultCat))) { - $newCat = []; - $newCat['oldid'] = $arrCat['topic_id']; + $newCat = []; + $newCat['oldid'] = $arrCat['topic_id']; $newCat['oldpid'] = $arrCat['topic_pid']; - /* @var Publisher\Category $categoryObj */ + /** @var Publisher\Category $categoryObj */ $categoryObj = $helper->getHandler('Category')->create(); $categoryObj->setVar('parentid', $arrCat['topic_pid']); @@ -150,7 +149,7 @@ echo sprintf(_AM_PUBLISHER_IMPORT_CATEGORY_SUCCESS, $categoryObj->name()) . '
'; - $sql = 'SELECT * FROM ' . $GLOBALS['xoopsDB']->prefix('news_stories') . ' WHERE topicid=' . $arrCat['topic_id']; + $sql = 'SELECT * FROM ' . $GLOBALS['xoopsDB']->prefix('news_stories') . ' WHERE topicid=' . $arrCat['topic_id']; $resultArticles = $GLOBALS['xoopsDB']->query($sql); while (false !== ($arrArticle = $GLOBALS['xoopsDB']->fetchArray($resultArticles))) { // insert article @@ -260,7 +259,7 @@ $publisher_module_id = $helper->getModule()->mid(); /** @var \XoopsCommentHandler $commentHandler */ $commentHandler = xoops_getHandler('comment'); - $criteria = new \CriteriaCompo(); + $criteria = new \CriteriaCompo(); $criteria->add(new \Criteria('com_modid', $news_module_id)); /** @var \XoopsComment $comment */ $comments = $commentHandler->getObjects($criteria); diff --git a/admin/import/smartsection.php b/admin/import/smartsection.php index 1b9a37e0..a9369994 100644 --- a/admin/import/smartsection.php +++ b/admin/import/smartsection.php @@ -14,7 +14,6 @@ /** * @copyright The XUUPS Project http://sourceforge.net/projects/xuups/ * @license http://www.fsf.org/copyleft/gpl.html GNU public license - * @package Publisher * @since 1.0 * @author trabis * @author The SmartFactory @@ -61,11 +60,11 @@ // Categories to be imported $sql = 'SELECT cat.categoryid, cat.parentid, cat.name, COUNT(art.itemid) FROM ' . $GLOBALS['xoopsDB']->prefix('smartsection_categories') . ' AS cat INNER JOIN ' . $GLOBALS['xoopsDB']->prefix('smartsection_items') . ' AS art ON cat.categoryid=art.categoryid GROUP BY art.categoryid'; - $result = $GLOBALS['xoopsDB']->query($sql); + $result = $GLOBALS['xoopsDB']->query($sql); $cat_cbox_options = []; while (list($cid, $pid, $cat_title, $art_count) = $GLOBALS['xoopsDB']->fetchRow($result)) { - $cat_title = $myts->displayTarea($cat_title); + $cat_title = $myts->displayTarea($cat_title); $cat_cbox_options[$cid] = "$cat_title ($art_count)"; } @@ -100,14 +99,14 @@ Publisher\Utility::cpHeader(); //publisher_adminMenu(-1, _AM_PUBLISHER_IMPORT); Publisher\Utility::openCollapsableBar('newsimportgo', 'newsimportgoicon', sprintf(_AM_PUBLISHER_IMPORT_FROM, $importFromModuleName), _AM_PUBLISHER_IMPORT_RESULT); - /* @var XoopsModuleHandler $moduleHandler */ - $moduleHandler = xoops_getHandler('module'); - $moduleObj = $moduleHandler->getByDirname('smartsection'); + /** @var XoopsModuleHandler $moduleHandler */ + $moduleHandler = xoops_getHandler('module'); + $moduleObj = $moduleHandler->getByDirname('smartsection'); $smartsection_module_id = $moduleObj->getVar('mid'); - /* @var XoopsGroupPermHandler $grouppermHandler */ + /** @var XoopsGroupPermHandler $grouppermHandler */ $grouppermHandler = xoops_getHandler('groupperm'); - $cnt_imported_cat = 0; + $cnt_imported_cat = 0; $cnt_imported_articles = 0; $parentId = Request::getInt('parent_category', 0, 'POST'); @@ -116,15 +115,15 @@ $resultCat = $GLOBALS['xoopsDB']->query($sql); - $newCatArray = []; + $newCatArray = []; $newArticleArray = []; $oldToNew = []; while (false !== ($arrCat = $GLOBALS['xoopsDB']->fetchArray($resultCat))) { - $newCat = []; - $newCat['oldid'] = $arrCat['categoryid']; + $newCat = []; + $newCat['oldid'] = $arrCat['categoryid']; $newCat['oldpid'] = $arrCat['parentid']; - /* @var Publisher\Category $categoryObj */ + /** @var Publisher\Category $categoryObj */ $categoryObj = $helper->getHandler('Category')->create(); $categoryObj->setVars($arrCat); @@ -145,7 +144,7 @@ echo sprintf(_AM_PUBLISHER_IMPORT_CATEGORY_SUCCESS, $categoryObj->name()) . ""; - $sql = 'SELECT * FROM ' . $GLOBALS['xoopsDB']->prefix('smartsection_items') . ' WHERE categoryid=' . $arrCat['categoryid']; + $sql = 'SELECT * FROM ' . $GLOBALS['xoopsDB']->prefix('smartsection_items') . ' WHERE categoryid=' . $arrCat['categoryid']; $resultArticles = $GLOBALS['xoopsDB']->query($sql); while (false !== ($arrArticle = $GLOBALS['xoopsDB']->fetchArray($resultArticles))) { @@ -178,8 +177,8 @@ continue; } // Linkes files - $sql = 'SELECT * FROM ' . $GLOBALS['xoopsDB']->prefix('smartsection_files') . ' WHERE itemid=' . $arrArticle['itemid']; - $resultFiles = $GLOBALS['xoopsDB']->query($sql); + $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']); @@ -234,7 +233,7 @@ $publisher_module_id = $helper->getModule()->mid(); /** @var \XoopsCommentHandler $commentHandler */ $commentHandler = xoops_getHandler('comment'); - $criteria = new \CriteriaCompo(); + $criteria = new \CriteriaCompo(); $criteria->add(new \Criteria('com_modid', $smartsection_module_id)); /** @var \XoopsComment $comment */ $comments = $commentHandler->getObjects($criteria); diff --git a/admin/import/wfsection.php b/admin/import/wfsection.php index 69b55f67..c23faed1 100644 --- a/admin/import/wfsection.php +++ b/admin/import/wfsection.php @@ -14,7 +14,6 @@ /** * @copyright The XUUPS Project http://sourceforge.net/projects/xuups/ * @license http://www.fsf.org/copyleft/gpl.html GNU public license - * @package Publisher * @since 1.0 * @author trabis * @author The SmartFactory @@ -60,12 +59,12 @@ $form = new \XoopsThemeForm(_AM_PUBLISHER_IMPORT_SETTINGS, 'import_form', PUBLISHER_ADMIN_URL . "/import/$scriptname"); // Categories to be imported - $sql = 'SELECT cat.id, cat.pid, cat.title, COUNT(art.articleid) FROM ' . $GLOBALS['xoopsDB']->prefix('wfs_category') . ' AS cat INNER JOIN ' . $GLOBALS['xoopsDB']->prefix('wfs_article') . ' AS art ON cat.id=art.categoryid GROUP BY art.categoryid'; - $result = $GLOBALS['xoopsDB']->query($sql); - $cat_cbox_values = []; + $sql = 'SELECT cat.id, cat.pid, cat.title, COUNT(art.articleid) FROM ' . $GLOBALS['xoopsDB']->prefix('wfs_category') . ' AS cat INNER JOIN ' . $GLOBALS['xoopsDB']->prefix('wfs_article') . ' AS art ON cat.id=art.categoryid GROUP BY art.categoryid'; + $result = $GLOBALS['xoopsDB']->query($sql); + $cat_cbox_values = []; $cat_cbox_options = []; while (list($cid, $pid, $cat_title, $art_count) = $GLOBALS['xoopsDB']->fetchRow($result)) { - $cat_title = $myts->displayTarea($cat_title); + $cat_title = $myts->displayTarea($cat_title); $cat_cbox_options[$cid] = "$cat_title ($art_count)"; } $cat_label = new \XoopsFormLabel(_AM_PUBLISHER_IMPORT_CATEGORIES, implode('
', $cat_cbox_options)); @@ -100,7 +99,7 @@ //publisher_adminMenu(-1, _AM_PUBLISHER_IMPORT); Publisher\Utility::openCollapsableBar('wfsectionimportgo', 'wfsectionimportgoicon', sprintf(_AM_PUBLISHER_IMPORT_FROM, $importFromModuleName), _AM_PUBLISHER_IMPORT_RESULT); - $cnt_imported_cat = 0; + $cnt_imported_cat = 0; $cnt_imported_articles = 0; $parentId = Request::getInt('parent_category', 0, 'POST'); @@ -116,12 +115,12 @@ $newCatArray = []; while (false !== ($arrCat = $GLOBALS['xoopsDB']->fetchArray($resultCat))) { - /* @var Publisher\Category $categoryObj */ + /** @var Publisher\Category $categoryObj */ $categoryObj = $helper->getHandler('Category')->create(); $newCat = []; - $newCat['oldid'] = $arrCat['id']; + $newCat['oldid'] = $arrCat['id']; $newCat['oldpid'] = $arrCat['pid']; $categoryObj->setVar('parentid', $arrCat['pid']); @@ -155,7 +154,7 @@ echo sprintf(_AM_PUBLISHER_IMPORT_CATEGORY_SUCCESS, $categoryObj->name()) . ''; - $sql = 'SELECT * FROM ' . $GLOBALS['xoopsDB']->prefix('wfs_article') . ' WHERE categoryid=' . $arrCat['id'] . ' ORDER BY weight'; + $sql = 'SELECT * FROM ' . $GLOBALS['xoopsDB']->prefix('wfs_article') . ' WHERE categoryid=' . $arrCat['id'] . ' ORDER BY weight'; $resultArticles = $GLOBALS['xoopsDB']->query($sql); while (false !== ($arrArticle = $GLOBALS['xoopsDB']->fetchArray($resultArticles))) { // insert article @@ -193,8 +192,8 @@ } // Linkes files - $sql = 'SELECT * FROM ' . $GLOBALS['xoopsDB']->prefix('wfs_files') . ' WHERE articleid=' . $arrArticle['articleid']; - $resultFiles = $GLOBALS['xoopsDB']->query($sql); + $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']); @@ -244,15 +243,15 @@ // Looping through the comments to link them to the new articles and module echo _AM_PUBLISHER_IMPORT_COMMENTS . '
'; - /* @var XoopsModuleHandler $moduleHandler */ - $moduleHandler = xoops_getHandler('module'); - $moduleObj = $moduleHandler->getByDirname('wfsection'); + /** @var XoopsModuleHandler $moduleHandler */ + $moduleHandler = xoops_getHandler('module'); + $moduleObj = $moduleHandler->getByDirname('wfsection'); $news_module_id = $moduleObj->getVar('mid'); $publisher_module_id = $helper->getModule()->mid(); /** @var \XoopsCommentHandler $commentHandler */ $commentHandler = xoops_getHandler('comment'); - $criteria = new \CriteriaCompo(); + $criteria = new \CriteriaCompo(); $criteria->add(new \Criteria('com_modid', $news_module_id)); /** @var \XoopsComment $comment */ $comments = $commentHandler->getObjects($criteria); diff --git a/admin/import/xfsection.php b/admin/import/xfsection.php index 8cbf90ae..fbfedf35 100644 --- a/admin/import/xfsection.php +++ b/admin/import/xfsection.php @@ -14,7 +14,6 @@ /** * @copyright The XUUPS Project http://sourceforge.net/projects/xuups/ * @license http://www.fsf.org/copyleft/gpl.html GNU public license - * @package Publisher * @since 1.0 * @author trabis * @author The SmartFactory @@ -60,12 +59,12 @@ $form = new \XoopsThemeForm(_AM_PUBLISHER_IMPORT_SETTINGS, 'import_form', PUBLISHER_ADMIN_URL . "/import/$scriptname"); // Categories to be imported - $sql = 'SELECT cat.id, cat.pid, cat.title, COUNT(art.articleid) FROM ' . $GLOBALS['xoopsDB']->prefix('xfs_category') . ' AS cat INNER JOIN ' . $GLOBALS['xoopsDB']->prefix('xfs_article') . ' AS art ON cat.id=art.categoryid GROUP BY art.categoryid'; - $result = $GLOBALS['xoopsDB']->query($sql); - $cat_cbox_values = []; + $sql = 'SELECT cat.id, cat.pid, cat.title, COUNT(art.articleid) FROM ' . $GLOBALS['xoopsDB']->prefix('xfs_category') . ' AS cat INNER JOIN ' . $GLOBALS['xoopsDB']->prefix('xfs_article') . ' AS art ON cat.id=art.categoryid GROUP BY art.categoryid'; + $result = $GLOBALS['xoopsDB']->query($sql); + $cat_cbox_values = []; $cat_cbox_options = []; while (list($cid, $pid, $cat_title, $art_count) = $GLOBALS['xoopsDB']->fetchRow($result)) { - $cat_title = $myts->displayTarea($cat_title); + $cat_title = $myts->displayTarea($cat_title); $cat_cbox_options[$cid] = "$cat_title ($art_count)"; } $cat_label = new \XoopsFormLabel(_AM_PUBLISHER_IMPORT_CATEGORIES, implode('
', $cat_cbox_options)); @@ -100,7 +99,7 @@ //publisher_adminMenu(-1, _AM_PUBLISHER_IMPORT); Publisher\Utility::openCollapsableBar('xfsectionimportgo', 'xfsectionimportgoicon', sprintf(_AM_PUBLISHER_IMPORT_FROM, $importFromModuleName), _AM_PUBLISHER_IMPORT_RESULT); - $cnt_imported_cat = 0; + $cnt_imported_cat = 0; $cnt_imported_articles = 0; $parentId = Request::getInt('parent_category', 0, 'POST'); @@ -111,12 +110,12 @@ $newCatArray = []; while (false !== ($arrCat = $GLOBALS['xoopsDB']->fetchArray($resultCat))) { - /* @var Publisher\Category $categoryObj */ + /** @var Publisher\Category $categoryObj */ $categoryObj = $helper->getHandler('Category')->create(); $newCat = []; - $newCat['oldid'] = $arrCat['id']; + $newCat['oldid'] = $arrCat['id']; $newCat['oldpid'] = $arrCat['pid']; $categoryObj->setVar('parentid', $arrCat['pid']); @@ -148,7 +147,7 @@ echo sprintf(_AM_PUBLISHER_IMPORT_CATEGORY_SUCCESS, $categoryObj->name()) . ""; - $sql = 'SELECT * FROM ' . $GLOBALS['xoopsDB']->prefix('xfs_article') . ' WHERE categoryid=' . $arrCat['id'] . ' ORDER BY weight'; + $sql = 'SELECT * FROM ' . $GLOBALS['xoopsDB']->prefix('xfs_article') . ' WHERE categoryid=' . $arrCat['id'] . ' ORDER BY weight'; $resultArticles = $GLOBALS['xoopsDB']->query($sql); while (false !== ($arrArticle = $GLOBALS['xoopsDB']->fetchArray($resultArticles))) { // insert article @@ -192,8 +191,8 @@ } // Linkes files - $sql = 'SELECT * FROM ' . $GLOBALS['xoopsDB']->prefix('xfs_files') . ' WHERE articleid=' . $arrArticle['articleid']; - $resultFiles = $GLOBALS['xoopsDB']->query($sql); + $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']); @@ -243,15 +242,15 @@ // Looping through the comments to link them to the new articles and module echo _AM_PUBLISHER_IMPORT_COMMENTS . '
'; - /* @var XoopsModuleHandler $moduleHandler */ - $moduleHandler = xoops_getHandler('module'); - $moduleObj = $moduleHandler->getByDirname('xfsection'); + /** @var XoopsModuleHandler $moduleHandler */ + $moduleHandler = xoops_getHandler('module'); + $moduleObj = $moduleHandler->getByDirname('xfsection'); $news_module_id = $moduleObj->getVar('mid'); $publisher_module_id = $helper->getModule()->mid(); /** @var \XoopsCommentHandler $commentHandler */ $commentHandler = xoops_getHandler('comment'); - $criteria = new \CriteriaCompo(); + $criteria = new \CriteriaCompo(); $criteria->add(new \Criteria('com_modid', $news_module_id)); /** @var \XoopsComment $comment */ $comments = $commentHandler->getObjects($criteria); diff --git a/admin/import/xnews.php b/admin/import/xnews.php index f0919537..86bb757d 100644 --- a/admin/import/xnews.php +++ b/admin/import/xnews.php @@ -14,7 +14,6 @@ /** * @copyright The XUUPS Project http://sourceforge.net/projects/xuups/ * @license http://www.fsf.org/copyleft/gpl.html GNU public license - * @package Publisher * @since 1.0 * @author trabis * @author The SmartFactory @@ -67,7 +66,7 @@ // } $imageCategoryHandler = xoops_getHandler('imagecategory'); - $imagecategory = $imageCategoryHandler->create(); + $imagecategory = $imageCategoryHandler->create(); // $imagecategory->setVar('imgcat_name', $imgcat_name); $imagecategory->setVar('imgcat_name', PUBLISHER_DIRNAME); //$imgcat_name); $imagecategory->setVar('imgcat_maxsize', $GLOBALS['xoopsModuleConfig']['maximum_filesize']); //$imgcat_maxsize); @@ -81,16 +80,16 @@ try { $imageCategoryHandler->insert($imagecategory); - } catch (\Exception $e) { + } catch (\Throwable $e) { echo "Caught exception: : couldn't insert Image Category " . $e->getMessage() . 'n'; } - $newid = $imagecategory->getVar('imgcat_id'); + $newid = $imagecategory->getVar('imgcat_id'); $imagecategorypermHandler = xoops_getHandler('groupperm'); if (!isset($readgroup)) { $readgroup = []; } - if (!in_array(XOOPS_GROUP_ADMIN, $readgroup)) { + if (!in_array(XOOPS_GROUP_ADMIN, $readgroup, true)) { $readgroup[] = XOOPS_GROUP_ADMIN; } foreach ($readgroup as $rgroup) { @@ -107,7 +106,7 @@ if (!isset($writegroup)) { $writegroup = []; } - if (!in_array(XOOPS_GROUP_ADMIN, $writegroup)) { + if (!in_array(XOOPS_GROUP_ADMIN, $writegroup, true)) { $writegroup[] = XOOPS_GROUP_ADMIN; } foreach ($writegroup as $wgroup) { @@ -126,11 +125,11 @@ // Categories to be imported $sql = 'SELECT cat.topic_id, cat.topic_pid, cat.topic_title, COUNT(art.storyid) FROM ' . $GLOBALS['xoopsDB']->prefix('nw_topics') . ' AS cat INNER JOIN ' . $GLOBALS['xoopsDB']->prefix('nw_stories') . ' AS art ON cat.topic_id=art.topicid GROUP BY art.topicid'; - $result = $GLOBALS['xoopsDB']->query($sql); + $result = $GLOBALS['xoopsDB']->query($sql); $cat_cbox_options = []; while (list($cid, $pid, $cat_title, $art_count) = $GLOBALS['xoopsDB']->fetchRow($result)) { - $cat_title = $myts->displayTarea($cat_title); + $cat_title = $myts->displayTarea($cat_title); $cat_cbox_options[$cid] = "$cat_title ($art_count)"; } @@ -166,14 +165,14 @@ //publisher_adminMenu(-1, _AM_PUBLISHER_IMPORT); // require_once dirname(dirname(__DIR__)) . '/include/common.php'; Publisher\Utility::openCollapsableBar('xnewsimportgo', 'xnewsimportgoicon', sprintf(_AM_PUBLISHER_IMPORT_FROM, $importFromModuleName), _AM_PUBLISHER_IMPORT_RESULT); - /* @var XoopsModuleHandler $moduleHandler */ - $moduleHandler = xoops_getHandler('module'); - $moduleObj = $moduleHandler->getByDirname('xnews'); + /** @var XoopsModuleHandler $moduleHandler */ + $moduleHandler = xoops_getHandler('module'); + $moduleObj = $moduleHandler->getByDirname('xnews'); $xnews_module_id = $moduleObj->getVar('mid'); - /* @var XoopsGroupPermHandler $grouppermHandler */ + /** @var XoopsGroupPermHandler $grouppermHandler */ $grouppermHandler = xoops_getHandler('groupperm'); - $cnt_imported_cat = 0; + $cnt_imported_cat = 0; $cnt_imported_articles = 0; $parentId = Request::getInt('parent_category', 0, 'POST'); @@ -182,9 +181,9 @@ $resultCat = $GLOBALS['xoopsDB']->query($sql); - $newCatArray = []; + $newCatArray = []; $newArticleArray = []; - /* @var XoopsImagecategoryHandler $imageCategoryHandler */ + /** @var XoopsImagecategoryHandler $imageCategoryHandler */ $imageCategoryHandler = xoops_getHandler('imagecategory'); // $criteria = new \CriteriaCombo; @@ -193,7 +192,7 @@ // $criteria->add(new \Criteria('imagecategory', $catObj->getVar('cid'), '=')); // $childCount = (int)($mylinksCatHandler->getCount($criteria)); - $criteria = new \Criteria('imgcat_name', PUBLISHER_DIRNAME); + $criteria = new \Criteria('imgcat_name', PUBLISHER_DIRNAME); $imageCategoryId = $imageCategoryHandler->getObjects($criteria); // $criteria = new \CriteriaCompo(); @@ -215,11 +214,11 @@ $oldToNew = []; while (false !== ($arrCat = $GLOBALS['xoopsDB']->fetchArray($resultCat))) { - $newCat = []; - $newCat['oldid'] = $arrCat['topic_id']; + $newCat = []; + $newCat['oldid'] = $arrCat['topic_id']; $newCat['oldpid'] = $arrCat['topic_pid']; - /* @var Publisher\Category $categoryObj */ + /** @var Publisher\Category $categoryObj */ $categoryObj = $helper->getHandler('Category')->create(); $categoryObj->setVar('parentid', $arrCat['topic_pid']); @@ -288,7 +287,7 @@ echo sprintf(_AM_PUBLISHER_IMPORT_CATEGORY_SUCCESS, $categoryObj->name()) . '
'; - $sql = 'SELECT * FROM ' . $GLOBALS['xoopsDB']->prefix('nw_stories') . ' WHERE topicid=' . $arrCat['topic_id']; + $sql = 'SELECT * FROM ' . $GLOBALS['xoopsDB']->prefix('nw_stories') . ' WHERE topicid=' . $arrCat['topic_id']; $resultArticles = $GLOBALS['xoopsDB']->query($sql); while (false !== ($arrArticle = $GLOBALS['xoopsDB']->fetchArray($resultArticles))) { // insert article @@ -317,8 +316,8 @@ /** @var \XoopsImageHandler $imgHandler */ $imgHandler = xoops_getHandler('image'); - $criteria = new \Criteria('image_name', $arrArticle['picture']); - $imageId = $imgHandler->getObjects($criteria); + $criteria = new \Criteria('image_name', $arrArticle['picture']); + $imageId = $imgHandler->getObjects($criteria); $newImageId = $imageId[0]->vars['image_id']['value']; $itemObj->setVar('image', $newImageId); $itemObj->setVar('images', $newImageId); @@ -350,14 +349,14 @@ } //-------------------------------------------- // Linkes files - $sql = 'SELECT * FROM ' . $GLOBALS['xoopsDB']->prefix('nw_stories_files') . ' WHERE storyid=' . $arrArticle['storyid']; - $resultFiles = $GLOBALS['xoopsDB']->query($sql); + $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 Publisher\File $fileObj */ + /** @var Publisher\File $fileObj */ $fileObj = $helper->getHandler('File')->create(); $fileObj->setVar('name', $arrFile['filerealname']); $fileObj->setVar('description', $arrFile['filerealname']); @@ -418,12 +417,12 @@ $publisher_module_id = $helper->getModule()->mid(); - /* @var XoopsCommentHandler $commentHandler */ + /** @var XoopsCommentHandler $commentHandler */ $commentHandler = xoops_getHandler('comment'); - $criteria = new \CriteriaCompo(); + $criteria = new \CriteriaCompo(); $criteria->add(new \Criteria('com_modid', $xnews_module_id)); $comments = $commentHandler->getObjects($criteria); - /* @var XoopsComment $comment */ + /** @var XoopsComment $comment */ foreach ($comments as $comment) { $comment->setVar('com_itemid', $newArticleArray[$comment->getVar('com_itemid')]); $comment->setVar('com_modid', $publisher_module_id); diff --git a/admin/index.php b/admin/index.php index 258c95d1..0651717d 100644 --- a/admin/index.php +++ b/admin/index.php @@ -16,7 +16,6 @@ * * @copyright The XOOPS Project (https://xoops.org) * @license GNU GPL (https://www.gnu.org/licenses/gpl-2.0.html/) - * @package Publisher * @since 1.0 * @author Mage, Mamba */ @@ -31,8 +30,8 @@ $helper = \XoopsModules\Publisher\Helper::getInstance(); $helper->loadLanguage('main'); $helper->loadLanguage('admin'); -$adminObject = \Xmf\Module\Admin::getInstance(); -$utility = new Publisher\Utility(); +$adminObject = \Xmf\Module\Admin::getInstance(); +$utility = new Publisher\Utility(); $configurator = new Publisher\Common\Configurator(); /* @@ -54,7 +53,7 @@ $adminObject->addConfigBoxLine('!' . _MD_PUBLISHER_ERROR_NO_PDF . '', 'default'); } -$modStats = []; +$modStats = []; $moduleStats = $utility::getModuleStats($configurator, $modStats); $adminObject->addInfoBox(constant('CO_' . $moduleDirNameUpper . '_' . 'STATS_SUMMARY')); @@ -100,13 +99,13 @@ //------------- Test Data ---------------------------- if ($helper->getConfig('displaySampleButton')) { - $yamlFile = dirname(__DIR__) . '/config/admin.yml'; - $config = loadAdminConfig($yamlFile); + $yamlFile = dirname(__DIR__) . '/config/admin.yml'; + $config = loadAdminConfig($yamlFile); $displaySampleButton = $config['displaySampleButton']; if (1 == $displaySampleButton) { xoops_loadLanguage('admin/modulesadmin', 'system'); - require dirname(__DIR__) . '/testdata/index.php'; + require dirname(__DIR__) . '/testdata/index.php'; $adminObject->addItemButton(constant('CO_' . $moduleDirNameUpper . '_' . 'ADD_SAMPLEDATA'), './../testdata/index.php?op=load', 'add'); $adminObject->addItemButton(constant('CO_' . $moduleDirNameUpper . '_' . 'SAVE_SAMPLEDATA'), './../testdata/index.php?op=save', 'add'); diff --git a/admin/item.php b/admin/item.php index e8fad2af..8f934414 100644 --- a/admin/item.php +++ b/admin/item.php @@ -14,8 +14,6 @@ /** * @copyright The XUUPS Project http://sourceforge.net/projects/xuups/ * @license http://www.fsf.org/copyleft/gpl.html GNU public license - * @package Admin - * @subpackage Action * @since 1.0 * @author trabis * @author The SmartFactory @@ -33,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'); @@ -43,9 +41,9 @@ // Where shall we start ? $submittedstartitem = Request::getInt('submittedstartitem', Request::getInt('submittedstartitem', 0, 'GET'), 'POST'); $publishedstartitem = Request::getInt('publishedstartitem', Request::getInt('publishedstartitem', 0, 'GET'), 'POST'); -$expiredstartitem = Request::getInt('publishedstartitem', Request::getInt('expiredstartitem', 0, 'GET'), 'POST'); -$offlinestartitem = Request::getInt('offlinestartitem', Request::getInt('offlinestartitem', 0, 'GET'), 'POST'); -$rejectedstartitem = Request::getInt('rejectedstartitem', Request::getInt('submittedstartitem', 0, 'GET'), 'POST'); +$expiredstartitem = Request::getInt('publishedstartitem', Request::getInt('expiredstartitem', 0, 'GET'), 'POST'); +$offlinestartitem = Request::getInt('offlinestartitem', Request::getInt('offlinestartitem', 0, 'GET'), 'POST'); +$rejectedstartitem = Request::getInt('rejectedstartitem', Request::getInt('submittedstartitem', 0, 'GET'), 'POST'); switch ($op) { case 'clone': @@ -82,7 +80,7 @@ $itemObj->setVarsFromRequest(); $old_status = $itemObj->status(); - $newStatus = Request::getInt('status', Constants::PUBLISHER_STATUS_PUBLISHED); //_PUBLISHER_STATUS_NOTSET; + $newStatus = Request::getInt('status', Constants::PUBLISHER_STATUS_PUBLISHED); //_PUBLISHER_STATUS_NOTSET; switch ($newStatus) { case Constants::PUBLISHER_STATUS_SUBMITTED: @@ -95,7 +93,7 @@ case Constants::PUBLISHER_STATUS_PUBLISHED: if ((Constants::PUBLISHER_STATUS_NOTSET == $old_status) || (Constants::PUBLISHER_STATUS_SUBMITTED == $old_status)) { $redirect_msg = _AM_PUBLISHER_SUBMITTED_APPROVE_SUCCESS; - $notifToDo = [Constants::PUBLISHER_NOTIFY_ITEM_PUBLISHED]; + $notifToDo = [Constants::PUBLISHER_NOTIFY_ITEM_PUBLISHED]; } else { $redirect_msg = _AM_PUBLISHER_PUBLISHED_MOD_SUCCESS; } @@ -166,7 +164,7 @@ echo "  "; echo '
'; - $orderBy = 'datesub'; + $orderBy = 'datesub'; $ascOrDesc = 'DESC'; // Display Submited articles @@ -194,9 +192,9 @@ $categoryObj = $itemsObj[$i]->getCategory(); $approve = "" . _AM_PUBLISHER_SUBMISSION_MODERATE . " "; - $clone = ''; - $delete = "" . _AM_PUBLISHER_DELETEITEM . ""; - $modify = ''; + $clone = ''; + $delete = "" . _AM_PUBLISHER_DELETEITEM . ""; + $modify = ''; echo ''; echo "" . $itemsObj[$i]->itemid() . ''; @@ -249,7 +247,7 @@ $modify = "" . _AM_PUBLISHER_EDITITEM . ""; $delete = "" . _AM_PUBLISHER_DELETEITEM . ""; - $clone = "" . _AM_PUBLISHER_CLONE_ITEM . ""; + $clone = "" . _AM_PUBLISHER_CLONE_ITEM . ""; echo ''; echo "" . $itemsObj[$i]->itemid() . ''; @@ -303,7 +301,7 @@ $modify = "" . _AM_PUBLISHER_EDITITEM . ""; $delete = "" . _AM_PUBLISHER_DELETEITEM . ""; - $clone = "" . _AM_PUBLISHER_CLONE_ITEM . ""; + $clone = "" . _AM_PUBLISHER_CLONE_ITEM . ""; echo ''; echo "" . $itemsObj[$i]->itemid() . ''; @@ -335,7 +333,7 @@ // Get the total number of Rejected ITEM $totalitems = $helper->getHandler('Item')->getItemsCount(-1, [Constants::PUBLISHER_STATUS_REJECTED]); - $itemsObj = $helper->getHandler('Item')->getAllRejected($helper->getConfig('idxcat_perpage'), $rejectedstartitem, -1, $orderBy, $ascOrDesc); + $itemsObj = $helper->getHandler('Item')->getAllRejected($helper->getConfig('idxcat_perpage'), $rejectedstartitem, -1, $orderBy, $ascOrDesc); $totalItemsOnPage = count($itemsObj); @@ -356,7 +354,7 @@ $modify = "" . _AM_PUBLISHER_EDITITEM . ""; $delete = "" . _AM_PUBLISHER_DELETEITEM . ""; - $clone = "" . _AM_PUBLISHER_CLONE_ITEM . ""; + $clone = "" . _AM_PUBLISHER_CLONE_ITEM . ""; echo ''; echo "" . $itemsObj[$i]->itemid() . ''; @@ -423,51 +421,51 @@ function publisher_editItem($showmenu = false, $itemid = 0, $clone = false) case Constants::PUBLISHER_STATUS_SUBMITTED: $breadcrumbAction1 = _CO_PUBLISHER_SUBMITTED; $breadcrumbAction2 = _AM_PUBLISHER_APPROVING; - $pageTitle = _AM_PUBLISHER_SUBMITTED_TITLE; - $pageInfo = _AM_PUBLISHER_SUBMITTED_INFO; - $buttonCaption = _AM_PUBLISHER_APPROVE; - $newStatus = Constants::PUBLISHER_STATUS_PUBLISHED; + $pageTitle = _AM_PUBLISHER_SUBMITTED_TITLE; + $pageInfo = _AM_PUBLISHER_SUBMITTED_INFO; + $buttonCaption = _AM_PUBLISHER_APPROVE; + $newStatus = Constants::PUBLISHER_STATUS_PUBLISHED; break; case Constants::PUBLISHER_STATUS_PUBLISHED: $breadcrumbAction1 = _CO_PUBLISHER_PUBLISHED; $breadcrumbAction2 = _AM_PUBLISHER_EDITING; - $pageTitle = _AM_PUBLISHER_PUBLISHEDEDITING; - $pageInfo = _AM_PUBLISHER_PUBLISHEDEDITING_INFO; - $buttonCaption = _AM_PUBLISHER_MODIFY; - $newStatus = Constants::PUBLISHER_STATUS_PUBLISHED; + $pageTitle = _AM_PUBLISHER_PUBLISHEDEDITING; + $pageInfo = _AM_PUBLISHER_PUBLISHEDEDITING_INFO; + $buttonCaption = _AM_PUBLISHER_MODIFY; + $newStatus = Constants::PUBLISHER_STATUS_PUBLISHED; break; case Constants::PUBLISHER_STATUS_OFFLINE: $breadcrumbAction1 = _CO_PUBLISHER_OFFLINE; $breadcrumbAction2 = _AM_PUBLISHER_EDITING; - $pageTitle = _AM_PUBLISHER_OFFLINEEDITING; - $pageInfo = _AM_PUBLISHER_OFFLINEEDITING_INFO; - $buttonCaption = _AM_PUBLISHER_MODIFY; - $newStatus = Constants::PUBLISHER_STATUS_OFFLINE; + $pageTitle = _AM_PUBLISHER_OFFLINEEDITING; + $pageInfo = _AM_PUBLISHER_OFFLINEEDITING_INFO; + $buttonCaption = _AM_PUBLISHER_MODIFY; + $newStatus = Constants::PUBLISHER_STATUS_OFFLINE; break; case Constants::PUBLISHER_STATUS_REJECTED: $breadcrumbAction1 = _CO_PUBLISHER_REJECTED; $breadcrumbAction2 = _AM_PUBLISHER_REJECTED; - $pageTitle = _AM_PUBLISHER_REJECTED_EDIT; - $pageInfo = _AM_PUBLISHER_REJECTED_EDIT_INFO; - $buttonCaption = _AM_PUBLISHER_MODIFY; - $newStatus = Constants::PUBLISHER_STATUS_REJECTED; + $pageTitle = _AM_PUBLISHER_REJECTED_EDIT; + $pageInfo = _AM_PUBLISHER_REJECTED_EDIT_INFO; + $buttonCaption = _AM_PUBLISHER_MODIFY; + $newStatus = Constants::PUBLISHER_STATUS_REJECTED; break; case Constants::PUBLISHER_STATUS_NOTSET: // Then it's a clone... $breadcrumbAction1 = _AM_PUBLISHER_ITEMS; $breadcrumbAction2 = _AM_PUBLISHER_CLONE_NEW; - $buttonCaption = _AM_PUBLISHER_CREATE; - $newStatus = Constants::PUBLISHER_STATUS_PUBLISHED; - $pageTitle = _AM_PUBLISHER_ITEM_DUPLICATING; - $pageInfo = _AM_PUBLISHER_ITEM_DUPLICATING_DSC; + $buttonCaption = _AM_PUBLISHER_CREATE; + $newStatus = Constants::PUBLISHER_STATUS_PUBLISHED; + $pageTitle = _AM_PUBLISHER_ITEM_DUPLICATING; + $pageInfo = _AM_PUBLISHER_ITEM_DUPLICATING_DSC; break; case 'default': default: $breadcrumbAction1 = _AM_PUBLISHER_ITEMS; $breadcrumbAction2 = _AM_PUBLISHER_EDITING; - $pageTitle = _AM_PUBLISHER_PUBLISHEDEDITING; - $pageInfo = _AM_PUBLISHER_PUBLISHEDEDITING_INFO; - $buttonCaption = _AM_PUBLISHER_MODIFY; - $newStatus = Constants::PUBLISHER_STATUS_PUBLISHED; + $pageTitle = _AM_PUBLISHER_PUBLISHEDEDITING; + $pageInfo = _AM_PUBLISHER_PUBLISHEDEDITING_INFO; + $buttonCaption = _AM_PUBLISHER_MODIFY; + $newStatus = Constants::PUBLISHER_STATUS_PUBLISHED; break; } @@ -487,11 +485,11 @@ function publisher_editItem($showmenu = false, $itemid = 0, $clone = false) $itemObj = $helper->getHandler('Item')->create(); $itemObj->setVarsFromRequest(); - $categoryObj = $helper->getHandler('Category')->create(); + $categoryObj = $helper->getHandler('Category')->create(); $breadcrumbAction1 = _AM_PUBLISHER_ITEMS; $breadcrumbAction2 = _AM_PUBLISHER_CREATINGNEW; - $buttonCaption = _AM_PUBLISHER_CREATE; - $newStatus = Constants::PUBLISHER_STATUS_PUBLISHED; + $buttonCaption = _AM_PUBLISHER_CREATE; + $newStatus = Constants::PUBLISHER_STATUS_PUBLISHED; $categoryObj->setVar('categoryid', Request::getInt('categoryid', 0, 'GET')); @@ -527,7 +525,7 @@ function publisher_editItem($showmenu = false, $itemid = 0, $clone = false) $form = new \XoopsThemeForm(_CO_PUBLISHER_DELETEFILE, 'form_name', 'pw_delete_file.php'); $pWrapSelect = new \XoopsFormSelect(Publisher\Utility::getUploadDir(true, 'content'), 'address'); - $folder = dir($dir); + $folder = dir($dir); while (false !== ($file = $folder->read())) { if ('.' !== $file && '..' !== $file) { $pWrapSelect->addOption($file, $file); diff --git a/admin/main.php b/admin/main.php index 1d33f238..878f662b 100644 --- a/admin/main.php +++ b/admin/main.php @@ -14,7 +14,6 @@ /** * @copyright The XUUPS Project http://sourceforge.net/projects/xuups/ * @license http://www.fsf.org/copyleft/gpl.html GNU public license - * @package Publisher * @since 1.0 * @author trabis * @author The SmartFactory @@ -32,15 +31,15 @@ $itemid = Request::getInt('itemid', 0, 'POST'); -$pick = Request::getInt('pick', Request::getInt('pick', 0, 'GET'), 'POST'); +$pick = Request::getInt('pick', Request::getInt('pick', 0, 'GET'), 'POST'); $statussel = Request::getInt('statussel', Request::getInt('statussel', 0, 'GET'), 'POST'); -$sortsel = Request::getString('sortsel', Request::getString('sortsel', 'itemid', 'GET'), 'POST'); -$ordersel = Request::getString('ordersel', Request::getString('ordersel', 'DESC', 'GET'), 'POST'); +$sortsel = Request::getString('sortsel', Request::getString('sortsel', 'itemid', 'GET'), 'POST'); +$ordersel = Request::getString('ordersel', Request::getString('ordersel', 'DESC', 'GET'), 'POST'); $module_id = $helper->getModule()->mid(); -/* @var XoopsGroupPermHandler $grouppermHandler */ +/** @var XoopsGroupPermHandler $grouppermHandler */ $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 @@ -96,26 +95,26 @@ // Construction of lower table Publisher\Utility::openCollapsableBar('allitemstable', 'allitemsicon', _AM_PUBLISHER_ALLITEMS, _AM_PUBLISHER_ALLITEMSMSG); -$showingtxt = ''; -$selectedtxt = ''; -$cond = ''; +$showingtxt = ''; +$selectedtxt = ''; +$cond = ''; $selectedtxt0 = ''; $selectedtxt1 = ''; $selectedtxt2 = ''; $selectedtxt3 = ''; $selectedtxt4 = ''; -$sorttxttitle = ''; +$sorttxttitle = ''; $sorttxtcreated = ''; -$sorttxtweight = ''; -$sorttxtitemid = ''; +$sorttxtweight = ''; +$sorttxtitemid = ''; -$sorttxthits = ''; -$sorttxtvotes = ''; +$sorttxthits = ''; +$sorttxtvotes = ''; $sorttxtcomments = ''; -$sorttxtrating = ''; +$sorttxtrating = ''; -$ordertxtasc = ''; +$ordertxtasc = ''; $ordertxtdesc = ''; switch ($sortsel) { @@ -156,33 +155,33 @@ switch ($statussel) { case Constants::PUBLISHER_STATUS_ALL: - $selectedtxt0 = 'selected'; - $caption = _AM_PUBLISHER_ALL; - $cond = ''; + $selectedtxt0 = 'selected'; + $caption = _AM_PUBLISHER_ALL; + $cond = ''; $status_explaination = _AM_PUBLISHER_ALL_EXP; break; case Constants::PUBLISHER_STATUS_SUBMITTED: - $selectedtxt1 = 'selected'; - $caption = _CO_PUBLISHER_SUBMITTED; - $cond = ' WHERE status = ' . Constants::PUBLISHER_STATUS_SUBMITTED . ' '; + $selectedtxt1 = 'selected'; + $caption = _CO_PUBLISHER_SUBMITTED; + $cond = ' WHERE status = ' . Constants::PUBLISHER_STATUS_SUBMITTED . ' '; $status_explaination = _AM_PUBLISHER_SUBMITTED_EXP; break; case Constants::PUBLISHER_STATUS_PUBLISHED: - $selectedtxt2 = 'selected'; - $caption = _CO_PUBLISHER_PUBLISHED; - $cond = ' WHERE status = ' . Constants::PUBLISHER_STATUS_PUBLISHED . ' '; + $selectedtxt2 = 'selected'; + $caption = _CO_PUBLISHER_PUBLISHED; + $cond = ' WHERE status = ' . Constants::PUBLISHER_STATUS_PUBLISHED . ' '; $status_explaination = _AM_PUBLISHER_PUBLISHED_EXP; break; case Constants::PUBLISHER_STATUS_OFFLINE: - $selectedtxt3 = 'selected'; - $caption = _CO_PUBLISHER_OFFLINE; - $cond = ' WHERE status = ' . Constants::PUBLISHER_STATUS_OFFLINE . ' '; + $selectedtxt3 = 'selected'; + $caption = _CO_PUBLISHER_OFFLINE; + $cond = ' WHERE status = ' . Constants::PUBLISHER_STATUS_OFFLINE . ' '; $status_explaination = _AM_PUBLISHER_OFFLINE_EXP; break; case Constants::PUBLISHER_STATUS_REJECTED: - $selectedtxt4 = 'selected'; - $caption = _CO_PUBLISHER_REJECTED; - $cond = ' WHERE status = ' . Constants::PUBLISHER_STATUS_REJECTED . ' '; + $selectedtxt4 = 'selected'; + $caption = _CO_PUBLISHER_REJECTED; + $cond = ' WHERE status = ' . Constants::PUBLISHER_STATUS_REJECTED . ' '; $status_explaination = _AM_PUBLISHER_REJECTED_ITEM_EXP; break; } @@ -240,11 +239,11 @@ for ($i = 0; $i < $totalItemsOnPage; ++$i) { // Creating the category object to which this item is linked $categoryObj = $itemsObj[$i]->getCategory(); - $approve = ''; + $approve = ''; switch ($itemsObj[$i]->status()) { case Constants::PUBLISHER_STATUS_SUBMITTED: $statustxt = _CO_PUBLISHER_SUBMITTED; - $approve = "itemid() . "'>"
                              . _AM_PUBLISHER_SUBMISSION_MODERATE
                              . " "; - $clone = ''; - $delete = "getModule()->dirname() . "/assets/images/links/delete.png' title='" . _AM_PUBLISHER_DELETEITEM . "' alt='" . _AM_PUBLISHER_DELETEITEM . "'>"; - $modify = ''; + $clone = ''; + $delete = "getModule()->dirname() . "/assets/images/links/delete.png' title='" . _AM_PUBLISHER_DELETEITEM . "' alt='" . _AM_PUBLISHER_DELETEITEM . "'>"; + $modify = ''; break; case Constants::PUBLISHER_STATUS_PUBLISHED: $statustxt = _CO_PUBLISHER_PUBLISHED; - $approve = ''; + $approve = ''; $modify = "getModule()->dirname() . "/assets/images/links/edit.gif' title='" . _AM_PUBLISHER_ITEM_EDIT . "' alt='" . _AM_PUBLISHER_ITEM_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 . "'> "; + $clone = "getModule()->dirname() . "/assets/images/links/clone.gif' title='" . _AM_PUBLISHER_CLONE_ITEM . "' alt='" . _AM_PUBLISHER_CLONE_ITEM . "'> "; break; case Constants::PUBLISHER_STATUS_OFFLINE: $statustxt = _CO_PUBLISHER_OFFLINE; - $approve = ''; - $modify = "getModule()->dirname() . "/assets/images/links/edit.gif' title='" . _AM_PUBLISHER_ITEM_EDIT . "' alt='" . _AM_PUBLISHER_ITEM_EDIT . "'> "; - $delete = "getModule()->dirname() . "/assets/images/links/delete.png' title='" . _AM_PUBLISHER_DELETEITEM . "' alt='" . _AM_PUBLISHER_DELETEITEM . "'> "; - $clone = /** @lang text */ + $approve = ''; + $modify = "getModule()->dirname() . "/assets/images/links/edit.gif' title='" . _AM_PUBLISHER_ITEM_EDIT . "' alt='" . _AM_PUBLISHER_ITEM_EDIT . "'> "; + $delete = "getModule()->dirname() . "/assets/images/links/delete.png' title='" . _AM_PUBLISHER_DELETEITEM . "' alt='" . _AM_PUBLISHER_DELETEITEM . "'> "; + $clone = /** @lang text */ "getModule()->dirname() . "/assets/images/links/clone.gif' title='" . _AM_PUBLISHER_CLONE_ITEM . "' alt='" . _AM_PUBLISHER_CLONE_ITEM . "'> "; break; 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 . "'> "; - $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 . "'> "; + $approve = ''; + $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; case 'default': default: $statustxt = _AM_PUBLISHER_STATUS0; - $approve = ''; - $clone = ''; - $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 . "'>"; + $approve = ''; + $clone = ''; + $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 3cf9bfc6..ad141f7d 100644 --- a/admin/menu.php +++ b/admin/menu.php @@ -14,7 +14,6 @@ /** * @copyright The XUUPS Project http://sourceforge.net/projects/xuups/ * @license http://www.fsf.org/copyleft/gpl.html GNU public license - * @package Publisher * @since 1.0 * @author trabis * @author The SmartFactory @@ -22,10 +21,9 @@ use XoopsModules\Publisher; - require_once dirname(__DIR__) . '/preloads/autoloader.php'; -$moduleDirName = basename(dirname(__DIR__)); +$moduleDirName = basename(dirname(__DIR__)); $moduleDirNameUpper = mb_strtoupper($moduleDirName); /** @var Publisher\Helper $helper */ @@ -34,53 +32,53 @@ $helper->loadLanguage('feedback'); // 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', + 'link' => 'admin/index.php', + 'icon' => $pathIcon32 . '/home.png', ]; $adminmenu[] = [ 'title' => _MI_PUBLISHER_ADMENU1, - 'link' => 'admin/main.php', - 'icon' => $pathIcon32 . '/manage.png', + 'link' => 'admin/main.php', + 'icon' => $pathIcon32 . '/manage.png', ]; // Category $adminmenu[] = [ 'title' => _MI_PUBLISHER_ADMENU2, - 'link' => 'admin/category.php', - 'icon' => $pathIcon32 . '/category.png', + 'link' => 'admin/category.php', + 'icon' => $pathIcon32 . '/category.png', ]; // Items $adminmenu[] = [ 'title' => _MI_PUBLISHER_ADMENU3, - 'link' => 'admin/item.php', - 'icon' => $pathIcon32 . '/content.png', + 'link' => 'admin/item.php', + 'icon' => $pathIcon32 . '/content.png', ]; // Permissions $adminmenu[] = [ 'title' => _MI_PUBLISHER_ADMENU4, - 'link' => 'admin/permissions.php', - 'icon' => $pathIcon32 . '/permissions.png', + 'link' => 'admin/permissions.php', + 'icon' => $pathIcon32 . '/permissions.png', ]; // Blocks Admin $adminmenu[] = [ 'title' => _MI_PUBLISHER_ADMENU5, - 'link' => 'admin/blocksadmin.php', - 'icon' => $pathIcon32 . '/block.png', + 'link' => 'admin/blocksadmin.php', + 'icon' => $pathIcon32 . '/block.png', ]; // Mimetypes $adminmenu[] = [ 'title' => _MI_PUBLISHER_ADMENU6, - 'link' => 'admin/mimetypes.php', - 'icon' => $pathIcon32 . '/type.png', + 'link' => 'admin/mimetypes.php', + 'icon' => $pathIcon32 . '/type.png', ]; //$adminmenu[] = [ @@ -103,15 +101,15 @@ //Import $adminmenu[] = [ 'title' => _MI_PUBLISHER_IMPORT, - 'link' => 'admin/import.php', - 'icon' => $pathIcon32 . '/download.png', + 'link' => 'admin/import.php', + 'icon' => $pathIcon32 . '/download.png', ]; //Clone $adminmenu[] = [ 'title' => _MI_PUBLISHER_MENU_CLONE, - 'link' => 'admin/clone.php', - 'icon' => $pathModIcon32 . '/editcopy.png', + 'link' => 'admin/clone.php', + 'icon' => $pathModIcon32 . '/editcopy.png', ]; // [ @@ -123,23 +121,23 @@ //Feedback $adminmenu[] = [ 'title' => constant('CO_' . $moduleDirNameUpper . '_' . 'ADMENU_FEEDBACK'), - 'link' => 'admin/feedback.php', - 'icon' => $pathIcon32 . '/mail_foward.png', + 'link' => 'admin/feedback.php', + 'icon' => $pathIcon32 . '/mail_foward.png', ]; if (is_object($helper->getModule()) && $helper->getConfig('displayDeveloperTools')) { $adminmenu[] = [ 'title' => constant('CO_' . $moduleDirNameUpper . '_' . 'ADMENU_MIGRATE'), - 'link' => 'admin/migrate.php', - 'icon' => $pathIcon32 . '/database_go.png', + 'link' => 'admin/migrate.php', + 'icon' => $pathIcon32 . '/database_go.png', ]; } //About $adminmenu[] = [ 'title' => _MI_PUBLISHER_ABOUT, - 'link' => 'admin/about.php', - 'icon' => $pathIcon32 . '/about.png', + 'link' => 'admin/about.php', + 'icon' => $pathIcon32 . '/about.png', ]; $GLOBALS['xoTheme']->addStylesheet('modules/' . $moduleDirName . '/assets/css/style.css'); diff --git a/admin/migrate.php b/admin/migrate.php index 6dd3c87f..e9669df1 100644 --- a/admin/migrate.php +++ b/admin/migrate.php @@ -61,13 +61,13 @@ /** @var \XoopsModules\Publisher\Common\Migrate $migrator */ $migrator = new \XoopsModules\Publisher\Common\Migrate($configurator); -$op = Request::getCmd('op', 'show'); -$opShow = Request::getCmd('show', null, 'POST'); +$op = Request::getCmd('op', 'show'); +$opShow = Request::getCmd('show', null, 'POST'); $opMigrate = Request::getCmd('migrate', null, 'POST'); -$opSchema = Request::getCmd('schema', null, 'POST'); -$op = !empty($opShow) ? 'show' : $op; -$op = !empty($opMigrate) ? 'migrate' : $op; -$op = !empty($opSchema) ? 'schema' : $op; +$opSchema = Request::getCmd('schema', null, 'POST'); +$op = !empty($opShow) ? 'show' : $op; +$op = !empty($opMigrate) ? 'migrate' : $op; +$op = !empty($opSchema) ? 'schema' : $op; $message = ''; diff --git a/admin/mimetypes.php b/admin/mimetypes.php index dd742069..bc8abf68 100644 --- a/admin/mimetypes.php +++ b/admin/mimetypes.php @@ -14,8 +14,6 @@ /** * @copyright The XUUPS Project http://sourceforge.net/projects/xuups/ * @license http://www.fsf.org/copyleft/gpl.html GNU public license - * @package Admin - * @subpackage Action * @since 1.0 * @author trabis * @author The SmartFactory @@ -30,15 +28,15 @@ $start = Request::getInt('start', 0, 'GET'); $limit = Request::getInt('limit', Request::getInt('limit', 15, 'GET'), 'POST'); -$aSortBy = [ - 'mime_id' => _AM_PUBLISHER_MIME_ID, - 'mime_name' => _AM_PUBLISHER_MIME_NAME, - 'mime_ext' => _AM_PUBLISHER_MIME_EXT, +$aSortBy = [ + 'mime_id' => _AM_PUBLISHER_MIME_ID, + '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]; +$aOrderBy = ['ASC' => _AM_PUBLISHER_TEXT_ASCENDING, 'DESC' => _AM_PUBLISHER_TEXT_DESCENDING]; +$aLimitBy = ['10' => 10, '15' => 15, '20' => 20, '25' => 25, '50' => 50, '100' => 100]; $aSearchBy = ['mime_id' => _AM_PUBLISHER_MIME_ID, 'mime_name' => _AM_PUBLISHER_MIME_NAME, 'mime_ext' => _AM_PUBLISHER_MIME_EXT]; $error = []; diff --git a/admin/pagewrap.php b/admin/pagewrap.php index bf547e25..917b8ce5 100644 --- a/admin/pagewrap.php +++ b/admin/pagewrap.php @@ -14,7 +14,6 @@ /** * @copyright The XUUPS Project http://sourceforge.net/projects/xuups/ * @license http://www.fsf.org/copyleft/gpl.html GNU public license - * @package Publisher * @since 1.0 * @author trabis * @author The SmartFactory @@ -48,7 +47,7 @@ $form = new \XoopsThemeForm(_CO_PUBLISHER_DELETEFILE, 'form_name', 'pw_delete_file.php'); $pWrapSelect = new \XoopsFormSelect(Publisher\Utility::getUploadDir(true, 'content'), 'address'); -$folder = dir($dir); +$folder = dir($dir); while ($file == $folder->read()) { if ('.' !== $file && '..' !== $file) { $pWrapSelect->addOption($file, $file); diff --git a/admin/permissions.php b/admin/permissions.php index c0970ce1..fc752376 100644 --- a/admin/permissions.php +++ b/admin/permissions.php @@ -14,7 +14,6 @@ /** * @copyright The XUUPS Project http://sourceforge.net/projects/xuups/ * @license http://www.fsf.org/copyleft/gpl.html GNU public license - * @package Publisher * @since 1.0 * @author trabis * @author The SmartFactory @@ -35,7 +34,7 @@ // View Categories permissions $item_list_view = []; -$block_view = []; +$block_view = []; Publisher\Utility::openCollapsableBar('permissionstable_view', 'permissionsicon_view', _AM_PUBLISHER_PERMISSIONSVIEWMAN, _AM_PUBLISHER_VIEW_CATS); $result_view = $GLOBALS['xoopsDB']->query('SELECT categoryid, name FROM ' . $GLOBALS['xoopsDB']->prefix($helper->getDirname() . '_categories') . ' '); @@ -84,35 +83,35 @@ echo "
\n"; Publisher\Utility::openCollapsableBar('permissionstable_form', 'permissionsicon_form', _AM_PUBLISHER_PERMISSIONS_FORM, _AM_PUBLISHER_PERMISSIONS_FORM_DSC); $form_options = [ - Constants::PUBLISHER_SUMMARY => _AM_PUBLISHER_SUMMARY, + Constants::PUBLISHER_SUMMARY => _AM_PUBLISHER_SUMMARY, //Constants::PUBLISHER_DISPLAY_SUMMARY => _CO_PUBLISHER_DISPLAY_SUMMARY, - Constants::PUBLISHER_AVAILABLE_PAGE_WRAP => _CO_PUBLISHER_AVAILABLE_PAGE_WRAP, - Constants::PUBLISHER_ITEM_TAG => _AM_PUBLISHER_ITEM_TAG, - Constants::PUBLISHER_IMAGE_ITEM => _AM_PUBLISHER_IMAGE_ITEM, + Constants::PUBLISHER_AVAILABLE_PAGE_WRAP => _CO_PUBLISHER_AVAILABLE_PAGE_WRAP, + Constants::PUBLISHER_ITEM_TAG => _AM_PUBLISHER_ITEM_TAG, + Constants::PUBLISHER_IMAGE_ITEM => _AM_PUBLISHER_IMAGE_ITEM, //_PUBLISHER_IMAGE_UPLOAD => _AM_PUBLISHER_IMAGE_UPLOAD, - Constants::PUBLISHER_ITEM_UPLOAD_FILE => _CO_PUBLISHER_ITEM_UPLOAD_FILE, - Constants::PUBLISHER_UID => _CO_PUBLISHER_UID, - Constants::PUBLISHER_DATESUB => _CO_PUBLISHER_DATESUB, - Constants::PUBLISHER_DATEEXPIRE => _CO_PUBLISHER_DATEEXPIRE, - Constants::PUBLISHER_STATUS => _CO_PUBLISHER_STATUS, - Constants::PUBLISHER_ITEM_SHORT_URL => _CO_PUBLISHER_ITEM_SHORT_URL, - Constants::PUBLISHER_ITEM_META_KEYWORDS => _CO_PUBLISHER_ITEM_META_KEYWORDS, + Constants::PUBLISHER_ITEM_UPLOAD_FILE => _CO_PUBLISHER_ITEM_UPLOAD_FILE, + Constants::PUBLISHER_UID => _CO_PUBLISHER_UID, + Constants::PUBLISHER_DATESUB => _CO_PUBLISHER_DATESUB, + Constants::PUBLISHER_DATEEXPIRE => _CO_PUBLISHER_DATEEXPIRE, + Constants::PUBLISHER_STATUS => _CO_PUBLISHER_STATUS, + Constants::PUBLISHER_ITEM_SHORT_URL => _CO_PUBLISHER_ITEM_SHORT_URL, + Constants::PUBLISHER_ITEM_META_KEYWORDS => _CO_PUBLISHER_ITEM_META_KEYWORDS, Constants::PUBLISHER_ITEM_META_DESCRIPTION => _CO_PUBLISHER_ITEM_META_DESCRIPTION, - Constants::PUBLISHER_WEIGHT => _CO_PUBLISHER_WEIGHT, - Constants::PUBLISHER_ALLOWCOMMENTS => _CO_PUBLISHER_ALLOWCOMMENTS, + Constants::PUBLISHER_WEIGHT => _CO_PUBLISHER_WEIGHT, + Constants::PUBLISHER_ALLOWCOMMENTS => _CO_PUBLISHER_ALLOWCOMMENTS, //Constants::PUBLISHER_PERMISSIONS_ITEM => _CO_PUBLISHER_PERMISSIONS_ITEM, //Constants::PUBLISHER_PERMISSIONS_ITEM_DSC => _CO_PUBLISHER_PERMISSIONS_ITEM_DSC, // Constants::PUBLISHER_PARTIAL_VIEW => _CO_PUBLISHER_PARTIAL_VIEW, - Constants::PUBLISHER_DOHTML => _CO_PUBLISHER_DOHTML, - Constants::PUBLISHER_DOSMILEY => _CO_PUBLISHER_DOSMILEY, - Constants::PUBLISHER_DOXCODE => _CO_PUBLISHER_DOXCODE, - Constants::PUBLISHER_DOIMAGE => _CO_PUBLISHER_DOIMAGE, - 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_DOHTML => _CO_PUBLISHER_DOHTML, + Constants::PUBLISHER_DOSMILEY => _CO_PUBLISHER_DOSMILEY, + Constants::PUBLISHER_DOXCODE => _CO_PUBLISHER_DOXCODE, + Constants::PUBLISHER_DOIMAGE => _CO_PUBLISHER_DOIMAGE, + 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, ]; -$form_submit = new \XoopsGroupPermForm('', $helper->getModule()->mid(), 'form_view', '', 'admin/permissions.php'); +$form_submit = new \XoopsGroupPermForm('', $helper->getModule()->mid(), 'form_view', '', 'admin/permissions.php'); foreach ($form_options as $key => $value) { $form_submit->addItem($key, $value); } @@ -123,7 +122,7 @@ // Editors permissions echo "
\n"; Publisher\Utility::openCollapsableBar('permissionstable_editors', 'permissions_editors', _AM_PUBLISHER_PERMISSIONS_EDITORS, _AM_PUBLISHER_PERMISSIONS_EDITORS_DSC); -$editors = Publisher\Utility::getEditors(); +$editors = Publisher\Utility::getEditors(); $form_submit = new \XoopsGroupPermForm('', $helper->getModule()->mid(), 'editors', '', 'admin/permissions.php'); foreach ($editors as $key => $value) { $form_submit->addItem($key, $value['title']); @@ -137,9 +136,9 @@ 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'); +$form_submit = new \XoopsGroupPermForm('', $helper->getModule()->mid(), 'global', '', 'admin/permissions.php'); foreach ($form_options as $key => $value) { $form_submit->addItem($key, $value); } diff --git a/admin/preferences.php b/admin/preferences.php index 175ec61a..dfa45f26 100644 --- a/admin/preferences.php +++ b/admin/preferences.php @@ -14,7 +14,6 @@ /** * @copyright The XUUPS Project http://sourceforge.net/projects/xuups/ * @license http://www.fsf.org/copyleft/gpl.html GNU public license - * @package Publisher * @since 1.0 * @author trabis * @author Kazumi Ono (AKA onokazu) @@ -28,14 +27,14 @@ /** @var Publisher\Helper $helper */ $helper = Publisher\Helper::getInstance(); -$module = $helper->getModule(); -$modId = $module->mid(); +$module = $helper->getModule(); +$modId = $module->mid(); $modname = $module->name(); $dirName = $helper->getDirname(); /** @var \XoopsModuleHandler $moduleHandler */ $moduleHandler = xoops_getHandler('module'); -$xoopsModule0 = $moduleHandler->getByDirname(basename(dirname(__DIR__))); +$xoopsModule0 = $moduleHandler->getByDirname(basename(dirname(__DIR__))); global $xoopsModule; xoops_loadLanguage('admin', 'system'); @@ -58,17 +57,17 @@ $configHandler = xoops_getHandler('config'); $config = $configHandler->getConfigs(new \Criteria('conf_modid', $modId)); - $count = count($config); + $count = count($config); if ($count < 1) { redirect_header($module->getInfo('adminindex'), 1); } - $xv_configs = $module->getInfo('config'); + $xv_configs = $module->getInfo('config'); $config_cats = $module->getInfo('configcat'); if (!array_key_exists('others', $config_cats)) { $config_cats['others'] = [ - 'name' => _MI_PUBLISHER_CONFCAT_OTHERS, + 'name' => _MI_PUBLISHER_CONFCAT_OTHERS, 'description' => _MI_PUBLISHER_CONFCAT_OTHERS_DSC, ]; } @@ -103,7 +102,7 @@ unset($xv_config); if (!array_key_exists($formCat, $config_cats)) { - $formCat = 'others'; + $formCat = 'others'; $cat_others_used = true; } @@ -120,7 +119,7 @@ } break; case 'select': - $ele = new \XoopsFormSelect($title, $config[$i]->getVar('conf_name'), $config[$i]->getConfValueForOutput()); + $ele = new \XoopsFormSelect($title, $config[$i]->getVar('conf_name'), $config[$i]->getConfValueForOutput()); $options = $configHandler->getConfigOptions(new \Criteria('conf_id', $config[$i]->getVar('conf_id'))); $opcount = count($options); for ($j = 0; $j < $opcount; ++$j) { @@ -130,7 +129,7 @@ } break; case 'select_multi': - $ele = new \XoopsFormSelect($title, $config[$i]->getVar('conf_name'), $config[$i]->getConfValueForOutput(), 5, true); + $ele = new \XoopsFormSelect($title, $config[$i]->getVar('conf_name'), $config[$i]->getConfValueForOutput(), 5, true); $options = $configHandler->getConfigOptions(new \Criteria('conf_id', $config[$i]->getVar('conf_id'))); $opcount = count($options); for ($j = 0; $j < $opcount; ++$j) { @@ -160,20 +159,20 @@ break; case 'password': $myts = \MyTextSanitizer::getInstance(); - $ele = new \XoopsFormPassword($title, $config[$i]->getVar('conf_name'), 50, 255, $myts->htmlSpecialChars($config[$i]->getConfValueForOutput())); + $ele = new \XoopsFormPassword($title, $config[$i]->getVar('conf_name'), 50, 255, $myts->htmlSpecialChars($config[$i]->getConfValueForOutput())); break; case 'color': $myts = \MyTextSanitizer::getInstance(); - $ele = new \XoopsFormColorPicker($title, $config[$i]->getVar('conf_name'), $myts->htmlSpecialChars($config[$i]->getConfValueForOutput())); + $ele = new \XoopsFormColorPicker($title, $config[$i]->getVar('conf_name'), $myts->htmlSpecialChars($config[$i]->getConfValueForOutput())); break; case 'hidden': $myts = \MyTextSanitizer::getInstance(); - $ele = new \XoopsFormHidden($config[$i]->getVar('conf_name'), $myts->htmlSpecialChars($config[$i]->getConfValueForOutput())); + $ele = new \XoopsFormHidden($config[$i]->getVar('conf_name'), $myts->htmlSpecialChars($config[$i]->getConfValueForOutput())); break; case 'textbox': default: $myts = \MyTextSanitizer::getInstance(); - $ele = new \XoopsFormText($title, $config[$i]->getVar('conf_name'), 50, 255, $myts->htmlSpecialChars($config[$i]->getConfValueForOutput())); + $ele = new \XoopsFormText($title, $config[$i]->getVar('conf_name'), 50, 255, $myts->htmlSpecialChars($config[$i]->getConfValueForOutput())); break; } $hidden = new \XoopsFormHidden('conf_ids[]', $config[$i]->getVar('conf_id')); @@ -203,11 +202,11 @@ if (!$GLOBALS['xoopsSecurity']->check()) { redirect_header($module->getInfo('adminindex'), 3, implode('
', $GLOBALS['xoopsSecurity']->getErrors())); } - $count = count($confIds); + $count = count($confIds); $configHandler = xoops_getHandler('config'); if ($count > 0) { for ($i = 0; $i < $count; ++$i) { - $config = $configHandler->getConfig($confIds[$i]); + $config = $configHandler->getConfig($confIds[$i]); $newValue = ${$config->getVar('conf_name')}; if (is_array($newValue) || $newValue != $config->getVar('conf_value')) { $config->setConfValueForInput($newValue); diff --git a/admin/pw_delete_file.php b/admin/pw_delete_file.php index 2b4f500e..6c7776a2 100644 --- a/admin/pw_delete_file.php +++ b/admin/pw_delete_file.php @@ -14,7 +14,6 @@ /** * @copyright The XUUPS Project http://sourceforge.net/projects/xuups/ * @license http://www.fsf.org/copyleft/gpl.html GNU public license - * @package Publisher * @since 1.0 * @author trabis * @author The SmartFactory @@ -31,10 +30,10 @@ redirect_header(XOOPS_URL . '/modules/publisher/admin/item.php', 3, _AM_PUBLISHER_FILE_DELETE_ERROR); } - $dir = Publisher\Utility::getUploadDir(true, 'content'); + $dir = Publisher\Utility::getUploadDir(true, 'content'); $check_path = realpath($dir); - $filename = Request::getString('address', '', 'POST'); + $filename = Request::getString('address', '', 'POST'); $path_file = realpath($dir . '/' . $filename); try { diff --git a/admin/pw_upload_file.php b/admin/pw_upload_file.php index bad30106..2c7e7e87 100644 --- a/admin/pw_upload_file.php +++ b/admin/pw_upload_file.php @@ -14,7 +14,6 @@ /** * @copyright The XUUPS Project http://sourceforge.net/projects/xuups/ * @license http://www.fsf.org/copyleft/gpl.html GNU public license - * @package Publisher * @since 1.0 * @author trabis * @author The SmartFactory @@ -31,7 +30,7 @@ redirect_header(Request::getString('backto', '', 'POST'), 2, _AM_PUBLISHER_FILEUPLOAD_SUCCESS); } else { $errorstxt = implode('
', $errors); - $message = sprintf(_CO_PUBLISHER_MESSAGE_FILE_ERROR, $errorstxt); + $message = sprintf(_CO_PUBLISHER_MESSAGE_FILE_ERROR, $errorstxt); redirect_header(Request::getString('backto', '', 'POST'), 5, $message); } @@ -46,11 +45,11 @@ 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'); - $maxImageWidth = $helper->getConfig('maximum_image_width'); + $maxFileSize = $helper->getConfig('maximum_filesize'); + $maxImageWidth = $helper->getConfig('maximum_image_width'); $maxImageHeight = $helper->getConfig('maximum_image_height'); if (!is_dir(Publisher\Utility::getUploadDir(true, 'content'))) { @@ -59,7 +58,7 @@ function publisher_pagewrap_upload(&$errors) } } $allowedMimeTypes = ['text/html', 'text/plain', 'application/xhtml+xml']; - $uploader = new \XoopsMediaUploader(Publisher\Utility::getUploadDir(true, 'content') . '/', $allowedMimeTypes, $maxFileSize, $maxImageWidth, $maxImageHeight); + $uploader = new \XoopsMediaUploader(Publisher\Utility::getUploadDir(true, 'content') . '/', $allowedMimeTypes, $maxFileSize, $maxImageWidth, $maxImageHeight); if ($uploader->fetchMedia($postField)) { $uploader->setTargetFileName($uploader->getMediaName()); if ($uploader->upload()) { diff --git a/archive.php b/archive.php index 5c22c441..e7d77fc2 100644 --- a/archive.php +++ b/archive.php @@ -14,7 +14,6 @@ /** * @copyright The XUUPS Project http://sourceforge.net/projects/xuups/ * @license http://www.fsf.org/copyleft/gpl.html GNU public license - * @package Publisher * @since 1.0 * @author Bandit-X * @author trabis @@ -35,24 +34,24 @@ xoops_loadLanguage('calendar'); //mb xoops_load('XoopsLocal'); -$lastyear = 0; -$lastmonth = 0; +$lastyear = 0; +$lastmonth = 0; $monthsArray = [ - 1 => _CAL_JANUARY, - 2 => _CAL_FEBRUARY, - 3 => _CAL_MARCH, - 4 => _CAL_APRIL, - 5 => _CAL_MAY, - 6 => _CAL_JUNE, - 7 => _CAL_JULY, - 8 => _CAL_AUGUST, - 9 => _CAL_SEPTEMBER, + 1 => _CAL_JANUARY, + 2 => _CAL_FEBRUARY, + 3 => _CAL_MARCH, + 4 => _CAL_APRIL, + 5 => _CAL_MAY, + 6 => _CAL_JUNE, + 7 => _CAL_JULY, + 8 => _CAL_AUGUST, + 9 => _CAL_SEPTEMBER, 10 => _CAL_OCTOBER, 11 => _CAL_NOVEMBER, 12 => _CAL_DECEMBER, ]; -$fromyear = Request::getInt('year'); -$frommonth = Request::getInt('month'); +$fromyear = Request::getInt('year'); +$frommonth = Request::getInt('month'); $pgtitle = ''; if ($fromyear && $frommonth) { @@ -86,30 +85,30 @@ $criteria->setSort('datesub'); $criteria->setOrder('DESC'); //Get all articles dates as an array to save memory -$items = $helper->getHandler('Item')->getAll($criteria, ['datesub'], false); +$items = $helper->getHandler('Item')->getAll($criteria, ['datesub'], false); $itemsCount = count($items); if (!($itemsCount > 0)) { redirect_header(XOOPS_URL, 2, _MD_PUBLISHER_NO_TOP_PERMISSIONS); } else { - $years = []; + $years = []; $months = []; - $i = 0; + $i = 0; foreach ($items as $item) { //mb $time = \XoopsLocal::formatTimestamp($item['datesub'], 'mysql', $useroffset); $time = formatTimestamp($item['datesub'], 'mysql', $useroffset); if (preg_match('/(\d{4})-(\d{1,2})-(\d{1,2}) (\d{1,2}):(\d{1,2}):(\d{1,2})/', $time, $datetime)) { - $thisYear = (int)$datetime[1]; + $thisYear = (int)$datetime[1]; $thisMonth = (int)$datetime[2]; //first year if (empty($lastyear)) { - $lastyear = $thisYear; - $articlesThisYear = 0; + $lastyear = $thisYear; + $articlesThisYear = 0; $articlesThisMonth = 0; } //first month of the year reset if (0 == $lastmonth) { - $lastmonth = $thisMonth; + $lastmonth = $thisMonth; $months[$lastmonth]['string'] = $monthsArray[$lastmonth]; $months[$lastmonth]['number'] = $lastmonth; // $months[$lastmonth]['articlesMonthCount'] = 1; @@ -122,10 +121,10 @@ $years[$i]['articlesYearCount'] = $articlesThisYear; - $months = []; - $lastmonth = 0; - $lastyear = $thisYear; - $articlesThisYear = 0; + $months = []; + $lastmonth = 0; + $lastyear = $thisYear; + $articlesThisYear = 0; $articlesThisMonth = 0; ++$i; } @@ -134,11 +133,11 @@ if ($articlesThisMonth > 0) { $months[$lastmonth]['articlesMonthCount'] = $articlesThisMonth; } - $lastmonth = $thisMonth; - $months[$lastmonth]['string'] = $monthsArray[$lastmonth]; - $months[$lastmonth]['number'] = $lastmonth; + $lastmonth = $thisMonth; + $months[$lastmonth]['string'] = $monthsArray[$lastmonth]; + $months[$lastmonth]['number'] = $lastmonth; $months[$lastmonth]['articlesMonthCount'] = 1; - $articlesThisMonth = 0; + $articlesThisMonth = 0; } ++$articlesThisMonth; @@ -163,29 +162,29 @@ $xoopsTpl->assign('lang_actions', _MD_PUBLISHER_ACTIONS); $xoopsTpl->assign('lang_date', _MD_PUBLISHER_DATE); $xoopsTpl->assign('lang_views', _MD_PUBLISHER_HITS); - $xoopsTpl->assign('lang_category', _MD_PUBLISHER_CATEGORY); + $xoopsTpl->assign('lang_category', _MD_PUBLISHER_CATEGORY); $xoopsTpl->assign('lang_author', _MD_PUBLISHER_AUTHOR); - + // must adjust the selected time to server timestamp $timeoffset = $useroffset - $GLOBALS['xoopsConfig']['server_TZ']; $timeoffsethours = (int)$timeoffset; $timeoffsetminutes = intval(($timeoffset - $timeoffsethours) * 60); $monthstart = mktime(0 - $timeoffsethours, 0 - $timeoffsetminutes, 0, $frommonth, 1, $fromyear); - $monthend = mktime(23 - $timeoffsethours, 59 - $timeoffsetminutes, 59, $frommonth + 1, 0, $fromyear); + $monthend = mktime(23 - $timeoffsethours, 59 - $timeoffsetminutes, 59, $frommonth + 1, 0, $fromyear); - $monthend = ($monthend > time()) ? time() : $monthend; + $monthend = ($monthend > time()) ? time() : $monthend; $count = 0; - $itemHandler = $helper->getHandler('Item'); - $itemHandler->table_link = $GLOBALS['xoopsDB']->prefix($helper->getDirname() . '_categories'); - $itemHandler->field_link = 'categoryid'; + $itemHandler = $helper->getHandler('Item'); + $itemHandler->table_link = $GLOBALS['xoopsDB']->prefix($helper->getDirname() . '_categories'); + $itemHandler->field_link = 'categoryid'; $itemHandler->field_object = 'categoryid'; // Categories for which user has access $categoriesGranted = $helper->getHandler('Permission')->getGrantedItems('category_read'); $grantedCategories = new \Criteria('l.categoryid', '(' . implode(',', $categoriesGranted) . ')', 'IN'); - $criteria = new \CriteriaCompo(); + $criteria = new \CriteriaCompo(); $criteria->add($grantedCategories, 'AND'); $criteria->add(new \Criteria('o.status', 2), 'AND'); $critdatesub = new \CriteriaCompo(); @@ -202,34 +201,34 @@ /** @var \XoopsModules\Publisher\Item $item */ foreach ($storyarray as $item) { - $story = []; - $htmltitle = ''; - $story['title'] = "' . $item->getTitle() . ''; + $story = []; + $htmltitle = ''; + $story['title'] = "' . $item->getTitle() . ''; $story['cleantitle'] = strip_tags($item->getTitle()); - $story['itemurl'] = $item->getItemUrl(); - $story['category'] = "" . $item->getCategoryName() . ''; - $story['counter'] = $item->counter(); - $story['date'] = $item->getDatesub(); + $story['itemurl'] = $item->getItemUrl(); + $story['category'] = "" . $item->getCategoryName() . ''; + $story['counter'] = $item->counter(); + $story['date'] = $item->getDatesub(); $story['print_link'] = XOOPS_URL . '/modules/' . PUBLISHER_DIRNAME . '/print.php?itemid=' . $item->itemid(); - $story['mail_link'] = 'mailto:?subject=' . sprintf(_CO_PUBLISHER_INTITEM, $GLOBALS['xoopsConfig']['sitename']) . '&body=' . sprintf(_CO_PUBLISHER_INTITEMFOUND, $GLOBALS['xoopsConfig']['sitename']) . ': ' . $item->getItemUrl(); - $story['pdf_link'] = XOOPS_URL . '/modules/' . PUBLISHER_DIRNAME . '/makepdf.php?itemid=' . $item->itemid(); - $story['author'] = $item->getWho(); - $story['summary'] = $item->getSummary(); + $story['mail_link'] = 'mailto:?subject=' . sprintf(_CO_PUBLISHER_INTITEM, $GLOBALS['xoopsConfig']['sitename']) . '&body=' . sprintf(_CO_PUBLISHER_INTITEMFOUND, $GLOBALS['xoopsConfig']['sitename']) . ': ' . $item->getItemUrl(); + $story['pdf_link'] = XOOPS_URL . '/modules/' . PUBLISHER_DIRNAME . '/makepdf.php?itemid=' . $item->itemid(); + $story['author'] = $item->getWho(); + $story['summary'] = $item->getSummary(); $story['cancomment'] = $item->cancomment(); - - $mainImage = $item->getMainImage(); - if (empty($mainImage['image_path'])) { - $mainImage['image_path'] = PUBLISHER_URL . '/assets/images/default_image.jpg'; - } - //check to see if GD function exist + + $mainImage = $item->getMainImage(); + if (empty($mainImage['image_path'])) { + $mainImage['image_path'] = PUBLISHER_URL . '/assets/images/default_image.jpg'; + } + //check to see if GD function exist if (!empty($mainImage['image_path']) && !function_exists('imagecreatetruecolor')) { - $story['item_image'] = $mainImage['path']; + $story['item_image'] = $mainImage['path']; } else { - $story['item_image'] = PUBLISHER_URL . '/thumb.php?src=' . $mainImage['image_path'] . ''; - $story['image_path'] = $mainImage['image_path']; - } - - $comments = $item->comments(); + $story['item_image'] = PUBLISHER_URL . '/thumb.php?src=' . $mainImage['image_path'] . ''; + $story['image_path'] = $mainImage['image_path']; + } + + $comments = $item->comments(); if ($comments > 0) { //shows 1 comment instead of 1 comm. if comments ==1 //langugage file modified accordingly @@ -239,11 +238,11 @@ $story['comment'] = ' ' . $comments . ' ' . _MD_PUBLISHER_COMMENTS . ' '; } } else { - $story['comment'] = ' ' . _MD_PUBLISHER_NO_COMMENTS . ' '; + $story['comment'] = ' ' . _MD_PUBLISHER_NO_COMMENTS . ' '; } $xoopsTpl->append('stories', $story); } - //unset($item); + //unset($item); } $xoopsTpl->assign('lang_printer', _MD_PUBLISHER_PRINTERFRIENDLY); $xoopsTpl->assign('lang_sendstory', _MD_PUBLISHER_SENDSTORY); @@ -251,7 +250,7 @@ } else { $xoopsTpl->assign('show_articles', false); } - + $xoopsTpl->assign('lang_newsarchives', _MD_PUBLISHER_ARCHIVES); require_once $GLOBALS['xoops']->path('footer.php'); diff --git a/author_items.php b/author_items.php index d4698f8f..ec7c67b4 100644 --- a/author_items.php +++ b/author_items.php @@ -14,8 +14,6 @@ /** * @copyright The XUUPS Project http://sourceforge.net/projects/xuups/ * @license http://www.fsf.org/copyleft/gpl.html GNU public license - * @package Publisher - * @subpackage Action * @since 1.0 * @author trabis */ @@ -33,7 +31,7 @@ /** @var \XoopsMemberHandler $memberHandler */ $memberHandler = xoops_getHandler('member'); -$thisuser = $memberHandler->getUser($uid); +$thisuser = $memberHandler->getUser($uid); if (!is_object($thisuser)) { redirect_header('index.php', 2, _CO_PUBLISHER_ERROR); } @@ -71,54 +69,52 @@ if (!isset($categories[$catId])) { $categories[$catId] = [ 'count_items' => 0, - 'count_hits' => 0, - 'title' => $item->getCategoryName(), - 'link' => $item->getCategoryLink(), + 'count_hits' => 0, + 'title' => $item->getCategoryName(), + 'link' => $item->getCategoryLink(), ]; } //mb start - $mainImage = $item->getMainImage(); - if (empty($mainImage['image_path'])) { + $mainImage = $item->getMainImage(); + if (empty($mainImage['image_path'])) { $mainImage['image_path'] = PUBLISHER_URL . '/assets/images/default_image.jpg'; - } + } // check to see if GD function exist if (!empty($mainImage['image_path']) && !function_exists('imagecreatetruecolor')) { $image = $mainImage['image_path']; } else { - $image = PUBLISHER_URL . '/thumb.php?src=' . $mainImage['image_path'] . ''; - } + $image = PUBLISHER_URL . '/thumb.php?src=' . $mainImage['image_path'] . ''; + } //mb end - $comments = $item->comments(); - if ($comments > 0) { - //shows 1 comment instead of 1 comm. if comments ==1 - //langugage file modified accordingly - if (1 == $comments) { - $comment = ' ' . _MB_PUBLISHER_ONECOMMENT . ' '; - } else { - $comment = ' ' . $comments . ' ' . _MB_PUBLISHER_COMMENTS . ' '; - } + $comments = $item->comments(); + if ($comments > 0) { + //shows 1 comment instead of 1 comm. if comments ==1 + //langugage file modified accordingly + if (1 == $comments) { + $comment = ' ' . _MB_PUBLISHER_ONECOMMENT . ' '; } else { - $comment = ' ' . _MB_PUBLISHER_NO_COMMENTS . ' '; + $comment = ' ' . $comments . ' ' . _MB_PUBLISHER_COMMENTS . ' '; } - - - + } else { + $comment = ' ' . _MB_PUBLISHER_NO_COMMENTS . ' '; + } + $categories[$catId]['count_items']++; $categories[$catId]['count_hits'] += $item->counter(); - $categories[$catId]['items'][] = [ - 'title' => $item->getTitle(), - 'cleantitle'=> strip_tags($item->getTitle()), - 'itemurl' => $item->getItemUrl(), - 'summary' => $item->getSummary(), - 'comment' => $comment, - 'cancomment'=> $item->cancomment(), - 'hits' => $item->counter(), - 'link' => $item->getItemLink(), + $categories[$catId]['items'][] = [ + 'title' => $item->getTitle(), + 'cleantitle' => strip_tags($item->getTitle()), + 'itemurl' => $item->getItemUrl(), + 'summary' => $item->getSummary(), + 'comment' => $comment, + 'cancomment' => $item->cancomment(), + 'hits' => $item->counter(), + 'link' => $item->getItemLink(), 'published' => $item->getDatesub(), //'published' => $item->getDatesub(_SHORTDATESTRING), //'rating' => $xoopsLocal->number_format((float)$item->rating()) - 'rating' => $item->rating(), - 'image' => $image, + 'rating' => $item->rating(), + 'image' => $image, ]; } } diff --git a/backend.php b/backend.php index 24846f9e..57c86d08 100644 --- a/backend.php +++ b/backend.php @@ -14,15 +14,12 @@ /** * @copyright The XUUPS Project http://sourceforge.net/projects/xuups/ * @license http://www.fsf.org/copyleft/gpl.html GNU public license - * @package Publisher - * @subpackage Action * @since 1.0 * @author trabis * @author The SmartFactory */ use Xmf\Request; -use XoopsModules\Publisher; require_once __DIR__ . '/header.php'; //xoops_load('XoopsLocal'); //mb @@ -42,7 +39,7 @@ } header('Content-Type:text/xml; charset=' . _CHARSET); -$tpl = new \XoopsTpl(); +$tpl = new \XoopsTpl(); $tpl->caching = 2; //$tpl->xoops_setCacheTime(0); $tpl->cache_lifetime = 0; @@ -53,8 +50,8 @@ // Check if ML Hack is installed, and if yes, parse the $content in formatForML if (method_exists($myts, 'formatForML')) { $GLOBALS['xoopsConfig']['sitename'] = $myts->formatForML($GLOBALS['xoopsConfig']['sitename']); - $GLOBALS['xoopsConfig']['slogan'] = $myts->formatForML($GLOBALS['xoopsConfig']['slogan']); - $channel_category = $myts->formatForML($channel_category); + $GLOBALS['xoopsConfig']['slogan'] = $myts->formatForML($GLOBALS['xoopsConfig']['slogan']); + $channel_category = $myts->formatForML($channel_category); } $tpl->assign('channel_charset', _CHARSET); $tpl->assign('channel_title', htmlspecialchars($GLOBALS['xoopsConfig']['sitename'], ENT_QUOTES | ENT_HTML5)); @@ -75,12 +72,12 @@ $tpl->assign('image_url', XOOPS_URL . '/images/logo.png'); $dimension = getimagesize($GLOBALS['xoops']->path('images/logo.png')); if (empty($dimension[0])) { - $width = 140; + $width = 140; $height = 140; } else { - $width = ($dimension[0] > 140) ? 140 : $dimension[0]; + $width = ($dimension[0] > 140) ? 140 : $dimension[0]; $dimension[1] = $dimension[1] * $width / $dimension[0]; - $height = ($dimension[1] > 140) ? $dimension[1] * $dimension[0] / 140 : $dimension[1]; + $height = ($dimension[1] > 140) ? $dimension[1] * $dimension[0] / 140 : $dimension[1]; } $height = round($height, 0, PHP_ROUND_HALF_UP); $tpl->assign('image_width', $width); @@ -92,11 +89,11 @@ $tpl->append( 'items', [ - 'title' => htmlspecialchars($item->getTitle(), ENT_QUOTES | ENT_HTML5), - 'link' => htmlspecialchars($item->getItemUrl(), ENT_QUOTES | ENT_HTML5), - 'guid' => $item->getItemUrl(), + 'title' => htmlspecialchars($item->getTitle(), ENT_QUOTES | ENT_HTML5), + 'link' => htmlspecialchars($item->getItemUrl(), ENT_QUOTES | ENT_HTML5), + 'guid' => $item->getItemUrl(), //mb 'pubdate' => XoopsLocal::formatTimestamp($item->getVar('datesub'), 'rss'), - 'pubdate' => formatTimestamp($item->getVar('datesub'), 'rss'), + 'pubdate' => formatTimestamp($item->getVar('datesub'), 'rss'), 'description' => htmlspecialchars($item->getBlockSummary(300, true), ENT_QUOTES | ENT_HTML5), ] ); diff --git a/blocks/category_items_sel.php b/blocks/category_items_sel.php index 98e42e05..9a5b3807 100644 --- a/blocks/category_items_sel.php +++ b/blocks/category_items_sel.php @@ -14,8 +14,6 @@ /** * @copyright The XUUPS Project http://sourceforge.net/projects/xuups/ * @license http://www.fsf.org/copyleft/gpl.html GNU public license - * @package Publisher - * @subpackage Blocks * @since 1.0 * @author trabis */ @@ -23,8 +21,6 @@ use XoopsModules\Publisher; use XoopsModules\Publisher\Constants; - - require_once dirname(__DIR__) . '/include/common.php'; /** @@ -41,22 +37,22 @@ function publisher_category_items_sel_show($options) /** @var Publisher\CategoryHandler $categoryHandler */ $categoryHandler = $helper->getHandler('Category'); - $categories = $categoryHandler->getCategories(0, 0, -1); + $categories = $categoryHandler->getCategories(0, 0, -1); if (0 === count($categories)) { return $block; } $selectedcatids = explode(',', $options[0]); - $sort = $options[1]; - $order = Publisher\Utility::getOrderBy($sort); - $limit = $options[2]; - $start = 0; + $sort = $options[1]; + $order = Publisher\Utility::getOrderBy($sort); + $limit = $options[2]; + $start = 0; // creating the ITEM objects that belong to the selected category $block['categories'] = []; foreach ($categories as $catId => $catObj) { - if (!in_array(0, $selectedcatids) && !in_array($catId, $selectedcatids)) { + if (!in_array(0, $selectedcatids, true) && !in_array($catId, $selectedcatids, true)) { continue; } @@ -81,13 +77,13 @@ function publisher_category_items_sel_show($options) continue; } - $item['title'] = $catObj->name(); - $item['itemurl'] = 'none'; + $item['title'] = $catObj->name(); + $item['itemurl'] = 'none'; $block['categories'][$catId]['items'][] = $item; foreach ($items[''] as $itemObj) { - $item['title'] = $itemObj->getTitle($options[3] ?? 0); - $item['itemurl'] = $itemObj->getItemUrl(); + $item['title'] = $itemObj->getTitle($options[3] ?? 0); + $item['itemurl'] = $itemObj->getItemUrl(); $block['categories'][$catId]['items'][] = $item; } $block['categories'][$catId]['name'] = $catObj->name(); @@ -114,16 +110,16 @@ function publisher_category_items_sel_edit($options) $form = new Publisher\BlockForm(); - $catEle = new \XoopsFormLabel(_MB_PUBLISHER_SELECTCAT, Publisher\Utility::createCategorySelect($options[0]), 'options[0]'); + $catEle = new \XoopsFormLabel(_MB_PUBLISHER_SELECTCAT, Publisher\Utility::createCategorySelect($options[0]), 'options[0]'); $orderEle = new \XoopsFormSelect(_MB_PUBLISHER_ORDER, 'options[1]', $options[1]); $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]); + $dispEle = new \XoopsFormText(_MB_PUBLISHER_DISP, 'options[2]', 10, 255, $options[2]); $charsEle = new \XoopsFormText(_MB_PUBLISHER_CHARS, 'options[3]', 10, 255, $options[3]); $form->addElement($catEle); diff --git a/blocks/date_to_date.php b/blocks/date_to_date.php index 2abf5e6d..eff45573 100644 --- a/blocks/date_to_date.php +++ b/blocks/date_to_date.php @@ -14,8 +14,6 @@ /** * @copyright The XUUPS Project http://sourceforge.net/projects/xuups/ * @license http://www.fsf.org/copyleft/gpl.html GNU public license - * @package Publisher - * @subpackage Blocks * @since 1.0 * @author trabis * @author The SmartFactory @@ -23,8 +21,6 @@ use XoopsModules\Publisher; - - require_once dirname(__DIR__) . '/include/common.php'; /** @@ -49,28 +45,28 @@ function publisher_date_to_date_show($options) // creating the ITEM objects that belong to the selected category /** @var Publisher\ItemHandler $itemHandler */ $itemHandler = $helper->getHandler('Item'); - $itemsObj = $itemHandler->getObjects($criteria); + $itemsObj = $itemHandler->getObjects($criteria); // $totalItems = count($itemsObj); if ($itemsObj && is_array($itemsObj)) { foreach ($itemsObj as $iValue) { - $newItems['itemid'] = $iValue->itemid(); - $newItems['title'] = $iValue->getTitle(); + $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, $options[3] ?? 65); + $newItems['categoryid'] = $iValue->categoryid(); + $newItems['date'] = $iValue->getDatesub(); + $newItems['poster'] = $iValue->getLinkedPosterName(); + $newItems['itemlink'] = $iValue->getItemLink(false, $options[3] ?? 65); $newItems['categorylink'] = $iValue->getCategoryLink(); - $block['items'][] = $newItems; + $block['items'][] = $newItems; } - $block['lang_title'] = _MB_PUBLISHER_ITEMS; - $block['lang_category'] = _MB_PUBLISHER_CATEGORY; - $block['lang_poster'] = _MB_PUBLISHER_POSTEDBY; - $block['lang_date'] = _MB_PUBLISHER_DATE; - $moduleName = $myts->displayTarea($helper->getModule()->getVar('name')); - $block['lang_visitItem'] = _MB_PUBLISHER_VISITITEM . ' ' . $moduleName; + $block['lang_title'] = _MB_PUBLISHER_ITEMS; + $block['lang_category'] = _MB_PUBLISHER_CATEGORY; + $block['lang_poster'] = _MB_PUBLISHER_POSTEDBY; + $block['lang_date'] = _MB_PUBLISHER_DATE; + $moduleName = $myts->displayTarea($helper->getModule()->getVar('name')); + $block['lang_visitItem'] = _MB_PUBLISHER_VISITITEM . ' ' . $moduleName; $block['lang_articles_from_to'] = sprintf(_MB_PUBLISHER_ARTICLES_FROM_TO, $options[0], $options[1] ?? 0); } @@ -92,7 +88,7 @@ function publisher_date_to_date_edit($options) $options[0] = formatTimestamp(1424860422); } - $form = new Publisher\BlockForm(); + $form = new Publisher\BlockForm(); $fromEle = new \XoopsFormTextDateSelect(_MB_PUBLISHER_FROM, 'options[0]', 15, strtotime($options[0])); // $fromEle->setNocolspan(); $untilEle = new \XoopsFormTextDateSelect(_MB_PUBLISHER_UNTIL, 'options[1]', 15, isset($options[1]) ? strtotime($options[1]) : ''); diff --git a/blocks/items_columns.php b/blocks/items_columns.php index a42786db..72681b13 100644 --- a/blocks/items_columns.php +++ b/blocks/items_columns.php @@ -14,8 +14,6 @@ /** * @copyright The XUUPS Project http://sourceforge.net/projects/xuups/ * @license http://www.fsf.org/copyleft/gpl.html GNU public license - * @package Publisher - * @subpackage Blocks * @since 1.0 * @author trabis * @author Bandit-x @@ -23,8 +21,6 @@ use XoopsModules\Publisher; - - require_once dirname(__DIR__) . '/include/common.php'; /*** @@ -44,13 +40,13 @@ function publisher_items_columns_show($options) /** @var Publisher\ItemHandler $itemHandler */ $itemHandler = $helper->getHandler('Item'); //Column Settings - $optNumColumns = isset($options[0]) ? (int)$options[0] : '2'; - $selCategories = isset($options[1]) ? explode(',', $options[1]) : []; - $optCatItems = (int)$options[2]; + $optNumColumns = isset($options[0]) ? (int)$options[0] : '2'; + $selCategories = isset($options[1]) ? explode(',', $options[1]) : []; + $optCatItems = (int)$options[2]; $optCatTruncate = isset($options[3]) ? (int)$options[3] : '0'; - $block = []; - $block['lang_reads'] = _MB_PUBLISHER_READS; + $block = []; + $block['lang_reads'] = _MB_PUBLISHER_READS; $block['lang_comments'] = _MB_PUBLISHER_COMMENTS; $block['lang_readmore'] = _MB_PUBLISHER_READMORE; @@ -60,9 +56,9 @@ function publisher_items_columns_show($options) $categoriesObj = $categoryHandler->getCategories(0, 0, -1); //if not selected 'all', let's get the selected ones - if (!in_array(0, $selCategories)) { + if (!in_array(0, $selCategories, true)) { foreach ($categoriesObj as $key => $value) { - if (in_array($key, $selCategories)) { + if (in_array($key, $selCategories, true)) { $selCategoriesObj[$key] = $value; } } @@ -81,27 +77,27 @@ function publisher_items_columns_show($options) $optNumColumns = $ccount; } - $k = 0; + $k = 0; $columns = $mainItem = $subItem = []; foreach ($selCategoriesObj as $categoryId => $mainItemCatObj) { $categoryItemsObj = $itemHandler->getAllPublished($optCatItems, 0, $categoryId); - $scount = count($categoryItemsObj); + $scount = count($categoryItemsObj); if ($scount > 0 && is_array($categoryItemsObj)) { reset($categoryItemsObj); //First Item $thisItem = array_values($categoryItemsObj)[0]; - $mainItem['item_title'] = $thisItem->getTitle(); + $mainItem['item_title'] = $thisItem->getTitle(); $mainItem['item_cleantitle'] = strip_tags($thisItem->getTitle()); - $mainItem['item_link'] = $thisItem->itemid(); - $mainItem['itemurl'] = $thisItem->getItemUrl(); - $mainItem['date'] = $thisItem->getDatesub(); + $mainItem['item_link'] = $thisItem->itemid(); + $mainItem['itemurl'] = $thisItem->getItemUrl(); + $mainItem['date'] = $thisItem->getDatesub(); - $mainImage = $thisItem->getMainImage(); + $mainImage = $thisItem->getMainImage(); if (empty($mainImage['image_path'])) { - $mainImage['image_path'] = PUBLISHER_URL . '/assets/images/default_image.jpg'; - } + $mainImage['image_path'] = PUBLISHER_URL . '/assets/images/default_image.jpg'; + } // check to see if GD function exist $mainItem['item_image'] = $mainImage['image_path']; if (!empty($mainImage['image_path']) && function_exists('imagecreatetruecolor')) { @@ -111,22 +107,22 @@ function publisher_items_columns_show($options) $mainItem['item_summary'] = $thisItem->getBlockSummary($optCatTruncate); - $mainItem['item_cat_name'] = $mainItemCatObj->name(); + $mainItem['item_cat_name'] = $mainItemCatObj->name(); $mainItem['item_cat_description'] = '' !== $mainItemCatObj->description() ? $mainItemCatObj->description() : $mainItemCatObj->name(); - $mainItem['item_cat_link'] = $mainItemCatObj->getCategoryLink(); - $mainItem['categoryurl'] = $mainItemCatObj->getCategoryUrl(); + $mainItem['item_cat_link'] = $mainItemCatObj->getCategoryLink(); + $mainItem['categoryurl'] = $mainItemCatObj->getCategoryUrl(); //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? - $subItem['title'] = $thisItem->getTitle(); + $subItem['title'] = $thisItem->getTitle(); $subItem['cleantitle'] = strip_tags($thisItem->getTitle()); - $subItem['link'] = $thisItem->getItemLink(); - $subItem['itemurl'] = $thisItem->getItemUrl(); - $subItem['summary'] = $thisItem->getBlockSummary($optCatTruncate); - $subItem['date'] = $thisItem->getDatesub(); + $subItem['link'] = $thisItem->getItemLink(); + $subItem['itemurl'] = $thisItem->getItemUrl(); + $subItem['summary'] = $thisItem->getBlockSummary($optCatTruncate); + $subItem['date'] = $thisItem->getDatesub(); $mainItem['subitem'][] = $subItem; unset($subItem); } @@ -142,11 +138,11 @@ function publisher_items_columns_show($options) } unset($categoryId, $mainItemCatObj); - $block['template'] = $options[4]; - $block['columns'] = $columns; - $block['columnwidth'] = (int)(100 / $optNumColumns); + $block['template'] = $options[4]; + $block['columns'] = $columns; + $block['columnwidth'] = (int)(100 / $optNumColumns); $block['display_datemainitem'] = $options[5] ?? ''; - $block['display_datesubitem'] = $options[6] ?? ''; + $block['display_datesubitem'] = $options[6] ?? ''; $GLOBALS['xoTheme']->addStylesheet(XOOPS_URL . '/modules/' . PUBLISHER_DIRNAME . '/assets/css/publisher.css'); @@ -165,7 +161,7 @@ function publisher_items_columns_edit($options) // require_once PUBLISHER_ROOT_PATH . '/class/blockform.php'; xoops_load('XoopsFormLoader'); - $form = new Publisher\BlockForm(); + $form = new Publisher\BlockForm(); $colEle = new \XoopsFormSelect(_MB_PUBLISHER_NUMBER_COLUMN_VIEW, 'options[0]', $options[0]); $colEle->addOptionArray( [ @@ -176,27 +172,28 @@ function publisher_items_columns_edit($options) '5' => 5, ] ); - $catEle = new \XoopsFormLabel(_MB_PUBLISHER_SELECTCAT, Publisher\Utility::createCategorySelect($options[1], 0, true, 'options[1]')); + $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]); + $cItemsEle = new \XoopsFormText(_MB_PUBLISHER_NUMBER_ITEMS_CAT, 'options[2]', 4, 255, $options[2]); $truncateEle = new \XoopsFormText(_MB_PUBLISHER_TRUNCATE, 'options[3]', 4, 255, $options[3]); $tempEle = new \XoopsFormSelect(_MB_PUBLISHER_TEMPLATE, 'options[4]', $options[4]); $tempEle->addOptionArray( [ - 'normal' => _MB_PUBLISHER_TEMPLATE_NORMAL, + 'normal' => _MB_PUBLISHER_TEMPLATE_NORMAL, 'extended' => _MB_PUBLISHER_TEMPLATE_EXTENDED, ]); $dateMain = new \XoopsFormRadioYN(_MB_PUBLISHER_DISPLAY_DATE_MAINITEM, 'options[5]', $options[5]); - $dateSub = new \XoopsFormRadioYN(_MB_PUBLISHER_DISPLAY_DATE_SUBITEM, 'options[6]', $options[6]); + $dateSub = new \XoopsFormRadioYN(_MB_PUBLISHER_DISPLAY_DATE_SUBITEM, 'options[6]', $options[6]); $form->addElement($colEle); $form->addElement($catEle); $form->addElement($cItemsEle); $form->addElement($truncateEle); $form->addElement($tempEle); - $form->addElement($dateMain); - $form->addElement($dateSub); + $form->addElement($dateMain); + $form->addElement($dateSub); + return $form->render(); } diff --git a/blocks/items_menu.php b/blocks/items_menu.php index b5a92ef8..f9ee8e15 100644 --- a/blocks/items_menu.php +++ b/blocks/items_menu.php @@ -14,8 +14,6 @@ /** * @copyright The XUUPS Project http://sourceforge.net/projects/xuups/ * @license http://www.fsf.org/copyleft/gpl.html GNU public license - * @package Publisher - * @subpackage Blocks * @since 1.0 * @author trabis * @author The SmartFactory @@ -24,8 +22,6 @@ use Xmf\Request; use XoopsModules\Publisher; - - require_once dirname(__DIR__) . '/include/common.php'; /** @@ -42,7 +38,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)) { @@ -64,7 +60,7 @@ function publisher_items_menu_show($options) // if we are in a category, then the $categoryObj is already defined in publisher/category.php global $categoryObj; $block['currentcat'] = $categoryObj->getCategoryLink('menuTop'); - $catLinkClass = 'menuSub'; + $catLinkClass = 'menuSub'; } } @@ -89,13 +85,13 @@ function publisher_items_menu_edit($options) $form = new Publisher\BlockForm(); - $catEle = new \XoopsFormLabel(_MB_PUBLISHER_SELECTCAT, Publisher\Utility::createCategorySelect($options[0], 0, true, 'options[0]')); + $catEle = new \XoopsFormLabel(_MB_PUBLISHER_SELECTCAT, Publisher\Utility::createCategorySelect($options[0], 0, true, 'options[0]')); $orderEle = new \XoopsFormSelect(_MB_PUBLISHER_ORDER, 'options[1]', $options[1]); $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 27edcfd1..3053e466 100644 --- a/blocks/items_new.php +++ b/blocks/items_new.php @@ -14,8 +14,6 @@ /** * @copyright The XUUPS Project http://sourceforge.net/projects/xuups/ * @license http://www.fsf.org/copyleft/gpl.html GNU public license - * @package Publisher - * @subpackage Blocks * @since 1.0 * @author trabis * @author The SmartFactory @@ -24,8 +22,6 @@ use XoopsModules\Publisher; use XoopsModules\Publisher\Constants; - - require_once dirname(__DIR__) . '/include/common.php'; /** @@ -42,13 +38,13 @@ function publisher_items_new_show($options) $selectedcatids = explode(',', $options[0]); - $block = []; + $block = []; $allcats = false; - if (in_array(0, $selectedcatids)) { + if (in_array(0, $selectedcatids, true)) { $allcats = true; } - $sort = $options[1]; + $sort = $options[1]; $order = Publisher\Utility::getOrderBy($sort); $limit = $options[3]; $start = 0; @@ -62,14 +58,14 @@ function publisher_items_new_show($options) $criteria->add(new \Criteria('categoryid', '(' . $options[0] . ')', 'IN')); } - $publisherIsAdmin = $helper->isUserAdmin(); - if (!$publisherIsAdmin) { - if (null === $criteria) { - $criteria = new \CriteriaCompo(); - } - $criteriaDateSub = new \Criteria('datesub', time(), '<='); - $criteria->add($criteriaDateSub); + $publisherIsAdmin = $helper->isUserAdmin(); + if (!$publisherIsAdmin) { + if (null === $criteria) { + $criteria = new \CriteriaCompo(); } + $criteriaDateSub = new \Criteria('datesub', time(), '<='); + $criteria->add($criteriaDateSub); + } // $optCatItems = (int)$options[2]; // $categoryId = -1; @@ -80,24 +76,24 @@ function publisher_items_new_show($options) $totalitems = count($itemsObj); if ($totalitems > 0) { foreach ($itemsObj as $iValue) { - $item = []; - $item['itemurl']= $iValue->getItemUrl(); - $item['link'] = $iValue->getItemLink(false, $options[4] ?? 65); - $item['id'] = $iValue->itemid(); + $item = []; + $item['itemurl'] = $iValue->getItemUrl(); + $item['link'] = $iValue->getItemLink(false, $options[4] ?? 65); + $item['id'] = $iValue->itemid(); $item['poster'] = $iValue->posterName(); // for make poster name linked, use getLinkedPosterName() instead of posterName() - $item['categorylink'] = $iValue->getCategoryLink(); - $item['date'] = $iValue->getDatesub(); - $item['hits'] = $iValue->counter(); - $item['summary'] = $iValue->getBlockSummary(300, true); //show complete summary but truncate to 300 if only body available - $item['rating'] = $iValue->rating(); + $item['categorylink'] = $iValue->getCategoryLink(); + $item['date'] = $iValue->getDatesub(); + $item['hits'] = $iValue->counter(); + $item['summary'] = $iValue->getBlockSummary(300, true); //show complete summary but truncate to 300 if only body available + $item['rating'] = $iValue->rating(); $item['votes'] = $iValue->votes(); - $item['lang_fullitem'] = _MB_PUBLISHER_FULLITEM; - $item['lang_poster'] = _MB_PUBLISHER_POSTEDBY; - $item['lang_date'] = _MB_PUBLISHER_ON; - $item['lang_category'] = _MB_PUBLISHER_CATEGORY; - $item['lang_hits'] = _MB_PUBLISHER_TOTALHITS; - $item['cancomment'] = $iValue->cancomment(); - $comments = $iValue->comments(); + $item['lang_fullitem'] = _MB_PUBLISHER_FULLITEM; + $item['lang_poster'] = _MB_PUBLISHER_POSTEDBY; + $item['lang_date'] = _MB_PUBLISHER_ON; + $item['lang_category'] = _MB_PUBLISHER_CATEGORY; + $item['lang_hits'] = _MB_PUBLISHER_TOTALHITS; + $item['cancomment'] = $iValue->cancomment(); + $comments = $iValue->comments(); if ($comments > 0) { //shows 1 comment instead of 1 comm. if comments ==1 //langugage file modified accordingly @@ -109,35 +105,32 @@ function publisher_items_new_show($options) } else { $item['comment'] = ' ' . _MB_PUBLISHER_NO_COMMENTS . ' '; } - - - if ('article' === $image) { $item['image'] = PUBLISHER_URL . '/assets/images/default_image.jpg'; $item['image_name'] = ''; - $images = $iValue->getImages(); - - if (empty($images['image_path'])) { - $images['image_path'] = PUBLISHER_URL . '/assets/images/default_image.jpg'; - } + $images = $iValue->getImages(); + + if (empty($images['image_path'])) { + $images['image_path'] = PUBLISHER_URL . '/assets/images/default_image.jpg'; + } if (is_object($images['main'])) { // check to see if GD function exist if (!function_exists('imagecreatetruecolor')) { $item['image'] = XOOPS_URL . '/uploads/' . $images['main']->getVar('image_name'); } else { $item['image'] = PUBLISHER_URL . '/thumb.php?src=' . XOOPS_URL . '/uploads/' . $images['main']->getVar('image_name') . ''; - $item['image_path'] = XOOPS_URL . '/uploads/' . $images['main']->getVar('image_name') . ''; + $item['image_path'] = XOOPS_URL . '/uploads/' . $images['main']->getVar('image_name') . ''; } $item['image_name'] = $images['main']->getVar('image_nicename'); } } elseif ('category' === $image) { - $item['image'] = $iValue->getCategoryImagePath(); + $item['image'] = $iValue->getCategoryImagePath(); $item['image_name'] = $iValue->getCategoryName(); } elseif ('avatar' === $image) { if ('0' == $iValue->uid()) { $item['image'] = XOOPS_URL . '/uploads/avatars/blank.gif'; - $images = $iValue->getImages(); + $images = $iValue->getImages(); if (is_object($images['main'])) { // check to see if GD function exist if (!function_exists('imagecreatetruecolor')) { @@ -148,16 +141,16 @@ function publisher_items_new_show($options) } // check to see if GD function exist } elseif (!function_exists('imagecreatetruecolor')) { - $item['image'] = XOOPS_URL . '/uploads/' . $iValue->posterAvatar(); - } else { - $item['image'] = PUBLISHER_URL . '/thumb.php?src=' . XOOPS_URL . '/uploads/' . $iValue->posterAvatar() . '&w=50'; - } + $item['image'] = XOOPS_URL . '/uploads/' . $iValue->posterAvatar(); + } else { + $item['image'] = PUBLISHER_URL . '/thumb.php?src=' . XOOPS_URL . '/uploads/' . $iValue->posterAvatar() . '&w=50'; + } $item['image_name'] = $iValue->posterName(); } $item['title'] = $iValue->getTitle(); - $item['alt'] = strip_tags($iValue->getItemLink()); + $item['alt'] = strip_tags($iValue->getItemLink()); if ('datesub' === $sort) { $item['new'] = $iValue->getDatesub(); } elseif ('counter' === $sort) { @@ -178,12 +171,13 @@ function publisher_items_new_show($options) $block['show_order'] = $options[2]; $block['show_summary'] = $options[6]; - $block['show_poster'] =$options[7]; - $block['show_date'] =$options[8]; - $block['show_category'] =$options[9]; - $block['show_hits'] =$options[10]; - $block['show_comment'] =$options[11]; - $block['show_rating'] =$options[12]; + $block['show_poster'] = $options[7]; + $block['show_date'] = $options[8]; + $block['show_category'] = $options[9]; + $block['show_hits'] = $options[10]; + $block['show_comment'] = $options[11]; + $block['show_rating'] = $options[12]; + return $block; } @@ -199,39 +193,39 @@ function publisher_items_new_edit($options) $form = new Publisher\BlockForm(); - $catEle = new \XoopsFormLabel(_MB_PUBLISHER_SELECTCAT, Publisher\Utility::createCategorySelect($options[0], 0, true, 'options[0]')); + $catEle = new \XoopsFormLabel(_MB_PUBLISHER_SELECTCAT, Publisher\Utility::createCategorySelect($options[0], 0, true, 'options[0]')); $orderEle = new \XoopsFormSelect(_MB_PUBLISHER_ORDER, 'options[1]', $options[1]); $orderEle->addOptionArray( [ - 'datesub' => _MB_PUBLISHER_DATE, - 'counter' => _MB_PUBLISHER_HITS, - 'weight' => _MB_PUBLISHER_WEIGHT, - 'rating' => _MI_PUBLISHER_ORDERBY_RATING, - 'votes' => _MI_PUBLISHER_ORDERBY_VOTES, + 'datesub' => _MB_PUBLISHER_DATE, + 'counter' => _MB_PUBLISHER_HITS, + 'weight' => _MB_PUBLISHER_WEIGHT, + 'rating' => _MI_PUBLISHER_ORDERBY_RATING, + 'votes' => _MI_PUBLISHER_ORDERBY_VOTES, 'comments' => _MI_PUBLISHER_ORDERBY_COMMENTS, ] ); - $showEle = new \XoopsFormRadioYN(_MB_PUBLISHER_ORDER_SHOW, 'options[2]', $options[2]); - $dispEle = new \XoopsFormText(_MB_PUBLISHER_DISP, 'options[3]', 10, 255, $options[3]); + $showEle = new \XoopsFormRadioYN(_MB_PUBLISHER_ORDER_SHOW, 'options[2]', $options[2]); + $dispEle = new \XoopsFormText(_MB_PUBLISHER_DISP, 'options[3]', 10, 255, $options[3]); $charsEle = new \XoopsFormText(_MB_PUBLISHER_CHARS, 'options[4]', 10, 255, $options[4]); $imageEle = new \XoopsFormSelect(_MB_PUBLISHER_IMAGE_TO_DISPLAY, 'options[5]', $options[5]); $imageEle->addOptionArray( [ - 'none' => _NONE, - 'article' => _MB_PUBLISHER_IMAGE_ARTICLE, + 'none' => _NONE, + 'article' => _MB_PUBLISHER_IMAGE_ARTICLE, 'category' => _MB_PUBLISHER_IMAGE_CATEGORY, - 'avatar' => _MB_PUBLISHER_IMAGE_AVATAR, + 'avatar' => _MB_PUBLISHER_IMAGE_AVATAR, ] ); - $showSummary = new \XoopsFormRadioYN(_MB_PUBLISHER_DISPLAY_SUMMARY, 'options[6]', $options[6]); - $showPoster = new \XoopsFormRadioYN(_MB_PUBLISHER_DISPLAY_POSTEDBY, 'options[7]', $options[7]); - $showDate = new \XoopsFormRadioYN(_MB_PUBLISHER_DISPLAY_POSTTIME, 'options[8]', $options[8]); - $showCategory = new \XoopsFormRadioYN(_MB_PUBLISHER_DISPLAY_TOPICLINK, 'options[9]', $options[9]); - $showHits = new \XoopsFormRadioYN(_MB_PUBLISHER_DISPLAY_READ, 'options[10]', $options[10]); - $showComment = new \XoopsFormRadioYN(_MB_PUBLISHER_DISPLAY_COMMENT, 'options[11]', $options[11]); - $showRating = new \XoopsFormRadioYN(_MB_PUBLISHER_DISPLAY_RATING, 'options[12]', $options[12]); + $showSummary = new \XoopsFormRadioYN(_MB_PUBLISHER_DISPLAY_SUMMARY, 'options[6]', $options[6]); + $showPoster = new \XoopsFormRadioYN(_MB_PUBLISHER_DISPLAY_POSTEDBY, 'options[7]', $options[7]); + $showDate = new \XoopsFormRadioYN(_MB_PUBLISHER_DISPLAY_POSTTIME, 'options[8]', $options[8]); + $showCategory = new \XoopsFormRadioYN(_MB_PUBLISHER_DISPLAY_TOPICLINK, 'options[9]', $options[9]); + $showHits = new \XoopsFormRadioYN(_MB_PUBLISHER_DISPLAY_READ, 'options[10]', $options[10]); + $showComment = new \XoopsFormRadioYN(_MB_PUBLISHER_DISPLAY_COMMENT, 'options[11]', $options[11]); + $showRating = new \XoopsFormRadioYN(_MB_PUBLISHER_DISPLAY_RATING, 'options[12]', $options[12]); $form->addElement($catEle); $form->addElement($orderEle); @@ -239,12 +233,12 @@ function publisher_items_new_edit($options) $form->addElement($dispEle); $form->addElement($charsEle); $form->addElement($imageEle); - $form->addElement($showSummary); + $form->addElement($showSummary); $form->addElement($showPoster); $form->addElement($showDate); $form->addElement($showCategory); - $form->addElement($showHits); - $form->addElement($showComment); + $form->addElement($showHits); + $form->addElement($showComment); $form->addElement($showRating); return $form->render(); diff --git a/blocks/items_random_item.php b/blocks/items_random_item.php index 59874a0b..20f03477 100644 --- a/blocks/items_random_item.php +++ b/blocks/items_random_item.php @@ -14,8 +14,6 @@ /** * @copyright The XUUPS Project http://sourceforge.net/projects/xuups/ * @license http://www.fsf.org/copyleft/gpl.html GNU public license - * @package Publisher - * @subpackage Blocks * @since 1.0 * @author trabis * @author The SmartFactory @@ -24,22 +22,20 @@ use XoopsModules\Publisher; use XoopsModules\Publisher\Constants; - - require_once dirname(__DIR__) . '/include/common.php'; /** * @param $options * - * @return array * @throws \Exception * @throws \Exception + * @return array */ function publisher_items_random_item_show($options) { $block = []; - - /** @var Publisher\Helper $helper */ + + /** @var Publisher\Helper $helper */ $helper = Publisher\Helper::getInstance(); /** @var Publisher\ItemHandler $itemHandler */ $itemHandler = $helper->getHandler('Item'); @@ -50,58 +46,58 @@ function publisher_items_random_item_show($options) return $block; } - $block['content'] = $itemsObj->getBlockSummary(300, true); //show complete summary but truncate to 300 if only body available - $block['id'] = $itemsObj->itemid(); - $block['url'] = $itemsObj->getItemUrl(); + $block['content'] = $itemsObj->getBlockSummary(300, true); //show complete summary but truncate to 300 if only body available + $block['id'] = $itemsObj->itemid(); + $block['url'] = $itemsObj->getItemUrl(); $block['lang_fullitem'] = _MB_PUBLISHER_FULLITEM; - $block['lang_poster'] = _MB_PUBLISHER_POSTEDBY; - $block['lang_date'] = _MB_PUBLISHER_ON; - $block['lang_category'] = _MB_PUBLISHER_CATEGORY; - $block['lang_reads'] = _MB_PUBLISHER_HITS; - $block['titlelink'] = $itemsObj->getItemLink('titlelink'); - $block['alt'] = strip_tags($itemsObj->getItemLink()); - $block['date'] = $itemsObj->getDatesub(); - $block['poster'] = $itemsObj->getLinkedPosterName(); - $block['categorylink'] = $itemsObj->getCategoryLink(); - $block['hits'] = ' ' . $itemsObj->counter() . ' ' . _READS . ''; - - $mainImage = $itemsObj->getMainImage(); // check to see if GD function exist - if (empty($mainImage['image_path'])) { - $mainImage['image_path'] = PUBLISHER_URL . '/assets/images/default_image.jpg'; - } - if (!function_exists('imagecreatetruecolor')) { - $block['item_image'] = $mainImage['image_path']; - } else { - $block['item_image'] = PUBLISHER_URL . '/thumb.php?src=' . $mainImage['image_path'] . ''; - $block['image_path'] = $mainImage['image_path']; - } - - $block['cancomment'] = $itemsObj->cancomment(); - $comments = $itemsObj->comments(); - if ($comments > 0) { - //shows 1 comment instead of 1 comm. if comments ==1 - //langugage file modified accordingly - if (1 == $comments) { - $block['comment'] = ' ' . _MB_PUBLISHER_ONECOMMENT . ' '; - } else { - $block['comment'] = ' ' . $comments . ' ' . _MB_PUBLISHER_COMMENTS . ' '; - } - } else { - $block['comment'] = ' ' . _MB_PUBLISHER_NO_COMMENTS . ' '; - } - $block['display_summary'] =$options[0]; - $block['display_item_image'] =$options[1]; - $block['display_poster'] =$options[2]; - $block['display_date'] =$options[3]; - $block['display_categorylink'] =$options[4]; - $block['display_hits'] =$options[5]; - $block['display_comment'] =$options[6]; - $block['display_lang_fullitem'] =$options[7]; - - $block['items'][] = $block; - return $block; + $block['lang_poster'] = _MB_PUBLISHER_POSTEDBY; + $block['lang_date'] = _MB_PUBLISHER_ON; + $block['lang_category'] = _MB_PUBLISHER_CATEGORY; + $block['lang_reads'] = _MB_PUBLISHER_HITS; + $block['titlelink'] = $itemsObj->getItemLink('titlelink'); + $block['alt'] = strip_tags($itemsObj->getItemLink()); + $block['date'] = $itemsObj->getDatesub(); + $block['poster'] = $itemsObj->getLinkedPosterName(); + $block['categorylink'] = $itemsObj->getCategoryLink(); + $block['hits'] = ' ' . $itemsObj->counter() . ' ' . _READS . ''; - } + $mainImage = $itemsObj->getMainImage(); // check to see if GD function exist + if (empty($mainImage['image_path'])) { + $mainImage['image_path'] = PUBLISHER_URL . '/assets/images/default_image.jpg'; + } + if (!function_exists('imagecreatetruecolor')) { + $block['item_image'] = $mainImage['image_path']; + } else { + $block['item_image'] = PUBLISHER_URL . '/thumb.php?src=' . $mainImage['image_path'] . ''; + $block['image_path'] = $mainImage['image_path']; + } + + $block['cancomment'] = $itemsObj->cancomment(); + $comments = $itemsObj->comments(); + if ($comments > 0) { + //shows 1 comment instead of 1 comm. if comments ==1 + //langugage file modified accordingly + if (1 == $comments) { + $block['comment'] = ' ' . _MB_PUBLISHER_ONECOMMENT . ' '; + } else { + $block['comment'] = ' ' . $comments . ' ' . _MB_PUBLISHER_COMMENTS . ' '; + } + } else { + $block['comment'] = ' ' . _MB_PUBLISHER_NO_COMMENTS . ' '; + } + $block['display_summary'] = $options[0]; + $block['display_item_image'] = $options[1]; + $block['display_poster'] = $options[2]; + $block['display_date'] = $options[3]; + $block['display_categorylink'] = $options[4]; + $block['display_hits'] = $options[5]; + $block['display_comment'] = $options[6]; + $block['display_lang_fullitem'] = $options[7]; + + $block['items'][] = $block; + + return $block; +} /** * @param $options @@ -114,22 +110,22 @@ function publisher_items_random_item_edit($options) $form = new Publisher\BlockForm(); $showSummary = new \XoopsFormRadioYN(_MB_PUBLISHER_DISPLAY_SUMMARY, 'options[0]', $options[0]); - $showImage = new \XoopsFormRadioYN(_MB_PUBLISHER_IMGDISPLAY, 'options[1]', $options[1]); - $showPoster = new \XoopsFormRadioYN(_MB_PUBLISHER_DISPLAY_POSTEDBY, 'options[2]', $options[2]); - $showDate = new \XoopsFormRadioYN(_MB_PUBLISHER_DISPLAY_POSTTIME, 'options[3]', $options[3]); - $showCategory = new \XoopsFormRadioYN(_MB_PUBLISHER_DISPLAY_TOPICLINK, 'options[4]', $options[4]); - $showHits = new \XoopsFormRadioYN(_MB_PUBLISHER_DISPLAY_READ, 'options[5]', $options[5]); - $showComment = new \XoopsFormRadioYN(_MB_PUBLISHER_DISPLAY_COMMENT, 'options[6]', $options[6]); + $showImage = new \XoopsFormRadioYN(_MB_PUBLISHER_IMGDISPLAY, 'options[1]', $options[1]); + $showPoster = new \XoopsFormRadioYN(_MB_PUBLISHER_DISPLAY_POSTEDBY, 'options[2]', $options[2]); + $showDate = new \XoopsFormRadioYN(_MB_PUBLISHER_DISPLAY_POSTTIME, 'options[3]', $options[3]); + $showCategory = new \XoopsFormRadioYN(_MB_PUBLISHER_DISPLAY_TOPICLINK, 'options[4]', $options[4]); + $showHits = new \XoopsFormRadioYN(_MB_PUBLISHER_DISPLAY_READ, 'options[5]', $options[5]); + $showComment = new \XoopsFormRadioYN(_MB_PUBLISHER_DISPLAY_COMMENT, 'options[6]', $options[6]); $dispMoreEle = new \XoopsFormRadioYN(_MB_PUBLISHER_DISPLAY_READ_FULLITEM, 'options[7]', $options[7]); - - $form->addElement($showSummary); + + $form->addElement($showSummary); $form->addElement($showImage); $form->addElement($showPoster); $form->addElement($showDate); $form->addElement($showCategory); - $form->addElement($showHits); - $form->addElement($showComment); - $form->addElement($dispMoreEle); - + $form->addElement($showHits); + $form->addElement($showComment); + $form->addElement($dispMoreEle); + return $form->render(); } diff --git a/blocks/items_recent.php b/blocks/items_recent.php index 86420624..6f3f3ac0 100644 --- a/blocks/items_recent.php +++ b/blocks/items_recent.php @@ -14,8 +14,6 @@ /** * @copyright The XUUPS Project http://sourceforge.net/projects/xuups/ * @license http://www.fsf.org/copyleft/gpl.html GNU public license - * @package Publisher - * @subpackage Blocks * @since 1.0 * @author trabis * @author The SmartFactory @@ -24,8 +22,6 @@ use XoopsModules\Publisher; use XoopsModules\Publisher\Constants; - - require_once dirname(__DIR__) . '/include/common.php'; /** @@ -39,7 +35,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 = []; @@ -50,7 +46,7 @@ function publisher_items_recent_show($options) $allcats = true; } - $sort = $options[1]; + $sort = $options[1]; $order = Publisher\Utility::getOrderBy($sort); $limit = $options[2]; $start = 0; @@ -78,31 +74,31 @@ function publisher_items_recent_show($options) if ($itemsObj && $totalItems > 0) { foreach ($itemsObj as $iValue) { - $newItems['itemid'] = $iValue->itemid(); - $newItems['itemurl'] = $iValue->getItemUrl(); - $newItems['title'] = $iValue->getTitle(); - $newItems['alt'] = strip_tags($iValue->getItemLink()); + $newItems['itemid'] = $iValue->itemid(); + $newItems['itemurl'] = $iValue->getItemUrl(); + $newItems['title'] = $iValue->getTitle(); + $newItems['alt'] = strip_tags($iValue->getItemLink()); $newItems['categoryname'] = $iValue->getCategoryName(); - $newItems['categoryid'] = $iValue->categoryid(); - $newItems['date'] = $iValue->getDatesub(); - $newItems['poster'] = $iValue->getLinkedPosterName(); - $newItems['itemlink'] = $iValue->getItemLink(false, $options[3] ?? 65); + $newItems['categoryid'] = $iValue->categoryid(); + $newItems['date'] = $iValue->getDatesub(); + $newItems['poster'] = $iValue->getLinkedPosterName(); + $newItems['itemlink'] = $iValue->getItemLink(false, $options[3] ?? 65); $newItems['categorylink'] = $iValue->getCategoryLink(); - $newItems['hits'] = ' ' . $iValue->counter() . ' ' . _READS . ''; - $newItems['summary'] = $iValue->getBlockSummary(300, true); //show complete summary but truncate to 300 if only body available - - $mainImage = $iValue->getMainImage(); // check to see if GD function exist - if (empty($mainImage['image_path'])) { - $mainImage['image_path'] = PUBLISHER_URL . '/assets/images/default_image.jpg'; - } - if (!function_exists('imagecreatetruecolor')) { - $newItems['item_image'] = $mainImage['image_path']; - } else { - $newItems['item_image'] = PUBLISHER_URL . '/thumb.php?src=' . $mainImage['image_path'] . ''; - $newItems['image_path'] = $mainImage['image_path']; - } - $newItems['cancomment'] = $iValue->cancomment(); - $comments = $iValue->comments(); + $newItems['hits'] = ' ' . $iValue->counter() . ' ' . _READS . ''; + $newItems['summary'] = $iValue->getBlockSummary(300, true); //show complete summary but truncate to 300 if only body available + + $mainImage = $iValue->getMainImage(); // check to see if GD function exist + if (empty($mainImage['image_path'])) { + $mainImage['image_path'] = PUBLISHER_URL . '/assets/images/default_image.jpg'; + } + if (!function_exists('imagecreatetruecolor')) { + $newItems['item_image'] = $mainImage['image_path']; + } else { + $newItems['item_image'] = PUBLISHER_URL . '/thumb.php?src=' . $mainImage['image_path'] . ''; + $newItems['image_path'] = $mainImage['image_path']; + } + $newItems['cancomment'] = $iValue->cancomment(); + $comments = $iValue->comments(); if ($comments > 0) { //shows 1 comment instead of 1 comm. if comments ==1 //langugage file modified accordingly @@ -112,31 +108,28 @@ function publisher_items_recent_show($options) $newItems['comment'] = ' ' . $comments . ' ' . _MB_PUBLISHER_COMMENTS . ' '; } } else { - $newItems['comment'] = ' ' . _MB_PUBLISHER_NO_COMMENTS . ' '; + $newItems['comment'] = ' ' . _MB_PUBLISHER_NO_COMMENTS . ' '; } - - - + $block['items'][] = $newItems; } $block['publisher_url'] = PUBLISHER_URL; - $block['lang_title'] = _MB_PUBLISHER_ITEMS; - $block['lang_category'] = _MB_PUBLISHER_CATEGORY; - $block['lang_poster'] = _MB_PUBLISHER_POSTEDBY; - $block['lang_date'] = _MB_PUBLISHER_DATE; - $moduleName = $myts->displayTarea($helper->getModule()->getVar('name')); + $block['lang_title'] = _MB_PUBLISHER_ITEMS; + $block['lang_category'] = _MB_PUBLISHER_CATEGORY; + $block['lang_poster'] = _MB_PUBLISHER_POSTEDBY; + $block['lang_date'] = _MB_PUBLISHER_DATE; + $moduleName = $myts->displayTarea($helper->getModule()->getVar('name')); $block['lang_visitItem'] = _MB_PUBLISHER_VISITITEM . ' ' . $moduleName; - - $block['show_image'] = $options[4]; - $block['show_summary'] = $options[5]; - $block['show_category'] =$options[6]; - $block['show_poster'] =$options[7]; - $block['show_date'] =$options[8]; - $block['show_hits'] =$options[9]; - $block['show_comment'] =$options[10]; - $block['show_morelink'] =$options[11]; - - } + + $block['show_image'] = $options[4]; + $block['show_summary'] = $options[5]; + $block['show_category'] = $options[6]; + $block['show_poster'] = $options[7]; + $block['show_date'] = $options[8]; + $block['show_hits'] = $options[9]; + $block['show_comment'] = $options[10]; + $block['show_morelink'] = $options[11]; + } return $block; } @@ -153,38 +146,38 @@ function publisher_items_recent_edit($options) $form = new Publisher\BlockForm(); - $catEle = new \XoopsFormLabel(_MB_PUBLISHER_SELECTCAT, Publisher\Utility::createCategorySelect($options[0], 0, true, 'options[0]')); + $catEle = new \XoopsFormLabel(_MB_PUBLISHER_SELECTCAT, Publisher\Utility::createCategorySelect($options[0], 0, true, 'options[0]')); $orderEle = new \XoopsFormSelect(_MB_PUBLISHER_ORDER, 'options[1]', $options[1]); $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]); + $dispEle = new \XoopsFormText(_MB_PUBLISHER_DISP, 'options[2]', 10, 255, $options[2]); $charsEle = new \XoopsFormText(_MB_PUBLISHER_CHARS, 'options[3]', 10, 255, $options[3]); - $showImage = new \XoopsFormRadioYN(_MB_PUBLISHER_IMGDISPLAY, 'options[4]', $options[4]); - $showSummary = new \XoopsFormRadioYN(_MB_PUBLISHER_DISPLAY_SUMMARY, 'options[5]', $options[5]); - $showCategory = new \XoopsFormRadioYN(_MB_PUBLISHER_DISPLAY_TOPICLINK, 'options[6]', $options[6]); - $showPoster = new \XoopsFormRadioYN(_MB_PUBLISHER_DISPLAY_POSTEDBY, 'options[7]', $options[7]); - $showDate = new \XoopsFormRadioYN(_MB_PUBLISHER_DISPLAY_POSTTIME, 'options[8]', $options[8]); - $showHits = new \XoopsFormRadioYN(_MB_PUBLISHER_DISPLAY_READ, 'options[9]', $options[9]); - $showComment = new \XoopsFormRadioYN(_MB_PUBLISHER_DISPLAY_COMMENT, 'options[10]', $options[10]); + $showImage = new \XoopsFormRadioYN(_MB_PUBLISHER_IMGDISPLAY, 'options[4]', $options[4]); + $showSummary = new \XoopsFormRadioYN(_MB_PUBLISHER_DISPLAY_SUMMARY, 'options[5]', $options[5]); + $showCategory = new \XoopsFormRadioYN(_MB_PUBLISHER_DISPLAY_TOPICLINK, 'options[6]', $options[6]); + $showPoster = new \XoopsFormRadioYN(_MB_PUBLISHER_DISPLAY_POSTEDBY, 'options[7]', $options[7]); + $showDate = new \XoopsFormRadioYN(_MB_PUBLISHER_DISPLAY_POSTTIME, 'options[8]', $options[8]); + $showHits = new \XoopsFormRadioYN(_MB_PUBLISHER_DISPLAY_READ, 'options[9]', $options[9]); + $showComment = new \XoopsFormRadioYN(_MB_PUBLISHER_DISPLAY_COMMENT, 'options[10]', $options[10]); $dispMoreEle = new \XoopsFormRadioYN(_MB_PUBLISHER_DISPLAY_MORELINK, 'options[11]', $options[11]); - - + $form->addElement($catEle); $form->addElement($orderEle); $form->addElement($dispEle); $form->addElement($charsEle); - $form->addElement($showImage); - $form->addElement($showSummary); - $form->addElement($showCategory); - $form->addElement($showPoster); + $form->addElement($showImage); + $form->addElement($showSummary); + $form->addElement($showCategory); + $form->addElement($showPoster); $form->addElement($showDate); - $form->addElement($showHits); - $form->addElement($showComment); + $form->addElement($showHits); + $form->addElement($showComment); $form->addElement($dispMoreEle); + return $form->render(); } diff --git a/blocks/items_spot.php b/blocks/items_spot.php index 515e407b..840eecbc 100644 --- a/blocks/items_spot.php +++ b/blocks/items_spot.php @@ -14,8 +14,6 @@ /** * @copyright The XUUPS Project http://sourceforge.net/projects/xuups/ * @license http://www.fsf.org/copyleft/gpl.html GNU public license - * @package Publisher - * @subpackage Blocks * @since 1.0 * @author trabis * @author The SmartFactory @@ -23,8 +21,6 @@ use XoopsModules\Publisher; - - require_once dirname(__DIR__) . '/include/common.php'; /** @@ -41,26 +37,26 @@ function publisher_items_spot_show($options) $categoryHandler = $helper->getHandler('Category'); /** @var Publisher\ItemHandler $itemHandler */ $itemHandler = $helper->getHandler('Item'); - xoops_loadLanguage('main', 'publisher'); + xoops_loadLanguage('main', 'publisher'); - $optDisplayLast = $options[0]; - $optItemsCount = $options[1]; - $optCategoryId = $options[2]; - $selItems = isset($options[3]) ? explode(',', $options[3]) : ''; - $optDisplayPoster = $options[4]; - $optDisplayComment = $options[5]; - $optDisplayType = $options[6]; - $optTruncate = (int)$options[7]; - $optCatImage = $options[8]; - $optSortOrder = $options[9] ?? ''; + $optDisplayLast = $options[0]; + $optItemsCount = $options[1]; + $optCategoryId = $options[2]; + $selItems = isset($options[3]) ? explode(',', $options[3]) : ''; + $optDisplayPoster = $options[4]; + $optDisplayComment = $options[5]; + $optDisplayType = $options[6]; + $optTruncate = (int)$options[7]; + $optCatImage = $options[8]; + $optSortOrder = $options[9] ?? ''; $optBtnDisplayMore = $options[10] ?? ''; - $optDisplayReads = $options[11] ?? ''; - $optdisplayitemimage=$options[12]?? ''; - $optdisplaywhenlink=$options[13]?? ''; - $optdisplaycategorylink=$options[14]?? ''; - $optdisplayadminlink=$options[15]?? ''; - $optdisplayreadmore =$options[16]?? ''; - + $optDisplayReads = $options[11] ?? ''; + $optdisplayitemimage = $options[12] ?? ''; + $optdisplaywhenlink = $options[13] ?? ''; + $optdisplaycategorylink = $options[14] ?? ''; + $optdisplayadminlink = $options[15] ?? ''; + $optdisplayreadmore = $options[16] ?? ''; + if (0 == $optCategoryId) { $optCategoryId = -1; } @@ -68,42 +64,42 @@ function publisher_items_spot_show($options) if (1 == $optDisplayLast) { switch ($optSortOrder) { case 'title': - $sort = 'title'; + $sort = 'title'; $order = 'ASC'; break; case 'date': - $sort = 'datesub'; + $sort = 'datesub'; $order = 'DESC'; break; case 'counter': - $sort = 'counter'; + $sort = 'counter'; $order = 'DESC'; break; case 'rating': - $sort = 'rating'; + $sort = 'rating'; $order = 'DESC'; break; case 'votes': - $sort = 'votes'; + $sort = 'votes'; $order = 'DESC'; break; case 'comments': - $sort = 'comments'; + $sort = 'comments'; $order = 'DESC'; break; default: - $sort = 'weight'; + $sort = 'weight'; $order = 'ASC'; break; } - $itemsObj = $itemHandler->getAllPublished($optItemsCount, 0, $optCategoryId, $sort, $order, 'summary'); - $i = 1; + $itemsObj = $itemHandler->getAllPublished($optItemsCount, 0, $optCategoryId, $sort, $order, 'summary'); + $i = 1; $itemsCount = count($itemsObj); if ($itemsObj) { if (-1 != $optCategoryId) { /** @var Publisher\Category $cat */ - $cat = $categoryHandler->get($optCategoryId); - $category['name'] = $cat->name; + $cat = $categoryHandler->get($optCategoryId); + $category['name'] = $cat->name; $category['categoryurl'] = $cat->getCategoryUrl(); if ('blank.png' !== $cat->getImage()) { $category['image_path'] = Publisher\Utility::getImageDir('category', false) . $cat->getImage(); @@ -136,7 +132,7 @@ function publisher_items_spot_show($options) /** @var Publisher\Item $itemObj */ $itemObj = $itemHandler->get($itemId); if (null !== $itemObj && !$itemObj->notLoaded()) { - $item = $itemObj->toArraySimple(); + $item = $itemObj->toArraySimple(); $item['who_when'] = sprintf(_MB_PUBLISHER_WHO_WHEN, $item['who'], $item['when']); if ($i < $itemsCount) { $item['showline'] = true; @@ -145,7 +141,7 @@ function publisher_items_spot_show($options) } if ($optTruncate > 0) { $block['truncate'] = true; - $item['summary'] = Publisher\Utility::truncateHtml($item['summary'], $optTruncate); + $item['summary'] = Publisher\Utility::truncateHtml($item['summary'], $optTruncate); } $block['items'][] = $item; ++$i; @@ -156,25 +152,25 @@ function publisher_items_spot_show($options) if (!isset($block['items']) || 0 == count($block['items'])) { return false; } - $block['lang_reads'] = _MB_PUBLISHER_READS; - $block['lang_comments'] = _MB_PUBLISHER_COMMENTS; - $block['lang_readmore'] = _MB_PUBLISHER_READMORE; - $block['lang_poster'] = _MB_PUBLISHER_POSTEDBY; - $block['lang_date'] = _MB_PUBLISHER_ON; - $block['lang_category'] = _MB_PUBLISHER_CATEGORY; - + $block['lang_reads'] = _MB_PUBLISHER_READS; + $block['lang_comments'] = _MB_PUBLISHER_COMMENTS; + $block['lang_readmore'] = _MB_PUBLISHER_READMORE; + $block['lang_poster'] = _MB_PUBLISHER_POSTEDBY; + $block['lang_date'] = _MB_PUBLISHER_ON; + $block['lang_category'] = _MB_PUBLISHER_CATEGORY; + $block['display_whowhen_link'] = $optDisplayPoster; - $block['display_who_link'] = $optDisplayPoster; + $block['display_who_link'] = $optDisplayPoster; $block['display_comment_link'] = $optDisplayComment; - $block['display_type'] = $optDisplayType; - $block['display_reads'] = $optDisplayReads; - $block['display_cat_image'] = $optCatImage; - $block['display_item_image'] =$optdisplayitemimage; - $block['display_when_link'] =$optdisplaywhenlink; - $block['display_categorylink'] =$optdisplaycategorylink; - $block['display_adminlink'] =$optdisplayadminlink; - $block['display_readmore'] =$optdisplayreadmore; - + $block['display_type'] = $optDisplayType; + $block['display_reads'] = $optDisplayReads; + $block['display_cat_image'] = $optCatImage; + $block['display_item_image'] = $optdisplayitemimage; + $block['display_when_link'] = $optdisplaywhenlink; + $block['display_categorylink'] = $optdisplaycategorylink; + $block['display_adminlink'] = $optdisplayadminlink; + $block['display_readmore'] = $optdisplayreadmore; + if ($optBtnDisplayMore) { $block['lang_displaymore'] = _MB_PUBLISHER_MORE_ITEMS; } @@ -194,19 +190,19 @@ 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]); + $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]', false)); + $catEle = new \XoopsFormLabel(_MB_PUBLISHER_SELECTCAT, Publisher\Utility::createCategorySelect($options[2], 0, true, 'options[2]', false)); /** @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); - $keys = array_keys($itemsObj); + $keys = array_keys($itemsObj); unset($criteria); if (empty($options[3]) || (0 == $options[3])) { $selItems = $keys[0] ?? 0; @@ -215,37 +211,37 @@ function publisher_items_spot_edit($options) } $itemEle = new \XoopsFormSelect(_MB_PUBLISHER_SELECT_ITEMS, 'options[3]', $selItems, 10, true); $itemEle->addOptionArray($itemsObj); - $whoEle = new \XoopsFormRadioYN(_MB_PUBLISHER_DISPLAY_POSTEDBY, 'options[4]', $options[4]); - $comEle = new \XoopsFormRadioYN(_MB_PUBLISHER_DISPLAY_COMMENTS, 'options[5]', $options[5]); + $whoEle = new \XoopsFormRadioYN(_MB_PUBLISHER_DISPLAY_POSTEDBY, 'options[4]', $options[4]); + $comEle = new \XoopsFormRadioYN(_MB_PUBLISHER_DISPLAY_COMMENTS, 'options[5]', $options[5]); $typeEle = new \XoopsFormSelect(_MB_PUBLISHER_DISPLAY_TYPE, 'options[6]', $options[6]); $typeEle->addOptionArray( [ - 'block' => _MB_PUBLISHER_DISPLAY_TYPE_BLOCK, + 'block' => _MB_PUBLISHER_DISPLAY_TYPE_BLOCK, '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]); - $sortEle = new \XoopsFormSelect(_MI_PUBLISHER_ORDERBY, 'options[9]', $options[9]); + $imageEle = new \XoopsFormRadioYN(_MB_PUBLISHER_DISPLAY_CATIMAGE, 'options[8]', $options[8]); + $sortEle = new \XoopsFormSelect(_MI_PUBLISHER_ORDERBY, 'options[9]', $options[9]); $sortEle->addOptionArray( [ - 'title' => _MI_PUBLISHER_ORDERBY_TITLE, - 'date' => _MI_PUBLISHER_ORDERBY_DATE, - 'counter' => _MI_PUBLISHER_ORDERBY_HITS, - 'rating' => _MI_PUBLISHER_ORDERBY_RATING, - 'votes' => _MI_PUBLISHER_ORDERBY_VOTES, + 'title' => _MI_PUBLISHER_ORDERBY_TITLE, + 'date' => _MI_PUBLISHER_ORDERBY_DATE, + 'counter' => _MI_PUBLISHER_ORDERBY_HITS, + 'rating' => _MI_PUBLISHER_ORDERBY_RATING, + 'votes' => _MI_PUBLISHER_ORDERBY_VOTES, 'comments' => _MI_PUBLISHER_ORDERBY_COMMENTS, - 'weight' => _MI_PUBLISHER_ORDERBY_WEIGHT, + 'weight' => _MI_PUBLISHER_ORDERBY_WEIGHT, ] ); $dispMoreEle = new \XoopsFormRadioYN(_MB_PUBLISHER_DISPLAY_MORELINK, 'options[10]', $options[10]); - $readsEle = new \XoopsFormRadioYN(_MB_PUBLISHER_DISPLAY_READ, 'options[11]', $options[11]); - $dispImage = new \XoopsFormRadioYN(_MB_PUBLISHER_IMGDISPLAY, 'options[12]', $options[12]); - $dispDate = new \XoopsFormRadioYN(_MB_PUBLISHER_DISPLAY_POSTTIME, 'options[13]', $options[13]); - $dispCategory = new \XoopsFormRadioYN(_MB_PUBLISHER_DISPLAY_TOPICLINK, 'options[14]', $options[14]); - $dispAdminlink = new \XoopsFormRadioYN(_MB_PUBLISHER_DISPLAY_ADMINLINK, 'options[15]', $options[15]); - $dispReadmore = new \XoopsFormRadioYN(_MB_PUBLISHER_DISPLAY_READ_FULLITEM, 'options[16]', $options[16]); - + $readsEle = new \XoopsFormRadioYN(_MB_PUBLISHER_DISPLAY_READ, 'options[11]', $options[11]); + $dispImage = new \XoopsFormRadioYN(_MB_PUBLISHER_IMGDISPLAY, 'options[12]', $options[12]); + $dispDate = new \XoopsFormRadioYN(_MB_PUBLISHER_DISPLAY_POSTTIME, 'options[13]', $options[13]); + $dispCategory = new \XoopsFormRadioYN(_MB_PUBLISHER_DISPLAY_TOPICLINK, 'options[14]', $options[14]); + $dispAdminlink = new \XoopsFormRadioYN(_MB_PUBLISHER_DISPLAY_ADMINLINK, 'options[15]', $options[15]); + $dispReadmore = new \XoopsFormRadioYN(_MB_PUBLISHER_DISPLAY_READ_FULLITEM, 'options[16]', $options[16]); + $form->addElement($autoEle); $form->addElement($countEle); $form->addElement($catEle); @@ -258,10 +254,11 @@ function publisher_items_spot_edit($options) $form->addElement($sortEle); $form->addElement($dispMoreEle); $form->addElement($readsEle); - $form->addElement($dispImage); - $form->addElement($dispDate); - $form->addElement($dispCategory); - $form->addElement($dispAdminlink); - $form->addElement($dispReadmore); + $form->addElement($dispImage); + $form->addElement($dispDate); + $form->addElement($dispCategory); + $form->addElement($dispAdminlink); + $form->addElement($dispReadmore); + return $form->render(); } diff --git a/blocks/latest_files.php b/blocks/latest_files.php index 9b89ee8e..ec35b2db 100644 --- a/blocks/latest_files.php +++ b/blocks/latest_files.php @@ -14,8 +14,6 @@ /** * @copyright The XUUPS Project http://sourceforge.net/projects/xuups/ * @license http://www.fsf.org/copyleft/gpl.html GNU public license - * @package Publisher - * @subpackage Blocks * @since 1.0 * @author trabis * @author The SmartFactory @@ -24,8 +22,6 @@ use XoopsModules\Publisher; use XoopsModules\Publisher\Constants; - - require_once dirname(__DIR__) . '/include/common.php'; /** @@ -49,15 +45,15 @@ function publisher_latest_files_show($options) $block = []; - $sort = $options[1]; - $order = Publisher\Utility::getOrderBy($sort); - $limit = $options[2]; + $sort = $options[1]; + $order = Publisher\Utility::getOrderBy($sort); + $limit = $options[2]; $directDownload = $options[3]; // creating the files objects $filesObj = $fileHandler->getAllFiles(0, Constants::PUBLISHER_STATUS_FILE_ACTIVE, $limit, 0, $sort, $order, explode(',', $options[0])); foreach ($filesObj as $fileObj) { - $aFile = []; + $aFile = []; $aFile['link'] = $directDownload ? $fileObj->getFileLink() : $fileObj->getItemLink(); if ('datesub' === $sort) { $aFile['new'] = $fileObj->getDatesub(); @@ -84,16 +80,16 @@ function publisher_latest_files_edit($options) $form = new Publisher\BlockForm(); - $catEle = new \XoopsFormLabel(_MB_PUBLISHER_SELECTCAT, Publisher\Utility::createCategorySelect($options[0], 0, true, 'options[0]')); + $catEle = new \XoopsFormLabel(_MB_PUBLISHER_SELECTCAT, Publisher\Utility::createCategorySelect($options[0], 0, true, 'options[0]')); $orderEle = new \XoopsFormSelect(_MB_PUBLISHER_ORDER, 'options[1]', $options[1]); $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]); + $dispEle = new \XoopsFormText(_MB_PUBLISHER_DISP, 'options[2]', 10, 255, $options[2]); $directEle = new \XoopsFormRadioYN(_MB_PUBLISHER_DIRECTDOWNLOAD, 'options[3]', $options[3]); $form->addElement($catEle); diff --git a/blocks/latest_news.php b/blocks/latest_news.php index 74a676dd..5dd3ae0e 100644 --- a/blocks/latest_news.php +++ b/blocks/latest_news.php @@ -14,8 +14,6 @@ /** * @copyright The XUUPS Project http://sourceforge.net/projects/xuups/ * @license http://www.fsf.org/copyleft/gpl.html GNU public license - * @package Publisher - * @subpackage Blocks * @since 1.0 * @author trabis * @author Bandit-x @@ -25,8 +23,6 @@ use XoopsModules\Publisher; use XoopsModules\Publisher\Constants; - - require_once dirname(__DIR__) . '/include/common.php'; /** @@ -45,24 +41,24 @@ function publisher_latest_news_show($options) $itemHandler = $helper->getHandler('Item'); // xoops_loadLanguage('main', 'publisher'); - $start = $options[0]; // You can show articles from specified range - $limit = $options[1]; - $columnCount = $options[2]; - $letters = $options[3]; + $start = $options[0]; // You can show articles from specified range + $limit = $options[1]; + $columnCount = $options[2]; + $letters = $options[3]; $selectedStories = $options[4]; - $sort = $options[9]; - $order = Publisher\Utility::getOrderBy($sort); - $imgWidth = $options[11]; - $imgHeight = $options[12]; - $border = $options[13]; - $bordercolor = $options[14]; + $sort = $options[9]; + $order = Publisher\Utility::getOrderBy($sort); + $imgWidth = $options[11]; + $imgHeight = $options[12]; + $border = $options[13]; + $bordercolor = $options[14]; $block['spec']['columnwidth'] = (1 / $columnCount * 100); $allcats = false; if (!isset($options[31])) { $allcats = true; - } elseif (in_array(0, explode(',', $options[31]))) { + } elseif (in_array(0, explode(',', $options[31]), true)) { $allcats = true; } @@ -97,29 +93,29 @@ function publisher_latest_news_show($options) if (0 == $scount) { return false; } - $k = 0; + $k = 0; $columns = []; foreach ($itemsObj as $itemid => $itemObj) { - $item = []; + $item = []; $item['itemurl'] = $itemObj->getItemUrl(); - $item['title'] = $itemObj->getItemLink(); - $item['alt'] = strip_tags($itemObj->getItemLink()); - $mainImage = $itemObj->getMainImage(); + $item['title'] = $itemObj->getItemLink(); + $item['alt'] = strip_tags($itemObj->getItemLink()); + $mainImage = $itemObj->getMainImage(); if (empty($mainImage['image_path'])) { $mainImage['image_path'] = PUBLISHER_URL . '/assets/images/default_image.jpg'; - } + } // check to see if GD function exist if (!empty($mainImage['image_path']) && !function_exists('imagecreatetruecolor')) { $item['item_image'] = $mainImage['image_path']; } else { $item['item_image'] = PUBLISHER_URL . '/thumb.php?src=' . $mainImage['image_path'] . '&w=' . $imgWidth; // No $imgHeight for autoheight option $item['image_path'] = $mainImage['image_path']; - } + } $item['text'] = $itemObj->getBlockSummary($letters); - $item['display_item_image'] =$options[10]; - $item['display_summary'] =$options[16]; - $item['display_adminlink'] =$options[29]; + $item['display_item_image'] = $options[10]; + $item['display_summary'] = $options[16]; + $item['display_adminlink'] = $options[29]; $item = $itemObj->getMainImage($item); //returns an array $lsHeight = $imgPosition = $lsMargin = ''; @@ -129,31 +125,31 @@ function publisher_latest_news_show($options) if ('LEFT' === $options[15]) { $imgPosition = 'float: left'; - $lsMargin = '-right'; - $block['position'] = $imgPosition; - $block['margin'] = $lsMargin; + $lsMargin = '-right'; + $block['position'] = $imgPosition; + $block['margin'] = $lsMargin; } if ('CENTER' === $options[15]) { $imgPosition = 'text-align:center'; - $lsMargin = ''; - $block['position'] = $imgPosition; - $block['margin'] = $lsMargin; + $lsMargin = ''; + $block['position'] = $imgPosition; + $block['margin'] = $lsMargin; } if ('RIGHT' === $options[15]) { $imgPosition = 'float: right'; - $lsMargin = '-left'; - $block['position'] = $imgPosition; - $block['margin'] = $lsMargin; + $lsMargin = '-left'; + $block['position'] = $imgPosition; + $block['margin'] = $lsMargin; } //Image if (1 == $options[10] && '' != $item['image_path']) { $startdiv = ''; - $image = $startdiv . '' . $item['image_name'] . ''; + $image = $startdiv . '' . $item['image_name'] . 'getBlockSummary($letters); + $block['text'] = $itemObj->getBlockSummary($letters); } - + $block['archivelink'] = ''; if (1 == $options[17]) { $block['archivelink'] = '| ' . _MB_PUBLISHER_ARCHIVE . ' '; @@ -185,28 +181,28 @@ function publisher_latest_news_show($options) $item['poster'] = ''; if (1 == $options[19]) { $item['poster'] = $itemObj->posterName(); - $block['lang_poster'] = _MB_PUBLISHER_POSTEDBY; + $block['lang_poster'] = _MB_PUBLISHER_POSTEDBY; } $item['posttime'] = ''; if (1 == $options[20]) { $item['posttime'] = $itemObj->getDatesub(); - $block['lang_date'] = _MB_PUBLISHER_ON; + $block['lang_date'] = _MB_PUBLISHER_ON; } $item['topic_title'] = ''; if (1 == $options[21]) { $item['topic_title'] = $itemObj->getCategoryLink(); $item['category'] = strip_tags($itemObj->getCategoryLink()); - $block['lang_category'] = _MB_PUBLISHER_CATEGORY; - } + $block['lang_category'] = _MB_PUBLISHER_CATEGORY; + } $item['read'] = ''; if (1 == $options[22]) { $item['read'] = $itemObj->counter(); - $block['lang_reads'] = _MB_PUBLISHER_READS; + $block['lang_reads'] = _MB_PUBLISHER_READS; } - $item['cancomment'] = $itemObj->cancomment(); + $item['cancomment'] = $itemObj->cancomment(); $comments = $itemObj->comments(); if (1 == $options[23]) { if ($comments > 0) { @@ -228,14 +224,14 @@ function publisher_latest_news_show($options) } $item['pdf'] = ''; - - if (1 == $options[25]) { - $item['pdf'] = "" . _CO_PUBLISHER_PDF . " "; - } - + + if (1 == $options[25]) { + $item['pdf'] = "" . _CO_PUBLISHER_PDF . " "; + } + $item['email'] = ''; - if (1 == $options[26]) { - $maillink = 'mailto:?subject=' . sprintf(_CO_PUBLISHER_INTITEM, $GLOBALS['xoopsConfig']['sitename']) . '&body=' . sprintf(_CO_PUBLISHER_INTITEMFOUND, $GLOBALS['xoopsConfig']['sitename']) . ': ' . $itemObj->getItemUrl(); + if (1 == $options[26]) { + $maillink = 'mailto:?subject=' . sprintf(_CO_PUBLISHER_INTITEM, $GLOBALS['xoopsConfig']['sitename']) . '&body=' . sprintf(_CO_PUBLISHER_INTITEMFOUND, $GLOBALS['xoopsConfig']['sitename']) . ': ' . $itemObj->getItemUrl(); $item['email'] = '' . _CO_PUBLISHER_MAIL . ' '; } @@ -255,17 +251,17 @@ function publisher_latest_news_show($options) } $block['scrollheight'] = $options[6]; - $block['scrollspeed'] = $options[7]; - $block['scrolldir'] = $options[8]; + $block['scrollspeed'] = $options[7]; + $block['scrolldir'] = $options[8]; $block['template'] = $options[30]; - $block['imgwidth'] = $options[11]; + $block['imgwidth'] = $options[11]; $block['imgheight'] = $options[12]; $block['border'] = $options[13]; $block['bordercolor'] = $options[14]; - - $block['letters'] = $letters; + + $block['letters'] = $letters; $columns[$k][] = $item; ++$k; @@ -411,11 +407,11 @@ function publisher_latest_news_edit($options) $form .= " ' . _LEFT . '  '; - $slc = ''; + $slc = ''; if (1 == $options[$number]) { $slc = ' checked'; } $select = " ' . _CENTER . '  '; - $slc = ''; + $slc = ''; if (0 == $options[$number]) { $slc = ' checked'; } diff --git a/blocks/search.php b/blocks/search.php index 84e2c9f4..ce33dd8d 100644 --- a/blocks/search.php +++ b/blocks/search.php @@ -14,8 +14,6 @@ /** * @copyright The XUUPS Project http://sourceforge.net/projects/xuups/ * @license http://www.fsf.org/copyleft/gpl.html GNU public license - * @package Publisher - * @subpackage Blocks * @since 1.0 * @author trabis * @author phppp @@ -24,8 +22,6 @@ use Xmf\Request; use XoopsModules\Publisher; - - require_once dirname(__DIR__) . '/include/common.php'; /** @@ -40,14 +36,14 @@ function publisher_search_show($options) $helper = Publisher\Helper::getInstance(); /** @var Publisher\CategoryHandler $categoryHandler */ $categoryHandler = $helper->getHandler('Category'); - $categories = $categoryHandler->getCategoriesForSearch(); + $categories = $categoryHandler->getCategoriesForSearch(); if (0 === count($categories)) { return $block; } xoops_loadLanguage('search'); - $andor = Request::getString('andor', Request::getString('andor', '', 'GET'), 'POST'); + $andor = Request::getString('andor', Request::getString('andor', '', 'GET'), 'POST'); $username = Request::getString('uname', Request::getString('uname', null, 'GET'), 'POST'); // $searchin = isset($_POST["searchin"]) ? $_POST["searchin"] : (isset($_GET["searchin"]) ? explode("|", $_GET["searchin"]) : array()); // $searchin = Request::getArray('searchin', (explode("|", Request::getString('searchin', array(), 'GET'))), 'POST'); @@ -59,19 +55,19 @@ function publisher_search_show($options) } $sortby = Request::getString('sortby', Request::getString('sortby', null, 'GET'), 'POST'); - $term = Request::getString('term', Request::getString('term', '', 'GET')); + $term = Request::getString('term', Request::getString('term', '', 'GET')); //mb TODO simplify next lines with category $category = Request::getArray('category', [], 'POST') ?: Request::getArray('category', null, 'GET'); - if (empty($category) || (is_array($category) && in_array('all', $category))) { + if (empty($category) || (is_array($category) && in_array('all', $category, true))) { $category = []; } else { $category = (!is_array($category)) ? explode(',', $category) : $category; $category = array_map('\intval', $category); } - $andor = in_array(mb_strtoupper($andor), ['OR', 'AND', 'EXACT']) ? mb_strtoupper($andor) : 'OR'; - $sortby = in_array(mb_strtolower($sortby), ['itemid', 'datesub', 'title', 'categoryid']) ? mb_strtolower($sortby) : 'itemid'; + $andor = in_array(mb_strtoupper($andor), ['OR', 'AND', 'EXACT'], true) ? mb_strtoupper($andor) : 'OR'; + $sortby = in_array(mb_strtolower($sortby), ['itemid', 'datesub', 'title', 'categoryid'], true) ? mb_strtolower($sortby) : 'itemid'; /* type */ $typeSelect = ''; $sortbySelect .= ''; - $block['typeSelect'] = $typeSelect; - $block['searchSelect'] = $searchSelect; + $block['typeSelect'] = $typeSelect; + $block['searchSelect'] = $searchSelect; $block['categorySelect'] = $categorySelect; - $block['sortbySelect'] = $sortbySelect; - $block['search_term'] = htmlspecialchars($term, ENT_QUOTES); - $block['search_user'] = $username; - $block['publisher_url'] = PUBLISHER_URL; + $block['sortbySelect'] = $sortbySelect; + $block['search_term'] = htmlspecialchars($term, ENT_QUOTES); + $block['search_user'] = $username; + $block['publisher_url'] = PUBLISHER_URL; return $block; } diff --git a/category.php b/category.php index 9f31eb06..3a6ccbb8 100644 --- a/category.php +++ b/category.php @@ -14,8 +14,6 @@ /** * @copyright The XUUPS Project http://sourceforge.net/projects/xuups/ * @license http://www.fsf.org/copyleft/gpl.html GNU public license - * @package Publisher - * @subpackage Action * @since 1.0 * @author trabis * @author The SmartFactory @@ -69,31 +67,31 @@ // creating the Item objects that belong to the selected category switch ($helper->getConfig('format_order_by')) { case 'title': - $sort = 'title'; + $sort = 'title'; $order = 'ASC'; break; case 'date': - $sort = 'datesub'; + $sort = 'datesub'; $order = 'DESC'; break; case 'counter': - $sort = 'counter'; + $sort = 'counter'; $order = 'DESC'; break; case 'rating': - $sort = 'rating'; + $sort = 'rating'; $order = 'DESC'; break; case 'votes': - $sort = 'votes'; + $sort = 'votes'; $order = 'DESC'; break; case 'comments': - $sort = 'comments'; + $sort = 'comments'; $order = 'DESC'; break; default: - $sort = 'weight'; + $sort = 'weight'; $order = 'ASC'; break; } @@ -107,10 +105,10 @@ // Arrays that will hold the informations passed on to smarty variables $category = []; -$items = []; +$items = []; // Populating the smarty variables with informations related to the selected category -$category = $categoryObj->toArraySimple(null); +$category = $categoryObj->toArraySimple(null); $category['categoryPath'] = $categoryObj->getCategoryPath($helper->getConfig('format_linked_path')); //$totalItems = $publisher_categoryHandler->publishedItemsCount($helper->getConfig('idxcat_display_last_item')); @@ -122,7 +120,7 @@ $lastitemsize = (int)$helper->getConfig('idxcat_last_item_size'); // Creating the sub-categories objects that belong to the selected category -$subcatsObj = $helper->getHandler('Category')->getCategories(0, 0, $categoryid); +$subcatsObj = $helper->getHandler('Category')->getCategories(0, 0, $categoryid); $total_subcats = count($subcatsObj); $total_items = 0; @@ -171,11 +169,11 @@ } } -$category['subcats'] = $subcategories; +$category['subcats'] = $subcategories; $category['subcatscount'] = count($subcategories); $thiscategory_itemcount = $totalItems[$categoryid] ?? 0; -$category['total'] = $thiscategory_itemcount; +$category['total'] = $thiscategory_itemcount; if (count($itemsObj) > 0) { /*$userids = []; @@ -191,22 +189,22 @@ // Adding the items of the selected category for ($i = 0; $i < $totalItemOnPage; ++$i) { - $item = $itemsObj[$i]->toArraySimple('default', $helper->getConfig('item_title_size')); + $item = $itemsObj[$i]->toArraySimple('default', $helper->getConfig('item_title_size')); $item['categoryname'] = $categoryObj->name(); $item['categorylink'] = "categoryid(), $categoryObj->short_url()) . "'>" . $categoryObj->name() . ''; - $item['who_when'] = $itemsObj[$i]->getWhoAndWhen(); + $item['who_when'] = $itemsObj[$i]->getWhoAndWhen(); $xoopsTpl->append('items', $item); } if (!empty($lastItemObj[$categoryObj->getVar('categoryid')])) { - $category['last_itemid'] = $lastItemObj[$categoryObj->getVar('categoryid')]->getVar('itemid'); + $category['last_itemid'] = $lastItemObj[$categoryObj->getVar('categoryid')]->getVar('itemid'); $category['last_title_link'] = $lastItemObj[$categoryObj->getVar('categoryid')]->getItemLink(false, $lastitemsize); } $xoopsTpl->assign('show_subtitle', $helper->getConfig('cat_disp_subtitle')); } -$categories = []; +$categories = []; $categories[] = $category; $xoopsTpl->assign('category', $category); $xoopsTpl->assign('categories', $categories); diff --git a/class/BaseObjectHandler.php b/class/BaseObjectHandler.php index 887683bd..ff8d41aa 100644 --- a/class/BaseObjectHandler.php +++ b/class/BaseObjectHandler.php @@ -19,7 +19,6 @@ * * @copyright The XUUPS Project http://sourceforge.net/projects/xuups/ * @license http://www.fsf.org/copyleft/gpl.html GNU public license - * @package Publisher * @since 1.0 * @author trabis * @author The SmartFactory @@ -27,8 +26,6 @@ use XoopsModules\Publisher; - - require_once \dirname(__DIR__) . '/include/common.php'; /** @@ -36,7 +33,6 @@ * * @copyright The XUUPS Project http://sourceforge.net/projects/xuups/ * @license http://www.fsf.org/copyleft/gpl.html GNU public license - * @package Publisher * @since 1.0 * @author trabis * @author Nazar Aziz @@ -57,12 +53,9 @@ class BaseObjectHandler extends \XoopsPersistableObjectHandler */ protected $idfield = 'id'; - public $helper = null; + public $helper = null; public $publisherIsAdmin = null; - /** - * @param \XoopsDatabase|null $db - */ public function init(\XoopsDatabase $db = null) { $this->db = $db; @@ -125,10 +118,10 @@ public function get($id = null, $fields = null) */ public function &getObjects(\CriteriaElement $criteria = null, $idAsKey = false, $asObject = true) //&getObjects($criteria = null, $idAsKey = false) { - $ret = []; + $ret = []; $limit = $start = 0; - $sql = $this->selectQuery($criteria); - $id = $this->idfield; + $sql = $this->selectQuery($criteria); + $id = $this->idfield; if (null !== $criteria) { $limit = $criteria->getLimit(); $start = $criteria->getStart(); @@ -153,7 +146,6 @@ public function &getObjects(\CriteriaElement $criteria = null, $idAsKey = false, } /** - * @param \XoopsObject $obj * @param bool $force * * @return bool @@ -304,7 +296,7 @@ public function deleteAll(\CriteriaElement $criteria = null, $force = true, $asO public function updateAll($fieldname, $fieldvalue, \CriteriaElement $criteria = null, $force = false) //updateAll($fieldname, $fieldvalue, $criteria = null) { $setClause = \is_numeric($fieldvalue) ? $fieldname . ' = ' . $fieldvalue : $fieldname . ' = ' . $this->db->quoteString($fieldvalue); - $sql = 'UPDATE ' . $this->db->prefix($this->dbtable) . ' SET ' . $setClause; + $sql = 'UPDATE ' . $this->db->prefix($this->dbtable) . ' SET ' . $setClause; if (null !== $criteria && $criteria instanceof \CriteriaElement) { $sql .= ' ' . $criteria->renderWhere(); } @@ -349,7 +341,6 @@ protected function deleteQuery($obj) * Singleton - prevent multiple instances of this class * * - * @param \XoopsDatabase|null $db * @return \XoopsObject {@link pagesCategoryHandler} */ public function getInstance(\XoopsDatabase $db = null) @@ -357,7 +348,7 @@ public function getInstance(\XoopsDatabase $db = null) static $instance; if (null === $instance) { $className = $this->className . 'Handler'; - $instance = new $className($db); + $instance = new $className($db); } return $instance; diff --git a/class/BlockForm.php b/class/BlockForm.php index 809c3efe..ac259960 100644 --- a/class/BlockForm.php +++ b/class/BlockForm.php @@ -19,15 +19,12 @@ * * @copyright The XUUPS Project http://sourceforge.net/projects/xuups/ * @license http://www.fsf.org/copyleft/gpl.html GNU public license - * @package Publisher * @since 1.0 * @author trabis */ use XoopsModules\Publisher; - - \xoops_load('XoopsForm'); /** diff --git a/class/Category.php b/class/Category.php index e7cad3bf..0aca5344 100644 --- a/class/Category.php +++ b/class/Category.php @@ -17,7 +17,6 @@ /** * @copyright The XUUPS Project http://sourceforge.net/projects/xuups/ * @license http://www.fsf.org/copyleft/gpl.html GNU public license - * @package Publisher * @since 1.0 * @author trabis * @author The SmartFactory @@ -25,8 +24,6 @@ use XoopsModules\Publisher; - - require_once \dirname(__DIR__) . '/include/common.php'; /** @@ -122,7 +119,7 @@ public function checkPermission() /** @var \XoopsModules\Publisher\PermissionHandler $permissionHandler */ $permissionHandler = $this->helper->getHandler('Permission'); $categoriesGranted = $permissionHandler->getGrantedItems('category_read'); - if (\in_array($this->categoryid(), $categoriesGranted)) { + if (\in_array($this->categoryid(), $categoriesGranted, true)) { $ret = true; } @@ -170,7 +167,7 @@ public function getCategoryPath($withAllLink = true) if (0 != $parentid) { /** @var Publisher\CategoryHandler $categoryHandler */ $categoryHandler = $this->helper->getHandler('Category'); - $parentObj = $categoryHandler->get($parentid); + $parentObj = $categoryHandler->get($parentid); // if ($parentObj->notLoaded()) { // exit; // } @@ -179,7 +176,7 @@ public function getCategoryPath($withAllLink = true) if ($parentObj->notLoaded()) { throw new \RuntimeException(_NOPERM); } - } catch (\Exception $e) { + } catch (\Throwable $e) { $this->helper->addLog($e); // redirect_header('', 1, _NOPERM); } @@ -197,12 +194,12 @@ public function getCategoryPath($withAllLink = true) */ public function getCategoryPathForMetaTitle() { - $ret = ''; + $ret = ''; $parentid = $this->parentid(); if (0 != $parentid) { /** @var Publisher\CategoryHandler $categoryHandler */ $categoryHandler = $this->helper->getHandler('Category'); - $parentObj = $categoryHandler->get($parentid); + $parentObj = $categoryHandler->get($parentid); // if ($parentObj->notLoaded()) { // exit('NOT LOADED'); // } @@ -211,7 +208,7 @@ public function getCategoryPathForMetaTitle() if ($parentObj->notLoaded()) { throw new \RuntimeException('NOT LOADED'); } - } catch (\Exception $e) { + } catch (\Throwable $e) { $this->helper->addLog($e); // redirect_header('', 1, _NOPERM); } @@ -300,11 +297,11 @@ public function store($sendNotifications = true, $force = true) */ public function sendNotifications() { - $tags = []; - $tags['MODULE_NAME'] = $this->helper->getModule()->getVar('name'); + $tags = []; + $tags['MODULE_NAME'] = $this->helper->getModule()->getVar('name'); $tags['CATEGORY_NAME'] = $this->name(); - $tags['CATEGORY_URL'] = $this->getCategoryUrl(); - /* @var \XoopsNotificationHandler $notificationHandler */ + $tags['CATEGORY_URL'] = $this->getCategoryUrl(); + /** @var \XoopsNotificationHandler $notificationHandler */ $notificationHandler = \xoops_getHandler('notification'); $notificationHandler->triggerEvent('global_item', 0, 'category_created', $tags); } @@ -316,18 +313,18 @@ public function sendNotifications() */ public function toArraySimple($category = []) { - $category['categoryid'] = $this->categoryid(); - $category['name'] = $this->name(); - $category['categorylink'] = $this->getCategoryLink(); - $category['categoryurl'] = $this->getCategoryUrl(); - $category['total'] = ($this->getVar('itemcount') > 0) ? $this->getVar('itemcount') : ''; - $category['description'] = $this->description(); - $category['header'] = $this->header(); - $category['meta_keywords'] = $this->meta_keywords(); + $category['categoryid'] = $this->categoryid(); + $category['name'] = $this->name(); + $category['categorylink'] = $this->getCategoryLink(); + $category['categoryurl'] = $this->getCategoryUrl(); + $category['total'] = ($this->getVar('itemcount') > 0) ? $this->getVar('itemcount') : ''; + $category['description'] = $this->description(); + $category['header'] = $this->header(); + $category['meta_keywords'] = $this->meta_keywords(); $category['meta_description'] = $this->meta_description(); - $category['short_url'] = $this->short_url(); + $category['short_url'] = $this->short_url(); if ($this->getVar('last_itemid') > 0) { - $category['last_itemid'] = $this->getVar('last_itemid', 'n'); + $category['last_itemid'] = $this->getVar('last_itemid', 'n'); $category['last_title_link'] = $this->getVar('last_title_link', 'n'); } if ('blank.png' !== $this->getImage()) { @@ -347,12 +344,12 @@ public function toArraySimple($category = []) */ public function toArrayTable($category = []) { - $category['categoryid'] = $this->categoryid(); + $category['categoryid'] = $this->categoryid(); $category['categorylink'] = $this->getCategoryLink(); - $category['total'] = ($this->getVar('itemcount') > 0) ? $this->getVar('itemcount') : ''; - $category['description'] = $this->description(); + $category['total'] = ($this->getVar('itemcount') > 0) ? $this->getVar('itemcount') : ''; + $category['description'] = $this->description(); if ($this->getVar('last_itemid') > 0) { - $category['last_itemid'] = $this->getVar('last_itemid', 'n'); + $category['last_itemid'] = $this->getVar('last_itemid', 'n'); $category['last_title_link'] = $this->getVar('last_title_link', 'n'); } if ('blank.png' !== $this->getImage()) { diff --git a/class/CategoryHandler.php b/class/CategoryHandler.php index be60eb1a..17ac348b 100644 --- a/class/CategoryHandler.php +++ b/class/CategoryHandler.php @@ -17,7 +17,6 @@ /** * @copyright The XUUPS Project http://sourceforge.net/projects/xuups/ * @license http://www.fsf.org/copyleft/gpl.html GNU public license - * @package Publisher * @since 1.0 * @author trabis * @author The SmartFactory @@ -25,8 +24,6 @@ use XoopsModules\Publisher; - - require_once \dirname(__DIR__) . '/include/common.php'; /** @@ -35,7 +32,6 @@ * of Category class objects. * * @author marcan - * @package Publisher */ class CategoryHandler extends \XoopsPersistableObjectHandler { @@ -45,10 +41,6 @@ class CategoryHandler extends \XoopsPersistableObjectHandler public $helper; public $publisherIsAdmin; - /** - * @param \XoopsDatabase|null $db - * @param \XoopsModules\Publisher\Helper|null $helper - */ public function __construct(\XoopsDatabase $db = null, \XoopsModules\Publisher\Helper $helper = null) { /** @var \XoopsModules\Publisher\Helper $this ->helper */ @@ -92,7 +84,7 @@ public function get($id = null, $fields = null) if (isset($cats[$id])) { return $cats[$id]; } - $obj = parent::get($id); + $obj = parent::get($id); $cats[$id] = $obj; return $obj; @@ -171,7 +163,7 @@ public function delete(\XoopsObject $category, $force = false) //delete(&$catego */ public function &getObjects(\CriteriaElement $criteria = null, $idAsKey = false, $as_object = true) //&getObjects($criteria = null, $idAsKey = false) { - $ret = []; + $ret = []; $theObjects = parent::getObjects($criteria, true); foreach ($theObjects as $theObject) { if (!$idAsKey) { @@ -197,7 +189,7 @@ public function &getObjects(\CriteriaElement $criteria = null, $idAsKey = false, */ public function &getCategories($limit = 0, $start = 0, $parentid = 0, $sort = 'weight', $order = 'ASC', $idAsKey = true) { - $ret = []; + $ret = []; $criteria = new \CriteriaCompo(); $criteria->setSort($sort); $criteria->order = $order; // used to fix bug in setOrder() for XOOPS < 2.5.10 @@ -252,7 +244,7 @@ public function getSubCatArray($category, $level, $catArray, $catResult) public function &getCategoriesForSubmit() { global $theresult; - $ret = []; + $ret = []; $criteria = new \CriteriaCompo(); $criteria->setSort('name'); $criteria->order = 'ASC'; // patch for XOOPS <= 2.5.10, does not set order correctly using setOrder() method @@ -295,7 +287,7 @@ public function getCategoriesForSearch() { global $theresult; - $ret = []; + $ret = []; $criteria = new \CriteriaCompo(); $criteria->setSort('name'); $criteria->order = 'ASC'; // patch for XOOPS <= 2.5.10, does not set order correctly using setOrder() method @@ -370,7 +362,7 @@ public function getCategoriesCount($parentid = 0) public function getSubCats($categories) { $criteria = new \CriteriaCompo(new \Criteria('parentid', '(' . \implode(',', \array_keys($categories)) . ')', 'IN')); - $ret = []; + $ret = []; if (!$this->publisherIsAdmin) { $categoriesGranted = $this->helper->getHandler('Permission')->getGrantedItems('category_read'); if (\count($categoriesGranted) > 0) { @@ -385,7 +377,7 @@ public function getSubCats($categories) } $criteria->setSort('weight'); $criteria->order = 'ASC'; // patch for XOOPS <= 2.5.10, does not set order correctly using setOrder() method - $subcats = $this->getObjects($criteria, true); + $subcats = $this->getObjects($criteria, true); /** @var Publisher\Category $subcat */ foreach ($subcats as $subcat) { $ret[$subcat->getVar('parentid')][$subcat->getVar('categoryid')] = $subcat; diff --git a/class/Cloner.php b/class/Cloner.php index 98ba326b..feeb2a05 100644 --- a/class/Cloner.php +++ b/class/Cloner.php @@ -39,7 +39,7 @@ public static function cloneFileFolder($path) } } else { $noChangeExtensions = ['jpeg', 'jpg', 'gif', 'png', 'zip', 'ttf']; - if (\in_array(mb_strtolower(\pathinfo($path, \PATHINFO_EXTENSION)), $noChangeExtensions)) { + if (\in_array(mb_strtolower(\pathinfo($path, \PATHINFO_EXTENSION)), $noChangeExtensions, true)) { // image \copy($path, $newPath); } else { @@ -93,7 +93,7 @@ public static function createLogo($dirname) \imagefilledrectangle($imageModule, 5, 35, 85, 46, $greyColor); // Write text - $textColor = \imagecolorallocate($imageModule, 0, 0, 0); + $textColor = \imagecolorallocate($imageModule, 0, 0, 0); $spaceToBorder = intval((80 - mb_strlen($dirname) * 6.5) / 2); \imagefttext($imageModule, 8.5, 0, $spaceToBorder, 45, $textColor, $font, \ucfirst($dirname), []); diff --git a/class/Common/Breadcrumb.php b/class/Common/Breadcrumb.php index 9a16e36c..e5da1f5b 100644 --- a/class/Common/Breadcrumb.php +++ b/class/Common/Breadcrumb.php @@ -32,7 +32,7 @@ */ class Breadcrumb { - public $dirname; + public $dirname; private $bread = []; public function __construct() @@ -49,7 +49,7 @@ public function __construct() public function addLink($title = '', $link = '') { $this->bread[] = [ - 'link' => $link, + 'link' => $link, 'title' => $title, ]; } diff --git a/class/Common/Configurator.php b/class/Common/Configurator.php index a8ea234e..ed169901 100644 --- a/class/Common/Configurator.php +++ b/class/Common/Configurator.php @@ -31,16 +31,16 @@ class Configurator { public $name; - public $paths = []; - public $icons = []; - public $uploadFolders = []; - public $copyBlankFiles = []; + public $paths = []; + public $icons = []; + public $uploadFolders = []; + public $copyBlankFiles = []; public $copyTestFolders = []; public $templateFolders = []; - public $oldFiles = []; - public $oldFolders = []; - public $renameTables = []; - public $moduleStats = []; + public $oldFiles = []; + public $oldFolders = []; + public $renameTables = []; + public $moduleStats = []; public $modCopyright; /** @@ -50,16 +50,16 @@ public function __construct() { $config = require \dirname(\dirname(__DIR__)) . '/config/config.php'; - $this->name = $config->name; - $this->uploadFolders = $config->uploadFolders; - $this->copyBlankFiles = $config->copyBlankFiles; + $this->name = $config->name; + $this->uploadFolders = $config->uploadFolders; + $this->copyBlankFiles = $config->copyBlankFiles; $this->copyTestFolders = $config->copyTestFolders; $this->templateFolders = $config->templateFolders; - $this->oldFiles = $config->oldFiles; - $this->oldFolders = $config->oldFolders; - $this->renameTables = $config->renameTables; - $this->moduleStats = $config->moduleStats; - $this->modCopyright = $config->modCopyright; + $this->oldFiles = $config->oldFiles; + $this->oldFolders = $config->oldFolders; + $this->renameTables = $config->renameTables; + $this->moduleStats = $config->moduleStats; + $this->modCopyright = $config->modCopyright; $this->paths = require \dirname(\dirname(__DIR__)) . '/config/paths.php'; $this->icons = require \dirname(\dirname(__DIR__)) . '/config/icons.php'; diff --git a/class/Common/FilesManagement.php b/class/Common/FilesManagement.php index a9c22425..08c83250 100644 --- a/class/Common/FilesManagement.php +++ b/class/Common/FilesManagement.php @@ -38,7 +38,7 @@ public static function createFolder($folder) file_put_contents($folder . '/index.html', ''); } - } catch (\Exception $e) { + } catch (\Throwable $e) { echo 'Caught exception: ', $e->getMessage(), '
'; } } @@ -150,8 +150,8 @@ public static function deleteDirectory($src) break; } } elseif (!($success = \unlink($fileInfo->getRealPath()))) { - break; - } + break; + } } // now delete this (sub)directory if all the files are gone if ($success) { @@ -193,7 +193,7 @@ public static function rrmdir($src) foreach ($iterator as $fObj) { if ($fObj->isFile()) { $filename = $fObj->getPathname(); - $fObj = null; // clear this iterator object to close the file + $fObj = null; // clear this iterator object to close the file if (!\unlink($filename)) { return false; // couldn't delete the file } diff --git a/class/Common/Meta.php b/class/Common/Meta.php index 32314af0..43260447 100644 --- a/class/Common/Meta.php +++ b/class/Common/Meta.php @@ -18,6 +18,7 @@ final class Meta * @param string $locale_code * @return string */ + public static function getStatik($locale_code) { return ' @@ -34,6 +35,7 @@ public static function getStatik($locale_code) /** * @return string */ + public static function getRobot() { return ' @@ -46,6 +48,7 @@ public static function getRobot() /** * @return string */ + public static function getNorobot() { return ' @@ -57,6 +60,7 @@ public static function getNorobot() * @param $title * @return string */ + public static function getTitle($title) { return '' . $title . ''; @@ -66,6 +70,7 @@ public static function getTitle($title) * @param $desc * @return string */ + public static function getDescription($desc) { return ''; @@ -75,9 +80,11 @@ public static function getDescription($desc) * @param $langList * @return string */ + public static function getAlternate($langList) { $LL = ''; + if (\count($langList) > 1): foreach ($langList as $lang): $LL .= ' @@ -86,7 +93,9 @@ public static function getAlternate($langList) else: $LL = ' '; + endif; + return $LL; } @@ -94,15 +103,20 @@ public static function getAlternate($langList) * @param $fb * @return string */ + public static function getFacebook($fb) { $fbh = ''; + if (\is_array($fb)): foreach ($fb as $fbkey => $fbrow): $fbh .= ' '; - endforeach; + + endforeach; + endif; + return $fbh; } @@ -110,14 +124,19 @@ public static function getFacebook($fb) * @param $tw * @return string */ + public static function getTwitter($tw) { $twh = ''; + if (\is_array($tw)): foreach ($tw as $twkey => $twrow): $twh .= ''; - endforeach; + + endforeach; + endif; + return $twh; } @@ -125,14 +144,19 @@ public static function getTwitter($tw) * @param $icon * @return string */ + public static function getIcon($icon) { $iconh = ''; + if (\is_array($icon)): foreach ($icon as $iconkey => $iconrow): $iconh .= ''; - endforeach; + + endforeach; + endif; + return $iconh; } @@ -140,6 +164,7 @@ public static function getIcon($icon) * @param $author * @return string */ + public static function getAuthor($author) { return ''; @@ -149,6 +174,7 @@ public static function getAuthor($author) * @param $canonical * @return string */ + public static function getCanonical($canonical) { return ''; @@ -158,6 +184,7 @@ public static function getCanonical($canonical) * @param $manifest * @return string */ + public static function getManifest($manifest) { return ''; @@ -167,6 +194,7 @@ public static function getManifest($manifest) * @param $google * @return string */ + public static function getGoogle($google) { return ''; @@ -176,6 +204,7 @@ public static function getGoogle($google) * @param $bing * @return string */ + public static function getBing($bing) { return ' @@ -186,6 +215,7 @@ public static function getBing($bing) * @param $yandex * @return string */ + public static function getgetYandex($yandex) { return ''; @@ -195,6 +225,7 @@ public static function getgetYandex($yandex) * @param $amp * @return string */ + public static function getAmp($amp) { return ''; @@ -204,19 +235,25 @@ public static function getAmp($amp) * @param $crumb * @return string */ + public static function getBreadcrumb($crumb) { - $h = ''; - $count = 0; + $h = ''; + + $count = 0; + $bcount = \count($crumb); + if (\is_array($crumb)): $h .= ''; + endif; + return $h; } } diff --git a/class/Common/Migrate.php b/class/Common/Migrate.php index 4987fcae..c7bded4e 100644 --- a/class/Common/Migrate.php +++ b/class/Common/Migrate.php @@ -38,7 +38,7 @@ public function __construct() if (!\class_exists($class)) { throw new \RuntimeException("Class '$class' not found"); } - $configurator = new $class(); + $configurator = new $class(); $this->renameTables = $configurator->renameTables; $moduleDirName = \basename(\dirname(\dirname(__DIR__))); @@ -83,7 +83,7 @@ private function convertIPAddresses($tableName, $columnName) */ private function moveDoColumns() { - $tableName = 'newbb_posts_text'; + $tableName = 'newbb_posts_text'; $srcTableName = 'newbb_posts'; if ($this->tableHandler->useTable($tableName) && $this->tableHandler->useTable($srcTableName)) { @@ -91,8 +91,8 @@ private function moveDoColumns() if (false === $attributes) { $this->synchronizeTable($tableName); $updateTable = $GLOBALS['xoopsDB']->prefix($tableName); - $joinTable = $GLOBALS['xoopsDB']->prefix($srcTableName); - $sql = "UPDATE `$updateTable` t1 INNER JOIN `$joinTable` t2 ON t1.post_id = t2.post_id \n" . "SET t1.dohtml = t2.dohtml, t1.dosmiley = t2.dosmiley, t1.doxcode = t2.doxcode\n" . ' , t1.doimage = t2.doimage, t1.dobr = t2.dobr'; + $joinTable = $GLOBALS['xoopsDB']->prefix($srcTableName); + $sql = "UPDATE `$updateTable` t1 INNER JOIN `$joinTable` t2 ON t1.post_id = t2.post_id \n" . "SET t1.dohtml = t2.dohtml, t1.dosmiley = t2.dosmiley, t1.doxcode = t2.doxcode\n" . ' , t1.doimage = t2.doimage, t1.dobr = t2.dobr'; $this->tableHandler->addToQueue($sql); } } diff --git a/class/Common/ModuleFeedback.php b/class/Common/ModuleFeedback.php index 7fce8e9e..adbe65a6 100644 --- a/class/Common/ModuleFeedback.php +++ b/class/Common/ModuleFeedback.php @@ -29,10 +29,10 @@ */ class ModuleFeedback extends \XoopsObject { - public $name = ''; - public $email = ''; - public $site = ''; - public $type = ''; + public $name = ''; + public $email = ''; + public $site = ''; + public $type = ''; public $content = ''; /** @@ -68,7 +68,7 @@ public function getFormFeedback($action = false) if (!$action) { $action = $_SERVER['REQUEST_URI']; } - $moduleDirName = \basename(\dirname(\dirname(__DIR__))); + $moduleDirName = \basename(\dirname(\dirname(__DIR__))); $moduleDirNameUpper = mb_strtoupper($moduleDirName); // Get Theme Form \xoops_load('XoopsFormLoader'); @@ -97,21 +97,21 @@ public function getFormFeedback($action = false) $fbtypeSelect->addOption(\constant('CO_' . $moduleDirNameUpper . '_' . 'FB_TYPE_OTHERS'), \constant('CO_' . $moduleDirNameUpper . '_' . 'FB_TYPE_OTHERS')); $form->addElement($fbtypeSelect, true); - $editorConfigs = []; - $editorConfigs['name'] = 'fb_content'; - $editorConfigs['value'] = $this->content; - $editorConfigs['rows'] = 5; - $editorConfigs['cols'] = 40; - $editorConfigs['width'] = '100%'; + $editorConfigs = []; + $editorConfigs['name'] = 'fb_content'; + $editorConfigs['value'] = $this->content; + $editorConfigs['rows'] = 5; + $editorConfigs['cols'] = 40; + $editorConfigs['width'] = '100%'; $editorConfigs['height'] = '400px'; /** @var \XoopsModuleHandler $moduleHandler */ $moduleHandler = \xoops_getHandler('module'); - $module = $moduleHandler->getByDirname('system'); + $module = $moduleHandler->getByDirname('system'); /** @var \XoopsConfigHandler $configHandler */ - $configHandler = \xoops_getHandler('config'); - $config = $configHandler->getConfigsByCat(0, $module->getVar('mid')); + $configHandler = \xoops_getHandler('config'); + $config = $configHandler->getConfigsByCat(0, $module->getVar('mid')); $editorConfigs['editor'] = $config['general_editor']; - $editor = new \XoopsFormEditor(\constant('CO_' . $moduleDirNameUpper . '_' . 'FB_TYPE_CONTENT'), 'fb_content', $editorConfigs); + $editor = new \XoopsFormEditor(\constant('CO_' . $moduleDirNameUpper . '_' . 'FB_TYPE_CONTENT'), 'fb_content', $editorConfigs); $form->addElement($editor, true); $form->addElement(new \XoopsFormHidden('op', 'send')); diff --git a/class/Common/ModuleStats.php b/class/Common/ModuleStats.php index ad32e7b3..6234fe98 100644 --- a/class/Common/ModuleStats.php +++ b/class/Common/ModuleStats.php @@ -17,6 +17,7 @@ trait ModuleStats * @param array $moduleStats * @return array */ + public static function getModuleStats($configurator, $moduleStats) { if (\count($configurator->moduleStats) > 0) { diff --git a/class/Common/ServerStats.php b/class/Common/ServerStats.php index 6f84dd44..2d008efb 100644 --- a/class/Common/ServerStats.php +++ b/class/Common/ServerStats.php @@ -29,7 +29,7 @@ trait ServerStats public static function getServerStats() { //mb $wfdownloads = WfdownloadsWfdownloads::getInstance(); - $moduleDirName = \basename(\dirname(\dirname(__DIR__))); + $moduleDirName = \basename(\dirname(\dirname(__DIR__))); $moduleDirNameUpper = mb_strtoupper($moduleDirName); \xoops_loadLanguage('common', $moduleDirName); $html = ''; @@ -52,7 +52,7 @@ public static function getServerStats() $html .= '
    '; $gdlib = \function_exists('gd_info') ? '' . \constant('CO_' . $moduleDirNameUpper . '_GDON') . '' : '' . \constant('CO_' . $moduleDirNameUpper . '_GDOFF') . ''; - $html .= '
  • ' . \constant('CO_' . $moduleDirNameUpper . '_GDLIBSTATUS') . $gdlib; + $html .= '
  • ' . \constant('CO_' . $moduleDirNameUpper . '_GDLIBSTATUS') . $gdlib; if (\function_exists('gd_info')) { if (true === ($gdlib = gd_info())) { $html .= '
  • ' . \constant('CO_' . $moduleDirNameUpper . '_GDLIBVERSION') . '' . $gdlib['GD Version'] . ''; @@ -66,7 +66,7 @@ public static function getServerStats() // $html .= '
  • ' . constant('CO_' . $moduleDirNameUpper . '_REGISTERGLOBALS . $registerglobals; $downloads = \ini_get('file_uploads') ? '' . \constant('CO_' . $moduleDirNameUpper . '_ON') . '' : '' . \constant('CO_' . $moduleDirNameUpper . '_OFF') . ''; - $html .= '
  • ' . \constant('CO_' . $moduleDirNameUpper . '_SERVERUPLOADSTATUS') . $downloads; + $html .= '
  • ' . \constant('CO_' . $moduleDirNameUpper . '_SERVERUPLOADSTATUS') . $downloads; $html .= '
  • ' . \constant('CO_' . $moduleDirNameUpper . '_MAXUPLOADSIZE') . ' ' . \ini_get('upload_max_filesize') . ''; $html .= '
  • ' . \constant('CO_' . $moduleDirNameUpper . '_MAXPOSTSIZE') . ' ' . \ini_get('post_max_size') . ''; diff --git a/class/Common/SysUtility.php b/class/Common/SysUtility.php index 3aa9c94b..e8478e43 100644 --- a/class/Common/SysUtility.php +++ b/class/Common/SysUtility.php @@ -2,7 +2,6 @@ declare(strict_types=1); -namespace XoopsModules\Publisher\Helper; namespace XoopsModules\Publisher\Common; /* @@ -19,7 +18,6 @@ */ /** - * * @license https://www.fsf.org/copyleft/gpl.html GNU public license * @copyright https://xoops.org 2000-2020 © XOOPS Project * @author ZySpec @@ -30,22 +28,19 @@ use XoopsFormDhtmlTextArea; use XoopsFormTextArea; use XoopsModules\Publisher; - +use XoopsModules\Publisher\Helper; /** * Class SysUtility */ class SysUtility { use VersionChecks; - //checkVerXoops, checkVerPhp Traits use ServerStats; - // getServerStats Trait use FilesManagement; - // Files Management Trait use ModuleStats; @@ -75,8 +70,8 @@ public static function truncateHtml($text, $length = 100, $ending = '...', $exac // splits all html-tags to scanable lines \preg_match_all('/(<.+?' . '>)?([^<>]*)/s', $text, $lines, \PREG_SET_ORDER); $total_length = mb_strlen($ending); - $open_tags = []; - $truncate = ''; + $open_tags = []; + $truncate = ''; foreach ($lines as $line_matchings) { // if there is any html-tag in this line, handle it and add it (uncounted) to the output if (!empty($line_matchings[1])) { @@ -102,7 +97,7 @@ public static function truncateHtml($text, $length = 100, $ending = '...', $exac $content_length = mb_strlen(\preg_replace('/&[0-9a-z]{2,8};|&#[0-9]{1,7};|[0-9a-f]{1,6};/i', ' ', $line_matchings[2])); if ($total_length + $content_length > $length) { // the number of characters which are left - $left = $length - $total_length; + $left = $length - $total_length; $entities_length = 0; // search for html entities if (\preg_match_all('/&[0-9a-z]{2,8};|&#[0-9]{1,7};|[0-9a-f]{1,6};/i', $line_matchings[2], $entities, \PREG_OFFSET_CAPTURE)) { @@ -121,7 +116,7 @@ public static function truncateHtml($text, $length = 100, $ending = '...', $exac // maximum lenght is reached, so get off the loop break; } - $truncate .= $line_matchings[2]; + $truncate .= $line_matchings[2]; $total_length += $content_length; // if the maximum length is reached, get off the loop @@ -165,12 +160,12 @@ public static function getEditor($helper = null, $options = null) { /** @var Helper $helper */ if (null === $options) { - $options = []; - $options['name'] = 'Editor'; - $options['value'] = 'Editor'; - $options['rows'] = 10; - $options['cols'] = '100%'; - $options['width'] = '100%'; + $options = []; + $options['name'] = 'Editor'; + $options['value'] = 'Editor'; + $options['rows'] = 10; + $options['cols'] = '100%'; + $options['width'] = '100%'; $options['height'] = '400px'; } diff --git a/class/Common/VersionChecks.php b/class/Common/VersionChecks.php index a271a17c..e996bb20 100644 --- a/class/Common/VersionChecks.php +++ b/class/Common/VersionChecks.php @@ -24,14 +24,13 @@ trait VersionChecks /** * Verifies XOOPS version meets minimum requirements for this module * @static - * @param \XoopsModule|null $module * * @param null|string $requiredVer * @return bool true if meets requirements, false if not */ public static function checkVerXoops(\XoopsModule $module = null, $requiredVer = null) { - $moduleDirName = \basename(\dirname(\dirname(__DIR__))); + $moduleDirName = \basename(\dirname(\dirname(__DIR__))); $moduleDirNameUpper = mb_strtoupper($moduleDirName); if (null === $module) { $module = \XoopsModule::getByDirname($moduleDirName); @@ -58,12 +57,11 @@ public static function checkVerXoops(\XoopsModule $module = null, $requiredVer = * Verifies PHP version meets minimum requirements for this module * @static * - * @param \XoopsModule|null $module * @return bool true if meets requirements, false if not */ public static function checkVerPhp(\XoopsModule $module = null) { - $moduleDirName = \basename(\dirname(\dirname(__DIR__))); + $moduleDirName = \basename(\dirname(\dirname(__DIR__))); $moduleDirNameUpper = mb_strtoupper($moduleDirName); if (null === $module) { $module = \XoopsModule::getByDirname($moduleDirName); @@ -98,12 +96,12 @@ public static function checkVerPhp(\XoopsModule $module = null) */ public static function checkVerModule($helper, $source = 'github', $default = 'master') { - $moduleDirName = \basename(\dirname(\dirname(__DIR__))); + $moduleDirName = \basename(\dirname(\dirname(__DIR__))); $moduleDirNameUpper = mb_strtoupper($moduleDirName); - $update = ''; - $repository = 'XoopsModules25x/' . $moduleDirName; + $update = ''; + $repository = 'XoopsModules25x/' . $moduleDirName; // $repository = 'XoopsModules25x/publisher'; //for testing only - $ret = ''; + $ret = ''; $infoReleasesUrl = "https://api.github.com/repos/$repository/releases"; if ('github' === $source) { if (\function_exists('curl_init') && false !== ($curlHandle = \curl_init())) { @@ -117,10 +115,10 @@ public static function checkVerModule($helper, $source = 'github', $default = 'm } elseif (false !== mb_strpos($curlReturn, 'Not Found')) { \trigger_error('Repository Not Found: ' . $infoReleasesUrl); } else { - $file = json_decode($curlReturn, false); + $file = json_decode($curlReturn, false); $latestVersionLink = \sprintf("https://github.com/$repository/archive/%s.zip", $file ? \reset($file)->tag_name : $default); - $latestVersion = $file[0]->tag_name; - $prerelease = $file[0]->prerelease; + $latestVersion = $file[0]->tag_name; + $prerelease = $file[0]->prerelease; if ('master' !== $latestVersionLink) { $update = \constant('CO_' . $moduleDirNameUpper . '_' . 'NEW_VERSION') . $latestVersion; } @@ -136,7 +134,7 @@ public static function checkVerModule($helper, $source = 'github', $default = 'm // $moduleVersion = '1.0'; //for testing only // $moduleDirName = 'aktuelles'; //for testing only if (!$prerelease && \version_compare($moduleVersion, $latestVersion, '<')) { - $ret = []; + $ret = []; $ret[] = $update; $ret[] = $latestVersionLink; } diff --git a/class/Constants.php b/class/Constants.php index 37613f3f..6e97b717 100644 --- a/class/Constants.php +++ b/class/Constants.php @@ -17,13 +17,10 @@ /** * @copyright The XUUPS Project http://sourceforge.net/projects/xuups/ * @license http://www.fsf.org/copyleft/gpl.html GNU public license - * @package Publisher - * @subpackage Include * @since 1.0 * @author trabis */ - /** * interface Constants */ diff --git a/class/File.php b/class/File.php index 49ff49fc..c5f15572 100644 --- a/class/File.php +++ b/class/File.php @@ -17,7 +17,6 @@ /** * @copyright The XUUPS Project http://sourceforge.net/projects/xuups/ * @license http://www.fsf.org/copyleft/gpl.html GNU public license - * @package Publisher * @since 1.0 * @author trabis * @author The SmartFactory @@ -25,8 +24,6 @@ use XoopsModules\Publisher; - - require_once \dirname(__DIR__) . '/include/common.php'; // File status @@ -96,7 +93,7 @@ public function checkUpload($postField, $allowedMimetypes, &$errors) { /** @var Publisher\MimetypeHandler $mimetypeHandler */ $mimetypeHandler = $this->helper->getHandler('Mimetype'); - $errors = []; + $errors = []; if (!$mimetypeHandler->checkMimeTypes($postField)) { $errors[] = \_CO_PUBLISHER_MESSAGE_WRONG_MIMETYPE; @@ -105,8 +102,8 @@ public function checkUpload($postField, $allowedMimetypes, &$errors) if (0 === \count($allowedMimetypes)) { $allowedMimetypes = $mimetypeHandler->getArrayByType(); } - $maxfilesize = $this->helper->getConfig('maximum_filesize'); - $maxfilewidth = $this->helper->getConfig('maximum_image_width'); + $maxfilesize = $this->helper->getConfig('maximum_filesize'); + $maxfilewidth = $this->helper->getConfig('maximum_image_width'); $maxfileheight = $this->helper->getConfig('maximum_image_height'); \xoops_load('XoopsMediaUploader'); $uploader = new \XoopsMediaUploader(Publisher\Utility::getUploadDir(), $allowedMimetypes, $maxfilesize, $maxfilewidth, $maxfileheight); @@ -129,12 +126,12 @@ public function storeUpload($postField, $allowedMimetypes, &$errors) { /** @var Publisher\MimetypeHandler $mimetypeHandler */ $mimetypeHandler = $this->helper->getHandler('Mimetype'); - $itemid = $this->getVar('itemid'); + $itemid = $this->getVar('itemid'); if (0 === \count($allowedMimetypes)) { $allowedMimetypes = $mimetypeHandler->getArrayByType(); } - $maxfilesize = $this->helper->getConfig('maximum_filesize'); - $maxfilewidth = $this->helper->getConfig('maximum_image_width'); + $maxfilesize = $this->helper->getConfig('maximum_filesize'); + $maxfilewidth = $this->helper->getConfig('maximum_image_width'); $maxfileheight = $this->helper->getConfig('maximum_image_height'); if (!\is_dir(Publisher\Utility::getUploadDir())) { if (!\mkdir($concurrentDirectory = Publisher\Utility::getUploadDir(), 0757) && !\is_dir($concurrentDirectory)) { @@ -174,7 +171,7 @@ public function store($allowedMimetypes = null, $force = true, $doupload = true) { if ($this->isNew()) { $errors = []; - $ret = true; + $ret = true; if ($doupload) { $ret = $this->storeUpload('item_upload_file', $allowedMimetypes, $errors); } @@ -270,9 +267,9 @@ public function displayFlash() */ public function getNameFromFilename() { - $ret = $this->filename(); + $ret = $this->filename(); $sepPos = mb_strpos($ret, '_'); - $ret = mb_substr($ret, $sepPos + 1); + $ret = mb_substr($ret, $sepPos + 1); return $ret; } diff --git a/class/FileHandler.php b/class/FileHandler.php index ccef1e08..ecf12503 100644 --- a/class/FileHandler.php +++ b/class/FileHandler.php @@ -17,7 +17,6 @@ /** * @copyright The XUUPS Project http://sourceforge.net/projects/xuups/ * @license http://www.fsf.org/copyleft/gpl.html GNU public license - * @package Publisher * @since 1.0 * @author trabis * @author The SmartFactory @@ -25,8 +24,6 @@ use XoopsModules\Publisher; - - require_once \dirname(__DIR__) . '/include/common.php'; // File status @@ -40,7 +37,6 @@ * of File class objects. * * @author marcan - * @package Publisher */ class FileHandler extends \XoopsPersistableObjectHandler { @@ -50,10 +46,6 @@ class FileHandler extends \XoopsPersistableObjectHandler */ public $helper; - /** - * @param \XoopsDatabase|null $db - * @param \XoopsModules\Publisher\Helper|null $helper - */ public function __construct(\XoopsDatabase $db = null, \XoopsModules\Publisher\Helper $helper = null) { /** @var \XoopsModules\Publisher\Helper $this ->helper */ @@ -96,7 +88,7 @@ public function deleteItemFiles(\XoopsObject $itemObj) if ('publisheritem' !== mb_strtolower(\get_class($itemObj))) { return false; } - $files = $this->getAllFiles($itemObj->itemid()); + $files = $this->getAllFiles($itemObj->itemid()); $result = true; foreach ($files as $file) { if (!$this->delete($file)) { @@ -130,9 +122,9 @@ public function getAllFiles($itemid = 0, $status = -1, $limit = 0, $start = 0, $ [$count] = $GLOBALS['xoopsDB']->fetchRow($result); if ($count > 0) { $this->field_object = 'itemid'; - $this->field_link = 'itemid'; - $hasStatusCriteria = false; - $criteriaStatus = new \CriteriaCompo(); + $this->field_link = 'itemid'; + $hasStatusCriteria = false; + $criteriaStatus = new \CriteriaCompo(); if (\is_array($status)) { $hasStatusCriteria = true; foreach ($status as $v) { @@ -143,8 +135,8 @@ public function getAllFiles($itemid = 0, $status = -1, $limit = 0, $start = 0, $ $criteriaStatus->add(new \Criteria('o.status', $status), 'OR'); } $hasCategoryCriteria = false; - $criteriaCategory = new \CriteriaCompo(); - $category = (array)$category; + $criteriaCategory = new \CriteriaCompo(); + $category = (array)$category; if (isset($category[0]) && 0 != $category[0] && \count($category) > 0) { $hasCategoryCriteria = true; foreach ($category as $cat) { @@ -152,7 +144,7 @@ public function getAllFiles($itemid = 0, $status = -1, $limit = 0, $start = 0, $ } } $criteriaItemid = new \Criteria('o.itemid', $itemid); - $criteria = new \CriteriaCompo(); + $criteria = new \CriteriaCompo(); if (0 != $itemid) { $criteria->add($criteriaItemid); } diff --git a/class/Form/CategoryForm.php b/class/Form/CategoryForm.php index 91ce84da..5f7b8420 100644 --- a/class/Form/CategoryForm.php +++ b/class/Form/CategoryForm.php @@ -19,7 +19,6 @@ * * @copyright The XUUPS Project http://sourceforge.net/projects/xuups/ * @license http://www.fsf.org/copyleft/gpl.html GNU public license - * @package Publisher * @since 1.0 * @author trabis */ @@ -27,8 +26,6 @@ use Xmf\Request; use XoopsModules\Publisher; - - // require_once dirname(dirname(__DIR__)) . '/include/common.php'; \xoops_load('XoopsFormLoader'); @@ -62,7 +59,7 @@ public function __construct(&$target, $subCatsCount = 4) $this->targetObject = &$target; $this->subCatsCount = $subCatsCount; - $memberHandler = \xoops_getHandler('member'); + $memberHandler = \xoops_getHandler('member'); $this->userGroups = $memberHandler->getGroupList(); parent::__construct(\_AM_PUBLISHER_CATEGORY, 'form', \xoops_getenv('SCRIPT_NAME'), 'post', true); @@ -79,9 +76,9 @@ public function createElements() $criteria = new \Criteria(null); $criteria->setSort('weight'); $criteria->order = 'ASC'; // patch for XOOPS <= 2.5.10, does not set order correctly using setOrder() method - $myTree = new \XoopsObjectTree($this->helper->getHandler('Category')->getObjects($criteria), 'categoryid', 'parentid'); - $moduleDirName = \basename(\dirname(__DIR__)); - $module = \XoopsModule::getByDirname($moduleDirName); + $myTree = new \XoopsObjectTree($this->helper->getHandler('Category')->getObjects($criteria), 'categoryid', 'parentid'); + $moduleDirName = \basename(\dirname(__DIR__)); + $module = \XoopsModule::getByDirname($moduleDirName); if (Publisher\Utility::checkVerXoops($GLOBALS['xoopsModule'], '2.5.9')) { $catSelect = $myTree->makeSelectElement('parentid', 'name', '--', $this->targetObject->parentid(), true, 0, '', \_AM_PUBLISHER_PARENT_CATEGORY_EXP); $this->addElement($catSelect); @@ -97,11 +94,11 @@ public function createElements() $this->addElement(new \XoopsFormTextArea(\_AM_PUBLISHER_COLDESCRIPT, 'description', $this->targetObject->description('e'), 7, 60)); // EDITOR - $groups = $GLOBALS['xoopsUser'] ? $GLOBALS['xoopsUser']->getGroups() : XOOPS_GROUP_ANONYMOUS; + $groups = $GLOBALS['xoopsUser'] ? $GLOBALS['xoopsUser']->getGroups() : XOOPS_GROUP_ANONYMOUS; $grouppermHandler = $this->helper->getHandler('GroupPerm'); - $moduleId = $this->helper->getModule()->mid(); - $allowedEditors = Publisher\Utility::getEditors($grouppermHandler->getItemIds('editors', $groups, $moduleId)); - $nohtml = false; + $moduleId = $this->helper->getModule()->mid(); + $allowedEditors = Publisher\Utility::getEditors($grouppermHandler->getItemIds('editors', $groups, $moduleId)); + $nohtml = false; if (\count($allowedEditors) > 0) { $editor = Request::getString('editor', '', 'POST'); if (!empty($editor)) { @@ -112,20 +109,20 @@ public function createElements() $editor = $GLOBALS['xoopsUser']->getVar('publisher_editor') ?? ''; // Need set through user profile } } - $editor = (empty($editor) || !\in_array($editor, $allowedEditors)) ? $this->helper->getConfig('submit_editor') : $editor; + $editor = (empty($editor) || !\in_array($editor, $allowedEditors, true)) ? $this->helper->getConfig('submit_editor') : $editor; $formEditor = new \XoopsFormSelectEditor($this, 'editor', $editor, $nohtml, $allowedEditors); $this->addElement($formEditor); } else { $editor = $this->helper->getConfig('submit_editor'); } - $editorConfigs = []; - $editorConfigs['rows'] = '' == $this->helper->getConfig('submit_editor_rows') ? 35 : $this->helper->getConfig('submit_editor_rows'); - $editorConfigs['cols'] = '' == $this->helper->getConfig('submit_editor_cols') ? 60 : $this->helper->getConfig('submit_editor_cols'); - $editorConfigs['width'] = '' == $this->helper->getConfig('submit_editor_width') ? '100%' : $this->helper->getConfig('submit_editor_width'); + $editorConfigs = []; + $editorConfigs['rows'] = '' == $this->helper->getConfig('submit_editor_rows') ? 35 : $this->helper->getConfig('submit_editor_rows'); + $editorConfigs['cols'] = '' == $this->helper->getConfig('submit_editor_cols') ? 60 : $this->helper->getConfig('submit_editor_cols'); + $editorConfigs['width'] = '' == $this->helper->getConfig('submit_editor_width') ? '100%' : $this->helper->getConfig('submit_editor_width'); $editorConfigs['height'] = '' == $this->helper->getConfig('submit_editor_height') ? '400px' : $this->helper->getConfig('submit_editor_height'); - $editorConfigs['name'] = 'header'; + $editorConfigs['name'] = 'header'; $editorConfigs['value'] = $this->targetObject->header('e'); $textHeader = new \XoopsFormEditor(\_AM_PUBLISHER_CATEGORY_HEADER, $editor, $editorConfigs, $nohtml, $onfailure = null); @@ -133,7 +130,7 @@ public function createElements() $this->addElement($textHeader); // IMAGE - $imageArray = \XoopsLists::getImgListAsArray(Publisher\Utility::getImageDir('category')); + $imageArray = \XoopsLists::getImgListAsArray(Publisher\Utility::getImageDir('category')); $imageSelect = new \XoopsFormSelect('', 'image', $this->targetObject->getImage()); //$imageSelect -> addOption ('-1', '---------------'); $imageSelect->addOptionArray($imageArray); @@ -146,7 +143,7 @@ public function createElements() // IMAGE UPLOAD $max_size = 5000000; - $fileBox = new \XoopsFormFile(\_AM_PUBLISHER_IMAGE_UPLOAD, 'image_file', $max_size); + $fileBox = new \XoopsFormFile(\_AM_PUBLISHER_IMAGE_UPLOAD, 'image_file', $max_size); $fileBox->setExtra("size ='45'"); $fileBox->setDescription(\_AM_PUBLISHER_IMAGE_UPLOAD_DSC); $this->addElement($fileBox); @@ -174,7 +171,7 @@ public function createElements() $this->addElement(new \XoopsFormText('Custom template', 'template', 50, 255, $this->targetObject->getTemplate('e')), false); // READ PERMISSIONS - $readPermissionsTray = new \XoopsFormElementTray(\_AM_PUBLISHER_PERMISSIONS_CAT_READ, ''); + $readPermissionsTray = new \XoopsFormElementTray(\_AM_PUBLISHER_PERMISSIONS_CAT_READ, ''); $selectAllReadCheckbox = new \XoopsFormCheckBox('', 'adminbox', 1); $selectAllReadCheckbox->addOption('allbox', \_AM_SYSTEM_ALL); $selectAllReadCheckbox->setExtra(" onclick='xoopsCheckGroup(\"form\", \"adminbox\" , \"groupsRead[]\");' "); @@ -233,7 +230,7 @@ public function createElements() for ($i = 0; $i < $this->subCatsCount; ++$i) { $subname = ''; if ($i < (($scname = Request::getArray('scname', [], 'POST')) ? \count($scname) : 0)) { - $temp = Request::getArray('scname', [], 'POST'); + $temp = Request::getArray('scname', [], 'POST'); $subname = ($scname = Request::getArray('scname', '', 'POST')) ? $temp[$i] : ''; } $catTray->addElement(new \XoopsFormText('', 'scname[' . $i . ']', 50, 255, $subname)); diff --git a/class/Form/FileForm.php b/class/Form/FileForm.php index 31ca0f5c..75ac25a3 100644 --- a/class/Form/FileForm.php +++ b/class/Form/FileForm.php @@ -19,7 +19,6 @@ * * @copyright The XUUPS Project http://sourceforge.net/projects/xuups/ * @license http://www.fsf.org/copyleft/gpl.html GNU public license - * @package Publisher * @since 1.0 * @author trabis */ @@ -27,8 +26,6 @@ use XoopsModules\Publisher; use XoopsModules\Publisher\Constants; - - // require_once dirname(dirname(__DIR__)) . '/include/common.php'; \xoops_load('XoopsFormLoader'); @@ -50,13 +47,10 @@ class FileForm extends \XoopsThemeForm public $targetObject; - /** - * @param $target - */ public function __construct(&$target) { /** @var Publisher\Helper $this ->helper */ - $this->helper = Publisher\Helper::getInstance(); + $this->helper = Publisher\Helper::getInstance(); $this->targetObject = &$target; parent::__construct(\_AM_PUBLISHER_UPLOAD_FILE, 'form', \xoops_getenv('SCRIPT_NAME'), 'post', true); @@ -99,7 +93,7 @@ public function createElements() public function createButtons() { $filesButtonTray = new \XoopsFormElementTray('', ''); - $filesHidden = new \XoopsFormHidden('op', 'uploadfile'); + $filesHidden = new \XoopsFormHidden('op', 'uploadfile'); $filesButtonTray->addElement($filesHidden); if (!$this->targetObject->fileid()) { diff --git a/class/Form/ItemForm.php b/class/Form/ItemForm.php index d81e4837..02f147bc 100644 --- a/class/Form/ItemForm.php +++ b/class/Form/ItemForm.php @@ -19,8 +19,6 @@ * * @copyright The XUUPS Project http://sourceforge.net/projects/xuups/ * @license http://www.fsf.org/copyleft/gpl.html GNU public license - * @package Class - * @subpackage Forms * @since 1.0 * @author trabis */ @@ -29,8 +27,6 @@ use XoopsModules\Publisher; use XoopsModules\Publisher\Constants; - - // require_once dirname(dirname(__DIR__)) . '/include/common.php'; \xoops_load('XoopsFormLoader'); @@ -45,10 +41,10 @@ class ItemForm extends Publisher\ThemeTabForm { public $checkperm = true; - public $tabs = [ - \_CO_PUBLISHER_TAB_MAIN => 'mainTab', + public $tabs = [ + \_CO_PUBLISHER_TAB_MAIN => 'mainTab', \_CO_PUBLISHER_TAB_IMAGES => 'imagesTab', - \_CO_PUBLISHER_TAB_FILES => 'filesTab', + \_CO_PUBLISHER_TAB_FILES => 'filesTab', \_CO_PUBLISHER_TAB_OTHERS => 'othersTab', ]; @@ -102,7 +98,7 @@ public function isGranted($item) { /** @var Publisher\Helper $helper */ $helper = Publisher\Helper::getInstance(); - $ret = false; + $ret = false; if (!$this->checkperm || $helper->getHandler('Permission')->isGranted('form_view', $item)) { $ret = true; } @@ -122,7 +118,7 @@ public function hasTab($tab) } $tabRef = $this->tabs[$tab]; - $items = $this->$tabRef; + $items = $this->$tabRef; foreach ($items as $item) { if ($this->isGranted($item)) { return true; @@ -145,11 +141,11 @@ public function createElements($obj) $allowedEditors = Publisher\Utility::getEditors($helper->getHandler('Permission')->getGrantedItems('editors')); if (!\is_object($GLOBALS['xoopsUser'])) { - $group = [XOOPS_GROUP_ANONYMOUS]; + $group = [XOOPS_GROUP_ANONYMOUS]; $currentUid = 0; $timeoffset = null; } else { - $group = $GLOBALS['xoopsUser']->getGroups(); + $group = $GLOBALS['xoopsUser']->getGroups(); $currentUid = $GLOBALS['xoopsUser']->uid(); $timeoffset = $GLOBALS['xoopsUser']->getVar('timezone_offset'); } @@ -203,7 +199,7 @@ public function createElements($obj) $editor = $GLOBALS['xoopsUser']->getVar('publisher_editor') ?? ''; // Need set through user profile } } - $editor = (empty($editor) || !\in_array($editor, $allowedEditors)) ? $helper->getConfig('submit_editor') : $editor; + $editor = (empty($editor) || !\in_array($editor, $allowedEditors, true)) ? $helper->getConfig('submit_editor') : $editor; $formEditor = new \XoopsFormSelectEditor($this, 'editor', $editor, $nohtml, $allowedEditors); $this->addElement($formEditor); @@ -211,27 +207,27 @@ public function createElements($obj) $editor = $helper->getConfig('submit_editor'); } - $editorConfigs = []; - $editorConfigs['rows'] = !$helper->getConfig('submit_editor_rows') ? 35 : $helper->getConfig('submit_editor_rows'); - $editorConfigs['cols'] = !$helper->getConfig('submit_editor_cols') ? 60 : $helper->getConfig('submit_editor_cols'); - $editorConfigs['width'] = !$helper->getConfig('submit_editor_width') ? '100%' : $helper->getConfig('submit_editor_width'); + $editorConfigs = []; + $editorConfigs['rows'] = !$helper->getConfig('submit_editor_rows') ? 35 : $helper->getConfig('submit_editor_rows'); + $editorConfigs['cols'] = !$helper->getConfig('submit_editor_cols') ? 60 : $helper->getConfig('submit_editor_cols'); + $editorConfigs['width'] = !$helper->getConfig('submit_editor_width') ? '100%' : $helper->getConfig('submit_editor_width'); $editorConfigs['height'] = !$helper->getConfig('submit_editor_height') ? '400px' : $helper->getConfig('submit_editor_height'); // SUMMARY if ($this->isGranted(Constants::PUBLISHER_SUMMARY)) { // Description //$summaryText = new \XoopsFormTextArea(_CO_PUBLISHER_SUMMARY, 'summary', $obj->getVar('summary', 'e'), 7, 60); - $editorConfigs['name'] = 'summary'; + $editorConfigs['name'] = 'summary'; $editorConfigs['value'] = $obj->getVar('summary', 'e'); - $summaryText = new \XoopsFormEditor(\_CO_PUBLISHER_SUMMARY, $editor, $editorConfigs, $nohtml, $onfailure = null); + $summaryText = new \XoopsFormEditor(\_CO_PUBLISHER_SUMMARY, $editor, $editorConfigs, $nohtml, $onfailure = null); $summaryText->setDescription(\_CO_PUBLISHER_SUMMARY_DSC); $this->addElement($summaryText); } // BODY - $editorConfigs['name'] = 'body'; + $editorConfigs['name'] = 'body'; $editorConfigs['value'] = $obj->getVar('body', 'e'); - $bodyText = new \XoopsFormEditor(\_CO_PUBLISHER_BODY, $editor, $editorConfigs, $nohtml, $onfailure = null); + $bodyText = new \XoopsFormEditor(\_CO_PUBLISHER_BODY, $editor, $editorConfigs, $nohtml, $onfailure = null); $bodyText->setDescription(\_CO_PUBLISHER_BODY_DSC); $this->addElement($bodyText); @@ -265,7 +261,7 @@ public function createElements($obj) // Available pages to wrap if ($this->isGranted(Constants::PUBLISHER_AVAILABLE_PAGE_WRAP)) { - $wrapPages = \XoopsLists::getHtmlListAsArray(Publisher\Utility::getUploadDir(true, 'content')); + $wrapPages = \XoopsLists::getHtmlListAsArray(Publisher\Utility::getUploadDir(true, 'content')); $availableWrapPagesText = []; foreach ($wrapPages as $page) { $availableWrapPagesText[] = "$page"; @@ -318,11 +314,11 @@ public function createElements($obj) // STATUS if ($this->isGranted(Constants::PUBLISHER_STATUS)) { - $options = [ + $options = [ Constants::PUBLISHER_STATUS_SUBMITTED => \_CO_PUBLISHER_SUBMITTED, Constants::PUBLISHER_STATUS_PUBLISHED => \_CO_PUBLISHER_PUBLISHED, - Constants::PUBLISHER_STATUS_OFFLINE => \_CO_PUBLISHER_OFFLINE, - Constants::PUBLISHER_STATUS_REJECTED => \_CO_PUBLISHER_REJECTED, + Constants::PUBLISHER_STATUS_OFFLINE => \_CO_PUBLISHER_OFFLINE, + Constants::PUBLISHER_STATUS_REJECTED => \_CO_PUBLISHER_REJECTED, ]; $statusSelect = new \XoopsFormSelect(\_CO_PUBLISHER_STATUS, 'status', $obj->getVar('status')); $statusSelect->addOptionArray($options); @@ -348,18 +344,17 @@ public function createElements($obj) // Date expire if ($this->isGranted(Constants::PUBLISHER_DATEEXPIRE)) { if ($obj->isNew()) { - $dateexpire = \time(); + $dateexpire = \time(); $dateexpire_opt = 0; } elseif (0 == $obj->getVar('dateexpire')) { - $dateexpire_opt = 0; - $dateexpire = \time(); - } else { - $dateexpire_opt = 1; - $dateexpire = $obj->getVar('dateexpire'); - } - + $dateexpire_opt = 0; + $dateexpire = \time(); + } else { + $dateexpire_opt = 1; + $dateexpire = $obj->getVar('dateexpire'); + } - $dateExpireYesNo = new \XoopsFormRadioYN('', 'use_expire_yn', $dateexpire_opt); + $dateExpireYesNo = new \XoopsFormRadioYN('', 'use_expire_yn', $dateexpire_opt); $dateexpire = \strtotime(\formatTimestamp($dateexpire)); //set to user timezone $dateexpire_datetime = new \XoopsFormDateTime('', 'dateexpire', $size = 15, $dateexpire, true); if (0 == $dateexpire_opt) { @@ -385,9 +380,9 @@ public function createElements($obj) // IMAGE if ($this->isGranted(Constants::PUBLISHER_IMAGE_ITEM)) { - $objimages = $obj->getImages(); - $mainarray = \is_object($objimages['main']) ? [$objimages['main']] : []; - $mergedimages = \array_merge($mainarray, $objimages['others']); + $objimages = $obj->getImages(); + $mainarray = \is_object($objimages['main']) ? [$objimages['main']] : []; + $mergedimages = \array_merge($mainarray, $objimages['others']); $objimage_array = []; foreach ($mergedimages as $imageObj) { $objimage_array[$imageObj->getVar('image_name')] = $imageObj->getVar('image_nicename'); @@ -400,22 +395,22 @@ public function createElements($obj) $catlist = $imgcatHandler->getList($group, 'imgcat_read', 1); } $imgcatConfig = $helper->getConfig('submit_imgcat'); - if (\in_array(Constants::PUBLISHER_IMGCAT_ALL, $imgcatConfig)) { + if (\in_array(Constants::PUBLISHER_IMGCAT_ALL, $imgcatConfig, true)) { $catids = \array_keys($catlist); } else { // compare selected in options with readable of user $catlist = \array_intersect($catlist, $imgcatConfig); - $catids = \array_keys($catlist); + $catids = \array_keys($catlist); } $imageObjs = []; if (!empty($catids)) { $imageHandler = \xoops_getHandler('image'); - $criteria = new \CriteriaCompo(new \Criteria('imgcat_id', '(' . \implode(',', $catids) . ')', 'IN')); + $criteria = new \CriteriaCompo(new \Criteria('imgcat_id', '(' . \implode(',', $catids) . ')', 'IN')); $criteria->add(new \Criteria('image_display', 1)); $criteria->setSort('image_nicename'); $criteria->order = 'ASC'; // patch for XOOPS <= 2.5.10, does not set order correctly using setOrder() method - $imageObjs = $imageHandler->getObjects($criteria, true); + $imageObjs = $imageHandler->getObjects($criteria, true); unset($criteria); } $image_array = []; @@ -441,13 +436,13 @@ public function createElements($obj) $buttonremove = new \XoopsFormButton('', 'buttonremove', \_CO_PUBLISHER_REMOVE); $buttonremove->setExtra("onclick='publisher_appendSelectOption(\"image_item\", \"image_notused\"), publisher_updateSelectOption(\"image_item\", \"image_featured\")'"); - $opentable = new \XoopsFormLabel('', '
    '); - $addcol = new \XoopsFormLabel('', ''); - $addbreak = new \XoopsFormLabel('', '
    '); + $opentable = new \XoopsFormLabel('', '
    '); + $addcol = new \XoopsFormLabel('', ''); + $addbreak = new \XoopsFormLabel('', '
    '); $closetable = new \XoopsFormLabel('', '
    '); $GLOBALS['xoTheme']->addScript(PUBLISHER_URL . '/assets/js/ajaxupload.3.9.js'); - $js_data = new \XoopsFormLabel( + $js_data = new \XoopsFormLabel( '', ' '; // } - } else { - $pdfButton .= "" . \_CO_PUBLISHER_PDF . " "; - $pdfButton .= ' '; - } - return $pdfButton; + } else { + $pdfButton .= "" . \_CO_PUBLISHER_PDF . " "; + $pdfButton .= ' '; } - /** + return $pdfButton; + } + + /** * @return string */ public function getPrintLinks() { - $printLinks = ''; + $printLinks = ''; // Print button $printLinks .= "itemid(), $this->short_url()) . "' rel='nofollow' target='_blank'>" . \_CO_PUBLISHER_PRINT . " "; $printLinks .= ' '; + return $printLinks; } @@ -528,15 +529,15 @@ public function sendNotifications($notifications = []) { /** @var \XoopsNotificationHandler $notificationHandler */ $notificationHandler = \xoops_getHandler('notification'); - $tags = []; + $tags = []; - $tags['MODULE_NAME'] = $this->helper->getModule()->getVar('name'); - $tags['ITEM_NAME'] = $this->getTitle(); - $tags['ITEM_SUBNAME'] = $this->getSubtitle(); + $tags['MODULE_NAME'] = $this->helper->getModule()->getVar('name'); + $tags['ITEM_NAME'] = $this->getTitle(); + $tags['ITEM_SUBNAME'] = $this->getSubtitle(); $tags['CATEGORY_NAME'] = $this->getCategoryName(); - $tags['CATEGORY_URL'] = PUBLISHER_URL . '/category.php?categoryid=' . $this->categoryid(); - $tags['ITEM_BODY'] = $this->body(); - $tags['DATESUB'] = $this->getDatesub(); + $tags['CATEGORY_URL'] = PUBLISHER_URL . '/category.php?categoryid=' . $this->categoryid(); + $tags['ITEM_BODY'] = $this->body(); + $tags['DATESUB'] = $this->getDatesub(); foreach ($notifications as $notification) { switch ($notification) { case Constants::PUBLISHER_NOTIFY_ITEM_PUBLISHED: @@ -566,8 +567,8 @@ public function sendNotifications($notifications = []) public function setDefaultPermissions() { $memberHandler = \xoops_getHandler('member'); - $groups = $memberHandler->getGroupList(); - $groupIds = 0 < \count($groups) ? \array_keys($groups) : []; + $groups = $memberHandler->getGroupList(); + $groupIds = \count($groups) > 0 ? \array_keys($groups) : []; /* $j = 0; $groupIds = []; @@ -639,7 +640,7 @@ public function getItemLink($class = false, $maxsize = 0) public function getWhoAndWhen() { $posterName = $this->getLinkedPosterName(); - $postdate = $this->getDatesub(); + $postdate = $this->getDatesub(); return \sprintf(\_CO_PUBLISHER_POSTEDBY, $posterName, $postdate); } @@ -718,11 +719,11 @@ public function getImages() static $ret; $itemid = $this->getVar('itemid'); if (!isset($ret[$itemid])) { - $ret[$itemid]['main'] = ''; + $ret[$itemid]['main'] = ''; $ret[$itemid]['others'] = []; - $imagesIds = []; - $image = $this->getVar('image'); - $images = $this->getVar('images'); + $imagesIds = []; + $image = $this->getVar('image'); + $images = $this->getVar('images'); if ('' != $images) { $imagesIds = \explode('|', $images); } @@ -732,8 +733,8 @@ public function getImages() $imageObjs = []; if (\count($imagesIds) > 0) { $imageHandler = \xoops_getHandler('image'); - $criteria = new \CriteriaCompo(new \Criteria('image_id', '(' . \implode(',', $imagesIds) . ')', 'IN')); - $imageObjs = $imageHandler->getObjects($criteria, true); + $criteria = new \CriteriaCompo(new \Criteria('image_id', '(' . \implode(',', $imagesIds) . ')', 'IN')); + $imageObjs = $imageHandler->getObjects($criteria, true); unset($criteria); } foreach ($imageObjs as $id => $imageObj) { @@ -763,35 +764,35 @@ public function toArraySimple($display = 'default', $maxCharTitle = 0, $maxCharS $itemPageId = -1; if (\is_numeric($display)) { $itemPageId = $display; - $display = 'all'; + $display = 'all'; } - $item['itemid'] = $this->itemid(); - $item['uid'] = $this->uid(); - $item['itemurl'] = $this->getItemUrl(); - $item['titlelink'] = $this->getItemLink('titlelink', $maxCharTitle); - $item['subtitle'] = $this->subtitle(); - $item['datesub'] = $this->getDatesub(); + $item['itemid'] = $this->itemid(); + $item['uid'] = $this->uid(); + $item['itemurl'] = $this->getItemUrl(); + $item['titlelink'] = $this->getItemLink('titlelink', $maxCharTitle); + $item['subtitle'] = $this->subtitle(); + $item['datesub'] = $this->getDatesub(); $item['dateexpire'] = $this->getDateExpire(); - $item['counter'] = $this->counter(); - $item['hits'] = ' ' . $this->counter() . ' ' . _READS . ''; - $item['who'] = $this->getWho(); - $item['when'] = $this->getWhen(); - $item['category'] = $this->getCategoryName(); - $item['categorylink'] = $this->getCategoryLink(); - $item['cancomment'] = $this->cancomment(); + $item['counter'] = $this->counter(); + $item['hits'] = ' ' . $this->counter() . ' ' . _READS . ''; + $item['who'] = $this->getWho(); + $item['when'] = $this->getWhen(); + $item['category'] = $this->getCategoryName(); + $item['categorylink'] = $this->getCategoryLink(); + $item['cancomment'] = $this->cancomment(); $comments = $this->comments(); - if ($comments > 0) { - //shows 1 comment instead of 1 comm. if comments ==1 - //langugage file modified accordingly - if (1 == $comments) { - $item['comments'] = ' ' . \_MD_PUBLISHER_ONECOMMENT . ' '; - } else { - $item['comments'] = ' ' . $comments . ' ' . \_MD_PUBLISHER_COMMENTS . ' '; - } + if ($comments > 0) { + //shows 1 comment instead of 1 comm. if comments ==1 + //langugage file modified accordingly + if (1 == $comments) { + $item['comments'] = ' ' . \_MD_PUBLISHER_ONECOMMENT . ' '; } else { - $item['comments'] = ' ' . \_MD_PUBLISHER_NO_COMMENTS . ' '; + $item['comments'] = ' ' . $comments . ' ' . \_MD_PUBLISHER_COMMENTS . ' '; } - $item = $this->getMainImage($item); + } else { + $item['comments'] = ' ' . \_MD_PUBLISHER_NO_COMMENTS . ' '; + } + $item = $this->getMainImage($item); switch ($display) { case 'summary': $item = $this->toArrayFull($item); @@ -813,9 +814,9 @@ public function toArraySimple($display = 'default', $maxCharTitle = 0, $maxCharS if (!$summary) { $summary = $this->getBody($maxCharSummary); } - $item['summary'] = $summary; + $item['summary'] = $summary; $item['truncated'] = $maxCharSummary > 0 && mb_strlen($summary) > $maxCharSummary; - $item = $this->toArrayFull($item); + $item = $this->toArrayFull($item); break; case 'all': $item = $this->toArrayFull($item); @@ -825,9 +826,9 @@ public function toArraySimple($display = 'default', $maxCharTitle = 0, $maxCharS // Highlighting searched words $highlight = true; if ($highlight && Request::getString('keywords', '', 'GET')) { - $myts = \MyTextSanitizer::getInstance(); + $myts = \MyTextSanitizer::getInstance(); $keywords = $myts->htmlSpecialChars(\trim(\urldecode(Request::getString('keywords', '', 'GET')))); - $fields = ['title', 'maintext', 'summary']; + $fields = ['title', 'maintext', 'summary']; foreach ($fields as $field) { if (isset($item[$field])) { $item[$field] = $this->highlight($item[$field], $keywords); @@ -845,21 +846,21 @@ public function toArraySimple($display = 'default', $maxCharTitle = 0, $maxCharS */ public function toArrayFull($item) { - $item['title'] = $this->getTitle(); - $item['clean_title'] = $this->getTitle(); - $item['itemurl'] = $this->getItemUrl(); - - $item['adminlink'] = $this->getAdminLinks(); - $item['pdfbutton'] = $this->getPdfButton(); - $item['printlink'] = $this->getPrintLinks(); + $item['title'] = $this->getTitle(); + $item['clean_title'] = $this->getTitle(); + $item['itemurl'] = $this->getItemUrl(); + + $item['adminlink'] = $this->getAdminLinks(); + $item['pdfbutton'] = $this->getPdfButton(); + $item['printlink'] = $this->getPrintLinks(); $item['categoryPath'] = $this->getCategoryPath($this->helper->getConfig('format_linked_path')); - $item['who_when'] = $this->getWhoAndWhen(); - $item['who'] = $this->getWho(); - $item['when'] = $this->getWhen(); - $item['category'] = $this->getCategoryName(); - $item['body'] = $this->getBody(); - $item['more'] = $this->getItemUrl(); - $item = $this->getMainImage($item); + $item['who_when'] = $this->getWhoAndWhen(); + $item['who'] = $this->getWho(); + $item['when'] = $this->getWhen(); + $item['category'] = $this->getCategoryName(); + $item['body'] = $this->getBody(); + $item['more'] = $this->getItemUrl(); + $item = $this->getMainImage($item); return $item; } @@ -873,7 +874,7 @@ public function toArrayFull($item) public function toArrayAll($item, $itemPageId) { $item['maintext'] = $this->buildMainText($itemPageId, $this->getBody()); - $item = $this->getOtherImages($item); + $item = $this->getOtherImages($item); return $item; } @@ -885,14 +886,14 @@ public function toArrayAll($item, $itemPageId) */ public function getMainImage($item = []) { - $images = $this->getImages(); + $images = $this->getImages(); $item['image_path'] = ''; $item['image_name'] = ''; if (\is_object($images['main'])) { - $dimensions = \getimagesize($GLOBALS['xoops']->path('uploads/' . $images['main']->getVar('image_name'))); - $item['image_width'] = $dimensions[0]; + $dimensions = \getimagesize($GLOBALS['xoops']->path('uploads/' . $images['main']->getVar('image_name'))); + $item['image_width'] = $dimensions[0]; $item['image_height'] = $dimensions[1]; - $item['image_path'] = XOOPS_URL . '/uploads/' . $images['main']->getVar('image_name'); + $item['image_path'] = XOOPS_URL . '/uploads/' . $images['main']->getVar('image_name'); // check to see if GD function exist if (!\function_exists('imagecreatetruecolor')) { $item['image_thumb'] = XOOPS_URL . '/uploads/' . $images['main']->getVar('image_name'); @@ -912,14 +913,14 @@ public function getMainImage($item = []) */ public function getOtherImages($item = []) { - $images = $this->getImages(); + $images = $this->getImages(); $item['images'] = []; - $i = 0; + $i = 0; foreach ($images['others'] as $image) { - $dimensions = \getimagesize($GLOBALS['xoops']->path('uploads/' . $image->getVar('image_name'))); - $item['images'][$i]['width'] = $dimensions[0]; + $dimensions = \getimagesize($GLOBALS['xoops']->path('uploads/' . $image->getVar('image_name'))); + $item['images'][$i]['width'] = $dimensions[0]; $item['images'][$i]['height'] = $dimensions[1]; - $item['images'][$i]['path'] = XOOPS_URL . '/uploads/' . $image->getVar('image_name'); + $item['images'][$i]['path'] = XOOPS_URL . '/uploads/' . $image->getVar('image_name'); // check to see if GD function exist if (!\function_exists('imagecreatetruecolor')) { $item['images'][$i]['thumb'] = XOOPS_URL . '/uploads/' . $image->getVar('image_name'); @@ -977,8 +978,8 @@ protected function convertForJapanese($str) return $str; } // presume OS Browser - $agent = Request::getString('HTTP_USER_AGENT', '', 'SERVER'); - $os = ''; + $agent = Request::getString('HTTP_USER_AGENT', '', 'SERVER'); + $os = ''; $browser = ''; // if (preg_match("/Win/i", $agent)) { if (false !== mb_stripos($agent, 'Win')) { @@ -1050,7 +1051,7 @@ public function setVarsFromRequest() // $this->setVar('categoryid', $categoryid);} if (\is_object($GLOBALS['xoopsUser'])) { $userTimeoffset = $GLOBALS['xoopsUser']->getVar('timezone_offset'); - }else{ + } else { $userTimeoffset = null; } $this->setVar('categoryid', Request::getInt('categoryid', 0, 'POST')); @@ -1069,15 +1070,15 @@ public function setVarsFromRequest() //Image hack $imageItemIds = []; - $sql = 'SELECT image_id, image_name FROM ' . $GLOBALS['xoopsDB']->prefix('image'); + $sql = 'SELECT image_id, image_name FROM ' . $GLOBALS['xoopsDB']->prefix('image'); $result = $GLOBALS['xoopsDB']->query($sql, 0, 0); while (false !== ($myrow = $GLOBALS['xoopsDB']->fetchArray($result))) { $imageName = $myrow['image_name']; - $id = $myrow['image_id']; + $id = $myrow['image_id']; if ($imageName == $imageFeatured) { $this->setVar('image', $id); } - if (\in_array($imageName, $imageItem)) { + if (\in_array($imageName, $imageItem, true)) { $imageItemIds[] = $id; } } @@ -1107,11 +1108,11 @@ public function setVarsFromRequest() $dateTimeObj->setTime(0, 0, (int)$resTime['time']); $serverTimestamp = userTimeToServerTime($dateTimeObj->getTimestamp(), $userTimeoffset); $this->setVar('datesub', $serverTimestamp); - // } + // } } elseif ($this->isNew()) { $this->setVar('datesub', \time()); } - + // date expire if (0 !== Request::getInt('use_expire_yn', 0, 'POST')) { if ('' !== Request::getString('dateexpire', '', 'POST')) { diff --git a/class/ItemHandler.php b/class/ItemHandler.php index 8a117d00..60d541b5 100644 --- a/class/ItemHandler.php +++ b/class/ItemHandler.php @@ -17,7 +17,6 @@ /** * @copyright The XUUPS Project http://sourceforge.net/projects/xuups/ * @license http://www.fsf.org/copyleft/gpl.html GNU public license - * @package Publisher * @since 1.0 * @author trabis * @author The SmartFactory @@ -25,7 +24,6 @@ use XoopsModules\Publisher; - require_once \dirname(__DIR__) . '/include/common.php'; /** @@ -34,7 +32,6 @@ * of Q&A class objects. * * @author marcan - * @package Publisher */ class ItemHandler extends \XoopsPersistableObjectHandler { @@ -46,10 +43,6 @@ class ItemHandler extends \XoopsPersistableObjectHandler protected $resultCatCounts = []; - /** - * @param \XoopsDatabase|null $db - * @param \XoopsModules\Publisher\Helper|null $helper - */ public function __construct(\XoopsDatabase $db = null, \XoopsModules\Publisher\Helper $helper = null) { /** @var Publisher\Helper $this ->helper */ @@ -178,8 +171,8 @@ public function delete(\XoopsObject $item, $force = false) */ public function &getObjects(\CriteriaElement $criteria = null, $idKey = 'none', $as_object = true, $notNullFields = null) { - $limit = $start = 0; - $ret = []; + $limit = $start = 0; + $ret = []; $notNullFields = (null !== $notNullFields) ?: ''; $sql = 'SELECT * FROM ' . $this->db->prefix($this->helper->getDirname() . '_items'); @@ -420,7 +413,7 @@ public function getAllExpired($limit = 0, $start = 0, $categoryid = -1, $sort = */ public function getPreviousPublished($obj) { - $ret = false; + $ret = false; $otherCriteria = new \CriteriaCompo(); $otherCriteria->add(new \Criteria('datesub', $obj->getVar('datesub'), '<')); $objs = $this->getItems(1, 0, [Constants::PUBLISHER_STATUS_PUBLISHED], $obj->getVar('categoryid'), 'datesub', 'DESC', '', true, $otherCriteria, 'none'); @@ -438,7 +431,7 @@ public function getPreviousPublished($obj) */ public function getNextPublished($obj) { - $ret = false; + $ret = false; $otherCriteria = new \CriteriaCompo(); $otherCriteria->add(new \Criteria('datesub', $obj->getVar('datesub'), '>')); $otherCriteria->add(new \Criteria('datesub', \time(), '<=')); @@ -563,7 +556,7 @@ public function getItems($limit = 0, $start = 0, $status = '', $categoryid = -1, $criteria->setStart($start); $criteria->setSort($sort); $criteria->order = $order; // patch for XOOPS <= 2.5.10 does not set order correctly using setOrder() method - $ret = &$this->getObjects($criteria, $idKey, $notNullFields); + $ret = &$this->getObjects($criteria, $idKey, $notNullFields); return $ret; } @@ -573,13 +566,13 @@ public function getItems($limit = 0, $start = 0, $status = '', $categoryid = -1, * @param string $status * @param int $categoryId * - * @return bool * @throws \Exception * @throws \Exception + * @return bool */ public function getRandomItem($field = '', $status = '', $categoryId = -1) { - $ret = false; + $ret = false; $notNullFields = $field; // Getting the number of published Items $totalItems = $this->getItemsCount($categoryId, $status, $notNullFields); @@ -588,7 +581,7 @@ public function getRandomItem($field = '', $status = '', $categoryId = -1) $entryNumber = \random_int(0, $totalItems); //TODO switch in PHP 7 to random_int() // $entryNumber2 = random_int(0, $totalItems); - $item = $this->getItems(1, $entryNumber, $status, $categoryId, $sort = 'datesub', $order = 'DESC', $notNullFields); + $item = $this->getItems(1, $entryNumber, $status, $categoryId, $sort = 'datesub', $order = 'DESC', $notNullFields); if ($item) { $ret = $item[0]; } @@ -670,14 +663,14 @@ public function notNullFieldClause($notNullFields = '', $withAnd = false) */ public function getItemsFromSearch($queryArray = [], $andor = 'AND', $limit = 0, $offset = 0, $userid = 0, $categories = [], $sortby = 0, $searchin = '', $extra = '') { - $count = 0; - $ret = []; + $count = 0; + $ret = []; $criteriaKeywords = $criteriaPermissions = $criteriaUser = null; - /* @var \XoopsGroupPermHandler $grouppermHandler */ + /** @var \XoopsGroupPermHandler $grouppermHandler */ $grouppermHandler = \xoops_getHandler('groupperm'); - $groups = \is_object($GLOBALS['xoopsUser']) ? $GLOBALS['xoopsUser']->getGroups() : XOOPS_GROUP_ANONYMOUS; - $searchin = empty($searchin) ? ['title', 'body', 'summary'] : (\is_array($searchin) ? $searchin : [$searchin]); - if (\in_array('all', $searchin) || 0 === \count($searchin)) { + $groups = \is_object($GLOBALS['xoopsUser']) ? $GLOBALS['xoopsUser']->getGroups() : XOOPS_GROUP_ANONYMOUS; + $searchin = empty($searchin) ? ['title', 'body', 'summary'] : (\is_array($searchin) ? $searchin : [$searchin]); + if (\in_array('all', $searchin, true) || 0 === \count($searchin)) { $searchin = ['title', 'subtitle', 'body', 'summary', 'meta_keywords']; //add support for searching in tags if Tag module exists and is active if (false !== $this->helper::getHelper('tag')) { @@ -685,7 +678,7 @@ public function getItemsFromSearch($queryArray = [], $andor = 'AND', $limit = 0, } } if ($userid && \is_array($userid)) { - $userid = \array_map('\intval', $userid); + $userid = \array_map('\intval', $userid); $criteriaUser = new \CriteriaCompo(); $criteriaUser->add(new \Criteria('uid', '(' . \implode(',', $userid) . ')', 'IN'), 'OR'); } elseif (\is_numeric($userid) && $userid > 0) { @@ -736,7 +729,7 @@ public function getItemsFromSearch($queryArray = [], $andor = 'AND', $limit = 0, $criteriaPermissions->add($grantedCategories, 'AND'); } elseif (\count($categories) > 0) { $criteriaPermissions = new \CriteriaCompo(); - $grantedCategories = new \Criteria('categoryid', '(' . \implode(',', $categories) . ')', 'IN'); + $grantedCategories = new \Criteria('categoryid', '(' . \implode(',', $categories) . ')', 'IN'); $criteriaPermissions->add($grantedCategories, 'AND'); } $criteriaItemsStatus = new \CriteriaCompo(); @@ -765,7 +758,7 @@ public function getItemsFromSearch($queryArray = [], $andor = 'AND', $limit = 0, $order = 'DESC'; } $criteria->order = $order; // patch for XOOPS <= 2.5.10, does not set order correctly using setOrder() method - $ret = &$this->getObjects($criteria); + $ret = &$this->getObjects($criteria); return $ret; } @@ -778,11 +771,11 @@ public function getItemsFromSearch($queryArray = [], $andor = 'AND', $limit = 0, */ public function getLastPublishedByCat($categoriesObj, $status = [Constants::PUBLISHER_STATUS_PUBLISHED]) { - $ret = []; + $ret = []; $catIds = []; foreach ($categoriesObj as $parentid) { foreach ($parentid as $category) { - $catId = $category->getVar('categoryid'); + $catId = $category->getVar('categoryid'); $catIds[$catId] = $catId; } } @@ -815,12 +808,12 @@ public function getLastPublishedByCat($categoriesObj, $status = [Constants::PUBL unset($item); } */ - $sql = 'SELECT mi.categoryid, mi.itemid, mi.title, mi.short_url, mi.uid, mi.datesub'; - $sql .= ' FROM (SELECT categoryid, MAX(datesub) AS date FROM ' . $this->db->prefix($this->helper->getDirname() . '_items'); - $sql .= ' WHERE status IN (' . \implode(',', $status) . ')'; - $sql .= ' AND categoryid IN (' . \implode(',', $catIds) . ')'; - $sql .= ' GROUP BY categoryid)mo'; - $sql .= ' JOIN ' . $this->db->prefix($this->helper->getDirname() . '_items') . ' mi ON mi.datesub = mo.date'; + $sql = 'SELECT mi.categoryid, mi.itemid, mi.title, mi.short_url, mi.uid, mi.datesub'; + $sql .= ' FROM (SELECT categoryid, MAX(datesub) AS date FROM ' . $this->db->prefix($this->helper->getDirname() . '_items'); + $sql .= ' WHERE status IN (' . \implode(',', $status) . ')'; + $sql .= ' AND categoryid IN (' . \implode(',', $catIds) . ')'; + $sql .= ' GROUP BY categoryid)mo'; + $sql .= ' JOIN ' . $this->db->prefix($this->helper->getDirname() . '_items') . ' mi ON mi.datesub = mo.date'; $result = $this->db->query($sql); while (false !== ($row = $this->db->fetchArray($result))) { // $item = new Item(); @@ -843,12 +836,12 @@ public function countArticlesByCat($parentid, $catsCount, $spaces = '') { // global $resultCatCounts; $newspaces = $spaces . '--'; - $thecount = 0; + $thecount = 0; foreach ($catsCount[$parentid] as $subCatId => $count) { - $thecount += $count; + $thecount += $count; $this->resultCatCounts[$subCatId] = $count; if (isset($catsCount[$subCatId])) { - $thecount += $this->countArticlesByCat($subCatId, $catsCount, $newspaces); + $thecount += $this->countArticlesByCat($subCatId, $catsCount, $newspaces); $this->resultCatCounts[$subCatId] = $thecount; } } @@ -867,16 +860,16 @@ public function getCountsByCat($catId, $status, $inSubCat = false) { // global $resultCatCounts; - $ret = []; + $ret = []; $catsCount = []; - $sql = 'SELECT c.parentid, i.categoryid, COUNT(*) AS count FROM ' . $this->db->prefix($this->helper->getDirname() . '_items') . ' AS i INNER JOIN ' . $this->db->prefix($this->helper->getDirname() . '_categories') . ' AS c ON i.categoryid=c.categoryid'; + $sql = 'SELECT c.parentid, i.categoryid, COUNT(*) AS count FROM ' . $this->db->prefix($this->helper->getDirname() . '_items') . ' AS i INNER JOIN ' . $this->db->prefix($this->helper->getDirname() . '_categories') . ' AS c ON i.categoryid=c.categoryid'; if ((int)$catId > 0) { $sql .= ' WHERE i.categoryid = ' . (int)$catId; $sql .= ' AND i.status IN (' . \implode(',', $status) . ')'; } else { $sql .= ' WHERE i.status IN (' . \implode(',', $status) . ')'; } - $sql .= ' GROUP BY i.categoryid ORDER BY c.parentid ASC, i.categoryid ASC'; + $sql .= ' GROUP BY i.categoryid ORDER BY c.parentid ASC, i.categoryid ASC'; $result = $this->db->query($sql); if (!$result) { return $ret; diff --git a/class/Metagen.php b/class/Metagen.php index 5416ef59..3dfd728f 100644 --- a/class/Metagen.php +++ b/class/Metagen.php @@ -17,7 +17,6 @@ /** * @copyright The XUUPS Project http://sourceforge.net/projects/xuups/ * @license http://www.fsf.org/copyleft/gpl.html GNU public license - * @package Publisher * @since 1.0 * @author trabis * @author The SmartFactory @@ -25,8 +24,6 @@ use XoopsModules\Publisher; - - require_once \dirname(__DIR__) . '/include/common.php'; /** @@ -84,7 +81,7 @@ public function __construct($title, $keywords = '', $description = '', $category { /** @var \XoopsModules\Publisher\Helper $this ->helper */ $this->helper = \XoopsModules\Publisher\Helper::getInstance(); - $this->myts = \MyTextSanitizer::getInstance(); + $this->myts = \MyTextSanitizer::getInstance(); $this->setCategoryPath($categoryPath); $this->setTitle($title); $this->setDescription($description); @@ -99,10 +96,10 @@ public function __construct($title, $keywords = '', $description = '', $category */ public function setTitle($title) { - $this->title = $this->html2text($title); + $this->title = $this->html2text($title); $this->originalTitle = $this->title; - $titleTag = []; - $titleTag['module'] = $this->helper->getModule()->getVar('name'); + $titleTag = []; + $titleTag['module'] = $this->helper->getModule()->getVar('name'); if (isset($this->title) && ('' != $this->title) && (mb_strtoupper($this->title) != mb_strtoupper($titleTag['module']))) { $titleTag['title'] = $this->title; } @@ -138,7 +135,7 @@ public function setKeywords($keywords) */ public function setCategoryPath($categoryPath) { - $categoryPath = $this->html2text($categoryPath); + $categoryPath = $this->html2text($categoryPath); $this->categoryPath = $categoryPath; } @@ -147,8 +144,8 @@ public function setCategoryPath($categoryPath) */ public function setDescription($description) { - $description = $this->html2text($description); - $description = $this->purifyText($description); + $description = $this->html2text($description); + $description = $this->purifyText($description); $this->description = $description; } @@ -168,10 +165,10 @@ public function createMetaDescription($maxWords = 30) { $description = $this->purifyText($this->description); $description = $this->html2text($description); - $words = \explode(' ', $description); - $ret = ''; - $i = 1; - $wordCount = \count($words); + $words = \explode(' ', $description); + $ret = ''; + $i = 1; + $wordCount = \count($words); foreach ($words as $word) { $ret .= $word; if ($i < $wordCount) { @@ -191,15 +188,15 @@ public function createMetaDescription($maxWords = 30) */ public function findMetaKeywords($text, $minChar) { - $keywords = []; - $text = $this->purifyText($text); - $text = $this->html2text($text); + $keywords = []; + $text = $this->purifyText($text); + $text = $this->html2text($text); $originalKeywords = \explode(' ', $text); foreach ($originalKeywords as $originalKeyword) { $secondRoundKeywords = \explode("'", $originalKeyword); foreach ($secondRoundKeywords as $secondRoundKeyword) { if (mb_strlen($secondRoundKeyword) >= $minChar) { - if (!\in_array($secondRoundKeyword, $keywords)) { + if (!\in_array($secondRoundKeyword, $keywords, true)) { $keywords[] = \trim($secondRoundKeyword); } } @@ -214,11 +211,11 @@ public function findMetaKeywords($text, $minChar) */ public function createMetaKeywords() { - $keywords = $this->findMetaKeywords($this->originalTitle . ' ' . $this->description, $this->minChar); + $keywords = $this->findMetaKeywords($this->originalTitle . ' ' . $this->description, $this->minChar); $moduleKeywords = $this->helper->getConfig('seo_meta_keywords'); if ('' != $moduleKeywords) { $moduleKeywords = \explode(',', $moduleKeywords); - $keywords = \array_merge($keywords, \array_map('\trim', $moduleKeywords)); + $keywords = \array_merge($keywords, \array_map('\trim', $moduleKeywords)); } $ret = \implode(',', $keywords); @@ -237,7 +234,7 @@ public function autoBuildMetaKeywords() */ public function buildAutoMetaTags() { - $this->keywords = $this->createMetaKeywords(); + $this->keywords = $this->createMetaKeywords(); $this->description = $this->createMetaDescription(); //$this->title = $this->createTitleTag(); } @@ -318,8 +315,8 @@ public static function generateSeoTitle($title = '', $withExt = true) '/%7E/', // ~ "/\./", // . ]; - $repPat = ['-', '-', '-', '-', '-', '-100', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-at-', '-', '-', '-', '-', '-', '-', '-', '-', '-']; - $title = preg_replace($pattern, $repPat, $title); + $repPat = ['-', '-', '-', '-', '-', '-100', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-at-', '-', '-', '-', '-', '-', '-', '-', '-', '-']; + $title = preg_replace($pattern, $repPat, $title); // Transformation des caractères accentués $pattern = [ '/%B0/', // ° @@ -339,17 +336,19 @@ public static function generateSeoTitle($title = '', $withExt = true) '/%F4/', // ô '/%F6/', // ö ]; - $repPat = ['-', 'e', 'e', 'e', 'e', 'c', 'a', 'a', 'a', 'i', 'i', 'u', 'u', 'u', 'o', 'o']; - $title = \preg_replace($pattern, $repPat, $title); + $repPat = ['-', 'e', 'e', 'e', 'e', 'c', 'a', 'a', 'a', 'i', 'i', 'u', 'u', 'u', 'o', 'o']; + $title = \preg_replace($pattern, $repPat, $title); $tableau = \explode('-', $title); // Transforms the string in table //Transforme la chaine de caractères en tableau $tableau = \array_filter($tableau, ['XoopsModules\Publisher\Metagen', 'emptyString']); // Remove empty strings of the table //Supprime les chaines vides du tableau - $title = \implode('-', $tableau); // Transforms a character string in table separated by a hyphen //Transforme un tableau en chaine de caractères séparé par un tiret + $title = \implode('-', $tableau); // Transforms a character string in table separated by a hyphen //Transforme un tableau en chaine de caractères séparé par un tiret if ($title && !(\is_array($title))) { if ($withExt) { $title .= '.html'; } + return $title; } + return ''; } diff --git a/class/Mimetype.php b/class/Mimetype.php index 78117b28..9dc06f37 100644 --- a/class/Mimetype.php +++ b/class/Mimetype.php @@ -19,7 +19,6 @@ * * @copyright The XUUPS Project http://sourceforge.net/projects/xuups/ * @license http://www.fsf.org/copyleft/gpl.html GNU public license - * @package Publisher * @since 1.0 * @author trabis * @author The SmartFactory @@ -27,15 +26,12 @@ use XoopsModules\Publisher; - - require_once \dirname(__DIR__) . '/include/common.php'; /** * Mimetype class * * @author Eric Juden - * @package publisher */ class Mimetype extends \XoopsObject { diff --git a/class/MimetypeHandler.php b/class/MimetypeHandler.php index 121ce0e8..65d97409 100644 --- a/class/MimetypeHandler.php +++ b/class/MimetypeHandler.php @@ -19,7 +19,6 @@ * * @copyright The XUUPS Project http://sourceforge.net/projects/xuups/ * @license http://www.fsf.org/copyleft/gpl.html GNU public license - * @package Publisher * @since 1.0 * @author trabis * @author The SmartFactory @@ -27,8 +26,6 @@ use XoopsModules\Publisher; - - require_once \dirname(__DIR__) . '/include/common.php'; /** @@ -38,9 +35,6 @@ class MimetypeHandler extends BaseObjectHandler { /** * Constructor - * - * @param \XoopsDatabase|null $db - * @param \XoopsModules\Publisher\Helper|null $helper */ public function __construct(\XoopsDatabase $db = null, \XoopsModules\Publisher\Helper $helper = null) { @@ -52,8 +46,8 @@ public function __construct(\XoopsDatabase $db = null, \XoopsModules\Publisher\H } $this->publisherIsAdmin = $this->helper->isUserAdmin(); - $this->db = $db; - $this->className = Mimetype::class; + $this->db = $db; + $this->className = Mimetype::class; } /** @@ -96,9 +90,9 @@ public function get($id = null, $fields = null) */ public function &getObjects(\CriteriaElement $criteria = null, $idAsKey = false, $asObject = true) //&getObjects($criteria = null) { - $ret = []; + $ret = []; $limit = $start = 0; - $sql = $this->selectQuery($criteria); + $sql = $this->selectQuery($criteria); if (null !== $criteria) { $limit = $criteria->getLimit(); $start = $criteria->getStart(); @@ -111,7 +105,7 @@ public function &getObjects(\CriteriaElement $criteria = null, $idAsKey = false, } // Add each returned record to the result array while (false !== ($myrow = $this->db->fetchArray($result))) { - $obj = new $this->className($myrow); + $obj = new $this->className($myrow); $ret[] = $obj; unset($obj); } @@ -166,7 +160,7 @@ public function getArray($mimeExt = null) */ public function checkMimeTypes($postField) { - $ret = false; + $ret = false; $allowed_mimetypes = $this->getArrayByType(); if (empty($allowed_mimetypes)) { return $ret; @@ -219,7 +213,7 @@ private function selectQuery(\CriteriaElement $criteria = null, $join = false) if ($join) { throw new \RuntimeException('no need for join...'); } - } catch (\Exception $e) { + } catch (\Throwable $e) { /** @var Publisher\Helper $helper */ $helper = Publisher\Helper::getInstance(); $helper->addLog($e); diff --git a/class/MimetypesUtility.php b/class/MimetypesUtility.php index 20fc9bab..dfcce795 100644 --- a/class/MimetypesUtility.php +++ b/class/MimetypesUtility.php @@ -19,7 +19,6 @@ * * @copyright The XUUPS Project http://sourceforge.net/projects/xuups/ * @license http://www.fsf.org/copyleft/gpl.html GNU public license - * @package Publisher * @since 1.0 * @author trabis * @author The SmartFactory @@ -49,8 +48,8 @@ public static function add() Publisher\Utility::openCollapsableBar('mimemaddtable', 'mimeaddicon', \_AM_PUBLISHER_MIME_ADD_TITLE); - $session = Publisher\Session::getInstance(); - $mimeType = $session->get('publisher_addMime'); + $session = Publisher\Session::getInstance(); + $mimeType = $session->get('publisher_addMime'); $mimeErrors = $session->get('publisher_addMimeErr'); //Display any form errors @@ -59,17 +58,17 @@ public static function add() } if (false === $mimeType) { - $mimeExt = ''; - $mimeName = ''; + $mimeExt = ''; + $mimeName = ''; $mimeTypes = ''; $mimeAdmin = 1; - $mimeUser = 1; + $mimeUser = 1; } else { - $mimeExt = $mimeType['mime_ext']; - $mimeName = $mimeType['mime_name']; + $mimeExt = $mimeType['mime_ext']; + $mimeName = $mimeType['mime_name']; $mimeTypes = $mimeType['mime_types']; $mimeAdmin = $mimeType['mime_admin']; - $mimeUser = $mimeType['mime_user']; + $mimeUser = $mimeType['mime_user']; } // Display add form @@ -130,36 +129,36 @@ public static function add() \xoops_cp_footer(); } else { $hasErrors = false; - $mimeExt = Request::getString('mime_ext', '', 'POST'); - $mimeName = Request::getString('mime_name', '', 'POST'); + $mimeExt = Request::getString('mime_ext', '', 'POST'); + $mimeName = Request::getString('mime_name', '', 'POST'); $mimeTypes = Request::getText('mime_types', '', 'POST'); $mimeAdmin = Request::getInt('mime_admin', 0, 'POST'); - $mimeUser = Request::getInt('mime_user', 0, 'POST'); + $mimeUser = Request::getInt('mime_user', 0, 'POST'); //Validate Mimetype entry if ('' === \trim($mimeExt)) { - $hasErrors = true; + $hasErrors = true; $error['mime_ext'][] = \_AM_PUBLISHER_VALID_ERR_MIME_EXT; } if ('' === \trim($mimeName)) { - $hasErrors = true; + $hasErrors = true; $error['mime_name'][] = \_AM_PUBLISHER_VALID_ERR_MIME_NAME; } if ('' === \trim($mimeTypes)) { - $hasErrors = true; + $hasErrors = true; $error['mime_types'][] = \_AM_PUBLISHER_VALID_ERR_MIME_TYPES; } if ($hasErrors) { - $session = Publisher\Session::getInstance(); - $mime = []; - $mime['mime_ext'] = $mimeExt; - $mime['mime_name'] = $mimeName; + $session = Publisher\Session::getInstance(); + $mime = []; + $mime['mime_ext'] = $mimeExt; + $mime['mime_name'] = $mimeName; $mime['mime_types'] = $mimeTypes; $mime['mime_admin'] = $mimeAdmin; - $mime['mime_user'] = $mimeUser; + $mime['mime_user'] = $mimeUser; $session->set('publisher_addMime', $mime); $session->set('publisher_addMimeErr', $error); \header('Location: ' . Publisher\Utility::makeUri(PUBLISHER_ADMIN_URL . '/mimetypes.php', ['op' => 'add'], false)); @@ -209,8 +208,8 @@ public static function edit() /** @var Publisher\MimetypeHandler $mimetypeHandler */ $mimetypeHandler = $helper->getHandler('Mimetype'); global $start, $limit; - $mimeId = 0; - $error = []; + $mimeId = 0; + $error = []; $hasErrors = false; if (0 == Request::getInt('id', 0, 'GET')) { \redirect_header(PUBLISHER_ADMIN_URL . '/mimetypes.php', 3, \_AM_PUBLISHER_MESSAGE_NO_ID); @@ -220,8 +219,8 @@ public static function edit() $mimeTypeObj = $mimetypeHandler->get($mimeId); // Retrieve mimetype object if (!Request::getString('edit_mime', '', 'POST')) { - $session = Publisher\Session::getInstance(); - $mimeType = $session->get('publisher_editMime_' . $mimeId); + $session = Publisher\Session::getInstance(); + $mimeType = $session->get('publisher_editMime_' . $mimeId); $mimeErrors = $session->get('publisher_editMimeErr_' . $mimeId); // Display header @@ -236,17 +235,17 @@ public static function edit() } if (false === $mimeType) { - $mimeExt = $mimeTypeObj->getVar('mime_ext'); - $mimeName = $mimeTypeObj->getVar('mime_name', 'e'); + $mimeExt = $mimeTypeObj->getVar('mime_ext'); + $mimeName = $mimeTypeObj->getVar('mime_name', 'e'); $mimeTypes = $mimeTypeObj->getVar('mime_types', 'e'); $mimeAdmin = $mimeTypeObj->getVar('mime_admin'); - $mimeUser = $mimeTypeObj->getVar('mime_user'); + $mimeUser = $mimeTypeObj->getVar('mime_user'); } else { - $mimeExt = $mimeType['mime_ext']; - $mimeName = $mimeType['mime_name']; + $mimeExt = $mimeType['mime_ext']; + $mimeName = $mimeType['mime_name']; $mimeTypes = $mimeType['mime_types']; $mimeAdmin = $mimeType['mime_admin']; - $mimeUser = $mimeType['mime_user']; + $mimeUser = $mimeType['mime_user']; } // Display edit form @@ -296,7 +295,7 @@ public static function edit() require_once \dirname(__DIR__) . '/admin/admin_footer.php'; } else { $mimeAdmin = 0; - $mimeUser = 0; + $mimeUser = 0; if (1 == Request::getInt('mime_admin', 0, 'POST')) { $mimeAdmin = 1; } @@ -306,28 +305,28 @@ public static function edit() //Validate Mimetype entry if ('' === Request::getString('mime_ext', '', 'POST')) { - $hasErrors = true; + $hasErrors = true; $error['mime_ext'][] = \_AM_PUBLISHER_VALID_ERR_MIME_EXT; } if ('' === Request::getString('mime_name', '', 'POST')) { - $hasErrors = true; + $hasErrors = true; $error['mime_name'][] = \_AM_PUBLISHER_VALID_ERR_MIME_NAME; } if ('' === Request::getString('mime_types', '', 'POST')) { - $hasErrors = true; + $hasErrors = true; $error['mime_types'][] = \_AM_PUBLISHER_VALID_ERR_MIME_TYPES; } if ($hasErrors) { - $session = Publisher\Session::getInstance(); - $mime = []; - $mime['mime_ext'] = Request::getString('mime_ext', '', 'POST'); - $mime['mime_name'] = Request::getString('mime_name', '', 'POST'); + $session = Publisher\Session::getInstance(); + $mime = []; + $mime['mime_ext'] = Request::getString('mime_ext', '', 'POST'); + $mime['mime_name'] = Request::getString('mime_name', '', 'POST'); $mime['mime_types'] = Request::getText('mime_types', '', 'POST'); $mime['mime_admin'] = $mimeAdmin; - $mime['mime_user'] = $mimeUser; + $mime['mime_user'] = $mimeUser; $session->set('publisher_editMime_' . $mimeId, $mime); $session->set('publisher_editMimeErr_' . $mimeId, $error); \header('Location: ' . Publisher\Utility::makeUri(PUBLISHER_ADMIN_URL . '/mimetypes.php', ['op' => 'edit', 'id' => $mimeId], false)); @@ -381,9 +380,9 @@ public static function manage() Publisher\Utility::cpHeader(); ////publisher_adminMenu(4, _AM_PUBLISHER_MIMETYPES); Publisher\Utility::openCollapsableBar('mimemanagetable', 'mimemanageicon', \_AM_PUBLISHER_MIME_MANAGE_TITLE, \_AM_PUBLISHER_MIME_INFOTEXT); - $crit = new \CriteriaCompo(); + $crit = new \CriteriaCompo(); $order = Request::getString('order', 'ASC', 'POST'); - $sort = Request::getString('sort', 'mime_ext', 'POST'); + $sort = Request::getString('sort', 'mime_ext', 'POST'); $crit->setOrder($order); $crit->setStart($start); @@ -391,7 +390,7 @@ public static function manage() $crit->setSort($sort); $mimetypes = $mimetypeHandler->getObjects($crit); // Retrieve a list of all mimetypes $mimeCount = $mimetypeHandler->getCount(); - $nav = new \XoopsPageNav($mimeCount, $limit, $start, 'start', "op=manage&limit=$limit"); + $nav = new \XoopsPageNav($mimeCount, $limit, $start, 'start', "op=manage&limit=$limit"); echo ""; echo "'; @@ -147,16 +140,16 @@ public function assign(\XoopsTpl $tpl) } if (\is_string($ele)) { $elements[$i]['body'] = $ele; - $elements[$i]['tab'] = $tab; + $elements[$i]['tab'] = $tab; continue; } - $eleName = $ele->getName(); - $eleDescription = $ele->getDescription(); - $n = $eleName ?: $i; - $elements[$n]['name'] = $eleName; - $elements[$n]['caption'] = $ele->getCaption(); - $elements[$n]['body'] = $ele->render(); - $elements[$n]['hidden'] = $ele->isHidden() ? true : false; + $eleName = $ele->getName(); + $eleDescription = $ele->getDescription(); + $n = $eleName ?: $i; + $elements[$n]['name'] = $eleName; + $elements[$n]['caption'] = $ele->getCaption(); + $elements[$n]['body'] = $ele->render(); + $elements[$n]['hidden'] = $ele->isHidden() ? true : false; $elements[$n]['required'] = $ele->isRequired(); if ('' != $eleDescription) { $elements[$n]['description'] = $eleDescription; @@ -167,15 +160,15 @@ public function assign(\XoopsTpl $tpl) $tpl->assign( $this->getName(), [ - 'title' => $this->getTitle(), - 'id' => 'tab_' . \preg_replace('/[^a-z0-9]+/i', '', $this->getTitle()), - 'name' => $this->getName(), - 'action' => $this->getAction(), - 'method' => $this->getMethod(), - 'extra' => 'onsubmit="return xoopsFormValidate_' . $this->getName() . '();"' . $this->getExtra(), + 'title' => $this->getTitle(), + 'id' => 'tab_' . \preg_replace('/[^a-z0-9]+/i', '', $this->getTitle()), + 'name' => $this->getName(), + 'action' => $this->getAction(), + 'method' => $this->getMethod(), + 'extra' => 'onsubmit="return xoopsFormValidate_' . $this->getName() . '();"' . $this->getExtra(), 'javascript' => $js, - 'tabs' => $this->formTabs, - 'elements' => $elements, + 'tabs' => $this->formTabs, + 'elements' => $elements, ] ); } @@ -210,7 +203,7 @@ public function endTabs() public function startFormTabs($tabText) { $this->formTabs[] = $tabText; - $ret = 'addTab'; + $ret = 'addTab'; return $ret; } @@ -337,7 +330,7 @@ public function &getElements($recurse = false) */ public function getElementNames() { - $ret = []; + $ret = []; $elements = &$this->getElements(true); foreach ($elements as $iValue) { $ret[] = $iValue->getName(); @@ -428,7 +421,7 @@ public function getElementValues($encode = false) { // will not use getElementByName() for performance.. $elements = &$this->getElements(true); - $values = []; + $values = []; foreach ($elements as $i => $iValue) { $name = $iValue->getName(false); if ($name && \method_exists($elements[$i], 'getValue')) { @@ -555,7 +548,7 @@ public function renderValidationJS($withtags = true) $js .= "\n\n
    "; @@ -518,7 +517,7 @@ public static function search() } $order = Request::getString('order', 'ASC'); - $sort = Request::getString('sort', 'mime_name'); + $sort = Request::getString('sort', 'mime_name'); Publisher\Utility::cpHeader(); //publisher_adminMenu(4, _AM_PUBLISHER_MIMETYPES . " > " . _AM_PUBLISHER_BUTTON_SEARCH); @@ -554,7 +553,7 @@ public static function search() } else { $searchField = Request::getString('search_by', ''); $searchField = isset($aSearchBy[$searchField]) ? $searchField : 'mime_ext'; - $searchText = Request::getString('search_text', ''); + $searchText = Request::getString('search_text', ''); $crit = new \Criteria($searchField, '%' . $GLOBALS['xoopsDB']->escape($searchText) . '%', 'LIKE'); $crit->setSort($sort); @@ -563,7 +562,7 @@ public static function search() $crit->setStart($start); $mimeCount = $mimetypeHandler->getCount($crit); $mimetypes = $mimetypeHandler->getObjects($crit); - $nav = new \XoopsPageNav($mimeCount, $limit, $start, 'start', "op=search&limit=$limit&order=$order&sort=$sort&mime_search=1&search_by=$searchField&search_text=" . \htmlentities($searchText, \ENT_QUOTES)); + $nav = new \XoopsPageNav($mimeCount, $limit, $start, 'start', "op=search&limit=$limit&order=$order&sort=$sort&mime_search=1&search_by=$searchField&search_text=" . \htmlentities($searchText, \ENT_QUOTES)); // Display results echo ''; @@ -684,7 +683,7 @@ public static function updateMimeValue() // op=updateMimeValue&id=65&mime_admin=0&limit=15&start=0 Publisher\Utility::cpHeader(); $hiddens = [ - 'id' => Request::getInt('id', 0, 'GET'), + 'id' => Request::getInt('id', 0, 'GET'), 'start' => Request::getInt('start', 0, 'GET'), 'limit' => Request::getInt('limit', 15, 'GET'), ]; @@ -695,10 +694,10 @@ public static function updateMimeValue() $mimeTypeObj = $helper->getHandler('Mimetype')->get($hiddens['id']); if (Request::hasVar('mime_admin')) { $hiddens['mime_admin'] = Request::getInt('mime_admin', 0, 'GET'); - $msg = \sprintf(\_AM_PUBLISHER_MIME_ACCESS_CONFIRM_ADMIN, $mimeTypeObj->getVar('mime_name')); + $msg = \sprintf(\_AM_PUBLISHER_MIME_ACCESS_CONFIRM_ADMIN, $mimeTypeObj->getVar('mime_name')); } else { $hiddens['mime_user'] = Request::getInt('mime_user', 0, 'GET'); - $msg = \sprintf(\_AM_PUBLISHER_MIME_ACCESS_CONFIRM_USER, $mimeTypeObj->getVar('mime_name')); + $msg = \sprintf(\_AM_PUBLISHER_MIME_ACCESS_CONFIRM_USER, $mimeTypeObj->getVar('mime_name')); } $action = PUBLISHER_ADMIN_URL . '/mimetypes.php?op=confirmUpdateMimeValue'; @@ -714,9 +713,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); } @@ -771,7 +770,7 @@ public static function clearAddSession() */ public static function clearEditSessionVars($id) { - $id = (int)$id; + $id = (int)$id; $session = Publisher\Session::getInstance(); $session->del("publisher_editMime_$id"); $session->del("publisher_editMimeErr_$id"); diff --git a/class/MyTextSanitizerExtension.php b/class/MyTextSanitizerExtension.php index 082e95ea..4f319a98 100644 --- a/class/MyTextSanitizerExtension.php +++ b/class/MyTextSanitizerExtension.php @@ -17,15 +17,10 @@ /** * @copyright The XUUPS Project http://sourceforge.net/projects/xuups/ * @license http://www.fsf.org/copyleft/gpl.html GNU public license - * @package Publisher - * @subpackage Include * @since 1.0 * @author trabis * @author Taiwen Jiang (phppp or D.J.) */ - -use XoopsModules\Publisher; - \define('MYTEXTSANITIZER_EXTENDED_MEDIA', 1); /** @@ -59,12 +54,12 @@ public static function getInstance() */ public function wmp(&$patterns, &$replacements) { - $patterns[] = "/\[wmp=(['\"]?)([^\"']*),([^\"']*)\\1]([^\"]*)\[\/wmp\]/sU"; - $rp = "\n"; - $rp .= "\n"; - $rp .= "\n"; - $rp .= ' '; - $rp .= "\n"; + $patterns[] = "/\[wmp=(['\"]?)([^\"']*),([^\"']*)\\1]([^\"]*)\[\/wmp\]/sU"; + $rp = "\n"; + $rp .= "\n"; + $rp .= "\n"; + $rp .= ' '; + $rp .= "\n"; $replacements[] = $rp; } @@ -107,7 +102,7 @@ public function displayFlash($url, $width = false, $height = false) */ public function flash(&$patterns, &$replacements) { - $patterns[] = "/\[(swf|flash)=(['\"]?)([^\"']*),([^\"']*)\\2]([^\"]*)\[\/\\1\]/esU"; + $patterns[] = "/\[(swf|flash)=(['\"]?)([^\"']*),([^\"']*)\\2]([^\"]*)\[\/\\1\]/esU"; $replacements[] = "Publisher\MyTextSanitizerExtension::displayFlash( '\\5', '\\3', '\\4' )"; } @@ -117,34 +112,34 @@ public function flash(&$patterns, &$replacements) */ public function mms(&$patterns, &$replacements) { - $patterns[] = "/\[mms=(['\"]?)([^\"']*),([^\"']*)\\1]([^\"]*)\[\/mms\]/sU"; - $rp = ""; - $rp .= ''; - $rp .= ''; - $rp .= ''; - $rp .= ''; - $rp .= ''; - $rp .= ''; - $rp .= ''; - $rp .= ''; - $rp .= ''; - $rp .= ''; - $rp .= ''; - $rp .= ''; - $rp .= ''; - $rp .= ''; - $rp .= ''; - $rp .= ''; - $rp .= ''; - $rp .= ''; - $rp .= ''; - $rp .= ''; - $rp .= ''; - $rp .= ''; - $rp .= ''; - $rp .= ''; - $rp .= ''; - $rp .= ''; + $patterns[] = "/\[mms=(['\"]?)([^\"']*),([^\"']*)\\1]([^\"]*)\[\/mms\]/sU"; + $rp = ""; + $rp .= ''; + $rp .= ''; + $rp .= ''; + $rp .= ''; + $rp .= ''; + $rp .= ''; + $rp .= ''; + $rp .= ''; + $rp .= ''; + $rp .= ''; + $rp .= ''; + $rp .= ''; + $rp .= ''; + $rp .= ''; + $rp .= ''; + $rp .= ''; + $rp .= ''; + $rp .= ''; + $rp .= ''; + $rp .= ''; + $rp .= ''; + $rp .= ''; + $rp .= ''; + $rp .= ''; + $rp .= ''; + $rp .= ''; $replacements[] = $rp; } @@ -155,40 +150,40 @@ public function mms(&$patterns, &$replacements) public function rtsp(&$patterns, &$replacements) { $patterns[] = "/\[rtsp=(['\"]?)([^\"']*),([^\"']*)\\1]([^\"]*)\[\/rtsp\]/sU"; - $rp = ""; - $rp .= ''; - $rp .= ''; - $rp .= ''; - $rp .= ''; - $rp .= ''; - $rp .= ''; - $rp .= ''; - $rp .= ''; - $rp .= ''; - $rp .= ''; - $rp .= ''; - $rp .= ''; - $rp .= ''; - $rp .= ''; - $rp .= " "; - $rp .= ''; - $rp .= "
    "; - $rp .= ''; - $rp .= ''; - $rp .= ''; - $rp .= ''; - $rp .= ''; - $rp .= ''; - $rp .= ''; - $rp .= ''; - $rp .= ''; - $rp .= ''; - $rp .= ''; - $rp .= ''; - $rp .= ''; - $rp .= ''; - $rp .= " "; - $rp .= ''; + $rp = ""; + $rp .= ''; + $rp .= ''; + $rp .= ''; + $rp .= ''; + $rp .= ''; + $rp .= ''; + $rp .= ''; + $rp .= ''; + $rp .= ''; + $rp .= ''; + $rp .= ''; + $rp .= ''; + $rp .= ''; + $rp .= ''; + $rp .= " "; + $rp .= ''; + $rp .= "
    "; + $rp .= ''; + $rp .= ''; + $rp .= ''; + $rp .= ''; + $rp .= ''; + $rp .= ''; + $rp .= ''; + $rp .= ''; + $rp .= ''; + $rp .= ''; + $rp .= ''; + $rp .= ''; + $rp .= ''; + $rp .= ''; + $rp .= " "; + $rp .= ''; $replacements[] = $rp; } diff --git a/class/PermissionHandler.php b/class/PermissionHandler.php index 7b4f65b8..57cb79e2 100644 --- a/class/PermissionHandler.php +++ b/class/PermissionHandler.php @@ -19,8 +19,6 @@ * * @copyright The XUUPS Project http://sourceforge.net/projects/xuups/ * @license http://www.fsf.org/copyleft/gpl.html GNU public license - * @package Class - * @subpackage Handlers * @since 1.0 * @author trabis * @author The SmartFactory @@ -28,7 +26,6 @@ use XoopsModules\Publisher; - require_once \dirname(__DIR__) . '/include/common.php'; /** @@ -41,10 +38,6 @@ class PermissionHandler extends \XoopsObjectHandler */ public $helper; - /** - * @param \XoopsDatabase|null $db - * @param \XoopsModules\Publisher\Helper|null $helper - */ public function __construct(\XoopsDatabase $db = null, \XoopsModules\Publisher\Helper $helper = null) { /** @var \XoopsModules\Publisher\Helper $this ->helper */ @@ -69,18 +62,18 @@ public function getGrantedGroupsById($gpermName, $id) if (isset($items[$gpermName][$id])) { return $items[$gpermName][$id]; } - $groups = []; + $groups = []; $criteria = new \CriteriaCompo(); $criteria->add(new \Criteria('gperm_modid', $this->helper->getModule()->getVar('mid'))); $criteria->add(new \Criteria('gperm_name', $gpermName)); $criteria->add(new \Criteria('gperm_itemid', $id)); //Instead of calling groupperm handler and get objects, we will save some memory and do it our way /** @var \XoopsMySQLDatabase $db */ - $db = \XoopsDatabaseFactory::getDatabaseConnection(); + $db = \XoopsDatabaseFactory::getDatabaseConnection(); $limit = $start = 0; - $sql = 'SELECT gperm_groupid FROM ' . $db->prefix('group_permission'); + $sql = 'SELECT gperm_groupid FROM ' . $db->prefix('group_permission'); if (null !== $criteria && $criteria instanceof \CriteriaElement) { - $sql .= ' ' . $criteria->renderWhere(); + $sql .= ' ' . $criteria->renderWhere(); $limit = $criteria->getLimit(); $start = $criteria->getStart(); } @@ -113,15 +106,15 @@ public function getGrantedItems($gpermName) $criteria->add(new \Criteria('gperm_modid', $this->helper->getModule()->getVar('mid'))); //Get user's groups - $groups = \is_object($GLOBALS['xoopsUser']) ? $GLOBALS['xoopsUser']->getGroups() : [XOOPS_GROUP_ANONYMOUS]; + $groups = \is_object($GLOBALS['xoopsUser']) ? $GLOBALS['xoopsUser']->getGroups() : [XOOPS_GROUP_ANONYMOUS]; $criteria2 = new \CriteriaCompo(); foreach ($groups as $gid) { $criteria2->add(new \Criteria('gperm_groupid', $gid), 'OR'); } $criteria->add($criteria2); - $db = \XoopsDatabaseFactory::getDatabaseConnection(); - $sql = 'SELECT gperm_itemid FROM ' . $db->prefix('group_permission'); - $sql .= ' ' . $criteria->renderWhere(); + $db = \XoopsDatabaseFactory::getDatabaseConnection(); + $sql = 'SELECT gperm_itemid FROM ' . $db->prefix('group_permission'); + $sql .= ' ' . $criteria->renderWhere(); $result = $db->query($sql, 0, 0); while (false !== ($myrow = $db->fetchArray($result))) { $ret[$myrow['gperm_itemid']] = $myrow['gperm_itemid']; @@ -162,9 +155,9 @@ public function isGranted($gpermName, $id) */ public function saveItemPermissions($groups, $itemId, $permName) { - $result = true; + $result = true; $moduleId = $this->helper->getModule()->getVar('mid'); - /* @var \XoopsGroupPermHandler $grouppermHandler */ + /** @var \XoopsGroupPermHandler $grouppermHandler */ $grouppermHandler = \xoops_getHandler('groupperm'); // First, if the permissions are already there, delete them $grouppermHandler->deleteByModule($moduleId, $permName, $itemId); @@ -190,7 +183,7 @@ public function saveItemPermissions($groups, $itemId, $permName) */ public function deletePermissions($itemId, $gpermName) { - $result = true; + $result = true; $grouppermHandler = \xoops_getHandler('groupperm'); $grouppermHandler->deleteByModule($this->helper->getModule()->getVar('mid'), $gpermName, $itemId); diff --git a/class/Rating.php b/class/Rating.php index ab914428..fe848661 100644 --- a/class/Rating.php +++ b/class/Rating.php @@ -18,12 +18,9 @@ * * @copyright The XUUPS Project http://sourceforge.net/projects/xuups/ * @license http://www.fsf.org/copyleft/gpl.html GNU public license - * @package Publisher * @since 1.0 * @author trabis */ - - require_once \dirname(__DIR__) . '/include/common.php'; /** diff --git a/class/RatingHandler.php b/class/RatingHandler.php index 79007bdc..31e87e73 100644 --- a/class/RatingHandler.php +++ b/class/RatingHandler.php @@ -18,12 +18,9 @@ * * @copyright The XUUPS Project http://sourceforge.net/projects/xuups/ * @license http://www.fsf.org/copyleft/gpl.html GNU public license - * @package Publisher * @since 1.0 * @author trabis */ - - require_once \dirname(__DIR__) . '/include/common.php'; /** @@ -33,7 +30,6 @@ class RatingHandler extends \XoopsPersistableObjectHandler { /** * RatingHandler constructor. - * @param \XoopsDatabase|null $db */ public function __construct(\XoopsDatabase $db = null) { diff --git a/class/Resizer.php b/class/Resizer.php index 503cf9e0..306bcad6 100644 --- a/class/Resizer.php +++ b/class/Resizer.php @@ -19,7 +19,6 @@ * * @copyright module for xoops * @license GPL 2.0 or later - * @package XOOPS common * @since 1.0 * @min_xoops 2.5.9 * @author Goffy - Wedega - Email: - Website: @@ -27,14 +26,14 @@ */ class Resizer { - public $sourceFile = ''; - public $endFile = ''; - public $maxWidth = 0; - public $maxHeight = 0; + public $sourceFile = ''; + public $endFile = ''; + public $maxWidth = 0; + public $maxHeight = 0; public $imageMimetype = ''; - public $jpgQuality = 90; - public $mergeType = 0; - public $mergePos = 0; + public $jpgQuality = 90; + public $mergeType = 0; + public $mergePos = 0; /** * resize image if size exceed given width/height @@ -57,7 +56,7 @@ public function resizeImage() return 'Unsupported format'; } - $width = \imagesx($img); + $width = \imagesx($img); $height = \imagesy($img); if ($width > $this->maxWidth || $height > $this->maxHeight) { @@ -66,16 +65,16 @@ public function resizeImage() if ($width < $this->maxWidth) { $new_width = $width; } else { - $new_width = $this->maxWidth; - $divisor = $width / $new_width; + $new_width = $this->maxWidth; + $divisor = $width / $new_width; $new_height = \floor($height / $divisor); } } elseif ($height < $this->maxHeight) { $new_height = $height; } else { $new_height = $this->maxHeight; - $divisor = $height / $new_height; - $new_width = \floor($width / $divisor); + $divisor = $height / $new_height; + $new_width = \floor($width / $divisor); } // Create a new temporary image. @@ -139,19 +138,19 @@ public function resizeAndCrop() [$original_w, $original_h] = \getimagesize($this->sourceFile); // RESIZE IMAGE AND PRESERVE PROPORTIONS - $max_width_resize = $this->maxWidth; + $max_width_resize = $this->maxWidth; $max_height_resize = $this->maxHeight; if ($original_w > $original_h) { $max_height_ratio = $this->maxHeight / $original_h; $max_width_resize = (int)\round($original_w * $max_height_ratio); } else { - $max_width_ratio = $this->maxWidth / $original_w; + $max_width_ratio = $this->maxWidth / $original_w; $max_height_resize = (int)\round($original_h * $max_width_ratio); } if ($max_width_resize < $this->maxWidth) { - $max_height_ratio = $this->maxWidth / $max_width_resize; + $max_height_ratio = $this->maxWidth / $max_width_resize; $max_height_resize = (int)\round($this->maxHeight * $max_height_ratio); - $max_width_resize = $this->maxWidth; + $max_width_resize = $this->maxWidth; } // CREATE THE PROPORTIONAL IMAGE RESOURCE @@ -162,7 +161,7 @@ public function resizeAndCrop() // CREATE THE CENTERED CROPPED IMAGE TO THE SPECIFIED DIMENSIONS $final = \imagecreatetruecolor($this->maxWidth, $this->maxHeight); - $max_width_offset = 0; + $max_width_offset = 0; $max_height_offset = 0; if ($this->maxWidth < $max_width_resize) { $max_width_offset = (int)\round(($max_width_resize - $this->maxWidth) / 2); @@ -185,12 +184,12 @@ public function resizeAndCrop() public function mergeImage() { $dest = \imagecreatefromjpeg($this->endFile); - $src = \imagecreatefromjpeg($this->sourceFile); + $src = \imagecreatefromjpeg($this->sourceFile); if (4 == $this->mergeType) { - $imgWidth = (int)\round($this->maxWidth / 2 - 1); + $imgWidth = (int)\round($this->maxWidth / 2 - 1); $imgHeight = (int)\round($this->maxHeight / 2 - 1); - $posCol2 = (int)\round($this->maxWidth / 2 + 1); - $posRow2 = (int)\round($this->maxHeight / 2 + 1); + $posCol2 = (int)\round($this->maxWidth / 2 + 1); + $posRow2 = (int)\round($this->maxHeight / 2 + 1); switch ($this->mergePos) { case 1: \imagecopy($dest, $src, 0, 0, 0, 0, $imgWidth, $imgHeight); //top left @@ -207,11 +206,11 @@ public function mergeImage() } } if (6 == $this->mergeType) { - $imgWidth = (int)\round($this->maxWidth / 3 - 1); + $imgWidth = (int)\round($this->maxWidth / 3 - 1); $imgHeight = (int)\round($this->maxHeight / 2 - 1); - $posCol2 = (int)\round($this->maxWidth / 3 + 1); - $posCol3 = $posCol2 + (int)\round($this->maxWidth / 3 + 1); - $posRow2 = (int)\round($this->maxHeight / 2 + 1); + $posCol2 = (int)\round($this->maxWidth / 3 + 1); + $posCol3 = $posCol2 + (int)\round($this->maxWidth / 3 + 1); + $posRow2 = (int)\round($this->maxHeight / 2 + 1); switch ($this->mergePos) { case 1: diff --git a/class/Seo.php b/class/Seo.php index 8f625547..0c7911d3 100644 --- a/class/Seo.php +++ b/class/Seo.php @@ -26,8 +26,6 @@ use XoopsModules\Publisher; - - require_once \dirname(__DIR__) . '/include/common.php'; /** @@ -56,7 +54,7 @@ public static function getTitle($title = '', $withExt = true) $title = \rawurlencode(mb_strtolower($title)); // Transformation des ponctuations - $pattern = [ + $pattern = [ '/%09/', // Tab '/%20/', // Space '/%21/', // ! @@ -87,13 +85,13 @@ public static function getTitle($title = '', $withExt = true) "/\./", // . ]; $repPattern = ['-', '-', '', '', '', '-100', '', '-', '', '', '', '-', '', '', '', '-', '', '', '-at-', '', '-', '', '-', '', '-', '', '-', '']; - $title = \preg_replace($pattern, $repPattern, $title); + $title = \preg_replace($pattern, $repPattern, $title); // Transformation des caractères accentués // è é ê ë ç à â ä î ï ù ü û ô ö - $pattern = ['/%B0/', '/%E8/', '/%E9/', '/%EA/', '/%EB/', '/%E7/', '/%E0/', '/%E2/', '/%E4/', '/%EE/', '/%EF/', '/%F9/', '/%FC/', '/%FB/', '/%F4/', '/%F6/']; + $pattern = ['/%B0/', '/%E8/', '/%E9/', '/%EA/', '/%EB/', '/%E7/', '/%E0/', '/%E2/', '/%E4/', '/%EE/', '/%EF/', '/%F9/', '/%FC/', '/%FB/', '/%F4/', '/%F6/']; $repPattern = ['-', 'e', 'e', 'e', 'e', 'c', 'a', 'a', 'a', 'i', 'i', 'u', 'u', 'u', 'o', 'o']; - $title = \preg_replace($pattern, $repPattern, $title); + $title = \preg_replace($pattern, $repPattern, $title); if (\count($title) > 0) { if ($withExt) { diff --git a/class/Session.php b/class/Session.php index 690ff3b4..1dd6148d 100644 --- a/class/Session.php +++ b/class/Session.php @@ -18,15 +18,12 @@ * * @copyright The XUUPS Project http://sourceforge.net/projects/xuups/ * @license http://www.fsf.org/copyleft/gpl.html GNU public license - * @package Publisher * @since 1.0 * @author trabis * @author Harry Fuecks (PHP Anthology Volume II) */ //namespace Publisher; - - require_once \dirname(__DIR__) . '/include/common.php'; /** diff --git a/class/ThemeTabForm.php b/class/ThemeTabForm.php index 86919173..afeabc3d 100644 --- a/class/ThemeTabForm.php +++ b/class/ThemeTabForm.php @@ -18,19 +18,15 @@ * * @copyright The XUUPS Project http://sourceforge.net/projects/xuups/ * @license http://www.fsf.org/copyleft/gpl.html GNU public license - * @package Publisher * @since 1.0 * @author trabis * @author John Neill */ - - require_once \dirname(__DIR__) . '/include/common.php'; /** * XoopsThemeTabForm * - * @package * @author John * @copyright Copyright (c) 2009 */ @@ -112,10 +108,10 @@ public function __construct($title, $name, $action, $method = 'post', $addtoken $GLOBALS['xoTheme']->addScript('browse.php?Frameworks/jquery/plugins/jquery.ui.js'); $GLOBALS['xoTheme']->addStylesheet(XOOPS_URL . '/modules/system/css/ui/' . \xoops_getModuleOption('jquery_theme', 'system') . '/ui.all.css'); - $this->title = $title; - $this->name = $name; - $this->action = $action; - $this->method = $method; + $this->title = $title; + $this->name = $name; + $this->action = $action; + $this->method = $method; $this->summary = $summary; if ($addtoken) { $this->addElement(new \XoopsFormHiddenToken()); @@ -124,13 +120,10 @@ public function __construct($title, $name, $action, $method = 'post', $addtoken //function render() {} - /** - * @param \XoopsTpl $tpl - */ public function assign(\XoopsTpl $tpl) { - $i = -1; - $tab = -1; + $i = -1; + $tab = -1; $elements = []; if (\count($this->getRequired()) > 0) { $this->elements[] = "
    * = " . _REQUIRED . '