Conditions | 12 |
Paths | 408 |
Total Lines | 119 |
Code Lines | 102 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
1 | <?php |
||
90 | private function getLanguageMain($module, $language) |
||
91 | { |
||
92 | /** @var \XoopsModules\Modulebuilder\Utility $utility */ |
||
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', 'Home'); |
||
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( |
||
105 | $language, |
||
106 | 'INDEX_DESC', |
||
107 | "Welcome to the homepage of your new module {$moduleName}!<br> |
||
108 | As you can see, you have created a page with a list of links at the top to navigate between the pages of your module. This description is only visible on the homepage of this module, the other pages you will see the content you created when you built this module with the module ModuleBuilder, and after creating new content in admin of this module. In order to expand this module with other resources, just add the code you need to extend the functionality of the same. The files are grouped by type, from the header to the footer to see how divided the source code.<br><br>If you see this message, it is because you have not created content for this module. Once you have created any type of content, you will not see this message.<br><br>If you liked the module ModuleBuilder and thanks to the long process for giving the opportunity to the new module to be created in a moment, consider making a donation to keep the module ModuleBuilder and make a donation using this button <a href='http://www.txmodxoops.org/modules/xdonations/index.php' title='Donation To Txmod Xoops'><img src='https://www.paypal.com/en_US/i/btn/btn_donate_LG.gif' alt='Button Donations' /></a><br>Thanks!<br><br>Use the link below to go to the admin and create content.", |
||
109 | true |
||
110 | ); |
||
111 | $ret .= $this->ld->getDefine($language, 'NO_PDF_LIBRARY', 'Libraries TCPDF not there yet, upload them in root/Frameworks'); |
||
112 | $ret .= $this->ld->getDefine($language, 'NO', 'No'); |
||
113 | $ret .= $this->ld->getDefine($language, 'DETAILS', 'Show details'); |
||
114 | $ret .= $this->ld->getDefine($language, 'BROKEN', 'Notify broken'); |
||
115 | $ret .= $this->ld->getAboveHeadDefines('Contents'); |
||
116 | $ucfTableName = ''; |
||
117 | $ucfTableSoleName = ''; |
||
|
|||
118 | $stuTableSoleName = ''; |
||
119 | $tableSoleName = ''; |
||
120 | $tableSubmit = 0; |
||
121 | $tableBroken = 0; |
||
122 | $tableRate = 0; |
||
123 | $tablePrint = 0; |
||
124 | foreach (\array_keys($tables) as $i) { |
||
125 | if (1 == $tables[$i]->getVar('table_user')) { |
||
126 | $tableName = $tables[$i]->getVar('table_name'); |
||
127 | $tableSoleName = $tables[$i]->getVar('table_solename'); |
||
128 | if (1 === (int)$tables[$i]->getVar('table_submit')) { |
||
129 | $tableSubmit = 1; |
||
130 | } |
||
131 | if (1 === (int)$tables[$i]->getVar('table_broken')) { |
||
132 | $tableBroken = 1; |
||
133 | } |
||
134 | if (1 === (int)$tables[$i]->getVar('table_rate')) { |
||
135 | $tableRate = 1; |
||
136 | } |
||
137 | if (1 === (int)$tables[$i]->getVar('table_print')) { |
||
138 | $tablePrint = 1; |
||
139 | } |
||
140 | $stuTableName = \mb_strtoupper($tableName); |
||
141 | $stuTableSoleName = \mb_strtoupper($tableSoleName); |
||
142 | $ucfTableName = $utility::UcFirstAndToLower($tableName); |
||
143 | $ucfTableSoleName = $utility::UcFirstAndToLower($tableSoleName); |
||
144 | $ret .= $this->ld->getAboveDefines($ucfTableSoleName); |
||
145 | $ret .= $this->ld->getDefine($language, $stuTableSoleName, $ucfTableSoleName); |
||
146 | $ret .= $this->ld->getDefine($language, $stuTableName, $ucfTableName); |
||
147 | $ret .= $this->ld->getDefine($language, "{$stuTableName}_TITLE", "{$ucfTableName} title"); |
||
148 | $ret .= $this->ld->getDefine($language, "{$stuTableName}_DESC", "{$ucfTableName} description"); |
||
149 | $ret .= $this->ld->getDefine($language, "{$stuTableName}_LIST", "List of {$ucfTableName}"); |
||
150 | $ret .= $this->ld->getAboveDefines("Caption of {$ucfTableSoleName}"); |
||
151 | $fields = $this->getTableFields($tables[$i]->getVar('table_mid'), $tables[$i]->getVar('table_id')); |
||
152 | foreach (\array_keys($fields) as $f) { |
||
153 | $fieldName = $fields[$f]->getVar('field_name'); |
||
154 | $rpFieldName = $this->getRightString($fieldName); |
||
155 | $fieldNameDesc = \ucfirst($rpFieldName); |
||
156 | $ret .= $this->ld->getDefine($language, $stuTableSoleName . '_' . $rpFieldName, $fieldNameDesc); |
||
157 | } |
||
158 | } |
||
159 | } |
||
160 | $ret .= $this->ld->getDefine($language, 'INDEX_THEREARE', "There are %s {$ucfTableName}"); |
||
161 | $ret .= $this->ld->getDefine($language, 'INDEX_LATEST_LIST', "Last {$module->getVar('mod_name')}"); |
||
162 | if (1 === $tableSubmit) { |
||
163 | $ret .= $this->ld->getAboveDefines('Submit'); |
||
164 | $ret .= $this->ld->getDefine($language, 'SUBMIT', 'Submit'); |
||
165 | $ret .= $this->ld->getAboveDefines('Form'); |
||
166 | $ret .= $this->ld->getDefine($language, 'FORM_OK', 'Successfully saved'); |
||
167 | $ret .= $this->ld->getDefine($language, 'FORM_DELETE_OK', 'Successfully deleted'); |
||
168 | $ret .= $this->ld->getDefine($language, 'FORM_SURE_DELETE', "Are you sure to delete: <b><span style='color : Red;'>%s </span></b>", true); |
||
169 | $ret .= $this->ld->getDefine($language, 'FORM_SURE_RENEW', "Are you sure to update: <b><span style='color : Red;'>%s </span></b>", true); |
||
170 | if (1 === $tableBroken) { |
||
171 | $ret .= $this->ld->getDefine($language, 'FORM_SURE_BROKEN', "Are you sure to notify as broken: <b><span style='color : Red;'>%s </span></b>", true); |
||
172 | } |
||
173 | $ret .= $this->ld->getDefine($language, 'INVALID_PARAM', "Invalid parameter", true); |
||
174 | } |
||
175 | if (1 === $tableRate) { |
||
176 | $ret .= $this->ld->getAboveHeadDefines('Ratings'); |
||
177 | $ret .= $this->ld->getDefine($language, 'RATING_CURRENT_1', 'Rating: %c / %m (%t rating totally)'); |
||
178 | $ret .= $this->ld->getDefine($language, 'RATING_CURRENT_X', 'Rating: %c / %m (%t ratings totally)'); |
||
179 | $ret .= $this->ld->getDefine($language, 'RATING_CURRENT_SHORT_1', '%c (%t rating)'); |
||
180 | $ret .= $this->ld->getDefine($language, 'RATING_CURRENT_SHORT_X', '%c (%t ratings)'); |
||
181 | $ret .= $this->ld->getDefine($language, 'RATING1', '1 of 5'); |
||
182 | $ret .= $this->ld->getDefine($language, 'RATING2', '2 of 5'); |
||
183 | $ret .= $this->ld->getDefine($language, 'RATING3', '3 of 5'); |
||
184 | $ret .= $this->ld->getDefine($language, 'RATING4', '4 of 5'); |
||
185 | $ret .= $this->ld->getDefine($language, 'RATING5', '5 of 5'); |
||
186 | $ret .= $this->ld->getDefine($language, 'RATING_10_1', '1 of 10'); |
||
187 | $ret .= $this->ld->getDefine($language, 'RATING_10_2', '2 of 10'); |
||
188 | $ret .= $this->ld->getDefine($language, 'RATING_10_3', '3 of 10'); |
||
189 | $ret .= $this->ld->getDefine($language, 'RATING_10_4', '4 of 10'); |
||
190 | $ret .= $this->ld->getDefine($language, 'RATING_10_5', '5 of 10'); |
||
191 | $ret .= $this->ld->getDefine($language, 'RATING_10_6', '6 of 10'); |
||
192 | $ret .= $this->ld->getDefine($language, 'RATING_10_7', '7 of 10'); |
||
193 | $ret .= $this->ld->getDefine($language, 'RATING_10_8', '8 of 10'); |
||
194 | $ret .= $this->ld->getDefine($language, 'RATING_10_9', '9 of 10'); |
||
195 | $ret .= $this->ld->getDefine($language, 'RATING_10_10', '10 of 10'); |
||
196 | $ret .= $this->ld->getDefine($language, 'RATING_VOTE_BAD', 'Invalid vote'); |
||
197 | $ret .= $this->ld->getDefine($language, 'RATING_VOTE_ALREADY', 'You have already voted'); |
||
198 | $ret .= $this->ld->getDefine($language, 'RATING_VOTE_THANKS', 'Thank you for rating'); |
||
199 | $ret .= $this->ld->getDefine($language, 'RATING_NOPERM', "Sorry, you don't have permission to rate items", true); |
||
200 | $ret .= $this->ld->getDefine($language, 'RATING_LIKE', 'Like'); |
||
201 | $ret .= $this->ld->getDefine($language, 'RATING_DISLIKE', 'Dislike'); |
||
202 | $ret .= $this->ld->getDefine($language, 'RATING_ERROR1', 'Error: update base table failed!'); |
||
203 | } |
||
204 | if (1 === $tablePrint) { |
||
205 | $ret .= $this->ld->getAboveHeadDefines('Print'); |
||
206 | $ret .= $this->ld->getDefine($language, 'PRINT', 'Print'); |
||
207 | } |
||
208 | return $ret; |
||
209 | } |
||
247 |