@@ -47,7 +47,7 @@ public function __construct()
4747 *
4848 * @param null
4949 *
50- * @return Modulebuilder\Files\CreateArchitecture
50+ * @return Modulebuilder\Files\CheckData
5151 */
5252 public static function getInstance ()
5353 {
@@ -63,14 +63,15 @@ public static function getInstance()
6363 * @public function getCheckResult
6464 *
6565 * @param $module
66+ * @return array
6667 */
6768 public function getCheckPreBuilding ($ module )
6869 {
6970 $ cf = Modulebuilder \Files \CreateFile::getInstance ();
7071
7172 $ modId = $ module ->getVar ('mod_id ' );
7273 $ tables = $ cf ->getTableTables ($ modId );
73- $ errors = [];
74+ $ infos = [];
7475
7576 foreach (array_keys ($ tables ) as $ t ) {
7677 if (1 == $ tables [$ t ]->getVar ('table_broken ' )) {
@@ -87,11 +88,12 @@ public function getCheckPreBuilding($module)
8788 }
8889 // check whether each table with handling "broken" has also a field "status"
8990 if ('' == $ fieldSatus ) {
90- $ error = str_replace ('%t ' , $ tableName , _AM_MODULEBUILDER_CHECKPREBUILD_BROKEN1 );
91- $ errors [] = ['tableName ' => $ tableName , ' icon ' => 'error ' , 'info ' => $ error ];
91+ $ info = str_replace ('%t ' , $ tableName , _AM_MODULEBUILDER_CHECKPREBUILD_BROKEN1 );
92+ $ infos [] = ['icon ' => 'error ' , 'info ' => $ info ];
9293 }
9394 }
9495 }
96+
9597 foreach (array_keys ($ tables ) as $ t ) {
9698 $ tableId = $ tables [$ t ]->getVar ('table_id ' );
9799 $ tableName = $ tables [$ t ]->getVar ('table_name ' );
@@ -106,8 +108,8 @@ public function getCheckPreBuilding($module)
106108 + (int )$ fields [$ f ]->getVar ('field_thead ' ) + (int )$ fields [$ f ]->getVar ('field_tbody ' ) + (int )$ fields [$ f ]->getVar ('field_tfoot ' ) + (int )$ fields [$ f ]->getVar ('field_block ' )
107109 + (int )$ fields [$ f ]->getVar ('field_main ' ) + (int )$ fields [$ f ]->getVar ('field_search ' ) + (int )$ fields [$ f ]->getVar ('field_required ' );
108110 if (0 == $ fieldParams ) {
109- $ error = str_replace (['%f ' , '%t ' ], [$ fieldName , $ tableName ], _AM_MODULEBUILDER_CHECKPREBUILD_FIELDS1 );
110- $ errors [] = ['tableName ' => $ tableName , ' icon ' => 'error ' , 'info ' => $ error ];
111+ $ info = str_replace (['%f ' , '%t ' ], [$ fieldName , $ tableName ], _AM_MODULEBUILDER_CHECKPREBUILD_FIELDS1 );
112+ $ infos [] = ['icon ' => 'error ' , 'info ' => $ info ];
111113 }
112114 }
113115 }
@@ -127,8 +129,8 @@ public function getCheckPreBuilding($module)
127129 $ fieldParams = (int )$ fields [$ f ]->getVar ('field_ihead ' ) + (int )$ fields [$ f ]->getVar ('field_ibody ' ) + (int )$ fields [$ f ]->getVar ('field_ifoot ' )
128130 + (int )$ fields [$ f ]->getVar ('field_thead ' ) + (int )$ fields [$ f ]->getVar ('field_tbody ' ) + (int )$ fields [$ f ]->getVar ('field_tfoot ' );
129131 if (0 == $ fieldParams ) {
130- $ error = str_replace (['%f ' , '%t ' ], [$ fieldName , $ tableName ], _AM_MODULEBUILDER_CHECKPREBUILD_FIELDS2 );
131- $ errors [] = ['tableName ' => $ tableName , ' icon ' => 'warning ' , 'info ' => $ error ];
132+ $ info = str_replace (['%f ' , '%t ' ], [$ fieldName , $ tableName ], _AM_MODULEBUILDER_CHECKPREBUILD_FIELDS2 );
133+ $ infos [] = ['icon ' => 'warning ' , 'info ' => $ info ];
132134 }
133135 }
134136 }
@@ -148,13 +150,13 @@ public function getCheckPreBuilding($module)
148150 if ($ f > 0 ) {
149151 $ fieldParams = (int )$ fields [$ f ]->getVar ('field_ihead ' ) + (int )$ fields [$ f ]->getVar ('field_ibody ' ) + (int )$ fields [$ f ]->getVar ('field_ifoot ' );
150152 if ($ fieldParams > 1 ) {
151- $ error = str_replace (['%f ' , '%t ' ], [$ fieldName , $ tableName ], _AM_MODULEBUILDER_CHECKPREBUILD_FIELDS3 );
152- $ errors [] = ['tableName ' => $ tableName , ' icon ' => 'warning ' , 'info ' => $ error ];
153+ $ info = str_replace (['%f ' , '%t ' ], [$ fieldName , $ tableName ], _AM_MODULEBUILDER_CHECKPREBUILD_FIELDS3 );
154+ $ infos [] = ['icon ' => 'warning ' , 'info ' => $ info ];
153155 }
154156 $ fieldParams = (int )$ fields [$ f ]->getVar ('field_thead ' ) + (int )$ fields [$ f ]->getVar ('field_tbody ' ) + (int )$ fields [$ f ]->getVar ('field_tfoot ' );
155157 if ($ fieldParams > 1 ) {
156- $ error = str_replace (['%f ' , '%t ' ], [$ fieldName , $ tableName ], _AM_MODULEBUILDER_CHECKPREBUILD_FIELDS3 );
157- $ errors [] = ['tableName ' => $ tableName , ' icon ' => 'warning ' , 'info ' => $ error ];
158+ $ info = str_replace (['%f ' , '%t ' ], [$ fieldName , $ tableName ], _AM_MODULEBUILDER_CHECKPREBUILD_FIELDS3 );
159+ $ infos [] = ['icon ' => 'warning ' , 'info ' => $ info ];
158160 }
159161 }
160162 }
@@ -169,37 +171,71 @@ public function getCheckPreBuilding($module)
169171 $ count = 0 ;
170172 if (1 == $ tables [$ t ]->getVar ('table_blocks ' )) {
171173 foreach (array_keys ($ fields ) as $ f ) {
172- $ fieldName = $ fields [$ f ]->getVar ('field_name ' );
173174 if (1 == $ fields [$ f ]->getVar ('field_block ' )) {
174175 $ count ++;
175176 }
176177 }
177178 if (0 == $ count ) {
178- $ error = str_replace (['%f ' , ' % t ' ], [$ fieldName , $ tableName ], _AM_MODULEBUILDER_CHECKPREBUILD_BLOCK1 );
179- $ errors [] = ['tableName ' => $ tableName , ' icon ' => 'warning ' , 'info ' => $ error ];
179+ $ info = str_replace (['%t ' ], [$ tableName ], _AM_MODULEBUILDER_CHECKPREBUILD_BLOCK1 );
180+ $ infos [] = ['icon ' => 'warning ' , 'info ' => $ info ];
180181 }
181182 }
182183 }
183184 //use in block but not field date
184185 foreach (array_keys ($ tables ) as $ t ) {
185186 $ tableId = $ tables [$ t ]->getVar ('table_id ' );
186187 $ tableName = $ tables [$ t ]->getVar ('table_name ' );
187- $ fields = $ cf -> getTableFields ( $ modId , $ tableId );
188+
188189 $ count = 0 ;
189190 if (1 == $ tables [$ t ]->getVar ('table_blocks ' )) {
191+ $ fields = $ cf ->getTableFields ($ modId , $ tableId );
190192 foreach (array_keys ($ fields ) as $ f ) {
191- $ fieldName = $ fields [$ f ]->getVar ('field_name ' );
192193 if (15 == $ fields [$ f ]->getVar ('field_element ' ) || 21 == $ fields [$ f ]->getVar ('field_element ' )) {
193194 $ count ++;
194195 }
195196 }
196197 if (0 == $ count ) {
197- $ error = str_replace (['%f ' , '%t ' ], [$ fieldName , $ tableName ], _AM_MODULEBUILDER_CHECKPREBUILD_BLOCK2 );
198- $ errors [] = ['tableName ' => $ tableName , 'icon ' => 'warning ' , 'info ' => $ error ];
198+ $ info = str_replace (['%t ' ], [$ tableName ], _AM_MODULEBUILDER_CHECKPREBUILD_BLOCK2 );
199+ $ infos [] = ['icon ' => 'warning ' , 'info ' => $ info ];
200+ }
201+ }
202+ }
203+ //use comments in multiple tables
204+ $ count = 0 ;
205+ $ tableComments = [];
206+ foreach (array_keys ($ tables ) as $ t ) {
207+ if (1 == $ tables [$ t ]->getVar ('table_comments ' )) {
208+ $ count ++;
209+ $ tableComments [] = $ tables [$ t ]->getVar ('table_name ' );
210+ }
211+ }
212+ if ($ count > 1 ) {
213+ $ tablesComments = implode (', ' , $ tableComments );
214+ $ info = str_replace ('%t ' , $ tablesComments , _AM_MODULEBUILDER_CHECKPREBUILD_COMMENTS1 );
215+ $ infos [] = ['icon ' => 'error ' , 'info ' => $ info ];
216+ }
217+
218+ foreach (array_keys ($ tables ) as $ t ) {
219+ if (1 == $ tables [$ t ]->getVar ('table_comments ' )) {
220+ $ tableId = $ tables [$ t ]->getVar ('table_id ' );
221+ $ tableName = $ tables [$ t ]->getVar ('table_name ' );
222+ $ fields = $ cf ->getTableFields ($ modId , $ tableId );
223+ $ fieldComments = '' ;
224+
225+ foreach (array_keys ($ fields ) as $ f ) {
226+ $ fieldName = $ fields [$ f ]->getVar ('field_name ' );
227+ if ($ fieldName == $ tables [$ t ]->getVar ('table_fieldname ' ) . '_comments ' ) {
228+ $ fieldComments = $ fieldName ;
229+ }
230+ }
231+ // check whether each table with handling "broken" has also a field "status"
232+ if ('' == $ fieldComments ) {
233+ $ info = str_replace (['%f ' , '%t ' ], [$ tables [$ t ]->getVar ('table_fieldname ' ) . '_comments ' , $ tableName ], _AM_MODULEBUILDER_CHECKPREBUILD_COMMENTS2 );
234+ $ infos [] = ['icon ' => 'warning ' , 'info ' => $ info ];
199235 }
200236 }
201237 }
202238
203- return $ errors ;
239+ return $ infos ;
204240 }
205241}
0 commit comments