From 647babff4e7beea3b75eff5ec014bf951c3687be Mon Sep 17 00:00:00 2001 From: "NB-GABOR02\\Goffy" Date: Tue, 7 Apr 2026 14:45:21 +0200 Subject: [PATCH 1/7] updated creation code to generate module with no errors from copilot --- class/Building.php | 8 +- class/Common/Breadcrumb.php | 2 +- class/Common/Confirm.php | 2 +- class/Common/DirectoryChecker.php | 6 +- class/Common/FileChecker.php | 34 +- class/Common/Migrate.php | 2 +- class/Common/ModuleFeedback.php | 8 +- class/Common/ModuleStats.php | 4 +- class/Common/SysUtility.php | 14 +- class/Common/TableChecker.php | 20 +- class/Common/TestdataButtons.php | 8 +- class/Common/VersionChecks.php | 2 +- class/Devtools.php | 18 +- class/Fieldattributes.php | 3 +- class/Fieldelements.php | 7 +- class/FieldelementsHandler.php | 36 +- class/Fieldkey.php | 3 +- class/Fieldnull.php | 3 +- class/Fields.php | 14 +- class/FieldsHandler.php | 28 +- class/Fieldtype.php | 3 +- class/Files/Admin/AdminBroken.php | 73 ++-- class/Files/Admin/AdminHeader.php | 16 +- class/Files/Admin/AdminIndex.php | 38 +- class/Files/Admin/AdminMenu.php | 31 +- class/Files/Admin/AdminPermissions.php | 36 +- .../Files/Assets/Css/Admin/CssAdminStyles.php | 7 +- class/Files/Assets/Css/CssSelectors.php | 9 +- class/Files/Assets/Css/CssStyles.php | 7 +- class/Files/Assets/Js/JavascriptJQuery.php | 20 +- class/Files/Assets/Js/JsJquery.php | 11 +- class/Files/Blocks/BlocksFiles.php | 107 +++-- class/Files/Blocks/BlocksFilesSpotlight.php | 102 +++-- class/Files/CheckData.php | 45 +-- class/Files/Classes/ClassFiles.php | 64 +-- class/Files/Classes/ClassFormElements.php | 113 +++--- class/Files/Classes/ClassHandlerFiles.php | 35 +- class/Files/Classes/ClassSpecialFiles.php | 37 +- class/Files/Classes/ClassXoopsCode.php | 133 +++---- class/Files/Config/ConfigConfig.php | 11 +- class/Files/CreateAbstractClass.php | 6 +- class/Files/CreateArchitecture.php | 110 +++--- class/Files/CreateClone.php | 8 +- class/Files/CreateCodeIndents.php | 9 +- class/Files/CreateFile.php | 61 ++- class/Files/CreateHtmlCode.php | 85 ++-- class/Files/CreateMoreFiles.php | 18 +- class/Files/CreatePhpCode.php | 176 ++++----- class/Files/CreateSmartyCode.php | 54 ++- class/Files/CreateStructure.php | 29 +- class/Files/CreateTableFields.php | 16 +- class/Files/CreateXoopsCode.php | 365 +++++++++--------- class/Files/Docs/DocsChangelog.php | 7 +- class/Files/Docs/DocsFiles.php | 39 +- .../Includes/IncludeCommentFunctions.php | 24 +- class/Files/Includes/IncludeComments.php | 19 +- class/Files/Includes/IncludeCommon.php | 23 +- class/Files/Includes/IncludeFunctions.php | 65 ++-- class/Files/Includes/IncludeJquery.php | 11 +- class/Files/Includes/IncludeNotifications.php | 25 +- class/Files/Includes/IncludeSearch.php | 12 +- class/Files/Language/LanguageAdmin.php | 38 +- class/Files/Language/LanguageBlocks.php | 15 +- class/Files/Language/LanguageDefines.php | 13 +- class/Files/Language/LanguageHelp.php | 15 +- class/Files/Language/LanguageMailTpl.php | 5 +- class/Files/Language/LanguageMain.php | 28 +- class/Files/Language/LanguageModinfo.php | 13 +- class/Files/Sql/SqlFile.php | 6 +- .../Templates/Admin/TemplatesAdminAbout.php | 5 +- .../Templates/Admin/TemplatesAdminBroken.php | 81 ++-- .../Templates/Admin/TemplatesAdminFooter.php | 13 +- .../Templates/Admin/TemplatesAdminHeader.php | 9 +- .../Templates/Admin/TemplatesAdminIndex.php | 9 +- .../Templates/Admin/TemplatesAdminPages.php | 48 +-- .../Admin/TemplatesAdminPermissions.php | 19 +- .../Blocks/Defstyle/TemplatesBlocks.php | 37 +- .../Defstyle/TemplatesBlocksSpotlight.php | 21 +- .../Templates/User/Defstyle/Breadcrumbs.php | 26 +- .../Templates/User/Defstyle/Categories.php | 17 +- .../User/Defstyle/CategoriesList.php | 22 +- .../Files/Templates/User/Defstyle/Footer.php | 19 +- .../Files/Templates/User/Defstyle/Header.php | 18 +- class/Files/Templates/User/Defstyle/Index.php | 19 +- .../Templates/User/Defstyle/MoreFiles.php | 14 +- class/Files/Templates/User/Defstyle/Pages.php | 32 +- .../Templates/User/Defstyle/PagesItem.php | 59 ++- .../Templates/User/Defstyle/PagesList.php | 11 +- class/Files/Templates/User/Defstyle/Pdf.php | 9 +- class/Files/Templates/User/Defstyle/Rate.php | 25 +- class/Files/Templates/User/Defstyle/Rss.php | 48 +-- .../Files/Templates/User/Defstyle/Search.php | 25 +- .../Templates/User/Defstyle/UserPrint.php | 37 +- class/Files/User/UserFooter.php | 11 +- class/Files/User/UserHeader.php | 14 +- class/Files/User/UserIndex.php | 33 +- class/Files/User/UserListTag.php | 10 +- class/Files/User/UserNotificationUpdate.php | 9 +- class/Files/User/UserPages.php | 100 ++--- class/Files/User/UserPdf.php | 138 ++++--- class/Files/User/UserPrint.php | 39 +- class/Files/User/UserRate.php | 99 +++-- class/Files/User/UserRss.php | 50 +-- class/Files/User/UserSearch.php | 18 +- class/Files/User/UserViewTag.php | 10 +- class/Files/User/UserXoopsCode.php | 35 +- class/Files/User/UserXoopsVersion.php | 139 ++++--- class/Files/admin/AdminAbout.php | 14 +- class/Files/admin/AdminFooter.php | 11 +- class/Files/admin/AdminPages.php | 68 ++-- class/Files/admin/AdminXoopsCode.php | 154 ++++---- class/Form/FormRadio.php | 4 +- class/Form/FormRaw.php | 2 +- class/Form/FormTab.php | 1 - class/Form/FormTabTray.php | 2 +- class/Form/ThemeForm.php | 4 +- class/Helper.php | 2 +- class/Html/FormLabel.php | 2 +- class/Import.php | 4 +- class/Logo.php | 2 +- class/LogoGenerator.php | 4 +- class/Modules.php | 12 +- class/ModulesHandler.php | 21 +- class/Morefiles.php | 10 +- class/MorefilesHandler.php | 27 +- class/Session.php | 6 +- class/Settings.php | 8 +- class/SettingsHandler.php | 21 +- class/SplClassLoader.php | 14 +- class/Tables.php | 10 +- class/TablesHandler.php | 27 +- class/Utility.php | 20 +- class/autoload.php | 2 +- xoops_version.php | 8 +- 134 files changed, 2041 insertions(+), 2162 deletions(-) diff --git a/class/Building.php b/class/Building.php index 1fbd8a57..eaf07224 100644 --- a/class/Building.php +++ b/class/Building.php @@ -33,8 +33,6 @@ class Building /** * @static function getInstance * - * @param null - * * @return Building */ public static function getInstance() @@ -52,7 +50,7 @@ public static function getInstance() * * @return \XoopsThemeForm */ - public function getForm($action = false) + public function getForm(bool $action = false) { $helper = Modulebuilder\Helper::getInstance(); if (false === $action) { @@ -85,7 +83,7 @@ public function getForm($action = false) * @param string $dir * @param string $pattern */ - public function clearDir($dir, $pattern = '*'): void + public function clearDir(string $dir, string $pattern = '*'): void { // Find all files and folders matching pattern $files = glob($dir . "/$pattern"); @@ -121,7 +119,7 @@ public function clearDir($dir, $pattern = '*'): void * @param string $src * @param string $dst */ - public function copyDir($src, $dst): void + public function copyDir(string $src, string $dst): void { $dir = \opendir($src); if (!\mkdir($dst) && !\is_dir($dst)) { diff --git a/class/Common/Breadcrumb.php b/class/Common/Breadcrumb.php index dbd19c3b..c4cb3d3c 100644 --- a/class/Common/Breadcrumb.php +++ b/class/Common/Breadcrumb.php @@ -52,7 +52,7 @@ public function __construct() * @param string $title * @param string $link */ - public function addLink($title = '', $link = ''): void + public function addLink(string $title = '', string $link = ''): void { $this->bread[] = [ 'link' => $link, diff --git a/class/Common/Confirm.php b/class/Common/Confirm.php index d2108513..60580058 100644 --- a/class/Common/Confirm.php +++ b/class/Common/Confirm.php @@ -53,7 +53,7 @@ class Confirm * @param string $title * @param string $label */ - public function __construct($hiddens, $action, $object, $title = '', $label = '') + public function __construct($hiddens, $action, $object, string $title = '', string $label = '') { $this->hiddens = $hiddens; $this->action = $action; diff --git a/class/Common/DirectoryChecker.php b/class/Common/DirectoryChecker.php index 6c450a96..5ad1d848 100644 --- a/class/Common/DirectoryChecker.php +++ b/class/Common/DirectoryChecker.php @@ -41,7 +41,7 @@ class DirectoryChecker * * @return bool|string */ - public static function getDirectoryStatus($path, $mode = 0777, $redirectFile = null) + public static function getDirectoryStatus($path, int $mode = 0777, $redirectFile = null) { $pathIcon16 = \Xmf\Module\Admin::iconUrl('', '16'); @@ -99,7 +99,7 @@ public static function getDirectoryStatus($path, $mode = 0777, $redirectFile = n * * @return bool */ - public static function createDirectory($target, $mode = 0777) + public static function createDirectory($target, int $mode = 0777) { $target = \str_replace('..', '', $target); @@ -113,7 +113,7 @@ public static function createDirectory($target, $mode = 0777) * * @return bool */ - public static function setDirectoryPermissions($target, $mode = 0777) + public static function setDirectoryPermissions($target, int $mode = 0777) { $target = \str_replace('..', '', $target); diff --git a/class/Common/FileChecker.php b/class/Common/FileChecker.php index c8282eb1..638475fa 100644 --- a/class/Common/FileChecker.php +++ b/class/Common/FileChecker.php @@ -37,12 +37,12 @@ class FileChecker { /** - * @param string $file_path + * @param string $file_path * @param string|null $original_file_path - * @param string $redirectFile + * @param string $redirectFile * @return bool|string */ - public static function getFileStatus($file_path, $original_file_path = null, $redirectFile) + public static function getFileStatus(string $file_path, string $original_file_path = null, string $redirectFile) { $pathIcon16 = \Xmf\Module\Admin::iconUrl('', '16'); @@ -135,7 +135,7 @@ public static function fileExists($file_path) * * @return bool */ - public static function setFilePermissions($target, $mode = 0777) + public static function setFilePermissions($target, int $mode = 0777) { $target = \str_replace('..', '', $target); @@ -144,18 +144,16 @@ public static function setFilePermissions($target, $mode = 0777) } $op = Request::getString('op', '', 'POST'); -switch ($op) { - case 'copyfile': - if (\Xmf\Request::hasVar('original_file_path', 'POST')) { - $original_file_path = $_POST['original_file_path']; - } - if (\Xmf\Request::hasVar('file_path', 'POST')) { - $file_path = $_POST['file_path']; - } - if (\Xmf\Request::hasVar('redirect', 'POST')) { - $redirect = $_POST['redirect']; - } - $msg = FileChecker::copyFile($original_file_path, $file_path) ? \constant('CO_' . $moduleDirNameUpper . '_' . 'FC_FILECOPIED') : \constant('CO_' . $moduleDirNameUpper . '_' . 'FC_FILENOTCOPIED'); - \redirect_header($redirect, 2, $msg . ': ' . $file_path); - break; +if ($op == 'copyfile') { + if (\Xmf\Request::hasVar('original_file_path', 'POST')) { + $original_file_path = $_POST['original_file_path']; + } + if (\Xmf\Request::hasVar('file_path', 'POST')) { + $file_path = $_POST['file_path']; + } + if (\Xmf\Request::hasVar('redirect', 'POST')) { + $redirect = $_POST['redirect']; + } + $msg = FileChecker::copyFile($original_file_path, $file_path) ? \constant('CO_' . $moduleDirNameUpper . '_' . 'FC_FILECOPIED') : \constant('CO_' . $moduleDirNameUpper . '_' . 'FC_FILENOTCOPIED'); + \redirect_header($redirect, 2, $msg . ': ' . $file_path); } diff --git a/class/Common/Migrate.php b/class/Common/Migrate.php index 5e46abac..d56fc374 100644 --- a/class/Common/Migrate.php +++ b/class/Common/Migrate.php @@ -58,7 +58,7 @@ private function changePrefix(): void * @param string $tableName table to convert * @param string $columnName column with IP address */ - private function convertIPAddresses($tableName, $columnName): void + private function convertIPAddresses(string $tableName, string $columnName): void { if ($this->tableHandler->useTable($tableName)) { $attributes = $this->tableHandler->getColumnAttributes($tableName, $columnName); diff --git a/class/Common/ModuleFeedback.php b/class/Common/ModuleFeedback.php index f4b68532..b756fa70 100644 --- a/class/Common/ModuleFeedback.php +++ b/class/Common/ModuleFeedback.php @@ -36,8 +36,6 @@ class ModuleFeedback extends \XoopsObject /** * Constructor - * - * @param null */ public function __construct() { @@ -45,8 +43,6 @@ public function __construct() /** * @static function &getInstance - * - * @param null */ public static function getInstance(): void { @@ -70,7 +66,9 @@ public function getFormFeedback() $form = new \XoopsThemeForm(\constant('CO_' . $moduleDirNameUpper . '_' . 'FB_FORM_TITLE'), 'formfeedback', 'feedback.php', 'post', true); $form->setExtra('enctype="multipart/form-data"'); - $recipient = new \XoopsFormText(\constant('CO_' . $moduleDirNameUpper . '_' . 'FB_RECIPIENT'), 'recipient', 50, 255, $GLOBALS['xoopsModule']->getInfo('author_mail')); + $xoopsModule = $GLOBALS['xoopsModule'] ?? null; + $authorMail = $xoopsModule ? (string)$xoopsModule->getInfo('author_mail') : ''; + $recipient = new \XoopsFormText(\constant('CO_' . $moduleDirNameUpper . '_' . 'FB_RECIPIENT'), 'recipient', 50, 255, $authorMail); $recipient->setExtra('disabled="disabled"'); $form->addElement($recipient); $your_name = new \XoopsFormText(\constant('CO_' . $moduleDirNameUpper . '_' . 'FB_NAME'), 'your_name', 50, 255, $this->name); diff --git a/class/Common/ModuleStats.php b/class/Common/ModuleStats.php index 7fb40989..674b69c0 100644 --- a/class/Common/ModuleStats.php +++ b/class/Common/ModuleStats.php @@ -23,10 +23,10 @@ trait ModuleStats { /** * @param \XoopsModules\Modulebuilder\Common\Configurator $configurator - * @param array $moduleStats + * @param array $moduleStats * @return array */ - public static function getModuleStats($configurator, $moduleStats) + public static function getModuleStats(Configurator $configurator, array $moduleStats) { if (\count($configurator->moduleStats) > 0) { foreach (\array_keys($configurator->moduleStats) as $i) { diff --git a/class/Common/SysUtility.php b/class/Common/SysUtility.php index e8d4d9de..48840524 100644 --- a/class/Common/SysUtility.php +++ b/class/Common/SysUtility.php @@ -62,14 +62,14 @@ public static function getInstance() * www.cakephp.org * * @param string $text String to truncate. - * @param int $length Length of returned string, including ellipsis. + * @param int $length Length of returned string, including ellipsis. * @param string $ending Ending to be appended to the trimmed string. - * @param bool $exact If false, $text will not be cut mid-word - * @param bool $considerHtml If true, HTML tags would be handled correctly + * @param bool $exact If false, $text will not be cut mid-word + * @param bool $considerHtml If true, HTML tags would be handled correctly * * @return string Trimmed string. */ - public static function truncateHtml($text, $length = 100, $ending = '...', $exact = false, $considerHtml = true) + public static function truncateHtml(string $text, int $length = 100, string $ending = '...', bool $exact = false, bool $considerHtml = true) { if ($considerHtml) { // if the plain text is shorter than the maximum length, return the whole text @@ -161,11 +161,11 @@ public static function truncateHtml($text, $length = 100, $ending = '...', $exac } /** - * @param \Xmf\Module\Helper $helper - * @param array|null $options + * @param \Xmf\Module\Helper|null $helper + * @param array|null $options * @return \XoopsFormDhtmlTextArea|\XoopsFormEditor */ - public static function getEditor($helper = null, $options = null) + public static function getEditor(\Xmf\Module\Helper $helper = null, array $options = null) { /** @var Helper $helper */ if (null === $options) { diff --git a/class/Common/TableChecker.php b/class/Common/TableChecker.php index 1ef283d7..5bf140a6 100644 --- a/class/Common/TableChecker.php +++ b/class/Common/TableChecker.php @@ -46,7 +46,6 @@ class TableChecker extends \XoopsObject public const CHECKTYPE_UPDATE_REPORT = 2; //update and report /** - * @param \XoopsModules\Modulebuilder\Common\TableChecker|null * @param mixed $mydirname * @param mixed $checktype */ @@ -72,7 +71,7 @@ public function processSQL() if ($numRows) { //table exist $this->result[] = 'Table exist:' . $table; - $ret = $this->checkTableFields($table, $tabledef['fields']); + //$ret = $this->checkTableFields($table, $tabledef['fields']); } else { if ($this::CHECKTYPE_UPDATE == $this->checktype || $this::CHECKTYPE_UPDATE_REPORT == $this->checktype) { // create new table @@ -92,6 +91,8 @@ public function processSQL() if (self::CHECKTYPE_REPORT == $this->checktype || self::CHECKTYPE_UPDATE_REPORT == $this->checktype) { return $this->result; } + + return []; } private function readSQLFile() @@ -156,11 +157,9 @@ private function extractKey($line) { //todo: split string into single keys $needle = '('; - $key_text = \substr($line, \strpos($line, $needle, 0) + 1); + $key_text = \substr($line, \strpos($line, $needle) + 1); $needle = ')'; - $key_text = \substr($key_text, 0, \strpos($key_text, $needle, 0)); - - return $key_text; + return \substr($key_text, 0, \strpos($key_text, $needle)); } private function extractField($line) @@ -191,7 +190,7 @@ private function extractField($line) if (\count($params) > $counter) { if ('default' == \mb_strtolower($params[$counter])) { $field['default'] = $params[$counter] . ' ' . $params[$counter + 1]; - $counter = $counter + 2; + //$counter = $counter + 2; } } @@ -211,7 +210,7 @@ private function checkTableFields($table, $fields) $numRows = $GLOBALS['xoopsDB']->getRowsNum($check); if ($numRows) { //field exist - $this->checkField($table, $field); + $this->checkField($field); } else { if (self::CHECKTYPE_UPDATE == $this->checktype || self::CHECKTYPE_UPDATE_REPORT == $this->checktype) { // create new field @@ -219,7 +218,7 @@ private function checkTableFields($table, $fields) if ('' !== (string)$field['after']) { $sql .= ' AFTER `' . $field['after'] . '`;'; } - if ($result = $GLOBALS['xoopsDB']->queryF($sql)) { + if ($GLOBALS['xoopsDB']->queryF($sql)) { $this->result[] = 'Field added:' . $fieldname; } else { \xoops_error($GLOBALS['xoopsDB']->error() . '
' . $sql); @@ -234,11 +233,10 @@ private function checkTableFields($table, $fields) return true; } - private function checkField($table, $field) + private function checkField($field): void { //to be created $this->result[] = 'Field exist:' . $field['name'] . ' - no changes'; - return true; } } diff --git a/class/Common/TestdataButtons.php b/class/Common/TestdataButtons.php index 75f63d36..3c7791df 100644 --- a/class/Common/TestdataButtons.php +++ b/class/Common/TestdataButtons.php @@ -41,7 +41,7 @@ class TestdataButtons * * @return void */ - public static function loadButtonConfig($adminObject): void + public static function loadButtonConfig(\Xmf\Module\Admin $adminObject): void { $moduleDirName = \basename(\dirname(__DIR__, 2)); $moduleDirNameUpper = \mb_strtoupper($moduleDirName); @@ -52,13 +52,13 @@ public static function loadButtonConfig($adminObject): void if (self::SHOW_BUTTONS == $displaySampleButton) { \xoops_loadLanguage('admin/modulesadmin', 'system'); - $adminObject->addItemButton(\constant('CO_' . $moduleDirNameUpper . '_' . 'LOAD_SAMPLEDATA'), $helper->url('testdata/index.php?op=load'), 'add'); - $adminObject->addItemButton(\constant('CO_' . $moduleDirNameUpper . '_' . 'SAVE_SAMPLEDATA'), $helper->url('testdata/index.php?op=save'), 'add'); + $adminObject->addItemButton(\constant('CO_' . $moduleDirNameUpper . '_' . 'LOAD_SAMPLEDATA'), $helper->url('testdata/index.php?op=load')); + $adminObject->addItemButton(\constant('CO_' . $moduleDirNameUpper . '_' . 'SAVE_SAMPLEDATA'), $helper->url('testdata/index.php?op=save')); $adminObject->addItemButton(\constant('CO_' . $moduleDirNameUpper . '_' . 'CLEAR_SAMPLEDATA'), $helper->url('testdata/index.php?op=clear'), 'alert'); // $adminObject->addItemButton(constant('CO_' . $moduleDirNameUpper . '_' . 'EXPORT_SCHEMA'), $helper->url( 'testdata/index.php?op=exportschema'), 'add'); $adminObject->addItemButton(\constant('CO_' . $moduleDirNameUpper . '_' . 'HIDE_SAMPLEDATA_BUTTONS'), '?op=hide_buttons', 'delete'); } else { - $adminObject->addItemButton(\constant('CO_' . $moduleDirNameUpper . '_' . 'SHOW_SAMPLEDATA_BUTTONS'), '?op=show_buttons', 'add'); + $adminObject->addItemButton(\constant('CO_' . $moduleDirNameUpper . '_' . 'SHOW_SAMPLEDATA_BUTTONS'), '?op=show_buttons'); // $displaySampleButton = $config['displaySampleButton']; } } diff --git a/class/Common/VersionChecks.php b/class/Common/VersionChecks.php index a18c6f28..fa19754f 100644 --- a/class/Common/VersionChecks.php +++ b/class/Common/VersionChecks.php @@ -44,7 +44,7 @@ public static function checkVerXoops(\XoopsModule $module = null, $requiredVer = } $success = true; - if ($module->versionCompare($currentVer, $requiredVer, '<')) { + if ($module->versionCompare($currentVer, $requiredVer)) { $success = false; $module->setErrors(\sprintf(\constant('CO_' . $moduleDirNameUpper . '_ERROR_BAD_XOOPS'), $requiredVer, $currentVer)); } diff --git a/class/Devtools.php b/class/Devtools.php index d9b19930..6481db7c 100644 --- a/class/Devtools.php +++ b/class/Devtools.php @@ -436,9 +436,10 @@ public static function function_tabreplacer($src_path, $dst_path): void * @param $dst_path * @param array $patKeys * @param array $patValues - * @param bool $replaceTabs + * @param bool $replaceTabs + * @param string[] $extensions */ - public static function cloneFileFolder($src_path, $dst_path, $patKeys = [], $patValues = [], $replaceTabs = false, $extensions = ['php']): void + public static function cloneFileFolder($src_path, $dst_path, array $patKeys = [], array $patValues = [], bool $replaceTabs = false, $extensions = ['php']): void { // open the source directory $dir = \opendir($src_path); @@ -463,9 +464,10 @@ public static function cloneFileFolder($src_path, $dst_path, $patKeys = [], $pat * @param $dst_file * @param array $patKeys * @param array $patValues - * @param bool $replaceTabs + * @param bool $replaceTabs + * @param $extensions */ - private static function cloneFile($src_file, $dst_file, $patKeys, $patValues, $replaceTabs, $extensions): void + private static function cloneFile($src_file, $dst_file, array $patKeys, array $patValues, bool $replaceTabs, $extensions): void { $replace_code = false; if (\in_array(\mb_strtolower(\pathinfo($src_file, PATHINFO_EXTENSION)), $extensions)) { @@ -499,7 +501,7 @@ private static function cloneFile($src_file, $dst_file, $patKeys, $patValues, $r * @param bool $action * @return \XoopsSimpleForm */ - public static function getFormModulesFq($action = false) + public static function getFormModulesFq(bool $action = false) { if (!$action) { $action = $_SERVER['REQUEST_URI']; @@ -528,7 +530,7 @@ public static function getFormModulesFq($action = false) * @param bool $action * @return \XoopsSimpleForm */ - public static function getFormModulesCl($action = false) + public static function getFormModulesCl(bool $action = false) { if (!$action) { $action = $_SERVER['REQUEST_URI']; @@ -557,7 +559,7 @@ public static function getFormModulesCl($action = false) * @param bool $action * @return \XoopsSimpleForm */ - public static function getFormModulesTab($action = false) + public static function getFormModulesTab(bool $action = false) { if (!$action) { $action = $_SERVER['REQUEST_URI']; @@ -586,7 +588,7 @@ public static function getFormModulesTab($action = false) * @param bool $action * @return \XoopsSimpleForm */ - public static function getFormModulesRemovePrefix($dst_path, $action = false) + public static function getFormModulesRemovePrefix($dst_path, bool $action = false) { if (!$action) { $action = $_SERVER['REQUEST_URI']; diff --git a/class/Fieldattributes.php b/class/Fieldattributes.php index 23723c3e..0b292d5c 100644 --- a/class/Fieldattributes.php +++ b/class/Fieldattributes.php @@ -36,7 +36,6 @@ class Fieldattributes extends \XoopsObject { /** * @public function constructor class - * @param null */ public function __construct() { @@ -47,7 +46,7 @@ public function __construct() /** * @static function getInstance - * @param null + * * @return Fieldattributes */ public static function getInstance() diff --git a/class/Fieldelements.php b/class/Fieldelements.php index 35273654..4dec54eb 100644 --- a/class/Fieldelements.php +++ b/class/Fieldelements.php @@ -31,7 +31,6 @@ class Fieldelements extends \XoopsObject { /** * @public function constructor class - * @param null */ public function __construct() { @@ -48,11 +47,11 @@ public function __construct() /** * @param string $method - * @param array $args + * @param array $args * * @return mixed */ - public function __call($method, $args) + public function __call(string $method, array $args) { $arg = $args[0] ?? null; @@ -61,7 +60,7 @@ public function __call($method, $args) /** * @static function getInstance - * @param null + * * @return Fieldelements */ public static function getInstance() diff --git a/class/FieldelementsHandler.php b/class/FieldelementsHandler.php index 6426927a..503491ef 100644 --- a/class/FieldelementsHandler.php +++ b/class/FieldelementsHandler.php @@ -40,13 +40,13 @@ public function __construct(\XoopsDatabase $db) /** * Get Count Fields. - * @param int $start - * @param int $limit + * @param int $start + * @param int $limit * @param string $sort * @param string $order * @return int */ - public function getCountFieldelements($start = 0, $limit = 0, $sort = 'fieldelement_id ASC, fieldelement_name', $order = 'ASC') + public function getCountFieldelements(int $start = 0, int $limit = 0, string $sort = 'fieldelement_id ASC, fieldelement_name', string $order = 'ASC') { $crCountFieldElems = new \CriteriaCompo(); $crCountFieldElems = $this->getFieldelementsCriteria($crCountFieldElems, $start, $limit, $sort, $order); @@ -56,13 +56,13 @@ public function getCountFieldelements($start = 0, $limit = 0, $sort = 'fieldelem /** * Get Objects Fields. - * @param int $start - * @param int $limit + * @param int $start + * @param int $limit * @param string $sort * @param string $order * @return array */ - public function getObjectsFieldelements($start = 0, $limit = 0, $sort = 'fieldelement_id ASC, fieldelement_name', $order = 'ASC') + public function getObjectsFieldelements(int $start = 0, int $limit = 0, string $sort = 'fieldelement_id ASC, fieldelement_name', string $order = 'ASC') { $crObjectsFieldElems = new \CriteriaCompo(); $crObjectsFieldElems = $this->getFieldelementsCriteria($crObjectsFieldElems, $start, $limit, $sort, $order); @@ -72,13 +72,13 @@ public function getObjectsFieldelements($start = 0, $limit = 0, $sort = 'fieldel /** * Get All Fields. - * @param int $start - * @param int $limit + * @param int $start + * @param int $limit * @param string $sort * @param string $order * @return array */ - public function getAllFieldelements($start = 0, $limit = 0, $sort = 'fieldelement_id ASC, fieldelement_name', $order = 'ASC') + public function getAllFieldelements(int $start = 0, int $limit = 0, string $sort = 'fieldelement_id ASC, fieldelement_name', string $order = 'ASC') { $crAllFieldElems = new \CriteriaCompo(); $crAllFieldElems = $this->getFieldelementsCriteria($crAllFieldElems, $start, $limit, $sort, $order); @@ -89,13 +89,13 @@ public function getAllFieldelements($start = 0, $limit = 0, $sort = 'fieldelemen /** * Get All Fields By Module & Table Id. * @param $tabId - * @param int $start - * @param int $limit + * @param int $start + * @param int $limit * @param string $sort * @param string $order * @return array */ - public function getAllFieldelementsByTableId($tabId, $start = 0, $limit = 0, $sort = 'fieldelement_id ASC, fieldelement_name', $order = 'ASC') + public function getAllFieldelementsByTableId($tabId, int $start = 0, int $limit = 0, string $sort = 'fieldelement_id ASC, fieldelement_name', string $order = 'ASC') { $crAllFieldElemsByModule = new \CriteriaCompo(); $crAllFieldElemsByModule->add(new \Criteria('fieldelement_tid', $tabId)); @@ -126,13 +126,13 @@ private function getFieldelementsCriteria($crFieldElemsCriteria, $start, $limit, /** * Get Fieldelements Criteria. * @param $crFieldElemsCriteria - * @param $start - * @param $limit - * @param $sort - * @param $order - * @return mixed + * @param int $start + * @param int $limit + * @param string $sort + * @param string $order + * @return array */ - public function getFieldelementsList($crFieldElemsCriteria, $start = 0, $limit = 0, $sort = 'fieldelement_sort', $order = 'ASC') + public function getFieldelementsList($crFieldElemsCriteria, int $start = 0, int $limit = 0, string $sort = 'fieldelement_sort', string $order = 'ASC') { $crFieldElems = $this->getFieldelementsCriteria($crFieldElemsCriteria, $start, $limit, $sort, $order); $fieldeleArr = $this->getAll($crFieldElems); diff --git a/class/Fieldkey.php b/class/Fieldkey.php index 8bdc1622..b9556d7f 100644 --- a/class/Fieldkey.php +++ b/class/Fieldkey.php @@ -31,7 +31,6 @@ class Fieldkey extends \XoopsObject { /** * @public function constructor class - * @param null */ public function __construct() { @@ -42,7 +41,7 @@ public function __construct() /** * @static function getInstance - * @param null + * * @return Fieldkey */ public static function getInstance() diff --git a/class/Fieldnull.php b/class/Fieldnull.php index 2b368711..6bb16940 100644 --- a/class/Fieldnull.php +++ b/class/Fieldnull.php @@ -31,7 +31,6 @@ class Fieldnull extends \XoopsObject { /** * @public function constructor class - * @param null */ public function __construct() { @@ -42,7 +41,7 @@ public function __construct() /** * @static function getInstance - * @param null + * * @return Fieldnull */ public static function getInstance() diff --git a/class/Fields.php b/class/Fields.php index 8d30ae19..c857279c 100644 --- a/class/Fields.php +++ b/class/Fields.php @@ -32,8 +32,6 @@ class Fields extends \XoopsObject { /** * @public function constructor class - * - * @param null */ public function __construct() { @@ -68,11 +66,11 @@ public function __construct() /** * @param string $method - * @param array $args + * @param array $args * * @return mixed */ - public function __call($method, $args) + public function __call(string $method, array $args) { $arg = $args[0] ?? null; @@ -101,14 +99,14 @@ public static function getInstance() * @param $prefix * @return Modulebuilder\Form\ThemeForm */ - private function getHeaderForm($prefix, $action = false) + private function getHeaderForm($prefix, bool $action = false) { if (false === $action) { $action = \Xmf\Request::getString('REQUEST_URI', '', 'SERVER'); } $isNew = $this->isNew(); - $title = $isNew ? \sprintf(\_AM_MODULEBUILDER_FIELDS_NEW) : \sprintf(\_AM_MODULEBUILDER_FIELDS_EDIT); + $title = $isNew ? \_AM_MODULEBUILDER_FIELDS_NEW : \_AM_MODULEBUILDER_FIELDS_EDIT; $form = new Modulebuilder\Form\ThemeForm(null, 'form', $action, 'post', true); $form->setExtra('enctype="multipart/form-data"'); @@ -145,7 +143,7 @@ private function getHeaderForm($prefix, $action = false) * @param bool $action * @return mixed */ - public function getFormNew($fieldMid = null, $fieldTid = null, $fieldNumb = null, $fieldName = null, $action = false) + public function getFormNew($fieldMid = null, $fieldTid = null, $fieldNumb = null, $fieldName = null, bool $action = false) { $helper = Modulebuilder\Helper::getInstance(); // Get handler tables @@ -338,7 +336,7 @@ private function getFormNewLine($form, $class, $i, $fieldMid, $fieldTid, $fName, * @param bool $action * @return mixed */ - public function getFormEdit($fieldMid = null, $fieldTid = null, $action = false) + public function getFormEdit($fieldMid = null, $fieldTid = null, bool $action = false) { $helper = Modulebuilder\Helper::getInstance(); $tablesHandler = $helper->getHandler('Tables'); diff --git a/class/FieldsHandler.php b/class/FieldsHandler.php index 2f1baaaf..96074e00 100644 --- a/class/FieldsHandler.php +++ b/class/FieldsHandler.php @@ -51,22 +51,20 @@ public function create($isNew = true) /** * retrieve a field. * - * @param int $i field id + * @param int $id field id * @param null $fields * - * @return mixed reference to the Fields object + * @return \XoopsObject|null reference to the Fields object * object */ - public function get($i = null, $fields = null) + public function get($id = null, $fields = null) { - return parent::get($i, $fields); + return parent::get($id, $fields); } /** * get inserted id. * - * @param null - * * @return int reference to the {@link Fields} object */ public function getInsertId() @@ -76,13 +74,13 @@ public function getInsertId() /** * Get Count Fields. - * @param int $start - * @param int $limit + * @param int $start + * @param int $limit * @param string $sort * @param string $order * @return int */ - public function getCountFields($start = 0, $limit = 0, $sort = 'field_id ASC, field_name', $order = 'ASC') + public function getCountFields(int $start = 0, int $limit = 0, string $sort = 'field_id ASC, field_name', string $order = 'ASC') { $crCountFields = new \CriteriaCompo(); $crCountFields = $this->getFieldsCriteria($crCountFields, $start, $limit, $sort, $order); @@ -92,13 +90,13 @@ public function getCountFields($start = 0, $limit = 0, $sort = 'field_id ASC, fi /** * Get All Fields. - * @param int $start - * @param int $limit + * @param int $start + * @param int $limit * @param string $sort * @param string $order * @return array */ - public function getAllFields($start = 0, $limit = 0, $sort = 'field_id ASC, field_name', $order = 'ASC') + public function getAllFields(int $start = 0, int $limit = 0, string $sort = 'field_id ASC, field_name', string $order = 'ASC') { $crAllFields = new \CriteriaCompo(); $crAllFields = $this->getFieldsCriteria($crAllFields, $start, $limit, $sort, $order); @@ -109,13 +107,13 @@ public function getAllFields($start = 0, $limit = 0, $sort = 'field_id ASC, fiel /** * Get All Fields By Module & Table Id. * @param $tabId - * @param int $start - * @param int $limit + * @param int $start + * @param int $limit * @param string $sort * @param string $order * @return array */ - public function getAllFieldsByTableId($tabId, $start = 0, $limit = 0, $sort = 'field_order ASC, field_id, field_name', $order = 'ASC') + public function getAllFieldsByTableId($tabId, int $start = 0, int $limit = 0, string $sort = 'field_order ASC, field_id, field_name', string $order = 'ASC') { $crAllFieldsByModule = new \CriteriaCompo(); $crAllFieldsByModule->add(new \Criteria('field_tid', $tabId)); diff --git a/class/Fieldtype.php b/class/Fieldtype.php index 673ef289..1b3d32dc 100644 --- a/class/Fieldtype.php +++ b/class/Fieldtype.php @@ -31,7 +31,6 @@ class Fieldtype extends \XoopsObject { /** * @public function constructor class - * @param null */ public function __construct() { @@ -42,7 +41,7 @@ public function __construct() /** * @static function getInstance - * @param null + * * @return Fieldtype */ public static function getInstance() diff --git a/class/Files/Admin/AdminBroken.php b/class/Files/Admin/AdminBroken.php index e0dd7a6c..5f7755ed 100644 --- a/class/Files/Admin/AdminBroken.php +++ b/class/Files/Admin/AdminBroken.php @@ -46,7 +46,6 @@ class AdminBroken extends Files\CreateFile /** * @public function constructor - * @param null */ public function __construct() { @@ -58,7 +57,7 @@ public function __construct() /** * @static function getInstance - * @param null + * * @return AdminBroken */ @@ -88,22 +87,21 @@ public function write($module, $tables, $filename) /** * @private function getAdminBrokenHeader * @param $moduleDirname - * @param $tableName - * @param string $t * @return string */ - private function getAdminBrokenHeader($moduleDirname, $tableName, $t = '') + private function getAdminBrokenHeader($moduleDirname) { + $tableName = 'broken'; $ret = $this->pc->getPhpCodeUseNamespace(['Xmf', 'Request'], '', ''); $ret .= $this->pc->getPhpCodeUseNamespace(['XoopsModules', $moduleDirname], '', ''); $ret .= $this->pc->getPhpCodeUseNamespace(['XoopsModules', $moduleDirname, 'Constants']); $ret .= $this->getRequire(); $ret .= $this->pc->getPhpCodeBlankLine(); - $ret .= $this->pc->getPhpCodeCommentLine('Define Stylesheet', '', $t); - $ret .= $this->xc->getXcXoThemeAddStylesheet('style', $t); - $ret .= $this->axc->getAdminTemplateMain($moduleDirname, $tableName, $t); + $ret .= $this->pc->getPhpCodeCommentLine('Define Stylesheet', ''); + $ret .= $this->xc->getXcXoThemeAddStylesheet(); + $ret .= $this->axc->getAdminTemplateMain($moduleDirname, $tableName); $navigation = $this->axc->getAdminDisplayNavigation($tableName); - $ret .= $this->xc->getXcXoopsTplAssign('navigation', $navigation, true, $t); + $ret .= $this->xc->getXcXoopsTplAssign('navigation', $navigation); return $ret; } @@ -111,11 +109,10 @@ private function getAdminBrokenHeader($moduleDirname, $tableName, $t = '') /** * @private function getAdminBrokenList * @param $tables - * @param $language - * @param string $t + * @param string $language * @return string */ - private function getAdminBrokenList($tables, $language, $t = '') + private function getAdminBrokenList($tables, string $language) { $ret = ''; foreach (\array_keys($tables) as $i) { @@ -124,10 +121,10 @@ private function getAdminBrokenList($tables, $language, $t = '') $tableSoleName = $tables[$i]->getVar('table_solename'); $ucfTableName = \ucfirst($tableName); $ret .= $this->pc->getPhpCodeBlankLine(); - $ret .= $this->pc->getPhpCodeCommentLine('Check table', $tableName, $t); - $ret .= $this->xc->getXcXoopsRequest('start', 'start' . $ucfTableName, '', 'Int', false, $t); + $ret .= $this->pc->getPhpCodeCommentLine('Check table', $tableName, ''); + $ret .= $this->xc->getXcXoopsRequest('start', 'start' . $ucfTableName, '', 'Int', false, ''); $adminpager = $this->xc->getXcGetConfig('adminpager'); - $ret .= $this->xc->getXcXoopsRequest('limit', 'limit' . $ucfTableName, $adminpager, 'Int', false, $t); + $ret .= $this->xc->getXcXoopsRequest('limit', 'limit' . $ucfTableName, $adminpager, 'Int', false, ''); $critName = 'cr' . $ucfTableName; $fields = $this->getTableFields($tables[$i]->getVar('table_mid'), $tables[$i]->getVar('table_id')); @@ -147,30 +144,30 @@ private function getAdminBrokenList($tables, $language, $t = '') } } - $ret .= $this->xc->getXcCriteriaCompo($critName, $t); + $ret .= $this->xc->getXcCriteriaCompo($critName, ''); $constant = $this->xc->getXcGetConstants('STATUS_BROKEN'); - $crit = $this->xc->getXcCriteria('', "'{$fieldSatus}'", $constant, '', true); - $ret .= $this->xc->getXcCriteriaAdd($critName, $crit, $t); - $ret .= $this->xc->getXcHandlerCountClear($tableName . 'Count', $tableName, '$' . $critName, $t); - $ret .= $this->xc->getXcXoopsTplAssign($tableName . '_count', "\${$tableName}Count", true, $t); + $crit = $this->xc->getXcCriteria('', "'$fieldSatus'", $constant, '', true); + $ret .= $this->xc->getXcCriteriaAdd($critName, $crit, ''); + $ret .= $this->xc->getXcHandlerCountClear($tableName . 'Count', $tableName, '$' . $critName, ''); + $ret .= $this->xc->getXcXoopsTplAssign($tableName . '_count', "\${$tableName}Count", true, ''); $sprintf = $this->pc->getPhpCodeSprintf($language . 'BROKEN_RESULT', "'{$ucfTableName}'"); - $ret .= $this->xc->getXcXoopsTplAssign($tableName . '_result', $sprintf, true, $t); - - $ret .= $this->xc->getXcCriteriaSetStart($critName, '$start', $t); - $ret .= $this->xc->getXcCriteriaSetLimit($critName, '$limit', $t); - $contIf = $this->xc->getXcHandlerAllClear("{$tableName}All", $tableName, "\${$critName}", $t . "\t"); - $foreach = $this->xc->getXcEqualsOperator("\${$tableSoleName}['table']", "'{$ucfTableName}'", '', $t . "\t\t"); - $foreach .= $this->xc->getXcEqualsOperator("\${$tableSoleName}['key']", "'{$fieldId}'", '', $t . "\t\t"); - $foreach .= $this->xc->getXcGetVar("{$tableSoleName}['keyval']", "{$tableName}All[\$i]", "{$fieldId}", false, $t . "\t\t"); - $foreach .= $this->xc->getXcGetVar("{$tableSoleName}['main']", "{$tableName}All[\$i]", "{$fieldMain}", false, $t . "\t\t"); - $foreach .= $this->xc->getXcXoopsTplAppend("{$tableName}_list", "\${$tableSoleName}", $t . "\t\t"); - $contIf .= $this->pc->getPhpCodeForeach("{$tableName}All", true, false, 'i', $foreach, $t . "\t"); - $contIf .= $this->xc->getXcPageNav($tableName, $t . "\t", 'start' . $ucfTableName, "'op=list&limit{$ucfTableName}=' . \$limit"); + $ret .= $this->xc->getXcXoopsTplAssign($tableName . '_result', $sprintf, true, ''); + + $ret .= $this->xc->getXcCriteriaSetStart($critName, '$start', ''); + $ret .= $this->xc->getXcCriteriaSetLimit($critName, '$limit', ''); + $contIf = $this->xc->getXcHandlerAllClear("{$tableName}All", $tableName, "\${$critName}", '' . "\t"); + $foreach = $this->xc->getXcEqualsOperator("\${$tableSoleName}['table']", "'{$ucfTableName}'", '', '' . "\t\t"); + $foreach .= $this->xc->getXcEqualsOperator("\${$tableSoleName}['key']", "'{$fieldId}'", '', '' . "\t\t"); + $foreach .= $this->xc->getXcGetVar("{$tableSoleName}['keyval']", "{$tableName}All[\$i]", "{$fieldId}", false, '' . "\t\t"); + $foreach .= $this->xc->getXcGetVar("{$tableSoleName}['main']", "{$tableName}All[\$i]", "{$fieldMain}", false, '' . "\t\t"); + $foreach .= $this->xc->getXcXoopsTplAppend("{$tableName}_list", "\${$tableSoleName}", '' . "\t\t"); + $contIf .= $this->pc->getPhpCodeForeach("{$tableName}All", true, false, 'i', $foreach, '' . "\t"); + $contIf .= $this->xc->getXcPageNav($tableName, '' . "\t", 'start' . $ucfTableName, "'op=list&limit{$ucfTableName}=' . \$limit", 'pagenav_' . $tableName); $sprintf = $this->pc->getPhpCodeSprintf($language . 'BROKEN_NODATA', "'{$ucfTableName}'"); - $contElse = $this->xc->getXcXoopsTplAssign('nodata' . $ucfTableName, $sprintf, true, $t . "\t"); + $contElse = $this->xc->getXcXoopsTplAssign('nodata' . $ucfTableName, $sprintf, true, '' . "\t"); - $ret .= $this->pc->getPhpCodeConditions("\${$tableName}Count", ' > ', '0', $contIf, $contElse, $t); - $ret .= $this->pc->getPhpCodeUnset($critName, $t); + $ret .= $this->pc->getPhpCodeConditions("\${$tableName}Count", ' > ', '0', $contIf, $contElse, ''); + $ret .= $this->pc->getPhpCodeUnset($critName, ''); } } @@ -181,9 +178,9 @@ private function getAdminBrokenList($tables, $language, $t = '') /** * @public function render - * @param null + * - * @return bool|string + * @return string */ public function render() { @@ -196,7 +193,7 @@ public function render() $language = $this->getLanguage($moduleDirname, 'AM'); $content = $this->getHeaderFilesComments($module); - $content .= $this->getAdminBrokenHeader($moduleDirname, 'broken'); + $content .= $this->getAdminBrokenHeader($moduleDirname); $content .= $this->getAdminBrokenList($tables, $language); $content .= $this->getRequire('footer'); diff --git a/class/Files/Admin/AdminHeader.php b/class/Files/Admin/AdminHeader.php index ca6628db..4d2a438a 100644 --- a/class/Files/Admin/AdminHeader.php +++ b/class/Files/Admin/AdminHeader.php @@ -42,7 +42,6 @@ class AdminHeader extends Files\CreateFile /** * @public function constructor - * @param null */ public function __construct() { @@ -53,7 +52,7 @@ public function __construct() /** * @static function getInstance - * @param null + * @return AdminHeader */ public static function getInstance() @@ -68,12 +67,12 @@ public static function getInstance() /** * @public function write - * @param string $module + * @param $module * @param mixed $table - * @param array $tables + * @param array $tables * @param string $filename */ - public function write($module, $table, $tables, $filename): void + public function write($module, $table, array $tables, string $filename): void { $this->setModule($module); $this->setTable($table); @@ -121,7 +120,7 @@ private function getAdminHeader($moduleDirname) $ret .= $this->pc->getPhpCodeCommentLine(); $template = $this->pc->getPhpCodeIncludeDir('\XOOPS_ROOT_PATH', 'class/template', true, false, 'require', "\t"); $template .= $this->xc->getXcEqualsOperator('$xoopsTpl', 'new \XoopsTpl()', null, "\t"); - $ret .= $this->pc->getPhpCodeConditions('!isset($xoopsTpl)', ' || ', '!\is_object($xoopsTpl)', $template, false); + $ret .= $this->pc->getPhpCodeConditions('!isset($xoopsTpl)', ' || ', '!\is_object($xoopsTpl)', $template); $ret .= $this->pc->getPhpCodeBlankLine(); $ret .= $this->pc->getPhpCodeCommentLine('Load languages'); $ret .= $this->xc->getXcXoopsLoadLanguage('admin', '', $moduleDirname); @@ -145,14 +144,15 @@ private function getAdminHeader($moduleDirname) $ret .= $this->pc->getPhpCodeBlankLine(); $ret .= $this->xc->getXcEqualsOperator('$adminObject', '\Xmf\Module\Admin::getInstance()'); $ret .= $this->getSimpleString("\$style = \\{$stuModuleDirname}_URL . '/assets/css/admin/style.css';"); + $ret .= $this->xc->getXcXoThemeAddStylesheet(); return $ret; } /** * @public function render - * @param null - * @return bool|string + + * @return string */ public function render() { diff --git a/class/Files/Admin/AdminIndex.php b/class/Files/Admin/AdminIndex.php index b5e8b1a4..f2d8eeab 100644 --- a/class/Files/Admin/AdminIndex.php +++ b/class/Files/Admin/AdminIndex.php @@ -46,7 +46,6 @@ class AdminIndex extends Files\CreateFile /** * @public function constructor - * @param null */ public function __construct() { @@ -58,7 +57,7 @@ public function __construct() /** * @static function getInstance - * @param null + * @return AdminIndex */ public static function getInstance() @@ -73,11 +72,11 @@ public static function getInstance() /** * @public function write - * @param string $module + * @param $module * @param mixed $tables * @param string $filename */ - public function write($module, $tables, $filename) + public function write($module, $tables, string $filename) { $this->setModule($module); $this->setTables($tables); @@ -131,30 +130,35 @@ private function getAdminIndex($module) if (\is_array($tables) && \in_array(1, $tableInstall)) { $ret .= $this->pc->getPhpCodeBlankLine(); $ret .= $this->pc->getPhpCodeCommentLine('Upload Folders'); + $ret .= $this->pc->getPhpCodeArray('folder',null,false,''); $ret .= $this->xc->getXcEqualsOperator('$configurator', 'new Common\Configurator()'); $cond = '$configurator->uploadFolders && \is_array($configurator->uploadFolders)'; $fe_action = $this->xc->getXcEqualsOperator('$folder[]', '$configurator->uploadFolders[$i]', '',"\t\t"); $condIf = $this->pc->getPhpCodeForeach('configurator->uploadFolders', true, false, 'i', $fe_action, "\t"); - $ret .= $this->pc->getPhpCodeConditions($cond, '', '', $condIf, false); + $ret .= $this->pc->getPhpCodeConditions($cond, '', '', $condIf); $ret .= $this->pc->getPhpCodeCommentLine('Uploads Folders Created'); - $boxLine = $this->axc->getAxcAddConfigBoxLine('$folder[$i]', 'folder', '', "\t"); - $boxLine .= $this->axc->getAxcAddConfigBoxLine("[\$folder[\$i], '777']", 'chmod', '', "\t"); - $ret .= $this->pc->getPhpCodeForeach('folder', true, false, 'i', $boxLine) . PHP_EOL; + $boxLine = $this->axc->getAxcAddConfigBoxLine('$folder[$i]', 'folder', '', "\t\t"); + $boxLine .= $this->axc->getAxcAddConfigBoxLine("[\$folder[\$i], '777']", 'chmod', '', "\t\t"); + $cond = '$folder'; + $condIf = $this->pc->getPhpCodeForeach('folder', true, false, 'i', $boxLine, "\t"); + $ret .= $this->pc->getPhpCodeConditions($cond, '', '', $condIf); + $ret .= $this->pc->getPhpCodeBlankLine(); } + $ret .= $this->pc->getPhpCodeCommentLine('Render Index'); $ret .= $this->xc->getXcXoopsTplAssign('navigation', "\$adminObject->displayNavigation('index.php')"); - $ret .= $this->pc->getPhpCodeCommentLine('Test Data'); $condIf = $this->xc->getXcXoopsLoadLanguage('admin/modulesadmin',"\t", 'system'); - $condIf .= $this->pc->getPhpCodeIncludeDir('\dirname(__DIR__)', 'testdata/index', true, '','',"\t"); - $condIf .= $this->axc->getAdminItemButton("\constant('CO_' . \$moduleDirNameUpper . '_ADD_SAMPLEDATA')", '', '', $op = '__DIR__ . /../../testdata/index.php?op=load', $type = 'samplebutton', $t = "\t"); - $condIf .= $this->axc->getAdminItemButton("\constant('CO_' . \$moduleDirNameUpper . '_SAVE_SAMPLEDATA')", '', '', $op = '__DIR__ . /../../testdata/index.php?op=save', $type = 'samplebutton', $t = "\t"); - $condIf .= '//' . $this->axc->getAdminItemButton("\constant('CO_' . \$moduleDirNameUpper . '_EXPORT_SCHEMA')", '', '', $op = '__DIR__ . /../../testdata/index.php?op=exportschema', $type = 'samplebutton', $t = "\t"); + $condIf .= $this->pc->getPhpCodeIncludeDir('\dirname(__DIR__)', 'testdata/index', true, false,'',"\t"); + $condIf .= $this->axc->getAdminItemButton("\constant('CO_' . \$moduleDirNameUpper . '_ADD_SAMPLEDATA')", '', '', '../testdata/index.php?op=load', 'samplebutton', "\t"); + $condIf .= $this->axc->getAdminItemButton("\constant('CO_' . \$moduleDirNameUpper . '_SAVE_SAMPLEDATA')", '', '', '../testdata/index.php?op=save', 'samplebutton', "\t"); + $condIf .= '//' . $this->axc->getAdminItemButton("\constant('CO_' . \$moduleDirNameUpper . '_EXPORT_SCHEMA')", '', '', '../testdata/index.php?op=exportschema', 'samplebutton', "\t"); $condIf .= $this->axc->getAdminDisplayButton('left', "\t"); $cond = $this->xc->getXcGetConfig('displaySampleButton'); - $ret .= $this->pc->getPhpCodeConditions($cond, '', '', $condIf, false); + $ret .= $this->pc->getPhpCodeConditions($cond, '', '', $condIf); $ret .= $this->xc->getXcXoopsTplAssign('index', '$adminObject->displayIndex()'); - $ret .= $this->pc->getPhpCodeCommentLine('End Test Data'); + + $ret .= $this->pc->getPhpCodeBlankLine(); $ret .= $this->getRequire('footer'); @@ -163,8 +167,8 @@ private function getAdminIndex($module) /** * @public function render - * @param null - * @return bool|string + + * @return string */ public function render() { diff --git a/class/Files/Admin/AdminMenu.php b/class/Files/Admin/AdminMenu.php index 99908120..57ca4d9d 100644 --- a/class/Files/Admin/AdminMenu.php +++ b/class/Files/Admin/AdminMenu.php @@ -38,7 +38,6 @@ class AdminMenu extends Files\CreateFile /** * @public function constructor - * @param null */ public function __construct() { @@ -48,7 +47,7 @@ public function __construct() /** * @static function getInstance - * @param null + * @return AdminMenu */ public static function getInstance() @@ -63,10 +62,10 @@ public static function getInstance() /** * @public function write - * @param string $module + * @param $module * @param string $filename */ - public function write($module, $filename): void + public function write($module, string $filename): void { $this->setModule($module); $this->setFileName($filename); @@ -75,10 +74,10 @@ public function write($module, $filename): void /** * @private function getAdminMenuArray * @param array $param - * @param bool $adminObject + * @param bool $adminObject * @return string */ - private function getAdminMenuArray($param = [], $adminObject = false) + private function getAdminMenuArray(array $param = [], bool $adminObject = false) { $ret = ''; if ($adminObject) { @@ -98,7 +97,7 @@ private function getAdminMenuArray($param = [], $adminObject = false) /** * @private function getAdminMenuHeader - * @param null + * @return string */ private function getAdminMenuHeader() @@ -120,28 +119,26 @@ private function getAdminMenuHeader() /** * @private function getAdminMenuDashboard * @param string $language - * @param int $menu + * @param int $menu * * @return string */ - private function getAdminMenuDashboard($language, $menu) + private function getAdminMenuDashboard(string $language, int $menu) { $param = ['title' => "{$language}{$menu}", 'link' => "'admin/index.php'", 'icon' => "\$sysPathIcon32.'/dashboard.png'"]; - $ret = $this->getAdminMenuArray($param, true); - - return $ret; + return $this->getAdminMenuArray($param, true); } /** * @private function getAdminMenuList - * @param string $module + * @param $module * @param string $language * @param string $langAbout - * @param int $menu + * @param int $menu * * @return string */ - private function getAdminMenuList($module, $language, $langAbout, $menu) + private function getAdminMenuList($module, string $language, string $langAbout, int $menu) { $ret = ''; $tables = $this->getTableTables($module->getVar('mod_id'), 'table_order'); @@ -181,8 +178,8 @@ private function getAdminMenuList($module, $language, $langAbout, $menu) /** * @public function render - * @param null - * @return bool|string + + * @return string */ public function render() { diff --git a/class/Files/Admin/AdminPermissions.php b/class/Files/Admin/AdminPermissions.php index 43d70667..18cf7d81 100644 --- a/class/Files/Admin/AdminPermissions.php +++ b/class/Files/Admin/AdminPermissions.php @@ -50,7 +50,6 @@ class AdminPermissions extends Files\CreateFile /** * @public function constructor - * @param null */ public function __construct() { @@ -64,7 +63,7 @@ public function __construct() /** * @static function getInstance * - * @param null + * * @return AdminPermissions */ @@ -81,13 +80,13 @@ public static function getInstance() /** * @public function write * - * @param string $module + * @param $module * @param mixed $tables * @param string $filename * * @return null */ - public function write($module, $tables, $filename) + public function write($module, $tables, string $filename) { $this->setModule($module); $this->setTables($tables); @@ -191,12 +190,12 @@ private function getPermissionsSwitch($module, $language) /** * @private function getPermissionsBody * - * @param string $module + * @param $module * @param string $language * * @return string */ - private function getPermissionsBody($module, $language) + private function getPermissionsBody($module, string $language) { $tables = $this->getTableTables($module->getVar('mod_id')); @@ -207,7 +206,7 @@ private function getPermissionsBody($module, $language) $if1 = $this->pc->getPhpCodeForeach('globalPerms', false, 'gPermId', 'gPermName', $foreach1, "\t"); $if1 .= $this->xc->getXcXoopsTplAssign('form', '$permform->render()', true, "\t"); $if1 .= $this->xc->getXcEqualsOperator('$permFound', 'true', null, "\t"); - $ret .= $this->pc->getPhpCodeConditions("'global'", ' === ', '$op', $if1, false); + $ret .= $this->pc->getPhpCodeConditions("'global'", ' === ', '$op', $if1); foreach (\array_keys($tables) as $t) { if (1 == $tables[$t]->getVar('table_permissions')) { @@ -215,18 +214,9 @@ private function getPermissionsBody($module, $language) $tableMid = $tables[$t]->getVar('table_mid'); $tableName = $tables[$t]->getVar('table_name'); $fields = $this->getTableFields($tableMid, $tableId); - $fieldId = 'id'; - $fieldMain = 'title'; - foreach (\array_keys($fields) as $f) { - $fieldName = $fields[$f]->getVar('field_name'); - if (0 == $f) { - $fieldId = $fieldName; - } - if (1 == $fields[$f]->getVar('field_main')) { - $fieldMain = $fieldName; - } - } - $if_count = $this->xc->getXcHandlerAllObj($tableName, $fieldMain, 0, 0, "\t\t"); + $fieldId = $this->xc->getXcTableFieldId($fields); + $fieldMain = $this->xc->getXcTableFieldMain($fields); + $if_count = $this->xc->getXcHandlerAllObj($tableName, $fieldMain, '0', '0', "\t\t"); $getVar1 = $this->xc->getXcGetVar('', "{$tableName}All[\$i]", $fieldId, true); $getVar2 = $this->xc->getXcGetVar('', "{$tableName}All[\$i]", $fieldMain, true); $fe_content = $this->xc->getXcAddItem('permform', $getVar1, $getVar2, "\t\t\t"); @@ -236,14 +226,14 @@ private function getPermissionsBody($module, $language) $if_table .= $this->pc->getPhpCodeConditions("\${$tableName}Count", ' > ', '0', $if_count, false, "\t"); $if_table .= $this->xc->getXcEqualsOperator('$permFound', 'true', null, "\t"); $cond = "'approve_{$tableName}' === \$op || 'submit_{$tableName}' === \$op || 'view_{$tableName}' === \$op"; - $ret .= $this->pc->getPhpCodeConditions($cond, '', '', $if_table, false); + $ret .= $this->pc->getPhpCodeConditions($cond, '', '', $if_table); } } $ret .= $this->pc->getPhpCodeUnset('permform'); $elseInter = $this->xc->getXcRedirectHeader("'permissions.php'", '', '3', "{$language}NO_PERMISSIONS_SET", false, "\t"); $elseInter .= $this->getSimpleString('exit();', "\t"); - $ret .= $this->pc->getPhpCodeConditions('$permFound', ' !== ', 'true', $elseInter, false); + $ret .= $this->pc->getPhpCodeConditions('$permFound', ' !== ', 'true', $elseInter); return $ret; } @@ -251,9 +241,9 @@ private function getPermissionsBody($module, $language) /** * @public function render * - * @param null + * - * @return bool|string + * @return string */ public function render() { diff --git a/class/Files/Assets/Css/Admin/CssAdminStyles.php b/class/Files/Assets/Css/Admin/CssAdminStyles.php index 73ea5c8f..64e2e5a3 100644 --- a/class/Files/Assets/Css/Admin/CssAdminStyles.php +++ b/class/Files/Assets/Css/Admin/CssAdminStyles.php @@ -32,7 +32,6 @@ class CssAdminStyles extends Files\CreateFile { /** * @public function constructor - * @param null */ public function __construct() { @@ -41,7 +40,7 @@ public function __construct() /** * @static function getInstance - * @param null + * * @return CssAdminStyles */ public static function getInstance() @@ -67,8 +66,8 @@ public function write($module, $filename): void /** * @public function render - * @param null - * @return bool|string + * + * @return string */ public function render() { diff --git a/class/Files/Assets/Css/CssSelectors.php b/class/Files/Assets/Css/CssSelectors.php index b57b1893..4318e8f8 100644 --- a/class/Files/Assets/Css/CssSelectors.php +++ b/class/Files/Assets/Css/CssSelectors.php @@ -30,7 +30,6 @@ class CssSelectors { /** * @static function getInstance - * @param null * * @return CssSelectors */ @@ -52,19 +51,17 @@ public static function getInstance() */ public function geCssComment($comment, $t) { - $ret = ('' != $comment) ? "{$t}/* {$comment} */" : ''; - - return $ret; + return ('' != $comment) ? "{$t}/* {$comment} */" : ''; } /** * @public function geCssSelector - * @param string $selector + * @param mixed $selector * @param mixed $content * @param string $t * @return string */ - public function geCssSelector($selector, $content, $t) + public function geCssSelector($selector, $content, string $t) { $ret = ''; if (\is_array($selector)) { diff --git a/class/Files/Assets/Css/CssStyles.php b/class/Files/Assets/Css/CssStyles.php index d098afcc..ef1ce279 100644 --- a/class/Files/Assets/Css/CssStyles.php +++ b/class/Files/Assets/Css/CssStyles.php @@ -32,7 +32,6 @@ class CssStyles extends Files\CreateFile { /** * @public function constructor - * @param null */ public function __construct() { @@ -41,7 +40,7 @@ public function __construct() /** * @static function getInstance - * @param null + * * @return CssStyles */ public static function getInstance() @@ -67,8 +66,8 @@ public function write($module, $filename): void /** * @public function render - * @param null - * @return bool|string + * + * @return string */ public function render() { diff --git a/class/Files/Assets/Js/JavascriptJQuery.php b/class/Files/Assets/Js/JavascriptJQuery.php index 530722e0..b06d84d6 100644 --- a/class/Files/Assets/Js/JavascriptJQuery.php +++ b/class/Files/Assets/Js/JavascriptJQuery.php @@ -33,7 +33,6 @@ class JavascriptJQuery extends Files\CreateFile { /** * @public function constructor - * @param null */ public function __construct() { @@ -42,7 +41,7 @@ public function __construct() /** * @static function getInstance - * @param null + * * @return JavascriptJQuery */ public static function getInstance() @@ -57,10 +56,10 @@ public static function getInstance() /** * @public function write - * @param string $module + * @param $module * @param string $filename */ - public function write($module, $filename): void + public function write($module, string $filename): void { $this->setModule($module); $this->setFileName($filename); @@ -68,13 +67,12 @@ public function write($module, $filename): void /** * @public function getJavascriptJQueryButtons - * @param null * * @return string */ public function getJavascriptJQueryButtons() { - $ret = << EOT; - - return $ret; } /** * @public function render - * @param null * - * @return bool|string + * @return string */ public function render() { diff --git a/class/Files/Assets/Js/JsJquery.php b/class/Files/Assets/Js/JsJquery.php index 973b7f6f..38d4698b 100644 --- a/class/Files/Assets/Js/JsJquery.php +++ b/class/Files/Assets/Js/JsJquery.php @@ -39,7 +39,6 @@ class JsJquery extends Files\CreateFile /** * @public function constructor - * @param null */ public function __construct() { @@ -49,7 +48,7 @@ public function __construct() /** * @static function getInstance - * @param null + * * @return JsJquery */ public static function getInstance() @@ -64,10 +63,10 @@ public static function getInstance() /** * @public function write - * @param string $module + * @param $module * @param string $filename */ - public function write($module, $filename): void + public function write($module, string $filename): void { $this->setModule($module); $this->setFileName($filename); @@ -75,8 +74,8 @@ public function write($module, $filename): void /** * @public function render - * @param null - * @return bool|string + * + * @return string */ public function render() { diff --git a/class/Files/Blocks/BlocksFiles.php b/class/Files/Blocks/BlocksFiles.php index 0796ded2..382b2e00 100644 --- a/class/Files/Blocks/BlocksFiles.php +++ b/class/Files/Blocks/BlocksFiles.php @@ -45,7 +45,6 @@ class BlocksFiles extends Files\CreateFile /** * @public function constructor - * @param null */ public function __construct() { @@ -56,7 +55,7 @@ public function __construct() /** * @static function getInstance - * @param null + * * @return BlocksFiles */ public static function getInstance() @@ -71,7 +70,7 @@ public static function getInstance() /** * @public function write - * @param string $module + * @param $module * @param mixed $table * @param $filename */ @@ -93,7 +92,7 @@ public function write($module, $table, $filename): void * @param int $fieldParent * @return string */ - private function getBlocksShow($moduleDirname, $tableName, $tableFieldname, $tablePermissions, $fields, $fieldId, $fieldParent = 0) + private function getBlocksShow($moduleDirname, $tableName, $tableFieldname, $tablePermissions, $fields, $fieldId, int $fieldParent = 0) { $ucfTableName = \ucfirst($tableName); $critName = 'cr' . $ucfTableName; @@ -109,16 +108,15 @@ private function getBlocksShow($moduleDirname, $tableName, $tableFieldname, $tab } $ret = $this->pc->getPhpCodeCommentMultiLine(['Function' => 'show block', '@param $options' => '', '@return' => 'array']); - $func = $this->xc->getXcEqualsOperator('$helper ', 'Helper::getInstance()','',"\t"); + $func = $this->xc->getXcEqualsOperator('$helper ', 'Helper::getInstance()','',"\t"); if (1 === $configMaxchar) { - $func .= $this->xc->getXcEqualsOperator('$utility ', "new \XoopsModules\\{$ucfModuleDirname}\Utility()", '',"\t"); - $func .= $this->xc->getXcEqualsOperator('$editorMaxchar', $this->xc->getXcGetConfig('editor_maxchar'), false, "\t"); + $func .= $this->xc->getXcEqualsOperator('$utility ', "new \XoopsModules\\{$ucfModuleDirname}\Utility()", '',"\t"); } //$func .= $this->xc->getXcEqualsOperator('$myts', 'MyTextSanitizer::getInstance()', '',"\t"); - $func .= $this->xc->getXcEqualsOperator('$block ', '[]', '',"\t"); - $func .= $this->xc->getXcEqualsOperator('$typeBlock ', '$options[0]','',"\t"); - $func .= $this->xc->getXcEqualsOperator('$limit ', '$options[1]','',"\t"); - $func .= $this->xc->getXcEqualsOperator('$lenghtTitle ', '$options[2]','',"\t"); + $func .= $this->xc->getXcEqualsOperator('$block ', '[]', '',"\t"); + $func .= $this->xc->getXcEqualsOperator('$typeBlock ', '$options[0]','',"\t"); + $func .= $this->xc->getXcEqualsOperator('$limit ', '$options[1]','',"\t"); + $func .= $this->xc->getXcEqualsOperator('$lenghtTitle', '$options[2]','',"\t"); $func .= $this->pc->getPhpCodeArrayShift('$options', "\t"); $func .= $this->pc->getPhpCodeArrayShift('$options', "\t"); $func .= $this->pc->getPhpCodeArrayShift('$options', "\t"); @@ -159,7 +157,7 @@ private function getBlocksShow($moduleDirname, $tableName, $tableFieldname, $tab } } if ('' !== $fieldStatus) { - $constant = $this->xc->getXcGetConstants('PERM_GLOBAL_VIEW'); + $constant = $this->xc->getXcGetConstants('STATUS_OFFLINE'); $crit = $this->xc->getXcCriteria('', "'{$fieldStatus}'", $constant, "'>'", true); $func .= $this->pc->getPhpCodeCommentLine("Criteria for status field",'',"\t"); $func .= $this->xc->getXcCriteriaAdd($critName, $crit, "\t"); @@ -186,20 +184,19 @@ private function getBlocksShow($moduleDirname, $tableName, $tableFieldname, $tab $crit = $this->xc->getXcCriteria('', "'{$fieldDate}'", '\time()', "'<='", true); $case2[] = $this->xc->getXcCriteriaAdd($critName, $crit,"\t\t\t"); $case2[] = $this->xc->getXcCriteriaSetSort($critName, "'{$fieldDate}'","\t\t\t"); - $case2[] = $this->xc->getXcCriteriaSetOrder($critName, "'ASC'","\t\t\t"); + $case2[] = $this->xc->getXcCriteriaSetOrder($critName, "'DESC'","\t\t\t"); $case3[] = $this->pc->getPhpCodeCommentLine("For the block: {$tableName} hits",'',"\t\t\t"); $case3[] = $this->pc->getPhpCodeCommentLine("Table {$tableName} must have {$tableFieldname}_hits or you have to change into corresponding field name",'',"\t\t\t"); $case3[] = $this->xc->getXcCriteriaSetSort($critName, "'{$tableFieldname}_hits'","\t\t\t"); $case3[] = $this->xc->getXcCriteriaSetOrder($critName, "'DESC'","\t\t\t"); + $case4[] = $this->pc->getPhpCodeCommentLine("For the block: {$tableName} top",'',"\t\t\t"); if ('' !== $fieldRating) { - $case4[] = $this->pc->getPhpCodeCommentLine("For the block: {$tableName} top",'',"\t\t\t"); $case4[] = $this->xc->getXcCriteriaSetSort($critName, "'{$fieldRating}'","\t\t\t"); } else { - $case4[] = $this->pc->getPhpCodeCommentLine("For the block: {$tableName} top",'',"\t\t\t"); $case4[] = $this->pc->getPhpCodeCommentLine("Table {$tableName} must have {$tableFieldname}_top or you have to change into corresponding field name",'',"\t\t\t"); $case4[] = $this->xc->getXcCriteriaSetSort($critName, "'{$tableFieldname}_top'","\t\t\t"); } - $case4[] = $this->xc->getXcCriteriaSetOrder($critName, "'ASC'","\t\t\t"); + $case4[] = $this->xc->getXcCriteriaSetOrder($critName, "'DESC'","\t\t\t"); $case5[] = $this->pc->getPhpCodeCommentLine("For the block: {$tableName} random",'',"\t\t\t"); $case5[] = $this->xc->getXcCriteriaSetSort($critName, "'RAND()'","\t\t\t"); $cases = [ @@ -222,7 +219,7 @@ private function getBlocksShow($moduleDirname, $tableName, $tableFieldname, $tab $func .= $this->xc->getXcCriteriaSetLimit($critName, '$limit', "\t"); $func .= $this->xc->getXcHandlerAllClear("{$tableName}All", $tableName, "\${$critName}", "\t"); $func .= $this->pc->getPhpCodeUnset($critName, "\t"); - $contentForeach = ''; + $contentForeach = $this->xc->getXcEqualsOperator("\${$tableName}","\${$tableName}All[\$i]->getValues{$ucfTableName}()", '', "\t\t\t"); $contentForeach .= $this->pc->getPhpCodeCommentMultiLine([ 'If you want to use the parameter for limits you have to adapt the line where it should be applied' => '', 'e.g. change' => '', @@ -234,32 +231,62 @@ private function getBlocksShow($moduleDirname, $tableName, $tableFieldname, $tab "\t" . '}' => '', "\t\$block[\$i]['title'] = " => '$myTitle;', ], "\t\t\t", false); + $lenName = 0; + foreach (\array_keys($fields) as $f) { + $fieldName = $fields[$f]->getVar('field_name'); + $fieldElement = $fields[$f]->getVar('field_element'); + if (1 == $fields[$f]->getVar('field_block')) { + switch ($fieldElement) { + case Constants::FIELD_ELE_TEXTAREA: + case Constants::FIELD_ELE_DHTMLTEXTAREA: + $lenName = max(strlen($this->getRightString($fieldName)) + 6, $lenName); + break; + case Constants::FIELD_ELE_SELECTUSER: + case Constants::FIELD_ELE_TEXTDATESELECT: + case Constants::FIELD_ELE_SELECTSTATUS: + case Constants::FIELD_ELE_RADIOYN: + case Constants::FIELD_ELE_RADIO_ONOFFLINE: + case Constants::FIELD_ELE_DATETIME: + $lenName = max(strlen($this->getRightString($fieldName)) + 5, $lenName); + break; + case 0: + default: + $lenName = max(strlen($this->getRightString($fieldName)), $lenName); + break; + } + } + } + $lenName += 15; foreach (\array_keys($fields) as $f) { $fieldName = $fields[$f]->getVar('field_name'); $rpFieldName = $this->getRightString($fieldName); $fieldElement = $fields[$f]->getVar('field_element'); if (0 == $f) { - $contentForeach .= $this->xc->getXcEqualsOperator("\$block[\$i]['id']", "\${$tableName}All[\$i]->getVar('{$fieldId}')", null, "\t\t\t"); + $contentForeach .= $this->xc->getXcEqualsOperator(str_pad("\$block[\$i]['id']", $lenName), "\${$tableName}['{$rpFieldName}']", null, "\t\t\t"); } if (1 == $fields[$f]->getVar('field_block')) { switch ($fieldElement) { - case Constants::FIELD_ELE_TEXT: - $contentForeach .= $this->xc->getXcEqualsOperator("\$block[\$i]['{$rpFieldName}']", "\htmlspecialchars(\${$tableName}All[\$i]->getVar('{$fieldName}'), ENT_QUOTES | ENT_HTML5)", null, "\t\t\t"); - break; case Constants::FIELD_ELE_TEXTAREA: case Constants::FIELD_ELE_DHTMLTEXTAREA: - $contentForeach .= $this->xc->getXcEqualsOperator("\$block[\$i]['{$rpFieldName}_text']", "\${$tableName}All[\$i]->getVar('{$fieldName}', 'e')", null, "\t\t\t"); - $contentForeach .= $this->xc->getXcEqualsOperator("\$block[\$i]['{$rpFieldName}_short']", "\$utility::truncateHtml(\${$tableName}All[\$i]->getVar('{$fieldName}', 'e'), \$editorMaxchar)", null, "\t\t\t"); + $contentForeach .= $this->xc->getXcEqualsOperator(str_pad("\$block[\$i]['{$rpFieldName}_text']", $lenName), "\${$tableName}['{$rpFieldName}_text']", null, "\t\t\t"); + $truncate = "\$utility::truncateHtml(\$block[\$i]['{$rpFieldName}_text'], \$lenghtTitle)"; + $contentForeach .= $this->xc->getXcEqualsOperator(str_pad("\$block[\$i]['{$rpFieldName}_short']", $lenName), $truncate, false, "\t\t\t"); break; - case 8: - $contentForeach .= $this->xc->getXcEqualsOperator("\$block[\$i]['{$rpFieldName}']", "\XoopsUser::getUnameFromId(\${$tableName}All[\$i]->getVar('{$fieldName}'))", null, "\t\t\t"); + case Constants::FIELD_ELE_TEXTDATESELECT: + case Constants::FIELD_ELE_DATETIME: + case Constants::FIELD_ELE_SELECTUSER: + $contentForeach .= $this->xc->getXcEqualsOperator(str_pad("\$block[\$i]['{$rpFieldName}_text']", $lenName), "\${$tableName}['{$rpFieldName}_text']", null, "\t\t\t"); break; - case 15: - $contentForeach .= $this->xc->getXcEqualsOperator("\$block[\$i]['{$rpFieldName}']","\\formatTimestamp(\${$tableName}All[\$i]->getVar('{$fieldName}'))", null, "\t\t\t"); + case Constants::FIELD_ELE_SELECTSTATUS: + case Constants::FIELD_ELE_RADIOYN: + case Constants::FIELD_ELE_RADIO_ONOFFLINE: + $contentForeach .= $this->xc->getXcEqualsOperator(str_pad("\$block[\$i]['{$rpFieldName}_text']", $lenName),"\${$tableName}['{$rpFieldName}_text']", null, "\t\t\t"); break; + case 0: + case Constants::FIELD_ELE_TEXT: default: - $contentForeach .= $this->xc->getXcEqualsOperator("\$block[\$i]['{$rpFieldName}']","\${$tableName}All[\$i]->getVar('{$fieldName}')", null, "\t\t\t"); + $contentForeach .= $this->xc->getXcEqualsOperator(str_pad("\$block[\$i]['{$rpFieldName}']", $lenName),"\${$tableName}['{$rpFieldName}']", null, "\t\t\t"); break; } } @@ -269,11 +296,13 @@ private function getBlocksShow($moduleDirname, $tableName, $tableFieldname, $tab $func .= $this->pc->getPhpCodeConditions("\count(\${$tableName}All)", ' > ', '0', $foreach, false, "\t"); $func .= $this->pc->getPhpCodeBlankLine(); $func .= $this->xc->getXcXoopsTplAssign("{$moduleDirname}_url", "\\{$stuModuleDirname}_URL", true ,"\t"); + $config = $this->xc->getXcGetConfig('table_type'); + $func .= $this->xc->getXcXoopsTplAssign('table_type', $config, true, "\t"); $func .= $this->pc->getPhpCodeBlankLine(); $func .= $this->getSimpleString('return $block;',"\t"); $func .= $this->pc->getPhpCodeBlankLine(); - $ret .= $this->pc->getPhpCodeFunction("b_{$moduleDirname}_{$tableName}_show", '$options', $func, '', false, ""); + $ret .= $this->pc->getPhpCodeFunction("b_{$moduleDirname}_{$tableName}_show", '$options', $func, ''); return $ret; } @@ -288,7 +317,7 @@ private function getBlocksShow($moduleDirname, $tableName, $tableFieldname, $tab * * @return string */ - private function getBlocksEdit($moduleDirname, $tableName, $fieldId, $fieldMain, $language) + private function getBlocksEdit(string $moduleDirname, string $tableName, string $fieldId, string $fieldMain, string $language) { $stuModuleDirname = \mb_strtoupper($moduleDirname); $stuTableName = \mb_strtoupper($tableName); @@ -296,7 +325,7 @@ private function getBlocksEdit($moduleDirname, $tableName, $fieldId, $fieldMain, $critName = 'cr' . $ucfTableName; $ret = $this->pc->getPhpCodeCommentMultiLine(['Function' => 'edit block', '@param $options' => '', '@return' => 'string']); - $func = $this->xc->getXcXoopsTplAssign("{$moduleDirname}_upload_url","\\{$stuModuleDirname}_UPLOAD_URL",'',"\t"); + $func = $this->xc->getXcXoopsTplAssign("{$moduleDirname}_upload_url","\\{$stuModuleDirname}_UPLOAD_URL",true,"\t"); $func .= $this->xc->getXcEqualsOperator('$form', "{$language}DISPLAY . ' : '", '',"\t"); $func .= $this->xc->getXcEqualsOperator('$form', "\"\"", '.',"\t"); $func .= $this->xc->getXcEqualsOperator('$form', "\" 
\"", '.',"\t"); @@ -305,11 +334,7 @@ private function getBlocksEdit($moduleDirname, $tableName, $fieldId, $fieldMain, $func .= $this->pc->getPhpCodeArrayShift('$options', "\t"); $func .= $this->pc->getPhpCodeArrayShift('$options', "\t"); $func .= $this->pc->getPhpCodeBlankLine(); - $func .= $this->xc->getXcCriteriaCompo($critName, "\t"); - $crit = $this->xc->getXcCriteria('', "'{$fieldId}'", '0', "'!='", true); - $func .= $this->xc->getXcCriteriaAdd($critName, $crit, "\t"); - $func .= $this->xc->getXcCriteriaSetSort($critName, "'{$fieldId}'","\t"); - $func .= $this->xc->getXcCriteriaSetOrder($critName, "'ASC'","\t"); + $func .= $this->pc->getPhpCodeCommentMultiLine([ 'If you want to filter your results by e.g. a category used in your' . $tableName => '', 'then you can activate the following code, but you have to change it according your category' => '' @@ -317,6 +342,11 @@ private function getBlocksEdit($moduleDirname, $tableName, $fieldId, $fieldMain, $func .= $this->getSimpleString('/*', "\t"); $func .= $this->xc->getXcEqualsOperator('$helper', 'Helper::getInstance()', '',"\t"); $func .= $this->xc->getXcHandlerLine($tableName, "\t"); + $func .= $this->xc->getXcCriteriaCompo($critName, "\t"); + $crit = $this->xc->getXcCriteria('', "'{$fieldId}'", '0', "'!='", true); + $func .= $this->xc->getXcCriteriaAdd($critName, $crit, "\t"); + $func .= $this->xc->getXcCriteriaSetSort($critName, "'{$fieldId}'","\t"); + $func .= $this->xc->getXcCriteriaSetOrder($critName, "'ASC'","\t"); $func .= $this->xc->getXcHandlerAllClear("{$tableName}All", $tableName, "\${$critName}", "\t"); $func .= $this->pc->getPhpCodeUnset($critName, "\t"); $func .= $this->xc->getXcEqualsOperator('$form', "{$language}{$stuTableName}_TO_DISPLAY . \"
\"", '.',"\t"); $func .= $this->xc->getXcEqualsOperator('$form', "\" 
\"", '.',"\t"); @@ -235,7 +285,8 @@ private function getBlocksEdit($moduleDirname, $tableName, $fieldId, $fieldMain, $func .= $this->xc->getXcEqualsOperator('$form', "{$language}{$stuTableName}_TO_DISPLAY . \"
'", '.',"\t"); $func .= $this->pc->getPhpCodeBlankLine(); @@ -250,9 +301,8 @@ private function getBlocksEdit($moduleDirname, $tableName, $fieldId, $fieldMain, /** * @public function render - * @param null * - * @return bool|string + * @return string */ public function render() { diff --git a/class/Files/CheckData.php b/class/Files/CheckData.php index 7b042e5b..8dba3b1a 100644 --- a/class/Files/CheckData.php +++ b/class/Files/CheckData.php @@ -52,7 +52,6 @@ class CheckData /** * @public function constructor - * @param null */ public function __construct() { @@ -62,8 +61,6 @@ public function __construct() /** * @static function getInstance * - * @param null - * * @return Modulebuilder\Files\CheckData */ public static function getInstance() @@ -102,9 +99,9 @@ public function getCheckPreBuilding($module) /** * @public function getCheckBroken * - * @return array|bool + * @return void */ - private function getCheckBroken() + private function getCheckBroken(): void { foreach (\array_keys($this->tables) as $t) { if (1 == $this->tables[$t]->getVar('table_broken')) { @@ -126,16 +123,14 @@ private function getCheckBroken() } } } - - return true; } /** * @private function getCheckUserpage * - * @return array|bool + * @return void */ - private function getCheckUserpage() + private function getCheckUserpage(): void { //check field params: minimum one param is selected foreach (\array_keys($this->tables) as $t) { @@ -258,15 +253,14 @@ private function getCheckUserpage() } } - return true; } /** * @private function getCheckBlock * - * @return array|bool + * @return void */ - private function getCheckBlock() + private function getCheckBlock(): void { //use in block but no field selected foreach (\array_keys($this->tables) as $t) { @@ -306,15 +300,14 @@ private function getCheckBlock() } } - return true; } /** * @private function getCheckComments * - * @return array|bool + * @return void */ - private function getCheckComments() + private function getCheckComments(): void { //use comments in multiple tables $count = 0; @@ -350,15 +343,14 @@ private function getCheckComments() } } - return true; } /** * @private function getCheckRatings * - * @return array|bool + * @return void */ - private function getCheckRating() + private function getCheckRating(): void { foreach (\array_keys($this->tables) as $t) { if (1 == $this->tables[$t]->getVar('table_rate')) { @@ -376,27 +368,26 @@ private function getCheckRating() } } // check whether each table with handling "rating" has also a field "rating" - if (0 == (int)$fieldRatings) { + if (0 == $fieldRatings) { $info = \str_replace('%t', $tableName, \_AM_MODULEBUILDER_BUILDING_CHECK_RATINGS1); $this->infos[] = ['icon' => 'error', 'info' => $info]; } // check whether each table with handling "rating" has also a field "votes" - if (0 == (int)$fieldVotes) { + if (0 == $fieldVotes) { $info = \str_replace('%t', $tableName, \_AM_MODULEBUILDER_BUILDING_CHECK_RATINGS2); $this->infos[] = ['icon' => 'error', 'info' => $info]; } } } - return true; } /** * @private function getCheckReads * - * @return array|bool + * @return void */ - private function getCheckReads() + private function getCheckReads(): void { foreach (\array_keys($this->tables) as $t) { if (1 == $this->tables[$t]->getVar('table_reads')) { @@ -410,22 +401,21 @@ private function getCheckReads() } } // check whether each table with handling "reads" has also a field "reads" - if (0 == (int)$fieldReads) { + if (0 == $fieldReads) { $info = \str_replace('%t', $tableName, \_AM_MODULEBUILDER_BUILDING_CHECK_READS1); $this->infos[] = ['icon' => 'error', 'info' => $info]; } } } - return true; } /** * @private function getCheckSql * - * @return array|bool + * @return void */ - private function getCheckSql() + private function getCheckSql(): void { foreach (\array_keys($this->tables) as $t) { $tableId = $this->tables[$t]->getVar('table_id'); @@ -449,6 +439,5 @@ private function getCheckSql() } } - return true; } } diff --git a/class/Files/Classes/ClassFiles.php b/class/Files/Classes/ClassFiles.php index be916e5d..65e88cbe 100644 --- a/class/Files/Classes/ClassFiles.php +++ b/class/Files/Classes/ClassFiles.php @@ -46,6 +46,10 @@ class ClassFiles extends Files\CreateFile * @var mixed */ private $pc = null; + /** + * @var mixed + */ + private $cf = null; /** * @var mixed */ @@ -53,11 +57,11 @@ class ClassFiles extends Files\CreateFile /** * @public function constructor - * @param null */ public function __construct() { parent::__construct(); + $this->cf = Modulebuilder\Files\CreateFile::getInstance(); $this->xc = Modulebuilder\Files\CreateXoopsCode::getInstance(); $this->pc = Modulebuilder\Files\CreatePhpCode::getInstance(); $this->cxc = Modulebuilder\Files\Classes\ClassXoopsCode::getInstance(); @@ -67,8 +71,6 @@ public function __construct() /** * @static function getInstance * - * @param null - * * @return ClassFiles */ public static function getInstance() @@ -84,9 +86,9 @@ public static function getInstance() /** * @public function write * - * @param string $module - * @param string $table - * @param mixed $tables + * @param $module + * @param $table + * @param $tables * @param $filename */ public function write($module, $table, $tables, $filename): void @@ -105,7 +107,7 @@ public function write($module, $table, $tables, $filename): void * * @return string */ - private function getInitVar($fieldName, $type = 'INT') + private function getInitVar(string $fieldName, string $type = 'INT') { return $this->cxc->getClassInitVar($fieldName, $type); } @@ -117,13 +119,14 @@ private function getInitVar($fieldName, $type = 'INT') * * @return string */ - private function getInitVars($fields) + private function getInitVars(array $fields) { $ret = ''; // Creation of the initVar functions list foreach (\array_keys($fields) as $f) { $fieldName = $fields[$f]->getVar('field_name'); $fieldType = $fields[$f]->getVar('field_type'); + //Attention: field_type is not the same as field_ele_type switch ($fieldType) { case 2: case 3: @@ -226,14 +229,15 @@ private function getClassObject($module, $table, $fields) $cCl .= $this->pc->getPhpCodeVariableClass('public', 'start', '0', "\t"); $cCl .= $this->pc->getPhpCodeCommentMultiLine(['@var' => 'int'], "\t"); $cCl .= $this->pc->getPhpCodeVariableClass('public', 'limit', '0', "\t"); - $cCl .= $this->pc->getPhpCodeCommentMultiLine(['Constructor' => '', '' => '', '@param' => 'null'], "\t"); + $cCl .= $this->pc->getPhpCodeCommentMultiLine(['Constructor' => '', '' => ''], "\t"); $constr = $this->getInitVars($fields); $cCl .= $this->pc->getPhpCodeFunction('__construct', '', $constr, 'public ', false, "\t"); - $arrayGetInstance = ['@static function' => '&getInstance', '' => '', '@param' => 'null']; + $arrayGetInstance = ['@static function' => 'getInstance', '' => '']; $cCl .= $this->pc->getPhpCodeCommentMultiLine($arrayGetInstance, "\t"); $getInstance = $this->pc->getPhpCodeVariableClass('static', 'instance', 'false', "\t\t"); $instance = $this->xc->getXcEqualsOperator('$instance', 'new self()', null, "\t\t\t"); $getInstance .= $this->pc->getPhpCodeConditions('!$instance', '', '', $instance, false, "\t\t"); + $getInstance .= $this->cf->getSimpleString('return $instance;', "\t\t"); $cCl .= $this->pc->getPhpCodeFunction('getInstance', '', $getInstance, 'public static ', false, "\t"); $cCl .= $this->getNewInsertId($table); @@ -262,7 +266,7 @@ private function getNewInsertId($table) { $tableName = $table->getVar('table_name'); $ucfTableName = \ucfirst($tableName); - $ret = $this->pc->getPhpCodeCommentMultiLine(['The new inserted' => '$Id', '@return' => 'inserted id'], "\t"); + $ret = $this->pc->getPhpCodeCommentMultiLine(['The new inserted' => '$Id', '@return' => 'int'], "\t"); $getInsertedId = $this->xc->getXcEqualsOperator('$newInsertedId', "\$GLOBALS['xoopsDB']->getInsertId()", null, "\t\t"); $getInsertedId .= $this->getSimpleString('return $newInsertedId;', "\t\t"); @@ -274,8 +278,8 @@ private function getNewInsertId($table) /** * @private function getFunctionForm * - * @param string $module - * @param string $table + * @param $module + * @param $table * @param $fieldId * @param $fieldInForm * @param $fieldUpload @@ -298,14 +302,13 @@ private function getFunctionForm($module, $table, $fieldId, $fieldInForm, $field $getForm .= $this->pc->getPhpCodeConditions('!', '', '$action', $action, false, "\t\t"); $xUser = $this->pc->getPhpCodeGlobals('xoopsUser'); $xModule = $this->pc->getPhpCodeGlobals('xoopsModule'); - //$getForm .= $this->pc->getPhpCodeTernaryOperator('isAdmin', '\is_object(' . $xUser . ')', $xUser . '->isAdmin(' . $xModule . '->mid())', 'false', "\t\t"); $getForm .= $this->xc->getXcEqualsOperator('$isAdmin', "\is_object(\$GLOBALS['xoopsUser']) && \$GLOBALS['xoopsUser']->isAdmin(\$GLOBALS['xoopsModule']->mid())", null, "\t\t"); if ($fieldUpload) { $permString = 'upload_groups'; $getForm .= $this->pc->getPhpCodeCommentLine('Permissions for', 'uploader', "\t\t"); $getForm .= $this->xc->getXcXoopsHandler('groupperm', "\t\t"); - $getForm .= $this->pc->getPhpCodeTernaryOperator('groups', '\is_object(' . $xUser . ')', $xUser . '->getGroups()', '\XOOPS_GROUP_ANONYMOUS', "\t\t"); - $checkRight = $this->xc->getXcCheckRight('$grouppermHandler', $permString, 32, '$groups', $xModule . '->getVar(\'mid\')', true); + $getForm .= $this->pc->getPhpCodeTernaryOperator('groups', '\is_object(' . $xUser . ')', $xUser . '->getGroups()', '[\XOOPS_GROUP_ANONYMOUS]', "\t\t"); + $checkRight = $this->xc->getXcCheckRight('$grouppermHandler', $permString, '32', '$groups', $xModule . '->getVar(\'mid\')', true); $getForm .= $this->pc->getPhpCodeTernaryOperator('permissionUpload', $checkRight, 'true', 'false', "\t\t"); } $getForm .= $this->pc->getPhpCodeCommentLine('Title', '', "\t\t"); @@ -342,7 +345,7 @@ private function getFunctionForm($module, $table, $fieldId, $fieldInForm, $field * @param $tableName * @return string */ - private function getPermissionsInForm($moduleDirname, $fieldId, $tableName) + private function getPermissionsInForm(string $moduleDirname, string $fieldId, $tableName) { $permissionApprove = $this->getLanguage($moduleDirname, 'AM', 'PERMISSIONS_APPROVE'); $permissionSubmit = $this->getLanguage($moduleDirname, 'AM', 'PERMISSIONS_SUBMIT'); @@ -355,13 +358,10 @@ private function getPermissionsInForm($moduleDirname, $fieldId, $tableName) $fId = $this->xc->getXcGetVar('', 'this', $fieldId, true); $mId = $this->xc->getXcGetVar('', "GLOBALS['xoopsModule']", 'mid', true); $contElse = $this->xc->getXcGetGroupIds('groupsIdsApprove', 'grouppermHandler', "'{$moduleDirname}_approve_{$tableName}'", $fId, $mId, "\t\t\t"); - $contElse .= $this->pc->getPhpCodeArrayType('groupsIdsApprove', 'values', 'groupsIdsApprove', null, false, "\t\t\t"); $contElse .= $this->cxc->getClassXoopsFormCheckBox('groupsCanApproveCheckbox', $permissionApprove, "groups_approve_{$tableName}[]", '$groupsIdsApprove', false, "\t\t\t"); $contElse .= $this->xc->getXcGetGroupIds('groupsIdsSubmit', 'grouppermHandler', "'{$moduleDirname}_submit_{$tableName}'", $fId, $mId, "\t\t\t"); - $contElse .= $this->pc->getPhpCodeArrayType('groupsIdsSubmit', 'values', 'groupsIdsSubmit', null, false, "\t\t\t"); $contElse .= $this->cxc->getClassXoopsFormCheckBox('groupsCanSubmitCheckbox', $permissionSubmit, "groups_submit_{$tableName}[]", '$groupsIdsSubmit', false, "\t\t\t"); $contElse .= $this->xc->getXcGetGroupIds('groupsIdsView', 'grouppermHandler', "'{$moduleDirname}_view_{$tableName}'", $fId, $mId, "\t\t\t"); - $contElse .= $this->pc->getPhpCodeArrayType('groupsIdsView', 'values', 'groupsIdsView', null, false, "\t\t\t"); $contElse .= $this->cxc->getClassXoopsFormCheckBox('groupsCanViewCheckbox', $permissionView, "groups_view_{$tableName}[]", '$groupsIdsView', false, "\t\t\t"); $contIf = $this->cxc->getClassXoopsFormCheckBox('groupsCanApproveCheckbox', $permissionApprove, "groups_approve_{$tableName}[]", '$fullList', false, "\t\t\t"); @@ -394,7 +394,7 @@ private function getPermissionsInForm($moduleDirname, $fieldId, $tableName) private function getValuesInObject($moduleDirname, $table, $fields) { $ucfTableName = \ucfirst($table->getVar('table_name')); - $ret = $this->pc->getPhpCodeCommentMultiLine(['Get' => 'Values', '@param null $keys' => '', '@param null $format' => '', '@param null $maxDepth' => '', '@return' => 'array'], "\t"); + $ret = $this->pc->getPhpCodeCommentMultiLine(['Get' => 'Values', '@param string $keys' => '', '@param string $format' => '', '@param string $maxDepth' => '', '@return' => 'array'], "\t"); $ucfModuleDirname = \ucfirst($moduleDirname); $language = $this->getLanguage($moduleDirname, 'AM'); $getValues = $this->xc->getXcEqualsOperator('$ret', '$this->getValues($keys, $format, $maxDepth)', null, "\t\t"); @@ -450,8 +450,8 @@ private function getValuesInObject($moduleDirname, $table, $fields) case Constants::FIELD_ELE_RADIO_ONOFFLINE: $spacer = str_repeat(' ', \max(0, $lenMaxName - 5 - \mb_strlen($rpFieldName))); $defaultRO = $this->xc->getXcGetConstants('RADIO_OFFLINE'); - $offlineRO = $language . \mb_strtoupper($ucfTableName) . '_' . \mb_strtoupper($rpFieldName) . '_OFFLINE'; - $onlineRO = $language . \mb_strtoupper($ucfTableName) . '_' . \mb_strtoupper($rpFieldName) . '_ONLINE'; + $offlineRO = $language . 'STATUS_OFFLINE'; + $onlineRO = $language . 'STATUS_ONLINE'; $getValues .= $this->xc->getXcEqualsOperator("\$ret['{$rpFieldName}_text']{$spacer}", "(int)\$this->getVar('{$fieldName}') > $defaultRO ? $onlineRO : $offlineRO", false, "\t\t"); break; case Constants::FIELD_ELE_SELECTUSER: @@ -506,12 +506,17 @@ private function getValuesInObject($moduleDirname, $table, $fields) $fieldMainTopic = $fieldNameTopic; } } - $getValues .= $this->xc->getXcHandlerLine($topicTableName, "\t\t"); + $getValues .= $this->xc->getXcHandlerLine($topicTableName, "\t\t"); $getTopicTable = "\${$topicTableName}Handler->get(\$this->getVar('{$fieldName}'))"; - $getValues .= $this->xc->getXcEqualsOperator("\${$topicTableName}Obj", $getTopicTable, null, "\t\t"); - $fMainTopic = "\${$topicTableName}Obj->getVar('{$fieldMainTopic}')"; - $getValues .= $this->xc->getXcEqualsOperator("\$ret['{$rpFieldName}']{$spacer}", $fMainTopic, null, "\t\t"); - $helper = 1; + $getValues .= $this->xc->getXcEqualsOperator("\${$topicTableName}Obj", $getTopicTable, null, "\t\t"); + $fMainTopic = "\${$topicTableName}Obj->getVar('{$fieldMainTopic}')"; + $ccFieldName = $this->cf->getCamelCase($fieldName, false, true); + $getValues .= $this->xc->getXcEqualsOperator("\${$ccFieldName}", "''", null, "\t\t"); + $condIf = $this->xc->getXcEqualsOperator("\${$ccFieldName}", $fMainTopic, null, "\t\t\t"); + $tablenameObj = $this->pc->getPhpCodeIsobject($topicTableName . 'Obj'); + $getValues .= $this->pc->getPhpCodeConditions($tablenameObj, '', '', $condIf, false, "\t\t"); + $getValues .= $this->xc->getXcEqualsOperator("\$ret['{$rpFieldName}']{$spacer}", "\${$ccFieldName}", null, "\t\t"); + $helper = 1; } else { $getValues .= $this->xc->getXcGetVar("ret['{$rpFieldName}']{$spacer}", 'this', $fieldName, false, "\t\t"); } @@ -593,9 +598,8 @@ private function getOptionsCheck($table) /** * @public function render - * @param null * - * @return bool|string + * @return string */ public function render() { diff --git a/class/Files/Classes/ClassFormElements.php b/class/Files/Classes/ClassFormElements.php index e7171210..c90ca222 100644 --- a/class/Files/Classes/ClassFormElements.php +++ b/class/Files/Classes/ClassFormElements.php @@ -39,10 +39,6 @@ class ClassFormElements extends Modulebuilder\Files\CreateAbstractClass * @var mixed */ private $tf = null; - /** - * @var mixed - */ - private $uxc = null; /** * @var mixed */ @@ -62,7 +58,6 @@ class ClassFormElements extends Modulebuilder\Files\CreateAbstractClass /** * @public function constructor - * @param null */ public function __construct() { @@ -71,13 +66,11 @@ public function __construct() $this->xc = Modulebuilder\Files\CreateXoopsCode::getInstance(); $this->pc = Modulebuilder\Files\CreatePhpCode::getInstance(); $this->tf = Modulebuilder\Files\CreateTableFields::getInstance(); - $this->uxc = Modulebuilder\Files\User\UserXoopsCode::getInstance(); $this->cxc = Modulebuilder\Files\Classes\ClassXoopsCode::getInstance(); } /** * @static function getInstance - * @param null * * @return ClassFormElements */ @@ -112,19 +105,17 @@ public function initForm($module, $table): void * @param string $required * @return string */ - private function getXoopsFormText($language, $fieldName, $fieldDefault, $required = 'false') + private function getXoopsFormText($language, $fieldName, $fieldDefault, string $required = 'false') { $ccFieldName = $this->cf->getCamelCase($fieldName, false, true); + $ret = $this->pc->getPhpCodeCommentLine('Form Text', $ccFieldName, "\t\t"); if ('' != $fieldDefault) { - $ret = $this->pc->getPhpCodeCommentLine('Form Text', $ccFieldName, "\t\t"); $ret .= $this->pc->getPhpCodeTernaryOperator($ccFieldName, '$this->isNew()', "'{$fieldDefault}'", "\$this->getVar('{$fieldName}')", "\t\t"); $formText = $this->cxc->getClassXoopsFormText('', $language, $fieldName, 20, 150, $ccFieldName, true); - $ret .= $this->cxc->getClassAddElement('form', $formText . $required); } else { - $ret = $this->pc->getPhpCodeCommentLine('Form Text', $ccFieldName, "\t\t"); $formText = $this->cxc->getClassXoopsFormText('', $language, $fieldName, 50, 255, "this->getVar('{$fieldName}')", true); - $ret .= $this->cxc->getClassAddElement('form', $formText . $required); } + $ret .= $this->cxc->getClassAddElement('form', $formText . $required); return $ret; } @@ -134,11 +125,11 @@ private function getXoopsFormText($language, $fieldName, $fieldDefault, $require * * @param $language * @param $fieldName - * @param $required + * @param string $required * * @return string */ - private function getXoopsFormTextArea($language, $fieldName, $required = 'false') + private function getXoopsFormTextArea($language, $fieldName, string $required = 'false') { $ccFieldName = $this->cf->getCamelCase($fieldName, false, true); $ret = $this->pc->getPhpCodeCommentLine('Form Editor', 'TextArea ' . $ccFieldName, "\t\t"); @@ -153,11 +144,11 @@ private function getXoopsFormTextArea($language, $fieldName, $required = 'false' * * @param $language * @param $fieldName - * @param $required + * @param string $required * * @return string */ - private function getXoopsFormDhtmlTextArea($language, $fieldName, $required = 'false') + private function getXoopsFormDhtmlTextArea($language, $fieldName, string $required = 'false') { $ccFieldName = $this->cf->getCamelCase($fieldName, false, true); $ret = $this->pc->getPhpCodeCommentLine('Form Editor', 'DhtmlTextArea ' . $ccFieldName, "\t\t"); @@ -196,7 +187,7 @@ private function getXoopsFormDhtmlTextArea($language, $fieldName, $required = 'f * @param string $required * @return string */ - private function getXoopsFormCheckBox($language, $tableSoleName, $fieldName, $fieldElementId, $required = 'false') + private function getXoopsFormCheckBox($language, $tableSoleName, $fieldName, $fieldElementId, string $required = 'false') { $stuTableSoleName = \mb_strtoupper($tableSoleName); $ucfFieldName = $this->cf->getCamelCase($fieldName, true); @@ -209,17 +200,15 @@ private function getXoopsFormCheckBox($language, $tableSoleName, $fieldName, $fi $foreach .= $this->cxc->getClassSetDescription('check' . $ucfFieldName, "{$language}{$stuTableSoleName}_OPTIONS_DESC", $t . "\t"); $foreach .= $this->cxc->getClassAddOption('check' . $ucfFieldName, "\$option, {$language}{$stuTableSoleName}_ . strtoupper(\$option)", $t . "\t"); $ret .= $this->pc->getPhpCodeForeach("{$tableSoleName}All", false, false, 'option', $foreach, $t); - $intElem = "\$check{$ucfFieldName}{$required}"; - $ret .= $this->cxc->getClassAddElement('form', $intElem, $t); } else { $ret = $this->pc->getPhpCodeCommentLine('Form Check Box', $ccFieldName, $t); $ret .= $this->pc->getPhpCodeTernaryOperator($ccFieldName, '$this->isNew()', 0, "\$this->getVar('{$fieldName}')", $t); $ret .= $this->cxc->getClassXoopsFormCheckBox('check' . $ucfFieldName, $language, $fieldName, "\${$ccFieldName}", false, $t); $option = "1, {$language}"; $ret .= $this->cxc->getClassAddOption('check' . $ucfFieldName, $option, $t); - $intElem = "\$check{$ucfFieldName}{$required}"; - $ret .= $this->cxc->getClassAddElement('form', $intElem, $t); } + $intElem = "\$check{$ucfFieldName}{$required}"; + $ret .= $this->cxc->getClassAddElement('form', $intElem, $t); return $ret; } @@ -248,11 +237,11 @@ private function getXoopsFormHidden($fieldName) * @param $language * @param $moduleDirname * @param $fieldName - * @param $required + * @param string $required * * @return string */ - private function getXoopsFormImageList($language, $moduleDirname, $fieldName, $required = 'false') + private function getXoopsFormImageList($language, $moduleDirname, $fieldName, string $required = 'false') { $ucfFieldName = $this->cf->getCamelCase($fieldName, true); $ccFieldName = $this->cf->getCamelCase($fieldName, false, true); @@ -296,11 +285,11 @@ private function getXoopsFormImageList($language, $moduleDirname, $fieldName, $r * @param $moduleDirname * @param $tableName * @param $fieldName - * @param $required + * @param string $required * * @return string */ - private function getXoopsFormSelectFile($language, $moduleDirname, $tableName, $fieldName, $required = 'false') + private function getXoopsFormSelectFile($language, $moduleDirname, $tableName, $fieldName, string $required = 'false') { $ucfFieldName = $this->cf->getCamelCase($fieldName, true); $ccFieldName = $this->cf->getCamelCase($fieldName, false, true); @@ -348,11 +337,11 @@ private function getXoopsFormSelectFile($language, $moduleDirname, $tableName, $ * @param $moduleDirname * @param $fieldName * @param $fieldDefault - * @param $required + * @param string $required * * @return string */ - private function getXoopsFormUrlFile($language, $moduleDirname, $fieldName, $fieldDefault, $required = 'false') + private function getXoopsFormUrlFile($language, $moduleDirname, $fieldName, $fieldDefault, string $required = 'false') { $ccFieldName = $this->cf->getCamelCase($fieldName, false, true); $languageShort = \mb_substr($language, 0, 5) . \mb_strtoupper($moduleDirname) . '_'; @@ -381,7 +370,7 @@ private function getXoopsFormUrlFile($language, $moduleDirname, $fieldName, $fie * @param string $required * @return string */ - private function getXoopsFormUploadImage($language, $moduleDirname, $tableName, $fieldName, $required = 'false') + private function getXoopsFormUploadImage($language, $moduleDirname, $tableName, $fieldName, string $required = 'false') { $ucfFieldName = $this->cf->getCamelCase($fieldName, true); $ccFieldName = $this->cf->getCamelCase($fieldName, false, true); @@ -418,9 +407,7 @@ private function getXoopsFormUploadImage($language, $moduleDirname, $tableName, $getConfig = $this->xc->getXcGetConfig('maxheight_image'); $labelInfo3 = $this->cxc->getClassXoopsFormLabel('', $languageShort . 'FORM_UPLOAD_IMG_HEIGHT', $getConfig . " . ' px'", true, ''); $contIf .= $this->cxc->getClassAddElement('imageTray', $labelInfo3, $t . "\t"); - $formHidden = $this->cxc->getClassXoopsFormHidden('', $fieldName, $ccFieldName, true, true, $t, true); - $contElse = $this->cxc->getClassAddElement('imageTray', $formHidden, $t . "\t"); - $ret .= $this->pc->getPhpCodeConditions('$permissionUpload', '', '', $contIf, $contElse, "\t\t"); + $ret .= $this->pc->getPhpCodeConditions('$permissionUpload', '', '', $contIf, false, "\t\t"); $ret .= $this->cxc->getClassAddElement('form', "\$imageTray{$required}", $t); return $ret; @@ -438,7 +425,7 @@ private function getXoopsFormUploadImage($language, $moduleDirname, $tableName, * @param string $required * @return string */ - private function getXoopsFormUploadFile($language, $moduleDirname, $tableName, $fieldName, $required = 'false') + private function getXoopsFormUploadFile($language, $moduleDirname, $tableName, $fieldName, string $required = 'false') { $ccFieldName = $this->cf->getCamelCase($fieldName, false, true); $languageShort = \mb_substr($language, 0, 5) . \mb_strtoupper($moduleDirname) . '_'; @@ -476,7 +463,7 @@ private function getXoopsFormUploadFile($language, $moduleDirname, $tableName, $ * @param string $required * @return string */ - private function getXoopsFormColorPicker($language, $fieldName, $required = 'false') + private function getXoopsFormColorPicker($language, $fieldName, string $required = 'false') { $ccFieldName = $this->cf->getCamelCase($fieldName, false, true); $t = "\t\t"; @@ -494,11 +481,11 @@ private function getXoopsFormColorPicker($language, $fieldName, $required = 'fal * @param $language * @param $tableName * @param $fieldName - * @param $required + * @param string $required * * @return string */ - private function getXoopsFormSelectBox($language, $tableName, $fieldName, $required = 'false') + private function getXoopsFormSelectBox($language, $tableName, $fieldName, string $required = 'false') { $ucfTableName = \ucfirst($tableName); $ccFieldName = $this->cf->getCamelCase($fieldName, false, true); @@ -522,7 +509,7 @@ private function getXoopsFormSelectBox($language, $tableName, $fieldName, $requi * @param string $required * @return string */ - private function getXoopsFormSelectUser($language, $fieldName, $required = 'false') + private function getXoopsFormSelectUser($language, $fieldName, string $required = 'false') { $ccFieldName = $this->cf->getCamelCase($fieldName, false, true); $t = "\t\t"; @@ -541,11 +528,11 @@ private function getXoopsFormSelectUser($language, $fieldName, $required = 'fals * * @param $language * @param $fieldName - * @param $required + * @param string $required * * @return string */ - private function getXoopsFormRadioYN($language, $fieldName, $required = 'false') + private function getXoopsFormRadioYN($language, $fieldName, string $required = 'false') { $ccFieldName = $this->cf->getCamelCase($fieldName, false, true); $t = "\t\t"; @@ -562,11 +549,11 @@ private function getXoopsFormRadioYN($language, $fieldName, $required = 'false') * * @param $language * @param $fieldName - * @param $required + * @param string $required * * @return string */ - private function getXoopsFormTextDateSelect($language, $fieldName, $required = 'false') + private function getXoopsFormTextDateSelect($language, $fieldName, string $required = 'false') { $t = "\t\t"; $ccFieldName = $this->cf->getCamelCase($fieldName, false, true); @@ -583,11 +570,11 @@ private function getXoopsFormTextDateSelect($language, $fieldName, $required = ' * * @param $language * @param $fieldName - * @param $required + * @param string $required * * @return string */ - private function getXoopsFormDateTime($language, $fieldName, $required = 'false') + private function getXoopsFormDateTime($language, $fieldName, string $required = 'false') { $t = "\t\t"; $ccFieldName = $this->cf->getCamelCase($fieldName, false, true); @@ -610,7 +597,7 @@ private function getXoopsFormDateTime($language, $fieldName, $required = 'false' * * @return string */ - private function getXoopsFormSelectStatus($language, $moduleDirname, $fieldName, $tablePermissions, $required = 'false') + private function getXoopsFormSelectStatus($language, $moduleDirname, $fieldName, $tablePermissions, string $required = 'false') { $ccFieldName = $this->cf->getCamelCase($fieldName, false, true); $languageShort = \mb_substr($language, 0, 5) . \mb_strtoupper($moduleDirname) . '_'; @@ -638,16 +625,16 @@ private function getXoopsFormSelectStatus($language, $moduleDirname, $fieldName, * * @param $language * @param $fieldName - * @param $required + * @param string $required * * @return string */ - private function getXoopsFormPassword($language, $fieldName, $required = 'false') + private function getXoopsFormPassword($language, $fieldName, string $required = 'false') { $t = "\t\t"; $ccFieldName = $this->cf->getCamelCase($fieldName, false, true); $ret = $this->pc->getPhpCodeCommentLine('Form Text', 'Enter Password ' . $ccFieldName, $t); - $xoopsPassword = $this->cxc->getClassXoopsFormPassword('', $language, $fieldName, 10, 32, true, $t); + $xoopsPassword = $this->cxc->getClassXoopsFormPassword('', $language, $fieldName, '10', '32', true, $t); $ret .= $this->cxc->getClassAddElement('form', $xoopsPassword . $required, $t); return $ret; @@ -662,7 +649,7 @@ private function getXoopsFormPassword($language, $fieldName, $required = 'false' * * @return string */ - private function getXoopsFormSelectCountry($language, $fieldName, $required = 'false') + private function getXoopsFormSelectCountry($language, $fieldName, string $required = 'false') { $ccFieldName = $this->cf->getCamelCase($fieldName, false, true); $t = "\t\t"; @@ -685,7 +672,7 @@ private function getXoopsFormSelectCountry($language, $fieldName, $required = 'f * * @return string */ - private function getXoopsFormSelectLang($language, $fieldName, $required = 'false') + private function getXoopsFormSelectLang($language, $fieldName, string $required = 'false') { $ccFieldName = $this->cf->getCamelCase($fieldName, false, true); $t = "\t\t"; @@ -709,7 +696,7 @@ private function getXoopsFormSelectLang($language, $fieldName, $required = 'fals * * @return string */ - private function getXoopsFormRadio($language, $moduleDirname, $fieldName, $required = 'false') + private function getXoopsFormRadio($language, $moduleDirname, $fieldName, string $required = 'false') { $ccFieldName = $this->cf->getCamelCase($fieldName, false, true); $languageShort = \mb_substr($language, 0, 5) . \mb_strtoupper($moduleDirname) . '_'; @@ -730,13 +717,12 @@ private function getXoopsFormRadio($language, $moduleDirname, $fieldName, $requi * @private function getXoopsFormRadioOnoffline * * @param $language - * @param $moduleDirname * @param $fieldName * @param string $required * * @return string */ - private function getXoopsFormRadioOnoffline($language, $fieldName, $required = 'false') + private function getXoopsFormRadioOnoffline($language, $fieldName, string $required = 'false') { $ccFieldName = $this->cf->getCamelCase($fieldName, false, true); $t = "\t\t"; @@ -763,7 +749,7 @@ private function getXoopsFormRadioOnoffline($language, $fieldName, $required = ' * * @return string */ - private function getXoopsFormSelectCombo($language, $moduleDirname, $tableName, $fieldName, $required = 'false') + private function getXoopsFormSelectCombo($language, $moduleDirname, $tableName, $fieldName, string $required = 'false') { $ucfTableName = \ucfirst($tableName); $ccFieldName = $this->cf->getCamelCase($fieldName, false, true); @@ -788,11 +774,11 @@ private function getXoopsFormSelectCombo($language, $moduleDirname, $tableName, * @param $language * @param $fieldName * @param $fieldElement - * @param $required + * @param string $required * * @return string */ - private function getXoopsFormTable($language,$fieldName, $fieldElement, $required = 'false') + private function getXoopsFormTable($language, $fieldName, $fieldElement, string $required = 'false') { $t = "\t\t"; $ret = ''; @@ -847,11 +833,11 @@ private function getXoopsFormTopic($language, $topicTableName, $fieldId, $fieldP * @private function getXoopsFormTag * * @param $fieldId - * @param $required + * @param string $required * * @return string */ - private function getXoopsFormTag($fieldId, $required = 'false') + private function getXoopsFormTag($fieldId, string $required = 'false') { $t = "\t\t"; $ret = $this->pc->getPhpCodeCommentLine('Use tag', 'module', $t); @@ -859,7 +845,7 @@ private function getXoopsFormTag($fieldId, $required = 'false') $ret .= $this->pc->getPhpCodeTernaryOperator('dirTag', $isDir, 'true', 'false', $t); $paramIf = '(' . $this->xc->getXcGetConfig('usetag') . ' == 1)'; $condIf = $this->pc->getPhpCodeTernaryOperator('tagId', '$this->isNew()', '0', "\$this->getVar('{$fieldId}')", $t . "\t"); - $condIf .= $this->pc->getPhpCodeIncludeDir('\XOOPS_ROOT_PATH', 'modules/tag/include/formtag', true, false, $type = 'require', $t . "\t"); + $condIf .= $this->pc->getPhpCodeIncludeDir('\XOOPS_ROOT_PATH', 'modules/tag/include/formtag', true, false, 'require', $t . "\t"); $paramElem = $this->cxc->getClassXoopsFormTag('', 'tag', 60, 255, 'tagId', 0, true, ''); $condIf .= $this->cxc->getClassAddElement('form', $paramElem . $required, $t . "\t"); $ret .= $this->pc->getPhpCodeConditions($paramIf, ' && ', '$dirTag', $condIf, false, $t); @@ -875,7 +861,7 @@ private function getXoopsFormTag($fieldId, $required = 'false') * @param string $required * @return string */ - private function getXoopsFormTextUuid($language, $fieldName, $required = 'false') + private function getXoopsFormTextUuid($language, $fieldName, string $required = 'false') { $ccFieldName = $this->cf->getCamelCase($fieldName, false, true); $ret = $this->pc->getPhpCodeCommentLine('Form Text Uuid', $ccFieldName, "\t\t"); @@ -894,12 +880,17 @@ private function getXoopsFormTextUuid($language, $fieldName, $required = 'false' * @param string $required * @return string */ - private function getXoopsFormTextIp($language, $fieldName, $required = 'false') + private function getXoopsFormTextIp($language, $fieldName, string $required = 'false') { $ccFieldName = $this->cf->getCamelCase($fieldName, false, true); $ret = $this->pc->getPhpCodeCommentLine('Form Text IP', $ccFieldName, "\t\t"); $ret .= $this->xc->getXcEqualsOperator('$' . $ccFieldName, "\$_SERVER['REMOTE_ADDR']", null, "\t\t"); + + $ret .= $this->pc->getPhpCodeTernaryOperator($ccFieldName, '$this->isNew()', "(\$_SERVER['REMOTE_ADDR'] ?? '')", "\$this->getVar('{$fieldName}')", "\t\t"); + + + $formText = $this->cxc->getClassXoopsFormText('', $language, $fieldName, 20, 150, $ccFieldName, true); $ret .= $this->cxc->getClassAddElement('form', $formText . $required); @@ -908,7 +899,7 @@ private function getXoopsFormTextIp($language, $fieldName, $required = 'false') /** * @public function renderElements - * @param null + * * @return string */ public function renderElements() @@ -927,7 +918,6 @@ public function renderElements() $fieldPidTopic = ''; $fieldMainTopic = ''; $fieldElementId = []; - $counter = 0; $tagDone = false; foreach (\array_keys($fields) as $f) { $fieldName = $fields[$f]->getVar('field_name'); @@ -946,7 +936,6 @@ public function renderElements() $fieldElementId[] = $fieldElements->getVar('fieldelement_id'); if (1 == $fieldInForm) { - $counter++; // Switch elements switch ($fieldElement) { case 1: diff --git a/class/Files/Classes/ClassHandlerFiles.php b/class/Files/Classes/ClassHandlerFiles.php index 13e25c46..8e08bd24 100644 --- a/class/Files/Classes/ClassHandlerFiles.php +++ b/class/Files/Classes/ClassHandlerFiles.php @@ -42,18 +42,18 @@ class ClassHandlerFiles extends Files\CreateFile /** * @var mixed */ - private $helper = null; + //private $helper = null; /** * @public function constructor - * @param null + * */ public function __construct() { parent::__construct(); $this->xc = Modulebuilder\Files\CreateXoopsCode::getInstance(); $this->pc = Modulebuilder\Files\CreatePhpCode::getInstance(); - $this->helper = Modulebuilder\Helper::getInstance(); + //$this->helper = Modulebuilder\Helper::getInstance(); } /** @@ -74,8 +74,8 @@ public static function getInstance() /** * @public function write * - * @param string $module - * @param string $table + * @param $module + * @param $table * @param mixed $tables * @param $filename */ @@ -91,14 +91,14 @@ public function write($module, $table, $tables, $filename): void * @public function getClassHandler * * @param string $moduleDirname - * @param string $table + * @param $table * @param string $fieldId * @param string $fieldMain * @param $fieldParentId * @param $fieldElement * @return string */ - private function getClassObjectHandler($moduleDirname, $table, $fieldId, $fieldMain, $fieldParentId, $fieldElement) + private function getClassObjectHandler(string $moduleDirname, $table, string $fieldId, string $fieldMain, $fieldParentId, $fieldElement) { $tableName = $table->getVar('table_name'); $ucfTableName = \ucfirst($tableName); @@ -162,7 +162,7 @@ private function getClassGet() */ private function getClassGetInsertId() { - $ret = $this->pc->getPhpCodeCommentMultiLine(['get inserted' => 'id', '' => '', '@param' => 'null', '@return int reference to the' => '{@link Get} object'], "\t"); + $ret = $this->pc->getPhpCodeCommentMultiLine(['get inserted' => 'id', '' => '', '@return int reference to the' => '{@link Get} object'], "\t"); $cClhgid = $this->getSimpleString('return $this->db->getInsertId();', "\t\t"); $ret .= $this->pc->getPhpCodeFunction('getInsertId', '', $cClhgid, 'public ', false, "\t"); @@ -182,13 +182,13 @@ private function getClassGetInsertId() private function getClassCounter($tableName, $fieldId, $fieldMain) { $ucfTableName = \ucfirst($tableName); - $ret = $this->pc->getPhpCodeCommentMultiLine(['Get Count ' . $ucfTableName => 'in the database', '@param int $start' => '', '@param int $limit' => '', '@param string $sort' => '', '@param string $order' => '', '@return' => 'int'], "\t"); + $ret = $this->pc->getPhpCodeCommentMultiLine(['Get Count ' . $ucfTableName => 'in the database', '@param string $sort' => '', '@param string $order' => '', '@return' => 'int'], "\t"); $critCount = $this->xc->getXcCriteriaCompo('crCount' . $ucfTableName, "\t\t"); - $paramsCrit = "\$this->get{$ucfTableName}Criteria(\$crCount{$ucfTableName}, \$start, \$limit, \$sort, \$order)"; + $paramsCrit = "\$this->get{$ucfTableName}Criteria(\$crCount{$ucfTableName}, 0, 0, \$sort, \$order)"; $critCount .= $this->xc->getXcEqualsOperator('$crCount' . $ucfTableName, $paramsCrit, null, "\t\t"); $critCount .= $this->getSimpleString("return \$this->getCount(\$crCount{$ucfTableName});", "\t\t"); - $params = "\$start = 0, \$limit = 0, \$sort = '{$fieldId} ASC, {$fieldMain}', \$order = 'ASC'"; + $params = "\$sort = '{$fieldId} ASC, {$fieldMain}', \$order = 'ASC'"; $ret .= $this->pc->getPhpCodeFunction('getCount' . $ucfTableName, $params, $critCount, 'public ', false, "\t"); @@ -278,12 +278,12 @@ private function getClassByCategory($moduleDirname, $tableName, $tableFieldName, private function getClassCriteria($tableName) { $ucfTableName = \ucfirst($tableName); - $ret = $this->pc->getPhpCodeCommentMultiLine(['Get' => 'Criteria ' . $ucfTableName, '@param ' => "\$cr{$ucfTableName}", '@param int $start' => '', '@param int $limit' => '', '@param string $sort' => '', '@param string $order' => '', '@return' => 'int'], "\t"); + $ret = $this->pc->getPhpCodeCommentMultiLine(['Get' => 'Criteria ' . $ucfTableName, '@param ' => "\$cr{$ucfTableName}", '@param int $start' => '', '@param int $limit' => '', '@param string $sort' => '', '@param string $order' => '', '@return' => '\CriteriaCompo'], "\t"); $paramsAllCriteria = "\$cr{$ucfTableName}, \$start, \$limit, \$sort, \$order"; - - $critSets = $this->xc->getXcCriteriaSetStart('cr' . $ucfTableName, '$start', "\t\t"); - $critSets .= $this->xc->getXcCriteriaSetLimit('cr' . $ucfTableName, '$limit', "\t\t"); + $condIf = $this->xc->getXcCriteriaSetStart('cr' . $ucfTableName, '$start', "\t\t\t"); + $condIf .= $this->xc->getXcCriteriaSetLimit('cr' . $ucfTableName, '$limit', "\t\t\t"); + $critSets = $this->pc->getPhpCodeConditions('$limit', ' > ', '0', $condIf, false, "\t\t"); $critSets .= $this->xc->getXcCriteriaSetSort('cr' . $ucfTableName, '$sort', "\t\t"); $critSets .= $this->xc->getXcCriteriaSetOrder('cr' . $ucfTableName, '$order', "\t\t"); $critSets .= $this->getSimpleString("return \$cr{$ucfTableName};", "\t\t"); @@ -323,9 +323,8 @@ private function getClassGetTableSolenameById($table, $fieldMain) /** * @public function render - * @param null * - * @return bool|string + * @return string */ public function render() { @@ -334,7 +333,7 @@ public function render() $filename = $this->getFileName(); $moduleDirname = $module->getVar('mod_dirname'); $fields = $this->getTableFields($table->getVar('table_mid'), $table->getVar('table_id')); - $fieldInForm = []; + //$fieldInForm = []; $fieldParentId = []; $fieldId = null; $fieldMain = null; diff --git a/class/Files/Classes/ClassSpecialFiles.php b/class/Files/Classes/ClassSpecialFiles.php index 800cc579..6a9fe6bb 100644 --- a/class/Files/Classes/ClassSpecialFiles.php +++ b/class/Files/Classes/ClassSpecialFiles.php @@ -51,7 +51,7 @@ class ClassSpecialFiles extends Files\CreateFile /** * @public function constructor - * @param null + * */ public function __construct() { @@ -78,12 +78,12 @@ public static function getInstance() /** * @public function write * - * @param string $module + * @param $module * @param string $table * @param mixed $tables * @param $filename */ - public function write($module, $table, $tables, $filename): void + public function write($module, string $table, $tables, $filename): void { $this->setModule($module); $this->setTable($table); @@ -93,9 +93,8 @@ public function write($module, $table, $tables, $filename): void /** * @public function render - * @param null * - * @return bool|string + * @return string */ public function renderClass() { @@ -107,10 +106,10 @@ public function renderClass() $content .= $this->pc->getPhpCodeUseNamespace(['XoopsModules', $moduleDirname]); $content .= $this->pc->getPhpCodeDefined(); $content .= $this->pc->getPhpCodeCommentMultiLine(['Class Object' => $this->className]); - $cCl = $this->pc->getPhpCodeCommentMultiLine(['Constructor' => '', '' => '', '@param' => 'null'], "\t"); + $cCl = $this->pc->getPhpCodeCommentMultiLine(['Constructor' => '', '' => ''], "\t"); $constr = ''; $cCl .= $this->pc->getPhpCodeFunction('__construct', '', $constr, 'public ', false, "\t"); - $arrGetInstance = ['@static function' => '&getInstance', '' => '', '@param' => 'null']; + $arrGetInstance = ['@static function' => 'getInstance', '' => '']; $cCl .= $this->pc->getPhpCodeCommentMultiLine($arrGetInstance, "\t"); $getInstance = $this->pc->getPhpCodeVariableClass('static', 'instance', 'false', "\t\t"); $instance = $this->xc->getXcEqualsOperator('$instance', 'new self()', null, "\t\t\t"); @@ -127,7 +126,7 @@ public function renderClass() * @public function getGlobalPerms * @param mixed $permId * - * @return bool|string + * @return string */ public function getGlobalPerms($permId) { @@ -141,23 +140,23 @@ public function getGlobalPerms($permId) $comment = ''; switch ($permId) { case 4: - $comment .= $this->pc->getPhpCodeCommentMultiLine(['@public' => 'function permGlobalApprove', 'returns' => 'right for global approve', '' => '', '@param' => 'null', '@return' => 'bool'], "\t"); - $right .= $this->xc->getXcCheckRight('$grouppermHandler', $moduleDirname . '_ac', 4, '$my_group_ids', '$mid', true, "\t\t\t"); + $comment .= $this->pc->getPhpCodeCommentMultiLine(['@public' => 'function permGlobalApprove', 'returns' => 'right for global approve', '' => '', '@return' => 'bool'], "\t"); + $right .= $this->xc->getXcCheckRight('$grouppermHandler', $moduleDirname . '_ac', '4', '$my_group_ids', '$mid', true, "\t\t\t"); $cond .= $this->pc->getPhpCodeConditions($right, '', '', $returnTrue, false, "\t\t"); $funcname .= 'getPermGlobalApprove'; break; case 8: - $comment .= $this->pc->getPhpCodeCommentMultiLine(['@public' => 'function permGlobalSubmit', 'returns' => 'right for global submit', '' => '', '@param' => 'null', '@return' => 'bool'], "\t"); + $comment .= $this->pc->getPhpCodeCommentMultiLine(['@public' => 'function permGlobalSubmit', 'returns' => 'right for global submit', '' => '', '@return' => 'bool'], "\t"); $cond .= $this->pc->getPhpCodeConditions('$this->getPermGlobalApprove()', '', '', $returnTrue, false, "\t\t"); - $right .= $this->xc->getXcCheckRight('$grouppermHandler', $moduleDirname . '_ac', 8, '$my_group_ids', '$mid', true, "\t\t\t"); + $right .= $this->xc->getXcCheckRight('$grouppermHandler', $moduleDirname . '_ac', '8', '$my_group_ids', '$mid', true, "\t\t\t"); $cond .= $this->pc->getPhpCodeConditions($right, '', '', $returnTrue, false, "\t\t"); $funcname .= 'getPermGlobalSubmit'; break; case 16: - $comment .= $this->pc->getPhpCodeCommentMultiLine(['@public' => 'function permGlobalView', 'returns' => 'right for global view', '' => '', '@param' => 'null', '@return' => 'bool'], "\t"); + $comment .= $this->pc->getPhpCodeCommentMultiLine(['@public' => 'function permGlobalView', 'returns' => 'right for global view', '' => '', '@return' => 'bool'], "\t"); $cond .= $this->pc->getPhpCodeConditions('$this->getPermGlobalApprove()', '', '', $returnTrue, false, "\t\t"); $cond .= $this->pc->getPhpCodeConditions('$this->getPermGlobalSubmit()', '', '', $returnTrue, false, "\t\t"); - $right .= $this->xc->getXcCheckRight('$grouppermHandler', $moduleDirname . '_ac', 16, '$my_group_ids', '$mid', true, "\t\t\t"); + $right .= $this->xc->getXcCheckRight('$grouppermHandler', $moduleDirname . '_ac', '16', '$my_group_ids', '$mid', true, "\t\t\t"); $cond .= $this->pc->getPhpCodeConditions($right, '', '', $returnTrue, false, "\t\t"); $funcname .= 'getPermGlobalView'; break; @@ -188,9 +187,8 @@ public function getGlobalPerms($permId) /** * @public function renderPermissionsHandler - * @param null * - * @return bool|string + * @return string */ public function renderPermissionsHandler() { @@ -203,8 +201,8 @@ public function renderPermissionsHandler() $content .= $this->pc->getPhpCodeDefined(); $content .= $this->pc->getPhpCodeCommentMultiLine(['Class Object' => $this->className]); - $constr = $this->pc->getPhpCodeCommentMultiLine(['Constructor' => '', '' => '', '@param' => 'null'], "\t"); - $constr .= $this->pc->getPhpCodeFunction('__construct', '', '', 'public ', false, "\t"); + $constr = $this->pc->getPhpCodeCommentMultiLine(['Constructor' => '', '@param' => '\XoopsDatabase $db'], "\t"); + $constr .= $this->pc->getPhpCodeFunction('__construct', '\XoopsDatabase $db', '', 'public ', false, "\t"); $functions = $constr; $functions .= $this->getGlobalPerms(4); $functions .= $this->getGlobalPerms(8); @@ -218,9 +216,8 @@ public function renderPermissionsHandler() /** * @public function renderConstantsInterface - * @param null * - * @return bool|string + * @return string */ public function renderConstantsInterface() { diff --git a/class/Files/Classes/ClassXoopsCode.php b/class/Files/Classes/ClassXoopsCode.php index d8d5f1c3..f6172c12 100644 --- a/class/Files/Classes/ClassXoopsCode.php +++ b/class/Files/Classes/ClassXoopsCode.php @@ -32,10 +32,7 @@ class ClassXoopsCode { /* * @static function getInstance - * @param null - */ - - /** + * * @return ClassXoopsCode */ public static function getInstance() @@ -58,7 +55,7 @@ public static function getInstance() * * @return string */ - public function getClassInitVar($paramLeft = '', $paramRight = '', $var = 'this', $t = "\t\t") + public function getClassInitVar(string $paramLeft = '', string $paramRight = '', string $var = 'this', string $t = "\t\t") { $stuParamRight = \mb_strtoupper($paramRight); @@ -74,12 +71,12 @@ public function getClassInitVar($paramLeft = '', $paramRight = '', $var = 'this' * @param null $param3 * @param null $param4 * @param null $param5 - * @param bool $isParam + * @param bool $isParam * @param string $t * * @return string */ - public function getClassXoopsPageNav($var, $param1, $param2 = null, $param3 = null, $param4 = null, $param5 = null, $isParam = false, $t = '') + public function getClassXoopsPageNav($var, $param1, $param2 = null, $param3 = null, $param4 = null, $param5 = null, bool $isParam = false, string $t = '') { $xPageNav = 'new \XoopsPageNav('; if (false === $isParam) { @@ -105,7 +102,7 @@ public function getClassXoopsPageNav($var, $param1, $param2 = null, $param3 = nu * * @return string */ - public function getXoopsSimpleForm($left = '', $element = '', $elementsContent = '', $caption = '', $var = '', $filename = '', $type = 'post', $t = '') + public function getXoopsSimpleForm(string $left = '', string $element = '', string $elementsContent = '', string $caption = '', string $var = '', string $filename = '', string $type = 'post', string $t = '') { $ret = "{$t}\${$left} = new \XoopsSimpleForm({$caption}, '{$var}', '{$filename}.php', '{$type}');\n"; if (!empty($elementsContent)) { @@ -125,12 +122,12 @@ public function getXoopsSimpleForm($left = '', $element = '', $elementsContent = * @param null $param2 * @param null $param3 * @param null $param4 - * @param bool $isParam + * @param bool $isParam * @param string $t * * @return string */ - public function getClassXoopsThemeForm($var, $param1, $param2 = null, $param3 = null, $param4 = null, $isParam = false, $t = "\t\t") + public function getClassXoopsThemeForm($var, $param1, $param2 = null, $param3 = null, $param4 = null, bool $isParam = false, string $t = "\t\t") { $themeForm = 'new \XoopsThemeForm('; if (false === $isParam) { @@ -152,7 +149,7 @@ public function getClassXoopsThemeForm($var, $param1, $param2 = null, $param3 = * * @return string */ - public function getClassXoopsFormElementTray($var, $param1, $param2 = '', $t = "\t\t") + public function getClassXoopsFormElementTray($var, $param1, string $param2 = '', string $t = "\t\t") { return "{$t}\${$var} = new \XoopsFormElementTray({$param1}, '{$param2}');\n"; } @@ -163,13 +160,13 @@ public function getClassXoopsFormElementTray($var, $param1, $param2 = '', $t = " * @param $var * @param string $param1 * @param null $param2 - * @param bool $isParam + * @param bool $isParam * @param string $t * - * @param bool $useParam + * @param bool $useParam * @return string */ - public function getClassXoopsFormLabel($var, $param1 = '', $param2 = null, $isParam = false, $t = "\t\t", $useParam = false) + public function getClassXoopsFormLabel($var, string $param1 = '', $param2 = null, bool $isParam = false, string $t = "\t\t", bool $useParam = false) { $label = 'new \XoopsFormLabel('; if (false === $useParam) { @@ -193,12 +190,12 @@ public function getClassXoopsFormLabel($var, $param1 = '', $param2 = null, $isPa * @param $param1 * @param $param2 * @param $param3 - * @param bool $isParam + * @param bool $isParam * @param string $t * * @return string */ - public function getClassXoopsFormFile($var, $param1, $param2, $param3, $isParam = false, $t = "\t\t") + public function getClassXoopsFormFile($var, $param1, $param2, $param3, bool $isParam = false, string $t = "\t\t") { $file = 'new \XoopsFormFile('; if (false === $isParam) { @@ -216,14 +213,14 @@ public function getClassXoopsFormFile($var, $param1, $param2, $param3, $isParam * @param $var * @param $param1 * @param $param2 - * @param bool $isForm - * @param bool $isParam + * @param bool $isForm + * @param bool $isParam * @param string $t * - * @param bool $useParam + * @param bool $useParam * @return string */ - public function getClassXoopsFormHidden($var, $param1, $param2, $isForm = false, $isParam = false, $t = "\t\t", $useParam = false) + public function getClassXoopsFormHidden($var, $param1, $param2, bool $isForm = false, bool $isParam = false, string $t = "\t\t", bool $useParam = false) { $hidden = 'new \XoopsFormHidden('; $getVarHidden = Modulebuilder\Files\CreateXoopsCode::getInstance()->getXcGetVar('', 'this', $param2, true); @@ -251,15 +248,15 @@ public function getClassXoopsFormHidden($var, $param1, $param2, $isForm = false, * @param $var * @param $param1 * @param $param2 - * @param int $param3 - * @param int $param4 + * @param int $param3 + * @param int $param4 * @param $param5 - * @param bool $isParam + * @param bool $isParam * @param string $t * * @return string */ - public function getClassXoopsFormText($var, $param1, $param2, $param3, $param4, $param5, $isParam = false, $t = "\t\t") + public function getClassXoopsFormText($var, $param1, $param2, int $param3, int $param4, $param5, bool $isParam = false, string $t = "\t\t") { $text = 'new \XoopsFormText('; if (false === $isParam) { @@ -279,12 +276,12 @@ public function getClassXoopsFormText($var, $param1, $param2, $param3, $param4, * @param $param2 * @param $param3 * @param $param4 - * @param bool $isParam + * @param bool $isParam * @param string $t * * @return string */ - public function getClassXoopsFormTextArea($var, $param1, $param2, $param3, $param4, $isParam = false, $t = "\t\t") + public function getClassXoopsFormTextArea($var, $param1, $param2, $param3, $param4, bool $isParam = false, string $t = "\t\t") { $area = 'new \XoopsFormTextArea('; $getVarTextArea = Modulebuilder\Files\CreateXoopsCode::getInstance()->getXcGetVar('', 'this', $param2, true, '', ", 'e'"); @@ -304,12 +301,12 @@ public function getClassXoopsFormTextArea($var, $param1, $param2, $param3, $para * @param $param1 * @param $param2 * @param $param3 - * @param bool $isParam + * @param bool $isParam * @param string $t * * @return string */ - public function getClassXoopsFormColorPicker($var, $param1, $param2, $param3, $isParam = false, $t = "\t\t") + public function getClassXoopsFormColorPicker($var, $param1, $param2, $param3, bool $isParam = false, string $t = "\t\t") { $picker = 'new \XoopsFormColorPicker('; if (false === $isParam) { @@ -329,12 +326,12 @@ public function getClassXoopsFormColorPicker($var, $param1, $param2, $param3, $i * @param $param2 * @param string $param3 * @param $ccFieldName - * @param bool $isParam + * @param bool $isParam * @param string $t * * @return string */ - public function getClassXoopsFormSelectUser($var, $param1, $param2, $param3, $ccFieldName, $isParam = false, $t = "\t\t") + public function getClassXoopsFormSelectUser($var, $param1, $param2, string $param3, $ccFieldName, bool $isParam = false, string $t = "\t\t") { $user = 'new \XoopsFormSelectUser('; //$getVarSelectUser = Modulebuilder\Files\CreateXoopsCode::getInstance()->getXcGetVar('', 'this', $param4, true); @@ -355,12 +352,12 @@ public function getClassXoopsFormSelectUser($var, $param1, $param2, $param3, $cc * @param $param2 * @param string $param3 * @param $param4 - * @param bool $isParam + * @param bool $isParam * @param string $t * * @return string */ - public function getClassXoopsFormTextDateSelect($var, $param1, $param2, $param3, $param4, $isParam = false, $t = "\t\t") + public function getClassXoopsFormTextDateSelect($var, $param1, $param2, string $param3, $param4, bool $isParam = false, string $t = "\t\t") { $tdate = 'new \XoopsFormTextDateSelect('; $getVarTextDateSelect = Modulebuilder\Files\CreateXoopsCode::getInstance()->getXcGetVar('', 'this', $param3, true); @@ -381,12 +378,12 @@ public function getClassXoopsFormTextDateSelect($var, $param1, $param2, $param3, * @param $param2 * @param string $param3 * @param $param4 - * @param bool $isParam + * @param bool $isParam * @param string $t * * @return string */ - public function getClassXoopsFormDateTime($var, $param1, $param2, $param3, $param4, $isParam = false, $t = "\t\t") + public function getClassXoopsFormDateTime($var, $param1, $param2, string $param3, $param4, bool $isParam = false, string $t = "\t\t") { $tdate = 'new \XoopsFormDateTime('; $getVarTextDateSelect = Modulebuilder\Files\CreateXoopsCode::getInstance()->getXcGetVar('', 'this', $param3, true); @@ -406,12 +403,12 @@ public function getClassXoopsFormDateTime($var, $param1, $param2, $param3, $para * @param $param1 * @param $param2 * @param $param3 - * @param bool $isParam + * @param bool $isParam * @param string $t * * @return string */ - public function getClassXoopsFormEditor($var, $param1, $param2, $param3, $isParam = false, $t = "\t\t") + public function getClassXoopsFormEditor($var, $param1, $param2, $param3, bool $isParam = false, string $t = "\t\t") { $editor = 'new \XoopsFormEditor('; if (false === $isParam) { @@ -430,12 +427,12 @@ public function getClassXoopsFormEditor($var, $param1, $param2, $param3, $isPara * @param $param1 * @param $param2 * @param $param3 - * @param bool $isParam + * @param bool $isParam * @param string $t * * @return string */ - public function getClassXoopsFormCheckBox($var, $param1, $param2, $param3, $isParam = false, $t = "\t\t") + public function getClassXoopsFormCheckBox($var, $param1, $param2, $param3, bool $isParam = false, string $t = "\t\t") { $checkBox = 'new \XoopsFormCheckBox('; if (false === $isParam) { @@ -454,12 +451,12 @@ public function getClassXoopsFormCheckBox($var, $param1, $param2, $param3, $isPa * @param $param1 * @param $param2 * @param $param3 - * @param bool $isParam + * @param bool $isParam * @param string $t * * @return string */ - public function getClassXoopsFormRadioYN($var, $param1, $param2, $param3, $isParam = false, $t = "\t\t") + public function getClassXoopsFormRadioYN($var, $param1, $param2, $param3, bool $isParam = false, string $t = "\t\t") { $radioYN = 'new \XoopsFormRadioYN('; if (false === $isParam) { @@ -478,12 +475,12 @@ public function getClassXoopsFormRadioYN($var, $param1, $param2, $param3, $isPar * @param $param1 * @param $param2 * @param $param3 - * @param bool $isParam + * @param bool $isParam * @param string $t * * @return string */ - public function getClassXoopsFormRadio($var, $param1, $param2, $param3, $isParam = false, $t = "\t\t") + public function getClassXoopsFormRadio($var, $param1, $param2, $param3, bool $isParam = false, string $t = "\t\t") { $radioYN = 'new \XoopsFormRadio('; if (false === $isParam) { @@ -504,12 +501,12 @@ public function getClassXoopsFormRadio($var, $param1, $param2, $param3, $isParam * @param $param3 * @param null $param4 * @param null $param5 - * @param bool $isParam + * @param bool $isParam * @param string $t * * @return string */ - public function getClassXoopsFormSelect($var, $param1, $param2, $param3, $param4 = null, $param5 = null, $isParam = false, $t = "\t\t") + public function getClassXoopsFormSelect($var, $param1, $param2, $param3, $param4 = null, $param5 = null, bool $isParam = false, string $t = "\t\t") { $otherParam = null != $param4 ? ", {$param4}" : (null != $param5 ? ", {$param5}" : ''); $select = 'new \XoopsFormSelect('; @@ -530,13 +527,13 @@ public function getClassXoopsFormSelect($var, $param1, $param2, $param3, $param4 * @param $param2 * @param $param3 * @param $param4 - * @param int $param5 - * @param bool $isParam + * @param int $param5 + * @param bool $isParam * @param string $t * * @return string */ - public function getClassXoopsFormTag($var, $param1, $param2, $param3, $param4, $param5 = 0, $isParam = false, $t = "\t\t") + public function getClassXoopsFormTag($var, $param1, $param2, $param3, $param4, int $param5 = 0, bool $isParam = false, string $t = "\t\t") { $tag = 'new \XoopsFormTag('; if (false === $isParam) { @@ -556,12 +553,12 @@ public function getClassXoopsFormTag($var, $param1, $param2, $param3, $param4, $ * @param $param2 * @param $param3 * @param $param4 - * @param bool $isParam + * @param bool $isParam * @param string $t * * @return string */ - public function getClassXoopsFormButton($var, $param1, $param2, $param3, $param4, $isParam = false, $t = "\t\t") + public function getClassXoopsFormButton($var, $param1, $param2, $param3, $param4, bool $isParam = false, string $t = "\t\t") { $button = 'new \XoopsFormButton('; if (false === $isParam) { @@ -576,17 +573,17 @@ public function getClassXoopsFormButton($var, $param1, $param2, $param3, $param4 /** * @public function getClassXoopsFormPassword * - * @param $var - * @param $param1 - * @param $param2 + * @param string $var + * @param string $param1 + * @param string $param2 * @param string $param3 - * @param $param4 - * @param bool $isParam + * @param string $param4 + * @param bool $isParam * @param string $t * * @return string */ - public function getClassXoopsFormPassword($var, $param1, $param2, $param3, $param4, $isParam = false, $t = "\t\t") + public function getClassXoopsFormPassword(string $var, string $param1, string $param2, string $param3, string $param4, bool $isParam = false, string $t = "\t\t") { $tpassword = 'new \XoopsFormPassword('; $getVarPassword = Modulebuilder\Files\CreateXoopsCode::getInstance()->getXcGetVar('', 'this', $param3, true); @@ -608,12 +605,12 @@ public function getClassXoopsFormPassword($var, $param1, $param2, $param3, $para * @param $param3 * @param null $param4 * @param null $param5 - * @param bool $isParam + * @param bool $isParam * @param string $t * * @return string */ - public function getClassXoopsFormSelectCountry($var, $param1, $param2, $param3, $param4 = null, $param5 = null, $isParam = false, $t = "\t\t") + public function getClassXoopsFormSelectCountry($var, $param1, $param2, $param3, $param4 = null, $param5 = null, bool $isParam = false, string $t = "\t\t") { $otherParam = null != $param4 ? ", {$param4}" : (null != $param5 ? ", {$param5}" : ''); $select = 'new \XoopsFormSelectCountry('; @@ -637,11 +634,9 @@ public function getClassXoopsFormSelectCountry($var, $param1, $param2, $param3, * * @return string */ - public function getClassXoopsObjectTree($var, $param1, $param2, $param3, $t = '') + public function getClassXoopsObjectTree(string $var, $param1, $param2, $param3, string $t = '') { - $ret = "{$t}\${$var} = new \XoopsObjectTree(\${$param1}, '{$param2}', '{$param3}');\n"; - - return $ret; + return "{$t}\${$var} = new \XoopsObjectTree(\${$param1}, '{$param2}', '{$param3}');\n"; } /** @@ -657,12 +652,10 @@ public function getClassXoopsObjectTree($var, $param1, $param2, $param3, $t = '' * * @return string */ - public function getClassXoopsMakeSelBox($var, $anchor, $param1, $param2, $param3, $param4, $t = '') + public function getClassXoopsMakeSelBox($var, $anchor, $param1, $param2, string $param3, $param4, string $t = '') { $getVar = Modulebuilder\Files\CreateXoopsCode::getInstance()->getXcGetVar('', 'this', $param4, true); - $ret = "{$t}\${$var} = \${$anchor}->makeSelBox('{$param1}', '{$param2}', '{$param3}', {$getVar}, true );\n"; - - return $ret; + return "{$t}\${$var} = \${$anchor}->makeSelBox('{$param1}', '{$param2}', '{$param3}', {$getVar}, true );\n"; } /** @@ -674,7 +667,7 @@ public function getClassXoopsMakeSelBox($var, $anchor, $param1, $param2, $param3 * * @return string */ - public function getClassAddOption($var, $params, $t = "\t\t") + public function getClassAddOption($var, $params, string $t = "\t\t") { return "{$t}\${$var}->addOption({$params});\n"; } @@ -688,7 +681,7 @@ public function getClassAddOption($var, $params, $t = "\t\t") * * @return string */ - public function getClassAddOptionArray($var, $params, $t = "\t\t") + public function getClassAddOptionArray($var, $params, string $t = "\t\t") { return "{$t}\${$var}->addOptionArray({$params});\n"; } @@ -702,7 +695,7 @@ public function getClassAddOptionArray($var, $params, $t = "\t\t") * * @return string */ - public function getClassAddElement($var = '', $params = '', $t = "\t\t") + public function getClassAddElement(string $var = '', string $params = '', string $t = "\t\t") { return "{$t}\${$var}->addElement({$params});\n"; } @@ -716,7 +709,7 @@ public function getClassAddElement($var = '', $params = '', $t = "\t\t") * * @return string */ - public function getClassSetDescription($var, $params, $t = "\t\t") + public function getClassSetDescription($var, $params, string $t = "\t\t") { return "{$t}\${$var}->setDescription({$params});\n"; } @@ -730,7 +723,7 @@ public function getClassSetDescription($var, $params, $t = "\t\t") * * @return string */ - public function getClassSetExtra($var, $params, $t = "\t\t") + public function getClassSetExtra($var, $params, string $t = "\t\t") { return "{$t}\${$var}->setExtra({$params});\n"; } diff --git a/class/Files/Config/ConfigConfig.php b/class/Files/Config/ConfigConfig.php index 6037fef8..f1954043 100644 --- a/class/Files/Config/ConfigConfig.php +++ b/class/Files/Config/ConfigConfig.php @@ -42,7 +42,6 @@ class ConfigConfig extends Files\CreateFile /** * @public function constructor - * @param null */ public function __construct() { @@ -67,11 +66,11 @@ public static function getInstance() /** * @public function write - * @param string $module + * @param $module * @param $tables * @param string $filename */ - public function write($module, $tables, $filename): void + public function write($module, $tables, string $filename): void { $this->setModule($module); $this->setTables($tables); @@ -141,7 +140,7 @@ private function getConfigCode() $ret .= $this->getSimpleString('],', "\t"); $ret .= $this->getSimpleString("'moduleStats' => [", "\t"); $ret .= $this->getSimpleString('],', "\t"); - $ret .= $this->getSimpleString("'modCopyright' => \"XOOPS Project\",", "\t"); + $ret .= $this->getSimpleString("'modCopyright' => \"XOOPS Project\",", "\t"); $ret .= $this->getSimpleString('];'); return $ret; @@ -149,8 +148,8 @@ private function getConfigCode() /** * @public function render - * @param null - * @return bool|string + * + * @return string */ public function render() { diff --git a/class/Files/CreateAbstractClass.php b/class/Files/CreateAbstractClass.php index 3d3102a6..bb0ea06a 100644 --- a/class/Files/CreateAbstractClass.php +++ b/class/Files/CreateAbstractClass.php @@ -62,7 +62,7 @@ abstract class CreateAbstractClass */ public function setModule($module): void { - if (\is_object($module) && ($module instanceof ModuleBuilder\Modules)) { + if (($module instanceof ModuleBuilder\Modules)) { $this->module = $module; } } @@ -84,7 +84,7 @@ public function getModule() */ public function setTable($table): void { - if (\is_object($table) && ($table instanceof Modulebuilder\Tables)) { + if (($table instanceof Modulebuilder\Tables)) { $this->table = $table; } } @@ -128,7 +128,7 @@ public function getTables() */ public function setFields($fields): void { - if (\is_object($fields) && ($fields instanceof Modulebuilder\Fields)) { + if (($fields instanceof Modulebuilder\Fields)) { $this->fields = $fields; } } diff --git a/class/Files/CreateArchitecture.php b/class/Files/CreateArchitecture.php index 80ee51ce..0facd6c5 100644 --- a/class/Files/CreateArchitecture.php +++ b/class/Files/CreateArchitecture.php @@ -51,7 +51,6 @@ class CreateArchitecture extends CreateStructure /** * @public function constructor - * @param null */ public function __construct() { @@ -64,8 +63,6 @@ public function __construct() /** * @static function getInstance * - * @param null - * * @return Modulebuilder\Files\CreateArchitecture */ public static function getInstance() @@ -156,8 +153,6 @@ public function setBaseFoldersFiles($module): void if (!\file_exists($logoGifFrom)) { // Rename file $copyFile = TDMC_IMAGES_LOGOS_URL . '/xoopsdevelopmentteam_logo.gif'; - $copyNewFile = $logoGifFrom; - \copy($copyFile, $copyNewFile); } else { // Copy file if (!\file_exists($logoPng)) { @@ -165,9 +160,9 @@ public function setBaseFoldersFiles($module): void $logoGifFrom = TDMC_UPLOAD_IMGMOD_PATH . '/' . $logoPng; } $copyFile = TDMC_IMAGES_LOGOS_URL . '/' . $logoPng; - $copyNewFile = $logoGifFrom; - \copy($copyFile, $copyNewFile); } + $copyNewFile = $logoGifFrom; + \copy($copyFile, $copyNewFile); // Creation of 'module_author_logo.gif' file $this->copyFile('assets/images', $copyNewFile, $logoPng); @@ -207,7 +202,7 @@ public function setBaseFoldersFiles($module): void /** * @public function setFilesToBuilding * - * @param string $module + * @param $module * * @return array */ @@ -220,7 +215,7 @@ public function setFilesToBuilding($module) $tables = $this->cf->getTableTables($modId); $files = $this->cf->getTableMorefiles($modId); $ret = []; - $templateType = 'defstyle'; + $templateType = 'defstyle'; // currently no other template style is implemented $patterns = [ \mb_strtolower('modulebuilder') => \mb_strtolower($moduleDirname), @@ -231,9 +226,9 @@ public function setFilesToBuilding($module) $this->patValues = \array_values($patterns); $table = null; - $tableCategory = []; + //$tableCategory = []; //$tableName = []; - $tableAdmin = []; + //$tableAdmin = []; $tableUser = []; $tableBlocks = []; $tableSearch = []; @@ -246,17 +241,17 @@ public function setFilesToBuilding($module) $tablePrint = []; $tableRate = []; $tableRss = []; - $tableSingle = []; - $tableSubmit = []; - $tableVisit = []; + //$tableSingle = []; + //$tableSubmit = []; + //$tableVisit = []; $tableTag = []; foreach (\array_keys($tables) as $t) { $tableId = $tables[$t]->getVar('table_id'); $tableName = $tables[$t]->getVar('table_name'); $tableSoleName = $tables[$t]->getVar('table_solename'); - $tableCategory[] = $tables[$t]->getVar('table_category'); + //$tableCategory[] = $tables[$t]->getVar('table_category'); $tableImage = $tables[$t]->getVar('table_image'); - $tableAdmin[] = $tables[$t]->getVar('table_admin'); + //$tableAdmin[] = $tables[$t]->getVar('table_admin'); $tableUser[] = $tables[$t]->getVar('table_user'); $tableBlocks[] = $tables[$t]->getVar('table_blocks'); $tableSearch[] = $tables[$t]->getVar('table_search'); @@ -269,9 +264,9 @@ public function setFilesToBuilding($module) $tablePrint[] = $tables[$t]->getVar('table_print'); $tableRate[] = $tables[$t]->getVar('table_rate'); $tableRss[] = $tables[$t]->getVar('table_rss'); - $tableSingle[] = $tables[$t]->getVar('table_single'); - $tableSubmit[] = $tables[$t]->getVar('table_submit'); - $tableVisit[] = $tables[$t]->getVar('table_visit'); + //$tableSingle[] = $tables[$t]->getVar('table_single'); + //$tableSubmit[] = $tables[$t]->getVar('table_submit'); + //$tableVisit[] = $tables[$t]->getVar('table_visit'); $tableTag[] = $tables[$t]->getVar('table_tag'); // Get Table Object @@ -301,11 +296,11 @@ public function setFilesToBuilding($module) $blocksFiles->write($module, $table, $tableName . '.php'); $ret[] = $blocksFiles->render(); // Templates Blocks Files - if ($templateType == 'bootstrap') { +/* if ($templateType == 'bootstrap') { $templatesBlocks = Modulebuilder\Files\Templates\Blocks\Bootstrap\TemplatesBlocks::getInstance(); - } else { + } else {*/ $templatesBlocks = Modulebuilder\Files\Templates\Blocks\Defstyle\TemplatesBlocks::getInstance(); - } + /*}*/ $templatesBlocks->write($module, $table, $moduleDirname . '_block_' . $tableName . '.tpl'); $ret[] = $templatesBlocks->render(); // Spotlight block @@ -314,11 +309,11 @@ public function setFilesToBuilding($module) $blocksFiles->write($module, $table, $tableName . '_spotlight.php'); $ret[] = $blocksFiles->render(); // Templates Blocks Files - if ($templateType == 'bootstrap') { +/* if ($templateType == 'bootstrap') { $templatesBlocks = Modulebuilder\Files\Templates\Blocks\Bootstrap\TemplatesBlocksSpotlight::getInstance(); - } else { + } else {*/ $templatesBlocks = Modulebuilder\Files\Templates\Blocks\Defstyle\TemplatesBlocksSpotlight::getInstance(); - } + /*}*/ $templatesBlocks->write($module, $table, $moduleDirname . '_block_' . $tableName . '_spotlight.tpl'); $ret[] = $templatesBlocks->render(); } @@ -343,27 +338,27 @@ public function setFilesToBuilding($module) $userPages->write($module, $table, $tableName . '.php'); $ret[] = $userPages->render(); // User Templates File - if ($templateType == 'bootstrap') { +/* if ($templateType == 'bootstrap') { $userTemplatesPages = Modulebuilder\Files\Templates\User\Bootstrap\Pages::getInstance(); - } else { + } else {*/ $userTemplatesPages = Modulebuilder\Files\Templates\User\Defstyle\Pages::getInstance(); - } + /*}*/ $userTemplatesPages->write($module, $table, $moduleDirname . '_' . $tableName . '.tpl'); $ret[] = $userTemplatesPages->render(); // User List Templates File - if ($templateType == 'bootstrap') { +/* if ($templateType == 'bootstrap') { $userTemplatesPagesList = Modulebuilder\Files\Templates\User\Bootstrap\PagesList::getInstance(); - } else { + } else {*/ $userTemplatesPagesList = Modulebuilder\Files\Templates\User\Defstyle\PagesList::getInstance(); - } + /*}*/ $userTemplatesPagesList->write($module, $table, $tables, $moduleDirname . '_' . $tableName . '_list' . '.tpl'); $ret[] = $userTemplatesPagesList->render(); // User Item Templates File - if ($templateType == 'bootstrap') { +/* if ($templateType == 'bootstrap') { $userTemplatesPagesItem = Modulebuilder\Files\Templates\User\Bootstrap\PagesItem::getInstance(); - } else { + } else {*/ $userTemplatesPagesItem = Modulebuilder\Files\Templates\User\Defstyle\PagesItem::getInstance(); - } + /*}*/ $userTemplatesPagesItem->write($module, $table, $tables, $moduleDirname . '_' . $tableName . '_item' . '.tpl'); $ret[] = $userTemplatesPagesItem->render(); if (1 === (int)$tables[$t]->getVar('table_category')) { @@ -591,6 +586,11 @@ public function setFilesToBuilding($module) if (\in_array(1, $tableComments)) { // Include Comments File $includeComments = Modulebuilder\Files\Includes\IncludeComments::getInstance(); + foreach (\array_keys($tables) as $t) { + if (1 == (int)$tables[$t]->getVar('table_comments')) { + $table = $tables[$t]; + } + } $includeComments->write($module, $table); $ret[] = $includeComments->renderCommentsIncludes($module, 'comment_edit'); // Include Comments File @@ -618,27 +618,27 @@ public function setFilesToBuilding($module) if ((1 == $module->getVar('mod_user')) && \in_array(1, $tableUser)) { // Creation of user template files // Templates Index File - if ($templateType == 'bootstrap') { +/* if ($templateType == 'bootstrap') { $userTemplatesIndex = Modulebuilder\Files\Templates\User\Bootstrap\Index::getInstance(); - } else { + } else {*/ $userTemplatesIndex = Modulebuilder\Files\Templates\User\Defstyle\Index::getInstance(); - } + /*}*/ $userTemplatesIndex->write($module, $table, $tables, $moduleDirname . '_index.tpl'); $ret[] = $userTemplatesIndex->render(); // Templates Footer File - if ($templateType == 'bootstrap') { +/* if ($templateType == 'bootstrap') { $userTemplatesFooter = Modulebuilder\Files\Templates\User\Bootstrap\Footer::getInstance(); - } else { + } else {*/ $userTemplatesFooter = Modulebuilder\Files\Templates\User\Defstyle\Footer::getInstance(); - } + /*}*/ $userTemplatesFooter->write($module, $table, $moduleDirname . '_footer.tpl'); $ret[] = $userTemplatesFooter->render(); // Templates Header File - if ($templateType == 'bootstrap') { +/* if ($templateType == 'bootstrap') { $userTemplatesHeader = Modulebuilder\Files\Templates\User\Bootstrap\Header::getInstance(); - } else { + } else {*/ $userTemplatesHeader = Modulebuilder\Files\Templates\User\Defstyle\Header::getInstance(); - } + /*}*/ $userTemplatesHeader->write($module, $moduleDirname . '_header.tpl'); $ret[] = $userTemplatesHeader->render(); @@ -666,11 +666,11 @@ public function setFilesToBuilding($module) $userPdf->write($module, $table, $tableName . '_pdf.php'); $ret[] = $userPdf->render(); // User Templates Pdf File - if ($templateType == 'bootstrap') { + /*if ($templateType == 'bootstrap') { $userTemplatesPdf = Modulebuilder\Files\Templates\User\Bootstrap\Pdf::getInstance(); - } else { + } else {*/ $userTemplatesPdf = Modulebuilder\Files\Templates\User\Defstyle\Pdf::getInstance(); - } + /*}*/ $userTemplatesPdf->write($module, $table, $moduleDirname . '_' . $tableName . '_pdf.tpl'); $ret[] = $userTemplatesPdf->render(); } @@ -685,11 +685,11 @@ public function setFilesToBuilding($module) $userPrint->write($module, $table, $tableName . '_print.php'); $ret[] = $userPrint->render(); // User Templates Print File - if ($templateType == 'bootstrap') { + /*if ($templateType == 'bootstrap') { $userTemplatesPrint = Modulebuilder\Files\Templates\User\Bootstrap\UserPrint::getInstance(); - } else { + } else {*/ $userTemplatesPrint = Modulebuilder\Files\Templates\User\Defstyle\UserPrint::getInstance(); - } + /*}*/ $userTemplatesPrint->write($module, $table, $moduleDirname . '_' . $tableName . '_print.tpl'); $ret[] = $userTemplatesPrint->render(); } @@ -714,11 +714,11 @@ public function setFilesToBuilding($module) $userRss->write($module, $table, 'rss.php'); $ret[] = $userRss->render(); // User Templates Rss File - if ($templateType == 'bootstrap') { + /*if ($templateType == 'bootstrap') { $userTemplatesRss = Modulebuilder\Files\Templates\User\Bootstrap\Rss::getInstance(); - } else { + } else {*/ $userTemplatesRss = Modulebuilder\Files\Templates\User\Defstyle\Rss::getInstance(); - } + /*}*/ $userTemplatesRss->write($module, $moduleDirname . '_rss.tpl'); $ret[] = $userTemplatesRss->render(); } @@ -741,11 +741,11 @@ public function setFilesToBuilding($module) $languageMain->write($module, $tables, 'main.php'); $ret[] = $languageMain->render(); // User Templates Breadcrumbs File - if ($templateType == 'bootstrap') { + /*if ($templateType == 'bootstrap') { $userTemplatesUserBreadcrumbs = Modulebuilder\Files\Templates\User\Bootstrap\Breadcrumbs::getInstance(); - } else { + } else {*/ $userTemplatesUserBreadcrumbs = Modulebuilder\Files\Templates\User\Defstyle\Breadcrumbs::getInstance(); - } + /*}*/ $userTemplatesUserBreadcrumbs->write($module, $moduleDirname . '_breadcrumbs.tpl'); $ret[] = $userTemplatesUserBreadcrumbs->render(); } diff --git a/class/Files/CreateClone.php b/class/Files/CreateClone.php index 7205ac17..91fae5c7 100644 --- a/class/Files/CreateClone.php +++ b/class/Files/CreateClone.php @@ -31,11 +31,11 @@ class CreateClone /** * @param $src_path * @param $dst_path - * @param bool $replace_code + * @param bool $replace_code * @param array $patKeys * @param array $patValues */ - public static function cloneFileFolder($src_path, $dst_path, $replace_code = false, $patKeys = [], $patValues = []): void + public static function cloneFileFolder($src_path, $dst_path, bool $replace_code = false, array $patKeys = [], array $patValues = []): void { // open the source directory $dir = \opendir($src_path); @@ -58,11 +58,11 @@ public static function cloneFileFolder($src_path, $dst_path, $replace_code = fal /** * @param $src_file * @param $dst_file - * @param bool $replace_code + * @param bool $replace_code * @param array $patKeys * @param array $patValues */ - public static function cloneFile($src_file, $dst_file, $replace_code = false, $patKeys = [], $patValues = []): void + public static function cloneFile($src_file, $dst_file, bool $replace_code = false, array $patKeys = [], array $patValues = []): void { if ($replace_code) { $noChangeExtensions = ['jpeg', 'jpg', 'gif', 'png', 'zip', 'ttf']; diff --git a/class/Files/CreateCodeIndents.php b/class/Files/CreateCodeIndents.php index 545232b5..6f95e1cf 100644 --- a/class/Files/CreateCodeIndents.php +++ b/class/Files/CreateCodeIndents.php @@ -8,14 +8,9 @@ * * @return string */ -function nl($tabs = 0) +function nl(int $tabs = 0) { - $r = "\n"; - for ($i = 0; $i < $tabs; ++$i) { - $r .= ' '; - } - - return $r; + return "\n" . str_repeat(' ', $tabs); } /* Usage example */ diff --git a/class/Files/CreateFile.php b/class/Files/CreateFile.php index 67a86164..50f9b95b 100644 --- a/class/Files/CreateFile.php +++ b/class/Files/CreateFile.php @@ -84,7 +84,6 @@ class CreateFile extends CreateTableFields /** * @public function constructor - * @param null */ public function __construct() { @@ -94,7 +93,7 @@ public function __construct() /** * @public static function getInstance - * @param null + * * @return Modulebuilder\Files\CreateFile */ public static function getInstance() @@ -113,12 +112,12 @@ public static function getInstance() * @param $moduleDirname * @param $subdir * @param $fileName - * @param $content + * @param string $content * @param $created * @param $notCreated - * @param $mode + * @param string $mode */ - public function create($moduleDirname, $subdir = null, $fileName = null, $content = '', $created = null, $notCreated = null, $mode = 'w+'): void + public function create($moduleDirname, $subdir = null, $fileName = null, string $content = '', $created = null, $notCreated = null, string $mode = 'w+'): void { $this->setFileName($fileName); $this->created = $created; @@ -147,14 +146,14 @@ public function create($moduleDirname, $subdir = null, $fileName = null, $conten * @private function setRepositoryPath * @param string $moduleDirname */ - private function setRepositoryPath($moduleDirname): void + private function setRepositoryPath(string $moduleDirname): void { $this->uploadPath = TDMC_UPLOAD_REPOSITORY_PATH . '/' . $moduleDirname; } /** * @private function getRepositoryPath - * @param null + * * @return string */ private function getRepositoryPath() @@ -173,7 +172,7 @@ private function setSubDir($subdir): void /** * @private function getSubDir - * @param null + * * @return string */ private function getSubDir() @@ -193,7 +192,7 @@ public function setFileName($fileName): void /** * @public function getFileName - * @param null + * * @return mixed */ public function getFileName() @@ -213,7 +212,7 @@ private function setContent($content): void /** * @private function setContent - * @param null + * * @return string */ private function getContent() @@ -223,7 +222,7 @@ private function getContent() /** * @private function getFolderName - * @param null + * * @return string */ private function getFolderName() @@ -243,7 +242,7 @@ private function getFolderName() /** * @public function getUploadPath - * @param null + * * @return string */ private function getUploadPath() @@ -259,7 +258,7 @@ private function getUploadPath() /** * @private function getCreated - * @param null + * * @return bool */ private function getCreated() @@ -269,7 +268,7 @@ private function getCreated() /** * @private function getNotCreated - * @param null + * * @return bool */ private function getNotCreated() @@ -288,7 +287,7 @@ private function setMode($mode): void /** * @private function getMode - * @param null + * * @return string */ private function getMode() @@ -301,10 +300,10 @@ private function getMode() * @param string $moduleDirname * @param string $prefix * @param string $suffix - * @param bool $addFq //add function qualifier + * @param bool $addFq //add function qualifier * @return string */ - public function getLanguage($moduleDirname, $prefix = '', $suffix = '', $addFq = true) + public function getLanguage(string $moduleDirname, string $prefix = '', string $suffix = '', bool $addFq = true) { $lang = ''; if ($addFq) { @@ -327,7 +326,7 @@ public function getLanguage($moduleDirname, $prefix = '', $suffix = '', $addFq = * * @return string */ - public function getLeftString($string) + public function getLeftString(string $string) { $ret = ''; if ('' != $string) { @@ -348,9 +347,7 @@ public function getRightString($string = null) if (\mb_strpos($string, '_')) { $str = \mb_strpos($string, '_'); if (false !== $str) { - $ret = \mb_substr($string, $str + 1, \mb_strlen($string)); - - return $ret; + return \mb_substr($string, $str + 1, \mb_strlen($string)); } } } @@ -361,12 +358,12 @@ public function getRightString($string = null) /** * @public function getCamelCase * @param $string - * @param $ucfirst - * @param $lcfirst + * @param bool $ucfirst + * @param bool $lcfirst * * @return string */ - public function getCamelCase($string, $ucfirst = false, $lcfirst = false) + public function getCamelCase($string, bool $ucfirst = false, bool $lcfirst = false) { $rightString = $this->getRightString($string); $leftString = $this->getLeftString($string); @@ -442,20 +439,20 @@ public function getStrToLower($string) /** * @public function getRequire - * @param $filename + * @param string $filename * @return string */ - public function getRequire($filename = 'header') + public function getRequire(string $filename = 'header') { return "require __DIR__ . '/{$filename}.php';\n"; } /** * @public function getRequireOnce - * @param $filename + * @param string $filename * @return string */ - public function getRequireOnce($filename = 'header') + public function getRequireOnce(string $filename = 'header') { return "require_once __DIR__ . '/{$filename}.php';\n"; } @@ -479,20 +476,20 @@ public function getDashComment($comment) * @param string $t * @return string */ - public function getSimpleString($string, $t = '') + public function getSimpleString($string, string $t = '') { return "{$t}{$string}\n"; } /** * @public function getHeaderFilesComments - * @param string $module + * @param $module * @param $noPhpFile * * @param string $namespace * @return string */ - public function getHeaderFilesComments($module, $noPhpFile = null, $namespace = '') + public function getHeaderFilesComments($module, $noPhpFile = null, string $namespace = '') { $pc = Modulebuilder\Files\CreatePhpCode::getInstance(); $name = $module->getVar('mod_name'); @@ -548,7 +545,7 @@ public function getHeaderFilesComments($module, $noPhpFile = null, $namespace = /** * @public function renderFile - * @param null + * * @return string */ public function renderFile() diff --git a/class/Files/CreateHtmlCode.php b/class/Files/CreateHtmlCode.php index f867c06a..fb1a2b05 100644 --- a/class/Files/CreateHtmlCode.php +++ b/class/Files/CreateHtmlCode.php @@ -33,8 +33,6 @@ class CreateHtmlCode /** * @static function getInstance * - * @param null - * * @return CreateHtmlCode */ public static function getInstance() @@ -50,15 +48,15 @@ public static function getInstance() /** * @public function getHtmlTag * @param string $tag - * @param array $attributes + * @param array $attributes * @param string $content - * @param bool $noClosed + * @param bool $noClosed * @param string $t * @param string $n - * @param bool $multiLine + * @param bool $multiLine * @return string */ - public function getHtmlTag($tag = '', $attributes = [], $content = '', $noClosed = false, $t = '', $n = "\n", $multiLine = false) + public function getHtmlTag(string $tag = '', array $attributes = [], string $content = '', bool $noClosed = false, string $t = '', string $n = "\n", bool $multiLine = false) { if (empty($attributes)) { $attributes = []; @@ -88,7 +86,7 @@ public function getHtmlTag($tag = '', $attributes = [], $content = '', $noClosed * @param array $attributes * @return string */ - private function getAttributes($attributes) + private function getAttributes(array $attributes) { $str = ''; foreach ($attributes as $name => $value) { @@ -107,7 +105,7 @@ private function getAttributes($attributes) * @param string $n * @return string */ - public function getHtmlEmpty($empty = '', $t = '', $n = '') + public function getHtmlEmpty(string $empty = '', string $t = '', string $n = '') { return "{$t}{$empty}{$n}"; } @@ -119,28 +117,23 @@ public function getHtmlEmpty($empty = '', $t = '', $n = '') * @param string $n * @return string */ - public function getHtmlComment($htmlComment = '', $t = '', $n = '') + public function getHtmlComment(string $htmlComment = '', string $t = '', string $n = '') { return "{$t}{$n}"; } /** * @public function getHtmlBr - * @param int $brNumb + * @param int $brNumb * @param string $htmlClass * @param string $t * @param string $n * @return string */ - public function getHtmlBr($brNumb = 1, $htmlClass = '', $t = '', $n = "\n") + public function getHtmlBr(int $brNumb = 1, string $htmlClass = '', string $t = '', string $n = "\n") { $brClass = ('' != $htmlClass) ? " class='{$htmlClass}'" : ''; - $ret = ''; - for ($i = 0; $i < $brNumb; ++$i) { - $ret .= "{$t}{$n}"; - } - - return $ret; + return str_repeat("{$t}{$n}", $brNumb); } /** @@ -152,12 +145,10 @@ public function getHtmlBr($brNumb = 1, $htmlClass = '', $t = '', $n = "\n") * @param string $n * @return string */ - public function getHtmlHNumb($content = '', $l = '1', $htmlHClass = '', $t = '', $n = "\n") + public function getHtmlHNumb(string $content = '', string $l = '1', string $htmlHClass = '', string $t = '', string $n = "\n") { $hClass = ('' != $htmlHClass) ? " class='{$htmlHClass}'" : ''; - $ret = "{$t}{$content}{$n}"; - - return $ret; + return "{$t}{$content}{$n}"; } /** @@ -166,10 +157,10 @@ public function getHtmlHNumb($content = '', $l = '1', $htmlHClass = '', $t = '', * @param string $divClass * @param string $t * @param string $n - * @param bool $split + * @param bool $split * @return string */ - public function getHtmlDiv($content = '', $divClass = '', $t = '', $n = "\n", $split = true) + public function getHtmlDiv(string $content = '', string $divClass = '', string $t = '', string $n = "\n", bool $split = true) { $rDivClass = ('' != $divClass) ? " class='{$divClass}'" : ''; @@ -192,7 +183,7 @@ public function getHtmlDiv($content = '', $divClass = '', $t = '', $n = "\n", $s * @param string $n * @return string */ - public function getHtmlPre($content = '', $preClass = '', $t = '', $n = "\n") + public function getHtmlPre(string $content = '', string $preClass = '', string $t = '', string $n = "\n") { $rPreClass = ('' != $preClass) ? " class='{$preClass}'" : ''; $ret = "{$t}{$n}"; @@ -208,10 +199,10 @@ public function getHtmlPre($content = '', $preClass = '', $t = '', $n = "\n") * @param string $spanClass * @param string $t * @param string $n - * @param bool $split + * @param bool $split * @return string */ - public function getHtmlSpan($content = '', $spanClass = '', $t = '', $n = "\n", $split = false) + public function getHtmlSpan(string $content = '', string $spanClass = '', string $t = '', string $n = "\n", bool $split = false) { $rSpanClass = ('' != $spanClass) ? " class='{$spanClass}'" : ''; $ret = "{$t}"; @@ -235,7 +226,7 @@ public function getHtmlSpan($content = '', $spanClass = '', $t = '', $n = "\n", * @param string $n * @return string */ - public function getHtmlParagraph($content = '', $pClass = '', $t = '', $n = "\n") + public function getHtmlParagraph(string $content = '', string $pClass = '', string $t = '', string $n = "\n") { $rPClass = ('' != $pClass) ? " class='{$pClass}'" : ''; $ret = "{$t}{$n}"; @@ -254,13 +245,11 @@ public function getHtmlParagraph($content = '', $pClass = '', $t = '', $n = "\n" * @param string $n * @return string */ - public function getHtmlI($content = '', $iClass = '', $iId = '', $t = '', $n = "\n") + public function getHtmlI(string $content = '', string $iClass = '', string $iId = '', string $t = '', string $n = "\n") { $rIClass = ('' != $iClass) ? " class='{$iClass}'" : ''; $rIId = ('' != $iId) ? " id='{$iId}'" : ''; - $ret = "{$t}{$content}{$n}"; - - return $ret; + return "{$t}{$content}{$n}"; } /** @@ -271,7 +260,7 @@ public function getHtmlI($content = '', $iClass = '', $iId = '', $t = '', $n = " * @param string $n * @return string */ - public function getHtmlUl($content = '', $ulClass = '', $t = '', $n = "\n") + public function getHtmlUl(string $content = '', string $ulClass = '', string $t = '', string $n = "\n") { $rUlClass = ('' != $ulClass) ? " class='{$ulClass}'" : ''; $ret = "{$t}{$n}"; @@ -289,7 +278,7 @@ public function getHtmlUl($content = '', $ulClass = '', $t = '', $n = "\n") * @param string $n * @return string */ - public function getHtmlOl($content = '', $olClass = '', $t = '', $n = "\n") + public function getHtmlOl(string $content = '', string $olClass = '', string $t = '', string $n = "\n") { $rOlClass = ('' != $olClass) ? " class='{$olClass}'" : ''; $ret = "{$t}{$n}"; @@ -305,10 +294,10 @@ public function getHtmlOl($content = '', $olClass = '', $t = '', $n = "\n") * @param string $liClass * @param string $t * @param string $n - * @param bool $split + * @param bool $split * @return string */ - public function getHtmlLi($content = '', $liClass = '', $t = '', $n = "\n", $split = false) + public function getHtmlLi(string $content = '', string $liClass = '', string $t = '', string $n = "\n", bool $split = false) { $rLiClass = ('' != $liClass) ? " class='{$liClass}'" : ''; if ($split) { @@ -330,7 +319,7 @@ public function getHtmlLi($content = '', $liClass = '', $t = '', $n = "\n", $spl * @param string $n * @return string */ - public function getHtmlStrong($content = '', $strongClass = '', $t = '', $n = '') + public function getHtmlStrong(string $content = '', string $strongClass = '', string $t = '', string $n = '') { $rStrongClass = ('' != $strongClass) ? " class='{$strongClass}'" : ''; @@ -349,7 +338,7 @@ public function getHtmlStrong($content = '', $strongClass = '', $t = '', $n = '' * @param string $n * @return string */ - public function getHtmlAnchor($url = '#', $content = ' ', $title = '', $target = '', $aClass = '', $rel = '', $t = '', $n = '') + public function getHtmlAnchor(string $url = '#', string $content = ' ', string $title = '', string $target = '', string $aClass = '', string $rel = '', string $t = '', string $n = '') { $target = ('' != $target) ? " target='{$target}'" : ''; $rAClass = ('' != $aClass) ? " class='{$aClass}'" : ''; @@ -367,7 +356,7 @@ public function getHtmlAnchor($url = '#', $content = ' ', $title = '', $tar * @param string $n * @return string */ - public function getHtmlImage($src = 'blank.gif', $alt = 'blank.gif', $imgClass = '', $t = '', $n = '') + public function getHtmlImage(string $src = 'blank.gif', string $alt = 'blank.gif', string $imgClass = '', string $t = '', string $n = '') { $rImgClass = ('' != $imgClass) ? " class='{$imgClass}'" : ''; if (strpos($src,"'")) { @@ -388,7 +377,7 @@ public function getHtmlImage($src = 'blank.gif', $alt = 'blank.gif', $imgClass = * @param string $n * @return string */ - public function getHtmlTable($content = '', $tableClass = '', $t = '', $n = "\n") + public function getHtmlTable(string $content = '', string $tableClass = '', string $t = '', string $n = "\n") { $rTableClass = ('' != $tableClass) ? " class='{$tableClass}'" : ''; $ret = "{$t}{$n}"; @@ -406,7 +395,7 @@ public function getHtmlTable($content = '', $tableClass = '', $t = '', $n = "\n" * @param string $n * @return string */ - public function getHtmlTableThead($content = '', $theadClass = '', $t = '', $n = "\n") + public function getHtmlTableThead(string $content = '', string $theadClass = '', string $t = '', string $n = "\n") { $rTheadClass = ('' != $theadClass) ? " class='{$theadClass}'" : ''; $ret = "{$t}{$n}"; @@ -425,7 +414,7 @@ public function getHtmlTableThead($content = '', $theadClass = '', $t = '', $n = * @param string $n * @return string */ - public function getHtmlTableTbody($content = '', $tbodyClass = '', $t = '', $n = "\n") + public function getHtmlTableTbody(string $content = '', string $tbodyClass = '', string $t = '', string $n = "\n") { $rTbodyClass = ('' != $tbodyClass) ? " class='{$tbodyClass}'" : ''; $ret = "{$t}{$n}"; @@ -442,10 +431,10 @@ public function getHtmlTableTbody($content = '', $tbodyClass = '', $t = '', $n = * * @param string $t * @param string $n - * @param bool $split + * @param bool $split * @return string */ - public function getHtmlTableTfoot($content = '', $tfootClass = '', $t = '', $n = "\n", $split = true) + public function getHtmlTableTfoot(string $content = '', string $tfootClass = '', string $t = '', string $n = "\n", bool $split = true) { $rTfootClass = ('' != $tfootClass) ? " class='{$tfootClass}'" : ''; if ($split) { @@ -467,7 +456,7 @@ public function getHtmlTableTfoot($content = '', $tfootClass = '', $t = '', $n = * @param string $n * @return string */ - public function getHtmlTableRow($content = '', $trClass = '', $t = '', $n = "\n") + public function getHtmlTableRow(string $content = '', string $trClass = '', string $t = '', string $n = "\n") { $rTrClass = ('' != $trClass) ? " class='{$trClass}'" : ''; $ret = "{$t}{$n}"; @@ -484,10 +473,10 @@ public function getHtmlTableRow($content = '', $trClass = '', $t = '', $n = "\n" * @param string $colspan * @param string $t * @param string $n - * @param bool $split + * @param bool $split * @return string */ - public function getHtmlTableHead($content = '', $thClass = '', $colspan = '', $t = '', $n = "\n", $split = false) + public function getHtmlTableHead(string $content = '', string $thClass = '', string $colspan = '', string $t = '', string $n = "\n", bool $split = false) { $rThClass = ('' != $thClass) ? " class='{$thClass}'" : ''; $colspan = ('' != $colspan) ? " colspan='{$colspan}'" : ''; @@ -509,10 +498,10 @@ public function getHtmlTableHead($content = '', $thClass = '', $colspan = '', $t * @param string $colspan * @param string $t * @param string $n - * @param bool $split + * @param bool $split * @return string */ - public function getHtmlTableData($content = '', $tdClass = '', $colspan = '', $t = '', $n = "\n", $split = false) + public function getHtmlTableData(string $content = '', string $tdClass = '', string $colspan = '', string $t = '', string $n = "\n", bool $split = false) { $rTdClass = ('' != $tdClass) ? " class='{$tdClass}'" : ''; $colspan = ('' != $colspan) ? " colspan='{$colspan}'" : ''; diff --git a/class/Files/CreateMoreFiles.php b/class/Files/CreateMoreFiles.php index 23de008f..bfacaac2 100644 --- a/class/Files/CreateMoreFiles.php +++ b/class/Files/CreateMoreFiles.php @@ -41,7 +41,6 @@ class CreateMoreFiles extends Files\CreateFile /** * @public function constructor - * @param null */ public function __construct() { @@ -50,7 +49,7 @@ public function __construct() /** * @static function getInstance - * @param null + * * @return CreateMorefiles */ public static function getInstance() @@ -65,13 +64,13 @@ public static function getInstance() /** * @public function write - * @param string $module + * @param $module * @param string $filename * * @param $folder * @param $extension */ - public function write($module, $filename, $folder, $extension) + public function write($module, string $filename, $folder, $extension) { $this->setModule($module); $this->extension = $extension; @@ -89,7 +88,7 @@ public function write($module, $filename, $folder, $extension) * @param string $header * @return string */ - private function getMorefilesPhp($header = '') + private function getMorefilesPhp(string $header = '') { $ret = " $dim) { @@ -838,7 +842,7 @@ public function getPhpCodeNamespace($dimensions, $t = '', $n = "\n\n") * @param string $n * @return string */ - public function getPhpCodeUseNamespace($dimensions, $t = '', $n = "\n\n") + public function getPhpCodeUseNamespace($dimensions, string $t = '', string $n = "\n\n") { $ret = "\n{$t}use "; foreach ($dimensions as $key => $dim) { @@ -873,7 +877,7 @@ public function getPhpCodeBlankLine() * @param string $type * @return string */ - public function getPhpCodeConstant($const, $value, $t = '', $type = 'const') + public function getPhpCodeConstant($const, $value, string $t = '', string $type = 'const') { return "{$t}{$type} {$const} = {$value};\n"; } @@ -886,10 +890,8 @@ public function getPhpCodeConstant($const, $value, $t = '', $type = 'const') * @param string $t * @return string */ - public function getPhpCodeTriggerError($msg, $type, $t = '') + public function getPhpCodeTriggerError($msg, $type, string $t = '') { - $ret = "{$t}\\trigger_error($msg, {$type});\n"; - - return $ret; + return "{$t}\\trigger_error($msg, {$type});\n"; } } diff --git a/class/Files/CreateSmartyCode.php b/class/Files/CreateSmartyCode.php index 3d3eaa74..7bae5586 100644 --- a/class/Files/CreateSmartyCode.php +++ b/class/Files/CreateSmartyCode.php @@ -33,7 +33,6 @@ class CreateSmartyCode { /** * @public function constructor - * @param null */ public function __construct() { @@ -41,7 +40,7 @@ public function __construct() /** * @static function getInstance - * @param null + * * @return Files\CreateSmartyCode */ public static function getInstance() @@ -58,21 +57,19 @@ public static function getInstance() * @public function getSmartyTag * * @param string $tag - * @param array $attributes + * @param array $attributes * @param string $content * * @param string $t * @return string */ - public function getSmartyTag($tag = '', $attributes = [], $content = '', $t = '') + public function getSmartyTag(string $tag = '', array $attributes = [], string $content = '', string $t = '') { if (empty($attributes)) { $attributes = []; } $attr = $this->getAttributes($attributes); - $ret = "{$t}<{{$tag}{$attr}}>{$content}<{/{$tag}}>"; - - return $ret; + return "{$t}<{{$tag}{$attr}}>{$content}<{/{$tag}}>"; } /** @@ -81,7 +78,7 @@ public function getSmartyTag($tag = '', $attributes = [], $content = '', $t = '' * * @return string */ - private function getAttributes($attributes) + private function getAttributes(array $attributes) { $str = ''; foreach ($attributes as $name => $value) { @@ -99,7 +96,7 @@ private function getAttributes($attributes) * * @return string */ - public function getSmartyEmpty($empty = '') + public function getSmartyEmpty(string $empty = '') { return (string)$empty; } @@ -111,7 +108,7 @@ public function getSmartyEmpty($empty = '') * @param string $n * @return string */ - public function getSmartyComment($comment = '', $t = '', $n = "\n") + public function getSmartyComment(string $comment = '', string $t = '', string $n = "\n") { return "{$t}<{* {$comment} *}>{$n}"; } @@ -122,7 +119,7 @@ public function getSmartyComment($comment = '', $t = '', $n = "\n") * @param string $t * @return string */ - public function getSmartyNoSimbol($noSimbol = '', $t = '') + public function getSmartyNoSimbol(string $noSimbol = '', string $t = '') { return "{$t}<{{$noSimbol}}>"; } @@ -135,7 +132,7 @@ public function getSmartyNoSimbol($noSimbol = '', $t = '') * @param string $n * @return string */ - public function getSmartyConst($language, $const, $t = '', $n = '') + public function getSmartyConst(string $language, $const, string $t = '', string $n = '') { return "{$t}<{\$smarty.const.{$language}{$const}}>{$n}"; } @@ -148,7 +145,7 @@ public function getSmartyConst($language, $const, $t = '', $n = '') * @param string $default * @return string */ - public function getSmartySingleVar($var, $t = '', $n = '', $default = 'false') + public function getSmartySingleVar(string $var, string $t = '', string $n = '', string $default = 'false') { $ret = "{$t}<{\${$var}"; if ('' !== $default) { @@ -167,7 +164,7 @@ public function getSmartySingleVar($var, $t = '', $n = '', $default = 'false') * @param string $n * @return string */ - public function getSmartyDoubleVar($leftVar, $rightVar, $t = '', $n = '', $default = 'false') + public function getSmartyDoubleVar(string $leftVar, string $rightVar, string $t = '', string $n = '', $default = 'false') { return "{$t}<{\${$leftVar}.{$rightVar}|default:{$default}}>{$n}"; } @@ -176,15 +173,14 @@ public function getSmartyDoubleVar($leftVar, $rightVar, $t = '', $n = '', $defau * @public function getSmartyIncludeFile * @param $moduleDirname * @param string $fileName - * @param bool $admin + * @param bool $admin * @param string $t * @param string $n * @param string $attributes * @return string */ - public function getSmartyIncludeFile($moduleDirname, $fileName = 'header', $admin = false, $t = '', $n = "\n", $attributes = '') + public function getSmartyIncludeFile($moduleDirname, string $fileName = 'header', bool $admin = false, string $t = '', string $n = "\n", string $attributes = '') { - $ret = ''; if (!$admin) { $ret = "{$t}<{include file='db:{$moduleDirname}_{$fileName}.tpl' {$attributes}}>{$n}"; } else { @@ -204,7 +200,7 @@ public function getSmartyIncludeFile($moduleDirname, $fileName = 'header', $admi * @param string $n * @return string */ - public function getSmartyIncludeFileListSection($moduleDirname, $fileName, $itemName, $arrayName, $t = '', $n = '') + public function getSmartyIncludeFileListSection($moduleDirname, $fileName, $itemName, $arrayName, string $t = '', string $n = '') { return "{$t}<{include file='db:{$moduleDirname}_{$fileName}_list.tpl' {$itemName}=\${$arrayName}[i]}>{$n}"; } @@ -218,7 +214,7 @@ public function getSmartyIncludeFileListSection($moduleDirname, $fileName, $item * @param string $n * @return string */ - public function getSmartyIncludeFileListForeach($moduleDirname, $fileName, $tableFieldName, $t = '', $n = '') + public function getSmartyIncludeFileListForeach($moduleDirname, $fileName, $tableFieldName, string $t = '', string $n = '') { return "{$t}<{include file='db:{$moduleDirname}_{$fileName}_list.tpl' {$tableFieldName}=\${$tableFieldName}}>{$n}"; } @@ -230,15 +226,15 @@ public function getSmartyIncludeFileListForeach($moduleDirname, $fileName, $tabl * @param string $type * @param string $contentIf * @param mixed $contentElse - * @param bool $count - * @param bool $noSimbol + * @param mixed $count + * @param mixed $noSimbol * @param string $t * @param string $n - * @param bool $split + * @param bool $split * @param mixed $default * @return string */ - public function getSmartyConditions($condition = '', $operator = '', $type = '', $contentIf = '', $contentElse = false, $count = false, $noSimbol = false, $t = '', $n = "\n", $split = true, $default = 'string') + public function getSmartyConditions(string $condition = '', string $operator = '', string $type = '', string $contentIf = '', $contentElse = false, $count = false, $noSimbol = false, string $t = '', string $n = "\n", bool $split = true, $default = 'string') { $ns = ''; $ts = ''; @@ -267,7 +263,7 @@ public function getSmartyConditions($condition = '', $operator = '', $type = '', } $ret .= "{$operator}{$type}}>{$ns}"; } else { - $ret = "{$t}<{if count(\${$condition}){$operator}{$type}}>{$ns}"; + $ret = "{$t}<{if \${$condition}|count{$operator}{$type}}>{$ns}"; } $ret .= "{$contentIf}"; if ($contentElse) { @@ -290,7 +286,7 @@ public function getSmartyConditions($condition = '', $operator = '', $type = '', * @param string $n * @return string */ - public function getSmartyForeach($item = 'item', $from = 'from', $content = 'content', $name = '', $key = '', $t = '', $n = "\n") + public function getSmartyForeach(string $item = 'item', string $from = 'from', string $content = 'content', string $name = '', string $key = '', string $t = '', string $n = "\n") { $name = '' != $name ? " name={$name}" : ''; $key = '' != $key ? " key={$key}" : ''; @@ -313,7 +309,7 @@ public function getSmartyForeach($item = 'item', $from = 'from', $content = 'con * @param string $n * @return string */ - public function getSmartyForeachQuery($item = 'item', $from = 'from', $content = 'content', $loop = 'loop', $key = '', $t = '', $n = "\n") + public function getSmartyForeachQuery(string $item = 'item', string $from = 'from', string $content = 'content', string $loop = 'loop', string $key = '', string $t = '', string $n = "\n") { $loop = '' != $loop ? " loop={$loop}" : ''; $key = '' != $key ? " key={$key}" : ''; @@ -329,13 +325,13 @@ public function getSmartyForeachQuery($item = 'item', $from = 'from', $content = * @param string $name * @param string $loop * @param string $content - * @param int $start - * @param int $step + * @param int $start + * @param int $step * @param string $t * @param string $n * @return string */ - public function getSmartySection($name = 'name', $loop = 'loop', $content = 'content', $start = 0, $step = 0, $t = '', $n = "\n") + public function getSmartySection(string $name = 'name', string $loop = 'loop', string $content = 'content', int $start = 0, int $step = 0, string $t = '', string $n = "\n") { $start = 0 != $start ? " start={$start}" : ''; $step = 0 != $step ? " step={$step}" : ''; diff --git a/class/Files/CreateStructure.php b/class/Files/CreateStructure.php index b0e7e6f3..0cbb2d76 100644 --- a/class/Files/CreateStructure.php +++ b/class/Files/CreateStructure.php @@ -49,8 +49,6 @@ class CreateStructure /** * @public function constructor class - * - * @param null */ public function __construct() { @@ -59,8 +57,6 @@ public function __construct() /** * @static function getInstance * - * @param null - * * @return Modulebuilder\Files\CreateStructure */ public static function getInstance() @@ -162,10 +158,8 @@ public function isDir($dname): void if (!\mkdir($dname, 0755) && !\is_dir($dname)) { throw new \RuntimeException(\sprintf('Directory "%s" was not created', $dname)); } - chmod($dname, 0755); - } else { - chmod($dname, 0755); } + chmod($dname, 0755); } /** @@ -173,7 +167,7 @@ public function isDir($dname): void * * @param string $dir */ - protected function makeDir($dir): void + protected function makeDir(string $dir): void { $this->isDir(\trim($dir)); } @@ -183,9 +177,9 @@ protected function makeDir($dir): void * * @param string $dir * - * @return string + * @return bool */ - public function isDirEmpty($dir) + public function isDirEmpty(string $dir) { $content = []; $handle = \opendir($dir); @@ -205,11 +199,11 @@ public function isDirEmpty($dir) /** * @public function addFolderPath * - * @param string $folderName + * @param string $folderName * @param bool|string $fileName * @return string */ - private function addFolderPath($folderName, $fileName = false) + private function addFolderPath(string $folderName, $fileName = false) { $this->setFolderName($folderName); if ($fileName) { @@ -227,7 +221,7 @@ private function addFolderPath($folderName, $fileName = false) * * @param string $dirName */ - public function makeDirInModule($dirName): void + public function makeDirInModule(string $dirName): void { $fname = $this->addFolderPath($dirName); $this->makeDir($fname); @@ -240,7 +234,7 @@ public function makeDirInModule($dirName): void * @param string $fromFile * @param string $toFile */ - public function makeDirAndCopyFile($folderName, $fromFile, $toFile): void + public function makeDirAndCopyFile(string $folderName, string $fromFile, string $toFile): void { $dname = $this->addFolderPath($folderName); $this->makeDir($dname); @@ -254,7 +248,7 @@ public function makeDirAndCopyFile($folderName, $fromFile, $toFile): void * @param string $fromFile * @param string $toFile */ - public function copyFile($folderName, $fromFile, $toFile): void + public function copyFile(string $folderName, string $fromFile, string $toFile): void { $dname = $this->addFolderPath($folderName); $fname = $this->addFolderPath($folderName, $toFile); @@ -268,14 +262,13 @@ public function copyFile($folderName, $fromFile, $toFile): void * @param string $fromFile * @param string $fname */ - public function setCopy($dname, $fromFile, $fname): void + public function setCopy(string $dname, string $fromFile, string $fname): void { if (\is_dir($dname)) { chmod($dname, 0777); - \copy($fromFile, $fname); } else { $this->makeDir($dname); - \copy($fromFile, $fname); } + \copy($fromFile, $fname); } } diff --git a/class/Files/CreateTableFields.php b/class/Files/CreateTableFields.php index c368672a..ad545c9f 100644 --- a/class/Files/CreateTableFields.php +++ b/class/Files/CreateTableFields.php @@ -60,9 +60,9 @@ public static function getInstance() * * @param string $sort * @param string $order - * @return mixed + * @return array */ - public function getTableTables($mId, $sort = 'table_id ASC, table_name', $order = 'ASC') + public function getTableTables($mId, string $sort = 'table_id ASC, table_name', string $order = 'ASC') { $criteria = new \CriteriaCompo(); $criteria->add(new \Criteria('table_mid', $mId)); // $mId = module Id @@ -82,9 +82,9 @@ public function getTableTables($mId, $sort = 'table_id ASC, table_name', $order * * @param string $sort * @param string $order - * @return mixed + * @return array */ - public function getTableFields($mId, $tId, $sort = 'field_order ASC, field_id', $order = 'ASC') + public function getTableFields($mId, $tId, string $sort = 'field_order ASC, field_id', string $order = 'ASC') { $criteria = new \CriteriaCompo(); $criteria->add(new \Criteria('field_mid', $mId)); // $mId = module Id @@ -105,9 +105,9 @@ public function getTableFields($mId, $tId, $sort = 'field_order ASC, field_id', * * @param string $sort * @param string $order - * @return mixed + * @return array */ - public function getTableFieldelements($mId = null, $tId = null, $sort = 'fieldelement_id ASC, fieldelement_name', $order = 'ASC') + public function getTableFieldelements($mId = null, $tId = null, string $sort = 'fieldelement_id ASC, fieldelement_name', string $order = 'ASC') { $criteria = new \CriteriaCompo(); if (null != $mId) { @@ -133,9 +133,9 @@ public function getTableFieldelements($mId = null, $tId = null, $sort = 'fieldel * * @param string $sort * @param string $order - * @return mixed + * @return array */ - public function getTableMorefiles($mId, $sort = 'file_id ASC, file_name', $order = 'ASC') + public function getTableMorefiles($mId, string $sort = 'file_id ASC, file_name', string $order = 'ASC') { $criteria = new \CriteriaCompo(); $criteria->add(new \Criteria('file_mid', $mId)); // $mId = module Id diff --git a/class/Files/CreateXoopsCode.php b/class/Files/CreateXoopsCode.php index ad7061b2..e0e24ad5 100644 --- a/class/Files/CreateXoopsCode.php +++ b/class/Files/CreateXoopsCode.php @@ -32,10 +32,7 @@ class CreateXoopsCode { /** * @static function getInstance - * @param null - */ - - /** + * * @return Modulebuilder\Files\CreateXoopsCode */ public static function getInstance() @@ -51,16 +48,16 @@ public static function getInstance() /** * @public function getXcSwitch * @param string $op - * @param array $cases - * @param bool $defaultAfterCase - * @param bool $default + * @param array $cases + * @param bool $defaultAfterCase + * @param bool $default * @param string $t - Indentation * - * @param bool $isString - * @param bool $isConst + * @param bool $isString + * @param bool $isConst * @return string */ - public function getXcSwitch($op = '', $cases = [], $defaultAfterCase = false, $default = false, $t = '', $isString = true, $isConst = false) + public function getXcSwitch(string $op = '', array $cases = [], bool $defaultAfterCase = false, bool $default = false, string $t = '', bool $isString = true, bool $isConst = false) { $pc = Modulebuilder\Files\CreatePhpCode::getInstance(); $contentSwitch = $pc->getPhpCodeCaseSwitch($cases, $defaultAfterCase, $default, $t . "\t", $isConst); @@ -73,11 +70,11 @@ public function getXcSwitch($op = '', $cases = [], $defaultAfterCase = false, $d * @param $var * @param $value * @param $interlock - * @param $t - Indentation + * @param string $t - Indentation * * @return string */ - public function getXcEqualsOperator($var, $value, $interlock = null, $t = '') + public function getXcEqualsOperator($var, $value, $interlock = null, string $t = '') { return "{$t}{$var} {$interlock}= {$value};\n"; } @@ -87,11 +84,11 @@ public function getXcEqualsOperator($var, $value, $interlock = null, $t = '') * @param $anchor * @param $name * @param $vars - * @param $close + * @param bool $close * * @return string */ - public function getXcAnchorFunction($anchor, $name, $vars, $close = false) + public function getXcAnchorFunction($anchor, $name, $vars, bool $close = false) { $semicolon = false !== $close ? ';' : ''; @@ -103,10 +100,10 @@ public function getXcAnchorFunction($anchor, $name, $vars, $close = false) * @param $tableName * @param $fieldName * @param $var - * @param $t + * @param string $t * @return string */ - public function getXcSetVarObj($tableName, $fieldName, $var, $t = '') + public function getXcSetVarObj($tableName, $fieldName, $var, string $t = '') { return "{$t}\${$tableName}Obj->setVar('{$fieldName}', {$var});\n"; } @@ -116,13 +113,13 @@ public function getXcSetVarObj($tableName, $fieldName, $var, $t = '') * @param string $varLeft * @param string $handle * @param string $var - * @param bool $isParam + * @param bool $isParam * @param string $t * * @param string $format * @return string */ - public function getXcGetVar($varLeft = '', $handle = '', $var = '', $isParam = false, $t = '', $format = '') + public function getXcGetVar(string $varLeft = '', string $handle = '', string $var = '', bool $isParam = false, string $t = '', string $format = '') { if (!$isParam) { $ret = "{$t}\${$varLeft} = \${$handle}->getVar('{$var}'{$format});\n"; @@ -135,14 +132,14 @@ public function getXcGetVar($varLeft = '', $handle = '', $var = '', $isParam = f /** * @public function getXcAddItem - * @param $varLeft - * @param $paramLeft - * @param $paramRight - * @param $t + * @param string $varLeft + * @param string $paramLeft + * @param string $paramRight + * @param string $t * * @return string */ - public function getXcAddItem($varLeft = '', $paramLeft = '', $paramRight = '', $t = '') + public function getXcAddItem(string $varLeft = '', string $paramLeft = '', string $paramRight = '', string $t = '') { return "{$t}\${$varLeft}->addItem({$paramLeft}, {$paramRight});\n"; } @@ -157,7 +154,7 @@ public function getXcAddItem($varLeft = '', $paramLeft = '', $paramRight = '', $ * @param string $t * @return string */ - public function getXcGetGroupIds($var = '', $anchor = '', $param1 = null, $param2 = null, $param3 = null, $t = '') + public function getXcGetGroupIds(string $var = '', string $anchor = '', $param1 = null, $param2 = null, $param3 = null, string $t = '') { return "{$t}\${$var} = \${$anchor}->getGroupIds({$param1}, {$param2}, {$param3});\n"; } @@ -172,7 +169,7 @@ public function getXcGetGroupIds($var = '', $anchor = '', $param1 = null, $param * @param string $t * @return string */ - public function getXcGetItemIds($var = '', $anchor = '', $param1 = null, $param2 = null, $param3 = null, $t = '') + public function getXcGetItemIds(string $var = '', string $anchor = '', $param1 = null, $param2 = null, $param3 = null, string $t = '') { return "{$t}\${$var} = \${$anchor}->getItemIds({$param1}, {$param2}, {$param3});\n"; } @@ -183,15 +180,23 @@ public function getXcGetItemIds($var = '', $anchor = '', $param1 = null, $param2 * @param $tableSoleName * @param $fieldName * @param string $t + * @param string $language * @return string */ - public function getXcSetVarTextDateSelect($tableName, $tableSoleName, $fieldName, $t = '') + public function getXcSetVarTextDateSelect($tableName, $tableSoleName, $fieldName, string $t = '', string $language = '') { - $tf = Modulebuilder\Files\CreateFile::getInstance(); - $rightField = $tf->getRightString($fieldName); + $cf = Modulebuilder\Files\CreateFile::getInstance(); + $pc = Modulebuilder\Files\CreatePhpCode::getInstance(); + $rightField = $cf->getRightString($fieldName); $ucfRightField = \ucfirst($rightField); $value = "\DateTime::createFromFormat(\_SHORTDATESTRING, Request::getString('{$fieldName}'))"; $ret = $this->getXcEqualsOperator("\${$tableSoleName}{$ucfRightField}Obj", $value, null, $t); + $contentIf = $pc->getPhpCodeCommentLine('Get Form', null, $t . "\t"); + $contentIf .= $this->getXcXoopsTplAssign('error', "{$language}INVALID_DATE", true, $t . "\t"); + $contentIf .= $this->getXcGetForm('form', $tableName, 'Obj', $t . "\t"); + $contentIf .= $this->getXcXoopsTplAssign('form', '$form->render()', true, $t . "\t"); + $contentIf .= $cf->getSimpleString('break;', $t . "\t"); + $ret .= $pc->getPhpCodeConditions("\${$tableSoleName}{$ucfRightField}Obj", ' === ', 'false', $contentIf,false,$t); $ret .= $this->getXcSetVarObj($tableName, $fieldName, "\${$tableSoleName}{$ucfRightField}Obj->getTimestamp()", $t); return $ret; @@ -203,20 +208,30 @@ public function getXcSetVarTextDateSelect($tableName, $tableSoleName, $fieldName * @param $tableSoleName * @param $fieldName * @param string $t + * @param string $language * @return string */ - public function getXcSetVarDateTime($tableName, $tableSoleName, $fieldName, $t = '') + public function getXcSetVarDateTime($tableName, $tableSoleName, $fieldName, string $t = '', string $language = '') { $tf = Modulebuilder\Files\CreateFile::getInstance(); + $pc = Modulebuilder\Files\CreatePhpCode::getInstance(); $rightField = $tf->getRightString($fieldName); $ucfRightField = \ucfirst($rightField); $request = "Request::getArray('{$fieldName}')"; $var = "\${$tableSoleName}{$ucfRightField}"; $varArr = "\${$tableSoleName}{$ucfRightField}Arr"; $ret = $this->getXcEqualsOperator($varArr, $request, null, $t); + $varObj = "\${$tableSoleName}{$ucfRightField}Obj"; + $contentIf = $pc->getPhpCodeCommentLine('Get Form', null, $t . "\t"); + $contentIf .= $this->getXcXoopsTplAssign('error', "{$language}INVALID_DATE", true, $t . "\t"); + $contentIf .= $this->getXcGetForm('form', $tableName, 'Obj', $t . "\t"); + $contentIf .= $this->getXcXoopsTplAssign('form', '$form->render()', true, $t . "\t"); + $contentIf .= $tf->getSimpleString('break;', $t . "\t"); + $ret .= $pc->getPhpCodeConditions("!isset(\${$tableSoleName}{$ucfRightField}Arr['date']) || !isset(\${$tableSoleName}{$ucfRightField}Arr['time'])", '', '', $contentIf,false,$t); $value = "\DateTime::createFromFormat(\_SHORTDATESTRING, {$varArr}['date'])"; $ret .= $this->getXcEqualsOperator($varObj, $value, null, $t); + $ret .= $pc->getPhpCodeConditions("\${$tableSoleName}{$ucfRightField}Obj", ' === ', 'false', $contentIf,false,$t); $ret .= "{$t}{$varObj}->setTime(0, 0, 0);\n"; $value = "{$varObj}->getTimestamp() + (int){$varArr}['time']"; $ret .= $this->getXcEqualsOperator($var, $value, null, $t); @@ -229,10 +244,10 @@ public function getXcSetVarDateTime($tableName, $tableSoleName, $fieldName, $t = * @public function getXcSetVarCheckBoxOrRadioYN * @param $tableName * @param $fieldName - * @param $t + * @param string $t * @return string */ - public function getXcSetVarCheckBoxOrRadioYN($tableName, $fieldName, $t = '') + public function getXcSetVarCheckBoxOrRadioYN($tableName, $fieldName, string $t = '') { return $this->getXcSetVarObj($tableName, $fieldName, "Request::getInt('{$fieldName}')", $t); } @@ -246,7 +261,7 @@ public function getXcSetVarCheckBoxOrRadioYN($tableName, $fieldName, $t = '') * @param string $t * @return string */ - public function getXcMediaUploader($var, $dirPath, $mimetype, $maxsize, $t = '') + public function getXcMediaUploader($var, $dirPath, $mimetype, $maxsize, string $t = '') { $mimetypes_file = $this->getXcGetConfig($mimetype); $maxsize_file = $this->getXcGetConfig($maxsize); @@ -258,13 +273,13 @@ public function getXcMediaUploader($var, $dirPath, $mimetype, $maxsize, $t = '') /** * @public function getXcXoopsCaptcha - * @param $var - * @param $instance - * @param $t + * @param string $var + * @param string $instance + * @param string $t * * @return string */ - public function getXcGetInstance($var = '', $instance = '', $t = '') + public function getXcGetInstance(string $var = '', string $instance = '', string $t = '') { return "{$t}\${$var} = {$instance}::getInstance();\n"; } @@ -282,10 +297,10 @@ public function getXcGetConfig($name) /** * @public function getXcIdGetVar * @param $lpFieldName - * @param $t + * @param string $t * @return string */ - public function getXcIdGetVar($lpFieldName, $t = '') + public function getXcIdGetVar($lpFieldName, string $t = '') { return "{$t}\${$lpFieldName}['id'] = \$i;\n"; } @@ -296,10 +311,10 @@ public function getXcIdGetVar($lpFieldName, $t = '') * @param $rpFieldName * @param $tableName * @param $fieldName - * @param $t + * @param string $t * @return string */ - public function getXcGetVarAll($lpFieldName, $rpFieldName, $tableName, $fieldName, $t = '') + public function getXcGetVarAll($lpFieldName, $rpFieldName, $tableName, $fieldName, string $t = '') { return "{$t}\${$lpFieldName}['{$rpFieldName}'] = \${$tableName}All[\$i]->getVar('{$fieldName}');\n"; } @@ -311,7 +326,7 @@ public function getXcGetVarAll($lpFieldName, $rpFieldName, $tableName, $fieldNam * @param string $t * @return string */ - public function getXcHelperGetInstance($moduleDirname, $t = '') + public function getXcHelperGetInstance($moduleDirname, string $t = '') { $ucfModuleDirname = \ucfirst($moduleDirname); $ret = "{$t}// Get instance of module\n"; @@ -328,7 +343,7 @@ public function getXcHelperGetInstance($moduleDirname, $t = '') * @param string $t * @return string */ - public function getXcFormatTimeStamp($left, $value, $format = 's', $t = '') + public function getXcFormatTimeStamp($left, $value, string $format = 's', string $t = '') { return "{$t}\${$left} = \\formatTimestamp({$value}, '{$format}');\n"; } @@ -344,7 +359,7 @@ public function getXcFormatTimeStamp($left, $value, $format = 's', $t = '') * @param string $t * @return string */ - public function getXcTopicGetVar($lpFieldName, $rpFieldName, $tableName, $tableNameTopic, $fieldNameParent, $fieldNameTopic, $t = '') + public function getXcTopicGetVar($lpFieldName, $rpFieldName, $tableName, $tableNameTopic, $fieldNameParent, $fieldNameTopic, string $t = '') { $pc = Modulebuilder\Files\CreatePhpCode::getInstance(); $ret = $pc->getPhpCodeCommentLine('Get Var', $fieldNameParent, $t); @@ -366,7 +381,7 @@ public function getXcTopicGetVar($lpFieldName, $rpFieldName, $tableName, $tableN * @param string $t * @return string */ - public function getXcParentTopicGetVar($lpFieldName, $rpFieldName, $tableName, $tableSoleNameTopic, $tableNameTopic, $fieldNameParent, $t = '') + public function getXcParentTopicGetVar($lpFieldName, $rpFieldName, $tableName, $tableSoleNameTopic, $tableNameTopic, $fieldNameParent, string $t = '') { $pc = Modulebuilder\Files\CreatePhpCode::getInstance(); $parentTopic = $pc->getPhpCodeCommentLine('Get', $tableNameTopic . ' Handler', $t . "\t"); @@ -388,7 +403,7 @@ public function getXcParentTopicGetVar($lpFieldName, $rpFieldName, $tableName, $ * @param string $t * @return string */ - public function getXcGetVarFromID($left, $anchor, $var, $tableName, $fieldName, $t = '') + public function getXcGetVarFromID($left, $anchor, $var, $tableName, $fieldName, string $t = '') { $pc = Modulebuilder\Files\CreatePhpCode::getInstance(); $ret = $pc->getPhpCodeCommentLine('Get Var', $fieldName, $t); @@ -442,7 +457,7 @@ public function getXcGetVarUrlFile($lpFieldName, $rpFieldName, $tableName, $fiel * @param string $t * @return string */ - public function getXcGetVarTextArea($lpFieldName, $rpFieldName, $tableName, $fieldName, $t = '') + public function getXcGetVarTextArea($lpFieldName, $rpFieldName, $tableName, $fieldName, string $t = '') { $pc = Modulebuilder\Files\CreatePhpCode::getInstance(); $getVar = $this->getXcGetVar('', "\${$tableName}All[\$i]", $fieldName, true); @@ -459,7 +474,7 @@ public function getXcGetVarTextArea($lpFieldName, $rpFieldName, $tableName, $fie * @param string $t * @return string */ - public function getXcGetVarSelectUser($lpFieldName, $rpFieldName, $tableName, $fieldName, $t = '') + public function getXcGetVarSelectUser($lpFieldName, $rpFieldName, $tableName, $fieldName, string $t = '') { return "{$t}\${$lpFieldName}['{$rpFieldName}'] = \XoopsUser::getUnameFromId(\${$tableName}All[\$i]->getVar('{$fieldName}'), 's');\n"; } @@ -473,7 +488,7 @@ public function getXcGetVarSelectUser($lpFieldName, $rpFieldName, $tableName, $f * @param string $t * @return string */ - public function getXcGetVarTextDateSelect($lpFieldName, $rpFieldName, $tableName, $fieldName, $t = '') + public function getXcGetVarTextDateSelect($lpFieldName, $rpFieldName, $tableName, $fieldName, string $t = '') { return "{$t}\${$lpFieldName}['{$rpFieldName}'] = \\formatTimestamp(\${$tableName}All[\$i]->getVar('{$fieldName}'), 's');\n"; } @@ -485,7 +500,7 @@ public function getXcGetVarTextDateSelect($lpFieldName, $rpFieldName, $tableName * @param string $t * @return string */ - public function getXcXoopsOptionTemplateMain($moduleDirname, $tableName, $t = '') + public function getXcXoopsOptionTemplateMain($moduleDirname, $tableName, string $t = '') { return "{$t}\$GLOBALS['xoopsOption']['template_main'] = '{$moduleDirname}_{$tableName}.tpl';\n"; } @@ -508,7 +523,7 @@ public function getXcUserHeader($moduleDirname, $tableName) /** * @public function getXcPermissionsHeader - * @param null + * * @return string */ public function getXcPermissionsHeader() @@ -519,7 +534,7 @@ public function getXcPermissionsHeader() $ret .= $this->getXcXoopsHandler('groupperm'); $groups = $this->getXcEqualsOperator('$groups', '$xoopsUser->getGroups()'); $elseGroups = $this->getXcEqualsOperator('$groups', '\XOOPS_GROUP_ANONYMOUS'); - $ret .= $pc->getPhpCodeConditions('\is_object($xoopsUser)', '', $type = '', $groups, $elseGroups); + $ret .= $pc->getPhpCodeConditions('\is_object($xoopsUser)', '', '', $groups, $elseGroups); return $ret; } @@ -596,6 +611,7 @@ public function getXcUserSaveElements($moduleDirname, $tableName, $tableSoleName $ret = ''; $fieldMain = ''; $countUploader = 0; + $language = '\_MA_' . \strtoupper($moduleDirname) . '_'; foreach (\array_keys($fields) as $f) { $fieldName = $fields[$f]->getVar('field_name'); $fieldElement = $fields[$f]->getVar('field_element'); @@ -611,7 +627,7 @@ public function getXcUserSaveElements($moduleDirname, $tableName, $tableSoleName $ret .= $axc->getAxcSetVarUploadFile($moduleDirname, $tableName, $fieldName, '', '', $countUploader); $countUploader++; } elseif (15 == $fieldElement) { - $ret .= $this->getXcSetVarTextDateSelect($tableName, $tableSoleName, $fieldName); + $ret .= $this->getXcSetVarTextDateSelect($tableName, $tableSoleName, $fieldName, '', $language); } else { $ret .= $this->getXcSetVarObj($tableName, $fieldName, "\$_POST['{$fieldName}']"); } @@ -626,11 +642,11 @@ public function getXcUserSaveElements($moduleDirname, $tableName, $tableSoleName * @param string $var1 * @param string $var2 * @param string $type - * @param bool $method + * @param bool $method * @param string $t * @return string */ - public function getXcXoopsRequest($left = '', $var1 = '', $var2 = '', $type = 'String', $method = false, $t = '') + public function getXcXoopsRequest(string $left = '', string $var1 = '', string $var2 = '', string $type = 'String', bool $method = false, string $t = '') { $ret = ''; $intVars = ('' != $var2) ? "'{$var1}', {$var2}" : "'{$var1}'"; @@ -658,12 +674,12 @@ public function getXcXoopsRequest($left = '', $var1 = '', $var2 = '', $type = 'S * @param string $var * @param string $groups * @param string $mid - * @param bool $isParam + * @param bool $isParam * * @param string $t * @return string */ - public function getXcAddRight($anchor, $permString = '', $var = '', $groups = '', $mid = '', $isParam = false, $t = '') + public function getXcAddRight($anchor, string $permString = '', string $var = '', string $groups = '', string $mid = '', bool $isParam = false, string $t = '') { if (!$isParam) { $ret = "{$t}\${$anchor}->addRight('{$permString}', {$var}, {$groups}, {$mid});\n"; @@ -682,12 +698,12 @@ public function getXcAddRight($anchor, $permString = '', $var = '', $groups = '' * @param string $var * @param string $groups * @param string $mid - * @param bool $isParam + * @param bool $isParam * * @param string $t * @return string */ - public function getXcCheckRight($anchor, $permString = '', $var = '', $groups = '', $mid = '', $isParam = false, $t = '') + public function getXcCheckRight($anchor, string $permString = '', string $var = '', string $groups = '', string $mid = '', bool $isParam = false, string $t = '') { if (!$isParam) { $ret = "{$t}{$anchor}->checkRight('{$permString}', {$var}, {$groups}, {$mid});\n"; @@ -705,12 +721,12 @@ public function getXcCheckRight($anchor, $permString = '', $var = '', $groups = * @param string $permString * @param string $mid * @param string $var - * @param bool $isParam + * @param bool $isParam * * @param string $t * @return string */ - public function getXcDeleteRight($anchor, $permString = '', $mid = '', $var = '', $isParam = false, $t = '') + public function getXcDeleteRight($anchor, string $permString = '', string $mid = '', string $var = '', bool $isParam = false, string $t = '') { if (!$isParam) { $ret = "{$t}\${$anchor}->deleteByModule({$mid}, '{$permString}', {$var});\n"; @@ -727,7 +743,7 @@ public function getXcDeleteRight($anchor, $permString = '', $mid = '', $var = '' * @param string $t * @return string */ - public function getXcHandlerLine($tableName, $t = '') + public function getXcHandlerLine($tableName, string $t = '') { $ucfTableName = \ucfirst($tableName); @@ -742,7 +758,7 @@ public function getXcHandlerLine($tableName, $t = '') * @param string $t * @return string */ - public function getXcHandlerCreateObj($tableName, $t = '') + public function getXcHandlerCreateObj($tableName, string $t = '') { return "{$t}\${$tableName}Obj = \${$tableName}Handler->create();\n"; } @@ -755,7 +771,7 @@ public function getXcHandlerCreateObj($tableName, $t = '') * @param string $t * @return string */ - public function getXcHandlerGetObj($tableName, $ccFieldId, $t = '') + public function getXcHandlerGetObj($tableName, $ccFieldId, string $t = '') { return "{$t}\${$tableName}Obj = \${$tableName}Handler->get(\${$ccFieldId});\n"; } @@ -768,28 +784,24 @@ public function getXcHandlerGetObj($tableName, $ccFieldId, $t = '') * @param string $t * @return string */ - public function getXcHandlerCountObj($tableName, $t = '') + public function getXcHandlerCountObj($tableName, string $t = '') { $ucfTableName = \ucfirst($tableName); - $ret = "{$t}\${$tableName}Count = \${$tableName}Handler->getCount{$ucfTableName}();\n"; - - return $ret; + return "{$t}\${$tableName}Count = \${$tableName}Handler->getCount{$ucfTableName}();\n"; } /** * @public function getXcClearCount * @param $left - * @param $anchor - * @param $params - * @param $t + * @param string $anchor + * @param string $params + * @param string $t * * @return string */ - public function getXcHandlerCountClear($left, $anchor = '', $params = '', $t = '') + public function getXcHandlerCountClear($left, string $anchor = '', string $params = '', string $t = '') { - $ret = "{$t}\${$left} = \${$anchor}Handler->getCount({$params});\n"; - - return $ret; + return "{$t}\${$left} = \${$anchor}Handler->getCount({$params});\n"; } /** @@ -803,14 +815,12 @@ public function getXcHandlerCountClear($left, $anchor = '', $params = '', $t = ' * @param string $t * @return string */ - public function getXcHandlerAllObj($tableName, $fieldMain = '', $start = '0', $limit = '0', $t = '') + public function getXcHandlerAllObj($tableName, string $fieldMain = '', string $start = '0', string $limit = '0', string $t = '') { $ucfTableName = \ucfirst($tableName); $startLimit = ('0' != $limit) ? "{$start}, {$limit}" : '0'; $params = ('' != $fieldMain) ? "{$startLimit}, '{$fieldMain}'" : $startLimit; - $ret = "{$t}\${$tableName}All = \${$tableName}Handler->getAll{$ucfTableName}({$params});\n"; - - return $ret; + return "{$t}\${$tableName}All = \${$tableName}Handler->getAll{$ucfTableName}({$params});\n"; } /** @@ -821,11 +831,9 @@ public function getXcHandlerAllObj($tableName, $fieldMain = '', $start = '0', $l * @param string $t * @return string */ - public function getXcHandlerAllClear($left, $anchor = '', $params = '', $t = '') + public function getXcHandlerAllClear($left, string $anchor = '', string $params = '', string $t = '') { - $ret = "{$t}\${$left} = \${$anchor}Handler->getAll({$params});\n"; - - return $ret; + return "{$t}\${$left} = \${$anchor}Handler->getAll({$params});\n"; } /** @@ -835,12 +843,12 @@ public function getXcHandlerAllClear($left, $anchor = '', $params = '', $t = '') * @param $var * @param string $obj * @param string $handler - * @param bool $isParam + * @param bool $isParam * * @param string $t * @return string */ - public function getXcHandlerGet($left, $var, $obj = '', $handler = 'Handler', $isParam = false, $t = '') + public function getXcHandlerGet($left, $var, string $obj = '', string $handler = 'Handler', bool $isParam = false, string $t = '') { if ($isParam) { $ret = "\${$left}{$handler}->get(\${$var})"; @@ -856,12 +864,12 @@ public function getXcHandlerGet($left, $var, $obj = '', $handler = 'Handler', $i * * @param $left * @param $var - * @param $obj - * @param $handler + * @param string $obj + * @param string $handler * * @return string */ - public function getXcHandlerInsert($left, $var, $obj = '', $handler = 'Handler') + public function getXcHandlerInsert($left, $var, string $obj = '', string $handler = 'Handler') { return "\${$left}{$handler}->insert(\${$var}{$obj})"; } @@ -875,7 +883,7 @@ public function getXcHandlerInsert($left, $var, $obj = '', $handler = 'Handler') * @param string $handler * @return string */ - public function getXcHandlerDelete($left, $var, $obj = '', $handler = 'Handler') + public function getXcHandlerDelete($left, $var, string $obj = '', string $handler = 'Handler') { return "\${$left}{$handler}->delete(\${$var}{$obj})"; } @@ -887,12 +895,12 @@ public function getXcHandlerDelete($left, $var, $obj = '', $handler = 'Handler') * @param $tableSoleName * * @param string $index - * @param bool $noArray + * @param bool $noArray * @param string $t * @param string $obj * @return string */ - public function getXcGetValues($tableName, $tableSoleName, $index = 'i', $noArray = false, $t = '', $obj = '') + public function getXcGetValues($tableName, $tableSoleName, string $index = 'i', bool $noArray = false, string $t = '', string $obj = '') { $index = '' !== $index ? $index : 'i'; $ucfTableName = \ucfirst($tableName); @@ -920,6 +928,7 @@ public function getXcSetVarsObjects($moduleDirname, $tableName, $tableSoleName, $ret = ''; $fieldMain = ''; $countUploader = 0; + $language = '\_MA_' . \strtoupper($moduleDirname) . '_'; foreach (\array_keys($fields) as $f) { $fieldName = $fields[$f]->getVar('field_name'); $fieldElement = $fields[$f]->getVar('field_element'); @@ -949,7 +958,7 @@ public function getXcSetVarsObjects($moduleDirname, $tableName, $tableSoleName, $countUploader++; break; case 15: - $ret .= $this->getXcSetVarTextDateSelect($tableName, $tableSoleName, $fieldName); + $ret .= $this->getXcSetVarTextDateSelect($tableName, $tableSoleName, $fieldName, '', $language); break; default: $ret .= $this->getXcSetVarObj($tableName, $fieldName, "\$_POST['{$fieldName}']"); @@ -969,7 +978,7 @@ public function getXcSetVarsObjects($moduleDirname, $tableName, $tableSoleName, * @param string $t * @return string */ - public function getXcSecurity($tableName, $t = '') + public function getXcSecurity($tableName, string $t = '') { $pc = Modulebuilder\Files\CreatePhpCode::getInstance(); $securityError = $this->getXcXoopsSecurityErrors(); @@ -987,7 +996,7 @@ public function getXcSecurity($tableName, $t = '') * @param string $t * @return string */ - public function getXcInsertData($tableName, $language, $t = '') + public function getXcInsertData($tableName, $language, string $t = '') { $pc = Modulebuilder\Files\CreatePhpCode::getInstance(); $content = "{$t}\t" . $this->getXcRedirectHeader($tableName, '?op=list', 2, "{$language}FORM_OK"); @@ -1002,11 +1011,11 @@ public function getXcInsertData($tableName, $language, $t = '') * @param $options * @param $numb * @param $var - * @param bool $isString + * @param bool $isString * @param string $t * @return string */ - public function getXcRedirectHeader($directory, $options, $numb, $var, $isString = true, $t = '') + public function getXcRedirectHeader($directory, $options, $numb, $var, bool $isString = true, string $t = '') { if (!$isString) { $ret = "{$t}\\redirect_header({$directory}, {$numb}, {$var});\n"; @@ -1028,7 +1037,7 @@ public function getXcRedirectHeader($directory, $options, $numb, $var, $isString * @param string $t * @return string */ - public function getXcXoopsConfirm($tableName, $language, $fieldId, $fieldMain, $options = 'delete', $t = '') + public function getXcXoopsConfirm($tableName, $language, $fieldId, $fieldMain, string $options = 'delete', string $t = '') { $stuOptions = \mb_strtoupper($options); $ccFieldId = Modulebuilder\Files\CreateFile::getInstance()->getCamelCase($fieldId, false, true); @@ -1039,9 +1048,7 @@ public function getXcXoopsConfirm($tableName, $language, $fieldId, $fieldMain, $ $array = "['ok' => 1, '{$fieldId}' => \${$ccFieldId}, 'start' => \$start, 'limit' => \$limit, 'op' => '{$options}']"; $server = $pc->getPhpCodeGlobalsVariables('REQUEST_URI', 'SERVER'); - $getVar = $this->getXcGetVar('', $tableName . 'Obj', $fieldMain, true); - $getVar = "\${$ccFieldMain}"; - $sprintf = $pc->getPhpCodeSprintf($language . 'FORM_SURE_' . $stuOptions, $getVar); + $sprintf = $pc->getPhpCodeSprintf($language . 'FORM_SURE_' . $stuOptions, "\${$ccFieldMain}"); $confirm = 'new Common\Confirm(' . "\n"; $confirm .= $t . "\t" . $array . ",\n"; $confirm .= $t . "\t" . $server . ",\n"; @@ -1057,13 +1064,13 @@ public function getXcXoopsConfirm($tableName, $language, $fieldId, $fieldMain, $ * @public function getXcHtmlErrors * * @param $tableName - * @param bool $isParam + * @param bool $isParam * @param string $obj * * @param string $t * @return string */ - public function getXcHtmlErrors($tableName, $isParam = false, $obj = 'Obj', $t = '') + public function getXcHtmlErrors($tableName, bool $isParam = false, string $obj = 'Obj', string $t = '') { if ($isParam) { $ret = "\${$tableName}{$obj}->getHtmlErrors()"; @@ -1084,7 +1091,7 @@ public function getXcHtmlErrors($tableName, $isParam = false, $obj = 'Obj', $t = * @param string $t * @return string */ - public function getXcGetForm($left, $tableName, $obj = '', $t = '') + public function getXcGetForm($left, $tableName, string $obj = '', string $t = '') { $ucfTableName = \ucfirst($tableName); @@ -1102,7 +1109,7 @@ public function getXcGetForm($left, $tableName, $obj = '', $t = '') * @param string $t * @return string */ - public function getTopicGetVar($lpFieldName, $rpFieldName, $tableName, $tableNameTopic, $fieldNameParent, $fieldNameTopic, $t = '') + public function getTopicGetVar($lpFieldName, $rpFieldName, $tableName, $tableNameTopic, $fieldNameParent, $fieldNameTopic, string $t = '') { $ret = Modulebuilder\Files\CreatePhpCode::getInstance()->getPhpCodeCommentLine('Get Var', $fieldNameParent, $t); $paramGet = $this->getXcGetVar('', "\${$tableName}All[\$i]", $fieldNameParent, true); @@ -1135,13 +1142,13 @@ public function getUploadImageGetVar($lpFieldName, $rpFieldName, $tableName, $fi */ /** - * @public function getXcSaveFieldId + * @public function getXcTableFieldId * * @param $fields * * @return string */ - public function getXcSaveFieldId($fields) + public function getXcTableFieldId($fields) { $fieldId = ''; foreach (\array_keys($fields) as $f) { @@ -1154,13 +1161,13 @@ public function getXcSaveFieldId($fields) } /** - * @public function getXcSaveFieldMain + * @public function getXcTableFieldMain * * @param $fields * * @return string */ - public function getXcSaveFieldMain($fields) + public function getXcTableFieldMain($fields) { $fieldMain = ''; foreach (\array_keys($fields) as $f) { @@ -1183,7 +1190,7 @@ public function getXcSaveFieldMain($fields) * @param string $t * @return string */ - public function getXcSaveElements($moduleDirname, $tableName, $tableSoleName, $fields, $t = '') + public function getXcSaveElements($moduleDirname, $tableName, $tableSoleName, $fields, string $t = '') { $axc = Modulebuilder\Files\Admin\AdminXoopsCode::getInstance(); $xc = Modulebuilder\Files\CreateXoopsCode::getInstance(); @@ -1191,6 +1198,7 @@ public function getXcSaveElements($moduleDirname, $tableName, $tableSoleName, $f $fieldMain = ''; $countUploader = 0; $fieldLines = ''; + $language = '\_MA_' . \strtoupper($moduleDirname) . '_'; foreach (\array_keys($fields) as $f) { $fieldName = $fields[$f]->getVar('field_name'); $fieldType = $fields[$f]->getVar('field_type'); @@ -1222,14 +1230,14 @@ public function getXcSaveElements($moduleDirname, $tableName, $tableSoleName, $f $countUploader++; break; case 15: - $fieldLines .= $this->getXcSetVarTextDateSelect($tableName, $tableSoleName, $fieldName, $t); + $fieldLines .= $this->getXcSetVarTextDateSelect($tableName, $tableSoleName, $fieldName, $t, $language); break; case 17: $fieldLines .= $axc->getAxcSetVarPassword($tableName, $fieldName, $t); $countUploader++; break; case 21: - $fieldLines .= $this->getXcSetVarDateTime($tableName, $tableSoleName, $fieldName, $t); + $fieldLines .= $this->getXcSetVarDateTime($tableName, $tableSoleName, $fieldName, $t, $language); break; default: $fieldLines .= $axc->getAxcSetVarMisc($tableName, $fieldName, $fieldType, $fieldElement, $t); @@ -1252,16 +1260,18 @@ public function getXcSaveElements($moduleDirname, $tableName, $tableSoleName, $f * @param string $t * @param string $paramStart * @param string $paramOp + * @param string $pageNavTplName * @return string */ - public function getXcPageNav($tableName, $t = '', $paramStart = 'start', $paramOp = "'op=list&limit=' . \$limit") + public function getXcPageNav($tableName, string $t = '', string $paramStart = 'start', string $paramOp = "'op=list&limit=' . \$limit", string $pageNavTplName = '') { $pc = Modulebuilder\Files\CreatePhpCode::getInstance(); $cxc = Modulebuilder\Files\Classes\ClassXoopsCode::getInstance(); $ret = $pc->getPhpCodeCommentLine('Display Navigation', null, $t); $condition = $pc->getPhpCodeIncludeDir('\XOOPS_ROOT_PATH', 'class/pagenav', true, false, 'require', $t . "\t"); $condition .= $cxc->getClassXoopsPageNav('pagenav', $tableName . 'Count', 'limit', 'start', $paramStart, $paramOp, false, $t . "\t"); - $condition .= $this->getXcXoopsTplAssign('pagenav', '$pagenav->renderNav()', true, $t . "\t"); + if ('' === $pageNavTplName) { $pageNavTplName = 'pagenav';} + $condition .= $this->getXcXoopsTplAssign($pageNavTplName, '$pagenav->renderNav()', true, $t . "\t"); $ret .= $pc->getPhpCodeConditions("\${$tableName}Count", ' > ', '$limit', $condition, false, $t); return $ret; @@ -1273,7 +1283,7 @@ public function getXcPageNav($tableName, $t = '', $paramStart = 'start', $paramO * @param string $t * @return string */ - public function getXcGetGlobal($globals, $t = '') + public function getXcGetGlobal($globals, string $t = '') { $ret = $t . 'global '; $detail = ''; @@ -1296,7 +1306,7 @@ public function getXcGetGlobal($globals, $t = '') * * @return string */ - public function getXcCriteriaCompo($var, $t = '') + public function getXcCriteriaCompo($var, string $t = '') { return "{$t}\${$var} = new \CriteriaCompo();\n"; } @@ -1308,12 +1318,12 @@ public function getXcCriteriaCompo($var, $t = '') * @param $param1 * @param string $param2 * @param string $param3 - * @param bool $isParam + * @param bool $isParam * @param string $t * * @return string */ - public function getXcCriteria($var, $param1, $param2 = '', $param3 = '', $isParam = false, $t = '') + public function getXcCriteria($var, $param1, string $param2 = '', string $param3 = '', bool $isParam = false, string $t = '') { $params = ('' != $param2) ? ', ' . $param2 : ''; $params .= ('' != $param3) ? ', ' . $param3 : ''; @@ -1337,7 +1347,7 @@ public function getXcCriteria($var, $param1, $param2 = '', $param3 = '', $isPara * @param string $condition * @return string */ - public function getXcCriteriaAdd($var, $param, $t = '', $n = "\n", $condition = '') + public function getXcCriteriaAdd($var, $param, string $t = '', string $n = "\n", string $condition = '') { if ('' !== $condition) { $condition = ", {$condition}"; @@ -1356,7 +1366,7 @@ public function getXcCriteriaAdd($var, $param, $t = '', $n = "\n", $condition = * @param string $n * @return string */ - public function getXcCriteriaSetStart($var, $start, $t = '', $n = "\n") + public function getXcCriteriaSetStart($var, $start, string $t = '', string $n = "\n") { return "{$t}\${$var}->setStart({$start});{$n}"; } @@ -1371,7 +1381,7 @@ public function getXcCriteriaSetStart($var, $start, $t = '', $n = "\n") * @param string $n * @return string */ - public function getXcCriteriaSetLimit($var, $limit, $t = '', $n = "\n") + public function getXcCriteriaSetLimit($var, $limit, string $t = '', string $n = "\n") { return "{$t}\${$var}->setLimit({$limit});{$n}"; } @@ -1386,7 +1396,7 @@ public function getXcCriteriaSetLimit($var, $limit, $t = '', $n = "\n") * @param string $n * @return string */ - public function getXcCriteriaSetSort($var, $sort, $t = '', $n = "\n") + public function getXcCriteriaSetSort($var, $sort, string $t = '', string $n = "\n") { return "{$t}\${$var}->setSort({$sort});{$n}"; } @@ -1401,7 +1411,7 @@ public function getXcCriteriaSetSort($var, $sort, $t = '', $n = "\n") * @param string $n * @return string */ - public function getXcCriteriaSetOrder($var, $order, $t = '', $n = "\n") + public function getXcCriteriaSetOrder($var, $order, string $t = '', string $n = "\n") { return "{$t}\${$var}->setOrder({$order});{$n}"; } @@ -1412,17 +1422,17 @@ public function getXcCriteriaSetOrder($var, $order, $t = '', $n = "\n") /** * @public function getXcXoopsFormGroupPerm - * @param $varLeft - * @param $formTitle - * @param $moduleId - * @param $permName - * @param $permDesc - * @param $filename - * @param $t + * @param string $varLeft + * @param string $formTitle + * @param string $moduleId + * @param string $permName + * @param string $permDesc + * @param string $filename + * @param string $t * * @return string */ - public function getXcXoopsFormGroupPerm($varLeft = '', $formTitle = '', $moduleId = '', $permName = '', $permDesc = '', $filename = '', $t = '') + public function getXcXoopsFormGroupPerm(string $varLeft = '', string $formTitle = '', string $moduleId = '', string $permName = '', string $permDesc = '', string $filename = '', string $t = '') { return "{$t}\${$varLeft} = new \XoopsGroupPermForm({$formTitle}, {$moduleId}, {$permName}, {$permDesc}, {$filename});\n"; } @@ -1432,16 +1442,16 @@ public function getXcXoopsFormGroupPerm($varLeft = '', $formTitle = '', $moduleI * @param string $varSelect * @param string $caption * @param string $var - * @param array $options - * @param bool $setExtra + * @param array $options + * @param string $setExtra * * @param string $t * @return string */ - public function getXoopsFormSelectExtraOptions($varSelect = '', $caption = '', $var = '', $options = [], $setExtra = true, $t = '') + public function getXoopsFormSelectExtraOptions(string $varSelect = '', string $caption = '', string $var = '', array $options = [], string $setExtra = '', string $t = '') { $ret = "{$t}\${$varSelect} = new \XoopsFormSelect({$caption}, '{$var}', \${$var});\n"; - if (false !== $setExtra) { + if ('' !== $setExtra) { $ret .= "{$t}\${$varSelect}->setExtra('{$setExtra}');\n"; } foreach ($options as $key => $value) { @@ -1462,9 +1472,7 @@ public function getXoopsFormSelectExtraOptions($varSelect = '', $caption = '', $ */ public function getXcGetConstants($const) { - $ret = "Constants::{$const}"; - - return $ret; + return "Constants::{$const}"; } /*************************************************************/ @@ -1474,7 +1482,7 @@ public function getXcGetConstants($const) /** * @public function getXcXoopsCPHeader - * @param null + * * @return string */ public function getXcXoopsCPHeader() @@ -1484,7 +1492,7 @@ public function getXcXoopsCPHeader() /** * @public function getXcXoopsCPFooter - * @param null + * * @return string */ public function getXcXoopsCPFooter() @@ -1495,11 +1503,11 @@ public function getXcXoopsCPFooter() /** * @public function getXcXoopsLoad * - * @param $var - * @param $t + * @param string $var + * @param string $t * @return string */ - public function getXcXoopsLoad($var = '', $t = '') + public function getXcXoopsLoad(string $var = '', string $t = '') { return "{$t}\xoops_load('{$var}');\n"; } @@ -1508,12 +1516,12 @@ public function getXcXoopsLoad($var = '', $t = '') * @public function getXcXoopsLoadLanguage * * @param $lang - * @param $t - * @param $domain + * @param string $t + * @param string $domain * * @return string */ - public function getXcXoopsLoadLanguage($lang, $t = '', $domain = '') + public function getXcXoopsLoadLanguage($lang, string $t = '', string $domain = '') { if ('' === $domain) { return "{$t}\xoops_loadLanguage('{$lang}');\n"; @@ -1524,10 +1532,10 @@ public function getXcXoopsLoadLanguage($lang, $t = '', $domain = '') /** * @public function getXcXoopsCaptcha - * @param $t + * @param string $t * @return string */ - public function getXcXoopsCaptcha($t = '') + public function getXcXoopsCaptcha(string $t = '') { return "{$t}\$xoopsCaptcha = \XoopsCaptcha::getInstance();\n"; } @@ -1536,11 +1544,11 @@ public function getXcXoopsCaptcha($t = '') * @public function getXcXoopsListImgListArray * @param $return * @param $var - * @param $t + * @param string $t * * @return string */ - public function getXcXoopsListImgListArray($return, $var, $t = '') + public function getXcXoopsListImgListArray($return, $var, string $t = '') { return "{$t}\${$return} = \XoopsLists::getImgListAsArray( {$var} );\n"; } @@ -1552,7 +1560,7 @@ public function getXcXoopsListImgListArray($return, $var, $t = '') * * @return string */ - public function getXcXoopsListLangList($return, $t = '') + public function getXcXoopsListLangList($return, string $t = '') { return "{$t}\${$return} = \XoopsLists::getLangList();\n"; } @@ -1564,7 +1572,7 @@ public function getXcXoopsListLangList($return, $t = '') * * @return string */ - public function getXcXoopsListCountryList($return, $t = '') + public function getXcXoopsListCountryList($return, string $t = '') { return "{$t}\${$return} = \XoopsLists::getCountryList();\n"; } @@ -1577,7 +1585,7 @@ public function getXcXoopsListCountryList($return, $t = '') * * @return string */ - public function getXcXoopsUserUnameFromId($left, $value, $t = '') + public function getXcXoopsUserUnameFromId($left, $value, string $t = '') { return "{$t}\${$left} = \XoopsUser::getUnameFromId({$value});\n"; } @@ -1587,12 +1595,12 @@ public function getXcXoopsUserUnameFromId($left, $value, $t = '') * * @param $tplString * @param $phpRender - * @param bool $leftIsString + * @param bool $leftIsString * @param string $t * @param string $tpl * @return string */ - public function getXcXoopsTplAssign($tplString, $phpRender, $leftIsString = true, $t = '', $tpl = '') + public function getXcXoopsTplAssign($tplString, $phpRender, bool $leftIsString = true, string $t = '', string $tpl = '') { $assign = "{$t}\$GLOBALS['xoopsTpl']->assign("; if ('' !== $tpl) { @@ -1617,7 +1625,7 @@ public function getXcXoopsTplAssign($tplString, $phpRender, $leftIsString = true * @param string $t * @return string */ - public function getXcXoopsTplAppend($tplString, $phpRender, $t = '') + public function getXcXoopsTplAppend($tplString, $phpRender, string $t = '') { return "{$t}\$GLOBALS['xoopsTpl']->append('{$tplString}', {$phpRender});\n"; } @@ -1631,7 +1639,7 @@ public function getXcXoopsTplAppend($tplString, $phpRender, $t = '') * @param string $t * @return string */ - public function getXcXoopsTplAppendByRef($tplString, $phpRender, $t = '') + public function getXcXoopsTplAppendByRef($tplString, $phpRender, string $t = '') { return "{$t}\$GLOBALS['xoopsTpl']->appendByRef('{$tplString}', {$phpRender});\n"; } @@ -1641,10 +1649,10 @@ public function getXcXoopsTplAppendByRef($tplString, $phpRender, $t = '') * * @param string $displayTpl * @param string $t - * @param bool $usedoublequotes + * @param bool $usedoublequotes * @return string */ - public function getXcXoopsTplDisplay($displayTpl = '{$templateMain}', $t = '', $usedoublequotes = true) + public function getXcXoopsTplDisplay(string $displayTpl = '{$templateMain}', string $t = '', bool $usedoublequotes = true) { if ($usedoublequotes) { return "{$t}\$GLOBALS['xoopsTpl']->display(\"db:{$displayTpl}\");\n"; @@ -1658,12 +1666,12 @@ public function getXcXoopsTplDisplay($displayTpl = '{$templateMain}', $t = '', $ * * @param $directory * @param $filename - * @param bool $isParam + * @param bool $isParam * * @param string $t * @return string */ - public function getXcXoopsPath($directory, $filename, $isParam = false, $t = '') + public function getXcXoopsPath($directory, $filename, bool $isParam = false, string $t = '') { if (!$isParam) { $ret = "{$t}\$GLOBALS['xoops']->path({$directory}.'/{$filename}.php');\n"; @@ -1679,12 +1687,12 @@ public function getXcXoopsPath($directory, $filename, $isParam = false, $t = '') * * @param $left * @param $string - * @param bool $isParam + * @param bool $isParam * * @param string $t * @return string */ - public function getXcXoopsModuleGetInfo($left, $string, $isParam = false, $t = '') + public function getXcXoopsModuleGetInfo($left, $string, bool $isParam = false, string $t = '') { if (!$isParam) { $ret = "{$t}\${$left} = \$GLOBALS['xoopsModule']->getInfo('{$string}');\n"; @@ -1700,10 +1708,10 @@ public function getXcXoopsModuleGetInfo($left, $string, $isParam = false, $t = ' * @param string $style * * @param string $t - * @param bool $isString + * @param bool $isString * @return string */ - public function getXcXoThemeAddStylesheet($style = 'style', $t = '', $isString = true) + public function getXcXoThemeAddStylesheet(string $style = 'style', string $t = '', bool $isString = true) { $ret = "{$t}\$GLOBALS['xoTheme']->addStylesheet("; if ($isString) { @@ -1716,17 +1724,17 @@ public function getXcXoThemeAddStylesheet($style = 'style', $t = '', $isString = /** * @public function getXcXoopsSecurityCheck - * @param $denial - * @return bool + * @param string $denial + * @return string */ - public function getXcXoopsSecurityCheck($denial = '') + public function getXcXoopsSecurityCheck(string $denial = '') { return "{$denial}\$GLOBALS['xoopsSecurity']->check()"; } /** * @public function getXcXoopsSecurityErrors - * @param null + * * @return string */ public function getXcXoopsSecurityErrors() @@ -1741,7 +1749,7 @@ public function getXcXoopsSecurityErrors() * @param string $n * @return string */ - public function getXcXoopsHandler($left, $t = '', $n = "\n") + public function getXcXoopsHandler($left, string $t = '', string $n = "\n") { return "{$t}\${$left}Handler = \xoops_getHandler('{$left}');{$n}"; } @@ -1756,15 +1764,19 @@ public function getXcXoopsHandler($left, $t = '', $n = "\n") * @param $tableName * @param $ccFieldId * @param string $t + * @param string $language * @return string */ - public function getXcCommonPagesEdit($tableName, $ccFieldId, $t = '') + public function getXcCommonPagesEdit($tableName, $ccFieldId, string $t = '', string $language = '') { $pc = Modulebuilder\Files\CreatePhpCode::getInstance(); $xc = Modulebuilder\Files\CreateXoopsCode::getInstance(); $ret = $pc->getPhpCodeCommentLine('Get Form', null, "\t\t"); $ret .= $xc->getXcHandlerGet($tableName, $ccFieldId, 'Obj', $tableName . 'Handler', false, $t); + $tablenameObj = $pc->getPhpCodeIsobject($tableName . 'Obj'); + $redirectError = $xc->getXcRedirectHeader($tableName, '', '3', "{$language}INVALID_PARAM", true, $t . "\t"); + $ret .= $pc->getPhpCodeConditions('!' . $tablenameObj, '', '', $redirectError, false, $t); $ret .= $xc->getXcEqualsOperator("\${$tableName}Obj->start", '$start', null, $t); $ret .= $xc->getXcEqualsOperator("\${$tableName}Obj->limit", '$limit', null, $t); $ret .= $xc->getXcGetForm('form', $tableName, 'Obj', $t); @@ -1779,7 +1791,7 @@ public function getXcCommonPagesEdit($tableName, $ccFieldId, $t = '') * @param string $t * @return string */ - public function getXcCommonPagesNew($tableName, $t = '') + public function getXcCommonPagesNew($tableName, string $t = '') { $pc = Modulebuilder\Files\CreatePhpCode::getInstance(); $xc = Modulebuilder\Files\CreateXoopsCode::getInstance(); @@ -1797,15 +1809,19 @@ public function getXcCommonPagesNew($tableName, $t = '') * @param $tableName * @param $ccFieldId * @param string $t + * @param string $language * @return string */ - public function getXcCommonPagesClone($tableName, $ccFieldId, $t = '') + public function getXcCommonPagesClone($tableName, $ccFieldId, string $t = '', string $language = '') { $pc = Modulebuilder\Files\CreatePhpCode::getInstance(); $xc = Modulebuilder\Files\CreateXoopsCode::getInstance(); $ret = $pc->getPhpCodeCommentLine('Get Form', null, "\t\t"); $ret .= $xc->getXcHandlerGet($tableName, $ccFieldId . 'Source', 'ObjSource', $tableName . 'Handler', false, $t); + $tablenameObj = $pc->getPhpCodeIsobject($tableName . 'ObjSource'); + $redirectError = $xc->getXcRedirectHeader($tableName, '', '3', "{$language}INVALID_PARAM", true, $t . "\t"); + $ret .= $pc->getPhpCodeConditions('!' . $tablenameObj, '', '', $redirectError, false, $t); $ret .= $xc->getXcEqualsOperator('$' . $tableName . 'Obj', '$' . $tableName . 'ObjSource->xoopsClone()', null, $t); $ret .= $xc->getXcGetForm('form', $tableName, 'Obj', $t); $ret .= $xc->getXcXoopsTplAssign('form', '$form->render()', true, $t); @@ -1822,10 +1838,10 @@ public function getXcCommonPagesClone($tableName, $ccFieldId, $t = '') * @param $fieldMain * @param $tableNotifications * @param string $t - * @param bool $admin + * @param bool $admin * @return string */ - public function getXcCommonPagesDelete($language, $tableName, $tableSoleName, $fieldId, $fieldMain, $tableNotifications, $t = '', $admin = false) + public function getXcCommonPagesDelete($language, $tableName, $tableSoleName, $fieldId, $fieldMain, $tableNotifications, string $t = '', bool $admin = false) { $pc = Modulebuilder\Files\CreatePhpCode::getInstance(); $xc = Modulebuilder\Files\CreateXoopsCode::getInstance(); @@ -1835,6 +1851,9 @@ public function getXcCommonPagesDelete($language, $tableName, $tableSoleName, $f $ccFieldMain = $cf->getCamelCase($fieldMain, false, true); $ret = $xc->getXcHandlerGet($tableName, $ccFieldId, 'Obj', $tableName . 'Handler', false, $t); + $tablenameObj = $pc->getPhpCodeIsobject($tableName . 'Obj'); + $redirectError = $xc->getXcRedirectHeader($tableName, '', '3', "{$language}INVALID_PARAM", true, $t . "\t"); + $ret .= $pc->getPhpCodeConditions('!' . $tablenameObj, '', '', $redirectError, false, $t); $ret .= $xc->getXcGetVar($ccFieldMain, "{$tableName}Obj", $fieldMain, false, $t); $reqOk = "_REQUEST['ok']"; $isset = $pc->getPhpCodeIsset($reqOk); diff --git a/class/Files/Docs/DocsChangelog.php b/class/Files/Docs/DocsChangelog.php index 0ac46d81..458bfe55 100644 --- a/class/Files/Docs/DocsChangelog.php +++ b/class/Files/Docs/DocsChangelog.php @@ -33,7 +33,6 @@ class DocsChangelog extends Files\CreateFile { /** * @public function constructor - * @param null */ public function __construct() { @@ -42,7 +41,7 @@ public function __construct() /** * @static function getInstance - * @param null + * * @return DocsChangelog */ public static function getInstance() @@ -68,8 +67,8 @@ public function write($module, $filename): void /** * @public function render - * @param null - * @return bool|string + * + * @return string */ public function render() { diff --git a/class/Files/Docs/DocsFiles.php b/class/Files/Docs/DocsFiles.php index 2648f8c7..82121ec0 100644 --- a/class/Files/Docs/DocsFiles.php +++ b/class/Files/Docs/DocsFiles.php @@ -33,7 +33,6 @@ class DocsFiles extends Files\CreateFile { /** * @public function constructor - * @param null */ public function __construct() { @@ -42,10 +41,7 @@ public function __construct() /** * @static function getInstance - * @param null - */ - - /** + * * @return DocsFiles */ public static function getInstance() @@ -60,11 +56,6 @@ public static function getInstance() /** * @public function write - * @param string $module - * @param string $filename - */ - - /** * @param $module * @param $filename */ @@ -91,14 +82,12 @@ public function write($module, $filename): void public function getChangeLogFile($moduleDirname, $mod_version, $mod_author) { $date = date('Y/m/d G:i:s'); - $ret = <<getVar('table_name'); $tableSoleName = $table->getVar('table_solename'); $tableFieldName = $table->getVar('table_fieldname'); + $language = '\_MA_' . strtoupper($moduleDirname) . '_'; + $fieldId = ''; $ccFieldId = ''; $ccFieldMain = ''; @@ -114,6 +115,9 @@ public function getCommentBody($module, $table) $func1 .= $this->xc->getXcHandlerLine($tableName, $t); $func1 .= $this->xc->getXcEqualsOperator("\${$ccFieldId}", '(int)$itemId', '', $t); $func1 .= $this->xc->getXcHandlerGet($tableName, $ccFieldId, 'Obj', $tableName . 'Handler', false, $t); + $tablenameObj = $this->pc->getPhpCodeIsobject($tableName . 'Obj'); + $redirectError = $this->xc->getXcRedirectHeader($tableName, '', '3', "{$language}INVALID_PARAM", true, $t . "\t"); + $func1 .= $this->pc->getPhpCodeConditions('!' . $tablenameObj, '', '', $redirectError, false, $t); $func1 .= $this->xc->getXcSetVarObj($tableName, $tableFieldName . '_comments', '(int)$itemNumb', $t); $insert = $this->xc->getXcHandlerInsert($tableName, $tableName, 'Obj'); $contIf = $this->getSimpleString('return true;', $t . "\t"); @@ -125,9 +129,13 @@ public function getCommentBody($module, $table) $func2 = $this->pc->getPhpCodeCommentLine('Notification event', '', $t); $func2 .= $this->xc->getXcHelperGetInstance($moduleDirname, $t); $func2 .= $this->xc->getXcHandlerLine($tableName, $t); - $func2 .= $this->xc->getXcGetVar($ccFieldId, 'comment', 'com_itemid', false, $t); + $func2 .= $this->getSimpleString('$' . $ccFieldId . " = (int)\$comment->getVar('com_itemid');", $t); $func2 .= $this->xc->getXcHandlerGet($tableName, $ccFieldId, 'Obj', $tableName . 'Handler', false, $t); + $tablenameObj = $this->pc->getPhpCodeIsobject($tableName . 'Obj'); + $redirectError = $this->xc->getXcRedirectHeader($tableName, '', '3', "{$language}INVALID_PARAM", true, $t . "\t"); + $func2 .= $this->pc->getPhpCodeConditions('!' . $tablenameObj, '', '', $redirectError, false, $t); $func2 .= $this->xc->getXcGetVar($ccFieldMain, "{$tableName}Obj", $fieldMain, false, $t); + $func2 .= $this->pc->getPhpCodeBlankLine(); $func2 .= $this->pc->getPhpCodeArray('tags', [], false, $t); $func2 .= $this->xc->getXcEqualsOperator("\$tags['ITEM_NAME']", "\${$ccFieldMain}", '', $t); @@ -146,8 +154,8 @@ public function getCommentBody($module, $table) /** * @public function render - * @param null - * @return bool|string + * + * @return string */ public function render() { diff --git a/class/Files/Includes/IncludeComments.php b/class/Files/Includes/IncludeComments.php index 12ef9880..c0e39a4f 100644 --- a/class/Files/Includes/IncludeComments.php +++ b/class/Files/Includes/IncludeComments.php @@ -42,7 +42,6 @@ class IncludeComments extends Files\CreateFile /** * @public function constructor - * @param null */ public function __construct() { @@ -53,7 +52,7 @@ public function __construct() /** * @static function getInstance - * @param null + * * @return IncludeComments */ public static function getInstance() @@ -68,8 +67,8 @@ public static function getInstance() /** * @public function write - * @param string $module - * @param mixed $table + * @param $module + * @param mixed $table */ public function write($module, $table): void { @@ -79,12 +78,12 @@ public function write($module, $table): void /** * @public function getCommentsIncludes - * @param string $module + * @param $module * @param string $filename * - * @return bool|string + * @return string */ - public function renderCommentsIncludes($module, $filename) + public function renderCommentsIncludes($module, string $filename) { $moduleDirname = $module->getVar('mod_dirname'); $content = $this->getHeaderFilesComments($module); @@ -98,12 +97,12 @@ public function renderCommentsIncludes($module, $filename) /** * @public function getCommentsNew - * @param string $module + * @param $module * @param string $filename * - * @return bool|string + * @return string */ - public function renderCommentsNew($module, $filename) + public function renderCommentsNew($module, string $filename) { $table = $this->getTable(); $moduleDirname = \mb_strtolower($module->getVar('mod_dirname')); diff --git a/class/Files/Includes/IncludeCommon.php b/class/Files/Includes/IncludeCommon.php index 221c208f..85a59b21 100644 --- a/class/Files/Includes/IncludeCommon.php +++ b/class/Files/Includes/IncludeCommon.php @@ -46,7 +46,6 @@ class IncludeCommon extends Files\CreateFile /** * @public function constructor - * @param null */ public function __construct() { @@ -58,7 +57,7 @@ public function __construct() /** * @static function getInstance - * @param null + * * @return IncludeCommon */ public static function getInstance() @@ -73,11 +72,11 @@ public static function getInstance() /** * @public function write - * @param string $module + * @param $module * @param object $table * @param string $filename */ - public function write($module, $table, $filename): void + public function write($module, object $table, string $filename): void { $this->setModule($module); $this->setTable($table); @@ -102,9 +101,8 @@ private function getCommonDefines($modDirname, $const, $desc) * @param \XoopsObject $module * @return string */ - private function getCommonCode($module) + private function getCommonCode(\XoopsObject $module) { - $table = $this->getTable(); $moduleDirname = $module->getVar('mod_dirname'); $stuModuleDirname = \mb_strtoupper($moduleDirname); $moduleAuthor = $module->getVar('mod_author'); @@ -113,10 +111,10 @@ private function getCommonCode($module) $moduleAuthorImage = \str_replace(' ', '', \mb_strtolower($moduleAuthor)); $contIf = $this->pc->getPhpCodeDefine('XOOPS_ICONS32_PATH', "\XOOPS_ROOT_PATH . '/Frameworks/moduleclasses/icons/32'", "\t"); - $ret = $this->pc->getPhpCodeConditions("!\defined('XOOPS_ICONS32_PATH')", '', '', $contIf, false); + $ret = $this->pc->getPhpCodeConditions("!\defined('XOOPS_ICONS32_PATH')", '', '', $contIf); $contIf = $this->pc->getPhpCodeDefine('XOOPS_ICONS32_URL', "\XOOPS_URL . '/Frameworks/moduleclasses/icons/32'", "\t"); - $ret .= $this->pc->getPhpCodeConditions("!\defined('XOOPS_ICONS32_URL')", '', '', $contIf, false); - $ret .= $this->getCommonDefines($moduleDirname, 'DIRNAME', "'{$moduleDirname}'"); + $ret .= $this->pc->getPhpCodeConditions("!\defined('XOOPS_ICONS32_URL')", '', '', $contIf); + $ret .= $this->getCommonDefines($moduleDirname, 'DIRNAME', "\basename(\dirname(__DIR__))"); $ret .= $this->getCommonDefines($moduleDirname, 'PATH', "\XOOPS_ROOT_PATH . '/modules/' . \\{$stuModuleDirname}_DIRNAME"); $ret .= $this->getCommonDefines($moduleDirname, 'URL', "\XOOPS_URL . '/modules/' . \\{$stuModuleDirname}_DIRNAME"); $ret .= $this->getCommonDefines($moduleDirname, 'ICONS_PATH', "\\{$stuModuleDirname}_PATH . '/assets/icons'"); @@ -126,13 +124,14 @@ private function getCommonCode($module) $ret .= $this->getCommonDefines($moduleDirname, 'UPLOAD_PATH', "\XOOPS_UPLOAD_PATH . '/' . \\{$stuModuleDirname}_DIRNAME"); $ret .= $this->getCommonDefines($moduleDirname, 'UPLOAD_URL', "\XOOPS_UPLOAD_URL . '/' . \\{$stuModuleDirname}_DIRNAME"); + /* if (\is_object($table)) { $fields = $this->getTableFields($table->getVar('table_mid'), $table->getVar('table_id')); $fieldElement = []; foreach (\array_keys($fields) as $f) { $fieldElement[] = $fields[$f]->getVar('field_element'); } - } + }*/ $ret .= $this->getCommonDefines($moduleDirname, 'UPLOAD_FILES_PATH', "\\{$stuModuleDirname}_UPLOAD_PATH . '/files'"); $ret .= $this->getCommonDefines($moduleDirname, 'UPLOAD_FILES_URL', "\\{$stuModuleDirname}_UPLOAD_URL . '/files'"); $ret .= $this->getCommonDefines($moduleDirname, 'UPLOAD_IMAGE_PATH', "\\{$stuModuleDirname}_UPLOAD_PATH . '/images'"); @@ -155,8 +154,8 @@ private function getCommonCode($module) /** * @public function render - * @param null - * @return bool|string + * + * @return string */ public function render() { diff --git a/class/Files/Includes/IncludeFunctions.php b/class/Files/Includes/IncludeFunctions.php index f587980e..5dc303f7 100644 --- a/class/Files/Includes/IncludeFunctions.php +++ b/class/Files/Includes/IncludeFunctions.php @@ -42,7 +42,6 @@ class IncludeFunctions extends Files\CreateFile /** * @public function constructor - * @param null */ public function __construct() { @@ -53,7 +52,7 @@ public function __construct() /** * @static function getInstance - * @param null + * * @return IncludeFunctions */ public static function getInstance() @@ -84,7 +83,7 @@ public function write($module, $filename): void * * @return string */ - private function getFunctionBlock($moduleDirname) + private function getFunctionBlock(string $moduleDirname) { $t = "\t"; $ret = $this->pc->getPhpCodeCommentMultiLine(['function' => 'add selected cats to block', '' => '', '@param $cats' => '', '@return' => 'string']); @@ -107,7 +106,7 @@ private function getFunctionBlock($moduleDirname) * * @return string */ - private function getFunctionGetMyItemIds($moduleDirname) + private function getFunctionGetMyItemIds(string $moduleDirname) { $t = "\t"; $ret = $this->pc->getPhpCodeCommentMultiLine(['Get the permissions ids' => '', '' => '', '@param $permtype' => '', '@param $dirname' => '', '@return' => 'mixed $itemIds']); @@ -117,6 +116,10 @@ private function getFunctionGetMyItemIds($moduleDirname) $func .= $this->pc->getPhpCodeConditions('\is_array($permissions) && \array_key_exists($permtype, $permissions)', '', '', $contIf, false, $t); $func .= $this->xc->getXcXoopsHandler('module', $t); $func .= $this->xc->getXcEqualsOperator("\${$moduleDirname}Module", '$moduleHandler->getByDirname($dirname)', '', $t); + $condIf = $this->getSimpleString('return [];', $t . "\t"); + $func .= $this->pc->getPhpCodeConditions("!\is_object(\${$moduleDirname}Module)", '', '', $condIf, false, $t); + + $func .= $this->pc->getPhpCodeTernaryOperator('groups', '\is_object($xoopsUser)', '$xoopsUser->getGroups()', '\XOOPS_GROUP_ANONYMOUS', $t); $func .= $this->xc->getXcXoopsHandler('groupperm', $t); $func .= $this->xc->getXcEqualsOperator('$itemIds', "\$grouppermHandler->getItemIds(\$permtype, \$groups, \${$moduleDirname}Module->getVar('mid'))", '', $t); @@ -136,7 +139,7 @@ private function getFunctionGetMyItemIds($moduleDirname) * * @return string */ - private function getFunctionNumbersOfEntries($moduleDirname, $tableMid, $tableId, $tableName) + private function getFunctionNumbersOfEntries(string $moduleDirname, $tableMid, $tableId, $tableName) { $fields = $this->getTableFields($tableMid, $tableId); $fieldId = ''; @@ -146,7 +149,7 @@ private function getFunctionNumbersOfEntries($moduleDirname, $tableMid, $tableId $fieldId = $fieldName; // fieldMain = fields parameters main field } } - $ret = <<getHandler('{$tableName}'); \$lenght_id = \$helper->getConfig('lenght_id'); \$rewrite_url = \$helper->getConfig('rewrite_url'); @@ -342,22 +336,18 @@ function {$moduleDirname}_RewriteUrl(\$module, \$array, \$type = 'content') return null; } EOT; - - return $ret; } /** * @private function getRewriteFilter - * * @param string $moduleDirname - * @param string $tableName * * @return string */ - private function getRewriteFilter($moduleDirname, $tableName) + private function getRewriteFilter(string $moduleDirname) { $ucfModuleDirname = \ucfirst($moduleDirname); - $ret = <<getHandler('{$tableName}'); \$regular_expression = \$helper->getConfig('regular_expression'); \$url = \strip_tags(\$url); - \$url .= \preg_replace('`\[.*\]`U', '', \$url); - \$url .= \preg_replace('`&(amp;)?#?[a-z0-9]+;`i', '-', \$url); - \$url .= \htmlentities(\$url, ENT_COMPAT, 'utf-8'); - \$url .= \preg_replace('`&([a-z])(acute|uml|circ|grave|ring|cedil|slash|tilde|caron|lig);`i', "\\1", \$url); - \$url .= \preg_replace([\$regular_expression, '`[-]+`'], '-', \$url); + \$url = \preg_replace('`\[.*\]`U', '', \$url); + \$url = \preg_replace('`&(amp;)?#?[a-z0-9]+;`i', '-', \$url); + \$url = \htmlentities(\$url, ENT_COMPAT, 'utf-8'); + \$url = \preg_replace('`&([a-z])(acute|uml|circ|grave|ring|cedil|slash|tilde|caron|lig);`i', '$1', \$url); + \$url = \preg_replace([\$regular_expression, '`[-]+`'], '-', \$url); \$url = ('' == \$url) ? \$type : \strtolower(\\trim(\$url, '-')); return \$url; } EOT; - - return $ret; } /** * @public function render * - * @param null - * - * @return bool|string + * @return string */ public function render() { @@ -425,8 +410,8 @@ public function render() } $content .= $this->getFunctionMetaKeywords($moduleDirname); $content .= $this->getFunctionMetaDescription($moduleDirname); - $content .= $this->getRewriteUrl($moduleDirname, $tableName); - $content .= $this->getRewriteFilter($moduleDirname, $tableName); + $content .= $this->getRewriteUrl($moduleDirname); + $content .= $this->getRewriteFilter($moduleDirname); $this->create($moduleDirname, 'include', $filename, $content, \_AM_MODULEBUILDER_FILE_CREATED, \_AM_MODULEBUILDER_FILE_NOTCREATED); diff --git a/class/Files/Includes/IncludeJquery.php b/class/Files/Includes/IncludeJquery.php index d273139d..cd8d8a55 100644 --- a/class/Files/Includes/IncludeJquery.php +++ b/class/Files/Includes/IncludeJquery.php @@ -39,7 +39,6 @@ class IncludeJquery extends Files\CreateFile /** * @public function constructor - * @param null */ public function __construct() { @@ -48,7 +47,7 @@ public function __construct() /** * @static function getInstance - * @param null + * * @return IncludeJquery */ public static function getInstance() @@ -63,10 +62,10 @@ public static function getInstance() /** * @public function write - * @param string $module + * @param $module * @param string $filename */ - public function write($module, $filename): void + public function write($module, string $filename): void { $this->setModule($module); $this->setFileName($filename); @@ -74,8 +73,8 @@ public function write($module, $filename): void /** * @public function render - * @param null - * @return bool|string + * + * @return string */ public function render() { diff --git a/class/Files/Includes/IncludeNotifications.php b/class/Files/Includes/IncludeNotifications.php index 9441b6f9..eee449f8 100644 --- a/class/Files/Includes/IncludeNotifications.php +++ b/class/Files/Includes/IncludeNotifications.php @@ -42,7 +42,6 @@ class IncludeNotifications extends Files\CreateFile /** * @public function constructor - * @param null */ public function __construct() { @@ -53,7 +52,7 @@ public function __construct() /** * @static function getInstance - * @param null + * * @return IncludeNotifications */ public static function getInstance() @@ -68,11 +67,11 @@ public static function getInstance() /** * @public function write - * @param string $module + * @param $module * @param mixed $tables * @param string $filename */ - public function write($module, $tables, $filename): void + public function write($module, $tables, string $filename): void { $this->setModule($module); $this->setTables($tables); @@ -85,7 +84,7 @@ public function write($module, $tables, $filename): void * * @return string */ - public function getNotificationsFunction($moduleDirname) + public function getNotificationsFunction(string $moduleDirname) { $stuModuleDirname = \mb_strtoupper($moduleDirname); $tables = $this->getTables(); @@ -97,6 +96,7 @@ public function getNotificationsFunction($moduleDirname) $func .= $this->pc->getPhpCodeConditions("!\defined('{$stuModuleDirname}_URL')", '', '', $contIf, false, $t); $func .= $this->pc->getPhpCodeBlankLine(); + $func .= $this->xc->getXcEqualsOperator("\$itemId", "(int)\$item_id", '', $t); $case[] = $this->xc->getXcEqualsOperator("\$item['name']", "''", '', $t . "\t\t"); $case[] = $this->xc->getXcEqualsOperator("\$item['url'] ", "''", '', $t . "\t\t"); $case[] = $this->getSimpleString('return $item;', $t . "\t\t"); @@ -130,14 +130,17 @@ public function getNotificationsFunction($moduleDirname) } else { $tableSingle = $tableName; } - $case[] = $this->xc->getXcEqualsOperator('$sql ', "'SELECT {$fieldMain} FROM ' . \$xoopsDB->prefix('{$moduleDirname}_{$tableName}') . ' WHERE {$fieldId} = '. \$item_id", '', $t . "\t\t"); - $case[] = $this->xc->getXcEqualsOperator('$result ', '$xoopsDB->query($sql)', '', $t . "\t\t"); + $case[] = $this->xc->getXcEqualsOperator('$sql ', "'SELECT {$fieldMain} FROM ' . \$xoopsDB->prefix('{$moduleDirname}_{$tableName}') . ' WHERE {$fieldId} = '. \$itemId", '', $t . "\t\t"); + $case[] = $this->xc->getXcEqualsOperator('$result', '$xoopsDB->query($sql)', '', $t . "\t\t"); + $condIf = $this->getSimpleString('return [];', $t . "\t\t\t"); + $case[] .= $this->pc->getPhpCodeConditions('!$result', '', '', $condIf, false, $t . "\t\t"); $case[] = $this->xc->getXcEqualsOperator('$result_array', '$xoopsDB->fetchArray($result)', '', $t . "\t\t"); + $case[] .= $this->pc->getPhpCodeConditions('!$result_array', '', '', $condIf, false, $t . "\t\t"); $case[] = $this->xc->getXcEqualsOperator("\$item['name']", "\$result_array['{$fieldMain}']", '', $t . "\t\t"); if ($fieldParent) { - $case[] = $this->xc->getXcEqualsOperator("\$item['url'] ", "\\{$stuModuleDirname}_URL . '/{$tableSingle}.php?{$fieldParent}=' . \$result_array['{$fieldParent}'] . '&{$fieldId}=' . \$item_id", '', $t . "\t\t"); + $case[] = $this->xc->getXcEqualsOperator("\$item['url'] ", "\\{$stuModuleDirname}_URL . '/{$tableSingle}.php?{$fieldParent}=' . \$result_array['{$fieldParent}'] . '&{$fieldId}=' . \$itemId", '', $t . "\t\t"); } else { - $case[] = $this->xc->getXcEqualsOperator("\$item['url'] ", "\\{$stuModuleDirname}_URL . '/{$tableName}.php?{$fieldId}=' . \$item_id", '', $t . "\t\t"); + $case[] = $this->xc->getXcEqualsOperator("\$item['url'] ", "\\{$stuModuleDirname}_URL . '/{$tableName}.php?{$fieldId}=' . \$itemId", '', $t . "\t\t"); } $case[] = $this->getSimpleString('return $item;', $t . "\t\t"); @@ -158,8 +161,8 @@ public function getNotificationsFunction($moduleDirname) /** * @public function render - * @param null - * @return bool|string + * + * @return string */ public function render() { diff --git a/class/Files/Includes/IncludeSearch.php b/class/Files/Includes/IncludeSearch.php index 723dd244..c9e6fbcc 100644 --- a/class/Files/Includes/IncludeSearch.php +++ b/class/Files/Includes/IncludeSearch.php @@ -46,7 +46,6 @@ class IncludeSearch extends Files\CreateFile /** * @public function constructor - * @param null */ public function __construct() { @@ -58,7 +57,7 @@ public function __construct() /** * @static function getInstance - * @param null + * * @return IncludeSearch */ public static function getInstance() @@ -73,11 +72,11 @@ public static function getInstance() /** * @public function write - * @param string $module + * @param $module * @param mixed $tables * @param string $filename */ - public function write($module, $tables, $filename): void + public function write($module, $tables, string $filename): void { $this->setModule($module); $this->setFileName($filename); @@ -105,7 +104,6 @@ public function getSearchFunction($moduleDirname) $tableId = $tables[$i]->getVar('table_id'); $tableMid = $tables[$i]->getVar('table_mid'); $tableName = $tables[$i]->getVar('table_name'); - $tableFieldname = $tables[$i]->getVar('table_fieldname'); $func .= $this->pc->getPhpCodeCommentLine('search in table', $tableName, $t); $func .= $this->pc->getPhpCodeCommentLine('search keywords', '', $t); $func .= $this->xc->getXcEqualsOperator('$elementCount', '0', '', $t); @@ -203,8 +201,8 @@ public function getSearchFunction($moduleDirname) /** * @public function render - * @param null - * @return bool|string + * + * @return string */ public function render() { diff --git a/class/Files/Language/LanguageAdmin.php b/class/Files/Language/LanguageAdmin.php index 969ee6b7..1169b4ba 100644 --- a/class/Files/Language/LanguageAdmin.php +++ b/class/Files/Language/LanguageAdmin.php @@ -45,7 +45,6 @@ class LanguageAdmin extends Files\CreateFile /** * @public function constructor - * @param null */ public function __construct() { @@ -56,7 +55,7 @@ public function __construct() /** * @static function getInstance - * @param null + * * @return LanguageAdmin */ public static function getInstance() @@ -71,12 +70,12 @@ public static function getInstance() /** * @public function write - * @param string $module + * @param $module * @param $table - * @param string $tables + * @param $tables * @param string $filename */ - public function write($module, $table, $tables, $filename): void + public function write($module, $table, $tables, string $filename): void { $this->setModule($module); $this->setTable($table); @@ -87,10 +86,10 @@ public function write($module, $table, $tables, $filename): void /** * @public function getLanguageAdminIndex * @param string $language - * @param array $tables + * @param array $tables * @return string */ - public function getLanguageAdminIndex($language, $tables) + public function getLanguageAdminIndex(string $language, array $tables) { $thereare = ''; $tableUser = 0; @@ -120,18 +119,18 @@ public function getLanguageAdminIndex($language, $tables) /** * @public function getLanguageAdminPages * @param string $language - * @param array $tables + * @param array $tables * @return string */ - public function getLanguageAdminPages($language, $tables) + public function getLanguageAdminPages(string $language, array $tables) { $ret = $this->ld->getAboveHeadDefines('Admin Files'); - $ret .= $this->ld->getAboveDefines('There aren\'t'); + $ret .= $this->ld->getAboveDefines('There are no'); foreach (\array_keys($tables) as $t) { $tableName = $tables[$t]->getVar('table_name'); $stuTableName = \mb_strtoupper($tableName); $stlTableName = \mb_strtolower($tableName); - $ret .= $this->ld->getDefine($language, "THEREARENT_{$stuTableName}", "There aren't {$stlTableName}", true); + $ret .= $this->ld->getDefine($language, "THEREARENO_{$stuTableName}", "There are no {$stlTableName}", true); } $ret .= $this->ld->getAboveDefines('Save/Delete'); $ret .= $this->ld->getDefine($language, 'FORM_OK', 'Successfully saved'); @@ -161,10 +160,10 @@ public function getLanguageAdminPages($language, $tables) /** * @public function getLanguageAdminClass * @param string $language - * @param array $tables + * @param array $tables * @return string */ - public function getLanguageAdminClass($language, $tables) + public function getLanguageAdminClass(string $language, array $tables) { $ret = $this->ld->getAboveHeadDefines('Admin Classes'); $fieldStatus = 0; @@ -237,6 +236,9 @@ public function getLanguageAdminClass($language, $tables) } } } + $ret .= $this->ld->getAboveDefines('Errors'); + $ret .= $this->ld->getDefine($language, 'INVALID_DATE', 'Invalid date'); + $ret .= $this->ld->getDefine($language, 'INVALID_PARAM', 'Invalid parameter'); $ret .= $this->ld->getAboveDefines('General'); $ret .= $this->ld->getDefine($language, 'FORM_UPLOAD', 'Upload file'); $ret .= $this->ld->getDefine($language, 'FORM_UPLOAD_NEW', 'Upload new file: '); @@ -248,10 +250,12 @@ public function getLanguageAdminClass($language, $tables) $ret .= $this->ld->getDefine($language, 'FORM_ACTION', 'Action'); $ret .= $this->ld->getDefine($language, 'FORM_EDIT', 'Modification'); $ret .= $this->ld->getDefine($language, 'FORM_DELETE', 'Clear'); + if ($fieldStatus > 0) { $ret .= $this->ld->getAboveDefines('Status'); $ret .= $this->ld->getDefine($language, 'STATUS_NONE', 'No status'); $ret .= $this->ld->getDefine($language, 'STATUS_OFFLINE', 'Offline'); + $ret .= $this->ld->getDefine($language, 'STATUS_ONLINE', 'Online'); $ret .= $this->ld->getDefine($language, 'STATUS_SUBMITTED', 'Submitted'); $ret .= $this->ld->getDefine($language, 'STATUS_APPROVED', 'Approved'); $ret .= $this->ld->getDefine($language, 'STATUS_BROKEN', 'Broken'); @@ -291,7 +295,7 @@ public function getLanguageAdminClass($language, $tables) * @param string $language * @return string */ - public function getLanguageAdminPermissions($language) + public function getLanguageAdminPermissions(string $language) { $ret = $this->ld->getAboveHeadDefines('Admin Permissions'); $ret .= $this->ld->getAboveDefines('Permissions'); @@ -316,7 +320,7 @@ public function getLanguageAdminPermissions($language) * @param string $language * @return string */ - public function getLanguageAdminFoot($language) + public function getLanguageAdminFoot(string $language) { $ret = $this->ld->getAboveHeadDefines('Admin Others'); $ret .= $this->ld->getDefine($language, 'ABOUT_MAKE_DONATION', 'Submit'); @@ -331,8 +335,8 @@ public function getLanguageAdminFoot($language) /** * @public function render - * @param null - * @return bool|string + * + * @return string */ public function render() { diff --git a/class/Files/Language/LanguageBlocks.php b/class/Files/Language/LanguageBlocks.php index b7721fec..5873e2ab 100644 --- a/class/Files/Language/LanguageBlocks.php +++ b/class/Files/Language/LanguageBlocks.php @@ -38,7 +38,6 @@ class LanguageBlocks extends Files\CreateFile /** * @public function constructor - * @param null */ public function __construct() { @@ -48,7 +47,7 @@ public function __construct() /** * @static function getInstance - * @param null + * * @return LanguageBlocks */ public static function getInstance() @@ -63,11 +62,11 @@ public static function getInstance() /** * @public function write - * @param string $module + * @param $module * @param mixed $tables * @param string $filename */ - public function write($module, $tables, $filename): void + public function write($module, $tables, string $filename): void { $this->setModule($module); $this->setFileName($filename); @@ -80,7 +79,7 @@ public function write($module, $tables, $filename): void * * @return string */ - private function getLanguageBlock($language) + private function getLanguageBlock(string $language) { $tables = $this->getTables(); $ret = $this->ld->getAboveDefines('Admin Edit'); @@ -119,7 +118,7 @@ private function getLanguageBlock($language) /** * @private function getFooter - * @param null + * * @return string */ private function getLanguageFooter() @@ -132,8 +131,8 @@ private function getLanguageFooter() /** * @public function render - * @param null - * @return bool|string + * + * @return string */ public function render() { diff --git a/class/Files/Language/LanguageDefines.php b/class/Files/Language/LanguageDefines.php index a97d3248..ed15270f 100644 --- a/class/Files/Language/LanguageDefines.php +++ b/class/Files/Language/LanguageDefines.php @@ -32,7 +32,6 @@ class LanguageDefines { /** * @public function constructor - * @param null */ public function __construct() { @@ -40,7 +39,7 @@ public function __construct() /** * @static function getInstance - * @param null + * * @return LanguageDefines */ public static function getInstance() @@ -58,7 +57,7 @@ public static function getInstance() * @param string $string * @return string */ - public function getAboveHeadDefines($string) + public function getAboveHeadDefines(string $string) { return "// ---------------- {$string} ----------------\n"; } @@ -68,7 +67,7 @@ public function getAboveHeadDefines($string) * @param string $string * @return string */ - public function getAboveDefines($string) + public function getAboveDefines(string $string) { return "// {$string}\n"; } @@ -78,10 +77,10 @@ public function getAboveDefines($string) * @param string $language * @param string $defined * @param string $description - * @param bool $usedoubleqoute + * @param bool $usedoubleqoute * @return string */ - public function getDefine($language, $defined, $description, $usedoubleqoute = false) + public function getDefine(string $language, string $defined, string $description, bool $usedoubleqoute = false) { $pc = Modulebuilder\Files\CreatePhpCode::getInstance(); @@ -102,7 +101,7 @@ public function getDefine($language, $defined, $description, $usedoubleqoute = f * * @return string */ - public function getBelowDefines($string) + public function getBelowDefines(string $string) { return "// ---------------- {$string} ----------------"; } diff --git a/class/Files/Language/LanguageHelp.php b/class/Files/Language/LanguageHelp.php index 83f6a551..709ec765 100644 --- a/class/Files/Language/LanguageHelp.php +++ b/class/Files/Language/LanguageHelp.php @@ -34,21 +34,20 @@ class LanguageHelp extends Files\CreateFile /** * @var mixed */ - private $ld = null; + //private $ld = null; /** * @public function constructor - * @param null */ public function __construct() { parent::__construct(); - $this->ld = LanguageDefines::getInstance(); + //$this->ld = LanguageDefines::getInstance(); } /** * @static function getInstance - * @param null + * * @return LanguageHelp */ public static function getInstance() @@ -63,10 +62,10 @@ public static function getInstance() /** * @public function write - * @param string $module + * @param $module * @param string $filename */ - public function write($module, $filename): void + public function write($module, string $filename): void { $this->setModule($module); $this->setFileName($filename); @@ -74,8 +73,8 @@ public function write($module, $filename): void /** * @public function render - * @param null - * @return bool|string + * + * @return string */ public function render() { diff --git a/class/Files/Language/LanguageMailTpl.php b/class/Files/Language/LanguageMailTpl.php index baca80da..5bc18e34 100644 --- a/class/Files/Language/LanguageMailTpl.php +++ b/class/Files/Language/LanguageMailTpl.php @@ -33,7 +33,6 @@ class LanguageMailTpl extends Files\CreateFile { /** * @public function constructor - * @param null */ public function __construct() { @@ -42,7 +41,7 @@ public function __construct() /** * @static function getInstance - * @param null + * * @return LanguageMailTpl */ public static function getInstance() @@ -348,7 +347,7 @@ public function getTemplateTableFooter($line) /** * @public function renderFile - * @return bool|string + * @return string */ public function render() { diff --git a/class/Files/Language/LanguageMain.php b/class/Files/Language/LanguageMain.php index abb2c015..5bfae901 100644 --- a/class/Files/Language/LanguageMain.php +++ b/class/Files/Language/LanguageMain.php @@ -42,7 +42,6 @@ class LanguageMain extends Files\CreateFile /** * @public function constructor - * @param null */ public function __construct() { @@ -53,7 +52,7 @@ public function __construct() /** * @static function getInstance - * @param null + * * @return LanguageMain */ public static function getInstance() @@ -68,11 +67,11 @@ public static function getInstance() /** * @public function write - * @param string $module + * @param $module * @param mixed $tables * @param string $filename */ - public function write($module, $tables, $filename): void + public function write($module, $tables, string $filename): void { $this->setModule($module); $this->setFileName($filename); @@ -81,22 +80,22 @@ public function write($module, $tables, $filename): void /** * @private function getLanguageMain - * @param string $module + * @param $module * @param string $language * * @return string */ - private function getLanguageMain($module, $language) + private function getLanguageMain($module, string $language) { $utility = new \XoopsModules\Modulebuilder\Utility(); - $moduleName = $module->getVar('mod_name'); $tables = $this->getTables(); $ret = $this->ld->getBlankLine(); $ret .= $this->pc->getPhpCodeIncludeDir('__DIR__', 'admin', true); $ret .= $this->ld->getBlankLine(); $ret .= $this->ld->getAboveHeadDefines('Main'); - $ret .= $this->ld->getDefine($language, 'INDEX', 'Overview ' . (string)$module->getVar('mod_name')); + $ret .= $this->ld->getDefine($language, 'HOME', 'Home'); + $ret .= $this->ld->getDefine($language, 'INDEX', 'Overview ' . $module->getVar('mod_name')); $ret .= $this->ld->getDefine($language, 'TITLE', (string)$module->getVar('mod_name')); $ret .= $this->ld->getDefine($language, 'DESC', (string)$module->getVar('mod_description')); $ret .= $this->ld->getDefine($language, 'NO_PDF_LIBRARY', 'Libraries TCPDF not there yet, upload them in root/Frameworks'); @@ -105,9 +104,6 @@ private function getLanguageMain($module, $language) $ret .= $this->ld->getDefine($language, 'BROKEN', 'Notify broken'); $ret .= $this->ld->getAboveHeadDefines('Contents'); $ucfTableName = ''; - $ucfTableSoleName = ''; - $stuTableSoleName = ''; - $tableSoleName = ''; $tableSubmit = 0; $tableBroken = 0; $tableRate = 0; @@ -170,7 +166,6 @@ private function getLanguageMain($module, $language) if (1 === $tableBroken) { $ret .= $this->ld->getDefine($language, 'FORM_SURE_BROKEN', "Are you sure to notify as broken: %s ", true); } - $ret .= $this->ld->getDefine($language, 'INVALID_PARAM', 'Invalid parameter'); } if (1 === $tableRate) { $ret .= $this->ld->getAboveHeadDefines('Ratings'); @@ -205,6 +200,9 @@ private function getLanguageMain($module, $language) $ret .= $this->ld->getAboveHeadDefines('Print'); $ret .= $this->ld->getDefine($language, 'PRINT', 'Print'); } + $ret .= $this->ld->getAboveDefines('Errors'); + $ret .= $this->ld->getDefine($language, 'INVALID_DATE', 'Invalid date'); + $ret .= $this->ld->getDefine($language, 'INVALID_PARAM', 'Invalid parameter'); return $ret; } @@ -215,7 +213,7 @@ private function getLanguageMain($module, $language) * * @return string */ - private function getLanguageMainFooter($language) + private function getLanguageMainFooter(string $language) { $ret = $this->ld->getAboveDefines('Admin link'); $ret .= $this->ld->getDefine($language, 'ADMIN', 'Admin'); @@ -227,8 +225,8 @@ private function getLanguageMainFooter($language) /** * @public function render - * @param null - * @return bool|string + * + * @return string */ public function render() { diff --git a/class/Files/Language/LanguageModinfo.php b/class/Files/Language/LanguageModinfo.php index 2b87dd1d..2ba32095 100644 --- a/class/Files/Language/LanguageModinfo.php +++ b/class/Files/Language/LanguageModinfo.php @@ -42,7 +42,6 @@ class LanguageModinfo extends Files\CreateFile /** * @public function constructor - * @param null */ public function __construct() { @@ -53,7 +52,7 @@ public function __construct() /** * @static function getInstance - * @param null + * * @return LanguageModinfo */ public static function getInstance() @@ -167,7 +166,7 @@ private function getLanguageAdmin($language) * * @return string */ - private function getLanguageSubmenu($language, $tables) + private function getLanguageSubmenu($language, array $tables) { $ret = $this->ld->getAboveDefines('Submenu'); $ret .= $this->ld->getDefine($language, 'SMNAME1', 'Index page'); @@ -203,7 +202,7 @@ private function getLanguageSubmenu($language, $tables) * * @return string */ - private function getLanguageBlocks($tables, $language) + private function getLanguageBlocks(array $tables, $language) { $ret = $this->ld->getAboveDefines('Blocks'); foreach (\array_keys($tables) as $i) { @@ -500,7 +499,7 @@ private function getLanguageRatingbars($language) /** * @private function getFooter - * @param null + * * @return string */ private function getLanguageFooter() @@ -513,8 +512,8 @@ private function getLanguageFooter() /** * @public function render - * @param null - * @return bool|string + * + * @return string */ public function render() { diff --git a/class/Files/Sql/SqlFile.php b/class/Files/Sql/SqlFile.php index e14a2b83..78ca77f9 100644 --- a/class/Files/Sql/SqlFile.php +++ b/class/Files/Sql/SqlFile.php @@ -110,7 +110,7 @@ private function getHeaderSqlComments($moduleName) * * @return string */ - private function getHeadDatabaseTable($moduleDirname, $tableName, $fieldsNumb) + private function getHeadDatabaseTable($moduleDirname, $tableName, int $fieldsNumb) { $ret = null; $arrayDbTable = [ @@ -384,11 +384,11 @@ private function getFootDatabaseTable() * @param $fieldNull * @param $fieldDefault * @param $autoincrement - * @param $lenMax + * @param int $lenMax * * @return string */ - private function getFieldRow($fieldName, $fieldTypeValue, $fieldAttribute = null, $fieldNull = null, $fieldDefault = null, $autoincrement = null, $lenMax = 0) + private function getFieldRow($fieldName, $fieldTypeValue, $fieldAttribute = null, $fieldNull = null, $fieldDefault = null, $autoincrement = null, int $lenMax = 0) { $fieldNameMax = " `{$fieldName}`"; if ($lenMax > 0) { diff --git a/class/Files/Templates/Admin/TemplatesAdminAbout.php b/class/Files/Templates/Admin/TemplatesAdminAbout.php index b64abd21..62393ab4 100644 --- a/class/Files/Templates/Admin/TemplatesAdminAbout.php +++ b/class/Files/Templates/Admin/TemplatesAdminAbout.php @@ -42,7 +42,6 @@ class TemplatesAdminAbout extends Files\CreateFile /** * @public function constructor - * @param null */ public function __construct() { @@ -78,8 +77,8 @@ public function write($module, $filename): void /** * @public function render - * @param null - * @return bool|string + * + * @return string */ public function render() { diff --git a/class/Files/Templates/Admin/TemplatesAdminBroken.php b/class/Files/Templates/Admin/TemplatesAdminBroken.php index fae01126..f1843fe0 100644 --- a/class/Files/Templates/Admin/TemplatesAdminBroken.php +++ b/class/Files/Templates/Admin/TemplatesAdminBroken.php @@ -42,7 +42,6 @@ class TemplatesAdminBroken extends Files\CreateFile /** * @public function constructor - * @param null */ public function __construct() { @@ -53,7 +52,7 @@ public function __construct() /** * @static function getInstance - * @param null + * * @return TemplatesAdminBroken */ public static function getInstance() @@ -68,7 +67,7 @@ public static function getInstance() /** * @public function write - * @param string $module + * @param $module * @param $tables * @param $filename */ @@ -84,7 +83,7 @@ public function write($module, $tables, $filename): void * @param string $moduleDirname * @return string */ - private function getTemplatesAdminBrokenHeader($moduleDirname) + private function getTemplatesAdminBrokenHeader(string $moduleDirname) { $ret = $this->hc->getHtmlComment('Header', '', "\n"); $ret .= $this->sc->getSmartyIncludeFile($moduleDirname, 'header', true, '', "\n\n"); @@ -95,57 +94,51 @@ private function getTemplatesAdminBrokenHeader($moduleDirname) /** * @private function getTemplatesAdminBrokenTableThead * @param string $language - * @param $t * @return string */ - private function getTemplatesAdminBrokenTableThead($language, $t) + private function getTemplatesAdminBrokenTableThead(string $language) { $th = ''; $lang = $this->sc->getSmartyConst($language, 'BROKEN_TABLE'); - $th .= $this->hc->getHtmlTableHead($lang, 'center', '', $t . "\t\t"); + $th .= $this->hc->getHtmlTableHead($lang, 'center', '', "\t\t\t\t"); $lang = $this->sc->getSmartyConst($language, 'BROKEN_MAIN'); - $th .= $this->hc->getHtmlTableHead($lang, 'center', '', $t . "\t\t"); + $th .= $this->hc->getHtmlTableHead($lang, 'center', '', "\t\t\t\t"); $lang = $this->sc->getSmartyConst($language, 'FORM_ACTION'); - $th .= $this->hc->getHtmlTableHead($lang, 'center width5', '', $t . "\t\t"); - $tr = $this->hc->getHtmlTableRow($th, 'head', $t . "\t"); - $ret = $this->hc->getHtmlTableThead($tr, '', $t); - - return $ret; + $th .= $this->hc->getHtmlTableHead($lang, 'center width5', '', "\t\t\t\t"); + $tr = $this->hc->getHtmlTableRow($th, 'head', "\t\t" . "\t"); + return $this->hc->getHtmlTableThead($tr, '', "\t\t"); } /** * @private function getTemplatesAdminBrokenTableTBody * @param string $tableName * @param $tableSoleName - * @param $t * @return string * @internal param string $language */ - private function getTemplatesAdminBrokenTableTBody($tableName, $tableSoleName, $t) + private function getTemplatesAdminBrokenTableTBody(string $tableName, $tableSoleName) { $td = ''; - $doubleKey = $this->sc->getSmartyDoubleVar($tableSoleName, 'key'); - $doubleVal = $this->sc->getSmartyDoubleVar($tableSoleName, 'keyval'); + $doubleKey = $this->sc->getSmartyDoubleVar($tableSoleName, 'key', '', '', "''|escape:'htmlattr'"); + $doubleVal = $this->sc->getSmartyDoubleVar($tableSoleName, 'keyval', '', '', "''|escape:'htmlattr'"); - $double = $this->sc->getSmartyDoubleVar($tableSoleName, 'table'); - $td .= $this->hc->getHtmlTableData($double, 'center', '', $t . "\t\t"); - $double = $this->sc->getSmartyDoubleVar($tableSoleName, 'main'); - $td .= $this->hc->getHtmlTableData($double, 'center', '', $t . "\t\t"); + $double = $this->sc->getSmartyDoubleVar($tableSoleName, 'table', '', '', "''|escape:'html'"); + $td .= $this->hc->getHtmlTableData($double, 'center', '', "\t\t\t\t"); + $double = $this->sc->getSmartyDoubleVar($tableSoleName, 'main', '', '', "''|escape:'html'"); + $td .= $this->hc->getHtmlTableData($double, 'center', '', "\t\t\t\t"); $lang = $this->sc->getSmartyConst('', '_EDIT'); $src = $this->sc->getSmartyNoSimbol("xoModuleIcons16 'edit.png'"); $img = $this->hc->getHtmlImage($src, $tableName); - $anchor = $this->hc->getHtmlAnchor($tableName . ".php?op=edit&{$doubleKey}=" . $doubleVal, $img, $lang, '', '', '', $t . "\t\t\t", "\n"); + $anchor = $this->hc->getHtmlAnchor($tableName . ".php?op=edit&{$doubleKey}=" . $doubleVal, $img, $lang, '', '', '', "\t\t" . "\t\t\t", "\n"); $lang = $this->sc->getSmartyConst('', '_DELETE'); $src = $this->sc->getSmartyNoSimbol("xoModuleIcons16 'delete.png'"); $img = $this->hc->getHtmlImage($src, $tableName); - $anchor .= $this->hc->getHtmlAnchor($tableName . ".php?op=delete&{$doubleKey}=" . $doubleVal, $img, $lang, '', '', '', $t . "\t\t\t", "\n"); - $td .= $this->hc->getHtmlTableData($anchor, 'center width5', '', $t . "\t\t", "\n", true); + $anchor .= $this->hc->getHtmlAnchor($tableName . ".php?op=delete&{$doubleKey}=" . $doubleVal, $img, $lang, '', '', '', "\t\t" . "\t\t\t", "\n"); + $td .= $this->hc->getHtmlTableData($anchor, 'center width5', '', "\t\t\t\t", "\n", true); $cycle = $this->sc->getSmartyNoSimbol('cycle values=\'odd, even\''); - $tr = $this->hc->getHtmlTableRow($td, $cycle, $t . "\t"); - $foreach = $this->sc->getSmartyForeach($tableSoleName, $tableName . '_list', $tr, '', '', $t . "\t"); - $tbody = $this->hc->getHtmlTableTbody($foreach, '', $t); - - return $tbody; + $tr = $this->hc->getHtmlTableRow($td, $cycle, "\t\t" . "\t"); + $foreach = $this->sc->getSmartyForeach($tableSoleName, $tableName . '_list', $tr, '', '', "\t\t" . "\t"); + return $this->hc->getHtmlTableTbody($foreach, '', "\t\t"); } /** @@ -155,13 +148,11 @@ private function getTemplatesAdminBrokenTableTBody($tableName, $tableSoleName, $ * @param string $language * @return string */ - private function getTemplatesAdminBrokenTable($tableName, $tableSoleName, $language) + private function getTemplatesAdminBrokenTable(string $tableName, $tableSoleName, string $language) { - $tbody = $this->getTemplatesAdminBrokenTableThead($language, "\t\t"); - $tbody .= $this->getTemplatesAdminBrokenTableTBody($tableName, $tableSoleName, "\t\t"); - $ret = $this->hc->getHtmlTable($tbody, 'table table-bordered', "\t"); - - return $ret; + $tbody = $this->getTemplatesAdminBrokenTableThead($language); + $tbody .= $this->getTemplatesAdminBrokenTableTBody($tableName, $tableSoleName); + return $this->hc->getHtmlTable($tbody, 'table table-bordered', "\t"); } /** @@ -171,28 +162,28 @@ private function getTemplatesAdminBrokenTable($tableName, $tableSoleName, $langu * @param string $t * @return string */ - private function getTemplatesAdminBrokenList($table, $language, $t = '') + private function getTemplatesAdminBrokenList($table, string $language, string $t = '') { $tableName = $table->getVar('table_name'); $tableSoleName = $table->getVar('table_solename'); $ucfTableName = \ucfirst($tableName); $double = $this->sc->getSmartySingleVar($tableName . '_result'); - $ret = $this->hc->getHtmlHNumb($double, 3); + $ret = $this->hc->getHtmlHNumb($double, '3'); $htmlTable = $this->getTemplatesAdminBrokenTable($tableName, $tableSoleName, $language); $htmlTable .= $this->hc->getHtmlDiv(' ', 'clear', $t, "\n", false); - $single = $this->sc->getSmartySingleVar('pagenav'); + $single = $this->sc->getSmartySingleVar('pagenav_' . $tableName, '', '', ''); $div = $this->hc->getHtmlDiv($single, 'xo-pagenav floatright', $t . "\t", "\n", false); $div .= $this->hc->getHtmlDiv('', 'clear spacer', $t . "\t", "\n", false); - $htmlTable .= $this->sc->getSmartyConditions('pagenav', '', '', $div, '', '', '', $t); + $htmlTable .= $this->sc->getSmartyConditions('pagenav_' . $tableName, '', '', $div, '', '', '', $t); $noData = $this->sc->getSmartySingleVar('nodata' . $ucfTableName, $t . "\t\t"); $src = $this->sc->getSmartyNoSimbol("xoModuleIcons32 'button_ok.png'"); $noData .= $this->hc->getHtmlImage($src, $tableName, '', '', "\n"); - $div = $this->hc->getHtmlDiv($noData, '', $t . "\t", "\n", true); + $div = $this->hc->getHtmlDiv($noData, '', $t . "\t"); $div .= $this->hc->getHtmlDiv('', 'clear spacer', $t . "\t", "\n", false); - $div .= $this->hc->getHtmlBr('2', '', $t . "\t"); + $div .= $this->hc->getHtmlBr(2, '', $t . "\t"); $contElse = $this->sc->getSmartyConditions('nodata' . $ucfTableName, '', '', $div, false, '', '', $t); $ret .= $this->sc->getSmartyConditions($tableName . '_count', '', '', $htmlTable, $contElse); - $ret .= $this->hc->getHtmlBr('3'); + $ret .= $this->hc->getHtmlBr(3); return $ret; } @@ -202,7 +193,7 @@ private function getTemplatesAdminBrokenList($table, $language, $t = '') * @param string $moduleDirname * @return string */ - private function getTemplatesAdminBrokenFooter($moduleDirname) + private function getTemplatesAdminBrokenFooter(string $moduleDirname) { $single = $this->sc->getSmartySingleVar('error'); $strong = $this->hc->getHtmlTag('strong', [], $single, false, '', ''); @@ -217,8 +208,8 @@ private function getTemplatesAdminBrokenFooter($moduleDirname) /** * @public function render - * @param null - * @return bool|string + * + * @return string */ public function render() { diff --git a/class/Files/Templates/Admin/TemplatesAdminFooter.php b/class/Files/Templates/Admin/TemplatesAdminFooter.php index e11b3cd0..b8b99325 100644 --- a/class/Files/Templates/Admin/TemplatesAdminFooter.php +++ b/class/Files/Templates/Admin/TemplatesAdminFooter.php @@ -42,7 +42,6 @@ class TemplatesAdminFooter extends Files\CreateFile /** * @public function constructor - * @param null */ public function __construct() { @@ -67,10 +66,10 @@ public static function getInstance() /** * @public function write - * @param string $module + * @param $module * @param string $filename */ - public function write($module, $filename): void + public function write($module, string $filename): void { $this->setModule($module); $this->setFileName($filename); @@ -78,8 +77,8 @@ public function write($module, $filename): void /** * @public function render - * @param null - * @return bool|string + * + * @return string */ public function render() { @@ -91,11 +90,11 @@ public function render() $language = $this->getLanguage($moduleDirname, 'AM', '', false); $singleNoVar = $this->sc->getSmartyNoSimbol("xoModuleIcons32 'xoopsmicrobutton.gif'"); $img = $this->hc->getHtmlTag('img', ['src' => $singleNoVar, 'alt' => 'XOOPS'], '', true, '', ''); - $anchor = $this->hc->getHtmlTag('a', ['href' => 'https://xoops.org/', 'title' => 'Visit XOOPS', 'target' => '_blank'], $img); + $anchor = $this->hc->getHtmlTag('a', ['href' => 'https://xoops.org/', 'title' => 'Visit XOOPS', 'target' => '_blank', 'rel' => 'noopener noreferrer'], $img); $content = $this->hc->getHtmlTag('div', ['class' => 'center'], "\n\t" . $anchor); $tree = $this->hc->getHtmlTag('strong', [], $moduleName, false, '', ''); $tree .= $this->sc->getSmartyConst($language, 'MAINTAINEDBY'); - $tree .= $this->hc->getHtmlTag('a', ['href' => '<{$maintainedby}>', 'title' => 'Visit ' . $supportName, 'class' => 'tooltip', 'rel' => 'external'], $supportName); + $tree .= $this->hc->getHtmlTag('a', ['href' => '<{$maintainedby|default:\'#\'|escape:\'htmlattr\'}>', 'title' => 'Visit ' . $supportName, 'class' => 'tooltip', 'rel' => 'external'], $supportName); $content .= $this->hc->getHtmlTag('div', ['class' => 'center smallsmall italic pad5'], "\n\t" . $tree); $this->create($moduleDirname, 'templates/admin', $filename, $content, \_AM_MODULEBUILDER_FILE_CREATED, \_AM_MODULEBUILDER_FILE_NOTCREATED); diff --git a/class/Files/Templates/Admin/TemplatesAdminHeader.php b/class/Files/Templates/Admin/TemplatesAdminHeader.php index 6945885d..c3894506 100644 --- a/class/Files/Templates/Admin/TemplatesAdminHeader.php +++ b/class/Files/Templates/Admin/TemplatesAdminHeader.php @@ -42,7 +42,6 @@ class TemplatesAdminHeader extends Files\CreateFile /** * @public function constructor - * @param null */ public function __construct() { @@ -67,10 +66,10 @@ public static function getInstance() /** * @public function write - * @param string $module + * @param $module * @param string $filename */ - public function write($module, $filename): void + public function write($module, string $filename): void { $this->setModule($module); $this->setFileName($filename); @@ -78,8 +77,8 @@ public function write($module, $filename): void /** * @public function render - * @param null - * @return bool|string + * + * @return string */ public function render() { diff --git a/class/Files/Templates/Admin/TemplatesAdminIndex.php b/class/Files/Templates/Admin/TemplatesAdminIndex.php index 88019bb5..c90934e7 100644 --- a/class/Files/Templates/Admin/TemplatesAdminIndex.php +++ b/class/Files/Templates/Admin/TemplatesAdminIndex.php @@ -42,7 +42,6 @@ class TemplatesAdminIndex extends Files\CreateFile /** * @public function constructor - * @param null */ public function __construct() { @@ -67,10 +66,10 @@ public static function getInstance() /** * @public function write - * @param string $module + * @param $module * @param string $filename */ - public function write($module, $filename): void + public function write($module, string $filename): void { $this->setModule($module); $this->setFileName($filename); @@ -78,8 +77,8 @@ public function write($module, $filename): void /** * @public function render - * @param null - * @return bool|string + * + * @return string */ public function render() { diff --git a/class/Files/Templates/Admin/TemplatesAdminPages.php b/class/Files/Templates/Admin/TemplatesAdminPages.php index 36c562e8..2abace26 100644 --- a/class/Files/Templates/Admin/TemplatesAdminPages.php +++ b/class/Files/Templates/Admin/TemplatesAdminPages.php @@ -45,7 +45,6 @@ class TemplatesAdminPages extends Files\CreateFile /** * @public function constructor - * @param null */ public function __construct() { @@ -56,7 +55,7 @@ public function __construct() /** * @static function getInstance - * @param null + * * @return TemplatesAdminPages */ public static function getInstance() @@ -75,7 +74,7 @@ public static function getInstance() * @param $table * @param string $filename */ - public function write($module, $table, $filename): void + public function write($module, $table, string $filename): void { $this->setModule($module); $this->setTable($table); @@ -87,7 +86,7 @@ public function write($module, $table, $filename): void * @param string $moduleDirname * @return string */ - private function getTemplatesAdminPagesHeader($moduleDirname) + private function getTemplatesAdminPagesHeader(string $moduleDirname) { $ret = $this->hc->getHtmlComment('Header', '',"\n"); $ret .= $this->sc->getSmartyIncludeFile($moduleDirname, 'header', true, '', "\n\n"); @@ -103,7 +102,7 @@ private function getTemplatesAdminPagesHeader($moduleDirname) * @param string $language * @return string */ - private function getTemplatesAdminPagesTableThead($tableSoleName, $tableAutoincrement, $fields, $language) + private function getTemplatesAdminPagesTableThead($tableSoleName, $tableAutoincrement, array $fields, string $language) { $th = ''; $langHeadId = \mb_strtoupper($tableSoleName) . '_ID'; @@ -124,9 +123,7 @@ private function getTemplatesAdminPagesTableThead($tableSoleName, $tableAutoincr $lang = $this->sc->getSmartyConst($language, 'FORM_ACTION'); $th .= $this->hc->getHtmlTag('th', ['class' => 'center width5'], $lang, false, "\t\t\t\t"); $tr = $this->hc->getHtmlTableRow($th, 'head', "\t\t\t"); - $ret = $this->hc->getHtmlTableThead($tr, '', "\t\t"); - - return $ret; + return $this->hc->getHtmlTableThead($tr, '', "\t\t"); } /** @@ -139,7 +136,7 @@ private function getTemplatesAdminPagesTableThead($tableSoleName, $tableAutoincr * @return string * @internal param string $language */ - private function getTemplatesAdminPagesTableTBody($moduleDirname, $tableName, $tableSoleName, $tableAutoincrement, $fields) + private function getTemplatesAdminPagesTableTBody(string $moduleDirname, string $tableName, $tableSoleName, $tableAutoincrement, array $fields) { $td = ''; if (1 == $tableAutoincrement) { @@ -158,7 +155,7 @@ private function getTemplatesAdminPagesTableTBody($moduleDirname, $tableName, $t switch ($fieldElement) { case Constants::FIELD_ELE_TEXTAREA: case Constants::FIELD_ELE_DHTMLTEXTAREA: - $double = $this->sc->getSmartyDoubleVar($tableSoleName, $rpFieldName . '_short'); + $double = $this->sc->getSmartyDoubleVar($tableSoleName, $rpFieldName . '_short', '', '', "''|escape:'html'"); $td .= $this->hc->getHtmlTableData($double, 'center', '',"\t\t\t\t"); break; case Constants::FIELD_ELE_CHECKBOX: @@ -177,37 +174,34 @@ private function getTemplatesAdminPagesTableTBody($moduleDirname, $tableName, $t break; case Constants::FIELD_ELE_IMAGELIST: $src = $this->sc->getSmartyNoSimbol('xoModuleIcons32'); - $src .= $this->sc->getSmartyDoubleVar($tableSoleName, $rpFieldName); + $src .= $this->sc->getSmartyDoubleVar($tableSoleName, $rpFieldName, '', '', "''|escape:'htmlattr'"); $img = $this->hc->getHtmlTag('img', ['src' => $src, 'alt' => $tableName], '', true,'',''); $td .= $this->hc->getHtmlTableData($img, 'center', '',"\t\t\t\t"); break; case Constants::FIELD_ELE_UPLOADIMAGE: - $single = $this->sc->getSmartySingleVar($moduleDirname . '_upload_url'); - $double = $this->sc->getSmartyDoubleVar($tableSoleName, $rpFieldName); + $single = $this->sc->getSmartySingleVar($moduleDirname . '_upload_url','','',"''|escape:'htmlattr'"); + $double = $this->sc->getSmartyDoubleVar($tableSoleName, $rpFieldName,'','',"''|escape:'htmlattr'"); $img = $this->hc->getHtmlTag('img', ['src' => $single . "/images/{$tableName}/" . $double, 'alt' => $tableName, 'style' => 'max-width:100px'], '', true, '', ''); $td .= $this->hc->getHtmlTableData($img, 'center', '',"\t\t\t\t"); break; case Constants::FIELD_ELE_SELECTSTATUS: - $double = $this->sc->getSmartyDoubleVar($tableSoleName, 'status'); + $double = $this->sc->getSmartyDoubleVar($tableSoleName, 'status', '', '', "''|escape:'html'"); $src = $this->sc->getSmartyNoSimbol('$modPathIcon16') . 'status' . $double . '.png'; - $imgAlt = $this->sc->getSmartyDoubleVar($tableSoleName, 'status_text'); + $imgAlt = $this->sc->getSmartyDoubleVar($tableSoleName, 'status_text', '', '', "''|escape:'html'"); $img = $this->hc->getHtmlTag('img', ['src' => $src, 'alt' => $imgAlt, 'title' => $imgAlt], '', true,'',''); $td .= $this->hc->getHtmlTableData($img, 'center', '',"\t\t\t\t"); break; case Constants::FIELD_ELE_RADIOYN: case Constants::FIELD_ELE_SELECTUSER: case Constants::FIELD_ELE_DATETIME: - case Constants::FIELD_ELE_TEXTDATESELECT: - $double = $this->sc->getSmartyDoubleVar($tableSoleName, $rpFieldName . '_text'); - $td .= $this->hc->getHtmlTableData($double, 'center', '',"\t\t\t\t"); - break; case Constants::FIELD_ELE_RADIO_ONOFFLINE: - $double = $this->sc->getSmartyDoubleVar($tableSoleName, $rpFieldName . '_text'); + case Constants::FIELD_ELE_TEXTDATESELECT: + $double = $this->sc->getSmartyDoubleVar($tableSoleName, $rpFieldName . '_text', '', '', "''|escape:'html'"); $td .= $this->hc->getHtmlTableData($double, 'center', '',"\t\t\t\t"); break; default: if (0 != $f) { - $double = $this->sc->getSmartyDoubleVar($tableSoleName, $rpFieldName); + $double = $this->sc->getSmartyDoubleVar($tableSoleName, $rpFieldName, '', '', "''|escape:'html'"); $td .= $this->hc->getHtmlTableData($double, 'center', '',"\t\t\t\t"); } break; @@ -248,12 +242,12 @@ private function getTemplatesAdminPagesTableTBody($moduleDirname, $tableName, $t * @param string $language * @return string */ - private function getTemplatesAdminPagesTable($moduleDirname, $tableName, $tableSoleName, $tableAutoincrement, $fields, $language) + private function getTemplatesAdminPagesTable(string $moduleDirname, string $tableName, $tableSoleName, $tableAutoincrement, $fields, string $language) { $tbody = $this->getTemplatesAdminPagesTableThead($tableSoleName, $tableAutoincrement, $fields, $language); $tbody .= $this->getTemplatesAdminPagesTableTBody($moduleDirname, $tableName, $tableSoleName, $tableAutoincrement, $fields); - return $this->hc->getHtmlTable($tbody, 'table table-bordered', "\t"); + return $this->hc->getHtmlTable($tbody, 'outer', "\t"); } /** @@ -266,7 +260,7 @@ private function getTemplatesAdminPagesTable($moduleDirname, $tableName, $tableS * @param string $language * @return string */ - private function getTemplatesAdminPages($moduleDirname, $tableName, $tableSoleName, $tableAutoincrement, $fields, $language) + private function getTemplatesAdminPages(string $moduleDirname, string $tableName, $tableSoleName, $tableAutoincrement, $fields, string $language) { $htmlTable = $this->getTemplatesAdminPagesTable($moduleDirname, $tableName, $tableSoleName, $tableAutoincrement, $fields, $language); $htmlTable .= $this->hc->getHtmlTag('div', ['class' => 'clear'], ' ', false, "\t"); @@ -291,7 +285,7 @@ private function getTemplatesAdminPages($moduleDirname, $tableName, $tableSoleNa * @param string $moduleDirname * @return string */ - private function getTemplatesAdminPagesFooter($moduleDirname) + private function getTemplatesAdminPagesFooter(string $moduleDirname) { $ret = $this->hc->getHtmlComment('Footer', '', "\n"); $ret .= $this->sc->getSmartyIncludeFile($moduleDirname, 'footer', true); @@ -301,8 +295,8 @@ private function getTemplatesAdminPagesFooter($moduleDirname) /** * @public function render - * @param null - * @return bool|string + * + * @return string */ public function render() { diff --git a/class/Files/Templates/Admin/TemplatesAdminPermissions.php b/class/Files/Templates/Admin/TemplatesAdminPermissions.php index 030e97c4..06ca2611 100644 --- a/class/Files/Templates/Admin/TemplatesAdminPermissions.php +++ b/class/Files/Templates/Admin/TemplatesAdminPermissions.php @@ -42,7 +42,6 @@ class TemplatesAdminPermissions extends Files\CreateFile /** * @public function constructor - * @param null */ public function __construct() { @@ -53,7 +52,7 @@ public function __construct() /** * @static function getInstance - * @param null + * * @return TemplatesAdminPermissions */ public static function getInstance() @@ -68,7 +67,7 @@ public static function getInstance() /** * @public function write - * @param string $module + * @param $module * @param $filename */ public function write($module, $filename): void @@ -83,22 +82,20 @@ public function write($module, $filename): void * * @return string */ - private function getTemplatesAdminPermissionsHeader($moduleDirname) + private function getTemplatesAdminPermissionsHeader(string $moduleDirname) { return $this->sc->getSmartyIncludeFile($moduleDirname, 'header', true, '', "\n\n"); } /** * @private function getTemplatesAdminPermissions - * @param null + * * @return string */ private function getTemplatesAdminPermissions() { $form = $this->sc->getSmartySingleVar('form'); - $ret = $this->hc->getHtmlTag('div', ['class' => 'spacer'], $form, '', '', "\n\n"); - - return $ret; + return $this->hc->getHtmlTag('div', ['class' => 'spacer'], $form, false, '', "\n\n"); } /** @@ -107,15 +104,15 @@ private function getTemplatesAdminPermissions() * * @return string */ - private function getTemplatesAdminPermissionsFooter($moduleDirname) + private function getTemplatesAdminPermissionsFooter(string $moduleDirname) { return $this->sc->getSmartyIncludeFile($moduleDirname, 'footer', true); } /** * @public function render - * @param null - * @return bool|string + * + * @return string */ public function render() { diff --git a/class/Files/Templates/Blocks/Defstyle/TemplatesBlocks.php b/class/Files/Templates/Blocks/Defstyle/TemplatesBlocks.php index 98072cc7..dccad169 100644 --- a/class/Files/Templates/Blocks/Defstyle/TemplatesBlocks.php +++ b/class/Files/Templates/Blocks/Defstyle/TemplatesBlocks.php @@ -45,7 +45,6 @@ class TemplatesBlocks extends Files\CreateFile /** * @public function constructor - * @param null */ public function __construct() { @@ -56,7 +55,7 @@ public function __construct() /** * @static function getInstance - * @param null + * * @return TemplatesBlocks */ public static function getInstance() @@ -71,11 +70,11 @@ public static function getInstance() /** * @public function write - * @param string $module - * @param string $table + * @param $module + * @param $table * @param string $filename */ - public function write($module, $table, $filename): void + public function write($module, $table, string $filename): void { $this->setModule($module); $this->setTable($table); @@ -90,7 +89,7 @@ public function write($module, $table, $filename): void * @param $tableAutoincrement * @return string */ - private function getTemplatesBlocksTableThead($tableId, $tableMid, $language, $tableAutoincrement) + private function getTemplatesBlocksTableThead($tableId, $tableMid, string $language, $tableAutoincrement) { $th = ''; if (1 == $tableAutoincrement) { @@ -105,6 +104,7 @@ private function getTemplatesBlocksTableThead($tableId, $tableMid, $language, $t $th .= $this->hc->getHtmlTableHead($lang, 'center', '', "\t\t\t"); } } + $th .= $this->hc->getHtmlTableHead(' ', '', '', "\t\t\t"); $tr = $this->hc->getHtmlTableRow($th, 'head', "\t\t"); return $this->hc->getHtmlTableThead($tr, '', "\t"); @@ -121,7 +121,7 @@ private function getTemplatesBlocksTableThead($tableId, $tableMid, $language, $t * @param $language * @return string */ - private function getTemplatesBlocksTableTbody($moduleDirname, $tableId, $tableMid, $tableName, $tableSoleName, $tableAutoincrement, $language) + private function getTemplatesBlocksTableTbody(string $moduleDirname, $tableId, $tableMid, $tableName, $tableSoleName, $tableAutoincrement, $language) { $td = ''; $fieldId = ''; @@ -148,19 +148,19 @@ private function getTemplatesBlocksTableTbody($moduleDirname, $tableId, $tableMi break; case Constants::FIELD_ELE_IMAGELIST: $src = $this->sc->getSmartyNoSimbol('xoModuleIcons32'); - $src .= $this->sc->getSmartyDoubleVar($tableSoleName, $rpFieldName); + $src .= $this->sc->getSmartyDoubleVar($tableSoleName, $rpFieldName, '', '', "''|escape:'html'"); $img = $this->hc->getHtmlTag('img', ['src' => $src, 'alt' => $tableName], '', true, '', ''); $td .= $this->hc->getHtmlTableData($img, 'center', '', "\t\t\t"); break; case Constants::FIELD_ELE_UPLOADIMAGE: - $single = $this->sc->getSmartySingleVar($moduleDirname . '_upload_url'); - $double = $this->sc->getSmartyDoubleVar($tableSoleName, $rpFieldName); + $single = $this->sc->getSmartySingleVar($moduleDirname . '_upload_url', '', '', "''|escape:'htmlattr'"); + $double = $this->sc->getSmartyDoubleVar($tableSoleName, $rpFieldName, '', '', "''|escape:'html'"); $img = $this->hc->getHtmlTag('img', ['src' => $single . "/images/{$tableName}/" . $double, 'alt' => $tableName], '', true, '', ''); $td .= $this->hc->getHtmlTableData($img, 'center', '', "\t\t\t"); break; case Constants::FIELD_ELE_TEXTAREA: case Constants::FIELD_ELE_DHTMLTEXTAREA: - $double = $this->sc->getSmartyDoubleVar($tableSoleName, $rpFieldName . '_short'); + $double = $this->sc->getSmartyDoubleVar($tableSoleName, $rpFieldName . '_short', '', '', "''|escape:'html'"); $td .= $this->hc->getHtmlTableData($double, 'center', '', "\t\t\t"); break; case Constants::FIELD_ELE_SELECTSTATUS: @@ -169,12 +169,12 @@ private function getTemplatesBlocksTableTbody($moduleDirname, $tableId, $tableMi case Constants::FIELD_ELE_SELECTUSER: case Constants::FIELD_ELE_DATETIME: case Constants::FIELD_ELE_TEXTDATESELECT: - $double = $this->sc->getSmartyDoubleVar($tableSoleName, $rpFieldName . '_text'); + $double = $this->sc->getSmartyDoubleVar($tableSoleName, $rpFieldName . '_text', '', '', "''|escape:'html'"); $td .= $this->hc->getHtmlTableData($double, 'center', '', "\t\t\t"); break; default: if (0 != $f) { - $double = $this->sc->getSmartyDoubleVar($tableSoleName, $rpFieldName); + $double = $this->sc->getSmartyDoubleVar($tableSoleName, $rpFieldName, '', '', "''|escape:'html'"); $td .= $this->hc->getHtmlTableData($double, 'center', '', "\t\t\t"); } break; @@ -195,8 +195,8 @@ private function getTemplatesBlocksTableTbody($moduleDirname, $tableId, $tableMi // $anchor .= $this->hc->getHtmlTag('a', ['href' => $tableName . ".php?op=delete&{$fieldId}=" . $double, 'title' => $lang], $img, false, "\t\t\t\t"); // $td .= $this->hc->getHtmlTag('td', ['class' => 'center'], "\n" . $anchor . "\t\t\t", false, "\t\t\t"); $double = $this->sc->getSmartyDoubleVar($tableSoleName, 'id'); - $lang = $this->sc->getSmartyConst($language, $stuTableSoleName . '_GOTO'); - $single = $this->sc->getSmartySingleVar($moduleDirname . '_url'); + $lang = $this->sc->getSmartyConst($language, $stuTableSoleName . '_GOTO|escape:"htmlattr"'); + $single = $this->sc->getSmartySingleVar($moduleDirname . '_url', '', '', "''|escape:'htmlattr'"); $anchor = $this->hc->getHtmlAnchor($single . '/' . $tableName . ".php?op=show&{$fieldId}=" . $double, $lang, $lang); $td .= $this->hc->getHtmlTableData($anchor, 'center', '', "\t\t\t"); $cycle = $this->sc->getSmartyNoSimbol('cycle values="odd, even"'); @@ -204,7 +204,7 @@ private function getTemplatesBlocksTableTbody($moduleDirname, $tableId, $tableMi $foreach = $this->sc->getSmartyForeach($tableSoleName, 'block', $tr, '', '', "\t\t"); $tbody = $this->hc->getHtmlTableTbody($foreach, '', "\t"); - return $this->sc->getSmartyConditions('block|default:0', ' > ', '0', $tbody, false, true, true, "\t"); + return $this->sc->getSmartyConditions('block', ' > ', '0', $tbody, false, true, true, "\t"); } /** @@ -230,7 +230,7 @@ private function getTemplatesBlocksTableTfoot() * @param string $language * @return string */ - private function getTemplatesBlocksTable($moduleDirname, $tableId, $tableMid, $tableName, $tableSoleName, $tableAutoincrement, $language) + private function getTemplatesBlocksTable(string $moduleDirname, $tableId, $tableMid, string $tableName, $tableSoleName, $tableAutoincrement, string $language) { $tbody = $this->getTemplatesBlocksTableThead($tableId, $tableMid, $language, $tableAutoincrement); $tbody .= $this->getTemplatesBlocksTableTbody($moduleDirname, $tableId, $tableMid, $tableName, $tableSoleName, $tableAutoincrement, $language); @@ -242,9 +242,8 @@ private function getTemplatesBlocksTable($moduleDirname, $tableId, $tableMid, $t /** * @public function render - * @param null * - * @return bool|string + * @return string */ public function render() { diff --git a/class/Files/Templates/Blocks/Defstyle/TemplatesBlocksSpotlight.php b/class/Files/Templates/Blocks/Defstyle/TemplatesBlocksSpotlight.php index 59ff5e3a..36a2d94b 100644 --- a/class/Files/Templates/Blocks/Defstyle/TemplatesBlocksSpotlight.php +++ b/class/Files/Templates/Blocks/Defstyle/TemplatesBlocksSpotlight.php @@ -47,7 +47,6 @@ class TemplatesBlocksSpotlight extends Files\CreateFile /** * @public function constructor - * @param null */ public function __construct() { @@ -58,8 +57,8 @@ public function __construct() /** * @static function getInstance - * @param null - * @return false|TemplatesBlocks|TemplatesBlocksSpotlight + * + * @return false|TemplatesBlocksSpotlight */ public static function getInstance() { @@ -73,11 +72,11 @@ public static function getInstance() /** * @public function write - * @param string $module - * @param string $table + * @param $module + * @param $table * @param string $filename */ - public function write($module, $table, $filename) + public function write($module, $table, string $filename) { $this->setModule($module); $this->setTable($table); @@ -92,7 +91,7 @@ public function write($module, $table, $filename) * @param $tableAutoincrement * @return string */ - private function getTemplatesBlocksTableThead($tableId, $tableMid, $language, $tableAutoincrement) + private function getTemplatesBlocksTableThead($tableId, $tableMid, string $language, $tableAutoincrement) { $th = ''; if (1 == $tableAutoincrement) { @@ -107,6 +106,7 @@ private function getTemplatesBlocksTableThead($tableId, $tableMid, $language, $t $th .= $this->hc->getHtmlTableHead($lang, 'center', '', "\t\t\t"); } } + $th .= $this->hc->getHtmlTableHead(' ', '', '', "\t\t\t"); $tr = $this->hc->getHtmlTableRow($th, 'head', "\t\t"); return $this->hc->getHtmlTableThead($tr, '', "\t"); @@ -123,7 +123,7 @@ private function getTemplatesBlocksTableThead($tableId, $tableMid, $language, $t * @param $language * @return string */ - private function getTemplatesBlocksTableTbody($moduleDirname, $tableId, $tableMid, $tableName, $tableSoleName, $tableAutoincrement, $language) + private function getTemplatesBlocksTableTbody(string $moduleDirname, $tableId, $tableMid, $tableName, $tableSoleName, $tableAutoincrement, $language) { $td = ''; $fieldId = ''; @@ -231,7 +231,7 @@ private function getTemplatesBlocksTableTfoot() * @param string $language * @return string */ - private function getTemplatesBlocksTable($moduleDirname, $tableId, $tableMid, $tableName, $tableSoleName, $tableAutoincrement, $language) + private function getTemplatesBlocksTable(string $moduleDirname, $tableId, $tableMid, string $tableName, $tableSoleName, $tableAutoincrement, string $language) { $tbody = $this->getTemplatesBlocksTableThead($tableId, $tableMid, $language, $tableAutoincrement); $tbody .= $this->getTemplatesBlocksTableTbody($moduleDirname, $tableId, $tableMid, $tableName, $tableSoleName, $tableAutoincrement, $language); @@ -243,9 +243,8 @@ private function getTemplatesBlocksTable($moduleDirname, $tableId, $tableMid, $t /** * @public function render - * @param null * - * @return bool|string + * @return string */ public function render() { diff --git a/class/Files/Templates/User/Defstyle/Breadcrumbs.php b/class/Files/Templates/User/Defstyle/Breadcrumbs.php index 1ed30067..f101fec4 100644 --- a/class/Files/Templates/User/Defstyle/Breadcrumbs.php +++ b/class/Files/Templates/User/Defstyle/Breadcrumbs.php @@ -47,7 +47,6 @@ class Breadcrumbs extends Files\CreateFile /** * @public function constructor - * @param null */ public function __construct() { @@ -76,7 +75,7 @@ public static function getInstance() * @param $module * @param string $filename */ - public function write($module, $filename): void + public function write($module, string $filename): void { $this->setModule($module); $this->setFileName($filename); @@ -84,22 +83,25 @@ public function write($module, $filename): void /** * @public function render - * @param null - * @return bool|string + * + * @return string */ public function render() { - $module = $this->getModule(); - $filename = $this->getFileName(); - $moduleDirname = $module->getVar('mod_dirname'); + $module = $this->getModule(); + $filename = $this->getFileName(); + $moduleDirname = $module->getVar('mod_dirname'); + $stuModuleDirname = \strtoupper($moduleDirname); - $title = $this->sc->getSmartyDoubleVar('itm', 'title'); - $titleElse = $this->sc->getSmartyDoubleVar('itm', 'title', "\t\t\t", "\n"); - $link = $this->sc->getSmartyDoubleVar('itm', 'link'); + $title = $this->sc->getSmartyDoubleVar('itm', 'title','','','""|escape:"html"'); + $title2 = $this->sc->getSmartyDoubleVar('itm', 'title','','','""|escape:"htmlattr"'); + $titleElse = $this->sc->getSmartyDoubleVar('itm', 'title', "\t\t\t", "\n", '""|escape:"html"'); + $link = $this->sc->getSmartyDoubleVar('itm', 'link','','','""|escape:"htmlattr"'); $glyph = $this->hc->getHtmlTag('i', ['class' => 'glyphicon glyphicon-home fa fa-home'], '', false, '', ''); - $anchor = $this->hc->getHtmlAnchor("<{xoAppUrl 'index.php'}>", $glyph, 'home'); + $langHome = $this->sc->getSmartyConst('_MA_' . $stuModuleDirname, '_HOME'); + $anchor = $this->hc->getHtmlAnchor("<{xoAppUrl 'index.php'}>", $glyph, $langHome); $into = $this->hc->getHtmlLi($anchor, 'breadcrumb-item', "\t"); - $anchorIf = $this->hc->getHtmlAnchor($link, $title, $title, '', '', '', "\t\t\t", "\n"); + $anchorIf = $this->hc->getHtmlAnchor($link, $title, $title2, '', '', '', "\t\t\t", "\n"); $breadcrumb = $this->sc->getSmartyConditions('itm.link', '', '', $anchorIf, $titleElse, false, false, "\t\t"); $foreach = $this->hc->getHtmlLi($breadcrumb, 'breadcrumb-item', "\t", "\n", true); $into .= $this->sc->getSmartyForeach('itm', 'xoBreadcrumbs', $foreach, 'bcloop', '', "\t"); diff --git a/class/Files/Templates/User/Defstyle/Categories.php b/class/Files/Templates/User/Defstyle/Categories.php index 2fdb4b33..019156de 100644 --- a/class/Files/Templates/User/Defstyle/Categories.php +++ b/class/Files/Templates/User/Defstyle/Categories.php @@ -42,7 +42,6 @@ class Categories extends Files\CreateFile /** * @public function constructor - * @param null */ public function __construct() { @@ -71,7 +70,7 @@ public static function getInstance() * @param $table * @param string $filename */ - public function write($module, $table, $filename): void + public function write($module, $table, string $filename): void { $this->setModule($module); $this->setTable($table); @@ -83,7 +82,7 @@ public function write($module, $table, $filename): void * @param string $moduleDirname * @return string */ - private function getTemplatesUserCategoriesHeader($moduleDirname) + private function getTemplatesUserCategoriesHeader(string $moduleDirname) { return $this->sc->getSmartyIncludeFile($moduleDirname) . PHP_EOL; } @@ -96,7 +95,7 @@ private function getTemplatesUserCategoriesHeader($moduleDirname) * @param $tableSoleName * @return string */ - private function getTemplatesUserCategoriesTable($moduleDirname, $tableName, $tableSoleName, $language) + private function getTemplatesUserCategoriesTable($moduleDirname, $tableName, $tableSoleName, string $language) { $single = $this->sc->getSmartySingleVar('table_type'); $table = $this->getTemplatesAdminPagesTableThead($tableName, $language); @@ -111,7 +110,7 @@ private function getTemplatesUserCategoriesTable($moduleDirname, $tableName, $ta * @param $tableName * @return string */ - private function getTemplatesUserCategoriesThead($tableName, $language) + private function getTemplatesUserCategoriesThead($tableName, string $language) { $stuTableName = \mb_strtoupper($tableName); $lang = $this->sc->getSmartyConst($language, $stuTableName . '_TITLE'); @@ -129,7 +128,7 @@ private function getTemplatesUserCategoriesThead($tableName, $language) * @param $tableSoleName * @return string */ - private function getTemplatesUserCategoriesTbody($moduleDirname, $tableName, $tableSoleName) + private function getTemplatesUserCategoriesTbody(string $moduleDirname, $tableName, $tableSoleName) { $single = $this->sc->getSmartySingleVar('panel_type'); $include = $this->sc->getSmartyIncludeFileListForeach($moduleDirname, $tableName, $tableSoleName); @@ -179,7 +178,7 @@ private function getTemplatesUserCategories($moduleDirname, $tableName, $tableSo * @param $language * @return string */ - private function getTemplatesUserCategoriesPanel($moduleDirname, $tableName, $tableSoleName, $language) + private function getTemplatesUserCategoriesPanel(string $moduleDirname, string $tableName, $tableSoleName, $language) { $stuTableName = \mb_strtoupper($tableName); $incl = $this->sc->getSmartyIncludeFileListForeach($moduleDirname, $tableName, $tableSoleName) . PHP_EOL; @@ -200,14 +199,14 @@ private function getTemplatesUserCategoriesPanel($moduleDirname, $tableName, $ta * * @return string */ - private function getTemplatesUserCategoriesFooter($moduleDirname) + private function getTemplatesUserCategoriesFooter(string $moduleDirname) { return $this->sc->getSmartyIncludeFile($moduleDirname, 'footer'); } /** * @public function render - * @return bool|string + * @return string */ public function render() { diff --git a/class/Files/Templates/User/Defstyle/CategoriesList.php b/class/Files/Templates/User/Defstyle/CategoriesList.php index 099f2244..6327fa9a 100644 --- a/class/Files/Templates/User/Defstyle/CategoriesList.php +++ b/class/Files/Templates/User/Defstyle/CategoriesList.php @@ -42,7 +42,6 @@ class CategoriesList extends Files\CreateFile /** * @public function constructor - * @param null */ public function __construct() { @@ -71,7 +70,7 @@ public static function getInstance() * @param $table * @param string $filename */ - public function write($module, $table, $filename): void + public function write($module, $table, string $filename): void { $this->setModule($module); $this->setTable($table); @@ -84,12 +83,10 @@ public function write($module, $table, $filename): void */ private function getTemplatesUserCategoriesListStartTable() { - $ret = << \n EOT; - - return $ret; } /** @@ -126,11 +123,11 @@ private function getTemplatesUserCategoriesListThead($table) /** * @private function getTemplatesUserCategoriesListTbody * @param string $moduleDirname - * @param string $table + * @param $table * * @return string */ - private function getTemplatesUserCategoriesListTbody($moduleDirname, $table) + private function getTemplatesUserCategoriesListTbody(string $moduleDirname, $table) { $tableName = $table->getVar('table_name'); $ret = << \n EOT; - - return $ret; } /** @@ -236,7 +230,7 @@ private function getTemplatesUserCategoriesListEndTable() * @param $tableSoleName * @return string */ - private function getTemplatesUserCategoriesListPanel($moduleDirname, $tableId, $tableMid, $tableName, $tableSoleName) + private function getTemplatesUserCategoriesListPanel(string $moduleDirname, $tableId, $tableMid, $tableName, $tableSoleName) { $fields = $this->getTableFields($tableMid, $tableId); $ret = ''; @@ -286,7 +280,7 @@ private function getTemplatesUserCategoriesListPanel($moduleDirname, $tableId, $ /** * @public function render - * @return bool|string + * @return string */ public function render() { diff --git a/class/Files/Templates/User/Defstyle/Footer.php b/class/Files/Templates/User/Defstyle/Footer.php index 4626891a..d76847d0 100644 --- a/class/Files/Templates/User/Defstyle/Footer.php +++ b/class/Files/Templates/User/Defstyle/Footer.php @@ -42,7 +42,6 @@ class Footer extends Files\CreateFile /** * @public function constructor - * @param null */ public function __construct() { @@ -53,7 +52,7 @@ public function __construct() /** * @static function getInstance - * @param null + * * @return Footer */ public static function getInstance() @@ -72,7 +71,7 @@ public static function getInstance() * @param mixed $table * @param string $filename */ - public function write($module, $table, $filename): void + public function write($module, $table, string $filename): void { $this->setModule($module); $this->setTable($table); @@ -81,9 +80,8 @@ public function write($module, $table, $filename): void /** * @public function getTemplateUserFooterFacebookLikeButton - * @param null * - * @return bool|string + * @return string */ public function getTemplateUserFooterFacebookLikeButton() { @@ -92,9 +90,8 @@ public function getTemplateUserFooterFacebookLikeButton() /** * @public function getTemplateUserFooterFacebookShareButton - * @param null * - * @return bool|string + * @return string */ public function getTemplateUserFooterFacebookShareButton() { @@ -104,7 +101,7 @@ public function getTemplateUserFooterFacebookShareButton() /** * @public function render * @param $language - * @return bool|string + * @return string */ private function getTemplateUserFooterContent($language) { @@ -122,7 +119,7 @@ private function getTemplateUserFooterContent($language) $contIf .= $this->getSimpleString('<{elseif $comment_mode == "nest"}>', "\t\t"); $contIf .= $this->sc->getSmartyIncludeFile('system_comments', 'nest', false, "\t\t\t"); $contDiv = $this->sc->getSmartyConditions('comment_mode', ' == ', '"flat"', $contIf, false, '', '', "\t\t", "\n", true, false); - $contIf = $this->hc->getHtmlDiv($contDiv, 'pad2 marg2', "\t", "\n", true); + $contIf = $this->hc->getHtmlDiv($contDiv, 'pad2 marg2', "\t"); $ret .= $this->sc->getSmartyConditions('comment_mode', '', '', $contIf); $ret .= $this->sc->getSmartyIncludeFile('system_notification', 'select'); @@ -131,8 +128,8 @@ private function getTemplateUserFooterContent($language) /** * @public function render - * @param null - * @return bool|string + * + * @return string */ public function render() { diff --git a/class/Files/Templates/User/Defstyle/Header.php b/class/Files/Templates/User/Defstyle/Header.php index 9b579847..9249b6ff 100644 --- a/class/Files/Templates/User/Defstyle/Header.php +++ b/class/Files/Templates/User/Defstyle/Header.php @@ -46,7 +46,6 @@ class Header extends Files\CreateFile /** * @public function constructor - * @param null */ public function __construct() { @@ -58,7 +57,7 @@ public function __construct() /** * @static function getInstance - * @param null + * * @return Header */ public static function getInstance() @@ -76,7 +75,7 @@ public static function getInstance() * @param $module * @param string $filename */ - public function write($module, $filename): void + public function write($module, string $filename): void { $this->setModule($module); $this->setFileName($filename); @@ -85,7 +84,7 @@ public function write($module, $filename): void /** * @public function getTemplatesUserHeader * @param $moduleDirname - * @return bool|string + * @return string */ public function getTemplatesUserHeader($moduleDirname) { @@ -101,13 +100,12 @@ public function getTemplatesUserHeader($moduleDirname) /** * @public function getTemplateFooterFacebbokSDK - * @param null * - * @return bool|string + * @return string */ public function getTemplateUserHeaderFacebbokSDK() { - $ret = <<<'EOT' + return <<<'EOT'
EOT; - - return $ret; } /** * @public function render - * @param null - * @return bool|string + * + * @return string */ public function render() { diff --git a/class/Files/Templates/User/Defstyle/Index.php b/class/Files/Templates/User/Defstyle/Index.php index 3830516b..cd0fb890 100644 --- a/class/Files/Templates/User/Defstyle/Index.php +++ b/class/Files/Templates/User/Defstyle/Index.php @@ -42,7 +42,6 @@ class Index extends Files\CreateFile /** * @public function constructor - * @param null */ public function __construct() { @@ -53,7 +52,7 @@ public function __construct() /** * @static function getInstance - * @param null + * * @return Index */ public static function getInstance() @@ -84,18 +83,18 @@ public function write($module, $table, $tables, $filename): void /** * @public function getTemplateUserIndexHeader * @param $moduleDirname - * @return bool|string + * @return string */ public function getTemplateUserIndexHeader($moduleDirname) { - return $this->sc->getSmartyIncludeFile($moduleDirname, 'header', false); + return $this->sc->getSmartyIncludeFile($moduleDirname); } /** * @public function getTemplatesUserIndexBodyDefault * @param $module * @param $language - * @return bool|string + * @return string */ public function getTemplatesUserIndexIntro($module, $language) { @@ -145,9 +144,9 @@ public function getTemplatesUserIndexIntro($module, $language) * @param $tableSoleName * @param $language * @param string $t - * @return bool|string + * @return string */ - public function getTemplateUserIndexTable($moduleDirname, $tableName, $tableSoleName, $language, $t = '') + public function getTemplateUserIndexTable($moduleDirname, $tableName, $tableSoleName, $language, string $t = '') { $double = $this->sc->getSmartyConst($language, 'INDEX_LATEST_LIST'); $ret = $this->hc->getHtmlDiv($double, "{$moduleDirname}-linetitle", $t, "\n", false); @@ -170,7 +169,7 @@ public function getTemplateUserIndexTable($moduleDirname, $tableName, $tableSole /** * @public function getTemplateUserIndexFooter * @param $moduleDirname - * @return bool|string + * @return string */ public function getTemplateUserIndexFooter($moduleDirname) { @@ -179,8 +178,8 @@ public function getTemplateUserIndexFooter($moduleDirname) /** * @public function render - * @param null - * @return bool|string + * + * @return string */ public function render() { diff --git a/class/Files/Templates/User/Defstyle/MoreFiles.php b/class/Files/Templates/User/Defstyle/MoreFiles.php index 2aba6ea2..0e03b7ad 100644 --- a/class/Files/Templates/User/Defstyle/MoreFiles.php +++ b/class/Files/Templates/User/Defstyle/MoreFiles.php @@ -36,7 +36,6 @@ class MoreFiles extends Files\CreateFile /** * @public function constructor - * @param null */ public function __construct() { @@ -45,7 +44,7 @@ public function __construct() /** * @static function getInstance - * @param null + * * @return Morefiles */ public static function getInstance() @@ -65,7 +64,7 @@ public static function getInstance() * @param $folder * @param $extension */ - public function write($module, $folder, $filename, $extension): void + public function write($module, $folder, string $filename, $extension): void { $this->setModule($module); $this->setFileName($filename); @@ -75,25 +74,22 @@ public function write($module, $folder, $filename, $extension): void /** * @private function getTemplatesUserMoreFile - * @param null * * @return string */ private function getTemplatesUserMoreFile() { - $ret = <<<'EOT' + return <<<'EOT'
Pleace! Enter here your template code here
EOT; - - return $ret; } /** * @public function render - * @param null - * @return bool|string + * + * @return string */ public function render() { diff --git a/class/Files/Templates/User/Defstyle/Pages.php b/class/Files/Templates/User/Defstyle/Pages.php index e35239d3..dd121013 100644 --- a/class/Files/Templates/User/Defstyle/Pages.php +++ b/class/Files/Templates/User/Defstyle/Pages.php @@ -42,7 +42,6 @@ class Pages extends Files\CreateFile /** * @public function constructor - * @param null */ public function __construct() { @@ -53,7 +52,7 @@ public function __construct() /** * @static function getInstance - * @param null + * * @return Pages */ public static function getInstance() @@ -72,7 +71,7 @@ public static function getInstance() * @param $table * @param string $filename */ - public function write($module, $table, $filename): void + public function write($module, $table, string $filename): void { $this->setModule($module); $this->setTable($table); @@ -84,9 +83,9 @@ public function write($module, $table, $filename): void * @param string $moduleDirname * @return string */ - private function getTemplatesUserPagesHeader($moduleDirname) + private function getTemplatesUserPagesHeader(string $moduleDirname) { - return $this->sc->getSmartyIncludeFile($moduleDirname, 'header', '','',"\n\n"); + return $this->sc->getSmartyIncludeFile($moduleDirname, 'header', false,'',"\n\n"); } /** @@ -97,7 +96,7 @@ private function getTemplatesUserPagesHeader($moduleDirname) * @param string $language * @return string */ - private function getTemplatesUserPagesTable($moduleDirname, $tableName, $tableSoleName, $language) + private function getTemplatesUserPagesTable(string $moduleDirname, string $tableName, $tableSoleName, string $language) { $tbody = $this->getTemplatesUserPagesTableThead($tableName, $language); $tbody .= $this->getTemplatesUserPagesTableTbody($moduleDirname, $tableName, $tableSoleName); @@ -113,7 +112,7 @@ private function getTemplatesUserPagesTable($moduleDirname, $tableName, $tableSo * @param $tableName * @return string */ - private function getTemplatesUserPagesTableThead($tableName, $language) + private function getTemplatesUserPagesTableThead($tableName, string $language) { $stuTableName = \mb_strtoupper($tableName); $single = $this->sc->getSmartySingleVar('divideby'); @@ -131,7 +130,7 @@ private function getTemplatesUserPagesTableThead($tableName, $language) * @param $tableSoleName * @return string */ - private function getTemplatesUserPagesTableTbody($moduleDirname, $tableName, $tableSoleName) + private function getTemplatesUserPagesTableTbody(string $moduleDirname, $tableName, $tableSoleName) { $single = $this->sc->getSmartySingleVar('panel_type'); $include = $this->sc->getSmartyIncludeFile($moduleDirname, $tableName . '_item', false, "\t\t\t\t\t\t", "\n", $tableSoleName . '=$' . $tableSoleName); @@ -147,7 +146,7 @@ private function getTemplatesUserPagesTableTbody($moduleDirname, $tableName, $ta /** * @private function getTemplatesUserPagesTfoot - * @param null + * * @return string */ private function getTemplatesUserPagesTableTfoot() @@ -176,24 +175,22 @@ private function getTemplatesUserPages($moduleDirname, $tableName, $tableSoleNam /** * @private function getTemplatesUserPagesForm - * @param string $t * @return string */ - private function getTemplatesUserPagesForm($t = "\t") + private function getTemplatesUserPagesForm() { - $var = $this->sc->getSmartySingleVar('form', $t, "\n"); + $var = $this->sc->getSmartySingleVar('form', "\t", "\n"); return $this->sc->getSmartyConditions('form', '', '', $var, false, false, true); } /** * @private function getTemplatesUserPagesError - * @param string $t * @return string */ - private function getTemplatesUserPagesError($t = "\t") + private function getTemplatesUserPagesError() { - $var = $this->sc->getSmartySingleVar('error', $t, "\n"); + $var = $this->sc->getSmartySingleVar('error', "\t", "\n"); return $this->sc->getSmartyConditions('error', '', '', $var, false, false, true); } @@ -204,7 +201,7 @@ private function getTemplatesUserPagesError($t = "\t") * * @return string */ - private function getTemplatesUserPagesFooter($moduleDirname) + private function getTemplatesUserPagesFooter(string $moduleDirname) { $ret = $this->hc->getHtmlEmpty('', '', "\n"); $ret .= $this->sc->getSmartyIncludeFile($moduleDirname, 'footer'); @@ -214,9 +211,8 @@ private function getTemplatesUserPagesFooter($moduleDirname) /** * @public function render - * @param null * - * @return bool|string + * @return string */ public function render() { diff --git a/class/Files/Templates/User/Defstyle/PagesItem.php b/class/Files/Templates/User/Defstyle/PagesItem.php index f0197d4d..dbddf88b 100644 --- a/class/Files/Templates/User/Defstyle/PagesItem.php +++ b/class/Files/Templates/User/Defstyle/PagesItem.php @@ -45,7 +45,6 @@ class PagesItem extends Files\CreateFile /** * @public function constructor - * @param null */ public function __construct() { @@ -56,7 +55,7 @@ public function __construct() /** * @static function getInstance - * @param null + * * @return PagesItem */ public static function getInstance() @@ -76,7 +75,7 @@ public static function getInstance() * @param string $filename * @param $tables */ - public function write($module, $table, $tables, $filename): void + public function write($module, $table, $tables, string $filename): void { $this->setModule($module); $this->setTable($table); @@ -96,7 +95,7 @@ public function write($module, $table, $tables, $filename): void * @param $language * @return string */ - private function getTemplatesUserPagesItemPanel($moduleDirname, $tableId, $tableMid, $tableName, $tableSoleName, $tableRate, $tableBroken, $language) + private function getTemplatesUserPagesItemPanel(string $moduleDirname, $tableId, $tableMid, $tableName, $tableSoleName, $tableRate, $tableBroken, $language) { $fields = $this->getTableFields($tableMid, $tableId); $ret = ''; @@ -117,14 +116,14 @@ private function getTemplatesUserPagesItemPanel($moduleDirname, $tableId, $table default: $fieldName = $fields[$f]->getVar('field_name'); $rpFieldName = $this->getRightString($fieldName); - $doubleVar = $this->sc->getSmartyDoubleVar($tableSoleName, $rpFieldName); + $doubleVar = $this->sc->getSmartyDoubleVar($tableSoleName, $rpFieldName, '', '', "''|escape:'html'"); $retNumb .= $this->hc->getHtmlHNumb($doubleVar, '3', 'panel-title', "\t"); break; case Constants::FIELD_ELE_TEXTAREA: case Constants::FIELD_ELE_DHTMLTEXTAREA: $fieldName = $fields[$f]->getVar('field_name'); $rpFieldName = $this->getRightString($fieldName); - $doubleVar = $this->sc->getSmartyDoubleVar($tableSoleName, $rpFieldName . '_short'); + $doubleVar = $this->sc->getSmartyDoubleVar($tableSoleName, $rpFieldName . '_short', '', '', "''|escape:'html'"); $retNumb .= $this->hc->getHtmlHNumb($doubleVar, '3', 'panel-title', "\t"); break; case Constants::FIELD_ELE_SELECTSTATUS: @@ -134,14 +133,14 @@ private function getTemplatesUserPagesItemPanel($moduleDirname, $tableId, $table case Constants::FIELD_ELE_TEXTDATESELECT: $fieldName = $fields[$f]->getVar('field_name'); $rpFieldName = $this->getRightString($fieldName); - $doubleVar = $this->sc->getSmartyDoubleVar($tableSoleName, $rpFieldName . '_text'); + $doubleVar = $this->sc->getSmartyDoubleVar($tableSoleName, $rpFieldName . '_text', '', '', "''|escape:'html'"); $retNumb .= $this->hc->getHtmlHNumb($doubleVar, '3', 'panel-title', "\t"); break; case Constants::FIELD_ELE_IMAGELIST: $fieldName = $fields[$f]->getVar('field_name'); $rpFieldName = $this->getRightString($fieldName); - $singleVar = $this->sc->getSmartySingleVar('xoops_icons32_url'); - $doubleVar = $this->sc->getSmartyDoubleVar($tableSoleName, $rpFieldName); + $singleVar = $this->sc->getSmartySingleVar('xoops_icons32_url', '', '', "''|escape:'htmlattr'"); + $doubleVar = $this->sc->getSmartyDoubleVar($tableSoleName, $rpFieldName, '', '', "''|escape:'htmlattr'"); $img = $this->hc->getHtmlImage($singleVar . '/' . $doubleVar, (string)$tableName); $retNumb .= $this->hc->getHtmlHNumb($doubleVar, '3', 'panel-title', "\t"); unset($img); @@ -149,8 +148,8 @@ private function getTemplatesUserPagesItemPanel($moduleDirname, $tableId, $table case Constants::FIELD_ELE_UPLOADIMAGE: $fieldName = $fields[$f]->getVar('field_name'); $rpFieldName = $this->getRightString($fieldName); - $singleVar = $this->sc->getSmartySingleVar($moduleDirname . '_upload_url'); - $doubleVar = $this->sc->getSmartyDoubleVar($tableSoleName, $rpFieldName); + $singleVar = $this->sc->getSmartySingleVar($moduleDirname . '_upload_url', '', '', "''|escape:'htmlattr'"); + $doubleVar = $this->sc->getSmartyDoubleVar($tableSoleName, $rpFieldName, '', '', "''|escape:'htmlattr'"); $img = $this->hc->getHtmlImage($singleVar . "/images/{$tableName}/" . $doubleVar, (string)$tableName); $retNumb .= $this->hc->getHtmlHNumb($doubleVar, '3', 'panel-title', "\t"); unset($img); @@ -170,14 +169,14 @@ private function getTemplatesUserPagesItemPanel($moduleDirname, $tableId, $table default: $fieldName = $fields[$f]->getVar('field_name'); $rpFieldName = $this->getRightString($fieldName); - $doubleVar = $this->sc->getSmartyDoubleVar($tableSoleName, $rpFieldName); + $doubleVar = $this->sc->getSmartyDoubleVar($tableSoleName, $rpFieldName, '', '', "''|escape:'html'"); $retElem .= $this->hc->getHtmlSpan($doubleVar, 'col-sm-9 justify', "\t"); break; case Constants::FIELD_ELE_TEXTAREA: case Constants::FIELD_ELE_DHTMLTEXTAREA: $fieldName = $fields[$f]->getVar('field_name'); $rpFieldName = $this->getRightString($fieldName); - $doubleVar = $this->sc->getSmartyDoubleVar($tableSoleName, $rpFieldName . '_short'); + $doubleVar = $this->sc->getSmartyDoubleVar($tableSoleName, $rpFieldName . '_short', '', '', "''|escape:'html'"); $retElem .= $this->hc->getHtmlSpan($doubleVar, 'col-sm-9 justify', "\t"); break; case Constants::FIELD_ELE_SELECTSTATUS: @@ -187,14 +186,14 @@ private function getTemplatesUserPagesItemPanel($moduleDirname, $tableId, $table case Constants::FIELD_ELE_TEXTDATESELECT: $fieldName = $fields[$f]->getVar('field_name'); $rpFieldName = $this->getRightString($fieldName); - $doubleVar = $this->sc->getSmartyDoubleVar($tableSoleName, $rpFieldName . '_text'); + $doubleVar = $this->sc->getSmartyDoubleVar($tableSoleName, $rpFieldName . '_text', '', '', "''|escape:'html'"); $retElem .= $this->hc->getHtmlSpan($doubleVar, 'col-sm-9 justify', "\t"); break; case Constants::FIELD_ELE_IMAGELIST: $fieldName = $fields[$f]->getVar('field_name'); $rpFieldName = $this->getRightString($fieldName); - $singleVar = $this->sc->getSmartySingleVar('xoops_icons32_url'); - $doubleVar = $this->sc->getSmartyDoubleVar($tableSoleName, $rpFieldName); + $singleVar = $this->sc->getSmartySingleVar('xoops_icons32_url', '', '', "''|escape:'htmlattr'"); + $doubleVar = $this->sc->getSmartyDoubleVar($tableSoleName, $rpFieldName, '', '', "''|escape:'htmlattr'"); $img = $this->hc->getHtmlImage($singleVar . '/' . $doubleVar, (string)$tableName); $retElem .= $this->hc->getHtmlSpan($img, 'col-sm-9 justify', "\t"); unset($img); @@ -202,8 +201,8 @@ private function getTemplatesUserPagesItemPanel($moduleDirname, $tableId, $table case Constants::FIELD_ELE_UPLOADIMAGE: $fieldName = $fields[$f]->getVar('field_name'); $rpFieldName = $this->getRightString($fieldName); - $singleVar = $this->sc->getSmartySingleVar($moduleDirname . '_upload_url'); - $doubleVar = $this->sc->getSmartyDoubleVar($tableSoleName, $rpFieldName); + $singleVar = $this->sc->getSmartySingleVar($moduleDirname . '_upload_url', '', '', "''|escape:'htmlattr'"); + $doubleVar = $this->sc->getSmartyDoubleVar($tableSoleName, $rpFieldName, '', '', "''|escape:'htmlattr'"); $img = $this->hc->getHtmlImage($singleVar . "/images/{$tableName}/" . $doubleVar, (string)$tableName); $retElem .= $this->hc->getHtmlSpan($img, 'col-sm-9 justify',"\t"); unset($img); @@ -225,7 +224,7 @@ private function getTemplatesUserPagesItemPanel($moduleDirname, $tableId, $table $rpFieldName = $this->getRightString($fieldName); $langConst = \mb_strtoupper($tableSoleName) . '_' . \mb_strtoupper($rpFieldName); $lang = $this->sc->getSmartyConst($language, $langConst); - $doubleVar = $this->sc->getSmartyDoubleVar($tableSoleName, $rpFieldName); + $doubleVar = $this->sc->getSmartyDoubleVar($tableSoleName, $rpFieldName, '', '', "''|escape:'html'"); $retFoot .= $this->hc->getHtmlSpan($lang . ': ' . $doubleVar, 'block-pie justify',"\t"); break; case Constants::FIELD_ELE_TEXTAREA: @@ -234,7 +233,7 @@ private function getTemplatesUserPagesItemPanel($moduleDirname, $tableId, $table $rpFieldName = $this->getRightString($fieldName); $langConst = \mb_strtoupper($tableSoleName) . '_' . \mb_strtoupper($rpFieldName); $lang = $this->sc->getSmartyConst($language, $langConst); - $doubleVar = $this->sc->getSmartyDoubleVar($tableSoleName, $rpFieldName . '_short'); + $doubleVar = $this->sc->getSmartyDoubleVar($tableSoleName, $rpFieldName . '_short', '', '', "''|escape:'html'"); $retFoot .= $this->hc->getHtmlSpan($lang . ': ' . $doubleVar, 'block-pie justify',"\t"); break; case Constants::FIELD_ELE_SELECTSTATUS: @@ -246,25 +245,25 @@ private function getTemplatesUserPagesItemPanel($moduleDirname, $tableId, $table $rpFieldName = $this->getRightString($fieldName); $langConst = \mb_strtoupper($tableSoleName) . '_' . \mb_strtoupper($rpFieldName); $lang = $this->sc->getSmartyConst($language, $langConst); - $doubleVar = $this->sc->getSmartyDoubleVar($tableSoleName, $rpFieldName . '_text'); + $doubleVar = $this->sc->getSmartyDoubleVar($tableSoleName, $rpFieldName . '_text', '', '', "''|escape:'html'"); $retFoot .= $this->hc->getHtmlSpan($lang . ': ' . $doubleVar, 'block-pie justify',"\t"); break; case Constants::FIELD_ELE_IMAGELIST: $fieldName = $fields[$f]->getVar('field_name'); $rpFieldName = $this->getRightString($fieldName); - $singleVar = $this->sc->getSmartySingleVar('xoops_icons32_url'); - $doubleVar = $this->sc->getSmartyDoubleVar($tableSoleName, $rpFieldName); + $singleVar = $this->sc->getSmartySingleVar('xoops_icons32_url', '', '', "''|escape:'htmlattr'"); + $doubleVar = $this->sc->getSmartyDoubleVar($tableSoleName, $rpFieldName, '', '', "''|escape:'htmlattr'"); $img = $this->hc->getHtmlImage($singleVar . '/' . $doubleVar, (string)$tableName); - $retElem .= $this->hc->getHtmlSpan($img, 'block-pie justify', "\t"); + //$retElem .= $this->hc->getHtmlSpan($img, 'block-pie justify', "\t"); unset($img); break; case Constants::FIELD_ELE_UPLOADIMAGE: $fieldName = $fields[$f]->getVar('field_name'); $rpFieldName = $this->getRightString($fieldName); - $singleVar = $this->sc->getSmartySingleVar($moduleDirname . '_upload_url'); - $doubleVar = $this->sc->getSmartyDoubleVar($tableSoleName, $rpFieldName); + $singleVar = $this->sc->getSmartySingleVar($moduleDirname . '_upload_url', '', '', "''|escape:'htmlattr'"); + $doubleVar = $this->sc->getSmartyDoubleVar($tableSoleName, $rpFieldName, '', '', "''|escape:'htmlattr'"); $img = $this->hc->getHtmlImage($singleVar . "/images/{$tableName}/" . $doubleVar, (string)$tableName); - $retElem .= $this->hc->getHtmlSpan($img, 'block-pie justify',"\t"); + //$retElem .= $this->hc->getHtmlSpan($img, 'block-pie justify',"\t"); unset($img); break; } @@ -290,7 +289,7 @@ private function getTemplatesUserPagesItemPanel($moduleDirname, $tableId, $table $anchors .= $this->hc->getHtmlAnchor($tableName . ".php?op=broken&{$fieldId}=" . $keyDouble . '&start=<{$start|default:0}>&limit=<{$limit|default:0}>', $lang, $lang, '', 'btn btn-warning right', '', "\t\t", "\n"); } $retFoot .= $this->hc->getHtmlDiv($anchors, 'col-sm-12 right',"\t"); - $ret .= $this->hc->getHtmlDiv($retFoot, 'panel-foot'); + $ret .= $this->hc->getHtmlDiv($retFoot, 'panel-footer'); if ($tableRate) { $rate = $this->sc->getSmartyIncludeFile($moduleDirname, 'rate', false, "\t", "\n", 'item=$' . $tableSoleName); $ret .= $this->sc->getSmartyConditions('rating', '', '', $rate, false, false, false, '', "\n", true, 'bool'); @@ -301,8 +300,8 @@ private function getTemplatesUserPagesItemPanel($moduleDirname, $tableId, $table /** * @public function render - * @param null - * @return bool|string + * + * @return string */ public function render() { diff --git a/class/Files/Templates/User/Defstyle/PagesList.php b/class/Files/Templates/User/Defstyle/PagesList.php index 1bfe3403..fc818059 100644 --- a/class/Files/Templates/User/Defstyle/PagesList.php +++ b/class/Files/Templates/User/Defstyle/PagesList.php @@ -45,7 +45,6 @@ class PagesList extends Files\CreateFile /** * @public function constructor - * @param null */ public function __construct() { @@ -56,7 +55,7 @@ public function __construct() /** * @static function getInstance - * @param null + * * @return PagesList */ public static function getInstance() @@ -76,7 +75,7 @@ public static function getInstance() * @param string $filename * @param $tables */ - public function write($module, $table, $tables, $filename): void + public function write($module, $table, $tables, string $filename): void { $this->setModule($module); $this->setTable($table); @@ -94,7 +93,7 @@ public function write($module, $table, $tables, $filename): void * @param $language * @return string */ - private function getTemplatesUserPagesListPanel($moduleDirname, $tableId, $tableMid, $tableName, $tableSoleName, $language) + private function getTemplatesUserPagesListPanel(string $moduleDirname, $tableId, $tableMid, $tableName, $tableSoleName, $language) { $fields = $this->getTableFields($tableMid, $tableId); $ret = ''; @@ -278,8 +277,8 @@ private function getTemplatesUserPagesListPanel($moduleDirname, $tableId, $table /** * @public function render - * @param null - * @return bool|string + * + * @return string */ public function render() { diff --git a/class/Files/Templates/User/Defstyle/Pdf.php b/class/Files/Templates/User/Defstyle/Pdf.php index 60260c75..5ef1b5ee 100644 --- a/class/Files/Templates/User/Defstyle/Pdf.php +++ b/class/Files/Templates/User/Defstyle/Pdf.php @@ -45,7 +45,6 @@ class Pdf extends Files\CreateFile /** * @public function constructor - * @param null */ public function __construct() { @@ -56,7 +55,7 @@ public function __construct() /** * @static function getInstance - * @param null + * * @return Pdf */ public static function getInstance() @@ -93,7 +92,7 @@ public function write($module, $table, $filename): void * @param $language * @return string */ - private function getTemplatesUserPdfBody($moduleDirname, $tableId, $tableMid, $tableName, $tableSoleName, $language) + private function getTemplatesUserPdfBody(string $moduleDirname, $tableId, $tableMid, $tableName, $tableSoleName, $language) { $fields = $this->getTableFields($tableMid, $tableId); $ret = ''; @@ -152,8 +151,8 @@ private function getTemplatesUserPdfBody($moduleDirname, $tableId, $tableMid, $t /** * @public function render - * @param null - * @return bool|string + * + * @return string */ public function render() { diff --git a/class/Files/Templates/User/Defstyle/Rate.php b/class/Files/Templates/User/Defstyle/Rate.php index b5c69ec8..5c2a716a 100644 --- a/class/Files/Templates/User/Defstyle/Rate.php +++ b/class/Files/Templates/User/Defstyle/Rate.php @@ -36,7 +36,6 @@ class Rate extends Files\CreateFile { /** * @public function constructor - * @param null */ public function __construct() { @@ -45,7 +44,6 @@ public function __construct() /** * @static function getInstance - * @param null * @return Rate */ public static function getInstance() @@ -64,7 +62,7 @@ public static function getInstance() * @param $table * @param string $filename */ - public function write($module, $table, $filename): void + public function write($module, $table, string $filename): void { $this->setModule($module); $this->setTable($table); @@ -74,12 +72,12 @@ public function write($module, $table, $filename): void /** * @private function getTemplatesUserRateHeader * @param string $moduleDirname - * @param string $table + * @param $table * @param string $language * * @return string */ - private function getTemplatesUserRateHeader($moduleDirname, $table, $language) + private function getTemplatesUserRateHeader(string $moduleDirname, $table, string $language) { $ret = << @@ -108,11 +106,11 @@ private function getTemplatesUserRateHeader($moduleDirname, $table, $language) /** * @private function getTemplatesUserRateBody * @param string $moduleDirname - * @param string $table + * @param $table * * @return string */ - private function getTemplatesUserRateBody($moduleDirname, $table) + private function getTemplatesUserRateBody(string $moduleDirname, $table) { $tableName = $table->getVar('table_name'); $ret = <<getVar('table_name'); $ret = << EOT; - - return $ret; } /** * @public function render - * @param null - * @return bool|string + * @return string */ public function render() { diff --git a/class/Files/Templates/User/Defstyle/Rss.php b/class/Files/Templates/User/Defstyle/Rss.php index bd2b08e2..a83de0bf 100644 --- a/class/Files/Templates/User/Defstyle/Rss.php +++ b/class/Files/Templates/User/Defstyle/Rss.php @@ -33,7 +33,6 @@ class Rss extends Files\CreateFile { /** * @public function constructor - * @param null */ public function __construct() { @@ -42,7 +41,6 @@ public function __construct() /** * @static function getInstance - * @param null * @return Rss */ public static function getInstance() @@ -60,7 +58,7 @@ public static function getInstance() * @param $module * @param string $filename */ - public function write($module, $filename): void + public function write($module, string $filename): void { $this->setModule($module); $this->setFileName($filename); @@ -68,54 +66,50 @@ public function write($module, $filename): void /** * @private function getTemplatesUserRssXml - * @param null * @return string */ private function getTemplatesUserRssXml() { - $ret = << - <{\$channel_title}> - <{\$channel_link}> - <{\$channel_desc}> - <{\$channel_lastbuild}> - https://backend.userland.com/rss/ - <{\$channel_generator}> - <{\$channel_category}> - <{\$channel_editor}> - <{\$channel_webmaster}> - <{\$channel_language}> + <{\$channel_title|escape:'html':'UTF-8'}> + <{\$channel_link|escape:'html':'UTF-8'}> + <{\$channel_desc|escape:'html':'UTF-8'}> + <{\$channel_lastbuild|escape:'html':'UTF-8'}> + <{\$docs|escape:'html':'UTF-8'}> + <{\$channel_generator|escape:'html':'UTF-8'}> + <{\$channel_category|escape:'html':'UTF-8'}> + <{\$channel_editor|escape:'html':'UTF-8'}> + <{\$channel_webmaster|escape:'html':'UTF-8'}> + <{\$channel_language|escape:'html':'UTF-8'}> <{if \$image_url != ""}> - <{\$channel_title}> - <{\$image_url}> - <{\$channel_link}> + <{\$channel_title|escape:'html':'UTF-8'}> + <{\$image_url|escape:'html':'UTF-8'}> + <{\$channel_link|escape:'html':'UTF-8'}> <{\$image_width}> <{\$image_height}> <{/if}> <{foreach item=item from=\$items}> - <{\$item.title}> - <{\$item.link}> - <{\$item.description}> - <{\$item.pubdate}> - <{\$item.guid}> + <{\$item.title|escape:'html':'UTF-8'}> + <{\$item.link|escape:'html':'UTF-8'}> + <{\$item.description|escape:'html':'UTF-8'}> + <{\$item.pubdate|escape:'html':'UTF-8'}> + <{\$item.guid|escape:'html':'UTF-8'}> <{/foreach}> \n EOT; - - return $ret; } /** * @public function render - * @param null - * @return bool|string + * @return string */ public function render() { diff --git a/class/Files/Templates/User/Defstyle/Search.php b/class/Files/Templates/User/Defstyle/Search.php index d83e8add..d7d78ae1 100644 --- a/class/Files/Templates/User/Defstyle/Search.php +++ b/class/Files/Templates/User/Defstyle/Search.php @@ -33,7 +33,6 @@ class Search extends Files\CreateFile { /** * @public function constructor - * @param null */ public function __construct() { @@ -42,7 +41,6 @@ public function __construct() /** * @static function getInstance - * @param null * @return Search */ public static function getInstance() @@ -61,7 +59,7 @@ public static function getInstance() * @param $table * @param string $filename */ - public function write($module, $table, $filename): void + public function write($module, $table, string $filename): void { $this->setModule($module); $this->setTable($table); @@ -71,12 +69,12 @@ public function write($module, $table, $filename): void /** * @private function getTemplatesUserSearchHeader * @param string $moduleDirname - * @param string $table + * @param $table * @param string $language * * @return string */ - private function getTemplatesUserSearchHeader($moduleDirname, $table, $language) + private function getTemplatesUserSearchHeader(string $moduleDirname, $table, string $language) { $ret = << @@ -105,11 +103,11 @@ private function getTemplatesUserSearchHeader($moduleDirname, $table, $language) /** * @private function getTemplatesUserSearchBody * @param string $moduleDirname - * @param string $table + * @param $table * * @return string */ - private function getTemplatesUserSearchBody($moduleDirname, $table) + private function getTemplatesUserSearchBody(string $moduleDirname, $table) { $tableName = $table->getVar('table_name'); $ret = <<getVar('table_name'); $ret = << EOT; - - return $ret; } /** * @public function render - * @param null - * @return bool|string + * @return string */ public function render() { diff --git a/class/Files/Templates/User/Defstyle/UserPrint.php b/class/Files/Templates/User/Defstyle/UserPrint.php index deb80c91..17a08323 100644 --- a/class/Files/Templates/User/Defstyle/UserPrint.php +++ b/class/Files/Templates/User/Defstyle/UserPrint.php @@ -45,7 +45,6 @@ class UserPrint extends Files\CreateFile /** * @public function constructor - * @param null */ public function __construct() { @@ -56,7 +55,6 @@ public function __construct() /** * @static function getInstance - * @param null * @return UserPrint */ public static function getInstance() @@ -75,7 +73,7 @@ public static function getInstance() * @param $table * @param string $filename */ - public function write($module, $table, $filename): void + public function write($module, $table, string $filename): void { $this->setModule($module); $this->setTable($table); @@ -87,7 +85,7 @@ public function write($module, $table, $filename): void * @param string $moduleDirname * @return string */ - private function getTemplatesUserPrintHeader($moduleDirname) + private function getTemplatesUserPrintHeader(string $moduleDirname) { $ret = $this->hc->getHtmlComment('Header', '', "\n"); $ret .= $this->sc->getSmartyIncludeFile($moduleDirname, 'header', false, '', "\n\n"); @@ -99,11 +97,11 @@ private function getTemplatesUserPrintHeader($moduleDirname) * @private function getTemplatesUserPrintTableThead * @param $tableSoleName * @param $tableAutoincrement - * @param array $fields + * @param array $fields * @param string $language * @return string */ - private function getTemplatesUserPrintTableThead($tableSoleName, $tableAutoincrement, $fields, $language) + private function getTemplatesUserPrintTableThead($tableSoleName, $tableAutoincrement, array $fields, string $language) { $th = ''; $langHeadId = \mb_strtoupper($tableSoleName) . '_ID'; @@ -122,9 +120,7 @@ private function getTemplatesUserPrintTableThead($tableSoleName, $tableAutoincre } $tr = $this->hc->getHtmlTableRow($th, 'head', "\t\t"); - $ret = $this->hc->getHtmlTableThead($tr, '', "\t"); - - return $ret; + return $this->hc->getHtmlTableThead($tr, '', "\t"); } /** @@ -133,11 +129,11 @@ private function getTemplatesUserPrintTableThead($tableSoleName, $tableAutoincre * @param string $tableName * @param $tableSoleName * @param $tableAutoincrement - * @param array $fields + * @param array $fields * @return string * @internal param string $language */ - private function getTemplatesUserPrintTableTBody($moduleDirname, $tableName, $tableSoleName, $tableAutoincrement, $fields) + private function getTemplatesUserPrintTableTBody(string $moduleDirname, string $tableName, $tableSoleName, $tableAutoincrement, array $fields) { $td = ''; if (1 == $tableAutoincrement) { @@ -207,9 +203,7 @@ private function getTemplatesUserPrintTableTBody($moduleDirname, $tableName, $ta $cycle = $this->sc->getSmartyNoSimbol('cycle values=\'odd, even\''); $tr = $this->hc->getHtmlTableRow($td, $cycle, "\t\t"); $foreach = $this->sc->getSmartyForeach($tableSoleName, $tableName . '_list', $tr, '', '', "\t\t"); - $tbody = $this->hc->getHtmlTableTbody($foreach, '', "\t"); - - return $tbody; + return $this->hc->getHtmlTableTbody($foreach, '', "\t"); } /** @@ -222,7 +216,7 @@ private function getTemplatesUserPrintTableTBody($moduleDirname, $tableName, $ta * @param string $language * @return string */ - private function getTemplatesUserPrintTable($moduleDirname, $tableName, $tableSoleName, $tableAutoincrement, $fields, $language) + private function getTemplatesUserPrintTable(string $moduleDirname, string $tableName, $tableSoleName, $tableAutoincrement, $fields, string $language) { $tbody = $this->getTemplatesUserPrintTableThead($tableSoleName, $tableAutoincrement, $fields, $language); $tbody .= $this->getTemplatesUserPrintTableTBody($moduleDirname, $tableName, $tableSoleName, $tableAutoincrement, $fields); @@ -240,11 +234,9 @@ private function getTemplatesUserPrintTable($moduleDirname, $tableName, $tableSo * @param string $language * @return string */ - private function getTemplatesUserPrint($moduleDirname, $tableName, $tableSoleName, $tableAutoincrement, $fields, $language) + private function getTemplatesUserPrint(string $moduleDirname, string $tableName, $tableSoleName, $tableAutoincrement, $fields, string $language) { - $htmlTable = $this->getTemplatesUserPrintTable($moduleDirname, $tableName, $tableSoleName, $tableAutoincrement, $fields, $language); - - return $htmlTable; + return $this->getTemplatesUserPrintTable($moduleDirname, $tableName, $tableSoleName, $tableAutoincrement, $fields, $language); } /** @@ -252,18 +244,17 @@ private function getTemplatesUserPrint($moduleDirname, $tableName, $tableSoleNam * @param string $moduleDirname * @return string */ - private function getTemplatesUserPrintFooter($moduleDirname) + private function getTemplatesUserPrintFooter(string $moduleDirname) { $ret = $this->hc->getHtmlComment('Footer', '', "\n"); - $ret .= $this->sc->getSmartyIncludeFile($moduleDirname, 'footer', false); + $ret .= $this->sc->getSmartyIncludeFile($moduleDirname, 'footer'); return $ret; } /** * @public function render - * @param null - * @return bool|string + * @return string */ public function render() { diff --git a/class/Files/User/UserFooter.php b/class/Files/User/UserFooter.php index 15e76361..1532ebce 100644 --- a/class/Files/User/UserFooter.php +++ b/class/Files/User/UserFooter.php @@ -46,7 +46,6 @@ class UserFooter extends Files\CreateFile /** * @public function constructor - * @param null */ public function __construct() { @@ -58,7 +57,6 @@ public function __construct() /** * @static function getInstance - * @param null * @return UserFooter */ public static function getInstance() @@ -73,10 +71,10 @@ public static function getInstance() /** * @public function write - * @param string $module + * @param $module * @param string $filename */ - public function write($module, $filename): void + public function write($module, string $filename): void { $this->setModule($module); $this->setFileName($filename); @@ -103,7 +101,7 @@ private function getUserFooter($moduleDirname, $language) $ret .= $this->xc->getXcXoopsTplAssign('admin', "\\{$stuModuleDirname}_ADMIN"); $ret .= $this->xc->getXcXoopsTplAssign('copyright', '$copyright'); $ret .= $this->pc->getPhpCodeCommentLine('Meta description'); - $ret .= $this->uxc->getUserMetaDesc($moduleDirname, $language); + $ret .= $this->uxc->getUserMetaDesc($moduleDirname); $ret .= $this->pc->getPhpCodeBlankLine(); $ret .= $this->pc->getPhpCodeCommentLine('Paths'); $ret .= $this->xc->getXcXoopsTplAssign('xoops_mpageurl', "\\{$stuModuleDirname}_URL.'/index.php'"); @@ -118,8 +116,7 @@ private function getUserFooter($moduleDirname, $language) /** * @public function render - * @param null - * @return bool|string + * @return string */ public function render() { diff --git a/class/Files/User/UserHeader.php b/class/Files/User/UserHeader.php index e52d2932..da25d5e1 100644 --- a/class/Files/User/UserHeader.php +++ b/class/Files/User/UserHeader.php @@ -31,10 +31,6 @@ */ class UserHeader extends Files\CreateFile { - /** - * @var mixed - */ - private $uxc = null; /** * @var mixed */ @@ -46,19 +42,16 @@ class UserHeader extends Files\CreateFile /** * @public function constructor - * @param null */ public function __construct() { parent::__construct(); $this->xc = Modulebuilder\Files\CreateXoopsCode::getInstance(); $this->pc = Modulebuilder\Files\CreatePhpCode::getInstance(); - $this->uxc = Modulebuilder\Files\User\UserXoopsCode::getInstance(); } /** * @static function getInstance - * @param null * @return UserHeader */ public static function getInstance() @@ -73,12 +66,12 @@ public static function getInstance() /** * @public function write - * @param string $module + * @param $module * @param mixed $table * @param array $tables * @param string $filename */ - public function write($module, $table, $tables, $filename): void + public function write($module, $table, array $tables, string $filename): void { $this->setModule($module); $this->setTable($table); @@ -142,8 +135,7 @@ private function getUserHeader($moduleDirname) /** * @public function render - * @param null - * @return bool|string + * @return string */ public function render() { diff --git a/class/Files/User/UserIndex.php b/class/Files/User/UserIndex.php index 64dd9b4a..f5cc860f 100644 --- a/class/Files/User/UserIndex.php +++ b/class/Files/User/UserIndex.php @@ -46,7 +46,6 @@ class UserIndex extends Files\CreateFile /** * @public function constructor - * @param null */ public function __construct() { @@ -58,7 +57,6 @@ public function __construct() /** * @static function getInstance - * @param null * @return UserIndex */ public static function getInstance() @@ -73,11 +71,11 @@ public static function getInstance() /** * @public function write - * @param string $module + * @param $module * @param $table * @param string $filename */ - public function write($module, $table, $filename) + public function write($module, $table, string $filename) { $this->setModule($module); $this->setTable($table); @@ -93,8 +91,6 @@ public function write($module, $table, $filename) */ private function getUserIndexHeader($language, $moduleDirname) { - $stuModuleDirname = \mb_strtoupper($moduleDirname); - $ret = $this->getRequire(); $ret .= $this->uxc->getUserTplMain($moduleDirname); $ret .= $this->pc->getPhpCodeIncludeDir('\XOOPS_ROOT_PATH', 'header', true); @@ -130,7 +126,7 @@ private function getBodyCategoriesIndex($tableMid, $tableId, $tableName, $tableS $ret .= $this->pc->getPhpCodeCommentLine('If there are ', $tableName); $ret .= $this->getSimpleString('$count = 1;'); - $contentIf = $this->xc->getXcHandlerAllObj($tableName, '', 0, 0, "\t"); + $contentIf = $this->xc->getXcHandlerAllObj($tableName, '', '0', '0', "\t"); $contentIf .= $this->pc->getPhpCodeIncludeDir('XOOPS_ROOT_PATH', 'class/tree', true, false, 'require', "\t"); //$contentIf .= $cc->getClassXoopsObjectTree('mytree', $tableName, $fieldId, $fieldParent, "\t"); $contentIf .= $this->pc->getPhpCodeArray($tableName, "\t"); @@ -143,7 +139,7 @@ private function getBodyCategoriesIndex($tableMid, $tableId, $tableName, $tableS $contentIf .= $this->pc->getPhpCodeUnset($tableName, "\t"); $getConfig = $this->xc->getXcGetConfig('numb_col'); $contentIf .= $this->xc->getXcXoopsTplAssign('numb_col', $getConfig, true, "\t"); - $ret .= $this->pc->getPhpCodeConditions("\${$tableName}Count", ' > ', '0', $contentIf, false); + $ret .= $this->pc->getPhpCodeConditions("\${$tableName}Count", ' > ', '0', $contentIf); $ret .= $this->pc->getPhpCodeUnset('count'); } unset($fieldParentId); @@ -154,15 +150,15 @@ private function getBodyCategoriesIndex($tableMid, $tableId, $tableName, $tableS /** * @private function getBodyPagesIndex * @param $tableName - * @param $tableSoleName * @param $language + * @param $tableMid + * @param $tableId * @return string */ - private function getBodyPagesIndex($tableName, $tableSoleName, $language) + private function getBodyPagesIndex($tableName, $language, $tableMid, $tableId) { $ucfTableName = \ucfirst($tableName); - $table = $this->getTable(); - $fields = $this->getTableFields($table->getVar('table_mid'), $table->getVar('table_id')); + $fields = $this->getTableFields($tableMid, $tableId); $ret = $this->pc->getPhpCodeCommentLine('Tables'); $ret .= $this->xc->getXcHandlerCountObj($tableName); @@ -174,7 +170,7 @@ private function getBodyPagesIndex($tableName, $tableSoleName, $language) $condIf .= $this->xc->getXcHandlerAllObj($tableName, '', '$start', '$limit', "\t"); $condIf .= $this->pc->getPhpCodeCommentLine('Get All', $ucfTableName, "\t"); $condIf .= $this->pc->getPhpCodeArray($tableName . '_list', null, false, "\t"); - $foreach = $this->xc->getXcGetValues($tableName, $tableSoleName . '_list[]', 'i', false, "\t\t"); + $foreach = $this->xc->getXcGetValues($tableName, $tableName . '_list[]', 'i', false, "\t\t"); //$foreach .= $this->pc->getPhpCodeArray('acount', ["'count'", '$count']); //$foreach .= $this->pc->getPhpCodeArrayType($tableName . '_list', 'merge', $tableSoleName . '_list', '$acount'); // Fields @@ -208,10 +204,10 @@ private function getBodyPagesIndex($tableName, $tableSoleName, $language) /** * @private function getUserPagesFooter * @param $moduleDirname - * @param $language + * * @return string */ - private function getUserIndexFooter($moduleDirname, $language) + private function getUserIndexFooter($moduleDirname) { $ret = $this->pc->getPhpCodeCommentLine('Meta keywords'); $ret .= $this->uxc->getUserMetaKeywords($moduleDirname); @@ -223,8 +219,7 @@ private function getUserIndexFooter($moduleDirname, $language) /** * @public function render - * @param null - * @return bool|string + * @return string */ public function render() { @@ -252,10 +247,10 @@ public function render() $content .= $this->getBodyCategoriesIndex($tableMid, $tableId, $tableName, $tableSoleName, $tableFieldname); } if (0 == $tableCategory && 1 == $tableIndex) { - $content .= $this->getBodyPagesIndex($tableName, $tableSoleName, $language); + $content .= $this->getBodyPagesIndex($tableName, $language, $tableMid, $tableId); } } - $content .= $this->getUserIndexFooter($moduleDirname, $language); + $content .= $this->getUserIndexFooter($moduleDirname); $this->create($moduleDirname, '/', $filename, $content, \_AM_MODULEBUILDER_FILE_CREATED, \_AM_MODULEBUILDER_FILE_NOTCREATED); diff --git a/class/Files/User/UserListTag.php b/class/Files/User/UserListTag.php index abd98e55..d88699a3 100644 --- a/class/Files/User/UserListTag.php +++ b/class/Files/User/UserListTag.php @@ -38,7 +38,6 @@ class UserListTag extends Files\CreateFile /** * @public function constructor - * @param null */ public function __construct() { @@ -48,7 +47,6 @@ public function __construct() /** * @static function getInstance - * @param null * @return UserListTag */ public static function getInstance() @@ -63,10 +61,10 @@ public static function getInstance() /** * @public function write - * @param string $module + * @param $module * @param string $filename */ - public function write($module, $filename): void + public function write($module, string $filename): void { $this->setModule($module); $this->setFileName($filename); @@ -74,7 +72,6 @@ public function write($module, $filename): void /** * @public function getUserListTag - * @param null * @return string */ public function getUserListTag() @@ -87,8 +84,7 @@ public function getUserListTag() /** * @public function render - * @param null - * @return bool|string + * @return string */ public function render() { diff --git a/class/Files/User/UserNotificationUpdate.php b/class/Files/User/UserNotificationUpdate.php index 5a34ef8b..a494d813 100644 --- a/class/Files/User/UserNotificationUpdate.php +++ b/class/Files/User/UserNotificationUpdate.php @@ -38,7 +38,6 @@ class UserNotificationUpdate extends Files\CreateFile /** * @public function constructor - * @param null */ public function __construct() { @@ -48,7 +47,6 @@ public function __construct() /** * @static function getInstance - * @param null * @return UserNotificationUpdate */ public static function getInstance() @@ -63,10 +61,10 @@ public static function getInstance() /** * @public function write - * @param string $module + * @param $module * @param string $filename */ - public function write($module, $filename): void + public function write($module, string $filename): void { $this->setModule($module); $this->setFileName($filename); @@ -74,8 +72,7 @@ public function write($module, $filename): void /** * @public function render - * @param null - * @return bool|string + * @return string */ public function render() { diff --git a/class/Files/User/UserPages.php b/class/Files/User/UserPages.php index aae5e3ef..2449c596 100644 --- a/class/Files/User/UserPages.php +++ b/class/Files/User/UserPages.php @@ -49,7 +49,6 @@ class UserPages extends Files\CreateFile /** * @public function constructor - * @param null */ public function __construct() { @@ -61,7 +60,6 @@ public function __construct() /** * @static function getInstance - * @param null * @return UserPages */ public static function getInstance() @@ -98,7 +96,6 @@ public function write($module, $table, $filename) */ private function getUserPagesHeader($moduleDirname, $tableName, $fieldId, $tablePermissions, $language) { - $stuModuleDirname = \mb_strtoupper($moduleDirname); $ccFieldId = $this->getCamelCase($fieldId, false, true); $ret = $this->pc->getPhpCodeUseNamespace(['Xmf', 'Request'], '', ''); @@ -160,7 +157,7 @@ private function getUserPagesHeader($moduleDirname, $tableName, $fieldId, $table * @param string $t * @return string */ - private function getUserPagesList($moduleDirname, $tableName, $fieldId, $fieldMain, $tableRate, $fieldReads, $language, $t = '') + private function getUserPagesList($moduleDirname, $tableName, $fieldId, $fieldMain, $tableRate, $fieldReads, $language, string $t = '') { $ucfTableName = \ucfirst($tableName); $stuTableName = \mb_strtoupper($tableName); @@ -169,8 +166,7 @@ private function getUserPagesList($moduleDirname, $tableName, $fieldId, $fieldMa $ccFieldReads = $this->getCamelCase($fieldReads, false, true); $stuModuleDirname = \mb_strtoupper($moduleDirname); - $ret = ''; - $ret .= $this->uxc->getUserBreadcrumbs($language, $tableName, 'list', '', "\t\t"); + $ret = $this->uxc->getUserBreadcrumbs($language, $tableName, 'list', '', "\t\t"); if ($tableRate) { $varRate = '$ratingbars'; $ret .= $this->xc->getXcEqualsOperator($varRate, '(int)' . $this->xc->getXcGetConfig('ratingbars'),'', $t); @@ -190,7 +186,7 @@ private function getUserPagesList($moduleDirname, $tableName, $fieldId, $fieldMa $contIf = $this->xc->getXcCriteriaAdd($critName, $crit, $t . "\t"); $ret .= $this->pc->getPhpCodeConditions("\${$ccFieldId}", ' > ', '0', $contIf, false, $t); $ret .= $this->xc->getXcHandlerCountClear($tableName . 'Count', $tableName, '$' . $critName, $t); - $ret .= $this->xc->getXcXoopsTplAssign($tableName . 'Count', "\${$tableName}Count", '', $t); + $ret .= $this->xc->getXcXoopsTplAssign($tableName . 'Count', "\${$tableName}Count", true, $t); $contIf = $this->xc->getXcCriteriaSetStart($critName, '$start', $t . "\t"); $contIf .= $this->xc->getXcCriteriaSetLimit($critName, '$limit', $t . "\t"); $ret .= $this->pc->getPhpCodeConditions("\${$ccFieldId}", ' === ', '0', $contIf, false, $t); @@ -203,8 +199,11 @@ private function getUserPagesList($moduleDirname, $tableName, $fieldId, $fieldMa $foreach .= $this->xc->getXcEqualsOperator('$keywords[$i]', "\${$ccFieldMain}",'', $t . "\t\t"); if ($tableRate) { $itemId = $this->xc->getXcGetVar($ccFieldId, "{$tableName}All[\$i]", $fieldId, true); - $const = $this->xc->getXcGetConstants('TABLE_' . $stuTableName); - $foreach .= $this->xc->getXcEqualsOperator("\${$tableName}[\$i]['rating']", "\$ratingsHandler->getItemRating({$itemId}, {$const})",'', $t . "\t\t"); + $const = $this->xc->getXcGetConstants('TABLE_' . $stuTableName); + $foreach .= $this->xc->getXcEqualsOperator("\${$tableName}List[\$i]['rating']", "\$ratingsHandler->getItemRating({$itemId}, {$const})",'', $t . "\t\t"); + $foreach .= $this->xc->getXcEqualsOperator("\${$tableName}List[\$i]['rating_source']", "{$const}",'', $t . "\t\t"); + $foreach .= $this->xc->getXcEqualsOperator("\$token", "\$GLOBALS['xoopsSecurity']->createToken()",'', $t . "\t\t"); + $foreach .= $this->xc->getXcXoopsTplAssign('xoops_token', '$token', true, $t . "\t\t"); } $condIf .= $this->pc->getPhpCodeForeach("{$tableName}All", true, false, 'i', $foreach, $t . "\t"); $condIf .= $this->xc->getXcXoopsTplAssign($tableName . '_list', "\${$tableName}List", true, $t . "\t"); @@ -223,9 +222,18 @@ private function getUserPagesList($moduleDirname, $tableName, $fieldId, $fieldMa $condIf .= $this->pc->getPhpCodeConditions("'show' == \$op && '' != \${$ccFieldMain}", '', '', $condIf2, false, $t . "\t"); if ('' !== $fieldReads) { - $condIf3 = $this->xc->getXcHandlerGetObj($tableName, $ccFieldId, $t . "\t\t"); + $redirectError = $this->xc->getXcRedirectHeader($tableName, '', '3', "{$language}INVALID_PARAM", true, $t . "\t\t\t"); + $condIf3 = $this->pc->getPhpCodeConditions('0 === $' . $ccFieldId, '', '', $redirectError, false, $t . "\t\t"); + + $condIf3 .= $this->xc->getXcHandlerGetObj($tableName, $ccFieldId, $t . "\t\t"); $getVar = $this->xc->getXcGetVar('', "{$tableName}Obj", $fieldReads, true); + + $tablenameObj = $this->pc->getPhpCodeIsobject($tableName . 'Obj'); + $condIf3 .= $this->pc->getPhpCodeConditions('!' . $tablenameObj, '', '', $redirectError, false, $t . "\t\t"); + + + $condIf3 .= $this->xc->getXcEqualsOperator("\${$ccFieldReads}", '(int)' . $getVar . ' + 1', false, $t . "\t\t"); $condIf3 .= $this->xc->getXcSetVarObj($tableName, $fieldReads, "\${$ccFieldReads}", $t . "\t\t"); $condIf3 .= $this->pc->getPhpCodeCommentLine('Insert Data', null, $t . "\t\t"); @@ -253,7 +261,7 @@ private function getUserPagesList($moduleDirname, $tableName, $fieldId, $fieldMa * @param string $t * @return string */ - public function getUserPagesSave($moduleDirname, $fields, $tableName, $tableSoleName, $tablePermissions, $tableNotifications, $language, $t = '') + public function getUserPagesSave(string $moduleDirname, $fields, string $tableName, $tableSoleName, $tablePermissions, $tableNotifications, $language, string $t = '') { $ucfTableName = \ucfirst($tableName); $countUploader = 0; @@ -290,6 +298,7 @@ public function getUserPagesSave($moduleDirname, $fields, $tableName, $tableSole $implode = $this->pc->getPhpCodeImplode(',', $securityError); $redirectError = $this->xc->getXcRedirectHeader($tableName, '', '3', $implode, true, $t . "\t"); $ret .= $this->pc->getPhpCodeConditions('!' . $xoopsSecurityCheck, '', '', $redirectError, false, $t); + if (1 == $tablePermissions) { $ret .= $this->pc->getPhpCodeCommentLine('Check permissions', '', $t); $contIf = $this->xc->getXcRedirectHeader($tableName, '?op=list', 3, '\_NOPERM', true, $t . "\t"); @@ -298,6 +307,9 @@ public function getUserPagesSave($moduleDirname, $fields, $tableName, $tableSole $getObj = $this->xc->getXcHandlerGetObj($tableName, $ccFieldId, $t . "\t"); $createObj = $this->xc->getXcHandlerCreateObj($tableName, $t . "\t"); $ret .= $this->pc->getPhpCodeConditions("\${$ccFieldId}", ' > ', '0', $getObj, $createObj, $t); + $tablenameObj = $this->pc->getPhpCodeIsobject($tableName . 'Obj'); + $redirectError = $this->xc->getXcRedirectHeader($tableName, '', '3', "{$language}INVALID_PARAM", true, $t . "\t"); + $ret .= $this->pc->getPhpCodeConditions('!' . $tablenameObj, '', '', $redirectError, false, $t); $ret .= $this->xc->getXcSaveElements($moduleDirname, $tableName, $tableSoleName, $fields, $t); $ret .= $this->pc->getPhpCodeCommentLine('Insert Data', null, $t); $insert = $this->xc->getXcHandlerInsert($tableName, $tableName, 'Obj'); @@ -323,7 +335,10 @@ public function getUserPagesSave($moduleDirname, $fields, $tableName, $tableSole } $contentInsert .= $this->pc->getPhpCodeArray('tags', [], false, $t . "\t"); $contentInsert .= $this->xc->getXcEqualsOperator("\$tags['ITEM_NAME']", "\${$ccFieldMain}", '', $t . "\t"); - $url = "\XOOPS_URL . '/modules/{$moduleDirname}/{$tableName}.php?op=show&{$fieldId}=' . \${$ccFieldId}"; + $url = "\XOOPS_URL . '/modules/{$moduleDirname}/{$tableName}.php?op=show&{$fieldId}=' . \$new{$ucfFieldId}"; + + + $contentInsert .= $this->xc->getXcEqualsOperator("\$tags['ITEM_URL'] ", $url, '', $t . "\t"); $contentInsert .= $this->xc->getXcXoopsHandler('notification', $t . "\t"); if ('' === $fieldStatus) { @@ -345,17 +360,17 @@ public function getUserPagesSave($moduleDirname, $fields, $tableName, $tableSole $not2Else = $this->pc->getPhpCodeCommentLine('Event new notification', null, $t . "\t\t\t"); $not2Else .= $this->getSimpleString("\$notificationHandler->triggerEvent('global', 0, 'global_new', \$tags);", $t . "\t\t\t"); $not1Else = $this->pc->getPhpCodeConditions("\${$ccFieldId}", ' > ', '0', $not2If, $not2Else, $t . "\t\t"); - $contentInsert .= $this->pc->getPhpCodeConditions("\${$ccFieldStatus}", ' == ', $this->xc->getXcGetConstants('STATUS_SUBMITTED'), $not1If, $not1Else, $t . "\t"); + $contentInsert .= $this->pc->getPhpCodeConditions("\${$ccFieldStatus}", ' == ', $this->xc->getXcGetConstants('STATUS_APPROVED'), $not1If, $not1Else, $t . "\t"); } } $contentInsert .= $this->pc->getPhpCodeCommentLine('redirect after insert', null, $t . "\t"); if ($countUploader > 0) { $errIf = $this->xc->getXcRedirectHeader("'{$tableName}.php?op=edit&{$fieldId}=' . \$new{$ucfFieldId}", '', '5', '$uploaderErrors', false, $t . "\t\t"); - $errElse = $this->xc->getXcRedirectHeader("'{$tableName}.php?op=list&start=' . \$start . '&limit=' . \$limit", '', '2', "{$language}FORM_OK", false, $t . "\t\t"); + $errElse = $this->xc->getXcRedirectHeader("'{$tableName}.php?op=list&start=' . \$start . '&limit=' . \$limit", '', '2', "{$language}FORM_OK", false, $t . "\t\t"); $confirmOk = $this->pc->getPhpCodeConditions('$uploaderErrors', ' !== ', "''", $errIf, $errElse, $t . "\t"); } else { - $confirmOk = $this->xc->getXcRedirectHeader("'{$tableName}.php?op=list&start=' . \$start . '&limit=' . \$limit", '', '2', "{$language}FORM_OK", false, $t . "\t\t"); + $confirmOk = $this->xc->getXcRedirectHeader("'{$tableName}.php?op=list&start=' . \$start . '&limit=' . \$limit", '', '2', "{$language}FORM_OK", false, $t . "\t\t"); } $contentInsert .= $confirmOk; $ret .= $this->pc->getPhpCodeConditions($insert, '', '', $contentInsert, false, $t); @@ -376,7 +391,7 @@ public function getUserPagesSave($moduleDirname, $fields, $tableName, $tableSole * * @return string */ - private function getPermissionsSave($moduleDirname, $ucfFieldId, $perm = 'view') + private function getPermissionsSave($moduleDirname, $ucfFieldId, string $perm = 'view') { $ret = $this->pc->getPhpCodeCommentLine('Permission to', $perm, "\t\t\t"); $ret .= $this->xc->getXcDeleteRight('grouppermHandler', "{$moduleDirname}_{$perm}", '$mid', "\$new{$ucfFieldId}", false, "\t\t\t"); @@ -396,7 +411,7 @@ private function getPermissionsSave($moduleDirname, $ucfFieldId, $perm = 'view') * @param string $t * @return string */ - public function getUserPagesNew($tableName, $tableSoleName, $tablePermissions, $language, $t = '') + public function getUserPagesNew($tableName, $tableSoleName, $tablePermissions, $language, string $t = '') { $ret = $this->uxc->getUserBreadcrumbs($language, $tableSoleName, 'add', '', "\t\t"); if (1 == $tablePermissions) { @@ -419,7 +434,7 @@ public function getUserPagesNew($tableName, $tableSoleName, $tablePermissions, $ * @param string $t * @return string */ - public function getUserPagesEdit($tableName, $tableSoleName, $tablePermissions, $fieldId, $language, $t = '') + public function getUserPagesEdit($tableName, $tableSoleName, $tablePermissions, $fieldId, $language, string $t = '') { $ret = $this->uxc->getUserBreadcrumbs($language, $tableSoleName, 'edit', '', "\t\t"); $ccFieldId = $this->getCamelCase($fieldId, false, true); @@ -431,7 +446,7 @@ public function getUserPagesEdit($tableName, $tableSoleName, $tablePermissions, $ret .= $this->pc->getPhpCodeCommentLine('Check params', '', $t); $contIf = $this->xc->getXcRedirectHeader($tableName, '?op=list', 3, "{$language}INVALID_PARAM", true, $t . "\t"); $ret .= $this->pc->getPhpCodeConditions("\${$ccFieldId}", ' == ', '0', $contIf, false, $t); - $ret .= $this->xc->getXcCommonPagesEdit($tableName, $ccFieldId, $t); + $ret .= $this->xc->getXcCommonPagesEdit($tableName, $ccFieldId, $t, $language); return $ret; } @@ -446,7 +461,7 @@ public function getUserPagesEdit($tableName, $tableSoleName, $tablePermissions, * @param string $t * @return string */ - public function getUserPagesClone($tableName, $tableSoleName, $tablePermissions, $fieldId, $language, $t = '') + public function getUserPagesClone($tableName, $tableSoleName, $tablePermissions, $fieldId, $language, string $t = '') { $ret = $this->uxc->getUserBreadcrumbs($language, $tableSoleName, 'clone', '', "\t\t"); $ccFieldId = $this->getCamelCase($fieldId, false, true); @@ -460,7 +475,7 @@ public function getUserPagesClone($tableName, $tableSoleName, $tablePermissions, $ret .= $this->pc->getPhpCodeCommentLine('Check params', '', $t); $contIf = $this->xc->getXcRedirectHeader($tableName, '?op=list', 3, "{$language}INVALID_PARAM", true, $t . "\t"); $ret .= $this->pc->getPhpCodeConditions("\${$ccFieldId}Source", ' == ', '0', $contIf, false, $t); - $ret .= $this->xc->getXcCommonPagesClone($tableName, $ccFieldId, $t); + $ret .= $this->xc->getXcCommonPagesClone($tableName, $ccFieldId, $t, $language); return $ret; } @@ -477,7 +492,7 @@ public function getUserPagesClone($tableName, $tableSoleName, $tablePermissions, * @param string $t * @return string */ - private function getUserPagesDelete($tableName, $tableSoleName, $tablePermissions, $language, $fieldId, $fieldMain, $tableNotifications, $t = '') + private function getUserPagesDelete($tableName, $tableSoleName, $tablePermissions, $language, $fieldId, $fieldMain, $tableNotifications, string $t = '') { $ret = $this->uxc->getUserBreadcrumbs($language, $tableSoleName, 'delete', '', "\t\t"); $ccFieldId = $this->getCamelCase($fieldId, false, true); @@ -507,7 +522,7 @@ private function getUserPagesDelete($tableName, $tableSoleName, $tablePermission * @param string $t * @return string */ - private function getUserPagesBroken($language, $moduleDirname, $tableName, $tableSoleName, $fieldId, $fieldStatus, $fieldMain, $tableNotifications, $t = '') + private function getUserPagesBroken($language, $moduleDirname, $tableName, $tableSoleName, $fieldId, $fieldStatus, $fieldMain, $tableNotifications, string $t = '') { $ccFieldId = $this->getCamelCase($fieldId, false, true); $ccFieldMain = $this->getCamelCase($fieldMain, false, true); @@ -517,6 +532,9 @@ private function getUserPagesBroken($language, $moduleDirname, $tableName, $tabl $ret .= $this->pc->getPhpCodeConditions("\${$ccFieldId}", ' == ', '0', $contIf, false, $t); $ret .= $this->xc->getXcHandlerGet($tableName, $ccFieldId, 'Obj', $tableName . 'Handler', false, $t); + $tablenameObj = $this->pc->getPhpCodeIsobject($tableName . 'Obj'); + $redirectError = $this->xc->getXcRedirectHeader($tableName, '', '3', "{$language}INVALID_PARAM", true, $t . "\t"); + $ret .= $this->pc->getPhpCodeConditions('!' . $tablenameObj, '', '', $redirectError, false, $t); $ret .= $this->xc->getXcGetVar($ccFieldMain, "{$tableName}Obj", $fieldMain, false, $t); $reqOk = "_REQUEST['ok']"; $isset = $this->pc->getPhpCodeIsset($reqOk); @@ -540,7 +558,7 @@ private function getUserPagesBroken($language, $moduleDirname, $tableName, $tabl $contInsert .= $this->getSimpleString("\$notificationHandler->triggerEvent('global', 0, 'global_broken', \$tags);", $t . "\t\t"); $contInsert .= $this->getSimpleString("\$notificationHandler->triggerEvent('{$tableName}', \${$ccFieldId}, '{$tableSoleName}_broken', \$tags);", $t . "\t\t"); } - $contInsert .= $this->xc->getXcRedirectHeader("'{$tableName}.php?op=list&start=' . \$start . '&limit=' . \$limit", '', '2', "{$language}FORM_OK", false, $t . "\t\t"); + $contInsert .= $this->xc->getXcRedirectHeader("'{$tableName}.php?op=list&start=' . \$start . '&limit=' . \$limit", '', '2', "{$language}FORM_OK", false, $t . "\t\t"); $htmlErrors = $this->xc->getXcHtmlErrors($tableName, true); $internalElse = $this->xc->getXcXoopsTplAssign('error', $htmlErrors, true, $t . "\t\t"); $condition .= $this->pc->getPhpCodeConditions($insert, '', '', $contInsert, $internalElse, $t . "\t"); @@ -553,16 +571,12 @@ private function getUserPagesBroken($language, $moduleDirname, $tableName, $tabl /** * @private function getUserPagesFooter * @param $moduleDirname - * @param $tableName * @param $tableComments - * @param $language * * @return string */ - private function getUserPagesFooter($moduleDirname, $tableName, $tableComments, $language) + private function getUserPagesFooter($moduleDirname, $tableComments) { - $stuModuleDirname = \mb_strtoupper($moduleDirname); - $stuTableName = \mb_strtoupper($tableName); $ret = $this->pc->getPhpCodeBlankLine(); $ret .= $this->pc->getPhpCodeCommentLine('Meta keywords'); $ret .= $this->uxc->getUserMetaKeywords($moduleDirname); @@ -570,7 +584,7 @@ private function getUserPagesFooter($moduleDirname, $tableName, $tableComments, if (1 == $tableComments) { $ret .= $this->pc->getPhpCodeBlankLine(); $ret .= $this->pc->getPhpCodeCommentLine('View comments'); - $ret .= $this->pc->getPhpCodeIncludeDir('\XOOPS_ROOT_PATH', 'include/comment_view', true, false); + $ret .= $this->pc->getPhpCodeIncludeDir('\XOOPS_ROOT_PATH', 'include/comment_view', true); } $ret .= $this->pc->getPhpCodeBlankLine(); $ret .= $this->getRequire('footer'); @@ -595,32 +609,30 @@ private function getUserPagesFooter($moduleDirname, $tableName, $tableComments, * @param $tableRate * @param $fieldReads * @param $language - * @param $t * @return string */ - private function getUserPagesSwitch($moduleDirname, $tableId, $tableMid, $tableName, $tableSoleName, $tableSubmit, $tablePermissions, $tableBroken, $fieldId, $fieldMain, $fieldStatus, $tableNotifications, $tableRate, $fieldReads, $language, $t) + private function getUserPagesSwitch($moduleDirname, $tableId, $tableMid, $tableName, $tableSoleName, $tableSubmit, $tablePermissions, $tableBroken, $fieldId, $fieldMain, $fieldStatus, $tableNotifications, $tableRate, $fieldReads, $language) { $fields = $this->getTableFields($tableMid, $tableId); $cases['show'] = []; - $cases['list'] = [$this->getUserPagesList($moduleDirname, $tableName, $fieldId, $fieldMain, $tableRate, $fieldReads, $language,$t . "\t")]; + $cases['list'] = [$this->getUserPagesList($moduleDirname, $tableName, $fieldId, $fieldMain, $tableRate, $fieldReads, $language, "\t\t")]; if (1 == $tableSubmit) { - $cases['save'] = [$this->getUserPagesSave($moduleDirname, $fields, $tableName, $tableSoleName, $tablePermissions, $tableNotifications, $language, $t . "\t")]; - $cases['new'] = [$this->getUserPagesNew($tableName, $tableSoleName, $tablePermissions, $language, $t . "\t")]; - $cases['edit'] = [$this->getUserPagesEdit($tableName, $tableSoleName, $tablePermissions, $fieldId, $language, $t . "\t")]; - $cases['clone'] = [$this->getUserPagesClone($tableName, $tableSoleName, $tablePermissions, $fieldId, $language, $t . "\t")]; - $cases['delete'] = [$this->getUserPagesDelete($tableName, $tableSoleName, $tablePermissions, $language, $fieldId, $fieldMain, $tableNotifications,$t . "\t")]; + $cases['save'] = [$this->getUserPagesSave($moduleDirname, $fields, $tableName, $tableSoleName, $tablePermissions, $tableNotifications, $language, "\t\t")]; + $cases['new'] = [$this->getUserPagesNew($tableName, $tableSoleName, $tablePermissions, $language, "\t\t")]; + $cases['edit'] = [$this->getUserPagesEdit($tableName, $tableSoleName, $tablePermissions, $fieldId, $language, "\t\t")]; + $cases['clone'] = [$this->getUserPagesClone($tableName, $tableSoleName, $tablePermissions, $fieldId, $language, "\t\t")]; + $cases['delete'] = [$this->getUserPagesDelete($tableName, $tableSoleName, $tablePermissions, $language, $fieldId, $fieldMain, $tableNotifications, "\t\t")]; } if (1 == $tableBroken) { - $cases['broken'] = [$this->getUserPagesBroken($language, $moduleDirname, $tableName, $tableSoleName, $fieldId, $fieldStatus, $fieldMain, $tableNotifications, $t . "\t")]; + $cases['broken'] = [$this->getUserPagesBroken($language, $moduleDirname, $tableName, $tableSoleName, $fieldId, $fieldStatus, $fieldMain, $tableNotifications, "\t\t")]; } - return $this->xc->getXcSwitch('op', $cases, true, false); + return $this->xc->getXcSwitch('op', $cases, true); } /** * @public function render - * @param null - * @return bool|string + * @return string */ public function render() { @@ -663,8 +675,8 @@ public function render() } $content = $this->getHeaderFilesComments($module); $content .= $this->getUserPagesHeader($moduleDirname, $tableName, $fieldId, $tablePermissions, $language); - $content .= $this->getUserPagesSwitch($moduleDirname, $tableId, $tableMid, $tableName, $tableSoleName, $tableSubmit, $tablePermissions, $tableBroken, $fieldId, $fieldMain, $fieldStatus, $tableNotifications, $tableRate, $fieldReads, $language, "\t"); - $content .= $this->getUserPagesFooter($moduleDirname, $tableName, $tableComments, $language); + $content .= $this->getUserPagesSwitch($moduleDirname, $tableId, $tableMid, $tableName, $tableSoleName, $tableSubmit, $tablePermissions, $tableBroken, $fieldId, $fieldMain, $fieldStatus, $tableNotifications, $tableRate, $fieldReads, $language); + $content .= $this->getUserPagesFooter($moduleDirname, $tableComments); $this->create($moduleDirname, '/', $filename, $content, \_AM_MODULEBUILDER_FILE_CREATED, \_AM_MODULEBUILDER_FILE_NOTCREATED); diff --git a/class/Files/User/UserPdf.php b/class/Files/User/UserPdf.php index d3461fd9..edc5628a 100644 --- a/class/Files/User/UserPdf.php +++ b/class/Files/User/UserPdf.php @@ -3,7 +3,10 @@ namespace XoopsModules\Modulebuilder\Files\User; use XoopsModules\Modulebuilder; -use XoopsModules\Modulebuilder\Files; +use XoopsModules\Modulebuilder\{ + Files, + Constants +}; /* You may not change or alter any portion of this comment or credits @@ -34,31 +37,29 @@ class UserPdf extends Files\CreateFile /** * @var mixed */ - private $uxc = null; + private $xc = null; /** * @var mixed */ - private $xc = null; + private $pc = null; /** * @var mixed */ - private $pc = null; + private $cf = null; /** * @public function constructor - * @param null */ public function __construct() { parent::__construct(); $this->xc = Modulebuilder\Files\CreateXoopsCode::getInstance(); $this->pc = Modulebuilder\Files\CreatePhpCode::getInstance(); - $this->uxc = Modulebuilder\Files\User\UserXoopsCode::getInstance(); + $this->cf = Modulebuilder\Files\CreateFile::getInstance(); } /** * @static function getInstance - * @param null * @return UserPdf */ public static function getInstance() @@ -73,11 +74,11 @@ public static function getInstance() /** * @public function write - * @param string $module + * @param $module * @param mixed $table * @param string $filename */ - public function write($module, $table, $filename): void + public function write($module, $table, string $filename): void { $this->setModule($module); $this->setTable($table); @@ -94,29 +95,34 @@ public function write($module, $table, $filename): void */ private function getUserPdfHeader($moduleDirname, $tableName, $fields, $language) { - $fieldId = $this->xc->getXcSaveFieldId($fields); + $fieldId = $this->xc->getXcTableFieldId($fields); $ccFieldId = $this->getCamelCase($fieldId, false, true); $ret = $this->pc->getPhpCodeUseNamespace(['Xmf', 'Request'], '', ''); $ret .= $this->pc->getPhpCodeUseNamespace(['XoopsModules', $moduleDirname], '', ''); $ret .= $this->pc->getPhpCodeUseNamespace(['XoopsModules', $moduleDirname, 'Constants']); $ret .= $this->getRequire(); $ret .= $this->pc->getPhpCodeIncludeDir("\XOOPS_ROOT_PATH . '/header.php'", '', true, true); - $fileExist = $this->pc->getPhpCodeFileExists("\$tcpdf = \XOOPS_ROOT_PATH.'/Frameworks/tcpdf/'"); + $ret .= $this->xc->getXcEqualsOperator('$tcpdf', "\XOOPS_ROOT_PATH.'/Frameworks/tcpdf/'"); + $fileExist = $this->pc->getPhpCodeFileExists("\$tcpdf . 'tcpdf.php'"); $requireOnce = $this->pc->getPhpCodeIncludeDir("\$tcpdf . 'tcpdf.php'", '', true, true, 'require', "\t"); - $redirectHeader = $this->xc->getXcRedirectHeader($tableName, '', $numb = '2', "{$language}NO_PDF_LIBRARY", true, "\t"); + $redirectHeader = $this->xc->getXcRedirectHeader($tableName, '', '2', "{$language}NO_PDF_LIBRARY", true, "\t"); $ret .= $this->pc->getPhpCodeConditions($fileExist, '', '', $requireOnce, $redirectHeader); $ret .= $this->pc->getPhpCodeIncludeDir("\$tcpdf . 'config/tcpdf_config.php'", '', true, true); $ret .= $this->pc->getPhpCodeCommentLine('Get new template'); $ret .= $this->pc->getPhpCodeIncludeDir("\XOOPS_ROOT_PATH . '/class/template.php'", '', true, true); - $ret .= $this->xc->getXcEqualsOperator('$pdfTpl', 'new $xoopsTpl()'); + $ret .= $this->xc->getXcEqualsOperator('$pdfTpl', 'new \XoopsTpl()'); $ret .= $this->pc->getPhpCodeBlankLine(); $ret .= $this->pc->getPhpCodeCommentLine('Get requests'); $ret .= $this->xc->getXcXoopsRequest($ccFieldId, $fieldId, '', 'Int'); $ret .= $this->pc->getPhpCodeCommentLine('Get Instance of Handler'); $ret .= $this->xc->getXcHandlerLine($tableName); $ret .= $this->xc->getXcHandlerGetObj($tableName, $ccFieldId); + $tablenameObj = $this->pc->getPhpCodeIsobject($tableName . 'Obj'); + $redirectError = $this->xc->getXcRedirectHeader($tableName, '', '3', "{$language}INVALID_PARAM", true, "\t"); + $ret .= $this->pc->getPhpCodeConditions('!' . $tablenameObj, '', '', $redirectError); $ret .= $this->pc->getPhpCodeBlankLine(); $ret .= $this->xc->getXcEqualsOperator('$myts', 'MyTextSanitizer::getInstance()'); + $ret .= $this->cf->getSimpleString("\$pdfTpl->assign('wgtestmb_upload_url', \\" . strtoupper($moduleDirname) . '_UPLOAD_URL);'); $ret .= $this->pc->getPhpCodeBlankLine(); return $ret; @@ -133,60 +139,84 @@ private function getUserPdfHeader($moduleDirname, $tableName, $fields, $language public function getUserPdfTcpdf($moduleDirname, $tableName, $tableSolename, $fields) { $stuModuleDirname = \mb_strtoupper($moduleDirname); - $ret = $this->pc->getPhpCodeCommentLine('Set defaults'); + + $fieldId = $this->xc->getXcTableFieldId($fields); + $ccFieldId = $this->getCamelCase($fieldId, false, true); + $fieldMain = $this->xc->getXcTableFieldMain($fields); + + $ret = $this->pc->getPhpCodeCommentLine('Check permissions'); + $ret .= $this->getSimpleString('$currentuid = 0;'); + $condIf = $this->getSimpleString('$currentuid = $xoopsUser->uid();', "\t"); + $ret .= $this->pc->getPhpCodeConditions('isset($xoopsUser) && \is_object($xoopsUser)', '', '', $condIf); + $ret .= $this->xc->getXcXoopsHandler('groupperm'); + $ret .= $this->xc->getXcXoopsHandler('member'); + $condIf = $this->getSimpleString('$my_group_ids = [\XOOPS_GROUP_ANONYMOUS];', "\t"); + $condElse = $this->getSimpleString('$my_group_ids = $memberHandler->getGroupsByUser($currentuid);', "\t"); + $ret .= $this->pc->getPhpCodeConditions('0', ' === ', '$currentuid', $condIf, $condElse); + $gperm = $this->xc->getXcCheckRight('!$grouppermHandler', "{$moduleDirname}_view_{$tableName}", "\${$ccFieldId}", '$my_group_ids', "\$GLOBALS['xoopsModule']->getVar('mid')", true); + $ret .= $this->pc->getPhpCodeCommentLine('Verify permissions'); + $noPerm = $this->xc->getXcRedirectHeader("\\{$stuModuleDirname}_URL . '/index.php'", '', '3', '\_NOPERM', false, "\t"); + $noPerm .= $this->getSimpleString('exit();', "\t"); + $ret .= $this->pc->getPhpCodeConditions($gperm, '', '', $noPerm); + + $ret .= $this->pc->getPhpCodeCommentLine('Set defaults'); $ret .= $this->xc->getXcEqualsOperator('$pdfFilename', "'$tableName.pdf'"); - $ret .= $this->xc->getXcEqualsOperator('$title ', "'Pdf Title'"); - $ret .= $this->xc->getXcEqualsOperator('$subject ', "'Pdf Subject'"); $ret .= $this->xc->getXcEqualsOperator('$content ', "''"); $ret .= $this->pc->getPhpCodeBlankLine(); $ret .= $this->pc->getPhpCodeCommentLine('Read data from table and create pdfData'); + + $titleFound = false; foreach (\array_keys($fields) as $f) { $fieldName = $fields[$f]->getVar('field_name'); $fieldDefault = $fields[$f]->getVar('field_default'); $fieldElement = $fields[$f]->getVar('field_element'); $getVar = $this->xc->getXcGetVar('', $tableName . 'Obj', $fieldName, true); switch ($fieldElement) { - case 2: + case Constants::FIELD_ELE_TEXT: if (false !== mb_strpos($fieldName, 'title') || false !== mb_strpos($fieldName, 'name') && '' == $fieldDefault) { $ret .= $this->pc->getPhpCodeStripTags("pdfData['title'] ", $getVar); $ret .= $this->pc->getPhpCodeStripTags("pdfData['subject'] ", $getVar); + $titleFound = true; } break; - case 3: - case 4: - $ret .= $this->pc->getPhpCodeStripTags('content', $getVar); + case Constants::FIELD_ELE_TEXTAREA: + case Constants::FIELD_ELE_DHTMLTEXTAREA: + $ret .= $this->pc->getPhpCodeStripTags('content', $getVar, false, '', '.='); break; - case 8: + case Constants::FIELD_ELE_SELECTUSER: $ret .= $this->xc->getXcXoopsUserUnameFromId("pdfData['author'] ", $getVar); break; - case 15: + case Constants::FIELD_ELE_TEXTDATESELECT: $ret .= $this->xc->getXcFormatTimeStamp("pdfData['date'] ", $getVar); break; } } - $ret .= $this->pc->getPhpCodeStripTags("pdfData['title'] ", '$myts->undoHtmlSpecialChars($title)'); - $ret .= $this->pc->getPhpCodeStripTags("pdfData['subject'] ", '$subject'); + if (!$titleFound) { + $getVar = $this->xc->getXcGetVar('', $tableName . 'Obj', $fieldMain, true); + $ret .= $this->xc->getXcEqualsOperator("\$pdfData['title'] ", $getVar); + $ret .= $this->xc->getXcEqualsOperator("\$pdfData['subject'] ", $getVar); + } $ret .= $this->xc->getXcEqualsOperator("\$pdfData['content'] ", '$myts->undoHtmlSpecialChars($content)'); - $ret .= $this->xc->getXcEqualsOperator("\$pdfData['fontname']", 'PDF_FONT_NAME_MAIN'); - $ret .= $this->xc->getXcEqualsOperator("\$pdfData['fontsize']", 'PDF_FONT_SIZE_MAIN'); - $ret .= $this->pc->getPhpCodeBlankLine(); - $ret .= $this->pc->getPhpCodeCommentLine('Get Config'); - $ret .= $this->xc->getXcEqualsOperator("\$pdfData['creator'] ", "\$GLOBALS['xoopsConfig']['sitename']"); - $ret .= $this->xc->getXcEqualsOperator("\$pdfData['subject'] ", "\$GLOBALS['xoopsConfig']['slogan']"); - $ret .= $this->xc->getXcEqualsOperator("\$pdfData['keywords'] ", "\$helper->getConfig('keywords')"); - $ret .= $this->pc->getPhpCodeBlankLine(); - $ret .= $this->pc->getPhpCodeCommentLine('Defines'); - $ret .= $this->pc->getPhpCodeDefine("{$stuModuleDirname}_CREATOR", "\$pdfData['creator']"); - $ret .= $this->pc->getPhpCodeDefine("{$stuModuleDirname}_AUTHOR", "\$pdfData['author']"); - $ret .= $this->pc->getPhpCodeDefine("{$stuModuleDirname}_HEADER_TITLE", "\$pdfData['title']"); - $ret .= $this->pc->getPhpCodeDefine("{$stuModuleDirname}_HEADER_STRING", "\$pdfData['subject']"); - $ret .= $this->pc->getPhpCodeDefine("{$stuModuleDirname}_HEADER_LOGO", "'logo.gif'"); - $ret .= $this->pc->getPhpCodeDefine("{$stuModuleDirname}_IMAGES_PATH", "\XOOPS_ROOT_PATH.'/images/'"); - $ret .= $this->pc->getPhpCodeBlankLine(); - $ret .= $this->pc->getPhpCodeCommentLine('Assign customs tpl fields'); - $ret .= $this->xc->getXcXoopsTplAssign('content_header', "'$tableName'", true, '', 'pdfTpl'); - $ret .= $this->xc->getXcGetValues($tableName, $tableSolename, '', true, '', 'Obj'); - $ret .= $this->xc->getXcXoopsTplAssign($tableSolename, '$' .$tableSolename, true, '', 'pdfTpl'); + $ret .= $this->xc->getXcEqualsOperator("\$pdfData['fontname']", 'PDF_FONT_NAME_MAIN'); + $ret .= $this->xc->getXcEqualsOperator("\$pdfData['fontsize']", 'PDF_FONT_SIZE_MAIN'); + $ret .= $this->pc->getPhpCodeBlankLine(); + $ret .= $this->pc->getPhpCodeCommentLine('Get Config'); + $ret .= $this->xc->getXcEqualsOperator("\$pdfData['creator'] ", "\$GLOBALS['xoopsConfig']['sitename']"); + $ret .= $this->xc->getXcEqualsOperator("\$pdfData['subject'] ", "\$GLOBALS['xoopsConfig']['slogan']"); + $ret .= $this->xc->getXcEqualsOperator("\$pdfData['keywords'] ", "\$helper->getConfig('keywords')"); + $ret .= $this->pc->getPhpCodeBlankLine(); + $ret .= $this->pc->getPhpCodeCommentLine('Defines'); + $ret .= $this->pc->getPhpCodeDefine("{$stuModuleDirname}_CREATOR", "\$pdfData['creator']"); + $ret .= $this->pc->getPhpCodeDefine("{$stuModuleDirname}_AUTHOR", "\$pdfData['author']"); + $ret .= $this->pc->getPhpCodeDefine("{$stuModuleDirname}_HEADER_TITLE", "\$pdfData['title']"); + $ret .= $this->pc->getPhpCodeDefine("{$stuModuleDirname}_HEADER_STRING", "\$pdfData['subject']"); + $ret .= $this->pc->getPhpCodeDefine("{$stuModuleDirname}_HEADER_LOGO", "'logo.gif'"); + $ret .= $this->pc->getPhpCodeDefine("{$stuModuleDirname}_IMAGES_PATH", "\XOOPS_ROOT_PATH.'/images/'"); + $ret .= $this->pc->getPhpCodeBlankLine(); + $ret .= $this->pc->getPhpCodeCommentLine('Assign customs tpl fields'); + $ret .= $this->xc->getXcXoopsTplAssign('content_header', "'$tableName'", true, '', 'pdfTpl'); + $ret .= $this->xc->getXcGetValues($tableName, $tableSolename, '', true, '', 'Obj'); + $ret .= $this->xc->getXcXoopsTplAssign($tableSolename, '$' .$tableSolename, true, '', 'pdfTpl'); $ret .= $this->pc->getPhpCodeBlankLine(); $ret .= $this->pc->getPhpCodeCommentLine('Create pdf'); @@ -197,7 +227,7 @@ public function getUserPdfTcpdf($moduleDirname, $tableName, $tableSolename, $fie $ret .= $this->pc->getPhpCodeCommentLine('Set document information'); $ret .= $this->getSimpleString("\$pdf->SetCreator(\$pdfData['creator']);"); $ret .= $this->getSimpleString("\$pdf->SetAuthor(\$pdfData['author']);"); - $ret .= $this->getSimpleString('$pdf->SetTitle($title);'); + $ret .= $this->getSimpleString("\$pdf->SetTitle(\$pdfData['title']);"); $ret .= $this->getSimpleString("\$pdf->SetKeywords(\$pdfData['keywords']);"); $ret .= $this->pc->getPhpCodeCommentLine('Set default header data'); $ret .= $this->getSimpleString("\$pdf->setHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, {$stuModuleDirname}_HEADER_TITLE, {$stuModuleDirname}_HEADER_STRING);"); @@ -211,16 +241,17 @@ public function getUserPdfTcpdf($moduleDirname, $tableName, $tableSolename, $fie $ret .= $this->pc->getPhpCodeCommentLine('For chinese'); $ifLang = $this->getSimpleString("\$pdf->setHeaderFont(['gbsn00lp', '', \$pdfData['fontsize']]);", "\t"); $ifLang .= $this->getSimpleString("\$pdf->SetFont('gbsn00lp', '', \$pdfData['fontsize']);", "\t"); - $ifLang .= $this->getSimpleString("\$pdf->setFooterFont('gbsn00lp', '', \$pdfData['fontsize']]);", "\t"); - $elseLang = $this->getSimpleString("\$pdf->setHeaderFont(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN);", "\t"); + $ifLang .= $this->getSimpleString("\$pdf->setFooterFont(['gbsn00lp', '', \$pdfData['fontsize']]);", "\t"); + $elseLang = $this->getSimpleString("\$pdf->setHeaderFont([PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN]);", "\t"); $elseLang .= $this->getSimpleString("\$pdf->SetFont(\$pdfData['fontname'], '', \$pdfData['fontsize']);", "\t"); - $elseLang .= $this->getSimpleString("\$pdf->setFooterFont([PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA);", "\t"); + $elseLang .= $this->getSimpleString("\$pdf->setFooterFont([PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA]);", "\t"); $ret .= $this->pc->getPhpCodeConditions('_LANGCODE', ' == ', "'cn'", $ifLang, $elseLang); $ret .= $this->pc->getPhpCodeCommentLine('Set some language-dependent strings (optional)'); - $ret .= $this->xc->getXcEqualsOperator('$lang', "\XOOPS_ROOT_PATH.'/Frameworks/tcpdf/lang/eng.php'"); - $fileExist = $this->pc->getPhpCodeFileExists('$lang'); - $contIf = $this->pc->getPhpCodeIncludeDir('$lang', '', true, true, 'require', "\t"); - $contIf .= $this->getSimpleString('$pdf->setLanguageArray($lang);', "\t"); + $ret .= $this->xc->getXcEqualsOperator('$langFile', "\XOOPS_ROOT_PATH.'/Frameworks/tcpdf/lang/eng.php'"); + $fileExist = $this->pc->getPhpCodeFileExists('$langFile'); + $contIf = $this->pc->getPhpCodeIncludeDir('$langFile', '', true, true, 'require', "\t"); + $contIfInt = $this->getSimpleString('$pdf->setLanguageArray($l);', "\t\t"); + $contIf .= $this->pc->getPhpCodeConditions('isset($l) && \is_array($l)', '', '', $contIfInt, false, "\t"); $ret .= $this->pc->getPhpCodeConditions("@{$fileExist}", '', '', $contIf); return $ret; @@ -249,8 +280,7 @@ private function getUserPdfFooter($moduleDirname, $tableName) /** * @public function render - * @param null - * @return bool|string + * @return string */ public function render() { diff --git a/class/Files/User/UserPrint.php b/class/Files/User/UserPrint.php index 2ffd5655..65fb8622 100644 --- a/class/Files/User/UserPrint.php +++ b/class/Files/User/UserPrint.php @@ -31,10 +31,6 @@ */ class UserPrint extends Files\CreateFile { - /** - * @var mixed - */ - private $uxc = null; /** * @var mixed */ @@ -46,19 +42,16 @@ class UserPrint extends Files\CreateFile /** * @public function constructor - * @param null */ public function __construct() { parent::__construct(); $this->xc = Modulebuilder\Files\CreateXoopsCode::getInstance(); $this->pc = Modulebuilder\Files\CreatePhpCode::getInstance(); - $this->uxc = UserXoopsCode::getInstance(); } /** * @static function getInstance - * @param null * @return UserPrint */ public static function getInstance() @@ -73,11 +66,11 @@ public static function getInstance() /** * @public function write - * @param string $module + * @param $module * @param mixed $table * @param string $filename */ - public function write($module, $table, $filename): void + public function write($module, $table, string $filename): void { $this->setModule($module); $this->setTable($table); @@ -91,7 +84,7 @@ public function write($module, $table, $filename): void * * @return string */ - public function getUserPrint($moduleDirname, $language) + public function getUserPrint(string $moduleDirname, string $language) { $stuModuleDirname = \mb_strtoupper($moduleDirname); $table = $this->getTable(); @@ -124,11 +117,19 @@ public function getUserPrint($moduleDirname, $language) $ret .= $this->pc->getPhpCodeCommentLine('Define Stylesheet'); $ret .= $this->xc->getXcXoThemeAddStylesheet(); $redirectHeader = $this->xc->getXcRedirectHeader("\\{$stuModuleDirname}_URL . '/index.php'", '', '2', "{$language}INVALID_PARAM", false, "\t"); - $ret .= $this->pc->getPhpCodeConditions("empty(\${$ccFieldId})", '', '', $redirectHeader); + $ret .= $this->pc->getPhpCodeConditions("\${$ccFieldId}", ' == ', '0', $redirectHeader); $ret .= $this->pc->getPhpCodeCommentLine('Get Instance of Handler'); $ret .= $this->xc->getXcHandlerLine($tableName); + + $ret .= $this->getSimpleString('$currentuid = 0;'); + $condIf = $this->getSimpleString('$currentuid = $xoopsUser->uid();', "\t"); + $ret .= $this->pc->getPhpCodeConditions('isset($xoopsUser) && \is_object($xoopsUser)', '', '', $condIf); $ret .= $this->xc->getXcXoopsHandler('groupperm'); + $ret .= $this->xc->getXcXoopsHandler('member'); + $condIf = $this->getSimpleString('$my_group_ids = [\XOOPS_GROUP_ANONYMOUS];', "\t"); + $condElse = $this->getSimpleString('$my_group_ids = $memberHandler->getGroupsByUser($currentuid);', "\t"); + $ret .= $this->pc->getPhpCodeConditions('0', ' === ', '$currentuid', $condIf, $condElse); $ret .= $this->pc->getPhpCodeCommentLine('Verify that the article is published'); if (false !== mb_strpos($fieldName, 'published')) { @@ -151,28 +152,30 @@ public function getUserPrint($moduleDirname, $language) $redirectHeader .= $this->getSimpleString('exit();'); $ret .= $this->pc->getPhpCodeConditions("\${$tableName}Handler->getVar('{$fieldName}') != 0 && \${$tableName}Handler->getVar('{$fieldName}') < \time()", '', '', $redirectHeader); } - $ret .= $this->xc->getXcHandlerGet($tableName, $ccFieldId, '', $tableName . 'Handler',false); - $gperm = $this->xc->getXcCheckRight('!$grouppermHandler', "{$moduleDirname}_view", "\${$ccFieldId}->getVar('{$fieldId}')", '$groups', "\$GLOBALS['xoopsModule']->getVar('mid')", true); + $ret .= $this->xc->getXcHandlerGet($tableName . 'Obj', $ccFieldId, '', $tableName . 'Handler'); + $tablenameObj = $this->pc->getPhpCodeIsobject($tableName . 'Obj'); + $redirectError = $this->xc->getXcRedirectHeader($tableName, '', '3', "{$language}INVALID_PARAM", true, "\t"); + $ret .= $this->pc->getPhpCodeConditions('!' . $tablenameObj, '', '', $redirectError); + $gperm = $this->xc->getXcCheckRight('!$grouppermHandler', "{$moduleDirname}_view_{$tableName}", "\${$tableName}Obj->getVar('{$fieldId}')", '$my_group_ids', "\$GLOBALS['xoopsModule']->getVar('mid')", true); $ret .= $this->pc->getPhpCodeCommentLine('Verify permissions'); $noPerm = $this->xc->getXcRedirectHeader("\\{$stuModuleDirname}_URL . '/index.php'", '', '3', '\_NOPERM', false, "\t"); $noPerm .= $this->getSimpleString('exit();', "\t"); $ret .= $this->pc->getPhpCodeConditions($gperm, '', '', $noPerm); - $ret .= $this->xc->getXcGetValues($tableName, $tableSoleName . 'List', '', true); + $ret .= $this->xc->getXcGetValues($tableName, $tableSoleName . 'List', '', true, '', 'Obj'); $ret .= $this->xc->getXcXoopsTplAppend($tableName . '_list', '$' . $tableSoleName . 'List'); $ret .= $this->pc->getPhpCodeBlankLine(); $ret .= $this->xc->getXcXoopsTplAssign('xoops_sitename', "\$GLOBALS['xoopsConfig']['sitename']"); - $getVar = $this->xc->getXcGetVar('', $tableName, $fieldMain, true); + $getVar = $this->xc->getXcGetVar('', $tableName . 'Obj', $fieldMain, true); $stripTags = $this->pc->getPhpCodeStripTags('', $getVar . " . ' - ' . " . "{$language}PRINT" . " . ' - ' . " . "\$GLOBALS['xoopsModule']->getVar('name')", true); $ret .= $this->xc->getXcXoopsTplAssign('xoops_pagetitle', $stripTags); - $ret .= $this->xc->getXcXoopsTplDisplay($tableName . '_print.tpl', '', false); + $ret .= $this->xc->getXcXoopsTplDisplay($moduleDirname . '_' . $tableName . '_print.tpl', '', false); return $ret; } /** * @public function render - * @param null - * @return bool|string + * @return string */ public function render() { diff --git a/class/Files/User/UserRate.php b/class/Files/User/UserRate.php index 2eb27ff8..b9ad4e67 100644 --- a/class/Files/User/UserRate.php +++ b/class/Files/User/UserRate.php @@ -39,28 +39,21 @@ class UserRate extends Files\CreateFile * @var mixed */ private $pc = null; - /** - * @var mixed - */ - private $uxc = null; - + /** * @public function constructor * - * @param null */ public function __construct() { parent::__construct(); $this->xc = Modulebuilder\Files\CreateXoopsCode::getInstance(); $this->pc = Modulebuilder\Files\CreatePhpCode::getInstance(); - $this->uxc = UserXoopsCode::getInstance(); } /** * @static function getInstance * - * @param null * * @return UserRate */ @@ -76,11 +69,11 @@ public static function getInstance() /** * @public function write - * @param string $module + * @param $module * @param $tables * @param string $filename */ - public function write($module, $tables, $filename) + public function write($module, $tables, string $filename) { $this->setModule($module); $this->setTables($tables); @@ -109,14 +102,15 @@ public function getUserRateHeader($moduleDirname) * @private function getUserRateSwitch * @param $tables * @param $language + * @param $moduleDirname * @return string */ - private function getUserRateSwitch($tables, $language) + private function getUserRateSwitch($tables, $language, $moduleDirname) { $t = "\t\t"; $cases = [ 'list' => [$this->getUserRateDefault( $t)], - 'save' => [$this->getUserRateSave($tables, $language, $t)], + 'save' => [$this->getUserRateSave($tables, $language, $t, $moduleDirname)], ]; return $this->xc->getXcSwitch('op', $cases, true); @@ -127,7 +121,7 @@ private function getUserRateSwitch($tables, $language) * @param string $t * @return string */ - public function getUserRateDefault($t = '') + public function getUserRateDefault(string $t = '') { $ret = $this->pc->getPhpCodeCommentLine('default should not happen','', $t); $ret .= $this->xc->getXcRedirectHeader('index', '', '3', '\_NOPERM', true, $t); @@ -140,16 +134,17 @@ public function getUserRateDefault($t = '') * @param $tables * @param $language * @param $t + * @param $moduleDirname * @return string */ - public function getUserRateSave($tables, $language, $t) + public function getUserRateSave($tables, $language, $t, $moduleDirname) { $ret = $this->pc->getPhpCodeCommentLine('Security Check', '', $t); $xoopsSecurityCheck = $this->xc->getXcXoopsSecurityCheck(); $securityError = $this->xc->getXcXoopsSecurityErrors(); $implode = $this->pc->getPhpCodeImplode(',', $securityError); $redirectError = $this->xc->getXcRedirectHeader('index', '', '3', $implode, true, $t . "\t"); - $ret .= $this->pc->getPhpCodeConditions($xoopsSecurityCheck, '', '', $redirectError, false, $t); + $ret .= $this->pc->getPhpCodeConditions('!' . $xoopsSecurityCheck, '', '', $redirectError, false, $t); $ret .= $this->xc->getXcXoopsRequest('rating', 'rating', '', 'Int', false, $t); $ret .= $this->xc->getXcEqualsOperator('$itemid', '0','', $t); @@ -166,17 +161,19 @@ public function getUserRateSave($tables, $language, $t) } } $contIf = $this->xc->getXcXoopsRequest('itemid', $fieldId, '', 'Int', false, $t . "\t"); - $contIf .= $this->xc->getXcEqualsOperator('$redir', "'{$tableName}.php?op=show&{$fieldId}=' . \$itemid",'', $t . "\t"); + $contIf .= $this->xc->getXcEqualsOperator('$redir', "'{$tableName}.php?op=show&{$fieldId}=' . \$itemid",'', $t . "\t"); $const = $this->xc->getXcGetConstants('TABLE_' . $stuTableName); $ret .= $this->pc->getPhpCodeConditions('$source', ' === ', $const, $contIf, false, $t); } } + $redirectError = $this->xc->getXcRedirectHeader('$redir', '', '3', "{$language}INVALID_PARAM", false, $t . "\t"); + $ret .= $this->pc->getPhpCodeConditions('(int)$itemid', ' === ', '0', $redirectError, false, $t); $ret .= $this->pc->getPhpCodeBlankLine(); $ret .= $this->pc->getPhpCodeCommentLine('Check permissions', '', $t); $ret .= $this->xc->getXcEqualsOperator('$rate_allowed', 'false','', $t); $xUser = $this->pc->getPhpCodeGlobals('xoopsUser'); - $ret .= $this->pc->getPhpCodeTernaryOperator('groups', '(isset(' . $xUser . ') && \is_object(' . $xUser . '))', $xUser . '->getGroups()', '\XOOPS_GROUP_ANONYMOUS', "\t\t"); + $ret .= $this->pc->getPhpCodeTernaryOperator('groups', '(isset(' . $xUser . ') && \is_object(' . $xUser . '))', $xUser . '->getGroups()', '[\XOOPS_GROUP_ANONYMOUS]', "\t\t"); $contIf = $this->xc->getXcEqualsOperator('$rate_allowed', 'true','', $t . "\t\t"); $contIf .= $this->getSimpleString('break;', $t . "\t\t"); $cond = '\XOOPS_GROUP_ADMIN == $group || \in_array($group, $helper->getConfig(\'ratingbar_groups\'))'; @@ -195,7 +192,7 @@ public function getUserRateSave($tables, $language, $t) $contIf = $this->xc->getXcRedirectHeader('index', '', '3', $language . 'RATING_VOTE_BAD', true, $t . "\t\t\t"); $contIf .= $this->getSimpleString('exit;', $t . "\t\t\t"); $const = $this->xc->getXcGetConstants('RATING_LIKES'); - $cases[$const] = [$this->pc->getPhpCodeConditions('$rating > 1 || $rating < -1', '', '', $contIf, false, $t . "\t\t")]; + $cases[$const] = [$this->pc->getPhpCodeConditions('!\in_array($rating, [-1, 1], true)', '', '', $contIf, false, $t . "\t\t")]; $const = $this->xc->getXcGetConstants('RATING_5STARS'); $cases[$const] = [$this->pc->getPhpCodeConditions('$rating > 5 || $rating < 1', '', '', $contIf, false, $t . "\t\t")]; $const = $this->xc->getXcGetConstants('RATING_10STARS'); @@ -227,38 +224,41 @@ public function getUserRateSave($tables, $language, $t) $contIf = $this->pc->getPhpCodeUnset('ratingsObj', $t . "\t"); $contIf .= $this->pc->getPhpCodeCommentLine('Calc average rating value', null, $t . "\t"); - $contIf .= $this->xc->getXcEqualsOperator('$nb_ratings ', '0','', $t . "\t"); - $contIf .= $this->xc->getXcEqualsOperator('$avg_rate_value', '0','', $t . "\t"); - $contIf .= $this->xc->getXcEqualsOperator('$current_rating', '0','', $t . "\t"); - $tableName = 'ratings'; - $ucfTableName = \ucfirst($tableName); - $critName = 'cr' . $ucfTableName; - $contIf .= $this->xc->getXcCriteriaCompo($critName, $t . "\t"); - $crit = $this->xc->getXcCriteria('', "'rate_source'", '$source','',true); - $contIf .= $this->xc->getXcCriteriaAdd($critName, $crit, $t . "\t"); - $crit = $this->xc->getXcCriteria('', "'rate_itemid'", '$itemid','',true); - $contIf .= $this->xc->getXcCriteriaAdd($critName, $crit, $t . "\t"); - $contIf .= $this->xc->getXcHandlerCountClear($tableName . 'Count', $tableName, '$' . $critName, $t . "\t"); - $contIf .= $this->xc->getXcHandlerAllClear($tableName . 'All', $tableName, '$' . $critName, $t . "\t"); - $contFe = $this->xc->getXcEqualsOperator('$current_rating', "\$ratingsAll[\$i]->getVar('rate_value')",'+', $t . "\t\t"); - $contIf .= $this->pc->getPhpCodeForeach("{$tableName}All", true, false, 'i', $contFe, $t . "\t"); - $contIf .= $this->pc->getPhpCodeUnset($tableName . 'All', $t . "\t"); - $contIfInt = $this->xc->getXcEqualsOperator('$avg_rate_value', 'number_format($current_rating / $ratingsCount, 2)','', $t . "\t\t"); - $contIf .= $this->pc->getPhpCodeConditions('$ratingsCount', ' > ', '0', $contIfInt, false, $t . "\t"); - - $contIf .= $this->pc->getPhpCodeCommentLine('Update related table', null, $t . "\t"); foreach ($tables as $table) { $tableName = $table->getVar('table_name'); - $tableFieldName = $table->getVar('table_fieldname'); $stuTableName = \mb_strtoupper($tableName); if (1 == $table->getVar('table_rate')) { - //$contIfInt = $this->xc->getXcEqualsOperator('$tableName', "'{$tableName}'",'', $t . "\t\t"); - //$contIfInt .= $this->xc->getXcEqualsOperator('$fieldRatings', "'{$tableFieldName}_ratings'",'', $t . "\t\t"); - //$contIfInt .= $this->xc->getXcEqualsOperator('$fieldVotes ', "'{$tableFieldName}_votes'",'', $t . "\t\t"); - $contIfInt = $this->xc->getXcHandlerGetObj($tableName, 'itemid', $t . "\t\t"); - $contIfInt .= $this->xc->getXcSetVarObj($tableName, "{$tableFieldName}_ratings", '$avg_rate_value', $t . "\t\t"); - $contIfInt .= $this->xc->getXcSetVarObj($tableName, "{$tableFieldName}_votes", '$ratingsCount', $t . "\t\t"); - $insertInt = $this->xc->getXcHandlerInsert($tableName, $tableName, 'Obj'); + $fields = $this->getTableFields($table->getVar('table_mid'), $table->getVar('table_id')); + $fieldId = ''; + $fieldRatings = ''; + $fieldVotes = ''; + foreach (\array_keys($fields) as $f) { + if (0 == $f) { + $fieldId = $fields[$f]->getVar('field_name'); + } + $fieldElement = $fields[$f]->getVar('field_element'); + if($fieldElement == Modulebuilder\Constants::FIELD_ELE_TEXTRATINGS) { + $fieldRatings = $fields[$f]->getVar('field_name'); + } + if($fieldElement == Modulebuilder\Constants::FIELD_ELE_TEXTVOTES) { + $fieldVotes = $fields[$f]->getVar('field_name'); + } + } + $sql = $this->getSimpleString("\$sql = '", $t . "\t\t"); + $sql .= $this->getSimpleString("UPDATE ' . \$GLOBALS['xoopsDB']->prefix('" . $moduleDirname . '_' . $tableName . "') . ' t", $t . "\t\t\t"); + $sql .= $this->getSimpleString('LEFT JOIN (', $t . "\t\t\t"); + $sql .= $this->getSimpleString('SELECT', $t . "\t\t\t\t"); + $sql .= $this->getSimpleString('rate_itemid, rate_source, COUNT(*) AS votes, ROUND(AVG(rate_value), 2) AS avg_rating', $t . "\t\t\t\t\t"); + $sql .= $this->getSimpleString("FROM ' . \$GLOBALS['xoopsDB']->prefix('{$moduleDirname}_ratings') . '", $t . "\t\t\t\t"); + $sql .= $this->getSimpleString('GROUP BY rate_itemid, rate_source', $t . "\t\t\t\t"); + $sql .= $this->getSimpleString(") r ON r.rate_itemid = t." . $fieldId . " and r.rate_source = ' . \$source . '", $t . "\t\t\t"); + $sql .= $this->getSimpleString('SET', $t . "\t\t\t"); + $sql .= $this->getSimpleString('t.' . $fieldVotes . ' = COALESCE(r.votes, 0),', $t . "\t\t\t\t"); + $sql .= $this->getSimpleString('t.' . $fieldRatings . ' = COALESCE(r.avg_rating, 0),', $t . "\t\t\t\t"); + $sql .= $this->getSimpleString("WHERE t." . $fieldId . " = ' . \$itemid;", $t . "\t\t\t"); + $contIfInt = $sql; + + $insertInt = "\$GLOBALS['xoopsDB']->queryF(\$sql)"; $insertOK = $this->xc->getXcRedirectHeader('$redir', '', '2', "{$language}RATING_VOTE_THANKS", false, $t . "\t\t\t"); $insertErr = $this->xc->getXcRedirectHeader($tableName, '', '3', "{$language}RATING_ERROR1", true, $t . "\t\t\t"); @@ -270,7 +270,7 @@ public function getUserRateSave($tables, $language, $t) } $contIf .= $this->pc->getPhpCodeBlankLine(); - $contIf .= $this->xc->getXcRedirectHeader('index', '', '2', "{$language}RATING_VOTE_THANKS", true, $t . "\t"); + $contIf .= $this->xc->getXcRedirectHeader('index', '', '2', "{$language}INVALID_PARAM", true, $t . "\t"); $ret .= $this->pc->getPhpCodeConditions($insert, '', '', $contIf, false, $t); $ret .= $this->pc->getPhpCodeCommentLine('Get Error', null, $t); @@ -290,8 +290,7 @@ public function getUserRateFooter() /** * @public function render - * @param null - * @return bool|string + * @return string */ public function render() { @@ -302,7 +301,7 @@ public function render() $language = $this->getLanguage($moduleDirname, 'MA'); $content = $this->getHeaderFilesComments($module); $content .= $this->getUserRateHeader($moduleDirname); - $content .= $this->getUserRateSwitch($tables, $language); + $content .= $this->getUserRateSwitch($tables, $language, $moduleDirname); $content .= $this->getUserRateFooter(); $this->create($moduleDirname, '/', $filename, $content, \_AM_MODULEBUILDER_FILE_CREATED, \_AM_MODULEBUILDER_FILE_NOTCREATED); diff --git a/class/Files/User/UserRss.php b/class/Files/User/UserRss.php index 4643fa54..14a32bad 100644 --- a/class/Files/User/UserRss.php +++ b/class/Files/User/UserRss.php @@ -31,14 +31,6 @@ */ class UserRss extends Files\CreateFile { - /** - * @var mixed - */ - private $uxc = null; - /** - * @var mixed - */ - private $xc = null; /** * @var mixed */ @@ -46,19 +38,15 @@ class UserRss extends Files\CreateFile /** * @public function constructor - * @param null */ public function __construct() { parent::__construct(); - $this->xc = Modulebuilder\Files\CreateXoopsCode::getInstance(); $this->pc = Modulebuilder\Files\CreatePhpCode::getInstance(); - $this->uxc = UserXoopsCode::getInstance(); } /** * @static function getInstance - * @param null * @return UserRss */ public static function getInstance() @@ -73,11 +61,11 @@ public static function getInstance() /** * @public function write - * @param string $module + * @param $module * @param mixed $table * @param string $filename */ - public function write($module, $table, $filename): void + public function write($module, $table, string $filename): void { $this->setModule($module); $this->setTable($table); @@ -89,7 +77,7 @@ public function write($module, $table, $filename): void * @param string $moduleDirname * @return string */ - public function getUserRss($moduleDirname) + public function getUserRss(string $moduleDirname) { $table = $this->getTable(); $tableName = $table->getVar('table_name'); @@ -153,11 +141,11 @@ public function getUserRss($moduleDirname) \$tpl->assign('channel_title', \htmlspecialchars(\$title, ENT_QUOTES)); \$tpl->assign('channel_link', \XOOPS_URL.'/'); \$tpl->assign('channel_desc', \htmlspecialchars(\$xoopsConfig['slogan'], ENT_QUOTES)); - \$tpl->assign('channel_lastbuild', \\formatTimestamp(\time(), 'rss')); + \$tpl->assign('channel_lastbuild', \\formatTimestamp(\\time(), 'rss')); \$tpl->assign('channel_webmaster', \$xoopsConfig['adminmail']); \$tpl->assign('channel_editor', \$xoopsConfig['adminmail']); \$tpl->assign('channel_category', 'Event'); - \$tpl->assign('channel_generator', 'XOOPS - ' . \htmlspecialchars(\$xoopsModule->getVar('{$fpmf}'), ENT_QUOTES)); + \$tpl->assign('channel_generator', 'XOOPS - ' . \htmlspecialchars(\$xoopsModule->getVar('name'), ENT_QUOTES)); \$tpl->assign('channel_language', _LANGCODE); if ( 'fr' == _LANGCODE ) { \$tpl->assign('docs', 'https://www.scriptol.fr/rss/RSS-2.0.html'); @@ -165,16 +153,17 @@ public function getUserRss($moduleDirname) \$tpl->assign('docs', 'https://cyber.law.harvard.edu/rss/rss.html'); } \$tpl->assign('image_url', \XOOPS_URL . \$xoopsModuleConfig['logorss']); - \$dimention = \getimagesize(\XOOPS_ROOT_PATH . \$xoopsModuleConfig['logorss']); - if (empty(\$dimention[0])) { - \$width = 88; - } else { - \$width = (\$dimention[0] > 144) ? 144 : \$dimention[0]; - } - if (empty(\$dimention[1])) { - \$height = 31; - } else { - \$height = (\$dimention[1] > 400) ? 400 : \$dimention[1]; + \$logoPath = \XOOPS_ROOT_PATH . \$xoopsModuleConfig['logorss']; + \$width = 88; + \$height = 31; + if (\\file_exists(\$logoPath)) { + \$dimension = \getimagesize(\$logoPath); + if (!empty(\$dimension[0])) { + \$width = (\$dimension[0] > 144) ? 144 : \$dimension[0]; + } + if (!empty(\$dimension[1])) { + \$height = (\$dimension[1] > 400) ? 400 : \$dimension[1]; + } } \$tpl->assign('image_width', \$width); \$tpl->assign('image_height', \$height); @@ -187,8 +176,8 @@ public function getUserRss($moduleDirname) \$description_short = \substr(\$description,0,\strpos(\$description,'[pagebreak]')); } \$tpl->append('items', ['title' => \htmlspecialchars(\${$tableName}Arr[\$i]->getVar('{$fpmf}'), ENT_QUOTES), - 'link' => \XOOPS_URL . '/modules/{$moduleDirname}/single.php?{$fppf}=' . \${$tableName}Arr[\$i]->getVar('{$fppf}') . '&{$fieldId}=' . \${$tableName}Arr[\$i]->getVar('{$fieldId}'), - 'guid' => \XOOPS_URL . '/modules/{$moduleDirname}/single.php?{$fppf}=' . \${$tableName}Arr[\$i]->getVar('{$fppf}') . '&{$fieldId}=' . \${$tableName}Arr[\$i]->getVar('{$fieldId}'), + 'link' => \XOOPS_URL . '/modules/{$moduleDirname}/single.php?{$fppf}=' . \${$tableName}Arr[\$i]->getVar('{$fppf}') . '&{$fieldId}=' . \${$tableName}Arr[\$i]->getVar('{$fieldId}'), + 'guid' => \XOOPS_URL . '/modules/{$moduleDirname}/single.php?{$fppf}=' . \${$tableName}Arr[\$i]->getVar('{$fppf}') . '&{$fieldId}=' . \${$tableName}Arr[\$i]->getVar('{$fieldId}'), 'pubdate' => \\formatTimestamp(\${$tableName}Arr[\$i]->getVar('date'), 'rss'), 'description' => \htmlspecialchars(\$description_short, ENT_QUOTES) ]); @@ -204,8 +193,7 @@ public function getUserRss($moduleDirname) /** * @public function render - * @param null - * @return bool|string + * @return string */ public function render() { diff --git a/class/Files/User/UserSearch.php b/class/Files/User/UserSearch.php index d8963199..913bd9d4 100644 --- a/class/Files/User/UserSearch.php +++ b/class/Files/User/UserSearch.php @@ -46,7 +46,6 @@ class UserSearch extends Files\CreateFile /** * @public function constructor - * @param null */ public function __construct() { @@ -58,7 +57,6 @@ public function __construct() /** * @static function getInstance - * @param null * @return UserSearch */ public static function getInstance() @@ -73,11 +71,11 @@ public static function getInstance() /** * @public function write - * @param string $module + * @param $module * @param mixed $table * @param string $filename */ - public function write($module, $table, $filename) + public function write($module, $table, string $filename) { $this->setModule($module); $this->setTable($table); @@ -130,12 +128,10 @@ private function getUserSearchHeader($moduleDirname, $table, $fields) */ public function getUserSearch() { - $ret = <<<'EOT' + /*$ret = <<<'EOT' -EOT; - $ret .= $this->getSimpleString('$keywords = [];'); - - return $ret; +EOT;*/ + return $this->getSimpleString('$keywords = [];'); } /** @@ -149,7 +145,6 @@ public function getUserSearch() */ private function getUserSearchFooter($moduleDirname, $tableName, $language) { - $stuModuleDirname = \mb_strtoupper($moduleDirname); $stuTableName = \mb_strtoupper($tableName); $ret = $this->getDashComment('Breadcrumbs'); $ret .= $this->uxc->getUserBreadcrumbs((string)$stuTableName, $language); @@ -163,8 +158,7 @@ private function getUserSearchFooter($moduleDirname, $tableName, $language) /** * @public function render - * @param null - * @return bool|string + * @return string */ public function render() { diff --git a/class/Files/User/UserViewTag.php b/class/Files/User/UserViewTag.php index 4ecefb3c..2a6fce3c 100644 --- a/class/Files/User/UserViewTag.php +++ b/class/Files/User/UserViewTag.php @@ -38,7 +38,6 @@ class UserViewTag extends Files\CreateFile /** * @public function constructor - * @param null */ public function __construct() { @@ -48,7 +47,6 @@ public function __construct() /** * @static function getInstance - * @param null * @return UserViewTag */ public static function getInstance() @@ -63,10 +61,10 @@ public static function getInstance() /** * @public function write - * @param string $module + * @param $module * @param string $filename */ - public function write($module, $filename): void + public function write($module, string $filename): void { $this->setModule($module); $this->setFileName($filename); @@ -74,7 +72,6 @@ public function write($module, $filename): void /** * @public function getUserViewTag - * @param null * @return string */ public function getUserViewTag() @@ -87,8 +84,7 @@ public function getUserViewTag() /** * @public function render - * @param null - * @return bool|string + * @return string */ public function render() { diff --git a/class/Files/User/UserXoopsCode.php b/class/Files/User/UserXoopsCode.php index 1a9cffd9..00cfa5df 100644 --- a/class/Files/User/UserXoopsCode.php +++ b/class/Files/User/UserXoopsCode.php @@ -41,7 +41,6 @@ class UserXoopsCode /** * @public function constructor - * @param null */ public function __construct() { @@ -75,7 +74,7 @@ public static function getInstance() * * @return string */ - public function getUserTplMain($moduleDirname, $tableName = 'index') + public function getUserTplMain($moduleDirname, string $tableName = 'index') { return "\$GLOBALS['xoopsOption']['template_main'] = '{$moduleDirname}_{$tableName}.tpl';\n"; } @@ -90,7 +89,7 @@ public function getUserTplMain($moduleDirname, $tableName = 'index') * @param string $t * @return string */ - public function getUserAddMeta($type, $language, $tableName, $t = '') + public function getUserAddMeta(string $type, $language, $tableName, string $t = '') { $stuTableName = \mb_strtoupper($tableName); $stripTags = $this->pc->getPhpCodeStripTags('', $language . $stuTableName, true); @@ -115,13 +114,11 @@ public function getUserMetaKeywords($moduleDirname) /** * @public function getUserMetaDesc * - * @param $moduleDirname - * @param $language - * @param string $file + * @param string $moduleDirname * * @return string */ - public function getUserMetaDesc($moduleDirname, $language, $file = 'INDEX') + public function getUserMetaDesc(string $moduleDirname) { return $moduleDirname. 'MetaDescription((string)$helper->' . "getConfig('metadescription'));\n"; } @@ -137,7 +134,7 @@ public function getUserMetaDesc($moduleDirname, $language, $file = 'INDEX') * * @return string */ - public function getUserBreadcrumbs($language, $tableName = 'index', $op = '', $link = '', $t = '') + public function getUserBreadcrumbs($language, string $tableName = 'index', string $op = '', string $link = '', string $t = '') { $stuTableName = \mb_strtoupper($tableName); $stuOp = ''; @@ -167,24 +164,22 @@ public function getUserBreadcrumbs($language, $tableName = 'index', $op = '', $l public function getUserBreadcrumbsFooterFile() { $cond = $this->xc->getXcXoopsTplAssign('xoBreadcrumbs', '$xoBreadcrumbs'); - $ret = $this->pc->getPhpCodeConditions('\count($xoBreadcrumbs)', ' > ', '1', $cond, false, "\t\t"); - - return $ret; + return $this->pc->getPhpCodeConditions('\count($xoBreadcrumbs)', ' > ', '1', $cond, false, "\t\t"); } /** * @public function getUserModVersionArray * - * @param int $eleArray + * @param int $eleArray * @param string|array $descriptions - * @param null $name - * @param null $index - * @param bool $num - * @param string $t + * @param null $name + * @param null $index + * @param null $num + * @param string $t * * @return string */ - public function getUserModVersionArray($eleArray, $descriptions, $name = null, $index = null, $num = false, $t = '') + public function getUserModVersionArray(int $eleArray, $descriptions, $name = null, $index = null, $num = null, string $t = '') { $ret = $t . '$modversion'; $isArray = false; @@ -241,16 +236,16 @@ public function getUserModVersionArray($eleArray, $descriptions, $name = null, $ /** * @public function getUserModVersionText * - * @param int $eleArray + * @param int $eleArray * @param $text * @param null $name * @param null $index - * @param bool $num + * @param null $num * @param string $t * * @return string */ - public function getUserModVersionText($eleArray, $text, $name = null, $index = null, $num = false, $t = '') + public function getUserModVersionText(int $eleArray, $text, $name = null, $index = null, $num = null, string $t = '') { $ret = $t . '$modversion'; diff --git a/class/Files/User/UserXoopsVersion.php b/class/Files/User/UserXoopsVersion.php index 53671d25..f590aa7d 100644 --- a/class/Files/User/UserXoopsVersion.php +++ b/class/Files/User/UserXoopsVersion.php @@ -50,7 +50,6 @@ class UserXoopsVersion extends Files\CreateFile /** * @public function constructor - * @param null */ public function __construct() { @@ -62,7 +61,6 @@ public function __construct() /** * @static function getInstance - * @param null * @return UserXoopsVersion */ public static function getInstance() @@ -109,7 +107,6 @@ public function setKeywords($keywords): void /** * @public function getKeywords - * @param null * @return array */ public function getKeywords() @@ -141,7 +138,7 @@ private function getXoopsVersionHeader($module, $language) $descriptions = [ 'name' => "{$language}NAME", - 'version' => "'" . (string)$module->getVar('mod_version') . "'", + 'version' => "'" . $module->getVar('mod_version') . "'", 'description' => "{$language}DESC", 'author' => "'{$module->getVar('mod_author')}'", 'author_mail' => "'{$module->getVar('mod_author_mail')}'", @@ -319,25 +316,25 @@ private function getXoopsVersionTemplatesAdminUser($moduleDirname, $tables, $adm $item[] = $this->pc->getPhpCodeCommentLine('User templates'); $item[] = $this->getXoopsVersionTemplatesLine($moduleDirname, 'header'); $item[] = $this->getXoopsVersionTemplatesLine($moduleDirname, 'index'); - $tableBroken = []; + //$tableBroken = []; $tablePdf = []; $tablePrint = []; $tableRate = []; $tableRss = []; $tableSearch = []; $tableSingle = []; - $tableSubmit = []; + //$tableSubmit = []; foreach (\array_keys($tables) as $t) { if (1 == $tables[$t]->getVar('table_user')) { $tableName = $tables[$t]->getVar('table_name'); - $tableBroken[] = $tables[$t]->getVar('table_broken'); + //$tableBroken[] = $tables[$t]->getVar('table_broken'); $tablePdf[] = $tables[$t]->getVar('table_pdf'); $tablePrint[] = $tables[$t]->getVar('table_print'); $tableRate[] = $tables[$t]->getVar('table_rate'); $tableRss[] = $tables[$t]->getVar('table_rss'); $tableSearch[] = $tables[$t]->getVar('table_search'); $tableSingle[] = $tables[$t]->getVar('table_single'); - $tableSubmit[] = $tables[$t]->getVar('table_submit'); + //$tableSubmit[] = $tables[$t]->getVar('table_submit'); $tableRate[] = $tables[$t]->getVar('table_rate'); $item[] = $this->getXoopsVersionTemplatesLine($moduleDirname, $tableName); $item[] = $this->getXoopsVersionTemplatesLine($moduleDirname, $tableName, 'list'); @@ -383,13 +380,13 @@ private function getXoopsVersionTemplatesAdminUser($moduleDirname, $tables, $adm /** * @private function getXoopsVersionTemplatesLine - * @param $moduleDirname - * @param $type + * @param string $moduleDirname + * @param string $type * @param string $extra - * @param bool $isAdmin + * @param bool $isAdmin * @return string */ - private function getXoopsVersionTemplatesLine($moduleDirname, $type, $extra = '', $isAdmin = false) + private function getXoopsVersionTemplatesLine(string $moduleDirname, string $type, string $extra = '', bool $isAdmin = false) { $ret = ''; $desc = "'description' => ''"; @@ -429,10 +426,10 @@ private function getXoopsVersionSubmenu($language, $tables) $contentIf = $this->uxc->getUserModVersionArray(2, $descriptions, 'sub', '','', "\t"); ++$i; - $tableSearch = []; + //$tableSearch = []; foreach (\array_keys($tables) as $t) { $tableName = $tables[$t]->getVar('table_name'); - $tableSearch[] = $tables[$t]->getVar('table_search'); + //$tableSearch[] = $tables[$t]->getVar('table_search'); if (1 == $tables[$t]->getVar('table_submenu')) { $contentIf .= $this->pc->getPhpCodeCommentLine('Sub', $tableName, "\t"); $descriptions = [ @@ -496,7 +493,7 @@ private function getXoopsVersionBlocks($moduleDirname, $tables, $language) foreach (\array_keys($tables) as $i) { $tableName = $tables[$i]->getVar('table_name'); if (0 == $tables[$i]->getVar('table_category') && 1 == $tables[$i]->getVar('table_blocks')) { - $ret .= $this->getXoopsVersionSpotlightBlocks($moduleDirname, $tableName, $language, 'spotlight'); + $ret .= $this->getXoopsVersionSpotlightBlocks($moduleDirname, $tableName, $language); } } @@ -536,14 +533,13 @@ private function getXoopsVersionTypeBlocks($moduleDirname, $tableName, $stuTable * @param $moduleDirname * @param $tableName * @param $language - * @param $type * @return string */ - private function getXoopsVersionSpotlightBlocks($moduleDirname, $tableName, $language, $type) + private function getXoopsVersionSpotlightBlocks($moduleDirname, $tableName, $language) { $stuTableName = \mb_strtoupper($tableName); $ucfTableName = \ucfirst($tableName); - $ret = $this->pc->getPhpCodeCommentLine($ucfTableName . ' ' . $type); + $ret = $this->pc->getPhpCodeCommentLine($ucfTableName . ' spotlight'); $blocks = [ 'file' => "'{$tableName}_spotlight.php'", 'name' => "{$language}{$stuTableName}_BLOCK_SPOTLIGHT", @@ -551,7 +547,7 @@ private function getXoopsVersionSpotlightBlocks($moduleDirname, $tableName, $lan 'show_func' => "'b_{$moduleDirname}_{$tableName}_spotlight_show'", 'edit_func' => "'b_{$moduleDirname}_{$tableName}_spotlight_edit'", 'template' => "'{$moduleDirname}_block_{$tableName}_spotlight.tpl'", - 'options' => "'{$type}|5|25|0'", + 'options' => "'spotlight|5|25|0'", ]; $ret .= $this->uxc->getUserModVersionArray(2, $blocks, 'blocks'); @@ -900,7 +896,7 @@ private function getXoopsVersionConfig($module, $tables, $language) 'title' => "'{$language}TABLE_TYPE'", 'description' => "'{$language}DIVIDEBY_DESC'", 'formtype' => "'select'", - 'valuetype' => "'int'", + 'valuetype' => "'text'", 'default' => "'bordered'", 'options' => "['bordered' => 'bordered', 'striped' => 'striped', 'hover' => 'hover', 'condensed' => 'condensed']", ]; @@ -923,7 +919,7 @@ private function getXoopsVersionConfig($module, $tables, $language) 'title' => "'{$language}IDPAYPAL'", 'description' => "'{$language}IDPAYPAL_DESC'", 'formtype' => "'textbox'", - 'valuetype' => "'textbox'", + 'valuetype' => "'text'", 'default' => "'XYZ123'", ]; $ret .= $this->uxc->getUserModVersionArray(2, $paypal, 'config'); @@ -1026,30 +1022,30 @@ private function getXoopsVersionNotifications($module, $language) $notifyFiles = []; $tables = $this->getTableTables($module->getVar('mod_id'), 'table_order'); - $tableCategory = []; + //$tableCategory = []; $tableBroken = []; $tableComments = []; - $tableSubmit = []; - $tableId = null; - $tableMid = null; + //$tableSubmit = []; + //$tableId = null; + //$tableMid = null; $notifyCategory = ''; $notifyEventGlobal = $this->pc->getPhpCodeCommentLine('Global events notification'); $notifyEventTable = $this->pc->getPhpCodeCommentLine('Event notifications for items'); //global events - $notifyEventGlobal .= $this->getXoopsVersionNotificationCodeComplete($language, 'event', 'global_new', 'global', 0, 'global_new', 'global_new_notify'); - $notifyEventGlobal .= $this->getXoopsVersionNotificationCodeComplete($language, 'event', 'global_modify', 'global', 0, 'global_modify', 'global_modify_notify'); - $notifyEventGlobal .= $this->getXoopsVersionNotificationCodeComplete($language, 'event', 'global_delete', 'global', 0, 'global_delete', 'global_delete_notify'); - $notifyEventGlobal .= $this->getXoopsVersionNotificationCodeComplete($language, 'event', 'global_approve', 'global', 1, 'global_approve', 'global_approve_notify'); + $notifyEventGlobal .= $this->getXoopsVersionNotificationCodeComplete($language, 'global_new', 'global', 0, 'global_new', 'global_new_notify'); + $notifyEventGlobal .= $this->getXoopsVersionNotificationCodeComplete($language, 'global_modify', 'global', 0, 'global_modify', 'global_modify_notify'); + $notifyEventGlobal .= $this->getXoopsVersionNotificationCodeComplete($language, 'global_delete', 'global', 0, 'global_delete', 'global_delete_notify'); + $notifyEventGlobal .= $this->getXoopsVersionNotificationCodeComplete($language, 'global_approve', 'global', 1, 'global_approve', 'global_approve_notify'); foreach (\array_keys($tables) as $t) { $tableBroken[] = $tables[$t]->getVar('table_broken'); $tableComments[] = $tables[$t]->getVar('table_comments'); } if (\in_array(1, $tableBroken)) { - $notifyEventGlobal .= $this->getXoopsVersionNotificationCodeComplete($language, 'event', 'global_broken', 'global', 1, 'global_broken', 'global_broken_notify'); + $notifyEventGlobal .= $this->getXoopsVersionNotificationCodeComplete($language, 'global_broken', 'global', 1, 'global_broken', 'global_broken_notify'); } if (\in_array(1, $tableComments)) { - $notifyEventGlobal .= $this->getXoopsVersionNotificationCodeComplete($language, 'event', 'global_comment', 'global', 0, 'global_comment', 'global_comment_notify'); + $notifyEventGlobal .= $this->getXoopsVersionNotificationCodeComplete($language, 'global_comment', 'global', 0, 'global_comment', 'global_comment_notify'); } foreach (\array_keys($tables) as $t) { @@ -1057,8 +1053,8 @@ private function getXoopsVersionNotifications($module, $language) $tableMid = $tables[$t]->getVar('table_mid'); $tableName = $tables[$t]->getVar('table_name'); $tableSoleName = $tables[$t]->getVar('table_solename'); - $tableCategory[] = $tables[$t]->getVar('table_category'); - $tableSubmit[] = $tables[$t]->getVar('table_submit'); + //$tableCategory[] = $tables[$t]->getVar('table_category'); + //$tableSubmit[] = $tables[$t]->getVar('table_submit'); $fields = $this->getTableFields($tableMid, $tableId); $fieldId = 0; foreach (\array_keys($fields) as $f) { @@ -1069,13 +1065,13 @@ private function getXoopsVersionNotifications($module, $language) } if (1 == $tables[$t]->getVar('table_notifications')) { $notifyFiles[] = $tableName; - $notifyCategory .= $this->getXoopsVersionNotificationTableName($language, 'category', $tableName, $tableSoleName, $tableName, $fieldId, 1); + $notifyCategory .= $this->getXoopsVersionNotificationTableName($language, $tableName, $tableSoleName, $tableName, $fieldId); //$notifyEvent .= $this->getXoopsVersionNotificationCodeComplete($language, 'event', $tableSoleName . '_new', $tableName, 0, $tableSoleName, $tableSoleName . '_new_notify'); - $notifyEventTable .= $this->getXoopsVersionNotificationCodeComplete($language, 'event', $tableSoleName . '_modify', $tableName, 0, $tableSoleName . '_modify', $tableSoleName . '_modify_notify'); - $notifyEventTable .= $this->getXoopsVersionNotificationCodeComplete($language, 'event', $tableSoleName . '_delete', $tableName, 0, $tableSoleName . '_delete', $tableSoleName . '_delete_notify'); - $notifyEventTable .= $this->getXoopsVersionNotificationCodeComplete($language, 'event', $tableSoleName . '_approve', $tableName, 0, $tableSoleName . '_approve', $tableSoleName . '_approve_notify'); + $notifyEventTable .= $this->getXoopsVersionNotificationCodeComplete($language, $tableSoleName . '_modify', $tableName, 0, $tableSoleName . '_modify', $tableSoleName . '_modify_notify'); + $notifyEventTable .= $this->getXoopsVersionNotificationCodeComplete($language, $tableSoleName . '_delete', $tableName, 0, $tableSoleName . '_delete', $tableSoleName . '_delete_notify'); + $notifyEventTable .= $this->getXoopsVersionNotificationCodeComplete($language, $tableSoleName . '_approve', $tableName, 0, $tableSoleName . '_approve', $tableSoleName . '_approve_notify'); if (1 == $tables[$t]->getVar('table_broken')) { - $notifyEventTable .= $this->getXoopsVersionNotificationCodeComplete($language, 'event', $tableSoleName . '_broken', $tableName, 0, $tableSoleName . '_broken', $tableSoleName . '_broken_notify'); + $notifyEventTable .= $this->getXoopsVersionNotificationCodeComplete($language, $tableSoleName . '_broken', $tableName, 0, $tableSoleName . '_broken', $tableSoleName . '_broken_notify'); } /*event will be added by xoops if (1 == $tables[$t]->getVar('table_comments')) { @@ -1084,7 +1080,7 @@ private function getXoopsVersionNotifications($module, $language) } } $ret .= $this->pc->getPhpCodeCommentLine('Categories of notification'); - $ret .= $this->getXoopsVersionNotificationGlobal($language, 'category', 'global', 'global', $notifyFiles); + $ret .= $this->getXoopsVersionNotificationGlobal($language, 'category', 'global', $notifyFiles); //$ret .= $this->getXoopsVersionNotificationCategory($language, 'category', 'category', 'category', $notifyFiles, $fieldParent, '1'); @@ -1097,19 +1093,18 @@ private function getXoopsVersionNotifications($module, $language) * @private function getXoopsVersionNotificationGlobal * @param $language * @param $type - * @param $name * @param $title * @param $from * * @return string */ - private function getXoopsVersionNotificationGlobal($language, $type, $name, $title, $from) + private function getXoopsVersionNotificationGlobal($language, $type, $title, $from) { $title = \mb_strtoupper($title); $implodeFrom = \implode(".php', '", $from); $ret = $this->pc->getPhpCodeCommentLine('Global Notify'); $global = [ - 'name' => "'{$name}'", + 'name' => "'global'", 'title' => "{$language}NOTIFY_{$title}", 'description' => "''", 'subscribe_from' => "['index.php', '{$implodeFrom}.php']", @@ -1122,17 +1117,16 @@ private function getXoopsVersionNotificationGlobal($language, $type, $name, $tit /** * @private function getXoopsVersionNotificationTableName * @param $language - * @param $type * @param $name * @param $title * @param $file * @param $item - * @param $allow * * @return string */ - private function getXoopsVersionNotificationTableName($language, $type, $name, $title, $file, $item, $allow) + private function getXoopsVersionNotificationTableName($language, $name, $title, $file, $item) { + $allow = 1; $stuTitle = \mb_strtoupper($title); $ucfTitle = \ucfirst($title); $ret = $this->pc->getPhpCodeCommentLine($ucfTitle . ' Notify'); @@ -1142,9 +1136,9 @@ private function getXoopsVersionNotificationTableName($language, $type, $name, $ 'description' => "''", 'subscribe_from' => "'{$file}.php'", 'item_name' => "'{$item}'", - 'allow_bookmark' => (string)$allow, + 'allow_bookmark' => (string)(1), ]; - $ret .= $this->uxc->getUserModVersionArray(3, $table, 'notification', "'{$type}'"); + $ret .= $this->uxc->getUserModVersionArray(3, $table, 'notification', "'category'"); return $ret; } @@ -1152,7 +1146,6 @@ private function getXoopsVersionNotificationTableName($language, $type, $name, $ /** * @private function getXoopsVersionNotifications * @param $language - * @param $type * @param $name * @param $category * @param $admin @@ -1161,7 +1154,7 @@ private function getXoopsVersionNotificationTableName($language, $type, $name, $ * * @return string */ - private function getXoopsVersionNotificationCodeComplete($language, $type, $name, $category, $admin, $title, $mail) + private function getXoopsVersionNotificationCodeComplete($language, $name, $category, $admin, $title, $mail) { $title = \mb_strtoupper($title); $ucfTitle = \ucfirst($title); @@ -1176,7 +1169,7 @@ private function getXoopsVersionNotificationCodeComplete($language, $type, $name 'mail_template' => "'{$mail}'", 'mail_subject' => "{$language}NOTIFY_{$title}_SUBJECT", ]; - $ret .= $this->uxc->getUserModVersionArray(3, $event, 'notification', "'{$type}'"); + $ret .= $this->uxc->getUserModVersionArray(3, $event, 'notification', "'event'"); return $ret; } @@ -1184,10 +1177,9 @@ private function getXoopsVersionNotificationCodeComplete($language, $type, $name /** * @private function getXoopsVersionNotifications * @param $moduleDirname - * @param string $t * @return string */ - private function getXoopsVersionSelectSizeMB($moduleDirname, $t = '') + private function getXoopsVersionSelectSizeMB($moduleDirname) { $ucModuleDirname = \mb_strtoupper($moduleDirname); @@ -1196,28 +1188,28 @@ private function getXoopsVersionSelectSizeMB($moduleDirname, $t = '') $ret .= $this->xc->getXcEqualsOperator('$iniPostMaxSize ', "{$moduleDirname}ReturnBytes(\ini_get('post_max_size'))"); $ret .= $this->xc->getXcEqualsOperator('$iniUploadMaxFileSize', "{$moduleDirname}ReturnBytes(\ini_get('upload_max_filesize'))"); $ret .= $this->xc->getXcEqualsOperator('$maxSize ', 'min($iniPostMaxSize, $iniUploadMaxFileSize)'); - $cond = $this->xc->getXcEqualsOperator('$increment', '500', null, $t . "\t"); - $ret .= $this->pc->getPhpCodeConditions('$maxSize', ' > ', '10000 * 1048576', $cond, false, $t); - $cond = $this->xc->getXcEqualsOperator('$increment', '200', null, $t . "\t"); - $ret .= $this->pc->getPhpCodeConditions('$maxSize', ' <= ', '10000 * 1048576', $cond, false, $t); - $cond = $this->xc->getXcEqualsOperator('$increment', '100', null, $t . "\t"); - $ret .= $this->pc->getPhpCodeConditions('$maxSize', ' <= ', '5000 * 1048576', $cond, false, $t); - $cond = $this->xc->getXcEqualsOperator('$increment', '50', null, $t . "\t"); - $ret .= $this->pc->getPhpCodeConditions('$maxSize', ' <= ', '2500 * 1048576', $cond, false, $t); - $cond = $this->xc->getXcEqualsOperator('$increment', '10', null, $t . "\t"); - $ret .= $this->pc->getPhpCodeConditions('$maxSize', ' <= ', '1000 * 1048576', $cond, false, $t); - $cond = $this->xc->getXcEqualsOperator('$increment', '5', null, $t . "\t"); - $ret .= $this->pc->getPhpCodeConditions('$maxSize', ' <= ', '500 * 1048576', $cond, false, $t); - $cond = $this->xc->getXcEqualsOperator('$increment', '2', null, $t . "\t"); - $ret .= $this->pc->getPhpCodeConditions('$maxSize', ' <= ', '100 * 1048576', $cond, false, $t); - $cond = $this->xc->getXcEqualsOperator('$increment', '1', null, $t . "\t"); - $ret .= $this->pc->getPhpCodeConditions('$maxSize', ' <= ', '50 * 1048576', $cond, false, $t); - $cond = $this->xc->getXcEqualsOperator('$increment', '0.5', null, $t . "\t"); - $ret .= $this->pc->getPhpCodeConditions('$maxSize', ' <= ', '25 * 1048576', $cond, false, $t); + $cond = $this->xc->getXcEqualsOperator('$increment', '500', null, "\t"); + $ret .= $this->pc->getPhpCodeConditions('$maxSize', ' > ', '10000 * 1048576', $cond, false, ''); + $cond = $this->xc->getXcEqualsOperator('$increment', '200', null, "\t"); + $ret .= $this->pc->getPhpCodeConditions('$maxSize', ' <= ', '10000 * 1048576', $cond, false, ''); + $cond = $this->xc->getXcEqualsOperator('$increment', '100', null, "\t"); + $ret .= $this->pc->getPhpCodeConditions('$maxSize', ' <= ', '5000 * 1048576', $cond, false, ''); + $cond = $this->xc->getXcEqualsOperator('$increment', '50', null, "\t"); + $ret .= $this->pc->getPhpCodeConditions('$maxSize', ' <= ', '2500 * 1048576', $cond, false, ''); + $cond = $this->xc->getXcEqualsOperator('$increment', '10', null, "\t"); + $ret .= $this->pc->getPhpCodeConditions('$maxSize', ' <= ', '1000 * 1048576', $cond, false, ''); + $cond = $this->xc->getXcEqualsOperator('$increment', '5', null, "\t"); + $ret .= $this->pc->getPhpCodeConditions('$maxSize', ' <= ', '500 * 1048576', $cond, false, ''); + $cond = $this->xc->getXcEqualsOperator('$increment', '2', null, "\t"); + $ret .= $this->pc->getPhpCodeConditions('$maxSize', ' <= ', '100 * 1048576', $cond, false, ''); + $cond = $this->xc->getXcEqualsOperator('$increment', '1', null, "\t"); + $ret .= $this->pc->getPhpCodeConditions('$maxSize', ' <= ', '50 * 1048576', $cond, false, ''); + $cond = $this->xc->getXcEqualsOperator('$increment', '0.5', null, "\t"); + $ret .= $this->pc->getPhpCodeConditions('$maxSize', ' <= ', '25 * 1048576', $cond, false, ''); $ret .= $this->xc->getXcEqualsOperator('$optionMaxsize', '[]'); $ret .= $this->xc->getXcEqualsOperator('$i', '$increment'); - $while = $this->xc->getXcEqualsOperator("\$optionMaxsize[\$i . ' ' . _MI_{$ucModuleDirname}_SIZE_MB]", '$i * 1048576', null, $t . "\t"); - $while .= $this->xc->getXcEqualsOperator('$i', '$increment', '+',$t . "\t"); + $while = $this->xc->getXcEqualsOperator("\$optionMaxsize[\$i . ' ' . _MI_{$ucModuleDirname}_SIZE_MB]", '$i * 1048576', null, "\t"); + $while .= $this->xc->getXcEqualsOperator('$i', '$increment', '+', "\t"); $ret .= $this->pc->getPhpCodeWhile('i * 1048576', $while, '$maxSize', '<='); return $ret; @@ -1225,8 +1217,7 @@ private function getXoopsVersionSelectSizeMB($moduleDirname, $t = '') /** * @public function render - * @param null - * @return bool|string + * @return string */ public function render() { diff --git a/class/Files/admin/AdminAbout.php b/class/Files/admin/AdminAbout.php index 4128773e..8a135fcd 100644 --- a/class/Files/admin/AdminAbout.php +++ b/class/Files/admin/AdminAbout.php @@ -42,8 +42,8 @@ class AdminAbout extends Files\CreateFile /** * @public function constructor - * @param null */ + public function __construct() { parent::__construct(); @@ -53,7 +53,7 @@ public function __construct() /** * @static function getInstance - * @param null + * @return AdminAbout */ public static function getInstance() @@ -68,8 +68,8 @@ public static function getInstance() /** * @public function write - * @param string $module - * @param string $filename + * @param $module + * @param $filename */ public function write($module, $filename) { @@ -79,8 +79,8 @@ public function write($module, $filename) /** * @public function render - * @param null - * @return bool|string + + * @return string */ public function render() { @@ -93,7 +93,7 @@ public function render() $content .= $this->getRequire(); $content .= $this->axc->getAdminTemplateMain($moduleDirname, 'about'); $content .= $this->xc->getXcXoopsTplAssign('navigation', "\$adminObject->displayNavigation('about.php')"); - $content .= $this->getSimpleString("\$adminObject->setPaypal('{$moduleDonations}');"); + $content .= $this->getSimpleString("\$adminObject->setPaypal('$moduleDonations');"); $content .= $this->xc->getXcXoopsTplAssign('about', "\$adminObject->renderAbout(false)"); $content .= $this->getRequire('footer'); diff --git a/class/Files/admin/AdminFooter.php b/class/Files/admin/AdminFooter.php index f8f20769..cb5f744d 100644 --- a/class/Files/admin/AdminFooter.php +++ b/class/Files/admin/AdminFooter.php @@ -42,7 +42,6 @@ class AdminFooter extends Files\CreateFile /** * @public function constructor - * @param null */ public function __construct() { @@ -67,8 +66,8 @@ public static function getInstance() /** * @public function write - * @param string $module - * @param string $filename + * @param $module + * @param $filename */ public function write($module, $filename): void { @@ -78,8 +77,8 @@ public function write($module, $filename): void /** * @public function render - * @param null - * @return bool|string + + * @return string */ public function render() { @@ -91,7 +90,7 @@ public function render() $isset = $this->pc->getPhpCodeIsset('templateMain'); $display = "\t" . $this->xc->getXcXoopsTplAssign('maintainedby', "\$helper->getConfig('maintainedby')"); $display .= "\t" . $this->xc->getXcXoopsTplDisplay(); - $content .= $this->pc->getPhpCodeConditions($isset, '', '', $display, false) . PHP_EOL; + $content .= $this->pc->getPhpCodeConditions($isset, '', '', $display) . PHP_EOL; $content .= $this->xc->getXcXoopsCPFooter(); $this->create($moduleDirname, 'admin', $filename, $content, \_AM_MODULEBUILDER_FILE_CREATED, \_AM_MODULEBUILDER_FILE_NOTCREATED); diff --git a/class/Files/admin/AdminPages.php b/class/Files/admin/AdminPages.php index d22309d3..cd1825ce 100644 --- a/class/Files/admin/AdminPages.php +++ b/class/Files/admin/AdminPages.php @@ -48,7 +48,6 @@ class AdminPages extends Files\CreateFile /** * @public function constructor - * @param null */ public function __construct() { @@ -60,7 +59,7 @@ public function __construct() /** * @static function getInstance - * @param null + * * @return AdminPages */ @@ -119,9 +118,9 @@ private function getAdminPagesHeader($moduleDirname, $fieldId) } $ret .= $this->xc->getXcXoopsRequest($leftOp, 'op', 'list', 'Cmd'); $ret .= $this->xc->getXcXoopsRequest($leftField, $fieldId, '', 'Int'); - $ret .= $this->xc->getXcXoopsRequest($leftStart, 'start', '', 'Int', false); + $ret .= $this->xc->getXcXoopsRequest($leftStart, 'start', '', 'Int'); $config = $this->xc->getXcGetConfig('adminpager'); - $ret .= $this->xc->getXcXoopsRequest($leftLimit, 'limit', $config, 'Int', false); + $ret .= $this->xc->getXcXoopsRequest($leftLimit, 'limit', $config, 'Int'); $ret .= $this->xc->getXcXoopsTplAssign('start', '$start'); $ret .= $this->xc->getXcXoopsTplAssign('limit', '$limit'); $ret .= $this->pc->getPhpCodeBlankLine(); @@ -131,11 +130,11 @@ private function getAdminPagesHeader($moduleDirname, $fieldId) /** * @private function getAdminPagesSwitch - * @param $cases + * @param array $cases * * @return string */ - private function getAdminPagesSwitch($cases = []) + private function getAdminPagesSwitch(array $cases = []) { $contentSwitch = $this->pc->getPhpCodeCaseSwitch($cases, true, false, "\t"); @@ -151,7 +150,7 @@ private function getAdminPagesSwitch($cases = []) * @param string $t * @return string */ - private function getAdminPagesList($moduleDirname, $table, $language, $fieldInForm, $t = '') + private function getAdminPagesList($moduleDirname, $table, $language, $fieldInForm, string $t = '') { $stuModuleDirname = \mb_strtoupper($moduleDirname); $tableName = $table->getVar('table_name'); @@ -182,7 +181,7 @@ private function getAdminPagesList($moduleDirname, $table, $language, $fieldInFo $contentForeach .= $this->pc->getPhpCodeUnset($tableSoleName, $t . "\t\t"); $condIf = $this->pc->getPhpCodeForeach("{$tableName}All", true, false, 'i', $contentForeach, $t . "\t"); $condIf .= $this->xc->getXcPageNav($tableName, $t . "\t"); - $condElse = $this->xc->getXcXoopsTplAssign('error', "{$language}THEREARENT_{$stuTableName}", true, $t . "\t"); + $condElse = $this->xc->getXcXoopsTplAssign('error', "{$language}THEREARENO_{$stuTableName}", true, $t . "\t"); $ret .= $this->pc->getPhpCodeConditions("\${$tableName}Count", ' > ', '0', $condIf, $condElse, $t); return $ret; @@ -197,7 +196,7 @@ private function getAdminPagesList($moduleDirname, $table, $language, $fieldInFo * @param string $t * @return string */ - private function getAdminPagesNew($moduleDirname, $tableName, $fieldInForm, $language, $t = '') + private function getAdminPagesNew($moduleDirname, $tableName, $fieldInForm, $language, string $t = '') { $stuTableName = \mb_strtoupper($tableName); $ret = $this->axc->getAdminTemplateMain($moduleDirname, $tableName, $t); @@ -224,7 +223,7 @@ private function getAdminPagesNew($moduleDirname, $tableName, $fieldInForm, $lan * @param string $t * @return string */ - private function getAdminPagesClone($moduleDirname, $tableName, $tableSoleName, $fieldInForm, $fieldId, $language, $t = '') + private function getAdminPagesClone($moduleDirname, $tableName, $tableSoleName, $fieldInForm, $fieldId, $language, string $t = '') { $stuTableName = \mb_strtoupper($tableName); $stuTableSoleName = \mb_strtoupper($tableSoleName); @@ -240,7 +239,12 @@ private function getAdminPagesClone($moduleDirname, $tableName, $tableSoleName, } $ret .= $this->pc->getPhpCodeCommentLine('Request source', '', $t); $ret .= $this->xc->getXcXoopsRequest($ccFieldId . 'Source', $fieldId . '_source', '', 'Int', false, $t); - $ret .= $this->xc->getXcCommonPagesClone($tableName, $ccFieldId, $t); + + $ret .= $this->pc->getPhpCodeCommentLine('Check params', '', $t); + $contIf = $this->xc->getXcRedirectHeader($tableName, '?op=list', 3, "{$language}INVALID_PARAM", true, $t . "\t"); + $ret .= $this->pc->getPhpCodeConditions("\${$ccFieldId}Source", ' === ', '0', $contIf, false, $t); + + $ret .= $this->xc->getXcCommonPagesClone($tableName, $ccFieldId, $t, $language); return $ret; } @@ -248,11 +252,11 @@ private function getAdminPagesClone($moduleDirname, $tableName, $tableSoleName, /** * @private function getPermissionsSave * @param $moduleDirname - * @param $perm + * @param string $perm * * @return string */ - private function getPermissionsSave($moduleDirname, $perm = 'view') + private function getPermissionsSave($moduleDirname, string $perm = 'view') { $ret = $this->pc->getPhpCodeCommentLine('Permission to', $perm, "\t\t\t"); $ret .= $this->xc->getXcDeleteRight('grouppermHandler', "{$moduleDirname}_{$perm}", '$mid', '$permId', false, "\t\t\t"); @@ -276,10 +280,11 @@ private function getPermissionsSave($moduleDirname, $perm = 'view') * @param string $t * @return string */ - private function getAdminPagesSave($moduleDirname, $tableName, $tableSoleName, $language, $fields, $fieldId, $fieldMain, $tablePerms, $t = '') + private function getAdminPagesSave($moduleDirname, $tableName, $tableSoleName, $language, $fields, $fieldId, $fieldMain, $tablePerms, string $t = '') { + $ret = $this->axc->getAdminTemplateMain($moduleDirname, $tableName, $t); $ccFieldId = $this->getCamelCase($fieldId, false, true); - $ret = $this->pc->getPhpCodeCommentLine('Security Check', '', $t); + $ret .= $this->pc->getPhpCodeCommentLine('Security Check', '', $t); $xoopsSecurityCheck = $this->xc->getXcXoopsSecurityCheck('!'); $securityError = $this->xc->getXcXoopsSecurityErrors(); $implode = $this->pc->getPhpCodeImplode(',', $securityError); @@ -289,6 +294,9 @@ private function getAdminPagesSave($moduleDirname, $tableName, $tableSoleName, $ $contentIf = $this->xc->getXcHandlerGetObj($tableName, $ccFieldId, $t . "\t"); $contentElse = $this->xc->getXcHandlerCreateObj($tableName, $t . "\t"); $ret .= $this->pc->getPhpCodeConditions("\${$ccFieldId}", ' > ', '0', $contentIf, $contentElse, $t); + $tablenameObj = $this->pc->getPhpCodeIsobject($tableName . 'Obj'); + $redirectError = $this->xc->getXcRedirectHeader($tableName, '', '3', "{$language}INVALID_PARAM", true, $t . "\t"); + $ret .= $this->pc->getPhpCodeConditions('!' . $tablenameObj, '', '', $redirectError, false, $t); $ret .= $this->pc->getPhpCodeCommentLine('Set Vars', null, $t); $countUploader = 0; $fieldLines = ''; @@ -320,13 +328,13 @@ private function getAdminPagesSave($moduleDirname, $tableName, $tableSoleName, $ $countUploader++; break; case Constants::FIELD_ELE_TEXTDATESELECT: - $fieldLines .= $this->xc->getXcSetVarTextDateSelect($tableName, $tableSoleName, $fieldName, $t); + $fieldLines .= $this->xc->getXcSetVarTextDateSelect($tableName, $tableSoleName, $fieldName, $t, $language); break; case Constants::FIELD_ELE_PASSWORD: $fieldLines .= $this->axc->getAxcSetVarPassword($tableName, $fieldName, $t); break; case Constants::FIELD_ELE_DATETIME: - $fieldLines .= $this->xc->getXcSetVarDateTime($tableName, $tableSoleName, $fieldName, $t); + $fieldLines .= $this->xc->getXcSetVarDateTime($tableName, $tableSoleName, $fieldName, $t, $language); break; default: $fieldLines .= $this->axc->getAxcSetVarMisc($tableName, $fieldName, $fieldType, $fieldElement, $t); @@ -340,12 +348,12 @@ private function getAdminPagesSave($moduleDirname, $tableName, $tableSoleName, $ $ret .= $fieldLines; $ret .= $this->pc->getPhpCodeCommentLine('Insert Data', null, $t); $insert = $this->xc->getXcHandlerInsert($tableName, $tableName, 'Obj'); - $contentInsert = ''; + $ucfTableName = \ucfirst($tableName); + $ucfFieldId = $this->getCamelCase($fieldId, true); + $contentInsert = $this->xc->getXcEqualsOperator("\$saved{$ucfFieldId}", "\${$ccFieldId} > 0 ? \${$ccFieldId} : \${$tableName}Obj->getNewInsertedId{$ucfTableName}()", null, $t . "\t"); + if (1 == $tablePerms) { - $ucfTableName = \ucfirst($tableName); - $ucfFieldId = $this->getCamelCase($fieldId, true); - $contentInsert = $this->xc->getXcEqualsOperator("\$new{$ucfFieldId}", "\${$tableName}Obj->getNewInsertedId{$ucfTableName}()", null, $t . "\t"); - $contentInsert .= $this->pc->getPhpCodeTernaryOperator('permId', "isset(\$_REQUEST['{$fieldId}'])", "\${$ccFieldId}", "\$new{$ucfFieldId}", $t . "\t"); + $contentInsert .= $this->xc->getXcEqualsOperator("\$permId", "\$saved{$ucfFieldId}",'', "\t\t\t"); $contentInsert .= $this->xc->getXcXoopsHandler('groupperm', $t . "\t"); $contentInsert .= $this->xc->getXcEqualsOperator('$mid', "\$GLOBALS['xoopsModule']->getVar('mid')", null, $t . "\t"); $contentInsert .= $this->getPermissionsSave($moduleDirname, 'view_' . $tableName); @@ -353,11 +361,11 @@ private function getAdminPagesSave($moduleDirname, $tableName, $tableSoleName, $ $contentInsert .= $this->getPermissionsSave($moduleDirname, 'approve_' . $tableName); } if ($countUploader > 0) { - $errIf = $this->xc->getXcRedirectHeader("'{$tableName}.php?op=edit&{$fieldId}=' . \${$ccFieldId}", '', '5', '$uploaderErrors', false, $t . "\t\t"); - $errElse = $this->xc->getXcRedirectHeader("'{$tableName}.php?op=list&start=' . \$start . '&limit=' . \$limit", '', '2', "{$language}FORM_OK", false, $t . "\t\t"); + $errIf = $this->xc->getXcRedirectHeader("'{$tableName}.php?op=edit&{$fieldId}=' . \$saved{$ucfFieldId}", '', '5', '$uploaderErrors', false, $t . "\t\t"); + $errElse = $this->xc->getXcRedirectHeader("'{$tableName}.php?op=list&start=' . \$start . '&limit=' . \$limit", '', '2', "{$language}FORM_OK", false, $t . "\t\t"); $contentInsert .= $this->pc->getPhpCodeConditions('$uploaderErrors', ' !== ', "''", $errIf, $errElse, $t . "\t"); } else { - $contentInsert .= $this->xc->getXcRedirectHeader("'{$tableName}.php?op=list&start=' . \$start . '&limit=' . \$limit", '', '2', "{$language}FORM_OK", false, $t . "\t\t"); + $contentInsert .= $this->xc->getXcRedirectHeader("'{$tableName}.php?op=list&start=' . \$start . '&limit=' . \$limit", '', '2', "{$language}FORM_OK", false, $t . "\t\t"); } $ret .= $this->pc->getPhpCodeConditions($insert, '', '', $contentInsert, false, $t); $ret .= $this->pc->getPhpCodeCommentLine('Get Form', null, $t); @@ -378,7 +386,7 @@ private function getAdminPagesSave($moduleDirname, $tableName, $tableSoleName, $ * @param string $t * @return string */ - private function getAdminPagesEdit($moduleDirname, $table, $language, $fieldId, $fieldInForm, $t = '') + private function getAdminPagesEdit($moduleDirname, $table, $language, $fieldId, $fieldInForm, string $t = '') { $tableName = $table->getVar('table_name'); $tableSoleName = $table->getVar('table_solename'); @@ -395,7 +403,7 @@ private function getAdminPagesEdit($moduleDirname, $table, $language, $fieldId, $ret .= $this->axc->getAdminItemButton($language, $tableName, $stuTableName, '', 'list', $t); $ret .= $this->xc->getXcXoopsTplAssign('buttons', '$adminObject->displayButton(\'left\')', true, $t); } - $ret .= $this->xc->getXcCommonPagesEdit($tableName, $ccFieldId, $t); + $ret .= $this->xc->getXcCommonPagesEdit($tableName, $ccFieldId, $t, $language); return $ret; } @@ -412,7 +420,7 @@ private function getAdminPagesEdit($moduleDirname, $table, $language, $fieldId, * @param string $t * @return string */ - private function getAdminPagesDelete($moduleDirname, $tableName, $tableSoleName, $language, $fieldId, $fieldMain, $tableNotifications, $t = '') + private function getAdminPagesDelete($moduleDirname, $tableName, $tableSoleName, $language, $fieldId, $fieldMain, $tableNotifications, string $t = '') { $ret = $this->axc->getAdminTemplateMain($moduleDirname, $tableName, $t); $navigation = $this->axc->getAdminDisplayNavigation($tableName); @@ -423,9 +431,9 @@ private function getAdminPagesDelete($moduleDirname, $tableName, $tableSoleName, /** * @public function render - * @param null + * - * @return bool|string + * @return string */ public function render() { diff --git a/class/Files/admin/AdminXoopsCode.php b/class/Files/admin/AdminXoopsCode.php index 183d5951..1b94fe7f 100644 --- a/class/Files/admin/AdminXoopsCode.php +++ b/class/Files/admin/AdminXoopsCode.php @@ -38,20 +38,24 @@ class AdminXoopsCode * @var mixed */ private $pc = null; + /** + * @var mixed + */ + private $cf = null; /** * @public function constructor - * @param null */ public function __construct() { $this->xc = Modulebuilder\Files\CreateXoopsCode::getInstance(); $this->pc = Modulebuilder\Files\CreatePhpCode::getInstance(); + $this->cf = Modulebuilder\Files\CreateFile::getInstance(); } /** * @static function getInstance - * @param null + * @return AdminXoopsCode */ public static function getInstance() @@ -72,7 +76,7 @@ public static function getInstance() * @param string $t * @return string */ - public function getAdminTemplateMain($moduleDirname, $tableName, $t = '') + public function getAdminTemplateMain($moduleDirname, $tableName, string $t = '') { return "{$t}\$templateMain = '{$moduleDirname}_admin_{$tableName}.tpl';\n"; } @@ -88,7 +92,7 @@ public function getAdminTemplateMain($moduleDirname, $tableName, $t = '') * @param string $t * @return string */ - public function getAdminItemButton($language, $tableName, $stuTableSoleName, $op = '?op=new', $type = 'add', $t = '') + public function getAdminItemButton($language, $tableName, $stuTableSoleName, string $op = '?op=new', string $type = 'add', string $t = '') { $stuType = \mb_strtoupper($type); $aM = $t . '$adminObject->addItemButton('; @@ -115,7 +119,7 @@ public function getAdminItemButton($language, $tableName, $stuTableSoleName, $op * @param string $t * @return string */ - public function getAdminDisplayButton($type, $t = '') + public function getAdminDisplayButton($type, string $t = '') { return "{$t}\$adminObject->displayButton('{$type}');\n"; } @@ -128,7 +132,7 @@ public function getAdminDisplayButton($type, $t = '') * @param string $t * @return string */ - public function getAdminDisplayNavigation($tableName, $t = '') + public function getAdminDisplayNavigation($tableName, string $t = '') { return "{$t}\$adminObject->displayNavigation('{$tableName}.php')"; } @@ -140,7 +144,7 @@ public function getAdminDisplayNavigation($tableName, $t = '') * @param string $t * @return string */ - public function getAxcAddInfoBox($language, $t = '') + public function getAxcAddInfoBox($language, string $t = '') { return "{$t}\$adminObject->addInfoBox({$language});\n"; } @@ -153,7 +157,7 @@ public function getAxcAddInfoBox($language, $t = '') * @param string $t * @return string */ - public function getAxcAddInfoBoxLine($label = '', $var = '', $t = '') + public function getAxcAddInfoBoxLine(string $label = '', string $var = '', string $t = '') { $aMenu = $t . '$adminObject->addInfoBoxLine(\sprintf('; if ('' != $var) { @@ -174,7 +178,7 @@ public function getAxcAddInfoBoxLine($label = '', $var = '', $t = '') * @param string $t * @return string */ - public function getAxcAddConfigBoxLine($language, $label = '', $var = '', $t = '') + public function getAxcAddConfigBoxLine($language, string $label = '', string $var = '', string $t = '') { $aMenu = $t . '$adminObject->addConfigBoxLine('; if ('' != $var) { @@ -194,7 +198,7 @@ public function getAxcAddConfigBoxLine($language, $label = '', $var = '', $t = ' * @param int $countUploader * @return string */ - public function getAxcSetVarImageList($tableName, $fieldName, $t = '', $countUploader = 0) + public function getAxcSetVarImageList(string $tableName, string $fieldName, string $t = '', int $countUploader = 0) { $ret = $this->pc->getPhpCodeCommentLine('Set Var', $fieldName, $t); $ret .= $this->pc->getPhpCodeIncludeDir('\XOOPS_ROOT_PATH', 'class/uploader', true, false, '', $t); @@ -221,51 +225,51 @@ public function getAxcSetVarImageList($tableName, $fieldName, $t = '', $countUpl * @param string $fieldName * @param $fieldMain * @param string $t - * @param int $countUploader + * @param int $countUploader * @return string */ - public function getAxcSetVarUploadImage($moduleDirname, $tableName, $fieldName, $fieldMain, $t = '', $countUploader = 0) + public function getAxcSetVarUploadImage(string $moduleDirname, string $tableName, string $fieldName, $fieldMain, string $t = '', int $countUploader = 0) { $stuModuleDirname = \mb_strtoupper($moduleDirname); - $ucfModuleDirname = \ucfirst($moduleDirname); + $ret = $this->pc->getPhpCodeCommentLine('Set Var', $fieldName, $t); - $ret .= $this->pc->getPhpCodeIncludeDir('\XOOPS_ROOT_PATH', 'class/uploader', true, false, '', $t); + $condIf = $this->pc->getPhpCodeIncludeDir('\XOOPS_ROOT_PATH', 'class/uploader', true, false, '', $t . "\t"); $file = $this->pc->getPhpCodeGlobalsVariables($fieldName, 'FILES') . "['name']"; - $ret .= $this->xc->getXcEqualsOperator('$filename ', $file, null, $t); + $ret .= $this->xc->getXcEqualsOperator('$filename', $file, null, $t); $mimetype = $this->pc->getPhpCodeGlobalsVariables($fieldName, 'FILES') . "['type']"; - $ret .= $this->xc->getXcEqualsOperator('$imgMimetype ', $mimetype, null, $t); - $ret .= $this->xc->getXcEqualsOperator('$imgNameDef ', "Request::getString('{$fieldMain}')", null, $t); + $condIf .= $this->xc->getXcEqualsOperator('$imgMimetype ', $mimetype, null, $t . "\t"); + $condIf .= $this->xc->getXcEqualsOperator('$imgNameDef ', "Request::getString('{$fieldMain}')", null, $t . "\t"); $xUploadImage = "\\{$stuModuleDirname}_UPLOAD_IMAGE_PATH"; - $ret .= $this->xc->getXcMediaUploader('uploader', $xUploadImage . " . '/{$tableName}/'", 'mimetypes_image', 'maxsize_image', $t); + $condIf .= $this->xc->getXcMediaUploader('uploader', $xUploadImage . " . '/{$tableName}/'", 'mimetypes_image', 'maxsize_image', $t . "\t"); + $isset = "isset(\$_POST['xoops_upload_file'][" . $countUploader . '])'; $post = $this->pc->getPhpCodeGlobalsVariables('xoops_upload_file', 'POST') . '[' . $countUploader . ']'; $fetchMedia = $this->getAxcFetchMedia('uploader', $post); - $expr = '/^.+\.([^.]+)$/sU'; - $ifelse = $this->pc->getPhpCodePregFunzions('extension', $expr, '', '$filename', 'replace', false, $t . "\t"); - $ifelse .= $t . "\t\$imgName = \str_replace(' ', '', \$imgNameDef) . '.' . \$extension;\n"; - $ifelse .= $this->getAxcSetPrefix('uploader', '$imgName', $t . "\t") . ";\n"; - $ifelse .= $t . "\t{$fetchMedia};\n"; - $contIf = $this->xc->getXcEqualsOperator('$savedFilename', '$uploader->getSavedFileName()', null, $t . "\t\t"); + $ifelse = $this->xc->getXcEqualsOperator('$extension', '\pathinfo($filename, \PATHINFO_EXTENSION)',null, $t . "\t\t"); + $ifelse .= $this->xc->getXcEqualsOperator('$imgName', "\str_replace(' ', '', \$imgNameDef) . '.' . \$extension", null,$t . "\t\t"); + $ifelse .= $this->getAxcSetPrefix('uploader', '$imgName', $t . "\t\t") . ";\n"; + $contIf = $this->xc->getXcEqualsOperator('$savedFilename', '$uploader->getSavedFileName()', null, $t . "\t\t\t"); $config = $this->xc->getXcGetConfig('maxwidth_image'); - $contIf .= $this->xc->getXcEqualsOperator('$maxwidth ', "(int){$config}", null, $t . "\t\t"); + $contIf .= $this->xc->getXcEqualsOperator('$maxwidth ', "(int){$config}", null, $t . "\t\t\t"); $config = $this->xc->getXcGetConfig('maxheight_image'); - $contIf .= $this->xc->getXcEqualsOperator('$maxheight', "(int){$config}", null, $t . "\t\t"); + $contIf .= $this->xc->getXcEqualsOperator('$maxheight', "(int){$config}", null, $t . "\t\t\t"); $resizer = $this->pc->getPhpCodeCommentLine('Resize image', '', $t . "\t\t\t"); - $resizer .= $this->xc->getXcEqualsOperator('$imgHandler ', "new {$ucfModuleDirname}\Common\Resizer()", null, $t . "\t\t\t"); - $resizer .= $this->xc->getXcEqualsOperator('$imgHandler->sourceFile ', $xUploadImage . " . '/{$tableName}/' . \$savedFilename", null, $t . "\t\t\t"); - $resizer .= $this->xc->getXcEqualsOperator('$imgHandler->endFile ', $xUploadImage . " . '/{$tableName}/' . \$savedFilename", null, $t . "\t\t\t"); - $resizer .= $this->xc->getXcEqualsOperator('$imgHandler->imageMimetype', '$imgMimetype', null, $t . "\t\t\t"); - $resizer .= $this->xc->getXcEqualsOperator('$imgHandler->maxWidth ', '$maxwidth', null, $t . "\t\t\t"); - $resizer .= $this->xc->getXcEqualsOperator('$imgHandler->maxHeight ', '$maxheight', null, $t . "\t\t\t"); - $resizer .= $this->xc->getXcEqualsOperator('$result ', '$imgHandler->resizeImage()', null, $t . "\t\t\t"); - $contIf .= $this->pc->getPhpCodeConditions('$maxwidth > 0 && $maxheight > 0', '', '', $resizer, false, $t . "\t\t"); - $contIf .= $this->xc->getXcSetVarObj($tableName, $fieldName, '$savedFilename', $t . "\t\t"); - $contElseInt = $this->xc->getXcEqualsOperator('$uploaderErrors', "'
' . \$uploader->getErrors()", '.', $t . "\t\t"); - $ifelse .= $this->pc->getPhpCodeConditions('$uploader->upload()', '', '', $contIf, $contElseInt, $t . "\t"); - $ifelseExt = $this->xc->getXcEqualsOperator('$uploaderErrors', "'
' . \$uploader->getErrors()", '.', $t . "\t\t"); - $contElseExt = $this->pc->getPhpCodeConditions('$filename', ' > ', "''", $ifelseExt, false, $t . "\t"); - $contElseExt .= $this->xc->getXcSetVarObj($tableName, $fieldName, "Request::getString('{$fieldName}')", $t . "\t"); - - $ret .= $this->pc->getPhpCodeConditions($fetchMedia, '', '', $ifelse, $contElseExt, $t); + $resizer .= $this->xc->getXcEqualsOperator('$imgHandler ', "new Common\Resizer()", null, $t . "\t\t\t\t"); + $resizer .= $this->xc->getXcEqualsOperator('$imgHandler->sourceFile ', $xUploadImage . " . '/{$tableName}/' . \$savedFilename", null, $t . "\t\t\t\t"); + $resizer .= $this->xc->getXcEqualsOperator('$imgHandler->endFile ', $xUploadImage . " . '/{$tableName}/' . \$savedFilename", null, $t . "\t\t\t\t"); + $resizer .= $this->xc->getXcEqualsOperator('$imgHandler->imageMimetype', '$imgMimetype', null, $t . "\t\t\t\t"); + $resizer .= $this->xc->getXcEqualsOperator('$imgHandler->maxWidth ', '$maxwidth', null, $t . "\t\t\t\t"); + $resizer .= $this->xc->getXcEqualsOperator('$imgHandler->maxHeight ', '$maxheight', null, $t . "\t\t\t\t"); + $resizer .= $this->xc->getXcEqualsOperator('$result ', '$imgHandler->resizeImage()', null, $t . "\t\t\t\t"); + $contIf .= $this->pc->getPhpCodeConditions('$maxwidth > 0 && $maxheight > 0', '', '', $resizer, false, $t . "\t\t\t"); + $contIf .= $this->xc->getXcSetVarObj($tableName, $fieldName, '$savedFilename', $t . "\t\t\t"); + $contElseInt = $this->xc->getXcEqualsOperator('$uploaderErrors', "'
' . \$uploader->getErrors()", '.', $t . "\t\t\t"); + $ifelse .= $this->pc->getPhpCodeConditions('$uploader->upload()', '', '', $contIf, $contElseInt, $t . "\t\t"); + $ifelseExt = $this->xc->getXcEqualsOperator('$uploaderErrors', "'
' . \$uploader->getErrors()", '.', $t . "\t\t\t"); + $contElseExt = $this->pc->getPhpCodeConditions('$filename', ' > ', "''", $ifelseExt, false, $t . "\t\t"); + $contElseExt .= $this->xc->getXcSetVarObj($tableName, $fieldName, "Request::getString('{$fieldName}')", $t . "\t\t"); + $condIf .= $this->pc->getPhpCodeConditions($isset . ' && ' . $fetchMedia, '', '', $ifelse, $contElseExt, $t . "\t"); + $condElse = $this->xc->getXcSetVarObj($tableName, $fieldName, "Request::getString('{$fieldName}')", $t . "\t"); + $ret .= $this->pc->getPhpCodeConditions("'' !== (string)\$filename", '', '', $condIf, $condElse, $t); return $ret; } @@ -275,18 +279,16 @@ public function getAxcSetVarUploadImage($moduleDirname, $tableName, $fieldName, * @param $moduleDirname * @param $tableName * @param $fieldName - * @param bool $formatUrl + * @param bool $formatUrl * @param string $t - * @param int $countUploader + * @param int $countUploader * @param string $fieldMain * @return string */ - public function getAxcSetVarUploadFile($moduleDirname, $tableName, $fieldName, $formatUrl = false, $t = '', $countUploader = 0, $fieldMain = '') + public function getAxcSetVarUploadFile($moduleDirname, $tableName, $fieldName, bool $formatUrl = false, string $t = '', int $countUploader = 0, string $fieldMain = '') { $stuModuleDirname = \mb_strtoupper($moduleDirname); - $ret = $this->getAxcSetVarImageFile('\\' . $stuModuleDirname . '_UPLOAD_FILES_PATH', $tableName, $fieldName, $formatUrl, $t, $countUploader, $fieldMain, 'mimetypes_file', 'maxsize_file'); - - return $ret; + return $this->getAxcSetVarImageFile('\\' . $stuModuleDirname . '_UPLOAD_FILES_PATH', $tableName, $fieldName, $formatUrl, $t, $countUploader, $fieldMain, 'mimetypes_file', 'maxsize_file'); } /** @@ -302,35 +304,45 @@ public function getAxcSetVarUploadFile($moduleDirname, $tableName, $fieldName, $ * @param string $maxsize * @return string */ - private function getAxcSetVarImageFile($dirname, $tableName, $fieldName, $formatUrl = false, $t = '', $countUploader = 0, $fieldMain = '', $mimetype = 'mimetypes_image', $maxsize = 'maxsize_image') + private function getAxcSetVarImageFile($dirname, $tableName, $fieldName, bool $formatUrl = false, string $t = '', int $countUploader = 0, string $fieldMain = '', string $mimetype = 'mimetypes_image', string $maxsize = 'maxsize_image') { $ret = ''; $files = ''; + $rpFieldName = '$' . $this->cf->getCamelCase($fieldName, false, true); + if ($formatUrl) { - $ret .= $this->xc->getXcSetVarObj($tableName, $fieldName, "formatURL(\$_REQUEST['{$fieldName}'])", $t); + $ret .= $this->xc->getXcEqualsOperator($rpFieldName, "formatURL((string)(\$_REQUEST['{$fieldName}'] ?? ''))", null, $t); } $ret .= $this->pc->getPhpCodeCommentLine('Set Var', $fieldName, $t); - $ret .= $this->pc->getPhpCodeIncludeDir('\XOOPS_ROOT_PATH', 'class/uploader', true, false, '', $t); $file = $this->pc->getPhpCodeGlobalsVariables($fieldName, 'FILES') . "['name']"; - $ret .= $this->xc->getXcEqualsOperator('$filename ', $file, null, $t); - $ret .= $this->xc->getXcEqualsOperator('$imgNameDef ', "Request::getString('{$fieldMain}')", null, $t); - $ret .= $this->xc->getXcMediaUploader('uploader', $dirname . " . '/{$tableName}{$files}/'", $mimetype, $maxsize, $t); + $ret .= $this->xc->getXcEqualsOperator('$filename', $file, null, $t); + $condIf = $this->pc->getPhpCodeIncludeDir('\XOOPS_ROOT_PATH', 'class/uploader', true, false, '', $t . "\t"); + $condIf .= $this->xc->getXcEqualsOperator('$imgNameDef', "Request::getString('{$fieldMain}')", null, $t . "\t"); + $condIf .= $this->xc->getXcMediaUploader('uploader', $dirname . " . '/{$tableName}{$files}/'", $mimetype, $maxsize, $t . "\t"); + $isset = "isset(\$_POST['xoops_upload_file'][" . $countUploader . '])'; $post = $this->pc->getPhpCodeGlobalsVariables('xoops_upload_file', 'POST') . '[' . $countUploader . ']'; $fetchMedia = $this->getAxcFetchMedia('uploader', $post); - $expr = '/^.+\.([^.]+)$/sU'; - $ifelse = $this->pc->getPhpCodePregFunzions('extension', $expr, '', '$filename', 'replace', false, $t . "\t"); - $ifelse .= $t . "\t\$imgName = \str_replace(' ', '', \$imgNameDef) . '.' . \$extension;\n"; - $ifelse .= $this->getAxcSetPrefix('uploader', '$imgName', $t . "\t") . ";\n"; - $ifelse .= $t . "\t{$fetchMedia};\n"; - $contIf = $this->xc->getXcSetVarObj($tableName, $fieldName, '$uploader->getSavedFileName()', $t . "\t\t"); - $contElseInt = $this->xc->getXcEqualsOperator('$uploaderErrors', "'
' . \$uploader->getErrors()", '.', $t . "\t\t"); - $ifelse .= $this->pc->getPhpCodeConditions('$uploader->upload()', '', '', $contIf, $contElseInt, $t . "\t"); - $ifelseExt = $this->xc->getXcEqualsOperator('$uploaderErrors', "'
' . \$uploader->getErrors()", '.', $t . "\t\t"); - $contElseExt = $this->pc->getPhpCodeConditions('$filename', ' > ', "''", $ifelseExt, false, $t . "\t"); - $contElseExt .= $this->xc->getXcSetVarObj($tableName, $fieldName, "Request::getString('{$fieldName}')", $t . "\t"); - - $ret .= $this->pc->getPhpCodeConditions($fetchMedia, '', '', $ifelse, $contElseExt, $t); + $ifelse = $this->xc->getXcEqualsOperator('$extension', '\pathinfo($filename, \PATHINFO_EXTENSION)',null, $t . "\t\t"); + $ifelse .= $this->xc->getXcEqualsOperator('$imgName', "\str_replace(' ', '', \$imgNameDef) . '.' . \$extension", null,$t . "\t\t"); + $ifelse .= $this->getAxcSetPrefix('uploader', '$imgName', $t . "\t\t") . ";\n"; + $contIf = $this->xc->getXcSetVarObj($tableName, $fieldName, '$uploader->getSavedFileName()', $t . "\t\t\t"); + $contElseInt = $this->xc->getXcEqualsOperator('$uploaderErrors', "'
' . \$uploader->getErrors()", '.', $t . "\t\t\t"); + $ifelse .= $this->pc->getPhpCodeConditions('$uploader->upload()', '', '', $contIf, $contElseInt, $t . "\t\t"); + $ifelseExt = $this->xc->getXcEqualsOperator('$uploaderErrors', "'
' . \$uploader->getErrors()", '.', $t . "\t\t\t"); + $contElseExt = $this->pc->getPhpCodeConditions('$filename', ' > ', "''", $ifelseExt, false, $t . "\t\t"); + if ($formatUrl) { + $contElseExt .= $this->xc->getXcSetVarObj($tableName, $fieldName, $rpFieldName, $t . "\t\t"); + } else { + $contElseExt .= $this->xc->getXcSetVarObj($tableName, $fieldName, "Request::getString('{$fieldName}')", $t . "\t\t"); + } + $condIf.= $this->pc->getPhpCodeConditions($isset . ' && ' . $fetchMedia, '', '', $ifelse, $contElseExt, $t . "\t"); + if ($formatUrl) { + $condElse= $this->xc->getXcSetVarObj($tableName, $fieldName, $rpFieldName, $t . "\t"); + } else { + $condElse = $this->xc->getXcSetVarObj($tableName, $fieldName, "Request::getString('{$fieldName}')", $t . "\t"); + } + $ret .= $this->pc->getPhpCodeConditions("'' !== (string)\$filename", '', '', $condIf, $condElse, $t); return $ret; } @@ -342,7 +354,7 @@ private function getAxcSetVarImageFile($dirname, $tableName, $fieldName, $format * @param string $t * @return string */ - public function getAxcSetVarPassword($tableName, $fieldName, $t = '') + public function getAxcSetVarPassword($tableName, $fieldName, string $t = '') { $cf = Modulebuilder\Files\CreateFile::getInstance(); $ccFieldId = $cf->getCamelCase($fieldName, false, true); @@ -362,7 +374,7 @@ public function getAxcSetVarPassword($tableName, $fieldName, $t = '') * @param string $t * @return string */ - public function getAxcSetVarMisc($tableName, $fieldName, $fieldType, $fieldElement, $t = '') + public function getAxcSetVarMisc($tableName, $fieldName, $fieldType, $fieldElement, string $t = '') { switch ((int)$fieldType){ case 2: @@ -407,7 +419,7 @@ public function getAxcSetVarMisc($tableName, $fieldName, $fieldType, $fieldEleme * @param string $t * @return string */ - public function getAxcFetchMedia($anchor, $var, $t = '') + public function getAxcFetchMedia($anchor, $var, string $t = '') { return "{$t}\${$anchor}->fetchMedia({$var})"; } @@ -421,7 +433,7 @@ public function getAxcFetchMedia($anchor, $var, $t = '') * @param string $t * @return string */ - public function getAxcSetPrefix($anchor, $var, $t = '') + public function getAxcSetPrefix($anchor, $var, string $t = '') { return "{$t}\${$anchor}->setPrefix({$var})"; } diff --git a/class/Form/FormRadio.php b/class/Form/FormRadio.php index 23bef86c..df10ea43 100644 --- a/class/Form/FormRadio.php +++ b/class/Form/FormRadio.php @@ -31,8 +31,8 @@ public function render() { $ret = ''; $ele_name = $this->getName(); - $ele_title = (string)$this->getTitle(); - $ele_value = (string)$this->getValue(); + $ele_title = $this->getTitle(); + $ele_value = $this->getValue(); $ele_options = $this->getOptions(); $ele_extra = $this->getExtra(); $ele_delimeter = empty($this->columns) ? $this->getDelimeter() : ''; diff --git a/class/Form/FormRaw.php b/class/Form/FormRaw.php index 221feef4..35dfc1e1 100644 --- a/class/Form/FormRaw.php +++ b/class/Form/FormRaw.php @@ -34,7 +34,7 @@ class FormRaw extends \XoopsFormElement * * @param string $value value */ - public function __construct($value = '') + public function __construct(string $value = '') { $this->setValue($value); } diff --git a/class/Form/FormTab.php b/class/Form/FormTab.php index 03420d21..53369760 100644 --- a/class/Form/FormTab.php +++ b/class/Form/FormTab.php @@ -50,7 +50,6 @@ public function __construct($caption, $name) public function render() { $ret = ''; - /** @var \XoopsFormElement $ele */ foreach ($this->getElements() as $ele) { $ret .= NWLINE; $ret .= '
' . NWLINE; diff --git a/class/Form/FormTabTray.php b/class/Form/FormTabTray.php index 5198a0a9..fae47ebb 100644 --- a/class/Form/FormTabTray.php +++ b/class/Form/FormTabTray.php @@ -48,7 +48,7 @@ class FormTabTray extends \XoopsFormElementTray * @param string $uiTheme Theme to use for jquery UI (remove? now set by theme) * @param string $delimiter delimiter */ - public function __construct($caption, $name, $uiTheme = 'base', $delimiter = ' ') + public function __construct($caption, $name, $uiTheme = 'base', string $delimiter = ' ') { $this->setName($name); $this->setCaption($caption); diff --git a/class/Form/ThemeForm.php b/class/Form/ThemeForm.php index a87c5ac4..3a37ca3b 100644 --- a/class/Form/ThemeForm.php +++ b/class/Form/ThemeForm.php @@ -51,7 +51,7 @@ public function render() //$ret = ($this->getTitle() ? '
' . $this->getTitle() . '
' : ''); $ret = NWLINE . 'getExtra() . '>' . NWLINE; $hidden = ''; - $class = 'even'; + //$class = 'even'; foreach ($this->getElements() as $ele) { if (!is_object($ele)) { $ret .= $ele; @@ -64,7 +64,7 @@ public function render() } } $ret .= NWLINE . ' ' . $hidden . NWLINE . ''; - $ret .= $this->renderValidationJS(true); + $ret .= $this->renderValidationJS(); return $ret; } diff --git a/class/Helper.php b/class/Helper.php index 613be9b3..090b8897 100644 --- a/class/Helper.php +++ b/class/Helper.php @@ -42,7 +42,7 @@ public function __construct($debug = false) * * @return \XoopsModules\Modulebuilder\Helper */ - public static function getInstance($debug = false) + public static function getInstance(bool $debug = false) { static $instance; if (null === $instance) { diff --git a/class/Html/FormLabel.php b/class/Html/FormLabel.php index f9940d98..af6ea50a 100644 --- a/class/Html/FormLabel.php +++ b/class/Html/FormLabel.php @@ -29,7 +29,7 @@ class FormLabel extends \XoopsFormElement /** * @param string $caption */ - public function __construct($caption = '') + public function __construct(string $caption = '') { $this->setCaption($caption); } diff --git a/class/Import.php b/class/Import.php index b279f368..54a084b3 100644 --- a/class/Import.php +++ b/class/Import.php @@ -74,7 +74,7 @@ public static function importModule(): array if ($modulesHandler->insert($newModuleObj)) { // get the ID of the new module $criteria = new \Criteria('mod_name', $moduleNewName); - $moduleObject = $modulesHandler->getObjects($criteria, false, true); + $moduleObject = $modulesHandler->getObjects($criteria); $moduleId = $moduleObject[0]->getVar('mod_id'); $tables = self::importTables($moduleId, $moduleName); if (null === $tables) { @@ -258,7 +258,7 @@ public static function importTables($moduleId, $moduleName): ?array * * @return array */ - public static function importFields($tableName) + public static function importFields(string $tableName) { $table = $GLOBALS['xoopsDB']->prefix((string)$tableName); $sql = 'SHOW COLUMNS FROM ' . $table; diff --git a/class/Logo.php b/class/Logo.php index 2cf921ad..64165fa5 100644 --- a/class/Logo.php +++ b/class/Logo.php @@ -128,7 +128,7 @@ public static function createLogo($logoIcon, $moduleDirname) // Write text $textColor = imagecolorallocate($imageModule, 0, 0, 0); $spaceToBorder = (92 - mb_strlen($moduleDirname) * 7.5) / 2; - imagefttext($imageModule, 8.5, 0, $spaceToBorder, 45, $textColor, $font, \ucfirst($moduleDirname), []); + imagefttext($imageModule, 8.5, 0, $spaceToBorder, 45, $textColor, $font, \ucfirst($moduleDirname)); imagecopy($imageModule, $imageIcon, 29, 2, 0, 0, 32, 32); diff --git a/class/LogoGenerator.php b/class/LogoGenerator.php index 10974a58..b2449770 100644 --- a/class/LogoGenerator.php +++ b/class/LogoGenerator.php @@ -28,7 +28,7 @@ /** * @param string $val */ -function phpFunction($val = ''): void +function phpFunction(string $val = ''): void { // create php function here echo $val; @@ -86,7 +86,7 @@ public static function createLogo($logoIcon, $moduleName) // Write text $textColor = imagecolorallocate($imageModule, 0, 0, 0); $spaceToBorder = (int)\floor((92 - mb_strlen($moduleName) * 7.5) / 2); - imagefttext($imageModule, 8.5, 0, $spaceToBorder, 45, $textColor, $font, $moduleName, []); + imagefttext($imageModule, 8.5, 0, $spaceToBorder, 45, $textColor, $font, $moduleName); imagecopy($imageModule, $imageIcon, 29, 2, 0, 0, 32, 32); diff --git a/class/Modules.php b/class/Modules.php index cf4e6a48..230ef42e 100644 --- a/class/Modules.php +++ b/class/Modules.php @@ -46,7 +46,6 @@ class Modules extends \XoopsObject /** * @public function constructor class - * @param null */ public function __construct() { @@ -97,11 +96,11 @@ public function __construct() /** * @param string $method - * @param array $args + * @param array $args * * @return mixed */ - public function __call($method, $args) + public function __call(string $method, array $args) { $arg = $args[0] ?? null; @@ -110,7 +109,6 @@ public function __call($method, $args) /** * @static function getInstance - * @param null * @return Modules */ public static function getInstance() @@ -179,7 +177,7 @@ public function getFormModules($action = false) } $isNew = $this->isNew(); - $title = $isNew ? \sprintf(\_AM_MODULEBUILDER_MODULE_NEW) : \sprintf(\_AM_MODULEBUILDER_MODULE_EDIT); + $title = $isNew ? \_AM_MODULEBUILDER_MODULE_NEW : \_AM_MODULEBUILDER_MODULE_EDIT; require_once \XOOPS_ROOT_PATH . '/class/xoopsformloader.php'; @@ -362,7 +360,7 @@ public function getFormModules($action = false) * * @return bool|string */ - private static function createLogo($logoIcon, $moduleDirname) + private static function createLogo($logoIcon, string $moduleDirname) { if (!\extension_loaded('gd')) { return false; @@ -384,7 +382,7 @@ private static function createLogo($logoIcon, $moduleDirname) // Write text $textColor = imagecolorallocate($imageModule, 0, 0, 0); $spaceBorder = (92 - mb_strlen($moduleDirname) * 7.5) / 2; - imagefttext($imageModule, 8.5, 0, $spaceBorder, 45, $textColor, $font, \ucfirst($moduleDirname), []); + imagefttext($imageModule, 8.5, 0, $spaceBorder, 45, $textColor, $font, \ucfirst($moduleDirname)); imagecopy($imageModule, $imageIcon, 29, 2, 0, 0, 32, 32); $logoImg = '/' . 'logoModule.png'; \imagepng($imageModule, TDMC_UPLOAD_IMGMOD_PATH . $logoImg); diff --git a/class/ModulesHandler.php b/class/ModulesHandler.php index b25656c9..955ed9be 100644 --- a/class/ModulesHandler.php +++ b/class/ModulesHandler.php @@ -52,21 +52,20 @@ public function create($isNew = true) /** * retrieve a field. * - * @param int $i field id + * @param int $id field id * @param null $fields * - * @return mixed reference to the Fields object + * @return \XoopsObject|null reference to the Fields object * object */ - public function get($i = null, $fields = null) + public function get($id = null, $fields = null) { - return parent::get($i, $fields); + return parent::get($id, $fields); } /** * get inserted id. * - * @param null * * @return int reference to the {@link Tables} object */ @@ -78,14 +77,14 @@ public function getInsertId() /** * Get Count Modules. * - * @param int $start - * @param int $limit + * @param int $start + * @param int $limit * @param string $sort * @param string $order * * @return int */ - public function getCountModules($start = 0, $limit = 0, $sort = 'mod_id', $order = 'DESC') + public function getCountModules(int $start = 0, int $limit = 0, string $sort = 'mod_id', string $order = 'DESC') { $crCountModules = new \CriteriaCompo(); $crCountModules = $this->getModulesCriteria($crCountModules, $start, $limit, $sort, $order); @@ -96,14 +95,14 @@ public function getCountModules($start = 0, $limit = 0, $sort = 'mod_id', $order /** * Get All Modules. * - * @param int $start - * @param int $limit + * @param int $start + * @param int $limit * @param string $sort * @param string $order * * @return array */ - public function getAllModules($start = 0, $limit = 0, $sort = 'mod_id', $order = 'DESC') + public function getAllModules(int $start = 0, int $limit = 0, string $sort = 'mod_id', string $order = 'DESC') { $crAllModules = new \CriteriaCompo(); $crAllModules = $this->getModulesCriteria($crAllModules, $start, $limit, $sort, $order); diff --git a/class/Morefiles.php b/class/Morefiles.php index 65d13d05..79d925b1 100644 --- a/class/Morefiles.php +++ b/class/Morefiles.php @@ -39,7 +39,6 @@ class Morefiles extends \XoopsObject /** * @public function constructor class * - * @param null */ public function __construct() { @@ -54,11 +53,11 @@ public function __construct() /** * @param string $method - * @param array $args + * @param array $args * * @return mixed */ - public function __call($method, $args) + public function __call(string $method, array $args) { $arg = $args[0] ?? null; @@ -68,7 +67,6 @@ public function __call($method, $args) /** * @static function getInstance * - * @param null * * @return Morefiles */ @@ -96,7 +94,7 @@ public function getFormMorefiles($action = false) } $isNew = $this->isNew(); - $title = $isNew ? \sprintf(\_AM_MODULEBUILDER_MORE_FILES_NEW) : \sprintf(\_AM_MODULEBUILDER_MORE_FILES_EDIT); + $title = $isNew ? \_AM_MODULEBUILDER_MORE_FILES_NEW : \_AM_MODULEBUILDER_MORE_FILES_EDIT; \xoops_load('XoopsFormLoader'); @@ -137,7 +135,7 @@ public function getFormMorefiles($action = false) $fileSelect->addOption("{$file1}", $file1); } } - $fileTray->addElement($fileSelect, false); + $fileTray->addElement($fileSelect); $form->addElement($fileTray); $fileInfolder = new \XoopsFormText(\_AM_MODULEBUILDER_MORE_FILES_INFOLDER, 'file_infolder', 50, 255, $this->getVar('file_infolder')); diff --git a/class/MorefilesHandler.php b/class/MorefilesHandler.php index 74ecac64..9fffe629 100644 --- a/class/MorefilesHandler.php +++ b/class/MorefilesHandler.php @@ -52,21 +52,20 @@ public function create($isNew = true) /** * retrieve a field. * - * @param int $i field id + * @param int $id field id * @param null $fields * - * @return mixed reference to the Fields object + * @return \XoopsObject|null reference to the Fields object * object */ - public function get($i = null, $fields = null) + public function get($id = null, $fields = null) { - return parent::get($i, $fields); + return parent::get($id, $fields); } /** * get inserted id. * - * @param null * * @return int reference to the {@link Tables} object */ @@ -78,14 +77,14 @@ public function getInsertId() /** * Get Count Morefiles. * - * @param int $start - * @param int $limit + * @param int $start + * @param int $limit * @param string $sort * @param string $order * * @return int */ - public function getCountMorefiles($start = 0, $limit = 0, $sort = 'file_id ASC, file_name', $order = 'ASC') + public function getCountMorefiles(int $start = 0, int $limit = 0, string $sort = 'file_id ASC, file_name', string $order = 'ASC') { $crMorefilesCount = new \CriteriaCompo(); $crMorefilesCount = $this->getMorefilesCriteria($crMorefilesCount, $start, $limit, $sort, $order); @@ -96,14 +95,14 @@ public function getCountMorefiles($start = 0, $limit = 0, $sort = 'file_id ASC, /** * Get All Morefiles. * - * @param int $start - * @param int $limit + * @param int $start + * @param int $limit * @param string $sort * @param string $order * * @return array */ - public function getAllMorefiles($start = 0, $limit = 0, $sort = 'file_id ASC, file_name', $order = 'ASC') + public function getAllMorefiles(int $start = 0, int $limit = 0, string $sort = 'file_id ASC, file_name', string $order = 'ASC') { $crMorefilesAdd = new \CriteriaCompo(); $crMorefilesAdd = $this->getMorefilesCriteria($crMorefilesAdd, $start, $limit, $sort, $order); @@ -115,14 +114,14 @@ public function getAllMorefiles($start = 0, $limit = 0, $sort = 'file_id ASC, fi * Get All Morefiles By Module Id. * * @param $modId - * @param int $start - * @param int $limit + * @param int $start + * @param int $limit * @param string $sort * @param string $order * * @return array */ - public function getAllMorefilesByModuleId($modId, $start = 0, $limit = 0, $sort = 'file_id ASC, file_name', $order = 'ASC') + public function getAllMorefilesByModuleId($modId, int $start = 0, int $limit = 0, string $sort = 'file_id ASC, file_name', string $order = 'ASC') { $crMorefilesByModuleId = new \CriteriaCompo(); $crMorefilesByModuleId->add(new \Criteria('file_mid', $modId)); diff --git a/class/Session.php b/class/Session.php index 27cb300e..74e87881 100644 --- a/class/Session.php +++ b/class/Session.php @@ -68,7 +68,7 @@ public static function getInstance() * @param string $name name of variable * @param mixed $value value of variable */ - public function setSession($name, $value): void + public function setSession(string $name, $value): void { $_SESSION[$name] = $value; } @@ -80,7 +80,7 @@ public function setSession($name, $value): void * * @return mixed value of session variable */ - public function getSession($name) + public function getSession(string $name) { if (isset($_SESSION[$name])) { return $_SESSION[$name]; @@ -94,7 +94,7 @@ public function getSession($name) * * @param string $name name of variable */ - public function deleteSession($name): void + public function deleteSession(string $name): void { unset($_SESSION[$name]); } diff --git a/class/Settings.php b/class/Settings.php index 1ad122b6..7386dbac 100644 --- a/class/Settings.php +++ b/class/Settings.php @@ -52,7 +52,6 @@ class Settings extends \XoopsObject /** * @public function constructor class * - * @param null */ public function __construct() { @@ -101,11 +100,11 @@ public function __construct() /** * @param string $method - * @param array $args + * @param array $args * * @return mixed */ - public function __call($method, $args) + public function __call(string $method, array $args) { $arg = $args[0] ?? null; @@ -115,7 +114,6 @@ public function __call($method, $args) /** * @static function getInstance * - * @param null * * @return Settings */ @@ -143,7 +141,7 @@ public function getFormSettings($action = false) } $isNew = $this->isNew(); - $title = $isNew ? \sprintf(\_AM_MODULEBUILDER_SETTING_NEW) : \sprintf(\_AM_MODULEBUILDER_SETTING_EDIT); + $title = $isNew ? \_AM_MODULEBUILDER_SETTING_NEW : \_AM_MODULEBUILDER_SETTING_EDIT; require_once \XOOPS_ROOT_PATH . '/class/xoopsformloader.php'; diff --git a/class/SettingsHandler.php b/class/SettingsHandler.php index 1a7fbead..6589408c 100644 --- a/class/SettingsHandler.php +++ b/class/SettingsHandler.php @@ -49,21 +49,20 @@ public function create($isNew = true) /** * retrieve a field. * - * @param int $i field id + * @param int $id field id * @param null $fields * - * @return mixed reference to the Settings object + * @return \XoopsObject|null reference to the Settings object * object */ - public function get($i = null, $fields = null) + public function get($id = null, $fields = null) { - return parent::get($i, $fields); + return parent::get($id, $fields); } /** * get inserted id. * - * @param null * * @return int reference to the {@link Tables} object */ @@ -75,14 +74,14 @@ public function getInsertId() /** * Get Count Settings. * - * @param int $start - * @param int $limit + * @param int $start + * @param int $limit * @param string $sort * @param string $order * * @return int */ - public function getCountSettings($start = 0, $limit = 0, $sort = 'set_id ASC, set_name', $order = 'ASC') + public function getCountSettings(int $start = 0, int $limit = 0, string $sort = 'set_id ASC, set_name', string $order = 'ASC') { $crCountSettings = new \CriteriaCompo(); $crCountSettings = $this->getSettingsCriteria($crCountSettings, $start, $limit, $sort, $order); @@ -93,14 +92,14 @@ public function getCountSettings($start = 0, $limit = 0, $sort = 'set_id ASC, se /** * Get All Settings. * - * @param int $start - * @param int $limit + * @param int $start + * @param int $limit * @param string $sort * @param string $order * * @return array */ - public function getAllSettings($start = 0, $limit = 0, $sort = 'set_id ASC, set_name', $order = 'ASC') + public function getAllSettings(int $start = 0, int $limit = 0, string $sort = 'set_id ASC, set_name', string $order = 'ASC') { $crAllSettings = new \CriteriaCompo(); $crAllSettings = $this->getSettingsCriteria($crAllSettings, $start, $limit, $sort, $order); diff --git a/class/SplClassLoader.php b/class/SplClassLoader.php index 210c7f75..29ca1d9f 100644 --- a/class/SplClassLoader.php +++ b/class/SplClassLoader.php @@ -49,10 +49,10 @@ class SplClassLoader * Creates a new SplClassLoader that loads classes of the * specified namespace. * - * @param string $ns The namespace to use + * @param string|null $ns The namespace to use * @param null $includePath */ - public function __construct($ns = null, $includePath = null) + public function __construct(string $ns = null, $includePath = null) { $this->_namespace = $ns; $this->_includePath = $includePath; @@ -63,7 +63,7 @@ public function __construct($ns = null, $includePath = null) * * @param string $sep The separator to use */ - public function setNamespaceSeparator($sep): void + public function setNamespaceSeparator(string $sep): void { $this->_namespaceSeparator = $sep; } @@ -81,7 +81,7 @@ public function getNamespaceSeparator() * * @param string $includePath */ - public function setIncludePath($includePath): void + public function setIncludePath(string $includePath): void { $this->_includePath = $includePath; } @@ -89,7 +89,7 @@ public function setIncludePath($includePath): void /** * Gets the base include path for all class files in the namespace of this class loader. * - * @return string + * @return string|null */ public function getIncludePath() { @@ -101,7 +101,7 @@ public function getIncludePath() * * @param string $fileExtension */ - public function setFileExtension($fileExtension): void + public function setFileExtension(string $fileExtension): void { $this->_fileExtension = $fileExtension; } @@ -137,7 +137,7 @@ public function unregister(): void * * @param string $className The name of the class to load */ - public function loadClass($className): void + public function loadClass(string $className): void { if (null === $this->_namespace || $this->_namespace . $this->_namespaceSeparator === mb_substr($className, 0, mb_strlen($this->_namespace . $this->_namespaceSeparator))) { $fileName = ''; diff --git a/class/Tables.php b/class/Tables.php index 94a3ec52..a9cd9340 100644 --- a/class/Tables.php +++ b/class/Tables.php @@ -58,7 +58,6 @@ class Tables extends \XoopsObject /** * @public function constructor class - * @param null */ public function __construct() { @@ -96,11 +95,11 @@ public function __construct() /** * @param string $method - * @param array $args + * @param array $args * * @return mixed */ - public function __call($method, $args) + public function __call(string $method, array $args) { $arg = $args[0] ?? null; @@ -109,7 +108,6 @@ public function __call($method, $args) /** * @static function getInstance - * @param null * @return Tables */ public static function getInstance() @@ -137,7 +135,7 @@ public function getFormTables($action = false) $isNew = $this->isNew(); $tableName = $this->getVar('table_name'); $tableMid = $this->getVar('table_mid'); - $title = $isNew ? \sprintf(\_AM_MODULEBUILDER_TABLES_NEW) : \sprintf(\_AM_MODULEBUILDER_TABLES_EDIT); + $title = $isNew ? \_AM_MODULEBUILDER_TABLES_NEW : \_AM_MODULEBUILDER_TABLES_EDIT; \xoops_load('XoopsFormLoader'); $form = new \XoopsThemeForm($title, 'tableform', $action, 'post', true); @@ -196,7 +194,7 @@ public function getFormTables($action = false) $imageSelect1->addOption($image1, $image1); } $imageSelect1->setExtra("onchange='showImgSelected(\"image1\", \"table_image\", \"" . $iconsDirectory . '", "", "' . \XOOPS_URL . "\")'"); - $imgtray1->addElement($imageSelect1, false); + $imgtray1->addElement($imageSelect1); $imgtray1->addElement(new \XoopsFormLabel('', "
")); $fileseltray1 = new \XoopsFormElementTray('', '
'); $fileseltray1->addElement(new \XoopsFormFile(\_AM_MODULEBUILDER_FORMUPLOAD, 'attachedfile', $helper->getConfig('maxsize_image'))); diff --git a/class/TablesHandler.php b/class/TablesHandler.php index 54d6bd4f..da9d9fb2 100644 --- a/class/TablesHandler.php +++ b/class/TablesHandler.php @@ -54,21 +54,20 @@ public function create($isNew = true) /** * retrieve a field. * - * @param int $i field id + * @param int $id field id * @param null $fields * - * @return mixed reference to the Fields object + * @return \XoopsObject|null reference to the Fields object * object */ - public function get($i = null, $fields = null) + public function get($id = null, $fields = null) { - return parent::get($i, $fields); + return parent::get($id, $fields); } /** * get inserted id. * - * @param null * * @return int reference to the {@link Tables} object */ @@ -80,14 +79,14 @@ public function getInsertId() /** * Get Count Modules. * - * @param int $start - * @param int $limit + * @param int $start + * @param int $limit * @param string $sort * @param string $order * * @return int */ - public function getCountTables($start = 0, $limit = 0, $sort = 'table_id ASC, table_name', $order = 'ASC') + public function getCountTables(int $start = 0, int $limit = 0, string $sort = 'table_id ASC, table_name', string $order = 'ASC') { $crCountTables = new \CriteriaCompo(); $crCountTables = $this->getTablesCriteria($crCountTables, $start, $limit, $sort, $order); @@ -98,14 +97,14 @@ public function getCountTables($start = 0, $limit = 0, $sort = 'table_id ASC, ta /** * Get All Modules. * - * @param int $start - * @param int $limit + * @param int $start + * @param int $limit * @param string $sort * @param string $order * * @return array */ - public function getAllTables($start = 0, $limit = 0, $sort = 'table_mid DESC, table_order ASC, table_id', $order = 'DESC') + public function getAllTables(int $start = 0, int $limit = 0, string $sort = 'table_mid DESC, table_order ASC, table_id', string $order = 'DESC') { $crAllTables = new \CriteriaCompo(); $crAllTables = $this->getTablesCriteria($crAllTables, $start, $limit, $sort, $order); @@ -117,14 +116,14 @@ public function getAllTables($start = 0, $limit = 0, $sort = 'table_mid DESC, ta * Get All Tables By Module Id. * * @param $modId - * @param int $start - * @param int $limit + * @param int $start + * @param int $limit * @param string $sort * @param string $order * * @return array */ - public function getAllTablesByModuleId($modId, $start = 0, $limit = 0, $sort = 'table_order ASC, table_id, table_name', $order = 'ASC') + public function getAllTablesByModuleId($modId, int $start = 0, int $limit = 0, string $sort = 'table_order ASC, table_id, table_name', string $order = 'ASC') { $crAllTablesByModuleId = new \CriteriaCompo(); $crAllTablesByModuleId->add(new \Criteria('table_mid', $modId)); diff --git a/class/Utility.php b/class/Utility.php index 20f7ade0..18781adb 100644 --- a/class/Utility.php +++ b/class/Utility.php @@ -71,17 +71,15 @@ function xoopsFormValidate_donation() { var myform = window.document.donation; 5 => '', ]; for ($key = 0; $key <= 4; ++$key) { - switch ($key) { - case 2: - $donationform[$key] = \sprintf( - $donationform[$key], - $GLOBALS['xoopsConfig']['sitename'] . ' - ' . ('' != $GLOBALS['xoopsUser']->getVar('name') ? $GLOBALS['xoopsUser']->getVar('name') . ' [' . $GLOBALS['xoopsUser']->getVar('uname') . ']' : $GLOBALS['xoopsUser']->getVar('uname')), - $GLOBALS['xoopsUser']->getVar('email'), - \XOOPS_LICENSE_KEY, - \mb_strtoupper($GLOBALS['xoopsModule']->getVar('dirname')), - \mb_strtoupper($GLOBALS['xoopsModule']->getVar('dirname')) . ' ' . $GLOBALS['xoopsModule']->getVar('name') - ); - break; + if ($key == 2) { + $donationform[$key] = \sprintf( + $donationform[$key], + $GLOBALS['xoopsConfig']['sitename'] . ' - ' . ('' != $GLOBALS['xoopsUser']->getVar('name') ? $GLOBALS['xoopsUser']->getVar('name') . ' [' . $GLOBALS['xoopsUser']->getVar('uname') . ']' : $GLOBALS['xoopsUser']->getVar('uname')), + $GLOBALS['xoopsUser']->getVar('email'), + \XOOPS_LICENSE_KEY, + \mb_strtoupper($GLOBALS['xoopsModule']->getVar('dirname')), + \mb_strtoupper($GLOBALS['xoopsModule']->getVar('dirname')) . ' ' . $GLOBALS['xoopsModule']->getVar('name') + ); } } $aboutRes = ''; diff --git a/class/autoload.php b/class/autoload.php index f7a4aab4..e8086d34 100644 --- a/class/autoload.php +++ b/class/autoload.php @@ -39,7 +39,7 @@ function application_autoloader($class): void $classFilename = $class . '.php'; $cachePath = \XOOPS_VAR_PATH . '/caches/modulebuilder_cache'; if (!\is_dir($cachePath)) { - if (!\mkdir($cachePath, 0777) && !\is_dir($cachePath)) { + if (!\mkdir($cachePath) && !\is_dir($cachePath)) { throw new \RuntimeException(\sprintf('Directory "%s" was not created', $cachePath)); } chmod($cachePath, 0777); diff --git a/xoops_version.php b/xoops_version.php index 465f6584..11b4dd0c 100644 --- a/xoops_version.php +++ b/xoops_version.php @@ -25,9 +25,9 @@ $moduleDirName = \basename(__DIR__); $moduleDirNameUpper = \mb_strtoupper($moduleDirName); -$modversion['version'] = '3.7.0'; +$modversion['version'] = '3.7.1'; $modversion['module_status'] = 'Alpha'; -$modversion['release_date'] = '2023/07/06'; // format: yyyy/mm/dd +$modversion['release_date'] = '2026/04/05'; // format: yyyy/mm/dd $modversion['name'] = \_MI_MODULEBUILDER_NAME; $modversion['description'] = \_MI_MODULEBUILDER_DESC; $modversion['author'] = 'Xoops TDM'; @@ -54,8 +54,8 @@ $modversion['targetdir'] = XOOPS_UPLOAD_PATH . "/{$moduleDirName}/repository/"; $modversion['module_website_url'] = 'https://github.com/XoopsModules25x/modulebuilder'; $modversion['module_website_name'] = 'GitHub Xoops'; -$modversion['min_php'] = '7.4'; -$modversion['min_xoops'] = '2.5.11-RC2'; +$modversion['min_php'] = '8.3'; +$modversion['min_xoops'] = '2.5.11'; $modversion['min_admin'] = '1.2'; $modversion['min_db'] = ['mysql' => '5.5']; //about From be917c6d87e73308f8faa720725b31b3c79ef33d Mon Sep 17 00:00:00 2001 From: "NB-GABOR02\\Goffy" Date: Tue, 7 Apr 2026 20:05:41 +0200 Subject: [PATCH 2/7] corrections coderabbigtai 1 --- class/Building.php | 4 ++-- class/Common/DirectoryChecker.php | 11 +++++----- class/Common/FileChecker.php | 22 +++++++++---------- class/Common/Migrate.php | 2 +- class/Common/TableChecker.php | 2 +- class/Common/VersionChecks.php | 2 +- class/Devtools.php | 17 +++++++------- class/Files/Admin/AdminBroken.php | 4 ++-- class/Files/Admin/AdminPermissions.php | 2 +- class/Files/Blocks/BlocksFiles.php | 2 +- class/Files/Classes/ClassFiles.php | 2 +- class/Files/CreateClone.php | 17 ++++++++++---- class/Files/CreatePhpCode.php | 17 +++++--------- class/Files/CreateStructure.php | 20 +++++++++-------- class/Files/CreateXoopsCode.php | 17 +++++--------- class/Files/Includes/IncludeNotifications.php | 8 +++---- class/Files/Language/LanguageHelp.php | 2 +- class/Files/Sql/SqlFile.php | 2 +- .../Templates/Admin/TemplatesAdminBroken.php | 2 +- .../Templates/User/Defstyle/Categories.php | 4 ++-- .../Templates/User/Defstyle/MoreFiles.php | 2 +- .../Templates/User/Defstyle/PagesItem.php | 4 ++-- .../Templates/User/Defstyle/PagesList.php | 2 +- class/Files/User/UserIndex.php | 4 ++-- class/Files/User/UserPages.php | 2 +- class/Files/User/UserPdf.php | 4 ++-- class/Files/User/UserRate.php | 6 ++--- class/Files/admin/AdminPages.php | 4 ++-- class/Form/FormRadio.php | 4 ++-- class/Helper.php | 2 +- class/LogoGenerator.php | 4 +++- class/Modules.php | 2 +- class/SplClassLoader.php | 4 ++-- class/Utility.php | 2 +- 34 files changed, 102 insertions(+), 103 deletions(-) diff --git a/class/Building.php b/class/Building.php index eaf07224..5bd7f965 100644 --- a/class/Building.php +++ b/class/Building.php @@ -46,11 +46,11 @@ public static function getInstance() } /** - * @param bool $action + * @param string|bool $action * * @return \XoopsThemeForm */ - public function getForm(bool $action = false) + public function getForm(string|bool $action = false) { $helper = Modulebuilder\Helper::getInstance(); if (false === $action) { diff --git a/class/Common/DirectoryChecker.php b/class/Common/DirectoryChecker.php index 5ad1d848..4aeb0f0f 100644 --- a/class/Common/DirectoryChecker.php +++ b/class/Common/DirectoryChecker.php @@ -134,12 +134,11 @@ public static function dirExists($dir_path) $op = Request::getString('op', '', 'POST'); switch ($op) { case 'createdir': - if (\Xmf\Request::hasVar('path', 'POST')) { - $path = $_POST['path']; - } - if (\Xmf\Request::hasVar('redirect', 'POST')) { - $redirect = $_POST['redirect']; + if (!\Xmf\Request::hasVar('path', 'POST') || !\Xmf\Request::hasVar('redirect', 'POST')) { + break; } + $path = $_POST['path']; + $redirect = $_POST['redirect']; $msg = DirectoryChecker::createDirectory($path) ? \constant('CO_' . $moduleDirNameUpper . '_' . 'DC_DIRCREATED') : \constant('CO_' . $moduleDirNameUpper . '_' . 'DC_DIRNOTCREATED'); \redirect_header($redirect, 2, $msg . ': ' . $path); break; @@ -153,7 +152,7 @@ public static function dirExists($dir_path) if (\Xmf\Request::hasVar('mode', 'POST')) { $mode = $_POST['mode']; } - $msg = DirectoryChecker::setDirectoryPermissions($path, $mode) ? \constant('CO_' . $moduleDirNameUpper . '_' . 'DC_PERMSET') : \constant('CO_' . $moduleDirNameUpper . '_' . 'DC_PERMNOTSET'); + $msg = DirectoryChecker::setDirectoryPermissions($path, (int)$mode) ? \constant('CO_' . $moduleDirNameUpper . '_' . 'DC_PERMSET') : \constant('CO_' . $moduleDirNameUpper . '_' . 'DC_PERMNOTSET'); \redirect_header($redirect, 2, $msg . ': ' . $path); break; } diff --git a/class/Common/FileChecker.php b/class/Common/FileChecker.php index 638475fa..c05e0e1a 100644 --- a/class/Common/FileChecker.php +++ b/class/Common/FileChecker.php @@ -38,11 +38,12 @@ class FileChecker { /** * @param string $file_path - * @param string|null $original_file_path * @param string $redirectFile + * @param string|null $original_file_path + * * @return bool|string */ - public static function getFileStatus(string $file_path, string $original_file_path = null, string $redirectFile) + public static function getFileStatus(string $file_path, string $redirectFile, string $original_file_path = null) { $pathIcon16 = \Xmf\Module\Admin::iconUrl('', '16'); @@ -145,15 +146,14 @@ public static function setFilePermissions($target, int $mode = 0777) $op = Request::getString('op', '', 'POST'); if ($op == 'copyfile') { - if (\Xmf\Request::hasVar('original_file_path', 'POST')) { - $original_file_path = $_POST['original_file_path']; - } - if (\Xmf\Request::hasVar('file_path', 'POST')) { - $file_path = $_POST['file_path']; - } - if (\Xmf\Request::hasVar('redirect', 'POST')) { - $redirect = $_POST['redirect']; - } + if (!\Xmf\Request::hasVar('original_file_path', 'POST') + || !\Xmf\Request::hasVar('file_path', 'POST') + || !\Xmf\Request::hasVar('redirect', 'POST')) { + return; + } + $original_file_path = $_POST['original_file_path']; + $file_path = $_POST['file_path']; + $redirect = $_POST['redirect']; $msg = FileChecker::copyFile($original_file_path, $file_path) ? \constant('CO_' . $moduleDirNameUpper . '_' . 'FC_FILECOPIED') : \constant('CO_' . $moduleDirNameUpper . '_' . 'FC_FILENOTCOPIED'); \redirect_header($redirect, 2, $msg . ': ' . $file_path); } diff --git a/class/Common/Migrate.php b/class/Common/Migrate.php index d56fc374..c570a58b 100644 --- a/class/Common/Migrate.php +++ b/class/Common/Migrate.php @@ -58,7 +58,7 @@ private function changePrefix(): void * @param string $tableName table to convert * @param string $columnName column with IP address */ - private function convertIPAddresses(string $tableName, string $columnName): void + protected function convertIPAddresses(string $tableName, string $columnName): void { if ($this->tableHandler->useTable($tableName)) { $attributes = $this->tableHandler->getColumnAttributes($tableName, $columnName); diff --git a/class/Common/TableChecker.php b/class/Common/TableChecker.php index 5bf140a6..9fe70478 100644 --- a/class/Common/TableChecker.php +++ b/class/Common/TableChecker.php @@ -71,7 +71,7 @@ public function processSQL() if ($numRows) { //table exist $this->result[] = 'Table exist:' . $table; - //$ret = $this->checkTableFields($table, $tabledef['fields']); + $this->checkTableFields($table, $tabledef['fields']); } else { if ($this::CHECKTYPE_UPDATE == $this->checktype || $this::CHECKTYPE_UPDATE_REPORT == $this->checktype) { // create new table diff --git a/class/Common/VersionChecks.php b/class/Common/VersionChecks.php index fa19754f..a18c6f28 100644 --- a/class/Common/VersionChecks.php +++ b/class/Common/VersionChecks.php @@ -44,7 +44,7 @@ public static function checkVerXoops(\XoopsModule $module = null, $requiredVer = } $success = true; - if ($module->versionCompare($currentVer, $requiredVer)) { + if ($module->versionCompare($currentVer, $requiredVer, '<')) { $success = false; $module->setErrors(\sprintf(\constant('CO_' . $moduleDirNameUpper . '_ERROR_BAD_XOOPS'), $requiredVer, $currentVer)); } diff --git a/class/Devtools.php b/class/Devtools.php index 6481db7c..54b246cb 100644 --- a/class/Devtools.php +++ b/class/Devtools.php @@ -498,10 +498,10 @@ private static function cloneFile($src_file, $dst_file, array $patKeys, array $p /** * get form with all existing modules - * @param bool $action + * @param string|false $action * @return \XoopsSimpleForm */ - public static function getFormModulesFq(bool $action = false) + public static function getFormModulesFq(string|false $action = false) { if (!$action) { $action = $_SERVER['REQUEST_URI']; @@ -527,10 +527,10 @@ public static function getFormModulesFq(bool $action = false) /** * get form with all existing modules - * @param bool $action + * @param string|false $action * @return \XoopsSimpleForm */ - public static function getFormModulesCl(bool $action = false) + public static function getFormModulesCl(string|false $action = false) { if (!$action) { $action = $_SERVER['REQUEST_URI']; @@ -556,10 +556,10 @@ public static function getFormModulesCl(bool $action = false) /** * get form with all existing modules - * @param bool $action + * @param string|false $action * @return \XoopsSimpleForm */ - public static function getFormModulesTab(bool $action = false) + public static function getFormModulesTab(string|false $action = false) { if (!$action) { $action = $_SERVER['REQUEST_URI']; @@ -585,10 +585,11 @@ public static function getFormModulesTab(bool $action = false) /** * get form with all existing modules - * @param bool $action + * @param string $dst_path + * @param string|false $action * @return \XoopsSimpleForm */ - public static function getFormModulesRemovePrefix($dst_path, bool $action = false) + public static function getFormModulesRemovePrefix(string $dst_path, string|false $action = false) { if (!$action) { $action = $_SERVER['REQUEST_URI']; diff --git a/class/Files/Admin/AdminBroken.php b/class/Files/Admin/AdminBroken.php index 5f7755ed..0f615b6b 100644 --- a/class/Files/Admin/AdminBroken.php +++ b/class/Files/Admin/AdminBroken.php @@ -122,9 +122,9 @@ private function getAdminBrokenList($tables, string $language) $ucfTableName = \ucfirst($tableName); $ret .= $this->pc->getPhpCodeBlankLine(); $ret .= $this->pc->getPhpCodeCommentLine('Check table', $tableName, ''); - $ret .= $this->xc->getXcXoopsRequest('start', 'start' . $ucfTableName, '', 'Int', false, ''); + $ret .= $this->xc->getXcXoopsRequest('start', 'start' . $ucfTableName, '', 'Int', ''); $adminpager = $this->xc->getXcGetConfig('adminpager'); - $ret .= $this->xc->getXcXoopsRequest('limit', 'limit' . $ucfTableName, $adminpager, 'Int', false, ''); + $ret .= $this->xc->getXcXoopsRequest('limit', 'limit' . $ucfTableName, $adminpager, 'Int', ''); $critName = 'cr' . $ucfTableName; $fields = $this->getTableFields($tables[$i]->getVar('table_mid'), $tables[$i]->getVar('table_id')); diff --git a/class/Files/Admin/AdminPermissions.php b/class/Files/Admin/AdminPermissions.php index 18cf7d81..ac41eb0f 100644 --- a/class/Files/Admin/AdminPermissions.php +++ b/class/Files/Admin/AdminPermissions.php @@ -182,7 +182,7 @@ private function getPermissionsSwitch($module, $language) ]; } } - $contentSwitch = $this->pc->getPhpCodeCaseSwitch($cases, true, false, "\t"); + $contentSwitch = $this->pc->getPhpCodeCaseSwitch($cases, true,"\t"); return $this->pc->getPhpCodeSwitch('op', $contentSwitch); } diff --git a/class/Files/Blocks/BlocksFiles.php b/class/Files/Blocks/BlocksFiles.php index 382b2e00..718f1aa5 100644 --- a/class/Files/Blocks/BlocksFiles.php +++ b/class/Files/Blocks/BlocksFiles.php @@ -206,7 +206,7 @@ private function getBlocksShow($moduleDirname, $tableName, $tableFieldname, $tab 'top' => $case4, 'random' => $case5, ]; - $contSwitch = $this->pc->getPhpCodeCaseSwitch($cases, true, false, "\t\t"); + $contSwitch = $this->pc->getPhpCodeCaseSwitch($cases, true, "\t\t"); $contElse = $this->pc->getPhpCodeSwitch('typeBlock', $contSwitch, "\t"); //end: content else: parent if (1 == $fieldParent) { diff --git a/class/Files/Classes/ClassFiles.php b/class/Files/Classes/ClassFiles.php index 65e88cbe..86fd6147 100644 --- a/class/Files/Classes/ClassFiles.php +++ b/class/Files/Classes/ClassFiles.php @@ -481,7 +481,7 @@ private function getValuesInObject($moduleDirname, $table, $fields) $contCase5 = $this->xc->getXcEqualsOperator('$status_text', $language . 'STATUS_BROKEN', false, "\t\t\t\t"); $cases[$this->xc->getXcGetConstants('STATUS_BROKEN')] = [$contCase5]; } - $contentSwitch = $this->pc->getPhpCodeCaseSwitch($cases, true, false, "\t\t\t", true); + $contentSwitch = $this->pc->getPhpCodeCaseSwitch($cases, true, "\t\t\t", true); $getValues .= $this->pc->getPhpCodeSwitch('status', $contentSwitch, "\t\t"); $len = $lenMaxName - \mb_strlen('status_text'); $spacer = $len > 0 ? str_repeat(' ', $len) : ''; diff --git a/class/Files/CreateClone.php b/class/Files/CreateClone.php index 91fae5c7..2d5665f0 100644 --- a/class/Files/CreateClone.php +++ b/class/Files/CreateClone.php @@ -68,20 +68,29 @@ public static function cloneFile($src_file, $dst_file, bool $replace_code = fals $noChangeExtensions = ['jpeg', 'jpg', 'gif', 'png', 'zip', 'ttf']; if (\in_array(\mb_strtolower(\pathinfo($src_file, PATHINFO_EXTENSION)), $noChangeExtensions)) { // image - \copy($src_file, $dst_file); + if (!\copy($src_file, $dst_file)) { + throw new \RuntimeException("Unable to copy {$src_file} to {$dst_file}"); + } } else { // file, read it and replace text - $content = file_get_contents($src_file); + $content = \file_get_contents($src_file); + if (false === $content) { + throw new \RuntimeException("Unable to read source file: {$src_file}"); + } $content = \str_replace($patKeys, $patValues, $content); //check file name whether it contains replace code $path_parts = \pathinfo($dst_file); $path = $path_parts['dirname']; $file = $path_parts['basename']; $dst_file = $path . '/' . \str_replace($patKeys, $patValues, $file); - file_put_contents($dst_file, $content); + if (false === \file_put_contents($dst_file, $content)) { + throw new \RuntimeException("Unable to write destination file: {$dst_file}"); + } } } else { - \copy($src_file, $dst_file); + if (!\copy($src_file, $dst_file)) { + throw new \RuntimeException("Unable to copy {$src_file} to {$dst_file}"); + } } } } diff --git a/class/Files/CreatePhpCode.php b/class/Files/CreatePhpCode.php index 8908ab15..b57e2823 100644 --- a/class/Files/CreatePhpCode.php +++ b/class/Files/CreatePhpCode.php @@ -470,13 +470,11 @@ public function getPhpCodeSwitch($op = null, $content = null, string $t = '', bo * * @param array $cases * @param bool $defaultAfterCase - * @param bool $default * @param string $t - * * @param bool $isConst * @return string */ - public function getPhpCodeCaseSwitch(array $cases = [], bool $defaultAfterCase = false, bool $default = false, string $t = '', bool $isConst = false) + public function getPhpCodeCaseSwitch(array $cases = [], bool $defaultAfterCase = false, string $t = '', bool $isConst = false) { $ret = ''; $def = "{$t}default:\n"; @@ -502,11 +500,6 @@ public function getPhpCodeCaseSwitch(array $cases = [], bool $defaultAfterCase = $defaultAfterCase = false; } } - if (false !== $default) { - $ret .= $def; - $ret .= "{$t}{$default}\n"; - $ret .= "{$t}\tbreak;\n"; - } return $ret; } @@ -791,10 +784,10 @@ public function getPhpCodeStripTags($left, $value, bool $isParam = false, string /** * @public function getPhpCodeHtmlentities * @param $entitiesVar - * @param bool $entitiesQuote + * @param int|string|false $entitiesQuote * @return string */ - public function getPhpCodeHtmlentities($entitiesVar, bool $entitiesQuote = false) + public function getPhpCodeHtmlentities($entitiesVar, int|string|false $entitiesQuote = false) { $entitiesVar = (false !== $entitiesQuote) ? $entitiesVar . ', ' . $entitiesQuote : $entitiesVar; return "htmlentities({$entitiesVar})"; @@ -803,10 +796,10 @@ public function getPhpCodeHtmlentities($entitiesVar, bool $entitiesQuote = false /** * @public function getPhpCodeHtmlspecialchars * @param $specialVar - * @param bool $specialQuote + * @param int|string|false $specialQuote * @return string */ - public function getPhpCodeHtmlspecialchars($specialVar, bool $specialQuote = false) + public function getPhpCodeHtmlspecialchars($specialVar, int|string|false $specialQuote = false) { $specialVar = (false !== $specialQuote) ? $specialVar . ', ' . $specialQuote : $specialVar; return "htmlspecialchars({$specialVar})"; diff --git a/class/Files/CreateStructure.php b/class/Files/CreateStructure.php index 0cbb2d76..ca933992 100644 --- a/class/Files/CreateStructure.php +++ b/class/Files/CreateStructure.php @@ -173,7 +173,7 @@ protected function makeDir(string $dir): void } /** - * @protected function isDirEmpty + * function isDirEmpty * * @param string $dir * @@ -181,19 +181,19 @@ protected function makeDir(string $dir): void */ public function isDirEmpty(string $dir) { - $content = []; - $handle = \opendir($dir); + $handle = \opendir($dir); + if (false === $handle) { + throw new \RuntimeException(\sprintf('Directory "%s" cannot be opened', $dir)); + } while (false !== ($entry = \readdir($handle))) { if ('.' !== $entry && '..' !== $entry) { - $content[] = $entry; + \closedir($handle); + return false; } } \closedir($handle); - if (\count($content) > 0) { - return true; - } - return false; + return true; } /** @@ -269,6 +269,8 @@ public function setCopy(string $dname, string $fromFile, string $fname): void } else { $this->makeDir($dname); } - \copy($fromFile, $fname); + if (!\copy($fromFile, $fname)) { + throw new \RuntimeException(\sprintf('Failed to copy "%s" to "%s"', $fromFile, $fname)); + } } } diff --git a/class/Files/CreateXoopsCode.php b/class/Files/CreateXoopsCode.php index e0e24ad5..0130c218 100644 --- a/class/Files/CreateXoopsCode.php +++ b/class/Files/CreateXoopsCode.php @@ -50,17 +50,15 @@ public static function getInstance() * @param string $op * @param array $cases * @param bool $defaultAfterCase - * @param bool $default - * @param string $t - Indentation - * + * @param string $t * @param bool $isString * @param bool $isConst * @return string */ - public function getXcSwitch(string $op = '', array $cases = [], bool $defaultAfterCase = false, bool $default = false, string $t = '', bool $isString = true, bool $isConst = false) + public function getXcSwitch(string $op = '', array $cases = [], bool $defaultAfterCase = false, string $t = '', bool $isString = true, bool $isConst = false) { $pc = Modulebuilder\Files\CreatePhpCode::getInstance(); - $contentSwitch = $pc->getPhpCodeCaseSwitch($cases, $defaultAfterCase, $default, $t . "\t", $isConst); + $contentSwitch = $pc->getPhpCodeCaseSwitch($cases, $defaultAfterCase, $t . "\t", $isConst); return $pc->getPhpCodeSwitch($op, $contentSwitch, $t, $isString); } @@ -642,11 +640,10 @@ public function getXcUserSaveElements($moduleDirname, $tableName, $tableSoleName * @param string $var1 * @param string $var2 * @param string $type - * @param bool $method * @param string $t * @return string */ - public function getXcXoopsRequest(string $left = '', string $var1 = '', string $var2 = '', string $type = 'String', bool $method = false, string $t = '') + public function getXcXoopsRequest(string $left = '', string $var1 = '', string $var2 = '', string $type = 'String', string $t = '') { $ret = ''; $intVars = ('' != $var2) ? "'{$var1}', {$var2}" : "'{$var1}'"; @@ -654,11 +651,7 @@ public function getXcXoopsRequest(string $left = '', string $var1 = '', string $ if ('String' === $type) { $ret .= "{$t}\${$left} = Request::getString({$stringVars});\n"; } elseif ('Int' === $type) { - if (false !== $method) { - $ret .= "{$t}\${$left} = Request::getInt({$intVars}, '{$method}');\n"; - } else { - $ret .= "{$t}\${$left} = Request::getInt({$intVars});\n"; - } + $ret .= "{$t}\${$left} = Request::getInt({$intVars});\n"; } else { $ret .= "{$t}\${$left} = Request::get{$type}('{$var1}', '{$var2}');\n"; } diff --git a/class/Files/Includes/IncludeNotifications.php b/class/Files/Includes/IncludeNotifications.php index eee449f8..5eff8d98 100644 --- a/class/Files/Includes/IncludeNotifications.php +++ b/class/Files/Includes/IncludeNotifications.php @@ -103,7 +103,7 @@ public function getNotificationsFunction(string $moduleDirname) $cases = [ 'global' => $case, ]; - $contentSwitch = $this->pc->getPhpCodeCaseSwitch($cases, false, false, $t . "\t"); + $contentSwitch = $this->pc->getPhpCodeCaseSwitch($cases, false, $t . "\t"); unset($case); foreach (\array_keys($tables) as $i) { @@ -133,9 +133,9 @@ public function getNotificationsFunction(string $moduleDirname) $case[] = $this->xc->getXcEqualsOperator('$sql ', "'SELECT {$fieldMain} FROM ' . \$xoopsDB->prefix('{$moduleDirname}_{$tableName}') . ' WHERE {$fieldId} = '. \$itemId", '', $t . "\t\t"); $case[] = $this->xc->getXcEqualsOperator('$result', '$xoopsDB->query($sql)', '', $t . "\t\t"); $condIf = $this->getSimpleString('return [];', $t . "\t\t\t"); - $case[] .= $this->pc->getPhpCodeConditions('!$result', '', '', $condIf, false, $t . "\t\t"); + $case[] = $this->pc->getPhpCodeConditions('!$result', '', '', $condIf, false, $t . "\t\t"); $case[] = $this->xc->getXcEqualsOperator('$result_array', '$xoopsDB->fetchArray($result)', '', $t . "\t\t"); - $case[] .= $this->pc->getPhpCodeConditions('!$result_array', '', '', $condIf, false, $t . "\t\t"); + $case[] = $this->pc->getPhpCodeConditions('!$result_array', '', '', $condIf, false, $t . "\t\t"); $case[] = $this->xc->getXcEqualsOperator("\$item['name']", "\$result_array['{$fieldMain}']", '', $t . "\t\t"); if ($fieldParent) { $case[] = $this->xc->getXcEqualsOperator("\$item['url'] ", "\\{$stuModuleDirname}_URL . '/{$tableSingle}.php?{$fieldParent}=' . \$result_array['{$fieldParent}'] . '&{$fieldId}=' . \$itemId", '', $t . "\t\t"); @@ -147,7 +147,7 @@ public function getNotificationsFunction(string $moduleDirname) $cases = [ $tableName => $case, ]; - $contentSwitch .= $this->pc->getPhpCodeCaseSwitch($cases, false, false, $t . "\t"); + $contentSwitch .= $this->pc->getPhpCodeCaseSwitch($cases, false, $t . "\t"); unset($case); } } diff --git a/class/Files/Language/LanguageHelp.php b/class/Files/Language/LanguageHelp.php index 709ec765..fbec75d4 100644 --- a/class/Files/Language/LanguageHelp.php +++ b/class/Files/Language/LanguageHelp.php @@ -115,7 +115,7 @@ public function render() if ('english' !== $language) { $this->create($moduleDirname, 'language/' . $language . '/help', $filename, $content, \_AM_MODULEBUILDER_FILE_CREATED, \_AM_MODULEBUILDER_FILE_NOTCREATED); } - $this->create($moduleDirname, 'language/' . $GLOBALS['xoopsConfig']['language'] . '/help', $filename, $content, \_AM_MODULEBUILDER_FILE_CREATED, \_AM_MODULEBUILDER_FILE_NOTCREATED); + $this->create($moduleDirname, 'language/english/help', $filename, $content, \_AM_MODULEBUILDER_FILE_CREATED, \_AM_MODULEBUILDER_FILE_NOTCREATED); return $this->renderFile(); } diff --git a/class/Files/Sql/SqlFile.php b/class/Files/Sql/SqlFile.php index 78ca77f9..ce2b6033 100644 --- a/class/Files/Sql/SqlFile.php +++ b/class/Files/Sql/SqlFile.php @@ -149,7 +149,7 @@ private function getDatabaseTables($module) $tableMid = $tables[$t]->getVar('table_mid'); $tableName = $tables[$t]->getVar('table_name'); $tableAutoincrement = $tables[$t]->getVar('table_autoincrement'); - $fieldsNumb = $tables[$t]->getVar('table_nbfields'); + $fieldsNumb = (int)$tables[$t]->getVar('table_nbfields'); if (1 === (int)$tables[$t]->getVar('table_rate')) { $tableRate = 1; } diff --git a/class/Files/Templates/Admin/TemplatesAdminBroken.php b/class/Files/Templates/Admin/TemplatesAdminBroken.php index f1843fe0..7057998d 100644 --- a/class/Files/Templates/Admin/TemplatesAdminBroken.php +++ b/class/Files/Templates/Admin/TemplatesAdminBroken.php @@ -152,7 +152,7 @@ private function getTemplatesAdminBrokenTable(string $tableName, $tableSoleName, { $tbody = $this->getTemplatesAdminBrokenTableThead($language); $tbody .= $this->getTemplatesAdminBrokenTableTBody($tableName, $tableSoleName); - return $this->hc->getHtmlTable($tbody, 'table table-bordered', "\t"); + return $this->hc->getHtmlTable($tbody, 'outer', "\t"); } /** diff --git a/class/Files/Templates/User/Defstyle/Categories.php b/class/Files/Templates/User/Defstyle/Categories.php index 019156de..35d7e8db 100644 --- a/class/Files/Templates/User/Defstyle/Categories.php +++ b/class/Files/Templates/User/Defstyle/Categories.php @@ -98,8 +98,8 @@ private function getTemplatesUserCategoriesHeader(string $moduleDirname) private function getTemplatesUserCategoriesTable($moduleDirname, $tableName, $tableSoleName, string $language) { $single = $this->sc->getSmartySingleVar('table_type'); - $table = $this->getTemplatesAdminPagesTableThead($tableName, $language); - $table .= $this->getTemplatesAdminPagesTableTBody($moduleDirname, $tableName, $tableSoleName, $language); + $table = $this->getTemplatesUserCategoriesThead($tableName, $language); + $table .= $this->getTemplatesUserCategoriesTbody($moduleDirname, $tableName, $tableSoleName); return $this->hc->getHtmlTable($table, 'table table-' . $single) . PHP_EOL; } diff --git a/class/Files/Templates/User/Defstyle/MoreFiles.php b/class/Files/Templates/User/Defstyle/MoreFiles.php index 0e03b7ad..392ccf21 100644 --- a/class/Files/Templates/User/Defstyle/MoreFiles.php +++ b/class/Files/Templates/User/Defstyle/MoreFiles.php @@ -60,8 +60,8 @@ public static function getInstance() /** * @public function write * @param $module - * @param string $filename * @param $folder + * @param string $filename * @param $extension */ public function write($module, $folder, string $filename, $extension): void diff --git a/class/Files/Templates/User/Defstyle/PagesItem.php b/class/Files/Templates/User/Defstyle/PagesItem.php index dbddf88b..d2eaab21 100644 --- a/class/Files/Templates/User/Defstyle/PagesItem.php +++ b/class/Files/Templates/User/Defstyle/PagesItem.php @@ -254,7 +254,7 @@ private function getTemplatesUserPagesItemPanel(string $moduleDirname, $tableId, $singleVar = $this->sc->getSmartySingleVar('xoops_icons32_url', '', '', "''|escape:'htmlattr'"); $doubleVar = $this->sc->getSmartyDoubleVar($tableSoleName, $rpFieldName, '', '', "''|escape:'htmlattr'"); $img = $this->hc->getHtmlImage($singleVar . '/' . $doubleVar, (string)$tableName); - //$retElem .= $this->hc->getHtmlSpan($img, 'block-pie justify', "\t"); + $retFoot .= $this->hc->getHtmlSpan($img, 'block-pie justify', "\t"); unset($img); break; case Constants::FIELD_ELE_UPLOADIMAGE: @@ -263,7 +263,7 @@ private function getTemplatesUserPagesItemPanel(string $moduleDirname, $tableId, $singleVar = $this->sc->getSmartySingleVar($moduleDirname . '_upload_url', '', '', "''|escape:'htmlattr'"); $doubleVar = $this->sc->getSmartyDoubleVar($tableSoleName, $rpFieldName, '', '', "''|escape:'htmlattr'"); $img = $this->hc->getHtmlImage($singleVar . "/images/{$tableName}/" . $doubleVar, (string)$tableName); - //$retElem .= $this->hc->getHtmlSpan($img, 'block-pie justify',"\t"); + $retFoot .= $this->hc->getHtmlSpan($img, 'block-pie justify',"\t"); unset($img); break; } diff --git a/class/Files/Templates/User/Defstyle/PagesList.php b/class/Files/Templates/User/Defstyle/PagesList.php index fc818059..7c31342a 100644 --- a/class/Files/Templates/User/Defstyle/PagesList.php +++ b/class/Files/Templates/User/Defstyle/PagesList.php @@ -72,8 +72,8 @@ public static function getInstance() * @public function write * @param $module * @param $table - * @param string $filename * @param $tables + * @param string $filename */ public function write($module, $table, $tables, string $filename): void { diff --git a/class/Files/User/UserIndex.php b/class/Files/User/UserIndex.php index f5cc860f..36e77fcc 100644 --- a/class/Files/User/UserIndex.php +++ b/class/Files/User/UserIndex.php @@ -164,9 +164,9 @@ private function getBodyPagesIndex($tableName, $language, $tableMid, $tableId) $ret .= $this->xc->getXcHandlerCountObj($tableName); $ret .= $this->xc->getXcXoopsTplAssign($tableName . 'Count', "\${$tableName}Count"); //$ret .= $this->getSimpleString('$count = 1;'); - $condIf = $this->xc->getXcXoopsRequest('start', 'start', '', 'Int', false, "\t"); + $condIf = $this->xc->getXcXoopsRequest('start', 'start', '', 'Int', "\t"); $userpager = $this->xc->getXcGetConfig('userpager'); - $condIf .= $this->xc->getXcXoopsRequest('limit', 'limit', $userpager, 'Int', false, "\t"); + $condIf .= $this->xc->getXcXoopsRequest('limit', 'limit', $userpager, 'Int', "\t"); $condIf .= $this->xc->getXcHandlerAllObj($tableName, '', '$start', '$limit', "\t"); $condIf .= $this->pc->getPhpCodeCommentLine('Get All', $ucfTableName, "\t"); $condIf .= $this->pc->getPhpCodeArray($tableName . '_list', null, false, "\t"); diff --git a/class/Files/User/UserPages.php b/class/Files/User/UserPages.php index 2449c596..41aefeb9 100644 --- a/class/Files/User/UserPages.php +++ b/class/Files/User/UserPages.php @@ -471,7 +471,7 @@ public function getUserPagesClone($tableName, $tableSoleName, $tablePermissions, $ret .= $this->pc->getPhpCodeConditions('!$permissionsHandler->getPermGlobalSubmit()', '', '', $contIf, false, $t); } $ret .= $this->pc->getPhpCodeCommentLine('Request source', '', $t); - $ret .= $this->xc->getXcXoopsRequest($ccFieldId . 'Source', $fieldId . '_source', '', 'Int', false, $t); + $ret .= $this->xc->getXcXoopsRequest($ccFieldId . 'Source', $fieldId . '_source', '', 'Int', $t); $ret .= $this->pc->getPhpCodeCommentLine('Check params', '', $t); $contIf = $this->xc->getXcRedirectHeader($tableName, '?op=list', 3, "{$language}INVALID_PARAM", true, $t . "\t"); $ret .= $this->pc->getPhpCodeConditions("\${$ccFieldId}Source", ' == ', '0', $contIf, false, $t); diff --git a/class/Files/User/UserPdf.php b/class/Files/User/UserPdf.php index edc5628a..b6a2da57 100644 --- a/class/Files/User/UserPdf.php +++ b/class/Files/User/UserPdf.php @@ -122,7 +122,7 @@ private function getUserPdfHeader($moduleDirname, $tableName, $fields, $language $ret .= $this->pc->getPhpCodeConditions('!' . $tablenameObj, '', '', $redirectError); $ret .= $this->pc->getPhpCodeBlankLine(); $ret .= $this->xc->getXcEqualsOperator('$myts', 'MyTextSanitizer::getInstance()'); - $ret .= $this->cf->getSimpleString("\$pdfTpl->assign('wgtestmb_upload_url', \\" . strtoupper($moduleDirname) . '_UPLOAD_URL);'); + $ret .= $this->cf->getSimpleString("\$pdfTpl->assign('" . $moduleDirname . "_upload_url', \\" . strtoupper($moduleDirname) . '_UPLOAD_URL);'); $ret .= $this->pc->getPhpCodeBlankLine(); return $ret; @@ -202,7 +202,7 @@ public function getUserPdfTcpdf($moduleDirname, $tableName, $tableSolename, $fie $ret .= $this->pc->getPhpCodeBlankLine(); $ret .= $this->pc->getPhpCodeCommentLine('Get Config'); $ret .= $this->xc->getXcEqualsOperator("\$pdfData['creator'] ", "\$GLOBALS['xoopsConfig']['sitename']"); - $ret .= $this->xc->getXcEqualsOperator("\$pdfData['subject'] ", "\$GLOBALS['xoopsConfig']['slogan']"); + //$ret .= $this->xc->getXcEqualsOperator("\$pdfData['subject'] ", "\$GLOBALS['xoopsConfig']['slogan']"); $ret .= $this->xc->getXcEqualsOperator("\$pdfData['keywords'] ", "\$helper->getConfig('keywords')"); $ret .= $this->pc->getPhpCodeBlankLine(); $ret .= $this->pc->getPhpCodeCommentLine('Defines'); diff --git a/class/Files/User/UserRate.php b/class/Files/User/UserRate.php index b9ad4e67..0510f2e7 100644 --- a/class/Files/User/UserRate.php +++ b/class/Files/User/UserRate.php @@ -146,7 +146,7 @@ public function getUserRateSave($tables, $language, $t, $moduleDirname) $redirectError = $this->xc->getXcRedirectHeader('index', '', '3', $implode, true, $t . "\t"); $ret .= $this->pc->getPhpCodeConditions('!' . $xoopsSecurityCheck, '', '', $redirectError, false, $t); - $ret .= $this->xc->getXcXoopsRequest('rating', 'rating', '', 'Int', false, $t); + $ret .= $this->xc->getXcXoopsRequest('rating', 'rating', '', 'Int', $t); $ret .= $this->xc->getXcEqualsOperator('$itemid', '0','', $t); $ret .= $this->xc->getXcEqualsOperator('$redir ', "\Xmf\Request::getString('HTTP_REFERER', '', 'SERVER')",'', $t); foreach ($tables as $table) { @@ -160,7 +160,7 @@ public function getUserRateSave($tables, $language, $t, $moduleDirname) $fieldId = $fields[$f]->getVar('field_name'); } } - $contIf = $this->xc->getXcXoopsRequest('itemid', $fieldId, '', 'Int', false, $t . "\t"); + $contIf = $this->xc->getXcXoopsRequest('itemid', $fieldId, '', 'Int', $t . "\t"); $contIf .= $this->xc->getXcEqualsOperator('$redir', "'{$tableName}.php?op=show&{$fieldId}=' . \$itemid",'', $t . "\t"); $const = $this->xc->getXcGetConstants('TABLE_' . $stuTableName); $ret .= $this->pc->getPhpCodeConditions('$source', ' === ', $const, $contIf, false, $t); @@ -200,7 +200,7 @@ public function getUserRateSave($tables, $language, $t, $moduleDirname) $const = $this->xc->getXcGetConstants('RATING_10NUM'); $cases[$const] = [$this->pc->getPhpCodeConditions('$rating > 10 || $rating < 1', '', '', $contIf, false, $t . "\t\t")]; $config = '(int)' . $this->xc->getXcGetConfig('ratingbars'); - $ret .= $this->xc->getXcSwitch($config, $cases, true, false, $t, false, true); + $ret .= $this->xc->getXcSwitch($config, $cases, true, $t, false, true); $ret .= $this->pc->getPhpCodeBlankLine(); $ret .= $this->pc->getPhpCodeCommentLine('Get existing rating', null, $t); diff --git a/class/Files/admin/AdminPages.php b/class/Files/admin/AdminPages.php index cd1825ce..386e639b 100644 --- a/class/Files/admin/AdminPages.php +++ b/class/Files/admin/AdminPages.php @@ -136,7 +136,7 @@ private function getAdminPagesHeader($moduleDirname, $fieldId) */ private function getAdminPagesSwitch(array $cases = []) { - $contentSwitch = $this->pc->getPhpCodeCaseSwitch($cases, true, false, "\t"); + $contentSwitch = $this->pc->getPhpCodeCaseSwitch($cases, true, "\t"); return $this->pc->getPhpCodeSwitch('op', $contentSwitch); } @@ -238,7 +238,7 @@ private function getAdminPagesClone($moduleDirname, $tableName, $tableSoleName, $ret .= $this->xc->getXcXoopsTplAssign('buttons', '$adminObject->displayButton(\'left\')', true, $t); } $ret .= $this->pc->getPhpCodeCommentLine('Request source', '', $t); - $ret .= $this->xc->getXcXoopsRequest($ccFieldId . 'Source', $fieldId . '_source', '', 'Int', false, $t); + $ret .= $this->xc->getXcXoopsRequest($ccFieldId . 'Source', $fieldId . '_source', '', 'Int', $t); $ret .= $this->pc->getPhpCodeCommentLine('Check params', '', $t); $contIf = $this->xc->getXcRedirectHeader($tableName, '?op=list', 3, "{$language}INVALID_PARAM", true, $t . "\t"); diff --git a/class/Form/FormRadio.php b/class/Form/FormRadio.php index df10ea43..23bef86c 100644 --- a/class/Form/FormRadio.php +++ b/class/Form/FormRadio.php @@ -31,8 +31,8 @@ public function render() { $ret = ''; $ele_name = $this->getName(); - $ele_title = $this->getTitle(); - $ele_value = $this->getValue(); + $ele_title = (string)$this->getTitle(); + $ele_value = (string)$this->getValue(); $ele_options = $this->getOptions(); $ele_extra = $this->getExtra(); $ele_delimeter = empty($this->columns) ? $this->getDelimeter() : ''; diff --git a/class/Helper.php b/class/Helper.php index 090b8897..2ab01f0a 100644 --- a/class/Helper.php +++ b/class/Helper.php @@ -30,7 +30,7 @@ class Helper extends \Xmf\Module\Helper /** * @param bool $debug */ - public function __construct($debug = false) + public function __construct(bool $debug = false) { $this->debug = $debug; $moduleDirName = \basename(\dirname(__DIR__)); diff --git a/class/LogoGenerator.php b/class/LogoGenerator.php index b2449770..1269d914 100644 --- a/class/LogoGenerator.php +++ b/class/LogoGenerator.php @@ -38,7 +38,9 @@ function phpFunction(string $val = ''): void if (\function_exists($myfunction)) { $ret = \XoopsModules\Modulebuilder\LogoGenerator::createLogo($_GET['iconName'], $_GET['caption']); - phpFunction($ret); + if (false !== $ret) { + phpFunction($ret); + } } else { echo 'Method Not Exist'; } diff --git a/class/Modules.php b/class/Modules.php index 230ef42e..f18bbd3e 100644 --- a/class/Modules.php +++ b/class/Modules.php @@ -100,7 +100,7 @@ public function __construct() * * @return mixed */ - public function __call(string $method, array $args) + public function __call(string $method, array $args): mixed { $arg = $args[0] ?? null; diff --git a/class/SplClassLoader.php b/class/SplClassLoader.php index 29ca1d9f..a308991a 100644 --- a/class/SplClassLoader.php +++ b/class/SplClassLoader.php @@ -79,9 +79,9 @@ public function getNamespaceSeparator() /** * Sets the base include path for all class files in the namespace of this class loader. * - * @param string $includePath + * @param string|null $includePath */ - public function setIncludePath(string $includePath): void + public function setIncludePath(?string $includePath): void { $this->_includePath = $includePath; } diff --git a/class/Utility.php b/class/Utility.php index 18781adb..7973c924 100644 --- a/class/Utility.php +++ b/class/Utility.php @@ -76,7 +76,7 @@ function xoopsFormValidate_donation() { var myform = window.document.donation; $donationform[$key], $GLOBALS['xoopsConfig']['sitename'] . ' - ' . ('' != $GLOBALS['xoopsUser']->getVar('name') ? $GLOBALS['xoopsUser']->getVar('name') . ' [' . $GLOBALS['xoopsUser']->getVar('uname') . ']' : $GLOBALS['xoopsUser']->getVar('uname')), $GLOBALS['xoopsUser']->getVar('email'), - \XOOPS_LICENSE_KEY, + \defined('XOOPS_LICENSE_KEY') ? \XOOPS_LICENSE_KEY : '', \mb_strtoupper($GLOBALS['xoopsModule']->getVar('dirname')), \mb_strtoupper($GLOBALS['xoopsModule']->getVar('dirname')) . ' ' . $GLOBALS['xoopsModule']->getVar('name') ); From a11a782fd5901d020be165b1fde255e3df0c58c1 Mon Sep 17 00:00:00 2001 From: "NB-GABOR02\\Goffy" Date: Tue, 7 Apr 2026 23:33:24 +0200 Subject: [PATCH 3/7] corrections coderabbitai 2 --- class/Common/DirectoryChecker.php | 26 +-- class/Common/TableChecker.php | 2 +- class/Files/Blocks/BlocksFiles.php | 4 +- class/Files/Classes/ClassFiles.php | 4 +- class/Files/CreateClone.php | 8 +- class/Files/CreateSmartyCode.php | 17 +- class/Files/CreateStructure.php | 6 +- class/Files/CreateXoopsCode.php | 189 +++++++++--------- class/Files/Language/LanguageHelp.php | 5 - .../Templates/Admin/TemplatesAdminBroken.php | 8 +- .../Templates/Admin/TemplatesAdminPages.php | 16 +- .../Blocks/Defstyle/TemplatesBlocks.php | 14 +- .../Templates/User/Defstyle/Breadcrumbs.php | 8 +- .../Templates/User/Defstyle/Categories.php | 18 +- .../Templates/User/Defstyle/PagesItem.php | 44 ++-- .../Templates/User/Defstyle/PagesList.php | 4 +- class/Files/User/UserPages.php | 14 +- class/Files/User/UserPdf.php | 63 +++--- class/Files/User/UserPrint.php | 45 +++-- class/Files/User/UserRate.php | 2 +- class/Modules.php | 39 ---- 21 files changed, 258 insertions(+), 278 deletions(-) diff --git a/class/Common/DirectoryChecker.php b/class/Common/DirectoryChecker.php index 4aeb0f0f..77172127 100644 --- a/class/Common/DirectoryChecker.php +++ b/class/Common/DirectoryChecker.php @@ -104,7 +104,11 @@ public static function createDirectory($target, int $mode = 0777) $target = \str_replace('..', '', $target); // https://www.php.net/manual/en/function.mkdir.php - return \is_dir($target) || (self::createDirectory(\dirname($target), $mode) && !\mkdir($target, $mode) && !\is_dir($target)); + return \is_dir($target) + || ( + self::createDirectory(\dirname($target), $mode) + && (\mkdir($target, $mode) || \is_dir($target)) + ); } /** @@ -137,22 +141,20 @@ public static function dirExists($dir_path) if (!\Xmf\Request::hasVar('path', 'POST') || !\Xmf\Request::hasVar('redirect', 'POST')) { break; } - $path = $_POST['path']; - $redirect = $_POST['redirect']; + $path = \Xmf\Request::getString('path', 'POST'); + $redirect = \Xmf\Request::getString('redirect', 'POST'); $msg = DirectoryChecker::createDirectory($path) ? \constant('CO_' . $moduleDirNameUpper . '_' . 'DC_DIRCREATED') : \constant('CO_' . $moduleDirNameUpper . '_' . 'DC_DIRNOTCREATED'); \redirect_header($redirect, 2, $msg . ': ' . $path); break; case 'setdirperm': - if (\Xmf\Request::hasVar('path', 'POST')) { - $path = $_POST['path']; - } - if (\Xmf\Request::hasVar('redirect', 'POST')) { - $redirect = $_POST['redirect']; - } - if (\Xmf\Request::hasVar('mode', 'POST')) { - $mode = $_POST['mode']; + if (!\Xmf\Request::hasVar('path', 'POST') || !\Xmf\Request::hasVar('redirect', 'POST') || !\Xmf\Request::hasVar('mode', 'POST')) { + break; } - $msg = DirectoryChecker::setDirectoryPermissions($path, (int)$mode) ? \constant('CO_' . $moduleDirNameUpper . '_' . 'DC_PERMSET') : \constant('CO_' . $moduleDirNameUpper . '_' . 'DC_PERMNOTSET'); + $path = \Xmf\Request::getString('path', 'POST'); + $redirect = \Xmf\Request::getString('redirect', 'POST'); + $mode = \Xmf\Request::getInt('mode', 'POST'); + $msg = DirectoryChecker::setDirectoryPermissions($path, $mode) ? \constant('CO_' . $moduleDirNameUpper . '_' . 'DC_PERMSET') : \constant('CO_' . $moduleDirNameUpper . '_' . 'DC_PERMNOTSET'); + \redirect_header($redirect, 2, $msg . ': ' . $path); break; } diff --git a/class/Common/TableChecker.php b/class/Common/TableChecker.php index 9fe70478..70c85b25 100644 --- a/class/Common/TableChecker.php +++ b/class/Common/TableChecker.php @@ -76,7 +76,7 @@ public function processSQL() if ($this::CHECKTYPE_UPDATE == $this->checktype || $this::CHECKTYPE_UPDATE_REPORT == $this->checktype) { // create new table $sql = $tabledef['sql']; - if ($this->result = $GLOBALS['xoopsDB']->queryF($sql)) { + if ($GLOBALS['xoopsDB']->queryF($sql)) { $this->result[] = 'Table created:' . $table; } else { \xoops_error($GLOBALS['xoopsDB']->error() . '
' . $sql); diff --git a/class/Files/Blocks/BlocksFiles.php b/class/Files/Blocks/BlocksFiles.php index 718f1aa5..9490942d 100644 --- a/class/Files/Blocks/BlocksFiles.php +++ b/class/Files/Blocks/BlocksFiles.php @@ -157,8 +157,8 @@ private function getBlocksShow($moduleDirname, $tableName, $tableFieldname, $tab } } if ('' !== $fieldStatus) { - $constant = $this->xc->getXcGetConstants('STATUS_OFFLINE'); - $crit = $this->xc->getXcCriteria('', "'{$fieldStatus}'", $constant, "'>'", true); + $constant = $this->xc->getXcGetConstants('STATUS_APPROVED'); + $crit = $this->xc->getXcCriteria('', "'{$fieldStatus}'", $constant, "'='", true); $func .= $this->pc->getPhpCodeCommentLine("Criteria for status field",'',"\t"); $func .= $this->xc->getXcCriteriaAdd($critName, $crit, "\t"); $func .= $this->pc->getPhpCodeBlankLine(); diff --git a/class/Files/Classes/ClassFiles.php b/class/Files/Classes/ClassFiles.php index 86fd6147..6907ec07 100644 --- a/class/Files/Classes/ClassFiles.php +++ b/class/Files/Classes/ClassFiles.php @@ -340,12 +340,12 @@ private function getFunctionForm($module, $table, $fieldId, $fieldInForm, $field * @private function getPermissionsInForm * * @param string $moduleDirname - * @param string $fieldId + * @param string|null $fieldId * * @param $tableName * @return string */ - private function getPermissionsInForm(string $moduleDirname, string $fieldId, $tableName) + private function getPermissionsInForm(string $moduleDirname, ?string $fieldId, $tableName) { $permissionApprove = $this->getLanguage($moduleDirname, 'AM', 'PERMISSIONS_APPROVE'); $permissionSubmit = $this->getLanguage($moduleDirname, 'AM', 'PERMISSIONS_SUBMIT'); diff --git a/class/Files/CreateClone.php b/class/Files/CreateClone.php index 2d5665f0..2bfb541f 100644 --- a/class/Files/CreateClone.php +++ b/class/Files/CreateClone.php @@ -39,8 +39,14 @@ public static function cloneFileFolder($src_path, $dst_path, bool $replace_code { // open the source directory $dir = \opendir($src_path); + if (false === $dir) { + throw new \RuntimeException("Unable to open source directory: {$src_path}"); + } // Make the destination directory if not exist - @\mkdir($dst_path); + if (!\is_dir($dst_path) && !\mkdir($dst_path, 0755) && !\is_dir($dst_path)) { + throw new \RuntimeException("Unable to create destination directory: {$dst_path}"); + } + // Loop through the files in source directory while ($file = \readdir($dir)) { if (($file != '.') && ($file != '..')) { diff --git a/class/Files/CreateSmartyCode.php b/class/Files/CreateSmartyCode.php index 7bae5586..9fee1358 100644 --- a/class/Files/CreateSmartyCode.php +++ b/class/Files/CreateSmartyCode.php @@ -143,14 +143,18 @@ public function getSmartyConst(string $language, $const, string $t = '', string * @param string $t * @param string $n * @param string $default + * @param string $escape * @return string */ - public function getSmartySingleVar(string $var, string $t = '', string $n = '', string $default = 'false') + public function getSmartySingleVar(string $var, string $t = '', string $n = '', string $default = 'false', string $escape = '') { $ret = "{$t}<{\${$var}"; if ('' !== $default) { $ret .= '|default:' . $default; } + if ('' !== $escape) { + $ret .= '|escape:' . $escape; + } $ret .= "}>{$n}"; return $ret; @@ -162,11 +166,18 @@ public function getSmartySingleVar(string $var, string $t = '', string $n = '', * @param string $rightVar * @param string $t * @param string $n + * @param string $default + * @param string $escape * @return string */ - public function getSmartyDoubleVar(string $leftVar, string $rightVar, string $t = '', string $n = '', $default = 'false') + public function getSmartyDoubleVar(string $leftVar, string $rightVar, string $t = '', string $n = '', string $default = 'false', string $escape = '') { - return "{$t}<{\${$leftVar}.{$rightVar}|default:{$default}}>{$n}"; + $ret = "{$t}<{\${$leftVar}.{$rightVar}|default:{$default}"; + if ('' !== $escape) { + $ret .= '|escape:' . $escape; + } + $ret .= "}>{$n}"; + return $ret; } /** diff --git a/class/Files/CreateStructure.php b/class/Files/CreateStructure.php index ca933992..f9a74872 100644 --- a/class/Files/CreateStructure.php +++ b/class/Files/CreateStructure.php @@ -179,7 +179,7 @@ protected function makeDir(string $dir): void * * @return bool */ - public function isDirEmpty(string $dir) + public function isDirEmpty(string $dir): bool { $handle = \opendir($dir); if (false === $handle) { @@ -197,13 +197,13 @@ public function isDirEmpty(string $dir) } /** - * @public function addFolderPath + * @private function addFolderPath * * @param string $folderName * @param bool|string $fileName * @return string */ - private function addFolderPath(string $folderName, $fileName = false) + private function addFolderPath(string $folderName, $fileName = false): string { $this->setFolderName($folderName); if ($fileName) { diff --git a/class/Files/CreateXoopsCode.php b/class/Files/CreateXoopsCode.php index 0130c218..8c2b9e2e 100644 --- a/class/Files/CreateXoopsCode.php +++ b/class/Files/CreateXoopsCode.php @@ -55,7 +55,7 @@ public static function getInstance() * @param bool $isConst * @return string */ - public function getXcSwitch(string $op = '', array $cases = [], bool $defaultAfterCase = false, string $t = '', bool $isString = true, bool $isConst = false) + public function getXcSwitch(string $op = '', array $cases = [], bool $defaultAfterCase = false, string $t = '', bool $isString = true, bool $isConst = false): string { $pc = Modulebuilder\Files\CreatePhpCode::getInstance(); $contentSwitch = $pc->getPhpCodeCaseSwitch($cases, $defaultAfterCase, $t . "\t", $isConst); @@ -72,7 +72,7 @@ public function getXcSwitch(string $op = '', array $cases = [], bool $defaultAft * * @return string */ - public function getXcEqualsOperator($var, $value, $interlock = null, string $t = '') + public function getXcEqualsOperator($var, $value, $interlock = null, string $t = ''): string { return "{$t}{$var} {$interlock}= {$value};\n"; } @@ -86,7 +86,7 @@ public function getXcEqualsOperator($var, $value, $interlock = null, string $t = * * @return string */ - public function getXcAnchorFunction($anchor, $name, $vars, bool $close = false) + public function getXcAnchorFunction($anchor, $name, $vars, bool $close = false): string { $semicolon = false !== $close ? ';' : ''; @@ -101,7 +101,7 @@ public function getXcAnchorFunction($anchor, $name, $vars, bool $close = false) * @param string $t * @return string */ - public function getXcSetVarObj($tableName, $fieldName, $var, string $t = '') + public function getXcSetVarObj($tableName, $fieldName, $var, string $t = ''): string { return "{$t}\${$tableName}Obj->setVar('{$fieldName}', {$var});\n"; } @@ -117,7 +117,7 @@ public function getXcSetVarObj($tableName, $fieldName, $var, string $t = '') * @param string $format * @return string */ - public function getXcGetVar(string $varLeft = '', string $handle = '', string $var = '', bool $isParam = false, string $t = '', string $format = '') + public function getXcGetVar(string $varLeft = '', string $handle = '', string $var = '', bool $isParam = false, string $t = '', string $format = ''): string { if (!$isParam) { $ret = "{$t}\${$varLeft} = \${$handle}->getVar('{$var}'{$format});\n"; @@ -137,7 +137,7 @@ public function getXcGetVar(string $varLeft = '', string $handle = '', string $v * * @return string */ - public function getXcAddItem(string $varLeft = '', string $paramLeft = '', string $paramRight = '', string $t = '') + public function getXcAddItem(string $varLeft = '', string $paramLeft = '', string $paramRight = '', string $t = ''): string { return "{$t}\${$varLeft}->addItem({$paramLeft}, {$paramRight});\n"; } @@ -152,7 +152,7 @@ public function getXcAddItem(string $varLeft = '', string $paramLeft = '', strin * @param string $t * @return string */ - public function getXcGetGroupIds(string $var = '', string $anchor = '', $param1 = null, $param2 = null, $param3 = null, string $t = '') + public function getXcGetGroupIds(string $var = '', string $anchor = '', $param1 = null, $param2 = null, $param3 = null, string $t = ''): string { return "{$t}\${$var} = \${$anchor}->getGroupIds({$param1}, {$param2}, {$param3});\n"; } @@ -167,7 +167,7 @@ public function getXcGetGroupIds(string $var = '', string $anchor = '', $param1 * @param string $t * @return string */ - public function getXcGetItemIds(string $var = '', string $anchor = '', $param1 = null, $param2 = null, $param3 = null, string $t = '') + public function getXcGetItemIds(string $var = '', string $anchor = '', $param1 = null, $param2 = null, $param3 = null, string $t = ''): string { return "{$t}\${$var} = \${$anchor}->getItemIds({$param1}, {$param2}, {$param3});\n"; } @@ -181,7 +181,7 @@ public function getXcGetItemIds(string $var = '', string $anchor = '', $param1 = * @param string $language * @return string */ - public function getXcSetVarTextDateSelect($tableName, $tableSoleName, $fieldName, string $t = '', string $language = '') + public function getXcSetVarTextDateSelect($tableName, $tableSoleName, $fieldName, string $t = '', string $language = ''): string { $cf = Modulebuilder\Files\CreateFile::getInstance(); $pc = Modulebuilder\Files\CreatePhpCode::getInstance(); @@ -209,7 +209,7 @@ public function getXcSetVarTextDateSelect($tableName, $tableSoleName, $fieldName * @param string $language * @return string */ - public function getXcSetVarDateTime($tableName, $tableSoleName, $fieldName, string $t = '', string $language = '') + public function getXcSetVarDateTime($tableName, $tableSoleName, $fieldName, string $t = '', string $language = ''): string { $tf = Modulebuilder\Files\CreateFile::getInstance(); $pc = Modulebuilder\Files\CreatePhpCode::getInstance(); @@ -245,7 +245,7 @@ public function getXcSetVarDateTime($tableName, $tableSoleName, $fieldName, stri * @param string $t * @return string */ - public function getXcSetVarCheckBoxOrRadioYN($tableName, $fieldName, string $t = '') + public function getXcSetVarCheckBoxOrRadioYN($tableName, $fieldName, string $t = ''): string { return $this->getXcSetVarObj($tableName, $fieldName, "Request::getInt('{$fieldName}')", $t); } @@ -259,7 +259,7 @@ public function getXcSetVarCheckBoxOrRadioYN($tableName, $fieldName, string $t = * @param string $t * @return string */ - public function getXcMediaUploader($var, $dirPath, $mimetype, $maxsize, string $t = '') + public function getXcMediaUploader($var, $dirPath, $mimetype, $maxsize, string $t = ''): string { $mimetypes_file = $this->getXcGetConfig($mimetype); $maxsize_file = $this->getXcGetConfig($maxsize); @@ -277,7 +277,7 @@ public function getXcMediaUploader($var, $dirPath, $mimetype, $maxsize, string $ * * @return string */ - public function getXcGetInstance(string $var = '', string $instance = '', string $t = '') + public function getXcGetInstance(string $var = '', string $instance = '', string $t = ''): string { return "{$t}\${$var} = {$instance}::getInstance();\n"; } @@ -287,7 +287,7 @@ public function getXcGetInstance(string $var = '', string $instance = '', string * @param $name * @return string */ - public function getXcGetConfig($name) + public function getXcGetConfig($name): string { return "\$helper->getConfig('{$name}')"; } @@ -298,7 +298,7 @@ public function getXcGetConfig($name) * @param string $t * @return string */ - public function getXcIdGetVar($lpFieldName, string $t = '') + public function getXcIdGetVar($lpFieldName, string $t = ''): string { return "{$t}\${$lpFieldName}['id'] = \$i;\n"; } @@ -312,7 +312,7 @@ public function getXcIdGetVar($lpFieldName, string $t = '') * @param string $t * @return string */ - public function getXcGetVarAll($lpFieldName, $rpFieldName, $tableName, $fieldName, string $t = '') + public function getXcGetVarAll($lpFieldName, $rpFieldName, $tableName, $fieldName, string $t = ''): string { return "{$t}\${$lpFieldName}['{$rpFieldName}'] = \${$tableName}All[\$i]->getVar('{$fieldName}');\n"; } @@ -324,7 +324,7 @@ public function getXcGetVarAll($lpFieldName, $rpFieldName, $tableName, $fieldNam * @param string $t * @return string */ - public function getXcHelperGetInstance($moduleDirname, string $t = '') + public function getXcHelperGetInstance($moduleDirname, string $t = ''): string { $ucfModuleDirname = \ucfirst($moduleDirname); $ret = "{$t}// Get instance of module\n"; @@ -341,7 +341,7 @@ public function getXcHelperGetInstance($moduleDirname, string $t = '') * @param string $t * @return string */ - public function getXcFormatTimeStamp($left, $value, string $format = 's', string $t = '') + public function getXcFormatTimeStamp($left, $value, string $format = 's', string $t = ''): string { return "{$t}\${$left} = \\formatTimestamp({$value}, '{$format}');\n"; } @@ -357,7 +357,7 @@ public function getXcFormatTimeStamp($left, $value, string $format = 's', string * @param string $t * @return string */ - public function getXcTopicGetVar($lpFieldName, $rpFieldName, $tableName, $tableNameTopic, $fieldNameParent, $fieldNameTopic, string $t = '') + public function getXcTopicGetVar($lpFieldName, $rpFieldName, $tableName, $tableNameTopic, $fieldNameParent, $fieldNameTopic, string $t = ''): string { $pc = Modulebuilder\Files\CreatePhpCode::getInstance(); $ret = $pc->getPhpCodeCommentLine('Get Var', $fieldNameParent, $t); @@ -379,7 +379,7 @@ public function getXcTopicGetVar($lpFieldName, $rpFieldName, $tableName, $tableN * @param string $t * @return string */ - public function getXcParentTopicGetVar($lpFieldName, $rpFieldName, $tableName, $tableSoleNameTopic, $tableNameTopic, $fieldNameParent, string $t = '') + public function getXcParentTopicGetVar($lpFieldName, $rpFieldName, $tableName, $tableSoleNameTopic, $tableNameTopic, $fieldNameParent, string $t = ''): string { $pc = Modulebuilder\Files\CreatePhpCode::getInstance(); $parentTopic = $pc->getPhpCodeCommentLine('Get', $tableNameTopic . ' Handler', $t . "\t"); @@ -401,7 +401,7 @@ public function getXcParentTopicGetVar($lpFieldName, $rpFieldName, $tableName, $ * @param string $t * @return string */ - public function getXcGetVarFromID($left, $anchor, $var, $tableName, $fieldName, string $t = '') + public function getXcGetVarFromID($left, $anchor, $var, $tableName, $fieldName, string $t = ''): string { $pc = Modulebuilder\Files\CreatePhpCode::getInstance(); $ret = $pc->getPhpCodeCommentLine('Get Var', $fieldName, $t); @@ -441,7 +441,7 @@ public function getXcGetVarUploadImage($lpFieldName, $rpFieldName, $tableName, $ * @param $fieldName * @return string */ - public function getXcGetVarUrlFile($lpFieldName, $rpFieldName, $tableName, $fieldName) + public function getXcGetVarUrlFile($lpFieldName, $rpFieldName, $tableName, $fieldName): string { return $this->getXcGetVarAll($lpFieldName, $rpFieldName, $tableName, $fieldName); } @@ -455,7 +455,7 @@ public function getXcGetVarUrlFile($lpFieldName, $rpFieldName, $tableName, $fiel * @param string $t * @return string */ - public function getXcGetVarTextArea($lpFieldName, $rpFieldName, $tableName, $fieldName, string $t = '') + public function getXcGetVarTextArea($lpFieldName, $rpFieldName, $tableName, $fieldName, string $t = ''): string { $pc = Modulebuilder\Files\CreatePhpCode::getInstance(); $getVar = $this->getXcGetVar('', "\${$tableName}All[\$i]", $fieldName, true); @@ -472,7 +472,7 @@ public function getXcGetVarTextArea($lpFieldName, $rpFieldName, $tableName, $fie * @param string $t * @return string */ - public function getXcGetVarSelectUser($lpFieldName, $rpFieldName, $tableName, $fieldName, string $t = '') + public function getXcGetVarSelectUser($lpFieldName, $rpFieldName, $tableName, $fieldName, string $t = ''): string { return "{$t}\${$lpFieldName}['{$rpFieldName}'] = \XoopsUser::getUnameFromId(\${$tableName}All[\$i]->getVar('{$fieldName}'), 's');\n"; } @@ -486,7 +486,7 @@ public function getXcGetVarSelectUser($lpFieldName, $rpFieldName, $tableName, $f * @param string $t * @return string */ - public function getXcGetVarTextDateSelect($lpFieldName, $rpFieldName, $tableName, $fieldName, string $t = '') + public function getXcGetVarTextDateSelect($lpFieldName, $rpFieldName, $tableName, $fieldName, string $t = ''): string { return "{$t}\${$lpFieldName}['{$rpFieldName}'] = \\formatTimestamp(\${$tableName}All[\$i]->getVar('{$fieldName}'), 's');\n"; } @@ -498,7 +498,7 @@ public function getXcGetVarTextDateSelect($lpFieldName, $rpFieldName, $tableName * @param string $t * @return string */ - public function getXcXoopsOptionTemplateMain($moduleDirname, $tableName, string $t = '') + public function getXcXoopsOptionTemplateMain($moduleDirname, $tableName, string $t = ''): string { return "{$t}\$GLOBALS['xoopsOption']['template_main'] = '{$moduleDirname}_{$tableName}.tpl';\n"; } @@ -509,7 +509,7 @@ public function getXcXoopsOptionTemplateMain($moduleDirname, $tableName, string * @param $tableName * @return string */ - public function getXcUserHeader($moduleDirname, $tableName) + public function getXcUserHeader($moduleDirname, $tableName): string { $pc = Modulebuilder\Files\CreatePhpCode::getInstance(); $ret = $pc->getPhpCodeIncludeDir('__DIR__', 'header'); @@ -524,7 +524,7 @@ public function getXcUserHeader($moduleDirname, $tableName) * * @return string */ - public function getXcPermissionsHeader() + public function getXcPermissionsHeader(): string { $pc = Modulebuilder\Files\CreatePhpCode::getInstance(); $ret = $pc->getPhpCodeCommentLine('Permission'); @@ -544,7 +544,7 @@ public function getXcPermissionsHeader() * * @return string */ - public function getXcGetFieldId($fields) + public function getXcGetFieldId($fields): string { $fieldId = 'id'; foreach (\array_keys($fields) as $f) { @@ -564,7 +564,7 @@ public function getXcGetFieldId($fields) * * @return string */ - public function getXcGetFieldName($fields) + public function getXcGetFieldName($fields): string { $fieldName = ''; foreach (\array_keys($fields) as $f) { @@ -581,7 +581,7 @@ public function getXcGetFieldName($fields) * * @return string */ - public function getXcGetFieldParentId($fields) + public function getXcGetFieldParentId($fields): string { $fieldPid = 'pid'; foreach (\array_keys($fields) as $f) { @@ -603,7 +603,7 @@ public function getXcGetFieldParentId($fields) * @param $fields * @return string */ - public function getXcUserSaveElements($moduleDirname, $tableName, $tableSoleName, $fields) + public function getXcUserSaveElements($moduleDirname, $tableName, $tableSoleName, $fields): string { $axc = Modulebuilder\Files\Admin\AdminXoopsCode::getInstance(); $ret = ''; @@ -643,7 +643,7 @@ public function getXcUserSaveElements($moduleDirname, $tableName, $tableSoleName * @param string $t * @return string */ - public function getXcXoopsRequest(string $left = '', string $var1 = '', string $var2 = '', string $type = 'String', string $t = '') + public function getXcXoopsRequest(string $left = '', string $var1 = '', string $var2 = '', string $type = 'String', string $t = ''): string { $ret = ''; $intVars = ('' != $var2) ? "'{$var1}', {$var2}" : "'{$var1}'"; @@ -672,7 +672,7 @@ public function getXcXoopsRequest(string $left = '', string $var1 = '', string $ * @param string $t * @return string */ - public function getXcAddRight($anchor, string $permString = '', string $var = '', string $groups = '', string $mid = '', bool $isParam = false, string $t = '') + public function getXcAddRight($anchor, string $permString = '', string $var = '', string $groups = '', string $mid = '', bool $isParam = false, string $t = ''): string { if (!$isParam) { $ret = "{$t}\${$anchor}->addRight('{$permString}', {$var}, {$groups}, {$mid});\n"; @@ -696,7 +696,7 @@ public function getXcAddRight($anchor, string $permString = '', string $var = '' * @param string $t * @return string */ - public function getXcCheckRight($anchor, string $permString = '', string $var = '', string $groups = '', string $mid = '', bool $isParam = false, string $t = '') + public function getXcCheckRight($anchor, string $permString = '', string $var = '', string $groups = '', string $mid = '', bool $isParam = false, string $t = ''): string { if (!$isParam) { $ret = "{$t}{$anchor}->checkRight('{$permString}', {$var}, {$groups}, {$mid});\n"; @@ -719,7 +719,7 @@ public function getXcCheckRight($anchor, string $permString = '', string $var = * @param string $t * @return string */ - public function getXcDeleteRight($anchor, string $permString = '', string $mid = '', string $var = '', bool $isParam = false, string $t = '') + public function getXcDeleteRight($anchor, string $permString = '', string $mid = '', string $var = '', bool $isParam = false, string $t = ''): string { if (!$isParam) { $ret = "{$t}\${$anchor}->deleteByModule({$mid}, '{$permString}', {$var});\n"; @@ -736,7 +736,7 @@ public function getXcDeleteRight($anchor, string $permString = '', string $mid = * @param string $t * @return string */ - public function getXcHandlerLine($tableName, string $t = '') + public function getXcHandlerLine($tableName, string $t = ''): string { $ucfTableName = \ucfirst($tableName); @@ -751,7 +751,7 @@ public function getXcHandlerLine($tableName, string $t = '') * @param string $t * @return string */ - public function getXcHandlerCreateObj($tableName, string $t = '') + public function getXcHandlerCreateObj($tableName, string $t = ''): string { return "{$t}\${$tableName}Obj = \${$tableName}Handler->create();\n"; } @@ -764,7 +764,7 @@ public function getXcHandlerCreateObj($tableName, string $t = '') * @param string $t * @return string */ - public function getXcHandlerGetObj($tableName, $ccFieldId, string $t = '') + public function getXcHandlerGetObj($tableName, $ccFieldId, string $t = ''): string { return "{$t}\${$tableName}Obj = \${$tableName}Handler->get(\${$ccFieldId});\n"; } @@ -777,7 +777,7 @@ public function getXcHandlerGetObj($tableName, $ccFieldId, string $t = '') * @param string $t * @return string */ - public function getXcHandlerCountObj($tableName, string $t = '') + public function getXcHandlerCountObj($tableName, string $t = ''): string { $ucfTableName = \ucfirst($tableName); return "{$t}\${$tableName}Count = \${$tableName}Handler->getCount{$ucfTableName}();\n"; @@ -792,7 +792,7 @@ public function getXcHandlerCountObj($tableName, string $t = '') * * @return string */ - public function getXcHandlerCountClear($left, string $anchor = '', string $params = '', string $t = '') + public function getXcHandlerCountClear($left, string $anchor = '', string $params = '', string $t = ''): string { return "{$t}\${$left} = \${$anchor}Handler->getCount({$params});\n"; } @@ -808,7 +808,7 @@ public function getXcHandlerCountClear($left, string $anchor = '', string $param * @param string $t * @return string */ - public function getXcHandlerAllObj($tableName, string $fieldMain = '', string $start = '0', string $limit = '0', string $t = '') + public function getXcHandlerAllObj($tableName, string $fieldMain = '', string $start = '0', string $limit = '0', string $t = ''): string { $ucfTableName = \ucfirst($tableName); $startLimit = ('0' != $limit) ? "{$start}, {$limit}" : '0'; @@ -824,7 +824,7 @@ public function getXcHandlerAllObj($tableName, string $fieldMain = '', string $s * @param string $t * @return string */ - public function getXcHandlerAllClear($left, string $anchor = '', string $params = '', string $t = '') + public function getXcHandlerAllClear($left, string $anchor = '', string $params = '', string $t = ''): string { return "{$t}\${$left} = \${$anchor}Handler->getAll({$params});\n"; } @@ -841,7 +841,7 @@ public function getXcHandlerAllClear($left, string $anchor = '', string $params * @param string $t * @return string */ - public function getXcHandlerGet($left, $var, string $obj = '', string $handler = 'Handler', bool $isParam = false, string $t = '') + public function getXcHandlerGet($left, $var, string $obj = '', string $handler = 'Handler', bool $isParam = false, string $t = ''): string { if ($isParam) { $ret = "\${$left}{$handler}->get(\${$var})"; @@ -862,7 +862,7 @@ public function getXcHandlerGet($left, $var, string $obj = '', string $handler = * * @return string */ - public function getXcHandlerInsert($left, $var, string $obj = '', string $handler = 'Handler') + public function getXcHandlerInsert($left, $var, string $obj = '', string $handler = 'Handler'): string { return "\${$left}{$handler}->insert(\${$var}{$obj})"; } @@ -876,7 +876,7 @@ public function getXcHandlerInsert($left, $var, string $obj = '', string $handle * @param string $handler * @return string */ - public function getXcHandlerDelete($left, $var, string $obj = '', string $handler = 'Handler') + public function getXcHandlerDelete($left, $var, string $obj = '', string $handler = 'Handler'): string { return "\${$left}{$handler}->delete(\${$var}{$obj})"; } @@ -893,7 +893,7 @@ public function getXcHandlerDelete($left, $var, string $obj = '', string $handle * @param string $obj * @return string */ - public function getXcGetValues($tableName, $tableSoleName, string $index = 'i', bool $noArray = false, string $t = '', string $obj = '') + public function getXcGetValues($tableName, $tableSoleName, string $index = 'i', bool $noArray = false, string $t = '', string $obj = ''): string { $index = '' !== $index ? $index : 'i'; $ucfTableName = \ucfirst($tableName); @@ -915,7 +915,7 @@ public function getXcGetValues($tableName, $tableSoleName, string $index = 'i', * @param $fields * @return string */ - public function getXcSetVarsObjects($moduleDirname, $tableName, $tableSoleName, $fields) + public function getXcSetVarsObjects($moduleDirname, $tableName, $tableSoleName, $fields): string { $axc = Modulebuilder\Files\Admin\AdminXoopsCode::getInstance(); $ret = ''; @@ -971,7 +971,7 @@ public function getXcSetVarsObjects($moduleDirname, $tableName, $tableSoleName, * @param string $t * @return string */ - public function getXcSecurity($tableName, string $t = '') + public function getXcSecurity($tableName, string $t = ''): string { $pc = Modulebuilder\Files\CreatePhpCode::getInstance(); $securityError = $this->getXcXoopsSecurityErrors(); @@ -989,7 +989,7 @@ public function getXcSecurity($tableName, string $t = '') * @param string $t * @return string */ - public function getXcInsertData($tableName, $language, string $t = '') + public function getXcInsertData($tableName, $language, string $t = ''): string { $pc = Modulebuilder\Files\CreatePhpCode::getInstance(); $content = "{$t}\t" . $this->getXcRedirectHeader($tableName, '?op=list', 2, "{$language}FORM_OK"); @@ -1008,7 +1008,7 @@ public function getXcInsertData($tableName, $language, string $t = '') * @param string $t * @return string */ - public function getXcRedirectHeader($directory, $options, $numb, $var, bool $isString = true, string $t = '') + public function getXcRedirectHeader($directory, $options, $numb, $var, bool $isString = true, string $t = ''): string { if (!$isString) { $ret = "{$t}\\redirect_header({$directory}, {$numb}, {$var});\n"; @@ -1021,7 +1021,6 @@ public function getXcRedirectHeader($directory, $options, $numb, $var, bool $isS /** * @public function getXcXoopsConfirm - * @param $tableName * @param $language * @param $fieldId * @param $fieldMain @@ -1030,7 +1029,7 @@ public function getXcRedirectHeader($directory, $options, $numb, $var, bool $isS * @param string $t * @return string */ - public function getXcXoopsConfirm($tableName, $language, $fieldId, $fieldMain, string $options = 'delete', string $t = '') + public function getXcXoopsConfirm($language, $fieldId, $fieldMain, string $options = 'delete', string $t = ''): string { $stuOptions = \mb_strtoupper($options); $ccFieldId = Modulebuilder\Files\CreateFile::getInstance()->getCamelCase($fieldId, false, true); @@ -1063,7 +1062,7 @@ public function getXcXoopsConfirm($tableName, $language, $fieldId, $fieldMain, s * @param string $t * @return string */ - public function getXcHtmlErrors($tableName, bool $isParam = false, string $obj = 'Obj', string $t = '') + public function getXcHtmlErrors($tableName, bool $isParam = false, string $obj = 'Obj', string $t = ''): string { if ($isParam) { $ret = "\${$tableName}{$obj}->getHtmlErrors()"; @@ -1084,7 +1083,7 @@ public function getXcHtmlErrors($tableName, bool $isParam = false, string $obj = * @param string $t * @return string */ - public function getXcGetForm($left, $tableName, string $obj = '', string $t = '') + public function getXcGetForm($left, $tableName, string $obj = '', string $t = ''): string { $ucfTableName = \ucfirst($tableName); @@ -1102,7 +1101,7 @@ public function getXcGetForm($left, $tableName, string $obj = '', string $t = '' * @param string $t * @return string */ - public function getTopicGetVar($lpFieldName, $rpFieldName, $tableName, $tableNameTopic, $fieldNameParent, $fieldNameTopic, string $t = '') + public function getTopicGetVar($lpFieldName, $rpFieldName, $tableName, $tableNameTopic, $fieldNameParent, $fieldNameTopic, string $t = ''): string { $ret = Modulebuilder\Files\CreatePhpCode::getInstance()->getPhpCodeCommentLine('Get Var', $fieldNameParent, $t); $paramGet = $this->getXcGetVar('', "\${$tableName}All[\$i]", $fieldNameParent, true); @@ -1141,7 +1140,7 @@ public function getUploadImageGetVar($lpFieldName, $rpFieldName, $tableName, $fi * * @return string */ - public function getXcTableFieldId($fields) + public function getXcTableFieldId($fields): string { $fieldId = ''; foreach (\array_keys($fields) as $f) { @@ -1160,7 +1159,7 @@ public function getXcTableFieldId($fields) * * @return string */ - public function getXcTableFieldMain($fields) + public function getXcTableFieldMain($fields): string { $fieldMain = ''; foreach (\array_keys($fields) as $f) { @@ -1183,7 +1182,7 @@ public function getXcTableFieldMain($fields) * @param string $t * @return string */ - public function getXcSaveElements($moduleDirname, $tableName, $tableSoleName, $fields, string $t = '') + public function getXcSaveElements($moduleDirname, $tableName, $tableSoleName, $fields, string $t = ''): string { $axc = Modulebuilder\Files\Admin\AdminXoopsCode::getInstance(); $xc = Modulebuilder\Files\CreateXoopsCode::getInstance(); @@ -1256,7 +1255,7 @@ public function getXcSaveElements($moduleDirname, $tableName, $tableSoleName, $f * @param string $pageNavTplName * @return string */ - public function getXcPageNav($tableName, string $t = '', string $paramStart = 'start', string $paramOp = "'op=list&limit=' . \$limit", string $pageNavTplName = '') + public function getXcPageNav($tableName, string $t = '', string $paramStart = 'start', string $paramOp = "'op=list&limit=' . \$limit", string $pageNavTplName = ''): string { $pc = Modulebuilder\Files\CreatePhpCode::getInstance(); $cxc = Modulebuilder\Files\Classes\ClassXoopsCode::getInstance(); @@ -1276,7 +1275,7 @@ public function getXcPageNav($tableName, string $t = '', string $paramStart = 's * @param string $t * @return string */ - public function getXcGetGlobal($globals, string $t = '') + public function getXcGetGlobal($globals, string $t = ''): string { $ret = $t . 'global '; $detail = ''; @@ -1299,7 +1298,7 @@ public function getXcGetGlobal($globals, string $t = '') * * @return string */ - public function getXcCriteriaCompo($var, string $t = '') + public function getXcCriteriaCompo($var, string $t = ''): string { return "{$t}\${$var} = new \CriteriaCompo();\n"; } @@ -1316,7 +1315,7 @@ public function getXcCriteriaCompo($var, string $t = '') * * @return string */ - public function getXcCriteria($var, $param1, string $param2 = '', string $param3 = '', bool $isParam = false, string $t = '') + public function getXcCriteria($var, $param1, string $param2 = '', string $param3 = '', bool $isParam = false, string $t = ''): string { $params = ('' != $param2) ? ', ' . $param2 : ''; $params .= ('' != $param3) ? ', ' . $param3 : ''; @@ -1340,7 +1339,7 @@ public function getXcCriteria($var, $param1, string $param2 = '', string $param3 * @param string $condition * @return string */ - public function getXcCriteriaAdd($var, $param, string $t = '', string $n = "\n", string $condition = '') + public function getXcCriteriaAdd($var, $param, string $t = '', string $n = "\n", string $condition = ''): string { if ('' !== $condition) { $condition = ", {$condition}"; @@ -1359,7 +1358,7 @@ public function getXcCriteriaAdd($var, $param, string $t = '', string $n = "\n", * @param string $n * @return string */ - public function getXcCriteriaSetStart($var, $start, string $t = '', string $n = "\n") + public function getXcCriteriaSetStart($var, $start, string $t = '', string $n = "\n"): string { return "{$t}\${$var}->setStart({$start});{$n}"; } @@ -1374,7 +1373,7 @@ public function getXcCriteriaSetStart($var, $start, string $t = '', string $n = * @param string $n * @return string */ - public function getXcCriteriaSetLimit($var, $limit, string $t = '', string $n = "\n") + public function getXcCriteriaSetLimit($var, $limit, string $t = '', string $n = "\n"): string { return "{$t}\${$var}->setLimit({$limit});{$n}"; } @@ -1389,7 +1388,7 @@ public function getXcCriteriaSetLimit($var, $limit, string $t = '', string $n = * @param string $n * @return string */ - public function getXcCriteriaSetSort($var, $sort, string $t = '', string $n = "\n") + public function getXcCriteriaSetSort($var, $sort, string $t = '', string $n = "\n"): string { return "{$t}\${$var}->setSort({$sort});{$n}"; } @@ -1404,7 +1403,7 @@ public function getXcCriteriaSetSort($var, $sort, string $t = '', string $n = "\ * @param string $n * @return string */ - public function getXcCriteriaSetOrder($var, $order, string $t = '', string $n = "\n") + public function getXcCriteriaSetOrder($var, $order, string $t = '', string $n = "\n"): string { return "{$t}\${$var}->setOrder({$order});{$n}"; } @@ -1425,7 +1424,7 @@ public function getXcCriteriaSetOrder($var, $order, string $t = '', string $n = * * @return string */ - public function getXcXoopsFormGroupPerm(string $varLeft = '', string $formTitle = '', string $moduleId = '', string $permName = '', string $permDesc = '', string $filename = '', string $t = '') + public function getXcXoopsFormGroupPerm(string $varLeft = '', string $formTitle = '', string $moduleId = '', string $permName = '', string $permDesc = '', string $filename = '', string $t = ''): string { return "{$t}\${$varLeft} = new \XoopsGroupPermForm({$formTitle}, {$moduleId}, {$permName}, {$permDesc}, {$filename});\n"; } @@ -1441,7 +1440,7 @@ public function getXcXoopsFormGroupPerm(string $varLeft = '', string $formTitle * @param string $t * @return string */ - public function getXoopsFormSelectExtraOptions(string $varSelect = '', string $caption = '', string $var = '', array $options = [], string $setExtra = '', string $t = '') + public function getXoopsFormSelectExtraOptions(string $varSelect = '', string $caption = '', string $var = '', array $options = [], string $setExtra = '', string $t = ''): string { $ret = "{$t}\${$varSelect} = new \XoopsFormSelect({$caption}, '{$var}', \${$var});\n"; if ('' !== $setExtra) { @@ -1463,7 +1462,7 @@ public function getXoopsFormSelectExtraOptions(string $varSelect = '', string $c * @param mixed $const * @return string */ - public function getXcGetConstants($const) + public function getXcGetConstants($const): string { return "Constants::{$const}"; } @@ -1478,7 +1477,7 @@ public function getXcGetConstants($const) * * @return string */ - public function getXcXoopsCPHeader() + public function getXcXoopsCPHeader(): string { return "xoops_cp_header();\n"; } @@ -1488,7 +1487,7 @@ public function getXcXoopsCPHeader() * * @return string */ - public function getXcXoopsCPFooter() + public function getXcXoopsCPFooter(): string { return "xoops_cp_footer();\n"; } @@ -1500,7 +1499,7 @@ public function getXcXoopsCPFooter() * @param string $t * @return string */ - public function getXcXoopsLoad(string $var = '', string $t = '') + public function getXcXoopsLoad(string $var = '', string $t = ''): string { return "{$t}\xoops_load('{$var}');\n"; } @@ -1514,7 +1513,7 @@ public function getXcXoopsLoad(string $var = '', string $t = '') * * @return string */ - public function getXcXoopsLoadLanguage($lang, string $t = '', string $domain = '') + public function getXcXoopsLoadLanguage($lang, string $t = '', string $domain = ''): string { if ('' === $domain) { return "{$t}\xoops_loadLanguage('{$lang}');\n"; @@ -1528,7 +1527,7 @@ public function getXcXoopsLoadLanguage($lang, string $t = '', string $domain = ' * @param string $t * @return string */ - public function getXcXoopsCaptcha(string $t = '') + public function getXcXoopsCaptcha(string $t = ''): string { return "{$t}\$xoopsCaptcha = \XoopsCaptcha::getInstance();\n"; } @@ -1541,7 +1540,7 @@ public function getXcXoopsCaptcha(string $t = '') * * @return string */ - public function getXcXoopsListImgListArray($return, $var, string $t = '') + public function getXcXoopsListImgListArray($return, $var, string $t = ''): string { return "{$t}\${$return} = \XoopsLists::getImgListAsArray( {$var} );\n"; } @@ -1553,7 +1552,7 @@ public function getXcXoopsListImgListArray($return, $var, string $t = '') * * @return string */ - public function getXcXoopsListLangList($return, string $t = '') + public function getXcXoopsListLangList($return, string $t = ''): string { return "{$t}\${$return} = \XoopsLists::getLangList();\n"; } @@ -1565,7 +1564,7 @@ public function getXcXoopsListLangList($return, string $t = '') * * @return string */ - public function getXcXoopsListCountryList($return, string $t = '') + public function getXcXoopsListCountryList($return, string $t = ''): string { return "{$t}\${$return} = \XoopsLists::getCountryList();\n"; } @@ -1578,7 +1577,7 @@ public function getXcXoopsListCountryList($return, string $t = '') * * @return string */ - public function getXcXoopsUserUnameFromId($left, $value, string $t = '') + public function getXcXoopsUserUnameFromId($left, $value, string $t = ''): string { return "{$t}\${$left} = \XoopsUser::getUnameFromId({$value});\n"; } @@ -1593,7 +1592,7 @@ public function getXcXoopsUserUnameFromId($left, $value, string $t = '') * @param string $tpl * @return string */ - public function getXcXoopsTplAssign($tplString, $phpRender, bool $leftIsString = true, string $t = '', string $tpl = '') + public function getXcXoopsTplAssign($tplString, $phpRender, bool $leftIsString = true, string $t = '', string $tpl = ''): string { $assign = "{$t}\$GLOBALS['xoopsTpl']->assign("; if ('' !== $tpl) { @@ -1618,7 +1617,7 @@ public function getXcXoopsTplAssign($tplString, $phpRender, bool $leftIsString = * @param string $t * @return string */ - public function getXcXoopsTplAppend($tplString, $phpRender, string $t = '') + public function getXcXoopsTplAppend($tplString, $phpRender, string $t = ''): string { return "{$t}\$GLOBALS['xoopsTpl']->append('{$tplString}', {$phpRender});\n"; } @@ -1632,7 +1631,7 @@ public function getXcXoopsTplAppend($tplString, $phpRender, string $t = '') * @param string $t * @return string */ - public function getXcXoopsTplAppendByRef($tplString, $phpRender, string $t = '') + public function getXcXoopsTplAppendByRef($tplString, $phpRender, string $t = ''): string { return "{$t}\$GLOBALS['xoopsTpl']->appendByRef('{$tplString}', {$phpRender});\n"; } @@ -1645,7 +1644,7 @@ public function getXcXoopsTplAppendByRef($tplString, $phpRender, string $t = '') * @param bool $usedoublequotes * @return string */ - public function getXcXoopsTplDisplay(string $displayTpl = '{$templateMain}', string $t = '', bool $usedoublequotes = true) + public function getXcXoopsTplDisplay(string $displayTpl = '{$templateMain}', string $t = '', bool $usedoublequotes = true): string { if ($usedoublequotes) { return "{$t}\$GLOBALS['xoopsTpl']->display(\"db:{$displayTpl}\");\n"; @@ -1664,7 +1663,7 @@ public function getXcXoopsTplDisplay(string $displayTpl = '{$templateMain}', str * @param string $t * @return string */ - public function getXcXoopsPath($directory, $filename, bool $isParam = false, string $t = '') + public function getXcXoopsPath($directory, $filename, bool $isParam = false, string $t = ''): string { if (!$isParam) { $ret = "{$t}\$GLOBALS['xoops']->path({$directory}.'/{$filename}.php');\n"; @@ -1685,7 +1684,7 @@ public function getXcXoopsPath($directory, $filename, bool $isParam = false, str * @param string $t * @return string */ - public function getXcXoopsModuleGetInfo($left, $string, bool $isParam = false, string $t = '') + public function getXcXoopsModuleGetInfo($left, $string, bool $isParam = false, string $t = ''): string { if (!$isParam) { $ret = "{$t}\${$left} = \$GLOBALS['xoopsModule']->getInfo('{$string}');\n"; @@ -1704,7 +1703,7 @@ public function getXcXoopsModuleGetInfo($left, $string, bool $isParam = false, s * @param bool $isString * @return string */ - public function getXcXoThemeAddStylesheet(string $style = 'style', string $t = '', bool $isString = true) + public function getXcXoThemeAddStylesheet(string $style = 'style', string $t = '', bool $isString = true): string { $ret = "{$t}\$GLOBALS['xoTheme']->addStylesheet("; if ($isString) { @@ -1720,7 +1719,7 @@ public function getXcXoThemeAddStylesheet(string $style = 'style', string $t = ' * @param string $denial * @return string */ - public function getXcXoopsSecurityCheck(string $denial = '') + public function getXcXoopsSecurityCheck(string $denial = ''): string { return "{$denial}\$GLOBALS['xoopsSecurity']->check()"; } @@ -1730,7 +1729,7 @@ public function getXcXoopsSecurityCheck(string $denial = '') * * @return string */ - public function getXcXoopsSecurityErrors() + public function getXcXoopsSecurityErrors(): string { return "\$GLOBALS['xoopsSecurity']->getErrors()"; } @@ -1742,7 +1741,7 @@ public function getXcXoopsSecurityErrors() * @param string $n * @return string */ - public function getXcXoopsHandler($left, string $t = '', string $n = "\n") + public function getXcXoopsHandler($left, string $t = '', string $n = "\n"): string { return "{$t}\${$left}Handler = \xoops_getHandler('{$left}');{$n}"; } @@ -1760,7 +1759,7 @@ public function getXcXoopsHandler($left, string $t = '', string $n = "\n") * @param string $language * @return string */ - public function getXcCommonPagesEdit($tableName, $ccFieldId, string $t = '', string $language = '') + public function getXcCommonPagesEdit($tableName, $ccFieldId, string $t = '', string $language = ''): string { $pc = Modulebuilder\Files\CreatePhpCode::getInstance(); $xc = Modulebuilder\Files\CreateXoopsCode::getInstance(); @@ -1784,7 +1783,7 @@ public function getXcCommonPagesEdit($tableName, $ccFieldId, string $t = '', str * @param string $t * @return string */ - public function getXcCommonPagesNew($tableName, string $t = '') + public function getXcCommonPagesNew($tableName, string $t = ''): string { $pc = Modulebuilder\Files\CreatePhpCode::getInstance(); $xc = Modulebuilder\Files\CreateXoopsCode::getInstance(); @@ -1805,7 +1804,7 @@ public function getXcCommonPagesNew($tableName, string $t = '') * @param string $language * @return string */ - public function getXcCommonPagesClone($tableName, $ccFieldId, string $t = '', string $language = '') + public function getXcCommonPagesClone($tableName, $ccFieldId, string $t = '', string $language = ''): string { $pc = Modulebuilder\Files\CreatePhpCode::getInstance(); $xc = Modulebuilder\Files\CreateXoopsCode::getInstance(); @@ -1834,7 +1833,7 @@ public function getXcCommonPagesClone($tableName, $ccFieldId, string $t = '', st * @param bool $admin * @return string */ - public function getXcCommonPagesDelete($language, $tableName, $tableSoleName, $fieldId, $fieldMain, $tableNotifications, string $t = '', bool $admin = false) + public function getXcCommonPagesDelete($language, $tableName, $tableSoleName, $fieldId, $fieldMain, $tableNotifications, string $t = '', bool $admin = false): string { $pc = Modulebuilder\Files\CreatePhpCode::getInstance(); $xc = Modulebuilder\Files\CreateXoopsCode::getInstance(); @@ -1869,7 +1868,7 @@ public function getXcCommonPagesDelete($language, $tableName, $tableSoleName, $f $htmlErrors = $xc->getXcHtmlErrors($tableName, true); $internalElse = $xc->getXcXoopsTplAssign('error', $htmlErrors, true, $t . "\t\t"); $condition .= $pc->getPhpCodeConditions($delete, '', '', $contInsert, $internalElse, $t . "\t"); - $mainElse = $xc->getXcXoopsConfirm($tableName, $language, $fieldId, $fieldMain, 'delete', $t . "\t"); + $mainElse = $xc->getXcXoopsConfirm($language, $fieldId, $fieldMain, 'delete', $t . "\t"); $ret .= $pc->getPhpCodeConditions($isset, ' && ', "1 == \${$reqOk}", $condition, $mainElse, $t); return $ret; diff --git a/class/Files/Language/LanguageHelp.php b/class/Files/Language/LanguageHelp.php index fbec75d4..55bc8bc4 100644 --- a/class/Files/Language/LanguageHelp.php +++ b/class/Files/Language/LanguageHelp.php @@ -31,10 +31,6 @@ */ class LanguageHelp extends Files\CreateFile { - /** - * @var mixed - */ - //private $ld = null; /** * @public function constructor @@ -42,7 +38,6 @@ class LanguageHelp extends Files\CreateFile public function __construct() { parent::__construct(); - //$this->ld = LanguageDefines::getInstance(); } /** diff --git a/class/Files/Templates/Admin/TemplatesAdminBroken.php b/class/Files/Templates/Admin/TemplatesAdminBroken.php index 7057998d..404892d7 100644 --- a/class/Files/Templates/Admin/TemplatesAdminBroken.php +++ b/class/Files/Templates/Admin/TemplatesAdminBroken.php @@ -119,12 +119,12 @@ private function getTemplatesAdminBrokenTableThead(string $language) private function getTemplatesAdminBrokenTableTBody(string $tableName, $tableSoleName) { $td = ''; - $doubleKey = $this->sc->getSmartyDoubleVar($tableSoleName, 'key', '', '', "''|escape:'htmlattr'"); - $doubleVal = $this->sc->getSmartyDoubleVar($tableSoleName, 'keyval', '', '', "''|escape:'htmlattr'"); + $doubleKey = $this->sc->getSmartyDoubleVar($tableSoleName, 'key', '', '', "''", "'htmlattr'"); + $doubleVal = $this->sc->getSmartyDoubleVar($tableSoleName, 'keyval', '', '', "''", "'htmlattr'"); - $double = $this->sc->getSmartyDoubleVar($tableSoleName, 'table', '', '', "''|escape:'html'"); + $double = $this->sc->getSmartyDoubleVar($tableSoleName, 'table', '', '', "''", "'html'"); $td .= $this->hc->getHtmlTableData($double, 'center', '', "\t\t\t\t"); - $double = $this->sc->getSmartyDoubleVar($tableSoleName, 'main', '', '', "''|escape:'html'"); + $double = $this->sc->getSmartyDoubleVar($tableSoleName, 'main', '', '', "''", "'html'"); $td .= $this->hc->getHtmlTableData($double, 'center', '', "\t\t\t\t"); $lang = $this->sc->getSmartyConst('', '_EDIT'); $src = $this->sc->getSmartyNoSimbol("xoModuleIcons16 'edit.png'"); diff --git a/class/Files/Templates/Admin/TemplatesAdminPages.php b/class/Files/Templates/Admin/TemplatesAdminPages.php index 2abace26..76328a6d 100644 --- a/class/Files/Templates/Admin/TemplatesAdminPages.php +++ b/class/Files/Templates/Admin/TemplatesAdminPages.php @@ -155,7 +155,7 @@ private function getTemplatesAdminPagesTableTBody(string $moduleDirname, string switch ($fieldElement) { case Constants::FIELD_ELE_TEXTAREA: case Constants::FIELD_ELE_DHTMLTEXTAREA: - $double = $this->sc->getSmartyDoubleVar($tableSoleName, $rpFieldName . '_short', '', '', "''|escape:'html'"); + $double = $this->sc->getSmartyDoubleVar($tableSoleName, $rpFieldName . '_short', '', '', "''", "'html'"); $td .= $this->hc->getHtmlTableData($double, 'center', '',"\t\t\t\t"); break; case Constants::FIELD_ELE_CHECKBOX: @@ -174,20 +174,20 @@ private function getTemplatesAdminPagesTableTBody(string $moduleDirname, string break; case Constants::FIELD_ELE_IMAGELIST: $src = $this->sc->getSmartyNoSimbol('xoModuleIcons32'); - $src .= $this->sc->getSmartyDoubleVar($tableSoleName, $rpFieldName, '', '', "''|escape:'htmlattr'"); + $src .= $this->sc->getSmartyDoubleVar($tableSoleName, $rpFieldName, '', '', "''", "'htmlattr'"); $img = $this->hc->getHtmlTag('img', ['src' => $src, 'alt' => $tableName], '', true,'',''); $td .= $this->hc->getHtmlTableData($img, 'center', '',"\t\t\t\t"); break; case Constants::FIELD_ELE_UPLOADIMAGE: - $single = $this->sc->getSmartySingleVar($moduleDirname . '_upload_url','','',"''|escape:'htmlattr'"); - $double = $this->sc->getSmartyDoubleVar($tableSoleName, $rpFieldName,'','',"''|escape:'htmlattr'"); + $single = $this->sc->getSmartySingleVar($moduleDirname . '_upload_url','','',"''", "'htmlattr'"); + $double = $this->sc->getSmartyDoubleVar($tableSoleName, $rpFieldName,'','',"''", "'htmlattr'"); $img = $this->hc->getHtmlTag('img', ['src' => $single . "/images/{$tableName}/" . $double, 'alt' => $tableName, 'style' => 'max-width:100px'], '', true, '', ''); $td .= $this->hc->getHtmlTableData($img, 'center', '',"\t\t\t\t"); break; case Constants::FIELD_ELE_SELECTSTATUS: - $double = $this->sc->getSmartyDoubleVar($tableSoleName, 'status', '', '', "''|escape:'html'"); + $double = $this->sc->getSmartyDoubleVar($tableSoleName, 'status', '', '', "''", "'html'"); $src = $this->sc->getSmartyNoSimbol('$modPathIcon16') . 'status' . $double . '.png'; - $imgAlt = $this->sc->getSmartyDoubleVar($tableSoleName, 'status_text', '', '', "''|escape:'html'"); + $imgAlt = $this->sc->getSmartyDoubleVar($tableSoleName, 'status_text', '', '', "''", "'html'"); $img = $this->hc->getHtmlTag('img', ['src' => $src, 'alt' => $imgAlt, 'title' => $imgAlt], '', true,'',''); $td .= $this->hc->getHtmlTableData($img, 'center', '',"\t\t\t\t"); break; @@ -196,12 +196,12 @@ private function getTemplatesAdminPagesTableTBody(string $moduleDirname, string case Constants::FIELD_ELE_DATETIME: case Constants::FIELD_ELE_RADIO_ONOFFLINE: case Constants::FIELD_ELE_TEXTDATESELECT: - $double = $this->sc->getSmartyDoubleVar($tableSoleName, $rpFieldName . '_text', '', '', "''|escape:'html'"); + $double = $this->sc->getSmartyDoubleVar($tableSoleName, $rpFieldName . '_text', '', '', "''", "'html'"); $td .= $this->hc->getHtmlTableData($double, 'center', '',"\t\t\t\t"); break; default: if (0 != $f) { - $double = $this->sc->getSmartyDoubleVar($tableSoleName, $rpFieldName, '', '', "''|escape:'html'"); + $double = $this->sc->getSmartyDoubleVar($tableSoleName, $rpFieldName, '', '', "''", "'html'"); $td .= $this->hc->getHtmlTableData($double, 'center', '',"\t\t\t\t"); } break; diff --git a/class/Files/Templates/Blocks/Defstyle/TemplatesBlocks.php b/class/Files/Templates/Blocks/Defstyle/TemplatesBlocks.php index dccad169..3ee8c03e 100644 --- a/class/Files/Templates/Blocks/Defstyle/TemplatesBlocks.php +++ b/class/Files/Templates/Blocks/Defstyle/TemplatesBlocks.php @@ -148,19 +148,19 @@ private function getTemplatesBlocksTableTbody(string $moduleDirname, $tableId, $ break; case Constants::FIELD_ELE_IMAGELIST: $src = $this->sc->getSmartyNoSimbol('xoModuleIcons32'); - $src .= $this->sc->getSmartyDoubleVar($tableSoleName, $rpFieldName, '', '', "''|escape:'html'"); + $src .= $this->sc->getSmartyDoubleVar($tableSoleName, $rpFieldName, '', '', "''", "'html'"); $img = $this->hc->getHtmlTag('img', ['src' => $src, 'alt' => $tableName], '', true, '', ''); $td .= $this->hc->getHtmlTableData($img, 'center', '', "\t\t\t"); break; case Constants::FIELD_ELE_UPLOADIMAGE: - $single = $this->sc->getSmartySingleVar($moduleDirname . '_upload_url', '', '', "''|escape:'htmlattr'"); - $double = $this->sc->getSmartyDoubleVar($tableSoleName, $rpFieldName, '', '', "''|escape:'html'"); + $single = $this->sc->getSmartySingleVar($moduleDirname . '_upload_url', '', '', "''", "'htmlattr'"); + $double = $this->sc->getSmartyDoubleVar($tableSoleName, $rpFieldName, '', '', "''", "'html'"); $img = $this->hc->getHtmlTag('img', ['src' => $single . "/images/{$tableName}/" . $double, 'alt' => $tableName], '', true, '', ''); $td .= $this->hc->getHtmlTableData($img, 'center', '', "\t\t\t"); break; case Constants::FIELD_ELE_TEXTAREA: case Constants::FIELD_ELE_DHTMLTEXTAREA: - $double = $this->sc->getSmartyDoubleVar($tableSoleName, $rpFieldName . '_short', '', '', "''|escape:'html'"); + $double = $this->sc->getSmartyDoubleVar($tableSoleName, $rpFieldName . '_short', '', '', "''", "'html'"); $td .= $this->hc->getHtmlTableData($double, 'center', '', "\t\t\t"); break; case Constants::FIELD_ELE_SELECTSTATUS: @@ -169,12 +169,12 @@ private function getTemplatesBlocksTableTbody(string $moduleDirname, $tableId, $ case Constants::FIELD_ELE_SELECTUSER: case Constants::FIELD_ELE_DATETIME: case Constants::FIELD_ELE_TEXTDATESELECT: - $double = $this->sc->getSmartyDoubleVar($tableSoleName, $rpFieldName . '_text', '', '', "''|escape:'html'"); + $double = $this->sc->getSmartyDoubleVar($tableSoleName, $rpFieldName . '_text', '', '', "''", "'html'"); $td .= $this->hc->getHtmlTableData($double, 'center', '', "\t\t\t"); break; default: if (0 != $f) { - $double = $this->sc->getSmartyDoubleVar($tableSoleName, $rpFieldName, '', '', "''|escape:'html'"); + $double = $this->sc->getSmartyDoubleVar($tableSoleName, $rpFieldName, '', '', "''", "'html'"); $td .= $this->hc->getHtmlTableData($double, 'center', '', "\t\t\t"); } break; @@ -196,7 +196,7 @@ private function getTemplatesBlocksTableTbody(string $moduleDirname, $tableId, $ // $td .= $this->hc->getHtmlTag('td', ['class' => 'center'], "\n" . $anchor . "\t\t\t", false, "\t\t\t"); $double = $this->sc->getSmartyDoubleVar($tableSoleName, 'id'); $lang = $this->sc->getSmartyConst($language, $stuTableSoleName . '_GOTO|escape:"htmlattr"'); - $single = $this->sc->getSmartySingleVar($moduleDirname . '_url', '', '', "''|escape:'htmlattr'"); + $single = $this->sc->getSmartySingleVar($moduleDirname . '_url', '', '', "''", "'htmlattr'"); $anchor = $this->hc->getHtmlAnchor($single . '/' . $tableName . ".php?op=show&{$fieldId}=" . $double, $lang, $lang); $td .= $this->hc->getHtmlTableData($anchor, 'center', '', "\t\t\t"); $cycle = $this->sc->getSmartyNoSimbol('cycle values="odd, even"'); diff --git a/class/Files/Templates/User/Defstyle/Breadcrumbs.php b/class/Files/Templates/User/Defstyle/Breadcrumbs.php index f101fec4..42c55926 100644 --- a/class/Files/Templates/User/Defstyle/Breadcrumbs.php +++ b/class/Files/Templates/User/Defstyle/Breadcrumbs.php @@ -93,10 +93,10 @@ public function render() $moduleDirname = $module->getVar('mod_dirname'); $stuModuleDirname = \strtoupper($moduleDirname); - $title = $this->sc->getSmartyDoubleVar('itm', 'title','','','""|escape:"html"'); - $title2 = $this->sc->getSmartyDoubleVar('itm', 'title','','','""|escape:"htmlattr"'); - $titleElse = $this->sc->getSmartyDoubleVar('itm', 'title', "\t\t\t", "\n", '""|escape:"html"'); - $link = $this->sc->getSmartyDoubleVar('itm', 'link','','','""|escape:"htmlattr"'); + $title = $this->sc->getSmartyDoubleVar('itm', 'title','','',"''", "'html'"); + $title2 = $this->sc->getSmartyDoubleVar('itm', 'title','','',"''", "'htmlattr'"); + $titleElse = $this->sc->getSmartyDoubleVar('itm', 'title', "\t\t\t", "\n", "''", "'html'"); + $link = $this->sc->getSmartyDoubleVar('itm', 'link','','',"''", "'htmlattr'"); $glyph = $this->hc->getHtmlTag('i', ['class' => 'glyphicon glyphicon-home fa fa-home'], '', false, '', ''); $langHome = $this->sc->getSmartyConst('_MA_' . $stuModuleDirname, '_HOME'); $anchor = $this->hc->getHtmlAnchor("<{xoAppUrl 'index.php'}>", $glyph, $langHome); diff --git a/class/Files/Templates/User/Defstyle/Categories.php b/class/Files/Templates/User/Defstyle/Categories.php index 35d7e8db..6dda46ff 100644 --- a/class/Files/Templates/User/Defstyle/Categories.php +++ b/class/Files/Templates/User/Defstyle/Categories.php @@ -82,7 +82,7 @@ public function write($module, $table, string $filename): void * @param string $moduleDirname * @return string */ - private function getTemplatesUserCategoriesHeader(string $moduleDirname) + private function getTemplatesUserCategoriesHeader(string $moduleDirname): string { return $this->sc->getSmartyIncludeFile($moduleDirname) . PHP_EOL; } @@ -95,7 +95,7 @@ private function getTemplatesUserCategoriesHeader(string $moduleDirname) * @param $tableSoleName * @return string */ - private function getTemplatesUserCategoriesTable($moduleDirname, $tableName, $tableSoleName, string $language) + private function getTemplatesUserCategoriesTable($moduleDirname, $tableName, $tableSoleName, string $language): string { $single = $this->sc->getSmartySingleVar('table_type'); $table = $this->getTemplatesUserCategoriesThead($tableName, $language); @@ -110,7 +110,7 @@ private function getTemplatesUserCategoriesTable($moduleDirname, $tableName, $ta * @param $tableName * @return string */ - private function getTemplatesUserCategoriesThead($tableName, string $language) + private function getTemplatesUserCategoriesThead($tableName, string $language): string { $stuTableName = \mb_strtoupper($tableName); $lang = $this->sc->getSmartyConst($language, $stuTableName . '_TITLE'); @@ -128,7 +128,7 @@ private function getTemplatesUserCategoriesThead($tableName, string $language) * @param $tableSoleName * @return string */ - private function getTemplatesUserCategoriesTbody(string $moduleDirname, $tableName, $tableSoleName) + private function getTemplatesUserCategoriesTbody(string $moduleDirname, $tableName, $tableSoleName): string { $single = $this->sc->getSmartySingleVar('panel_type'); $include = $this->sc->getSmartyIncludeFileListForeach($moduleDirname, $tableName, $tableSoleName); @@ -146,7 +146,7 @@ private function getTemplatesUserCategoriesTbody(string $moduleDirname, $tableNa * @private function getTemplatesUserCategoriesTfoot * @return string */ - private function getTemplatesUserCategoriesTfoot() + private function getTemplatesUserCategoriesTfoot(): string { $td = $this->hc->getHtmlTableData(' ') . PHP_EOL; $tr = $this->hc->getHtmlTableRow($td) . PHP_EOL; @@ -162,7 +162,7 @@ private function getTemplatesUserCategoriesTfoot() * @param $language * @return string */ - private function getTemplatesUserCategories($moduleDirname, $tableName, $tableSoleName, $language) + private function getTemplatesUserCategories($moduleDirname, $tableName, $tableSoleName, $language): string { $tab = $this->getTemplatesUserCategoriesTable($moduleDirname, $tableName, $tableSoleName, $language) . PHP_EOL; $div = $this->hc->getHtmlDiv($tab, 'table-responsive') . PHP_EOL; @@ -178,7 +178,7 @@ private function getTemplatesUserCategories($moduleDirname, $tableName, $tableSo * @param $language * @return string */ - private function getTemplatesUserCategoriesPanel(string $moduleDirname, string $tableName, $tableSoleName, $language) + private function getTemplatesUserCategoriesPanel(string $moduleDirname, string $tableName, $tableSoleName, $language): string { $stuTableName = \mb_strtoupper($tableName); $incl = $this->sc->getSmartyIncludeFileListForeach($moduleDirname, $tableName, $tableSoleName) . PHP_EOL; @@ -199,7 +199,7 @@ private function getTemplatesUserCategoriesPanel(string $moduleDirname, string $ * * @return string */ - private function getTemplatesUserCategoriesFooter(string $moduleDirname) + private function getTemplatesUserCategoriesFooter(string $moduleDirname): string { return $this->sc->getSmartyIncludeFile($moduleDirname, 'footer'); } @@ -208,7 +208,7 @@ private function getTemplatesUserCategoriesFooter(string $moduleDirname) * @public function render * @return string */ - public function render() + public function render(): string { $module = $this->getModule(); $table = $this->getTable(); diff --git a/class/Files/Templates/User/Defstyle/PagesItem.php b/class/Files/Templates/User/Defstyle/PagesItem.php index d2eaab21..208c1438 100644 --- a/class/Files/Templates/User/Defstyle/PagesItem.php +++ b/class/Files/Templates/User/Defstyle/PagesItem.php @@ -72,8 +72,8 @@ public static function getInstance() * @public function write * @param $module * @param $table - * @param string $filename * @param $tables + * @param string $filename */ public function write($module, $table, $tables, string $filename): void { @@ -116,14 +116,14 @@ private function getTemplatesUserPagesItemPanel(string $moduleDirname, $tableId, default: $fieldName = $fields[$f]->getVar('field_name'); $rpFieldName = $this->getRightString($fieldName); - $doubleVar = $this->sc->getSmartyDoubleVar($tableSoleName, $rpFieldName, '', '', "''|escape:'html'"); + $doubleVar = $this->sc->getSmartyDoubleVar($tableSoleName, $rpFieldName, '', '', "''", "'html'"); $retNumb .= $this->hc->getHtmlHNumb($doubleVar, '3', 'panel-title', "\t"); break; case Constants::FIELD_ELE_TEXTAREA: case Constants::FIELD_ELE_DHTMLTEXTAREA: $fieldName = $fields[$f]->getVar('field_name'); $rpFieldName = $this->getRightString($fieldName); - $doubleVar = $this->sc->getSmartyDoubleVar($tableSoleName, $rpFieldName . '_short', '', '', "''|escape:'html'"); + $doubleVar = $this->sc->getSmartyDoubleVar($tableSoleName, $rpFieldName . '_short', '', '', "''", "'html'"); $retNumb .= $this->hc->getHtmlHNumb($doubleVar, '3', 'panel-title', "\t"); break; case Constants::FIELD_ELE_SELECTSTATUS: @@ -133,14 +133,14 @@ private function getTemplatesUserPagesItemPanel(string $moduleDirname, $tableId, case Constants::FIELD_ELE_TEXTDATESELECT: $fieldName = $fields[$f]->getVar('field_name'); $rpFieldName = $this->getRightString($fieldName); - $doubleVar = $this->sc->getSmartyDoubleVar($tableSoleName, $rpFieldName . '_text', '', '', "''|escape:'html'"); + $doubleVar = $this->sc->getSmartyDoubleVar($tableSoleName, $rpFieldName . '_text', '', '', "''", "'html'"); $retNumb .= $this->hc->getHtmlHNumb($doubleVar, '3', 'panel-title', "\t"); break; case Constants::FIELD_ELE_IMAGELIST: $fieldName = $fields[$f]->getVar('field_name'); $rpFieldName = $this->getRightString($fieldName); - $singleVar = $this->sc->getSmartySingleVar('xoops_icons32_url', '', '', "''|escape:'htmlattr'"); - $doubleVar = $this->sc->getSmartyDoubleVar($tableSoleName, $rpFieldName, '', '', "''|escape:'htmlattr'"); + $singleVar = $this->sc->getSmartySingleVar('xoops_icons32_url', '', '', "''", "'htmlattr'"); + $doubleVar = $this->sc->getSmartyDoubleVar($tableSoleName, $rpFieldName, '', '', "''", "'htmlattr'"); $img = $this->hc->getHtmlImage($singleVar . '/' . $doubleVar, (string)$tableName); $retNumb .= $this->hc->getHtmlHNumb($doubleVar, '3', 'panel-title', "\t"); unset($img); @@ -148,8 +148,8 @@ private function getTemplatesUserPagesItemPanel(string $moduleDirname, $tableId, case Constants::FIELD_ELE_UPLOADIMAGE: $fieldName = $fields[$f]->getVar('field_name'); $rpFieldName = $this->getRightString($fieldName); - $singleVar = $this->sc->getSmartySingleVar($moduleDirname . '_upload_url', '', '', "''|escape:'htmlattr'"); - $doubleVar = $this->sc->getSmartyDoubleVar($tableSoleName, $rpFieldName, '', '', "''|escape:'htmlattr'"); + $singleVar = $this->sc->getSmartySingleVar($moduleDirname . '_upload_url', '', '', "''", "'htmlattr'"); + $doubleVar = $this->sc->getSmartyDoubleVar($tableSoleName, $rpFieldName, '', '', "''", "'htmlattr'"); $img = $this->hc->getHtmlImage($singleVar . "/images/{$tableName}/" . $doubleVar, (string)$tableName); $retNumb .= $this->hc->getHtmlHNumb($doubleVar, '3', 'panel-title', "\t"); unset($img); @@ -169,14 +169,14 @@ private function getTemplatesUserPagesItemPanel(string $moduleDirname, $tableId, default: $fieldName = $fields[$f]->getVar('field_name'); $rpFieldName = $this->getRightString($fieldName); - $doubleVar = $this->sc->getSmartyDoubleVar($tableSoleName, $rpFieldName, '', '', "''|escape:'html'"); + $doubleVar = $this->sc->getSmartyDoubleVar($tableSoleName, $rpFieldName, '', '', "''", "'html'"); $retElem .= $this->hc->getHtmlSpan($doubleVar, 'col-sm-9 justify', "\t"); break; case Constants::FIELD_ELE_TEXTAREA: case Constants::FIELD_ELE_DHTMLTEXTAREA: $fieldName = $fields[$f]->getVar('field_name'); $rpFieldName = $this->getRightString($fieldName); - $doubleVar = $this->sc->getSmartyDoubleVar($tableSoleName, $rpFieldName . '_short', '', '', "''|escape:'html'"); + $doubleVar = $this->sc->getSmartyDoubleVar($tableSoleName, $rpFieldName . '_short', '', '', "''", "'html'"); $retElem .= $this->hc->getHtmlSpan($doubleVar, 'col-sm-9 justify', "\t"); break; case Constants::FIELD_ELE_SELECTSTATUS: @@ -186,14 +186,14 @@ private function getTemplatesUserPagesItemPanel(string $moduleDirname, $tableId, case Constants::FIELD_ELE_TEXTDATESELECT: $fieldName = $fields[$f]->getVar('field_name'); $rpFieldName = $this->getRightString($fieldName); - $doubleVar = $this->sc->getSmartyDoubleVar($tableSoleName, $rpFieldName . '_text', '', '', "''|escape:'html'"); + $doubleVar = $this->sc->getSmartyDoubleVar($tableSoleName, $rpFieldName . '_text', '', '', "''", "'html'"); $retElem .= $this->hc->getHtmlSpan($doubleVar, 'col-sm-9 justify', "\t"); break; case Constants::FIELD_ELE_IMAGELIST: $fieldName = $fields[$f]->getVar('field_name'); $rpFieldName = $this->getRightString($fieldName); - $singleVar = $this->sc->getSmartySingleVar('xoops_icons32_url', '', '', "''|escape:'htmlattr'"); - $doubleVar = $this->sc->getSmartyDoubleVar($tableSoleName, $rpFieldName, '', '', "''|escape:'htmlattr'"); + $singleVar = $this->sc->getSmartySingleVar('xoops_icons32_url', '', '', "''", "'htmlattr'"); + $doubleVar = $this->sc->getSmartyDoubleVar($tableSoleName, $rpFieldName, '', '', "''", "'htmlattr'"); $img = $this->hc->getHtmlImage($singleVar . '/' . $doubleVar, (string)$tableName); $retElem .= $this->hc->getHtmlSpan($img, 'col-sm-9 justify', "\t"); unset($img); @@ -201,8 +201,8 @@ private function getTemplatesUserPagesItemPanel(string $moduleDirname, $tableId, case Constants::FIELD_ELE_UPLOADIMAGE: $fieldName = $fields[$f]->getVar('field_name'); $rpFieldName = $this->getRightString($fieldName); - $singleVar = $this->sc->getSmartySingleVar($moduleDirname . '_upload_url', '', '', "''|escape:'htmlattr'"); - $doubleVar = $this->sc->getSmartyDoubleVar($tableSoleName, $rpFieldName, '', '', "''|escape:'htmlattr'"); + $singleVar = $this->sc->getSmartySingleVar($moduleDirname . '_upload_url', '', '', "''", "'htmlattr'"); + $doubleVar = $this->sc->getSmartyDoubleVar($tableSoleName, $rpFieldName, '', '', "''", "'htmlattr'"); $img = $this->hc->getHtmlImage($singleVar . "/images/{$tableName}/" . $doubleVar, (string)$tableName); $retElem .= $this->hc->getHtmlSpan($img, 'col-sm-9 justify',"\t"); unset($img); @@ -224,7 +224,7 @@ private function getTemplatesUserPagesItemPanel(string $moduleDirname, $tableId, $rpFieldName = $this->getRightString($fieldName); $langConst = \mb_strtoupper($tableSoleName) . '_' . \mb_strtoupper($rpFieldName); $lang = $this->sc->getSmartyConst($language, $langConst); - $doubleVar = $this->sc->getSmartyDoubleVar($tableSoleName, $rpFieldName, '', '', "''|escape:'html'"); + $doubleVar = $this->sc->getSmartyDoubleVar($tableSoleName, $rpFieldName, '', '', "''", "'html'"); $retFoot .= $this->hc->getHtmlSpan($lang . ': ' . $doubleVar, 'block-pie justify',"\t"); break; case Constants::FIELD_ELE_TEXTAREA: @@ -233,7 +233,7 @@ private function getTemplatesUserPagesItemPanel(string $moduleDirname, $tableId, $rpFieldName = $this->getRightString($fieldName); $langConst = \mb_strtoupper($tableSoleName) . '_' . \mb_strtoupper($rpFieldName); $lang = $this->sc->getSmartyConst($language, $langConst); - $doubleVar = $this->sc->getSmartyDoubleVar($tableSoleName, $rpFieldName . '_short', '', '', "''|escape:'html'"); + $doubleVar = $this->sc->getSmartyDoubleVar($tableSoleName, $rpFieldName . '_short', '', '', "''", "'html'"); $retFoot .= $this->hc->getHtmlSpan($lang . ': ' . $doubleVar, 'block-pie justify',"\t"); break; case Constants::FIELD_ELE_SELECTSTATUS: @@ -245,14 +245,14 @@ private function getTemplatesUserPagesItemPanel(string $moduleDirname, $tableId, $rpFieldName = $this->getRightString($fieldName); $langConst = \mb_strtoupper($tableSoleName) . '_' . \mb_strtoupper($rpFieldName); $lang = $this->sc->getSmartyConst($language, $langConst); - $doubleVar = $this->sc->getSmartyDoubleVar($tableSoleName, $rpFieldName . '_text', '', '', "''|escape:'html'"); + $doubleVar = $this->sc->getSmartyDoubleVar($tableSoleName, $rpFieldName . '_text', '', '', "''", "'html'"); $retFoot .= $this->hc->getHtmlSpan($lang . ': ' . $doubleVar, 'block-pie justify',"\t"); break; case Constants::FIELD_ELE_IMAGELIST: $fieldName = $fields[$f]->getVar('field_name'); $rpFieldName = $this->getRightString($fieldName); - $singleVar = $this->sc->getSmartySingleVar('xoops_icons32_url', '', '', "''|escape:'htmlattr'"); - $doubleVar = $this->sc->getSmartyDoubleVar($tableSoleName, $rpFieldName, '', '', "''|escape:'htmlattr'"); + $singleVar = $this->sc->getSmartySingleVar('xoops_icons32_url', '', '', "''", "'htmlattr'"); + $doubleVar = $this->sc->getSmartyDoubleVar($tableSoleName, $rpFieldName, '', '', "''", "'htmlattr'"); $img = $this->hc->getHtmlImage($singleVar . '/' . $doubleVar, (string)$tableName); $retFoot .= $this->hc->getHtmlSpan($img, 'block-pie justify', "\t"); unset($img); @@ -260,8 +260,8 @@ private function getTemplatesUserPagesItemPanel(string $moduleDirname, $tableId, case Constants::FIELD_ELE_UPLOADIMAGE: $fieldName = $fields[$f]->getVar('field_name'); $rpFieldName = $this->getRightString($fieldName); - $singleVar = $this->sc->getSmartySingleVar($moduleDirname . '_upload_url', '', '', "''|escape:'htmlattr'"); - $doubleVar = $this->sc->getSmartyDoubleVar($tableSoleName, $rpFieldName, '', '', "''|escape:'htmlattr'"); + $singleVar = $this->sc->getSmartySingleVar($moduleDirname . '_upload_url', '', '', "''", "'htmlattr'"); + $doubleVar = $this->sc->getSmartyDoubleVar($tableSoleName, $rpFieldName, '', '', "''", "'htmlattr'"); $img = $this->hc->getHtmlImage($singleVar . "/images/{$tableName}/" . $doubleVar, (string)$tableName); $retFoot .= $this->hc->getHtmlSpan($img, 'block-pie justify',"\t"); unset($img); diff --git a/class/Files/Templates/User/Defstyle/PagesList.php b/class/Files/Templates/User/Defstyle/PagesList.php index 7c31342a..db294997 100644 --- a/class/Files/Templates/User/Defstyle/PagesList.php +++ b/class/Files/Templates/User/Defstyle/PagesList.php @@ -93,7 +93,7 @@ public function write($module, $table, $tables, string $filename): void * @param $language * @return string */ - private function getTemplatesUserPagesListPanel(string $moduleDirname, $tableId, $tableMid, $tableName, $tableSoleName, $language) + private function getTemplatesUserPagesListPanel(string $moduleDirname, $tableId, $tableMid, $tableName, $tableSoleName, $language): string { $fields = $this->getTableFields($tableMid, $tableId); $ret = ''; @@ -280,7 +280,7 @@ private function getTemplatesUserPagesListPanel(string $moduleDirname, $tableId, * * @return string */ - public function render() + public function render(): string { $module = $this->getModule(); $table = $this->getTable(); diff --git a/class/Files/User/UserPages.php b/class/Files/User/UserPages.php index 41aefeb9..74b2b211 100644 --- a/class/Files/User/UserPages.php +++ b/class/Files/User/UserPages.php @@ -166,7 +166,7 @@ private function getUserPagesList($moduleDirname, $tableName, $fieldId, $fieldMa $ccFieldReads = $this->getCamelCase($fieldReads, false, true); $stuModuleDirname = \mb_strtoupper($moduleDirname); - $ret = $this->uxc->getUserBreadcrumbs($language, $tableName, 'list', '', "\t\t"); + $ret = $this->uxc->getUserBreadcrumbs($language, $tableName, 'list', '', $t); if ($tableRate) { $varRate = '$ratingbars'; $ret .= $this->xc->getXcEqualsOperator($varRate, '(int)' . $this->xc->getXcGetConfig('ratingbars'),'', $t); @@ -413,7 +413,7 @@ private function getPermissionsSave($moduleDirname, $ucfFieldId, string $perm = */ public function getUserPagesNew($tableName, $tableSoleName, $tablePermissions, $language, string $t = '') { - $ret = $this->uxc->getUserBreadcrumbs($language, $tableSoleName, 'add', '', "\t\t"); + $ret = $this->uxc->getUserBreadcrumbs($language, $tableSoleName, 'add', '', $t); if (1 == $tablePermissions) { $ret .= $this->pc->getPhpCodeCommentLine('Check permissions', '', $t); $contIf = $this->xc->getXcRedirectHeader($tableName, '?op=list', 3, '\_NOPERM', true, $t . "\t"); @@ -436,7 +436,7 @@ public function getUserPagesNew($tableName, $tableSoleName, $tablePermissions, $ */ public function getUserPagesEdit($tableName, $tableSoleName, $tablePermissions, $fieldId, $language, string $t = '') { - $ret = $this->uxc->getUserBreadcrumbs($language, $tableSoleName, 'edit', '', "\t\t"); + $ret = $this->uxc->getUserBreadcrumbs($language, $tableSoleName, 'edit', '', $t); $ccFieldId = $this->getCamelCase($fieldId, false, true); if (1 == $tablePermissions) { $ret .= $this->pc->getPhpCodeCommentLine('Check permissions', '', $t); @@ -463,7 +463,7 @@ public function getUserPagesEdit($tableName, $tableSoleName, $tablePermissions, */ public function getUserPagesClone($tableName, $tableSoleName, $tablePermissions, $fieldId, $language, string $t = '') { - $ret = $this->uxc->getUserBreadcrumbs($language, $tableSoleName, 'clone', '', "\t\t"); + $ret = $this->uxc->getUserBreadcrumbs($language, $tableSoleName, 'clone', '', $t); $ccFieldId = $this->getCamelCase($fieldId, false, true); if (1 == $tablePermissions) { $ret .= $this->pc->getPhpCodeCommentLine('Check permissions', '', $t); @@ -494,7 +494,7 @@ public function getUserPagesClone($tableName, $tableSoleName, $tablePermissions, */ private function getUserPagesDelete($tableName, $tableSoleName, $tablePermissions, $language, $fieldId, $fieldMain, $tableNotifications, string $t = '') { - $ret = $this->uxc->getUserBreadcrumbs($language, $tableSoleName, 'delete', '', "\t\t"); + $ret = $this->uxc->getUserBreadcrumbs($language, $tableSoleName, 'delete', '', $t); $ccFieldId = $this->getCamelCase($fieldId, false, true); if (1 == $tablePermissions) { $ret .= $this->pc->getPhpCodeCommentLine('Check permissions', '', $t); @@ -526,7 +526,7 @@ private function getUserPagesBroken($language, $moduleDirname, $tableName, $tabl { $ccFieldId = $this->getCamelCase($fieldId, false, true); $ccFieldMain = $this->getCamelCase($fieldMain, false, true); - $ret = $this->uxc->getUserBreadcrumbs($language, '', 'broken', '', "\t\t"); + $ret = $this->uxc->getUserBreadcrumbs($language, '', 'broken', '', $t); $ret .= $this->pc->getPhpCodeCommentLine('Check params', '', $t); $contIf = $this->xc->getXcRedirectHeader($tableName, '?op=list', 3, "{$language}INVALID_PARAM", true, $t . "\t"); $ret .= $this->pc->getPhpCodeConditions("\${$ccFieldId}", ' == ', '0', $contIf, false, $t); @@ -562,7 +562,7 @@ private function getUserPagesBroken($language, $moduleDirname, $tableName, $tabl $htmlErrors = $this->xc->getXcHtmlErrors($tableName, true); $internalElse = $this->xc->getXcXoopsTplAssign('error', $htmlErrors, true, $t . "\t\t"); $condition .= $this->pc->getPhpCodeConditions($insert, '', '', $contInsert, $internalElse, $t . "\t"); - $mainElse = $this->xc->getXcXoopsConfirm($tableName, $language, $fieldId, $fieldMain, 'broken', $t . "\t"); + $mainElse = $this->xc->getXcXoopsConfirm($language, $fieldId, $fieldMain, 'broken', $t . "\t"); $ret .= $this->pc->getPhpCodeConditions($isset, ' && ', "1 == \${$reqOk}", $condition, $mainElse, $t); return $ret; diff --git a/class/Files/User/UserPdf.php b/class/Files/User/UserPdf.php index b6a2da57..0a1c7035 100644 --- a/class/Files/User/UserPdf.php +++ b/class/Files/User/UserPdf.php @@ -134,9 +134,10 @@ private function getUserPdfHeader($moduleDirname, $tableName, $fields, $language * @param $tableName * @param $tableSolename * @param $fields + * @param $tablePermissions * @return string */ - public function getUserPdfTcpdf($moduleDirname, $tableName, $tableSolename, $fields) + public function getUserPdfTcpdf($moduleDirname, $tableName, $tableSolename, $fields, $tablePermissions) { $stuModuleDirname = \mb_strtoupper($moduleDirname); @@ -144,21 +145,22 @@ public function getUserPdfTcpdf($moduleDirname, $tableName, $tableSolename, $fie $ccFieldId = $this->getCamelCase($fieldId, false, true); $fieldMain = $this->xc->getXcTableFieldMain($fields); - $ret = $this->pc->getPhpCodeCommentLine('Check permissions'); - $ret .= $this->getSimpleString('$currentuid = 0;'); - $condIf = $this->getSimpleString('$currentuid = $xoopsUser->uid();', "\t"); - $ret .= $this->pc->getPhpCodeConditions('isset($xoopsUser) && \is_object($xoopsUser)', '', '', $condIf); - $ret .= $this->xc->getXcXoopsHandler('groupperm'); - $ret .= $this->xc->getXcXoopsHandler('member'); - $condIf = $this->getSimpleString('$my_group_ids = [\XOOPS_GROUP_ANONYMOUS];', "\t"); - $condElse = $this->getSimpleString('$my_group_ids = $memberHandler->getGroupsByUser($currentuid);', "\t"); - $ret .= $this->pc->getPhpCodeConditions('0', ' === ', '$currentuid', $condIf, $condElse); - $gperm = $this->xc->getXcCheckRight('!$grouppermHandler', "{$moduleDirname}_view_{$tableName}", "\${$ccFieldId}", '$my_group_ids', "\$GLOBALS['xoopsModule']->getVar('mid')", true); - $ret .= $this->pc->getPhpCodeCommentLine('Verify permissions'); - $noPerm = $this->xc->getXcRedirectHeader("\\{$stuModuleDirname}_URL . '/index.php'", '', '3', '\_NOPERM', false, "\t"); - $noPerm .= $this->getSimpleString('exit();', "\t"); - $ret .= $this->pc->getPhpCodeConditions($gperm, '', '', $noPerm); - + if (1 === $tablePermissions) { + $ret = $this->pc->getPhpCodeCommentLine('Check permissions'); + $ret .= $this->getSimpleString('$currentuid = 0;'); + $condIf = $this->getSimpleString('$currentuid = $xoopsUser->uid();', "\t"); + $ret .= $this->pc->getPhpCodeConditions('isset($xoopsUser) && \is_object($xoopsUser)', '', '', $condIf); + $ret .= $this->xc->getXcXoopsHandler('groupperm'); + $ret .= $this->xc->getXcXoopsHandler('member'); + $condIf = $this->getSimpleString('$my_group_ids = [\XOOPS_GROUP_ANONYMOUS];', "\t"); + $condElse = $this->getSimpleString('$my_group_ids = $memberHandler->getGroupsByUser($currentuid);', "\t"); + $ret .= $this->pc->getPhpCodeConditions('0', ' === ', '$currentuid', $condIf, $condElse); + $gperm = $this->xc->getXcCheckRight('!$grouppermHandler', "{$moduleDirname}_view_{$tableName}", "\${$ccFieldId}", '$my_group_ids', "\$GLOBALS['xoopsModule']->getVar('mid')", true); + $ret .= $this->pc->getPhpCodeCommentLine('Verify permissions'); + $noPerm = $this->xc->getXcRedirectHeader("\\{$stuModuleDirname}_URL . '/index.php'", '', '3', '\_NOPERM', false, "\t"); + $noPerm .= $this->getSimpleString('exit();', "\t"); + $ret .= $this->pc->getPhpCodeConditions($gperm, '', '', $noPerm); + } $ret .= $this->pc->getPhpCodeCommentLine('Set defaults'); $ret .= $this->xc->getXcEqualsOperator('$pdfFilename', "'$tableName.pdf'"); $ret .= $this->xc->getXcEqualsOperator('$content ', "''"); @@ -284,20 +286,21 @@ private function getUserPdfFooter($moduleDirname, $tableName) */ public function render() { - $module = $this->getModule(); - $table = $this->getTable(); - $filename = $this->getFileName(); - $moduleDirname = $module->getVar('mod_dirname'); - $tableId = $table->getVar('table_id'); - $tableMid = $table->getVar('table_mid'); - $tableName = $table->getVar('table_name'); - $tableSolename = $table->getVar('table_solename'); - $fields = $this->getTableFields($tableMid, $tableId); - $language = $this->getLanguage($moduleDirname, 'MA'); - $content = $this->getHeaderFilesComments($module); - $content .= $this->getUserPdfHeader($moduleDirname, $tableName, $fields, $language); - $content .= $this->getUserPdfTcpdf($moduleDirname, $tableName, $tableSolename, $fields); - $content .= $this->getUserPdfFooter($moduleDirname, $tableName); + $module = $this->getModule(); + $table = $this->getTable(); + $filename = $this->getFileName(); + $moduleDirname = $module->getVar('mod_dirname'); + $tableId = $table->getVar('table_id'); + $tableMid = $table->getVar('table_mid'); + $tableName = $table->getVar('table_name'); + $tableSolename = $table->getVar('table_solename'); + $tablePermissions = (int)$table->getVar('table_permissions'); + $fields = $this->getTableFields($tableMid, $tableId); + $language = $this->getLanguage($moduleDirname, 'MA'); + $content = $this->getHeaderFilesComments($module); + $content .= $this->getUserPdfHeader($moduleDirname, $tableName, $fields, $language); + $content .= $this->getUserPdfTcpdf($moduleDirname, $tableName, $tableSolename, $fields, $tablePermissions); + $content .= $this->getUserPdfFooter($moduleDirname, $tableName); $this->create($moduleDirname, '/', $filename, $content, \_AM_MODULEBUILDER_FILE_CREATED, \_AM_MODULEBUILDER_FILE_NOTCREATED); diff --git a/class/Files/User/UserPrint.php b/class/Files/User/UserPrint.php index 65fb8622..75a30cc4 100644 --- a/class/Files/User/UserPrint.php +++ b/class/Files/User/UserPrint.php @@ -84,7 +84,7 @@ public function write($module, $table, string $filename): void * * @return string */ - public function getUserPrint(string $moduleDirname, string $language) + public function getUserPrint(string $moduleDirname, string $language, int $tablePermissions) { $stuModuleDirname = \mb_strtoupper($moduleDirname); $table = $this->getTable(); @@ -122,15 +122,6 @@ public function getUserPrint(string $moduleDirname, string $language) $ret .= $this->pc->getPhpCodeCommentLine('Get Instance of Handler'); $ret .= $this->xc->getXcHandlerLine($tableName); - $ret .= $this->getSimpleString('$currentuid = 0;'); - $condIf = $this->getSimpleString('$currentuid = $xoopsUser->uid();', "\t"); - $ret .= $this->pc->getPhpCodeConditions('isset($xoopsUser) && \is_object($xoopsUser)', '', '', $condIf); - $ret .= $this->xc->getXcXoopsHandler('groupperm'); - $ret .= $this->xc->getXcXoopsHandler('member'); - $condIf = $this->getSimpleString('$my_group_ids = [\XOOPS_GROUP_ANONYMOUS];', "\t"); - $condElse = $this->getSimpleString('$my_group_ids = $memberHandler->getGroupsByUser($currentuid);', "\t"); - $ret .= $this->pc->getPhpCodeConditions('0', ' === ', '$currentuid', $condIf, $condElse); - $ret .= $this->pc->getPhpCodeCommentLine('Verify that the article is published'); if (false !== mb_strpos($fieldName, 'published')) { $ret .= $this->pc->getPhpCodeCommentLine('Not yet', $fieldName); @@ -156,11 +147,21 @@ public function getUserPrint(string $moduleDirname, string $language) $tablenameObj = $this->pc->getPhpCodeIsobject($tableName . 'Obj'); $redirectError = $this->xc->getXcRedirectHeader($tableName, '', '3', "{$language}INVALID_PARAM", true, "\t"); $ret .= $this->pc->getPhpCodeConditions('!' . $tablenameObj, '', '', $redirectError); - $gperm = $this->xc->getXcCheckRight('!$grouppermHandler', "{$moduleDirname}_view_{$tableName}", "\${$tableName}Obj->getVar('{$fieldId}')", '$my_group_ids', "\$GLOBALS['xoopsModule']->getVar('mid')", true); - $ret .= $this->pc->getPhpCodeCommentLine('Verify permissions'); - $noPerm = $this->xc->getXcRedirectHeader("\\{$stuModuleDirname}_URL . '/index.php'", '', '3', '\_NOPERM', false, "\t"); - $noPerm .= $this->getSimpleString('exit();', "\t"); - $ret .= $this->pc->getPhpCodeConditions($gperm, '', '', $noPerm); + if (1 === $tablePermissions) { + $ret .= $this->getSimpleString('$currentuid = 0;'); + $condIf = $this->getSimpleString('$currentuid = $xoopsUser->uid();', "\t"); + $ret .= $this->pc->getPhpCodeConditions('isset($xoopsUser) && \is_object($xoopsUser)', '', '', $condIf); + $ret .= $this->xc->getXcXoopsHandler('groupperm'); + $ret .= $this->xc->getXcXoopsHandler('member'); + $condIf = $this->getSimpleString('$my_group_ids = [\XOOPS_GROUP_ANONYMOUS];', "\t"); + $condElse = $this->getSimpleString('$my_group_ids = $memberHandler->getGroupsByUser($currentuid);', "\t"); + $ret .= $this->pc->getPhpCodeConditions('0', ' === ', '$currentuid', $condIf, $condElse); + $gperm = $this->xc->getXcCheckRight('!$grouppermHandler', "{$moduleDirname}_view_{$tableName}", "\${$tableName}Obj->getVar('{$fieldId}')", '$my_group_ids', "\$GLOBALS['xoopsModule']->getVar('mid')", true); + $ret .= $this->pc->getPhpCodeCommentLine('Verify permissions'); + $noPerm = $this->xc->getXcRedirectHeader("\\{$stuModuleDirname}_URL . '/index.php'", '', '3', '\_NOPERM', false, "\t"); + $noPerm .= $this->getSimpleString('exit();', "\t"); + $ret .= $this->pc->getPhpCodeConditions($gperm, '', '', $noPerm); + } $ret .= $this->xc->getXcGetValues($tableName, $tableSoleName . 'List', '', true, '', 'Obj'); $ret .= $this->xc->getXcXoopsTplAppend($tableName . '_list', '$' . $tableSoleName . 'List'); $ret .= $this->pc->getPhpCodeBlankLine(); @@ -179,12 +180,14 @@ public function getUserPrint(string $moduleDirname, string $language) */ public function render() { - $module = $this->getModule(); - $filename = $this->getFileName(); - $moduleDirname = $module->getVar('mod_dirname'); - $language = $this->getLanguage($moduleDirname, 'MA'); - $content = $this->getHeaderFilesComments($module); - $content .= $this->getUserPrint($moduleDirname, $language); + $module = $this->getModule(); + $filename = $this->getFileName(); + $table = $this->getTable(); + $tablePermissions = (int)$table->getVar('table_permissions'); + $moduleDirname = $module->getVar('mod_dirname'); + $language = $this->getLanguage($moduleDirname, 'MA'); + $content = $this->getHeaderFilesComments($module); + $content .= $this->getUserPrint($moduleDirname, $language, $tablePermissions); $this->create($moduleDirname, '/', $filename, $content, \_AM_MODULEBUILDER_FILE_CREATED, \_AM_MODULEBUILDER_FILE_NOTCREATED); diff --git a/class/Files/User/UserRate.php b/class/Files/User/UserRate.php index 0510f2e7..85861d08 100644 --- a/class/Files/User/UserRate.php +++ b/class/Files/User/UserRate.php @@ -254,7 +254,7 @@ public function getUserRateSave($tables, $language, $t, $moduleDirname) $sql .= $this->getSimpleString(") r ON r.rate_itemid = t." . $fieldId . " and r.rate_source = ' . \$source . '", $t . "\t\t\t"); $sql .= $this->getSimpleString('SET', $t . "\t\t\t"); $sql .= $this->getSimpleString('t.' . $fieldVotes . ' = COALESCE(r.votes, 0),', $t . "\t\t\t\t"); - $sql .= $this->getSimpleString('t.' . $fieldRatings . ' = COALESCE(r.avg_rating, 0),', $t . "\t\t\t\t"); + $sql .= $this->getSimpleString('t.' . $fieldRatings . ' = COALESCE(r.avg_rating, 0)', $t . "\t\t\t\t"); $sql .= $this->getSimpleString("WHERE t." . $fieldId . " = ' . \$itemid;", $t . "\t\t\t"); $contIfInt = $sql; diff --git a/class/Modules.php b/class/Modules.php index f18bbd3e..c2d379a7 100644 --- a/class/Modules.php +++ b/class/Modules.php @@ -353,45 +353,6 @@ public function getFormModules($action = false) return $form; } - /** - * @private static function createLogo - * @param mixed $logoIcon - * @param string $moduleDirname - * - * @return bool|string - */ - private static function createLogo($logoIcon, string $moduleDirname) - { - if (!\extension_loaded('gd')) { - return false; - } - $requiredFunctions = ['imagecreatefrompng', 'imagefttext', 'imagecopy', 'imagepng', 'imagedestroy', 'imagecolorallocate']; - foreach ($requiredFunctions as $func) { - if (!\function_exists($func)) { - return false; - } - } - - if (!\file_exists($imageBase = TDMC_IMAGES_LOGOS_PATH . '/empty.png') - || !\file_exists($font = TDMC_FONTS_PATH . '/VeraBd.ttf') - || !\file_exists($iconFile = XOOPS_ICONS32_PATH . '/' . \basename($logoIcon))) { - return false; - } - $imageModule = \imagecreatefrompng($imageBase); - $imageIcon = \imagecreatefrompng($iconFile); - // Write text - $textColor = imagecolorallocate($imageModule, 0, 0, 0); - $spaceBorder = (92 - mb_strlen($moduleDirname) * 7.5) / 2; - imagefttext($imageModule, 8.5, 0, $spaceBorder, 45, $textColor, $font, \ucfirst($moduleDirname)); - imagecopy($imageModule, $imageIcon, 29, 2, 0, 0, 32, 32); - $logoImg = '/' . 'logoModule.png'; - \imagepng($imageModule, TDMC_UPLOAD_IMGMOD_PATH . $logoImg); - \imagedestroy($imageModule); - \imagedestroy($imageIcon); - - return TDMC_UPLOAD_IMGMOD_URL . $logoImg; - } - /** * Get Values. * From 85be4bfdab97c20e49d01766b22710e4d725b099 Mon Sep 17 00:00:00 2001 From: "NB-GABOR02\\Goffy" Date: Wed, 8 Apr 2026 09:38:20 +0200 Subject: [PATCH 4/7] corrections coderabbitai 3 --- class/Common/DirectoryChecker.php | 6 +++--- class/Files/CreateXoopsCode.php | 15 ++++++++------- class/Files/Language/LanguageHelp.php | 5 ++++- .../Files/Templates/User/Defstyle/Breadcrumbs.php | 2 +- class/Files/User/UserPdf.php | 3 ++- class/Files/admin/AdminPages.php | 2 +- 6 files changed, 19 insertions(+), 14 deletions(-) diff --git a/class/Common/DirectoryChecker.php b/class/Common/DirectoryChecker.php index 77172127..1ed64fd4 100644 --- a/class/Common/DirectoryChecker.php +++ b/class/Common/DirectoryChecker.php @@ -150,9 +150,9 @@ public static function dirExists($dir_path) if (!\Xmf\Request::hasVar('path', 'POST') || !\Xmf\Request::hasVar('redirect', 'POST') || !\Xmf\Request::hasVar('mode', 'POST')) { break; } - $path = \Xmf\Request::getString('path', 'POST'); - $redirect = \Xmf\Request::getString('redirect', 'POST'); - $mode = \Xmf\Request::getInt('mode', 'POST'); + $path = \Xmf\Request::getString('path'); + $redirect = \Xmf\Request::getString('redirect'); + $mode = \Xmf\Request::getInt('mode'); $msg = DirectoryChecker::setDirectoryPermissions($path, $mode) ? \constant('CO_' . $moduleDirNameUpper . '_' . 'DC_PERMSET') : \constant('CO_' . $moduleDirNameUpper . '_' . 'DC_PERMNOTSET'); \redirect_header($redirect, 2, $msg . ': ' . $path); diff --git a/class/Files/CreateXoopsCode.php b/class/Files/CreateXoopsCode.php index 8c2b9e2e..45820900 100644 --- a/class/Files/CreateXoopsCode.php +++ b/class/Files/CreateXoopsCode.php @@ -177,11 +177,12 @@ public function getXcGetItemIds(string $var = '', string $anchor = '', $param1 = * @param $tableName * @param $tableSoleName * @param $fieldName - * @param string $t * @param string $language + * @param string $t + * * @return string */ - public function getXcSetVarTextDateSelect($tableName, $tableSoleName, $fieldName, string $t = '', string $language = ''): string + public function getXcSetVarTextDateSelect($tableName, $tableSoleName, $fieldName, string $language, string $t = ''): string { $cf = Modulebuilder\Files\CreateFile::getInstance(); $pc = Modulebuilder\Files\CreatePhpCode::getInstance(); @@ -622,10 +623,10 @@ public function getXcUserSaveElements($moduleDirname, $tableName, $tableSoleName $ret .= $axc->getAxcSetVarUploadImage($moduleDirname, $tableName, $fieldName, $fieldMain, '', $countUploader); $countUploader++; } elseif (14 == $fieldElement) { - $ret .= $axc->getAxcSetVarUploadFile($moduleDirname, $tableName, $fieldName, '', '', $countUploader); + $ret .= $axc->getAxcSetVarUploadFile($moduleDirname, $tableName, $fieldName, false, '', $countUploader); $countUploader++; } elseif (15 == $fieldElement) { - $ret .= $this->getXcSetVarTextDateSelect($tableName, $tableSoleName, $fieldName, '', $language); + $ret .= $this->getXcSetVarTextDateSelect($tableName, $tableSoleName, $fieldName, $language); } else { $ret .= $this->getXcSetVarObj($tableName, $fieldName, "\$_POST['{$fieldName}']"); } @@ -947,11 +948,11 @@ public function getXcSetVarsObjects($moduleDirname, $tableName, $tableSoleName, $countUploader++; break; case 14: - $ret .= $axc->getAxcSetVarUploadFile($moduleDirname, $tableName, $fieldName, false, $countUploader, $fieldMain); + $ret .= $axc->getAxcSetVarUploadFile($moduleDirname, $tableName, $fieldName, false, '', $countUploader, $fieldMain); $countUploader++; break; case 15: - $ret .= $this->getXcSetVarTextDateSelect($tableName, $tableSoleName, $fieldName, '', $language); + $ret .= $this->getXcSetVarTextDateSelect($tableName, $tableSoleName, $fieldName, $language); break; default: $ret .= $this->getXcSetVarObj($tableName, $fieldName, "\$_POST['{$fieldName}']"); @@ -1222,7 +1223,7 @@ public function getXcSaveElements($moduleDirname, $tableName, $tableSoleName, $f $countUploader++; break; case 15: - $fieldLines .= $this->getXcSetVarTextDateSelect($tableName, $tableSoleName, $fieldName, $t, $language); + $fieldLines .= $this->getXcSetVarTextDateSelect($tableName, $tableSoleName, $fieldName, $language, $t); break; case 17: $fieldLines .= $axc->getAxcSetVarPassword($tableName, $fieldName, $t); diff --git a/class/Files/Language/LanguageHelp.php b/class/Files/Language/LanguageHelp.php index 55bc8bc4..47de7a28 100644 --- a/class/Files/Language/LanguageHelp.php +++ b/class/Files/Language/LanguageHelp.php @@ -60,7 +60,7 @@ public static function getInstance() * @param $module * @param string $filename */ - public function write($module, string $filename): void + public function write(Modulebuilder\Modules $module, string $filename): void { $this->setModule($module); $this->setFileName($filename); @@ -109,6 +109,9 @@ public function render() EOT; if ('english' !== $language) { $this->create($moduleDirname, 'language/' . $language . '/help', $filename, $content, \_AM_MODULEBUILDER_FILE_CREATED, \_AM_MODULEBUILDER_FILE_NOTCREATED); + if (!$this->renderFile()) { + throw new \RuntimeException("The help.tpl file in 'language/" . $language . "/help' could not be created."); + } } $this->create($moduleDirname, 'language/english/help', $filename, $content, \_AM_MODULEBUILDER_FILE_CREATED, \_AM_MODULEBUILDER_FILE_NOTCREATED); diff --git a/class/Files/Templates/User/Defstyle/Breadcrumbs.php b/class/Files/Templates/User/Defstyle/Breadcrumbs.php index 42c55926..30d39485 100644 --- a/class/Files/Templates/User/Defstyle/Breadcrumbs.php +++ b/class/Files/Templates/User/Defstyle/Breadcrumbs.php @@ -86,7 +86,7 @@ public function write($module, string $filename): void * * @return string */ - public function render() + public function render(): string { $module = $this->getModule(); $filename = $this->getFileName(); diff --git a/class/Files/User/UserPdf.php b/class/Files/User/UserPdf.php index 0a1c7035..b38f7b7d 100644 --- a/class/Files/User/UserPdf.php +++ b/class/Files/User/UserPdf.php @@ -145,8 +145,9 @@ public function getUserPdfTcpdf($moduleDirname, $tableName, $tableSolename, $fie $ccFieldId = $this->getCamelCase($fieldId, false, true); $fieldMain = $this->xc->getXcTableFieldMain($fields); + $ret = ''; if (1 === $tablePermissions) { - $ret = $this->pc->getPhpCodeCommentLine('Check permissions'); + $ret .= $this->pc->getPhpCodeCommentLine('Check permissions'); $ret .= $this->getSimpleString('$currentuid = 0;'); $condIf = $this->getSimpleString('$currentuid = $xoopsUser->uid();', "\t"); $ret .= $this->pc->getPhpCodeConditions('isset($xoopsUser) && \is_object($xoopsUser)', '', '', $condIf); diff --git a/class/Files/admin/AdminPages.php b/class/Files/admin/AdminPages.php index 386e639b..2273b5eb 100644 --- a/class/Files/admin/AdminPages.php +++ b/class/Files/admin/AdminPages.php @@ -328,7 +328,7 @@ private function getAdminPagesSave($moduleDirname, $tableName, $tableSoleName, $ $countUploader++; break; case Constants::FIELD_ELE_TEXTDATESELECT: - $fieldLines .= $this->xc->getXcSetVarTextDateSelect($tableName, $tableSoleName, $fieldName, $t, $language); + $fieldLines .= $this->xc->getXcSetVarTextDateSelect($tableName, $tableSoleName, $fieldName, $language, $t); break; case Constants::FIELD_ELE_PASSWORD: $fieldLines .= $this->axc->getAxcSetVarPassword($tableName, $fieldName, $t); From 031e944f6a18b19cc352c234ff142a642d5bf9f5 Mon Sep 17 00:00:00 2001 From: "NB-GABOR02\\Goffy" Date: Wed, 8 Apr 2026 09:58:48 +0200 Subject: [PATCH 5/7] corrections coderabbitai 4 --- class/Common/DirectoryChecker.php | 10 +++++----- class/Files/Language/LanguageHelp.php | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/class/Common/DirectoryChecker.php b/class/Common/DirectoryChecker.php index 1ed64fd4..695fe35e 100644 --- a/class/Common/DirectoryChecker.php +++ b/class/Common/DirectoryChecker.php @@ -141,8 +141,8 @@ public static function dirExists($dir_path) if (!\Xmf\Request::hasVar('path', 'POST') || !\Xmf\Request::hasVar('redirect', 'POST')) { break; } - $path = \Xmf\Request::getString('path', 'POST'); - $redirect = \Xmf\Request::getString('redirect', 'POST'); + $path = \Xmf\Request::getString('path','', 'POST'); + $redirect = \Xmf\Request::getString('redirect','', 'POST'); $msg = DirectoryChecker::createDirectory($path) ? \constant('CO_' . $moduleDirNameUpper . '_' . 'DC_DIRCREATED') : \constant('CO_' . $moduleDirNameUpper . '_' . 'DC_DIRNOTCREATED'); \redirect_header($redirect, 2, $msg . ': ' . $path); break; @@ -150,9 +150,9 @@ public static function dirExists($dir_path) if (!\Xmf\Request::hasVar('path', 'POST') || !\Xmf\Request::hasVar('redirect', 'POST') || !\Xmf\Request::hasVar('mode', 'POST')) { break; } - $path = \Xmf\Request::getString('path'); - $redirect = \Xmf\Request::getString('redirect'); - $mode = \Xmf\Request::getInt('mode'); + $path = \Xmf\Request::getString('path','', 'POST'); + $redirect = \Xmf\Request::getString('redirect','', 'POST'); + $mode = \Xmf\Request::getInt('mode','', 'POST'); $msg = DirectoryChecker::setDirectoryPermissions($path, $mode) ? \constant('CO_' . $moduleDirNameUpper . '_' . 'DC_PERMSET') : \constant('CO_' . $moduleDirNameUpper . '_' . 'DC_PERMNOTSET'); \redirect_header($redirect, 2, $msg . ': ' . $path); diff --git a/class/Files/Language/LanguageHelp.php b/class/Files/Language/LanguageHelp.php index 47de7a28..e2e7aec9 100644 --- a/class/Files/Language/LanguageHelp.php +++ b/class/Files/Language/LanguageHelp.php @@ -110,7 +110,7 @@ public function render() if ('english' !== $language) { $this->create($moduleDirname, 'language/' . $language . '/help', $filename, $content, \_AM_MODULEBUILDER_FILE_CREATED, \_AM_MODULEBUILDER_FILE_NOTCREATED); if (!$this->renderFile()) { - throw new \RuntimeException("The help.tpl file in 'language/" . $language . "/help' could not be created."); + throw new \RuntimeException("The {$filename} file in 'language/" . $language . "/help' could not be created."); } } $this->create($moduleDirname, 'language/english/help', $filename, $content, \_AM_MODULEBUILDER_FILE_CREATED, \_AM_MODULEBUILDER_FILE_NOTCREATED); From fe27e7b39b0dec475769992dc12d0a07e67bc419 Mon Sep 17 00:00:00 2001 From: "NB-GABOR02\\Goffy" Date: Wed, 8 Apr 2026 16:46:51 +0200 Subject: [PATCH 6/7] corrections coderabbitai 5 --- class/Common/DirectoryChecker.php | 2 +- class/Files/Language/LanguageHelp.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/class/Common/DirectoryChecker.php b/class/Common/DirectoryChecker.php index 695fe35e..d8b7baae 100644 --- a/class/Common/DirectoryChecker.php +++ b/class/Common/DirectoryChecker.php @@ -152,7 +152,7 @@ public static function dirExists($dir_path) } $path = \Xmf\Request::getString('path','', 'POST'); $redirect = \Xmf\Request::getString('redirect','', 'POST'); - $mode = \Xmf\Request::getInt('mode','', 'POST'); + $mode = \Xmf\Request::getInt('mode',0 , 'POST'); $msg = DirectoryChecker::setDirectoryPermissions($path, $mode) ? \constant('CO_' . $moduleDirNameUpper . '_' . 'DC_PERMSET') : \constant('CO_' . $moduleDirNameUpper . '_' . 'DC_PERMNOTSET'); \redirect_header($redirect, 2, $msg . ': ' . $path); diff --git a/class/Files/Language/LanguageHelp.php b/class/Files/Language/LanguageHelp.php index e2e7aec9..3b87c4cf 100644 --- a/class/Files/Language/LanguageHelp.php +++ b/class/Files/Language/LanguageHelp.php @@ -57,7 +57,7 @@ public static function getInstance() /** * @public function write - * @param $module + * @param Modulebuilder\Modules $module * @param string $filename */ public function write(Modulebuilder\Modules $module, string $filename): void From da685c4d37b56bdd87aa8830bac41975d3a42185 Mon Sep 17 00:00:00 2001 From: "NB-GABOR02\\Goffy" Date: Wed, 8 Apr 2026 16:48:10 +0200 Subject: [PATCH 7/7] corrections coderabbitai 6 --- class/Files/Language/LanguageHelp.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/class/Files/Language/LanguageHelp.php b/class/Files/Language/LanguageHelp.php index 3b87c4cf..be96ba22 100644 --- a/class/Files/Language/LanguageHelp.php +++ b/class/Files/Language/LanguageHelp.php @@ -71,7 +71,7 @@ public function write(Modulebuilder\Modules $module, string $filename): void * * @return string */ - public function render() + public function render(): string { $module = $this->getModule(); $filename = $this->getFileName();