mambax7 /
tdmcreate-1.91
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 namespace XoopsModules\Tdmcreate\Files\Language; |
||||||||
| 2 | |||||||||
| 3 | use XoopsModules\Tdmcreate; |
||||||||
| 4 | use XoopsModules\Tdmcreate\Files; |
||||||||
| 5 | |||||||||
| 6 | /* |
||||||||
| 7 | You may not change or alter any portion of this comment or credits |
||||||||
| 8 | of supporting developers from this source code or any supporting source code |
||||||||
| 9 | which is considered copyrighted (c) material of the original comment or credit authors. |
||||||||
| 10 | |||||||||
| 11 | This program is distributed in the hope that it will be useful, |
||||||||
| 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||||||
| 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
||||||||
| 14 | */ |
||||||||
| 15 | /** |
||||||||
| 16 | * tdmcreate module. |
||||||||
| 17 | * |
||||||||
| 18 | * @copyright XOOPS Project (https://xoops.org) |
||||||||
| 19 | * @license GNU GPL 2 (http://www.gnu.org/licenses/old-licenses/gpl-2.0.html) |
||||||||
| 20 | * |
||||||||
| 21 | * @since 2.5.0 |
||||||||
| 22 | * |
||||||||
| 23 | * @author Txmod Xoops http://www.txmodxoops.org |
||||||||
| 24 | * |
||||||||
| 25 | * @version $Id: LanguageAdmin.php 12258 2014-01-02 09:33:29Z timgno $ |
||||||||
| 26 | */ |
||||||||
| 27 | |||||||||
| 28 | /** |
||||||||
| 29 | * Class LanguageAdmin. |
||||||||
| 30 | */ |
||||||||
| 31 | class LanguageAdmin extends Files\CreateFile |
||||||||
| 32 | { |
||||||||
| 33 | /** |
||||||||
| 34 | * @public function constructor |
||||||||
| 35 | * @param null |
||||||||
| 36 | */ |
||||||||
| 37 | public function __construct() |
||||||||
| 38 | { |
||||||||
| 39 | parent::__construct(); |
||||||||
| 40 | $this->defines = LanguageDefines::getInstance(); |
||||||||
|
0 ignored issues
–
show
Bug
Best Practice
introduced
by
Loading history...
|
|||||||||
| 41 | } |
||||||||
| 42 | |||||||||
| 43 | /** |
||||||||
| 44 | * @static function getInstance |
||||||||
| 45 | * @param null |
||||||||
| 46 | * @return LanguageAdmin |
||||||||
| 47 | */ |
||||||||
| 48 | public static function getInstance() |
||||||||
| 49 | { |
||||||||
| 50 | static $instance = false; |
||||||||
| 51 | if (!$instance) { |
||||||||
| 52 | $instance = new self(); |
||||||||
| 53 | } |
||||||||
| 54 | |||||||||
| 55 | return $instance; |
||||||||
| 56 | } |
||||||||
| 57 | |||||||||
| 58 | /** |
||||||||
| 59 | * @public function write |
||||||||
| 60 | * @param string $module |
||||||||
| 61 | * @param $table |
||||||||
| 62 | * @param string $tables |
||||||||
| 63 | * @param string $filename |
||||||||
| 64 | */ |
||||||||
| 65 | public function write($module, $table, $tables, $filename) |
||||||||
| 66 | { |
||||||||
| 67 | $this->setModule($module); |
||||||||
| 68 | $this->setTable($table); |
||||||||
| 69 | $this->setTables($tables); |
||||||||
| 70 | $this->setFileName($filename); |
||||||||
| 71 | } |
||||||||
| 72 | |||||||||
| 73 | /** |
||||||||
| 74 | * @public function getLanguageAdminIndex |
||||||||
| 75 | * @param string $language |
||||||||
| 76 | * @param string $tables |
||||||||
| 77 | * @return string |
||||||||
| 78 | */ |
||||||||
| 79 | public function getLanguageAdminIndex($language, $tables) |
||||||||
| 80 | { |
||||||||
| 81 | $ret = $this->defines->getAboveHeadDefines('Admin Index'); |
||||||||
| 82 | $ret .= $this->defines->getDefine($language, 'STATISTICS', 'Statistics'); |
||||||||
| 83 | $ret .= $this->defines->getAboveDefines('There are'); |
||||||||
| 84 | foreach (array_keys($tables) as $t) { |
||||||||
|
0 ignored issues
–
show
$tables of type string is incompatible with the type array expected by parameter $input of array_keys().
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||||||
| 85 | $tableName = $tables[$t]->getVar('table_name'); |
||||||||
| 86 | $stuTableName = mb_strtoupper($tableName); |
||||||||
| 87 | $stlTableName = mb_strtolower($tableName); |
||||||||
| 88 | $ret .= $this->defines->getDefine($language, "THEREARE_{$stuTableName}", "There are <span class='bold'>%s</span> {$stlTableName} in the database", true); |
||||||||
| 89 | } |
||||||||
| 90 | |||||||||
| 91 | return $ret; |
||||||||
| 92 | } |
||||||||
| 93 | |||||||||
| 94 | /** |
||||||||
| 95 | * @public function getLanguageAdminPages |
||||||||
| 96 | * @param string $language |
||||||||
| 97 | * @param string $tables |
||||||||
| 98 | * @return string |
||||||||
| 99 | */ |
||||||||
| 100 | public function getLanguageAdminPages($language, $tables) |
||||||||
| 101 | { |
||||||||
| 102 | $ret = $this->defines->getAboveHeadDefines('Admin Files'); |
||||||||
| 103 | $ret .= $this->defines->getAboveDefines('There aren\'t'); |
||||||||
| 104 | foreach (array_keys($tables) as $t) { |
||||||||
|
0 ignored issues
–
show
$tables of type string is incompatible with the type array expected by parameter $input of array_keys().
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||||||
| 105 | $tableName = $tables[$t]->getVar('table_name'); |
||||||||
| 106 | $stuTableName = mb_strtoupper($tableName); |
||||||||
| 107 | $stlTableName = mb_strtolower($tableName); |
||||||||
| 108 | $ret .= $this->defines->getDefine($language, "THEREARENT_{$stuTableName}", "There aren't {$stlTableName}", true); |
||||||||
| 109 | } |
||||||||
| 110 | $ret .= $this->defines->getAboveDefines('Save/Delete'); |
||||||||
| 111 | $ret .= $this->defines->getDefine($language, 'FORM_OK', 'Successfully saved'); |
||||||||
| 112 | $ret .= $this->defines->getDefine($language, 'FORM_DELETE_OK', 'Successfully deleted'); |
||||||||
| 113 | $ret .= $this->defines->getDefine($language, 'FORM_SURE_DELETE', "Are you sure to delete: <b><span style='color : Red;'>%s </span></b>", true); |
||||||||
| 114 | $ret .= $this->defines->getDefine($language, 'FORM_SURE_RENEW', "Are you sure to update: <b><span style='color : Red;'>%s </span></b>", true); |
||||||||
| 115 | $ret .= $this->defines->getAboveDefines('Buttons'); |
||||||||
| 116 | |||||||||
| 117 | foreach (array_keys($tables) as $t) { |
||||||||
| 118 | $tableName = $tables[$t]->getVar('table_name'); |
||||||||
|
0 ignored issues
–
show
|
|||||||||
| 119 | $tableSoleName = $tables[$t]->getVar('table_solename'); |
||||||||
| 120 | $stuTableSoleName = mb_strtoupper($tableSoleName); |
||||||||
| 121 | $ucfTableSoleName = ucfirst($tableSoleName); |
||||||||
| 122 | $ret .= $this->defines->getDefine($language, "ADD_{$stuTableSoleName}", "Add New {$ucfTableSoleName}"); |
||||||||
| 123 | } |
||||||||
| 124 | $ret .= $this->defines->getAboveDefines('Lists'); |
||||||||
| 125 | |||||||||
| 126 | foreach (array_keys($tables) as $t) { |
||||||||
| 127 | $tableName = $tables[$t]->getVar('table_name'); |
||||||||
| 128 | $stuTableName = mb_strtoupper($tableName); |
||||||||
| 129 | $ucfTableName = ucfirst($tableName); |
||||||||
| 130 | $ret .= $this->defines->getDefine($language, "{$stuTableName}_LIST", "List of {$ucfTableName}"); |
||||||||
| 131 | } |
||||||||
| 132 | |||||||||
| 133 | return $ret; |
||||||||
| 134 | } |
||||||||
| 135 | |||||||||
| 136 | /** |
||||||||
| 137 | * @public function getLanguageAdminClass |
||||||||
| 138 | * @param string $language |
||||||||
| 139 | * @param string $tables |
||||||||
| 140 | * @return string |
||||||||
| 141 | */ |
||||||||
| 142 | public function getLanguageAdminClass($language, $tables) |
||||||||
| 143 | { |
||||||||
| 144 | $ret = $this->defines->getAboveHeadDefines('Admin Classes'); |
||||||||
| 145 | |||||||||
| 146 | foreach (array_keys($tables) as $t) { |
||||||||
|
0 ignored issues
–
show
$tables of type string is incompatible with the type array expected by parameter $input of array_keys().
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||||||
| 147 | $tableId = $tables[$t]->getVar('table_id'); |
||||||||
| 148 | $tableMid = $tables[$t]->getVar('table_mid'); |
||||||||
| 149 | $tableName = $tables[$t]->getVar('table_name'); |
||||||||
| 150 | $tableSoleName = $tables[$t]->getVar('table_solename'); |
||||||||
| 151 | $ucfTableSoleName = ucfirst($tableSoleName); |
||||||||
| 152 | |||||||||
| 153 | $fields = $this->getTableFields($tableMid, $tableId); |
||||||||
| 154 | $fieldInForm = 0; |
||||||||
| 155 | foreach (array_keys($fields) as $f) { |
||||||||
| 156 | if ($fieldInForm < $fields[$f]->getVar('field_inform')) { |
||||||||
| 157 | $fieldInForm = $fields[$f]->getVar('field_inform'); |
||||||||
| 158 | } |
||||||||
| 159 | } |
||||||||
| 160 | if (1 == $fieldInForm) { |
||||||||
| 161 | $ret .= $this->defines->getAboveDefines("{$ucfTableSoleName} add/edit"); |
||||||||
| 162 | $ret .= $this->defines->getDefine($language, "{$tableSoleName}_ADD", "Add {$ucfTableSoleName}"); |
||||||||
| 163 | $ret .= $this->defines->getDefine($language, "{$tableSoleName}_EDIT", "Edit {$ucfTableSoleName}"); |
||||||||
| 164 | } |
||||||||
| 165 | $ret .= $this->defines->getAboveDefines("Elements of {$ucfTableSoleName}"); |
||||||||
| 166 | |||||||||
| 167 | foreach (array_keys($fields) as $f) { |
||||||||
| 168 | $fieldName = $fields[$f]->getVar('field_name'); |
||||||||
| 169 | $fieldElement = $fields[$f]->getVar('field_element'); |
||||||||
| 170 | $stuFieldName = mb_strtoupper($fieldName); |
||||||||
|
0 ignored issues
–
show
|
|||||||||
| 171 | |||||||||
| 172 | $rpFieldName = $this->getRightString($fieldName); |
||||||||
| 173 | if ($fieldElement > 15) { |
||||||||
| 174 | $fieldElements = Tdmcreate\Helper::getInstance()->getHandler('fieldelements')->get($fieldElement); |
||||||||
| 175 | $fieldElementTid = $fieldElements->getVar('fieldelement_tid'); |
||||||||
|
0 ignored issues
–
show
|
|||||||||
| 176 | $fieldElementName = $fieldElements->getVar('fieldelement_name'); |
||||||||
| 177 | $fieldNameDesc = mb_substr($fieldElementName, mb_strrpos($fieldElementName, ':'), mb_strlen($fieldElementName)); |
||||||||
|
0 ignored issues
–
show
It seems like
$fieldElementName can also be of type array and array; however, parameter $str of mb_strlen() does only seem to accept string, maybe add an additional type check?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
It seems like
$fieldElementName can also be of type array and array; however, parameter $haystack of mb_strrpos() does only seem to accept string, maybe add an additional type check?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
It seems like
$fieldElementName can also be of type array and array; however, parameter $str of mb_substr() does only seem to accept string, maybe add an additional type check?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||||||
| 178 | $fieldNameDesc = str_replace(': ', '', $fieldNameDesc); |
||||||||
| 179 | } else { |
||||||||
| 180 | $fieldNameDesc = false !== mb_strpos($rpFieldName, '_') ? str_replace('_', ' ', ucfirst($rpFieldName)) : ucfirst($rpFieldName); |
||||||||
| 181 | } |
||||||||
| 182 | |||||||||
| 183 | $ret .= $this->defines->getDefine($language, $tableSoleName . '_' . $rpFieldName, $fieldNameDesc); |
||||||||
| 184 | $stuTableName = mb_strtoupper($tableName); |
||||||||
| 185 | |||||||||
| 186 | switch ($fieldElement) { |
||||||||
| 187 | case 10: |
||||||||
| 188 | $ret .= $this->defines->getDefine($language, "FORM_IMAGE_LIST_{$stuTableName}", "{$fieldNameDesc} in frameworks images"); |
||||||||
| 189 | break; |
||||||||
| 190 | case 12: |
||||||||
| 191 | $ret .= $this->defines->getDefine($language, "FORM_URL_{$stuTableName}", "{$fieldNameDesc} in text url"); |
||||||||
| 192 | $ret .= $this->defines->getDefine($language, 'FORM_URL_UPLOAD', "{$fieldNameDesc} in uploads files"); |
||||||||
| 193 | break; |
||||||||
| 194 | case 13: |
||||||||
| 195 | $ret .= $this->defines->getDefine($language, "FORM_UPLOAD_IMAGE_{$stuTableName}", "{$fieldNameDesc} in uploads images"); |
||||||||
| 196 | break; |
||||||||
| 197 | case 14: |
||||||||
| 198 | $ret .= $this->defines->getDefine($language, "FORM_UPLOAD_FILE_{$stuTableName}", "{$fieldNameDesc} in uploads files"); |
||||||||
| 199 | break; |
||||||||
| 200 | } |
||||||||
| 201 | } |
||||||||
| 202 | } |
||||||||
| 203 | $ret .= $this->defines->getAboveDefines('General'); |
||||||||
| 204 | $ret .= $this->defines->getDefine($language, 'FORM_UPLOAD', 'Upload file'); |
||||||||
| 205 | $ret .= $this->defines->getDefine($language, 'FORM_IMAGE_PATH', 'Files in %s '); |
||||||||
| 206 | $ret .= $this->defines->getDefine($language, 'FORM_ACTION', 'Action'); |
||||||||
| 207 | $ret .= $this->defines->getDefine($language, 'FORM_EDIT', 'Modification'); |
||||||||
| 208 | $ret .= $this->defines->getDefine($language, 'FORM_DELETE', 'Clear'); |
||||||||
| 209 | |||||||||
| 210 | return $ret; |
||||||||
| 211 | } |
||||||||
| 212 | |||||||||
| 213 | /** |
||||||||
| 214 | * @public function getLanguageAdminPermissions |
||||||||
| 215 | * @param string $language |
||||||||
| 216 | * @return string |
||||||||
| 217 | */ |
||||||||
| 218 | public function getLanguageAdminPermissions($language) |
||||||||
| 219 | { |
||||||||
| 220 | $ret = $this->defines->getAboveHeadDefines('Admin Permissions'); |
||||||||
| 221 | $ret .= $this->defines->getAboveDefines('Permissions'); |
||||||||
| 222 | $ret .= $this->defines->getDefine($language, 'PERMISSIONS_GLOBAL', 'Permissions global'); |
||||||||
| 223 | $ret .= $this->defines->getDefine($language, 'PERMISSIONS_GLOBAL_DESC', 'Permissions global to check type of.'); |
||||||||
| 224 | $ret .= $this->defines->getDefine($language, 'PERMISSIONS_GLOBAL_4', 'Permissions global to approve'); |
||||||||
| 225 | $ret .= $this->defines->getDefine($language, 'PERMISSIONS_GLOBAL_8', 'Permissions global to submit'); |
||||||||
| 226 | $ret .= $this->defines->getDefine($language, 'PERMISSIONS_GLOBAL_16', 'Permissions global to view'); |
||||||||
| 227 | $ret .= $this->defines->getDefine($language, 'PERMISSIONS_APPROVE', 'Permissions to approve'); |
||||||||
| 228 | $ret .= $this->defines->getDefine($language, 'PERMISSIONS_APPROVE_DESC', 'Permissions to approve'); |
||||||||
| 229 | $ret .= $this->defines->getDefine($language, 'PERMISSIONS_SUBMIT', 'Permissions to submit'); |
||||||||
| 230 | $ret .= $this->defines->getDefine($language, 'PERMISSIONS_SUBMIT_DESC', 'Permissions to submit'); |
||||||||
| 231 | $ret .= $this->defines->getDefine($language, 'PERMISSIONS_VIEW', 'Permissions to view'); |
||||||||
| 232 | $ret .= $this->defines->getDefine($language, 'PERMISSIONS_VIEW_DESC', 'Permissions to view'); |
||||||||
| 233 | $ret .= $this->defines->getDefine($language, 'NO_PERMISSIONS_SET', 'No permission set'); |
||||||||
| 234 | |||||||||
| 235 | return $ret; |
||||||||
| 236 | } |
||||||||
| 237 | |||||||||
| 238 | /** |
||||||||
| 239 | * @public function getLanguageAdminFoot |
||||||||
| 240 | * @param string $language |
||||||||
| 241 | * @return string |
||||||||
| 242 | */ |
||||||||
| 243 | public function getLanguageAdminFoot($language) |
||||||||
| 244 | { |
||||||||
| 245 | $ret = $this->defines->getAboveHeadDefines('Admin Others'); |
||||||||
| 246 | $ret .= $this->defines->getDefine($language, 'MAINTAINEDBY', ' is maintained by '); |
||||||||
| 247 | $ret .= $this->defines->getBelowDefines('End'); |
||||||||
| 248 | |||||||||
| 249 | return $ret; |
||||||||
| 250 | } |
||||||||
| 251 | |||||||||
| 252 | /** |
||||||||
| 253 | * @public function render |
||||||||
| 254 | * @param null |
||||||||
| 255 | * @return bool|string |
||||||||
| 256 | */ |
||||||||
| 257 | public function render() |
||||||||
| 258 | { |
||||||||
| 259 | $module = $this->getModule(); |
||||||||
| 260 | $tables = $this->getTableTables($module->getVar('mod_id')); |
||||||||
| 261 | foreach (array_keys($tables) as $t) { |
||||||||
| 262 | $tablePermissions[] = $tables[$t]->getVar('table_permissions'); |
||||||||
| 263 | } |
||||||||
| 264 | $tables = $this->getTables(); |
||||||||
| 265 | $filename = $this->getFileName(); |
||||||||
| 266 | $moduleDirname = $module->getVar('mod_dirname'); |
||||||||
| 267 | $language = $this->getLanguage($moduleDirname, 'AM'); |
||||||||
| 268 | $content = $this->getHeaderFilesComments($module, $filename); |
||||||||
| 269 | if (is_array($tables)) { |
||||||||
| 270 | $content .= $this->getLanguageAdminIndex($language, $tables); |
||||||||
| 271 | $content .= $this->getLanguageAdminPages($language, $tables); |
||||||||
| 272 | $content .= $this->getLanguageAdminClass($language, $tables); |
||||||||
| 273 | } |
||||||||
| 274 | if (in_array(1, $tablePermissions)) { |
||||||||
|
0 ignored issues
–
show
Comprehensibility
Best Practice
introduced
by
|
|||||||||
| 275 | $content .= $this->getLanguageAdminPermissions($language); |
||||||||
| 276 | } |
||||||||
| 277 | $content .= $this->getLanguageAdminFoot($language); |
||||||||
| 278 | |||||||||
| 279 | $this->create($moduleDirname, 'language/' . $GLOBALS['xoopsConfig']['language'], $filename, $content, _AM_TDMCREATE_FILE_CREATED, _AM_TDMCREATE_FILE_NOTCREATED); |
||||||||
| 280 | |||||||||
| 281 | return $this->renderFile(); |
||||||||
| 282 | } |
||||||||
| 283 | } |
||||||||
| 284 |