From 754f2c1c4bf068464c7a1b86ce39a4f5ce6d76c4 Mon Sep 17 00:00:00 2001 From: mambax7 Date: Fri, 1 Jan 2021 06:23:30 -0500 Subject: [PATCH] refactor icons and ModuleStats --- admin/admin_header.php | 9 +++---- admin/blocksadmin.php | 13 +++++++---- admin/index.php | 2 +- admin/item.php | 22 +++++++++--------- admin/main.php | 37 +++++++++++------------------ admin/mimetypes.php | 4 ++-- blocks/latest_news.php | 10 ++++---- class/Common/Configurator.php | 5 +--- class/Common/ModuleStats.php | 16 ++----------- class/Common/SysUtility.php | 2 +- class/Form/ItemForm.php | 4 ++-- class/Item.php | 29 ++++++++++++++--------- class/MimetypesUtility.php | 24 +++++++++---------- class/Utility.php | 44 ++++++++++++++++++++++------------- config/config.php | 14 +---------- config/icons.php | 36 ++++++++++++++++++---------- config/paths.php | 9 ------- include/common.php | 29 +++++++++++++---------- language/english/common.php | 4 ++-- 19 files changed, 151 insertions(+), 162 deletions(-) diff --git a/admin/admin_header.php b/admin/admin_header.php index 0bd638a0..7354b5cd 100644 --- a/admin/admin_header.php +++ b/admin/admin_header.php @@ -21,6 +21,7 @@ use Xmf\Module\Admin; use XoopsModules\Publisher\Helper; +use XoopsModules\Publisher\Common\Configurator; require dirname(__DIR__) . '/preloads/autoloader.php'; @@ -46,12 +47,8 @@ $helper->loadLanguage('modinfo'); $helper->loadLanguage('main'); -$imagearray = [ - 'editimg' => "" . _AM_PUBLISHER_ICO_EDIT . "", - 'deleteimg' => "" . _AM_PUBLISHER_ICO_DELETE . "", - 'online' => "" . _AM_PUBLISHER_ICO_ONLINE . "", - 'offline' => "" . _AM_PUBLISHER_ICO_OFFLINE . "", -]; +$configurator = new Configurator(); +$icons = $configurator->icons; $myts = \MyTextSanitizer::getInstance(); diff --git a/admin/blocksadmin.php b/admin/blocksadmin.php index a8858f77..1eabe2c0 100644 --- a/admin/blocksadmin.php +++ b/admin/blocksadmin.php @@ -18,7 +18,9 @@ use Xmf\Module\Admin; use Xmf\Request; -use XoopsModules\Publisher\{Helper +use XoopsModules\Publisher\{ + Common\Configurator, + Helper }; require __DIR__ . '/admin_header.php'; @@ -69,6 +71,9 @@ function listBlocks() xoops_loadLanguage('admin/blocksadmin', 'system'); xoops_loadLanguage('admin/groups', 'system'); + $configurator = new Configurator(); + $icons = $configurator->icons; + /** @var \XoopsModuleHandler $moduleHandler */ $moduleHandler = xoops_getHandler('module'); /** @var \XoopsMemberHandler $memberHandler */ @@ -259,12 +264,10 @@ function listBlocks() // Actions - echo "" . _EDIT . " - " . _CLONE . " + echo "" . $icons->edit . " " . _CLONE . " "; if (!in_array($i->getVar('block_type'), ['S', 'M'])) { - echo " getVar('bid') . "'>" . _DELETE . " - "; + echo " getVar('bid') . "'>" . $icons->delete . ""; } echo " diff --git a/admin/index.php b/admin/index.php index 5e55afba..6a4e9176 100644 --- a/admin/index.php +++ b/admin/index.php @@ -60,7 +60,7 @@ $adminObject->addConfigBoxLine('!' . _MD_PUBLISHER_ERROR_NO_PDF . '', 'default'); } -$moduleStats = $utility::getModuleStats($configurator); +$moduleStats = $utility::getModuleStats(); $adminObject->addInfoBox(constant('CO_' . $moduleDirNameUpper . '_' . 'STATS_SUMMARY')); if ($moduleStats && is_array($moduleStats)) { diff --git a/admin/item.php b/admin/item.php index b51022dd..a4de85ad 100644 --- a/admin/item.php +++ b/admin/item.php @@ -193,9 +193,9 @@ for ($i = 0; $i < $totalItemsOnPage; ++$i) { $categoryObj = $itemsObj[$i]->getCategory(); - $approve = "" . _AM_PUBLISHER_SUBMISSION_MODERATE . " "; + $approve = "" . $icons->delete . " "; $clone = ''; - $delete = "" . _AM_PUBLISHER_DELETEITEM . ""; + $delete = "" . $icons->delete . ""; $modify = ''; echo ''; @@ -247,9 +247,9 @@ for ($i = 0; $i < $totalItemsOnPage; ++$i) { $categoryObj = $itemsObj[$i]->getCategory(); - $modify = "" . _AM_PUBLISHER_EDITITEM . ""; - $delete = "" . _AM_PUBLISHER_DELETEITEM . ""; - $clone = "" . _AM_PUBLISHER_CLONE_ITEM . ""; + $modify = "" . $icons->edit . ""; + $delete = "" . $icons->delete . ""; + $clone = "" . $icons->clone . ""; echo ''; echo "" . $itemsObj[$i]->itemid() . ''; @@ -301,9 +301,9 @@ for ($i = 0; $i < $totalItemsOnPage; ++$i) { $categoryObj = $itemsObj[$i]->getCategory(); - $modify = "" . _AM_PUBLISHER_EDITITEM . ""; - $delete = "" . _AM_PUBLISHER_DELETEITEM . ""; - $clone = "" . _AM_PUBLISHER_CLONE_ITEM . ""; + $modify = "" . $icons->edit . ""; + $delete = "" . $icons->delete . ""; + $clone = "" . $icons->clone . ""; echo ''; echo "" . $itemsObj[$i]->itemid() . ''; @@ -354,9 +354,9 @@ for ($i = 0; $i < $totalItemsOnPage; ++$i) { $categoryObj = $itemsObj[$i]->getCategory(); - $modify = "" . _AM_PUBLISHER_EDITITEM . ""; - $delete = "" . _AM_PUBLISHER_DELETEITEM . ""; - $clone = "" . _AM_PUBLISHER_CLONE_ITEM . ""; + $modify = "" . $icons->edit . ""; + $delete = "" . $icons->delete . ""; + $clone = "" . $icons->clone . ""; echo ''; echo "" . $itemsObj[$i]->itemid() . ''; diff --git a/admin/main.php b/admin/main.php index f6c68b55..555061c3 100644 --- a/admin/main.php +++ b/admin/main.php @@ -245,51 +245,40 @@ switch ($itemsObj[$i]->status()) { case Constants::PUBLISHER_STATUS_SUBMITTED: $statustxt = _CO_PUBLISHER_SUBMITTED; - $approve = "getModule()->dirname() - . "/assets/images/links/approve.gif' title='" - . _AM_PUBLISHER_SUBMISSION_MODERATE - . "' alt='" - . _AM_PUBLISHER_SUBMISSION_MODERATE - . "'> "; + $approve = "" . $icons->moderate . " "; $clone = ''; - $delete = "getModule()->dirname() . "/assets/images/links/delete.png' title='" . _AM_PUBLISHER_DELETEITEM . "' alt='" . _AM_PUBLISHER_DELETEITEM . "'>"; + $delete = "" . $icons->delete . ""; $modify = ''; break; case Constants::PUBLISHER_STATUS_PUBLISHED: $statustxt = _CO_PUBLISHER_PUBLISHED; $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 . "'> "; + $modify = "" . $icons->edit . " "; + $delete = "" . $icons->delete . " "; + $clone = "" . $icons->clone . " "; 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 . "'> "; + $modify = "" . $icons->edit . " "; + $delete = "" . $icons->delete . " "; $clone = /** @lang text */ - "getModule()->dirname() . "/assets/images/links/clone.gif' title='" . _AM_PUBLISHER_CLONE_ITEM . "' alt='" . _AM_PUBLISHER_CLONE_ITEM . "'> "; + "" . $icons->clone . " "; 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 . "'> "; + $modify = "" . $icons->rejectededit . " "; + $delete = "" . $icons->delete . " "; + $clone = "" . $icons->clone . " "; 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 . "'>"; + $modify = "" . $icons->rejectededit . " "; + $delete = "" . $icons->delete . ""; break; } diff --git a/admin/mimetypes.php b/admin/mimetypes.php index e3120561..b675671a 100644 --- a/admin/mimetypes.php +++ b/admin/mimetypes.php @@ -60,7 +60,7 @@ MimetypesUtility::edit(); break; case 'search': - MimetypesUtility::search(); + MimetypesUtility::search($icons); break; case 'updateMimeValue': MimetypesUtility::updateMimeValue(); @@ -76,6 +76,6 @@ break; case 'manage': default: - MimetypesUtility::manage(); + MimetypesUtility::manage($icons); break; } diff --git a/blocks/latest_news.php b/blocks/latest_news.php index 55b2e330..a54422aa 100644 --- a/blocks/latest_news.php +++ b/blocks/latest_news.php @@ -158,8 +158,8 @@ function publisher_latest_news_show($options) } if (is_object($GLOBALS['xoopsUser']) && $GLOBALS['xoopsUser']->isAdmin(-1)) { - $item['admin'] = "" . _CO_PUBLISHER_EDIT . " "; - $item['admin'] .= "itemid() . "'>" . _CO_PUBLISHER_DELETE . ""; + $item['admin'] = "edit . " "; + $item['admin'] .= "itemid() . "'>" . $icons->delete . ""; } else { $item['admin'] = ''; } @@ -223,19 +223,19 @@ function publisher_latest_news_show($options) $item['print'] = ''; if (1 == $options[24]) { - $item['print'] = '' . _CO_PUBLISHER_PRINT . ' '; + $item['print'] = '" . $icons->print . " '; } $item['pdf'] = ''; if (1 == $options[25]) { - $item['pdf'] = "" . _CO_PUBLISHER_PDF . " "; + $item['pdf'] = "" . $icons->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(); - $item['email'] = '' . _CO_PUBLISHER_MAIL . ' '; + $item['email'] = '' . $icons->mail . ' '; } $block['morelink'] = ''; diff --git a/class/Common/Configurator.php b/class/Common/Configurator.php index 172a226e..6771ad4a 100644 --- a/class/Common/Configurator.php +++ b/class/Common/Configurator.php @@ -32,7 +32,6 @@ class Configurator { public $name; public $paths = []; - public $icons = []; public $uploadFolders = []; public $copyBlankFiles = []; public $copyTestFolders = []; @@ -40,8 +39,8 @@ class Configurator public $oldFiles = []; public $oldFolders = []; public $renameTables = []; - public $moduleStats = []; public $modCopyright; + public $icons; /** * Configurator constructor. @@ -50,7 +49,6 @@ public function __construct() { $config = require \dirname(__DIR__, 2) . '/config/config.php'; - $this->name = $config->name; $this->uploadFolders = $config->uploadFolders; $this->copyBlankFiles = $config->copyBlankFiles; $this->copyTestFolders = $config->copyTestFolders; @@ -58,7 +56,6 @@ public function __construct() $this->oldFiles = $config->oldFiles; $this->oldFolders = $config->oldFolders; $this->renameTables = $config->renameTables; - $this->moduleStats = $config->moduleStats; $this->modCopyright = $config->modCopyright; $this->paths = require \dirname(__DIR__, 2) . '/config/paths.php'; diff --git a/class/Common/ModuleStats.php b/class/Common/ModuleStats.php index 1d5b438a..3b979822 100644 --- a/class/Common/ModuleStats.php +++ b/class/Common/ModuleStats.php @@ -4,6 +4,8 @@ namespace XoopsModules\Publisher\Common; +use XoopsModules\Publisher\Helper; +use XoopsModules\Publisher\Constants; /** * Created by PhpStorm. * User: mamba @@ -12,20 +14,6 @@ */ trait ModuleStats { - /** - * @param \XoopsModules\Publisher\Common\Configurator $configurator - * @return array - */ - public static function getModuleStats($configurator) - { - $moduleStats = []; - if (\count($configurator->moduleStats) > 0) { - foreach (\array_keys($configurator->moduleStats) as $i) { - $moduleStats[$i] = $configurator->moduleStats[$i]; - } - } - return $moduleStats; - } } diff --git a/class/Common/SysUtility.php b/class/Common/SysUtility.php index 1db61af1..0d2ddda3 100644 --- a/class/Common/SysUtility.php +++ b/class/Common/SysUtility.php @@ -43,7 +43,7 @@ class SysUtility use FilesManagement; // Files Management Trait - use ModuleStats; // ModuleStats Trait +// use ModuleStats; // ModuleStats Trait /** * truncateHtml can truncate a string up to a number of characters while preserving whole words and HTML tags diff --git a/class/Form/ItemForm.php b/class/Form/ItemForm.php index 32580a9d..33816a0d 100644 --- a/class/Form/ItemForm.php +++ b/class/Form/ItemForm.php @@ -587,8 +587,8 @@ public function createElements($obj) $table .= ''; foreach ($filesObj as $fileObj) { - $modify = "" . \_CO_PUBLISHER_EDITFILE . ""; - $delete = "" . \_CO_PUBLISHER_DELETEFILE . ""; + $modify = "" . $icons->edit . ""; + $delete = "" . $icons->delete . ""; $not_visible = ''; if (0 == $fileObj->status()) { $not_visible = ""; diff --git a/class/Item.php b/class/Item.php index c965f5ef..db2bdb4e 100644 --- a/class/Item.php +++ b/class/Item.php @@ -87,6 +87,7 @@ public function __construct($id = null) $this->initVar('meta_description', \XOBJ_DTYPE_TXTAREA, '', false); $this->initVar('short_url', \XOBJ_DTYPE_TXTBOX, '', false, 255); $this->initVar('item_tag', \XOBJ_DTYPE_TXTAREA, '', false); + $this->initVar('votetype', \XOBJ_DTYPE_INT, 1, false); // Non consistent values $this->initVar('pagescount', \XOBJ_DTYPE_INT, 0, false); if (null !== $id) { @@ -462,7 +463,7 @@ public function getFiles() /** * @return string */ - public function getAdminLinks() + public function getAdminLinks($icons) { $adminLinks = ''; if (\is_object($GLOBALS['xoopsUser']) @@ -471,18 +472,18 @@ public function getAdminLinks() if (Utility::userIsAdmin() || Utility::userIsAuthor($this) || Utility::userIsModerator($this)) { if ($this->helper->getConfig('perm_edit') || Utility::userIsModerator($this) || Utility::userIsAdmin()) { // Edit button - $adminLinks .= "" . \_CO_PUBLISHER_EDIT . ""; + $adminLinks .= "" . $icons->edit . ""; $adminLinks .= ' '; } if ($this->helper->getConfig('perm_delete') || Utility::userIsModerator($this) || Utility::userIsAdmin()) { // Delete button - $adminLinks .= "itemid() . "'>" . \_CO_PUBLISHER_DELETE . ""; + $adminLinks .= "itemid() . "'>" . $icons->delete . ""; $adminLinks .= ' '; } } if ($this->helper->getConfig('perm_clone') || Utility::userIsModerator($this) || Utility::userIsAdmin()) { // Duplicate button - $adminLinks .= "itemid() . "'>" . \_CO_PUBLISHER_CLONE . ""; + $adminLinks .= "itemid() . "'>" . $icons->clone . ""; $adminLinks .= ' '; } } @@ -493,12 +494,12 @@ public function getAdminLinks() /** * @return string */ - public function getPdfButton() + public function getPdfButton($icons) { $pdfButton = ''; // PDF button if (\is_file(XOOPS_ROOT_PATH . '/class/libraries/vendor/tecnickcom/tcpdf/tcpdf.php')) { - $pdfButton .= "" . \_CO_PUBLISHER_PDF . " "; + $pdfButton .= "" . $icons->pdf . " "; $pdfButton .= ' '; } else { // if (is_object($GLOBALS['xoopsUser']) && Utility::userIsAdmin()) { @@ -519,11 +520,11 @@ public function getPdfButton() /** * @return string */ - public function getPrintLinks() + public function getPrintLinks($icons) { $printLinks = ''; // Print button - $printLinks .= "itemid(), $this->short_url()) . "' rel='nofollow' target='_blank'>" . \_CO_PUBLISHER_PRINT . " "; + $printLinks .= "itemid(), $this->short_url()) . "' rel='nofollow' target='_blank'>" . $icons->print . " "; $printLinks .= ' '; return $printLinks; @@ -787,6 +788,7 @@ public function toArraySimple($display = 'default', $maxCharTitle = 0, $maxCharS $item['category'] = $this->getCategoryName(); $item['categorylink'] = $this->getCategoryLink(); $item['cancomment'] = $this->cancomment(); + $item['votetype'] = $this->votetype(); $comments = $this->comments(); if ($comments > 0) { //shows 1 comment instead of 1 comm. if comments ==1 @@ -852,13 +854,16 @@ public function toArraySimple($display = 'default', $maxCharTitle = 0, $maxCharS */ public function toArrayFull($item) { + $configurator = new Common\Configurator(); + $icons = $configurator->icons; + $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['adminlink'] = $this->getAdminLinks($icons); + $item['pdfbutton'] = $this->getPdfButton($icons); + $item['printlink'] = $this->getPrintLinks($icons); $item['categoryPath'] = $this->getCategoryPath($this->helper->getConfig('format_linked_path')); $item['who_when'] = $this->getWhoAndWhen(); $item['who'] = $this->getWho(); @@ -1147,6 +1152,7 @@ public function setVarsFromRequest() $this->setVar('doxcode', $this->helper->getConfig('submit_doxcode')); $this->setVar('doimage', $this->helper->getConfig('submit_doimage')); $this->setVar('dobr', $this->helper->getConfig('submit_dobr')); + $this->setVar('votetype', $this->helper->getConfig('ratingbars')); } else { $this->setVar('uid', Request::getInt('uid', 0, 'POST')); $this->setVar('cancomment', Request::getInt('allowcomments', 1, 'POST')); @@ -1156,6 +1162,7 @@ public function setVarsFromRequest() $this->setVar('doxcode', Request::getInt('doxcode', 1, 'POST')); $this->setVar('doimage', Request::getInt('doimage', 1, 'POST')); $this->setVar('dobr', Request::getInt('dolinebreak', 1, 'POST')); + $this->setVar('votetype', Request::getInt('votetype', 1, 'POST')); } $this->setVar('notifypub', Request::getString('notify', '', 'POST')); diff --git a/class/MimetypesUtility.php b/class/MimetypesUtility.php index f29b49a2..fa5a1b3b 100644 --- a/class/MimetypesUtility.php +++ b/class/MimetypesUtility.php @@ -343,13 +343,13 @@ public static function edit() } } - public static function manage() + public static function manage($icons) { $helper = Helper::getInstance(); $utility = new Utility(); /** @var MimetypeHandler $mimetypeHandler */ $mimetypeHandler = $helper->getHandler('Mimetype'); - global $imagearray, $start, $limit, $aSortBy, $aOrderBy, $aLimitBy, $aSearchBy; + global $start, $limit, $aSortBy, $aOrderBy, $aLimitBy, $aSearchBy; if (Request::getString('deleteMimes', '', 'POST')) { $aMimes = Request::getArray('mimes', [], 'POST'); @@ -456,15 +456,15 @@ public static function manage() " . $mime->getVar('mime_ext') . " getVar('mime_id') . '&mime_admin=' . $mime->getVar('mime_admin') . '&limit=' . $limit . '&start=' . $start . "'> - " . ($mime->getVar('mime_admin') ? $imagearray['online'] : $imagearray['offline']) . " + " . ($mime->getVar('mime_admin') ? $icons->online : $icons->offline) . " getVar('mime_id') . '&mime_user=' . $mime->getVar('mime_user') . '&limit=' . $limit . '&start=' . $start . "'> - " . ($mime->getVar('mime_user') ? $imagearray['online'] : $imagearray['offline']) . " + " . ($mime->getVar('mime_user') ? $icons->online : $icons->offline) . " - getVar('mime_id') . '&limit=' . $limit . '&start=' . $start . "'>" . $imagearray['editimg'] . " - getVar('mime_id') . '&limit=' . $limit . '&start=' . $start . "'>" . $imagearray['deleteimg'] . ' + getVar('mime_id') . '&limit=' . $limit . '&start=' . $start . "'>" . $icons->edit . " + getVar('mime_id') . '&limit=' . $limit . '&start=' . $start . "'>" . $icons->delete . ' '; } @@ -486,12 +486,12 @@ public static function manage() require_once \dirname(__DIR__) . '/admin/admin_footer.php'; } - public static function search() + public static function search($icons) { $helper = Helper::getInstance(); /** @var MimetypeHandler $mimetypeHandler */ $mimetypeHandler = $helper->getHandler('Mimetype'); - global $limit, $start, $imagearray, $aSearchBy, $aOrderBy, $aLimitBy, $aSortBy; + global $limit, $start, $aSearchBy, $aOrderBy, $aLimitBy, $aSortBy; if (Request::getString('deleteMimes', '', 'POST')) { $aMimes = Request::getArray('mimes', [], 'POST'); @@ -607,15 +607,15 @@ public static function search() " . $mime->getVar('mime_ext') . " getVar('mime_id') . '&mime_admin=' . $mime->getVar('mime_admin') . '&limit=' . $limit . '&start=' . $start . "'> - " . ($mime->getVar('mime_admin') ? $imagearray['online'] : $imagearray['offline']) . " + " . ($mime->getVar('mime_admin') ? $icons->online : $icons->offline) . " getVar('mime_id') . '&mime_user=' . $mime->getVar('mime_user') . '&limit=' . $limit . '&start=' . $start . "'> - " . ($mime->getVar('mime_user') ? $imagearray['online'] : $imagearray['offline']) . " + " . ($mime->getVar('mime_user') ? $icons->online : $icons->offline) . " - getVar('mime_id') . '&limit=' . $limit . '&start=' . $start . "'>" . $imagearray['editimg'] . " - getVar('mime_id') . '&limit=' . $limit . '&start=' . $start . "'>" . $imagearray['deleteimg'] . ' + getVar('mime_id') . '&limit=' . $limit . '&start=' . $start . "'>" . $icons->edit . " + getVar('mime_id') . '&limit=' . $limit . '&start=' . $start . "'>" . $icons->delete . ' '; } diff --git a/class/Utility.php b/class/Utility.php index c4eb3c91..8ac0188e 100644 --- a/class/Utility.php +++ b/class/Utility.php @@ -180,8 +180,8 @@ public static function displayCategory(Category $categoryObj, $level = 0) $description = \mb_substr($description, 0, 100 - 1) . '...'; } } - $modify = "" . \_AM_PUBLISHER_EDITCOL . ""; - $delete = "" . \_AM_PUBLISHER_DELETECOL . ""; + $modify = "" . $icons->edit . ""; + $delete = "" . $icons->delete . ""; $spaces = \str_repeat(' ', ($level * 3)); /* $spaces = ''; @@ -324,8 +324,8 @@ public static function editCategory($showmenu = false, $categoryId = 0, $nbSubCa echo ''; if ($totalsubs > 0) { foreach ($subcatsObj as $subcat) { - $modify = "getModule()->dirname() . "/assets/images/links/edit.gif' title='" . \_AM_PUBLISHER_MODIFY . "' alt='" . \_AM_PUBLISHER_MODIFY . "'>"; - $delete = "getModule()->dirname() . "/assets/images/links/delete.png' title='" . \_AM_PUBLISHER_DELETE . "' alt='" . \_AM_PUBLISHER_DELETE . "'>"; + $modify = "" . $icons->edit . ""; + $delete = "" . $icons->delete . ""; echo ''; echo "" . $subcat->categoryid() . ''; echo "getModule()->dirname() . '/category.php?categoryid=' . $subcat->categoryid() . '&parentid=' . $subcat->parentid() . "'>" . $subcat->name() . ''; @@ -362,18 +362,8 @@ public static function editCategory($showmenu = false, $categoryId = 0, $nbSubCa if ($totalitems > 0) { for ($i = 0; $i < $totalitemsOnPage; ++$i) { $categoryObj = $allcats[$itemsObj[$i]->categoryid()]; - $modify = "getModule()->dirname() . "/assets/images/links/edit.gif' title='" . \_AM_PUBLISHER_EDITITEM . "' alt='" . \_AM_PUBLISHER_EDITITEM . "'>"; - $delete = "getModule()->dirname() - . "/assets/images/links/delete.png' title='" - . \_AM_PUBLISHER_DELETEITEM - . "' alt='" - . \_AM_PUBLISHER_DELETEITEM - . "'>"; + $modify = "" . $icons->edit . ""; + $delete = "" . $icons->delete . ""; echo ''; echo "" . $itemsObj[$i]->itemid() . ''; echo "" . $categoryObj->name() . ''; @@ -1429,4 +1419,26 @@ public static function convertCharset($item) return @\iconv('windows-1256', 'UTF-8', $item); } + + public static function getModuleStats() + { + $helper = Helper::getInstance(); + // $moduleStats = []; + // if (\count($configurator->moduleStats) > 0) { + // foreach (\array_keys($configurator->moduleStats) as $i) { + // $moduleStats[$i] = $configurator->moduleStats[$i]; + // } + // } + + $moduleStats = [ + 'totalcategories' => $helper->getHandler('Category')->getCategoriesCount(-1), + 'totalitems' => $helper->getHandler('Item')->getItemsCount(), + 'totalsubmitted' => $helper->getHandler('Item')->getItemsCount(-1, Constants::PUBLISHER_STATUS_SUBMITTED), + 'totalpublished' => $helper->getHandler('Item')->getItemsCount(-1, Constants::PUBLISHER_STATUS_PUBLISHED), + 'totaloffline' => $helper->getHandler('Item')->getItemsCount(-1, Constants::PUBLISHER_STATUS_OFFLINE), + 'totalrejected' => $helper->getHandler('Item')->getItemsCount(-1, Constants::PUBLISHER_STATUS_REJECTED), + ]; + + return $moduleStats; + } } diff --git a/config/config.php b/config/config.php index 31f38782..21f07298 100644 --- a/config/config.php +++ b/config/config.php @@ -25,11 +25,9 @@ require_once dirname(__DIR__) . '/include/common.php'; $moduleDirName = basename(dirname(__DIR__)); -$moduleDirNameUpper = mb_strtoupper($moduleDirName); $helper = Helper::getInstance(); return (object)[ - 'name' => $moduleDirNameUpper . ' Module Configurator', 'paths' => [ 'dirname' => $moduleDirName, 'admin' => XOOPS_ROOT_PATH . '/modules/' . $moduleDirName . '/admin', @@ -86,15 +84,5 @@ 'renameTables' => [// 'XX_archive' => 'ZZZZ_archive', ], - 'moduleStats' => [ - 'totalcategories' => $helper->getHandler('Category')->getCategoriesCount(-1), - 'totalitems' => $helper->getHandler('Item')->getItemsCount(), - 'totalsubmitted' => $helper->getHandler('Item')->getItemsCount(-1, Constants::PUBLISHER_STATUS_SUBMITTED), - 'totalpublished' => $helper->getHandler('Item')->getItemsCount(-1, Constants::PUBLISHER_STATUS_PUBLISHED), - 'totaloffline' => $helper->getHandler('Item')->getItemsCount(-1, Constants::PUBLISHER_STATUS_OFFLINE), - 'totalrejected' => $helper->getHandler('Item')->getItemsCount(-1, Constants::PUBLISHER_STATUS_REJECTED), - ], - 'modCopyright' => " - XOOPS Project", -]; +]; diff --git a/config/icons.php b/config/icons.php index 483c7c23..1c595d2f 100644 --- a/config/icons.php +++ b/config/icons.php @@ -5,22 +5,34 @@ /** @return object */ use Xmf\Module\Admin; +use XoopsModules\Publisher\Helper; $pathIcon16 = Admin::iconUrl('', 16); $moduleDirName = basename(dirname(__DIR__)); +$moduleDirNameUpper = mb_strtoupper($moduleDirName); +$helper = Helper::getInstance(); +$helper->loadLanguage('admin'); +$pathModIcon32 = $helper->getModule()->getInfo('modicons32'); + +$print = constant('CO_' . $moduleDirNameUpper . '_' . 'PRINT'); +$pdf = constant('CO_' . $moduleDirNameUpper . '_' . 'PDF'); return (object)[ - // 'name' => mb_strtoupper($moduleDirName) . ' IconConfigurator', - // 'icons' => [ - 'edit' => " . _EDIT . ", - 'delete' => "" . _DELETE . "", - 'clone' => "" . _CLONE . "", - 'preview' => "" . _PREVIEW . "", - 'print' => "" . _CLONE . "", - 'pdf' => "" . _CLONE . "", - 'add' => "" . _ADD . "", - '0' => "" . 0 . "", - '1' => "" . 1 . "", - // ], + 'edit' => "" . _EDIT . "", + 'delete' => "" . _DELETE . "", + 'clone' => "" . _CLONE . "", + 'preview' => "" . _PREVIEW . "", + 'print' => "" . $print . "", + 'pdf' => "" . $pdf . "", + 'add' => "" . _ADD . "", + '0' => "" . 0 . "", + '1' => "" . 1 . "", + + //Publisher + 'rejectededit' => "" . _AM_PUBLISHER_REJECTED_EDIT . "", + 'online' => "" . _AM_PUBLISHER_ICO_ONLINE . "", + 'offline' => "" . _AM_PUBLISHER_ICO_OFFLINE . "", + 'moderate' => "" . _AM_PUBLISHER_SUBMISSION_MODERATE . "", + 'mail' => "" . _CO_PUBLISHER_MAIL . "", ]; diff --git a/config/paths.php b/config/paths.php index dc373f17..78c8838e 100644 --- a/config/paths.php +++ b/config/paths.php @@ -10,8 +10,6 @@ // $moduleDirNameUpper = mb_strtoupper($moduleDirName); return (object)[ - // 'name' => mb_strtoupper($moduleDirName) . ' PathConfigurator', - // 'paths' => [ 'dirname' => $moduleDirName, 'admin' => XOOPS_ROOT_PATH . '/modules/' . $moduleDirName . '/admin', 'modPath' => XOOPS_ROOT_PATH . '/modules/' . $moduleDirName, @@ -21,12 +19,5 @@ 'uploadPathCategory' => XOOPS_UPLOAD_PATH . '/' . $moduleDirName . '/category', 'uploadPathScreenshots' => XOOPS_UPLOAD_PATH . '/' . $moduleDirName . '/screenshots', - // ], - // 'uploadFolders' => [ - // XOOPS_UPLOAD_PATH . '/' . $moduleDirName, - // XOOPS_UPLOAD_PATH . '/' . $moduleDirName . '/category', - // XOOPS_UPLOAD_PATH . '/' . $moduleDirName . '/screenshots', - // //XOOPS_UPLOAD_PATH . '/flags' - // ], ]; //} diff --git a/include/common.php b/include/common.php index 4b78cc55..f7d93d0a 100644 --- a/include/common.php +++ b/include/common.php @@ -21,7 +21,9 @@ */ use Xmf\Module\Admin; -use XoopsModules\Publisher\{Helper, +use XoopsModules\Publisher\{ + Common\Configurator, + Helper, Utility }; @@ -40,6 +42,9 @@ $helper->loadLanguage('common'); +$configurator = new Configurator(); +$icons = $configurator->icons; + //$utilities = new Publisher\Utilities(); //$brokenHandler = new Publisher\BrokenHandler($db); //$categoryHandler = new Publisher\CategoryHandler($db); @@ -108,17 +113,17 @@ //$pathModIcon16 = $helper->getModule()->getInfo('modicons16'); //$pathModIcon32 = $helper->getModule()->getInfo('modicons32'); -$icons = [ - 'edit' => " . _EDIT . ", - 'delete' => "" . _DELETE . "", - 'clone' => "" . _CLONE . "", - 'preview' => "" . _PREVIEW . "", - 'print' => "" . _CLONE . "", - 'pdf' => "" . _CLONE . "", - 'add' => "" . _ADD . "", - '0' => "" . 0 . "", - '1' => "" . 1 . "", -]; +//$icons = [ +// 'edit' => " . _EDIT . ", +// 'delete' => "" . _DELETE . "", +// 'clone' => "" . _CLONE . "", +// 'preview' => "" . _PREVIEW . "", +// 'print' => "" . _CLONE . "", +// 'pdf' => "" . _CLONE . "", +// 'add' => "" . _ADD . "", +// '0' => "" . 0 . "", +// '1' => "" . 1 . "", +//]; $debug = false; diff --git a/language/english/common.php b/language/english/common.php index d644c5ab..abcc45a5 100644 --- a/language/english/common.php +++ b/language/english/common.php @@ -135,8 +135,8 @@ define('CO_' . $moduleDirNameUpper . '_SPHPINI', "Information taken from PHP ini file:"); define('CO_' . $moduleDirNameUpper . '_UPLOADPATHDSC', 'Note. Upload path *MUST* contain the full server path of your upload folder.'); -define('CO_' . $moduleDirNameUpper . '_PRINT', "Print"); -define('CO_' . $moduleDirNameUpper . '_PDF', "Create PDF"); +define('CO_' . $moduleDirNameUpper . '_' . 'PRINT', "Print"); +define('CO_' . $moduleDirNameUpper . '_' . 'PDF', "Create PDF"); define('CO_' . $moduleDirNameUpper . '_UPGRADEFAILED0', "Update failed - couldn't rename field '%s'"); define('CO_' . $moduleDirNameUpper . '_UPGRADEFAILED1', "Update failed - couldn't add new fields");