ggoffy /
modulebuilder
This project does not seem to handle request data directly as such no vulnerable execution paths were found.
include, or for example
via PHP's auto-loading mechanism.
| 1 | <?php |
||||
| 2 | |||||
| 3 | namespace XoopsModules\Modulebuilder\Files\Language; |
||||
| 4 | |||||
| 5 | use XoopsModules\Modulebuilder; |
||||
| 6 | use XoopsModules\Modulebuilder\Files; |
||||
| 7 | |||||
| 8 | /* |
||||
| 9 | You may not change or alter any portion of this comment or credits |
||||
| 10 | of supporting developers from this source code or any supporting source code |
||||
| 11 | which is considered copyrighted (c) material of the original comment or credit authors. |
||||
| 12 | |||||
| 13 | This program is distributed in the hope that it will be useful, |
||||
| 14 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
| 15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
||||
| 16 | */ |
||||
| 17 | /** |
||||
| 18 | * modulebuilder module. |
||||
| 19 | * |
||||
| 20 | * @copyright XOOPS Project (https://xoops.org) |
||||
| 21 | * @license GNU GPL 2 (https://www.gnu.org/licenses/old-licenses/gpl-2.0.html) |
||||
| 22 | * |
||||
| 23 | * @since 2.5.0 |
||||
| 24 | * |
||||
| 25 | * @author Txmod Xoops https://xoops.org |
||||
| 26 | * Goffy https://myxoops.org |
||||
| 27 | * |
||||
| 28 | */ |
||||
| 29 | |||||
| 30 | /** |
||||
| 31 | * Class LanguageMain. |
||||
| 32 | */ |
||||
| 33 | class LanguageMain extends Files\CreateFile |
||||
| 34 | { |
||||
| 35 | /** |
||||
| 36 | * @var mixed |
||||
| 37 | */ |
||||
| 38 | private $ld = null; |
||||
| 39 | |||||
| 40 | /** |
||||
| 41 | * @var mixed |
||||
| 42 | */ |
||||
| 43 | private $pc = null; |
||||
| 44 | |||||
| 45 | /** |
||||
| 46 | * @public function constructor |
||||
| 47 | * @param null |
||||
| 48 | */ |
||||
| 49 | public function __construct() |
||||
| 50 | { |
||||
| 51 | parent::__construct(); |
||||
| 52 | $this->ld = LanguageDefines::getInstance(); |
||||
| 53 | $this->pc = Modulebuilder\Files\CreatePhpCode::getInstance(); |
||||
| 54 | } |
||||
| 55 | |||||
| 56 | /** |
||||
| 57 | * @static function getInstance |
||||
| 58 | * @param null |
||||
| 59 | * @return LanguageMain |
||||
| 60 | */ |
||||
| 61 | public static function getInstance() |
||||
| 62 | { |
||||
| 63 | static $instance = false; |
||||
| 64 | if (!$instance) { |
||||
| 65 | $instance = new self(); |
||||
| 66 | } |
||||
| 67 | |||||
| 68 | return $instance; |
||||
| 69 | } |
||||
| 70 | |||||
| 71 | /** |
||||
| 72 | * @public function write |
||||
| 73 | * @param string $module |
||||
| 74 | * @param mixed $tables |
||||
| 75 | * @param string $filename |
||||
| 76 | */ |
||||
| 77 | public function write($module, $tables, $filename) |
||||
| 78 | { |
||||
| 79 | $this->setModule($module); |
||||
| 80 | $this->setFileName($filename); |
||||
| 81 | $this->setTables($tables); |
||||
| 82 | } |
||||
| 83 | |||||
| 84 | /** |
||||
| 85 | * @private function getLanguageMain |
||||
| 86 | * @param string $module |
||||
| 87 | * @param string $language |
||||
| 88 | * |
||||
| 89 | * @return string |
||||
| 90 | */ |
||||
| 91 | private function getLanguageMain($module, $language) |
||||
| 92 | { |
||||
| 93 | $utility = new \XoopsModules\Modulebuilder\Utility(); |
||||
| 94 | |||||
| 95 | $moduleName = $module->getVar('mod_name'); |
||||
| 96 | $tables = $this->getTables(); |
||||
| 97 | $ret = $this->ld->getBlankLine(); |
||||
| 98 | $ret .= $this->pc->getPhpCodeIncludeDir('__DIR__', 'admin', true); |
||||
| 99 | $ret .= $this->ld->getBlankLine(); |
||||
| 100 | $ret .= $this->ld->getAboveHeadDefines('Main'); |
||||
| 101 | $ret .= $this->ld->getDefine($language, 'INDEX', 'Overview ' . (string)$module->getVar('mod_name')); |
||||
| 102 | $ret .= $this->ld->getDefine($language, 'TITLE', (string)$module->getVar('mod_name')); |
||||
| 103 | $ret .= $this->ld->getDefine($language, 'DESC', (string)$module->getVar('mod_description')); |
||||
| 104 | $ret .= $this->ld->getDefine($language, 'INDEX_DESC',"Welcome to the homepage of your new module {$moduleName}!<br>This description is only visible on the homepage of this module."); |
||||
| 105 | $ret .= $this->ld->getDefine($language, 'NO_PDF_LIBRARY', 'Libraries TCPDF not there yet, upload them in root/Frameworks'); |
||||
| 106 | $ret .= $this->ld->getDefine($language, 'NO', 'No'); |
||||
| 107 | $ret .= $this->ld->getDefine($language, 'DETAILS', 'Show details'); |
||||
| 108 | $ret .= $this->ld->getDefine($language, 'BROKEN', 'Notify broken'); |
||||
| 109 | $ret .= $this->ld->getAboveHeadDefines('Contents'); |
||||
| 110 | $ucfTableName = ''; |
||||
| 111 | $ucfTableSoleName = ''; |
||||
|
0 ignored issues
–
show
Unused Code
introduced
by
Loading history...
|
|||||
| 112 | $stuTableSoleName = ''; |
||||
|
0 ignored issues
–
show
|
|||||
| 113 | $tableSoleName = ''; |
||||
|
0 ignored issues
–
show
|
|||||
| 114 | $tableSubmit = 0; |
||||
| 115 | $tableBroken = 0; |
||||
| 116 | $tableRate = 0; |
||||
| 117 | $tablePrint = 0; |
||||
| 118 | foreach (\array_keys($tables) as $i) { |
||||
| 119 | if (1 == $tables[$i]->getVar('table_user')) { |
||||
| 120 | $tableName = $tables[$i]->getVar('table_name'); |
||||
| 121 | $tableSoleName = $tables[$i]->getVar('table_solename'); |
||||
| 122 | if (1 === (int)$tables[$i]->getVar('table_submit')) { |
||||
| 123 | $tableSubmit = 1; |
||||
| 124 | } |
||||
| 125 | if (1 === (int)$tables[$i]->getVar('table_broken')) { |
||||
| 126 | $tableBroken = 1; |
||||
| 127 | } |
||||
| 128 | if (1 === (int)$tables[$i]->getVar('table_rate')) { |
||||
| 129 | $tableRate = 1; |
||||
| 130 | } |
||||
| 131 | if (1 === (int)$tables[$i]->getVar('table_print')) { |
||||
| 132 | $tablePrint = 1; |
||||
| 133 | } |
||||
| 134 | $stuTableName = \mb_strtoupper($tableName); |
||||
| 135 | $stuTableSoleName = \mb_strtoupper($tableSoleName); |
||||
| 136 | $ucfTableName = $utility::UcFirstAndToLower($tableName); |
||||
| 137 | $ucfTableSoleName = $utility::UcFirstAndToLower($tableSoleName); |
||||
| 138 | $ret .= $this->ld->getAboveDefines($ucfTableSoleName); |
||||
| 139 | $ret .= $this->ld->getDefine($language, $stuTableSoleName, $ucfTableSoleName); |
||||
| 140 | if (1 === $tableSubmit) { |
||||
| 141 | $ret .= $this->ld->getDefine($language, "{$stuTableSoleName}_ADD", "Add {$ucfTableSoleName}"); |
||||
| 142 | $ret .= $this->ld->getDefine($language, "{$stuTableSoleName}_EDIT", "Edit {$ucfTableSoleName}"); |
||||
| 143 | $ret .= $this->ld->getDefine($language, "{$stuTableSoleName}_DELETE", "Delete {$ucfTableSoleName}"); |
||||
| 144 | $ret .= $this->ld->getDefine($language, "{$stuTableSoleName}_CLONE", "Clone {$ucfTableSoleName}"); |
||||
| 145 | } |
||||
| 146 | $ret .= $this->ld->getDefine($language, $stuTableName, $ucfTableName); |
||||
| 147 | $ret .= $this->ld->getDefine($language, "{$stuTableName}_LIST", "List of {$ucfTableName}"); |
||||
| 148 | $ret .= $this->ld->getDefine($language, "{$stuTableName}_TITLE", "{$ucfTableName} title"); |
||||
| 149 | $ret .= $this->ld->getDefine($language, "{$stuTableName}_DESC", "{$ucfTableName} description"); |
||||
| 150 | |||||
| 151 | $ret .= $this->ld->getAboveDefines("Caption of {$ucfTableSoleName}"); |
||||
| 152 | $fields = $this->getTableFields($tables[$i]->getVar('table_mid'), $tables[$i]->getVar('table_id')); |
||||
| 153 | foreach (\array_keys($fields) as $f) { |
||||
| 154 | $fieldName = $fields[$f]->getVar('field_name'); |
||||
| 155 | $rpFieldName = $this->getRightString($fieldName); |
||||
| 156 | $fieldNameDesc = \ucfirst($rpFieldName); |
||||
| 157 | $ret .= $this->ld->getDefine($language, $stuTableSoleName . '_' . $rpFieldName, $fieldNameDesc); |
||||
| 158 | } |
||||
| 159 | } |
||||
| 160 | } |
||||
| 161 | $ret .= $this->ld->getDefine($language, 'INDEX_THEREARE', "There are %s {$ucfTableName}"); |
||||
| 162 | $ret .= $this->ld->getDefine($language, 'INDEX_LATEST_LIST', "Last {$module->getVar('mod_name')}"); |
||||
| 163 | if (1 === $tableSubmit) { |
||||
| 164 | $ret .= $this->ld->getAboveDefines('Submit'); |
||||
| 165 | $ret .= $this->ld->getDefine($language, 'SUBMIT', 'Submit'); |
||||
| 166 | $ret .= $this->ld->getAboveDefines('Form'); |
||||
| 167 | $ret .= $this->ld->getDefine($language, 'FORM_OK', 'Successfully saved'); |
||||
| 168 | $ret .= $this->ld->getDefine($language, 'FORM_DELETE_OK', 'Successfully deleted'); |
||||
| 169 | $ret .= $this->ld->getDefine($language, 'FORM_SURE_DELETE', "Are you sure to delete: <b><span style='color : Red;'>%s </span></b>", true); |
||||
| 170 | $ret .= $this->ld->getDefine($language, 'FORM_SURE_RENEW', "Are you sure to update: <b><span style='color : Red;'>%s </span></b>", true); |
||||
| 171 | if (1 === $tableBroken) { |
||||
| 172 | $ret .= $this->ld->getDefine($language, 'FORM_SURE_BROKEN', "Are you sure to notify as broken: <b><span style='color : Red;'>%s </span></b>", true); |
||||
| 173 | } |
||||
| 174 | $ret .= $this->ld->getDefine($language, 'INVALID_PARAM', 'Invalid parameter', false); |
||||
| 175 | } |
||||
| 176 | if (1 === $tableRate) { |
||||
| 177 | $ret .= $this->ld->getAboveHeadDefines('Ratings'); |
||||
| 178 | $ret .= $this->ld->getDefine($language, 'RATING_CURRENT_1', 'Rating: %c / %m (%t rating totally)'); |
||||
| 179 | $ret .= $this->ld->getDefine($language, 'RATING_CURRENT_X', 'Rating: %c / %m (%t ratings totally)'); |
||||
| 180 | $ret .= $this->ld->getDefine($language, 'RATING_CURRENT_SHORT_1', '%c (%t rating)'); |
||||
| 181 | $ret .= $this->ld->getDefine($language, 'RATING_CURRENT_SHORT_X', '%c (%t ratings)'); |
||||
| 182 | $ret .= $this->ld->getDefine($language, 'RATING1', '1 of 5'); |
||||
| 183 | $ret .= $this->ld->getDefine($language, 'RATING2', '2 of 5'); |
||||
| 184 | $ret .= $this->ld->getDefine($language, 'RATING3', '3 of 5'); |
||||
| 185 | $ret .= $this->ld->getDefine($language, 'RATING4', '4 of 5'); |
||||
| 186 | $ret .= $this->ld->getDefine($language, 'RATING5', '5 of 5'); |
||||
| 187 | $ret .= $this->ld->getDefine($language, 'RATING_10_1', '1 of 10'); |
||||
| 188 | $ret .= $this->ld->getDefine($language, 'RATING_10_2', '2 of 10'); |
||||
| 189 | $ret .= $this->ld->getDefine($language, 'RATING_10_3', '3 of 10'); |
||||
| 190 | $ret .= $this->ld->getDefine($language, 'RATING_10_4', '4 of 10'); |
||||
| 191 | $ret .= $this->ld->getDefine($language, 'RATING_10_5', '5 of 10'); |
||||
| 192 | $ret .= $this->ld->getDefine($language, 'RATING_10_6', '6 of 10'); |
||||
| 193 | $ret .= $this->ld->getDefine($language, 'RATING_10_7', '7 of 10'); |
||||
| 194 | $ret .= $this->ld->getDefine($language, 'RATING_10_8', '8 of 10'); |
||||
| 195 | $ret .= $this->ld->getDefine($language, 'RATING_10_9', '9 of 10'); |
||||
| 196 | $ret .= $this->ld->getDefine($language, 'RATING_10_10', '10 of 10'); |
||||
| 197 | $ret .= $this->ld->getDefine($language, 'RATING_VOTE_BAD', 'Invalid vote'); |
||||
| 198 | $ret .= $this->ld->getDefine($language, 'RATING_VOTE_ALREADY', 'You have already voted'); |
||||
| 199 | $ret .= $this->ld->getDefine($language, 'RATING_VOTE_THANKS', 'Thank you for rating'); |
||||
| 200 | $ret .= $this->ld->getDefine($language, 'RATING_NOPERM', "Sorry, you don't have permission to rate items", true); |
||||
| 201 | $ret .= $this->ld->getDefine($language, 'RATING_LIKE', 'Like'); |
||||
| 202 | $ret .= $this->ld->getDefine($language, 'RATING_DISLIKE', 'Dislike'); |
||||
| 203 | $ret .= $this->ld->getDefine($language, 'RATING_ERROR1', 'Error: update base table failed!'); |
||||
| 204 | } |
||||
| 205 | if (1 === $tablePrint) { |
||||
| 206 | $ret .= $this->ld->getAboveHeadDefines('Print'); |
||||
| 207 | $ret .= $this->ld->getDefine($language, 'PRINT', 'Print'); |
||||
| 208 | } |
||||
| 209 | return $ret; |
||||
| 210 | } |
||||
| 211 | |||||
| 212 | /** |
||||
| 213 | * @private function getLanguageMainFooter |
||||
| 214 | * @param string $language |
||||
| 215 | * |
||||
| 216 | * @return string |
||||
| 217 | */ |
||||
| 218 | private function getLanguageMainFooter($language) |
||||
| 219 | { |
||||
| 220 | $ret = $this->ld->getAboveDefines('Admin link'); |
||||
| 221 | $ret .= $this->ld->getDefine($language, 'ADMIN', 'Admin'); |
||||
| 222 | $ret .= $this->ld->getBelowDefines('End'); |
||||
| 223 | $ret .= $this->ld->getBlankLine(); |
||||
| 224 | |||||
| 225 | return $ret; |
||||
| 226 | } |
||||
| 227 | |||||
| 228 | /** |
||||
| 229 | * @public function render |
||||
| 230 | * @param null |
||||
| 231 | * @return bool|string |
||||
| 232 | */ |
||||
| 233 | public function render() |
||||
| 234 | { |
||||
| 235 | $module = $this->getModule(); |
||||
| 236 | $filename = $this->getFileName(); |
||||
| 237 | $moduleDirname = $module->getVar('mod_dirname'); |
||||
| 238 | $language = $this->getLanguage($moduleDirname, 'MA', '', false); |
||||
|
0 ignored issues
–
show
false of type false is incompatible with the type string expected by parameter $addFq of XoopsModules\Modulebuild...eateFile::getLanguage().
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||
| 239 | $content = $this->getHeaderFilesComments($module); |
||||
| 240 | $content .= $this->getLanguageMain($module, $language); |
||||
| 241 | $content .= $this->getLanguageMainFooter($language); |
||||
| 242 | |||||
| 243 | $this->create($moduleDirname, 'language/' . $GLOBALS['xoopsConfig']['language'], $filename, $content, \_AM_MODULEBUILDER_FILE_CREATED, \_AM_MODULEBUILDER_FILE_NOTCREATED); |
||||
| 244 | |||||
| 245 | return $this->renderFile(); |
||||
| 246 | } |
||||
| 247 | } |
||||
| 248 |