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 | /** @var \XoopsModules\Modulebuilder\Utility $utility */ |
||
94 | $utility = new \XoopsModules\Modulebuilder\Utility(); |
||
95 | |||
96 | $moduleName = $module->getVar('mod_name'); |
||
97 | $tables = $this->getTables(); |
||
98 | $ret = $this->ld->getBlankLine(); |
||
99 | $ret .= $this->pc->getPhpCodeIncludeDir('__DIR__', 'admin', true); |
||
100 | $ret .= $this->ld->getBlankLine(); |
||
101 | $ret .= $this->ld->getAboveHeadDefines('Main'); |
||
102 | $ret .= $this->ld->getDefine($language, 'INDEX', 'Overview ' . (string)$module->getVar('mod_name')); |
||
103 | $ret .= $this->ld->getDefine($language, 'TITLE', (string)$module->getVar('mod_name')); |
||
104 | $ret .= $this->ld->getDefine($language, 'DESC', (string)$module->getVar('mod_description')); |
||
105 | $ret .= $this->ld->getDefine( |
||
106 | $language, |
||
107 | 'INDEX_DESC', |
||
108 | "Welcome to the homepage of your new module {$moduleName}!<br> |
||
109 | 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='https://xoops.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.", |
||
110 | true |
||
111 | ); |
||
112 | $ret .= $this->ld->getDefine($language, 'NO_PDF_LIBRARY', 'Libraries TCPDF not there yet, upload them in root/Frameworks'); |
||
113 | $ret .= $this->ld->getDefine($language, 'NO', 'No'); |
||
114 | $ret .= $this->ld->getDefine($language, 'DETAILS', 'Show details'); |
||
115 | $ret .= $this->ld->getDefine($language, 'BROKEN', 'Notify broken'); |
||
116 | $ret .= $this->ld->getAboveHeadDefines('Contents'); |
||
117 | $ucfTableName = ''; |
||
118 | $ucfTableSoleName = ''; |
||
119 | $stuTableSoleName = ''; |
||
120 | $tableSoleName = ''; |
||
121 | $tableSubmit = 0; |
||
122 | $tableBroken = 0; |
||
123 | $tableRate = 0; |
||
124 | $tablePrint = 0; |
||
125 | foreach (\array_keys($tables) as $i) { |
||
126 | if (1 == $tables[$i]->getVar('table_user')) { |
||
127 | $tableName = $tables[$i]->getVar('table_name'); |
||
128 | $tableSoleName = $tables[$i]->getVar('table_solename'); |
||
129 | if (1 === (int)$tables[$i]->getVar('table_submit')) { |
||
130 | $tableSubmit = 1; |
||
131 | } |
||
132 | if (1 === (int)$tables[$i]->getVar('table_broken')) { |
||
133 | $tableBroken = 1; |
||
134 | } |
||
135 | if (1 === (int)$tables[$i]->getVar('table_rate')) { |
||
136 | $tableRate = 1; |
||
137 | } |
||
138 | if (1 === (int)$tables[$i]->getVar('table_print')) { |
||
139 | $tablePrint = 1; |
||
140 | } |
||
141 | $stuTableName = \mb_strtoupper($tableName); |
||
142 | $stuTableSoleName = \mb_strtoupper($tableSoleName); |
||
143 | $ucfTableName = $utility::UcFirstAndToLower($tableName); |
||
144 | $ucfTableSoleName = $utility::UcFirstAndToLower($tableSoleName); |
||
145 | $ret .= $this->ld->getAboveDefines($ucfTableSoleName); |
||
146 | $ret .= $this->ld->getDefine($language, $stuTableSoleName, $ucfTableSoleName); |
||
147 | if (1 === $tableSubmit) { |
||
148 | $ret .= $this->ld->getDefine($language, "{$stuTableSoleName}_ADD", "Add {$ucfTableSoleName}"); |
||
149 | $ret .= $this->ld->getDefine($language, "{$stuTableSoleName}_EDIT", "Edit {$ucfTableSoleName}"); |
||
150 | $ret .= $this->ld->getDefine($language, "{$stuTableSoleName}_DELETE", "Delete {$ucfTableSoleName}"); |
||
151 | $ret .= $this->ld->getDefine($language, "{$stuTableSoleName}_CLONE", "Clone {$ucfTableSoleName}"); |
||
152 | } |
||
153 | $ret .= $this->ld->getDefine($language, $stuTableName, $ucfTableName); |
||
154 | $ret .= $this->ld->getDefine($language, "{$stuTableName}_LIST", "List of {$ucfTableName}"); |
||
155 | $ret .= $this->ld->getDefine($language, "{$stuTableName}_TITLE", "{$ucfTableName} title"); |
||
156 | $ret .= $this->ld->getDefine($language, "{$stuTableName}_DESC", "{$ucfTableName} description"); |
||
157 | |||
158 | $ret .= $this->ld->getAboveDefines("Caption of {$ucfTableSoleName}"); |
||
159 | $fields = $this->getTableFields($tables[$i]->getVar('table_mid'), $tables[$i]->getVar('table_id')); |
||
160 | foreach (\array_keys($fields) as $f) { |
||
161 | $fieldName = $fields[$f]->getVar('field_name'); |
||
162 | $rpFieldName = $this->getRightString($fieldName); |
||
163 | $fieldNameDesc = \ucfirst($rpFieldName); |
||
164 | $ret .= $this->ld->getDefine($language, $stuTableSoleName . '_' . $rpFieldName, $fieldNameDesc); |
||
165 | } |
||
166 | } |
||
167 | } |
||
168 | $ret .= $this->ld->getDefine($language, 'INDEX_THEREARE', "There are %s {$ucfTableName}"); |
||
169 | $ret .= $this->ld->getDefine($language, 'INDEX_LATEST_LIST', "Last {$module->getVar('mod_name')}"); |
||
170 | if (1 === $tableSubmit) { |
||
171 | $ret .= $this->ld->getAboveDefines('Submit'); |
||
172 | $ret .= $this->ld->getDefine($language, 'SUBMIT', 'Submit'); |
||
173 | $ret .= $this->ld->getAboveDefines('Form'); |
||
174 | $ret .= $this->ld->getDefine($language, 'FORM_OK', 'Successfully saved'); |
||
175 | $ret .= $this->ld->getDefine($language, 'FORM_DELETE_OK', 'Successfully deleted'); |
||
176 | $ret .= $this->ld->getDefine($language, 'FORM_SURE_DELETE', "Are you sure to delete: <b><span style='color : Red;'>%s </span></b>", true); |
||
177 | $ret .= $this->ld->getDefine($language, 'FORM_SURE_RENEW', "Are you sure to update: <b><span style='color : Red;'>%s </span></b>", true); |
||
178 | if (1 === $tableBroken) { |
||
179 | $ret .= $this->ld->getDefine($language, 'FORM_SURE_BROKEN', "Are you sure to notify as broken: <b><span style='color : Red;'>%s </span></b>", true); |
||
180 | } |
||
181 | $ret .= $this->ld->getDefine($language, 'INVALID_PARAM', 'Invalid parameter', false); |
||
182 | } |
||
183 | if (1 === $tableRate) { |
||
184 | $ret .= $this->ld->getAboveHeadDefines('Ratings'); |
||
185 | $ret .= $this->ld->getDefine($language, 'RATING_CURRENT_1', 'Rating: %c / %m (%t rating totally)'); |
||
186 | $ret .= $this->ld->getDefine($language, 'RATING_CURRENT_X', 'Rating: %c / %m (%t ratings totally)'); |
||
187 | $ret .= $this->ld->getDefine($language, 'RATING_CURRENT_SHORT_1', '%c (%t rating)'); |
||
188 | $ret .= $this->ld->getDefine($language, 'RATING_CURRENT_SHORT_X', '%c (%t ratings)'); |
||
189 | $ret .= $this->ld->getDefine($language, 'RATING1', '1 of 5'); |
||
190 | $ret .= $this->ld->getDefine($language, 'RATING2', '2 of 5'); |
||
191 | $ret .= $this->ld->getDefine($language, 'RATING3', '3 of 5'); |
||
192 | $ret .= $this->ld->getDefine($language, 'RATING4', '4 of 5'); |
||
193 | $ret .= $this->ld->getDefine($language, 'RATING5', '5 of 5'); |
||
194 | $ret .= $this->ld->getDefine($language, 'RATING_10_1', '1 of 10'); |
||
195 | $ret .= $this->ld->getDefine($language, 'RATING_10_2', '2 of 10'); |
||
196 | $ret .= $this->ld->getDefine($language, 'RATING_10_3', '3 of 10'); |
||
197 | $ret .= $this->ld->getDefine($language, 'RATING_10_4', '4 of 10'); |
||
198 | $ret .= $this->ld->getDefine($language, 'RATING_10_5', '5 of 10'); |
||
199 | $ret .= $this->ld->getDefine($language, 'RATING_10_6', '6 of 10'); |
||
200 | $ret .= $this->ld->getDefine($language, 'RATING_10_7', '7 of 10'); |
||
201 | $ret .= $this->ld->getDefine($language, 'RATING_10_8', '8 of 10'); |
||
202 | $ret .= $this->ld->getDefine($language, 'RATING_10_9', '9 of 10'); |
||
203 | $ret .= $this->ld->getDefine($language, 'RATING_10_10', '10 of 10'); |
||
204 | $ret .= $this->ld->getDefine($language, 'RATING_VOTE_BAD', 'Invalid vote'); |
||
205 | $ret .= $this->ld->getDefine($language, 'RATING_VOTE_ALREADY', 'You have already voted'); |
||
206 | $ret .= $this->ld->getDefine($language, 'RATING_VOTE_THANKS', 'Thank you for rating'); |
||
207 | $ret .= $this->ld->getDefine($language, 'RATING_NOPERM', "Sorry, you don't have permission to rate items", true); |
||
208 | $ret .= $this->ld->getDefine($language, 'RATING_LIKE', 'Like'); |
||
209 | $ret .= $this->ld->getDefine($language, 'RATING_DISLIKE', 'Dislike'); |
||
210 | $ret .= $this->ld->getDefine($language, 'RATING_ERROR1', 'Error: update base table failed!'); |
||
211 | } |
||
212 | if (1 === $tablePrint) { |
||
213 | $ret .= $this->ld->getAboveHeadDefines('Print'); |
||
214 | $ret .= $this->ld->getDefine($language, 'PRINT', 'Print'); |
||
215 | } |
||
216 | return $ret; |
||
217 | } |
||
218 | |||
219 | /** |
||
220 | * @private function getLanguageMainFooter |
||
221 | * @param string $language |
||
222 | * |
||
223 | * @return string |
||
224 | */ |
||
225 | private function getLanguageMainFooter($language) |
||
226 | { |
||
227 | $ret = $this->ld->getAboveDefines('Admin link'); |
||
228 | $ret .= $this->ld->getDefine($language, 'ADMIN', 'Admin'); |
||
229 | $ret .= $this->ld->getBelowDefines('End'); |
||
230 | $ret .= $this->ld->getBlankLine(); |
||
231 | |||
232 | return $ret; |
||
233 | } |
||
234 | |||
235 | /** |
||
236 | * @public function render |
||
237 | * @param null |
||
238 | * @return bool|string |
||
239 | */ |
||
240 | public function render() |
||
241 | { |
||
242 | $module = $this->getModule(); |
||
243 | $filename = $this->getFileName(); |
||
244 | $moduleDirname = $module->getVar('mod_dirname'); |
||
245 | $language = $this->getLanguage($moduleDirname, 'MA', '', false); |
||
0 ignored issues
–
show
Bug
introduced
by
Loading history...
|
|||
246 | $content = $this->getHeaderFilesComments($module); |
||
247 | $content .= $this->getLanguageMain($module, $language); |
||
248 | $content .= $this->getLanguageMainFooter($language); |
||
249 | |||
250 | $this->create($moduleDirname, 'language/' . $GLOBALS['xoopsConfig']['language'], $filename, $content, \_AM_MODULEBUILDER_FILE_CREATED, \_AM_MODULEBUILDER_FILE_NOTCREATED); |
||
251 | |||
252 | return $this->renderFile(); |
||
253 | } |
||
254 | } |
||
255 |