33namespace XoopsModules \Modulebuilder \Files \Classes ;
44
55use XoopsModules \Modulebuilder ;
6- use XoopsModules \Modulebuilder \Files ;
6+ use XoopsModules \Modulebuilder \{
7+ Files ,
8+ Constants
9+ };
710
811/*
912 You may not change or alter any portion of this comment or credits
@@ -224,11 +227,27 @@ public function renderConstantsInterface()
224227 $ module = $ this ->getModule ();
225228 $ filename = $ this ->getFileName ();
226229 $ tables = $ this ->getTables ();
227- $ tablePermissions = [];
228- $ tableRate = [];
230+
231+
232+ $ tablePermissions = [];
233+ $ tableRate = [];
234+ $ hasRadioOnoffline = false ;
235+ $ hasSelectStatus = false ;
229236 foreach (\array_keys ($ tables ) as $ t ) {
230237 $ tablePermissions [] = $ tables [$ t ]->getVar ('table_permissions ' );
231238 $ tableRate [] = $ tables [$ t ]->getVar ('table_rate ' );
239+ $ fields = $ this ->getTableFields ($ tables [$ t ]->getVar ('table_mid ' ), $ tables [$ t ]->getVar ('table_id ' ));
240+ foreach (\array_keys ($ fields ) as $ f ) {
241+ $ fieldElement = $ fields [$ f ]->getVar ('field_element ' );
242+ switch ($ fieldElement ) {
243+ case Constants::FIELD_ELE_RADIO_ONOFFLINE :
244+ $ hasRadioOnoffline = true ;
245+ break ;
246+ case Constants::FIELD_ELE_SELECTSTATUS :
247+ $ hasSelectStatus = true ;
248+ break ;
249+ }
250+ }
232251 }
233252 $ moduleDirname = $ module ->getVar ('mod_dirname ' );
234253 $ namespace = $ this ->pc ->getPhpCodeNamespace (['XoopsModules ' , $ moduleDirname ]);
@@ -243,13 +262,21 @@ public function renderConstantsInterface()
243262 $ contentClass .= $ this ->pc ->getPhpCodeConstant ('TABLE_ ' . $ stuTableName , $ t , "\t" , 'public const ' );
244263 }
245264
246- $ contentClass .= $ this ->pc ->getPhpCodeBlankLine ();
247- $ contentClass .= $ this ->pc ->getPhpCodeCommentLine ('Constants for status ' , '' , "\t" );
248- $ contentClass .= $ this ->pc ->getPhpCodeConstant ('STATUS_NONE ' , 0 , "\t" , 'public const ' );
249- $ contentClass .= $ this ->pc ->getPhpCodeConstant ('STATUS_OFFLINE ' , 1 , "\t" , 'public const ' );
250- $ contentClass .= $ this ->pc ->getPhpCodeConstant ('STATUS_SUBMITTED ' , 2 , "\t" , 'public const ' );
251- $ contentClass .= $ this ->pc ->getPhpCodeConstant ('STATUS_APPROVED ' , 3 , "\t" , 'public const ' );
252- $ contentClass .= $ this ->pc ->getPhpCodeConstant ('STATUS_BROKEN ' , 4 , "\t" , 'public const ' );
265+ if ($ hasSelectStatus ) {
266+ $ contentClass .= $ this ->pc ->getPhpCodeBlankLine ();
267+ $ contentClass .= $ this ->pc ->getPhpCodeCommentLine ('Constants for status ' , '' , "\t" );
268+ $ contentClass .= $ this ->pc ->getPhpCodeConstant ('STATUS_NONE ' , 0 , "\t" , 'public const ' );
269+ $ contentClass .= $ this ->pc ->getPhpCodeConstant ('STATUS_OFFLINE ' , 1 , "\t" , 'public const ' );
270+ $ contentClass .= $ this ->pc ->getPhpCodeConstant ('STATUS_SUBMITTED ' , 2 , "\t" , 'public const ' );
271+ $ contentClass .= $ this ->pc ->getPhpCodeConstant ('STATUS_APPROVED ' , 3 , "\t" , 'public const ' );
272+ $ contentClass .= $ this ->pc ->getPhpCodeConstant ('STATUS_BROKEN ' , 4 , "\t" , 'public const ' );
273+ }
274+ if ($ hasRadioOnoffline ) {
275+ $ contentClass .= $ this ->pc ->getPhpCodeBlankLine ();
276+ $ contentClass .= $ this ->pc ->getPhpCodeCommentLine ('Constants for radio on-/offline ' , '' , "\t" );
277+ $ contentClass .= $ this ->pc ->getPhpCodeConstant ('RADIO_OFFLINE ' , 0 , "\t" , 'public const ' );
278+ $ contentClass .= $ this ->pc ->getPhpCodeConstant ('RADIO_ONLINE ' , 1 , "\t" , 'public const ' );
279+ }
253280 if (\in_array (1 , $ tablePermissions )) {
254281 $ constPerm = $ this ->pc ->getPhpCodeBlankLine ();
255282 $ constPerm .= $ this ->pc ->getPhpCodeCommentLine ('Constants for permissions ' , '' , "\t" );
0 commit comments