Skip to content

Commit 1531a26

Browse files
committed
- fixed bugs in comments handling
- added notification comments
1 parent d71037c commit 1531a26

32 files changed

+433
-285
lines changed

_TODO.txt

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,29 +12,18 @@ TODOs:
1212
new xoops_confirm
1313

1414

15-
16-
Notifications:
17-
notification comments
18-
19-
2015
rate.php:
2116
this file currently is not rating
2217

2318

24-
Comment files
25-
are the comment files (CreateArchitecture.php line 533 ff) required?
19+
2620

2721

2822
Permissions:
2923
check handling for different groups
3024
implement autoapprove
3125

3226

33-
Test:
34-
ändern auf testen, nicht bei building ausführen
35-
in user file, but no decision where (header?body?footer?)
36-
keine Doppelverwendung:header?body?footer?
37-
3827

3928
*****************************
4029
Open questions:

admin/building.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
<?php
22

3-
use XoopsModules\Modulebuilder;
4-
53
/*
64
You may not change or alter any portion of this comment or credits
75
of supporting developers from this source code or any supporting source code
@@ -23,6 +21,8 @@
2321
*
2422
*/
2523

24+
use XoopsModules\Modulebuilder;
25+
use XoopsModules\Modulebuilder\Files;
2626
use Xmf\Request;
2727

2828
$templateMain = 'modulebuilder_building.tpl';

class/Files/Assets/Css/CssSelectors.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ public function geCssSelector($selector, $content, $t)
7777
} else {
7878
$ret .= $content . ';';
7979
}
80-
$ret = '}';
80+
$ret .= '}';
8181

8282
return $ret;
8383
}

class/Files/Assets/Js/JavascriptJQuery.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ public function render()
176176
$filename = $this->getFileName();
177177
$moduleDirname = $module->getVar('mod_dirname');
178178
$content = $this->getHeaderFilesComments($module);
179-
$content = $this->getJavascriptJQueryButtons();
179+
$content .= $this->getJavascriptJQueryButtons();
180180
$content .= $this->getJavascriptJQueryPrint();
181181

182182
$this->create($moduleDirname, 'assets/js', $filename, $content, _AM_MODULEBUILDER_FILE_CREATED, _AM_MODULEBUILDER_FILE_NOTCREATED);

class/Files/CheckData.php

Lines changed: 56 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -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
}

class/Files/CreateArchitecture.php

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -348,13 +348,19 @@ public function setFilesToBuilding($module)
348348
// Language Mail Template Approve File
349349
$languageMailTpl->write($module, $table, $tableSoleName . '_approve_notify.tpl');
350350
$ret[] = $languageMailTpl->render();
351-
}
352-
// Creation of notifications files
353-
if (1 === (int)$tables[$t]->getVar('table_broken')) {
354-
// Language Mail Template Category File
355-
$languageMailTpl = Modulebuilder\Files\Language\LanguageMailTpl::getInstance();
356-
$languageMailTpl->write($module, $table, $tableSoleName . '_broken_notify.tpl');
357-
$ret[] = $languageMailTpl->render();
351+
if (1 === (int)$tables[$t]->getVar('table_broken')) {
352+
// Language Mail Template Category File
353+
$languageMailTpl = Modulebuilder\Files\Language\LanguageMailTpl::getInstance();
354+
$languageMailTpl->write($module, $table, $tableSoleName . '_broken_notify.tpl');
355+
$ret[] = $languageMailTpl->render();
356+
}
357+
// Creation of notifications files
358+
if (1 === (int)$tables[$t]->getVar('table_comments')) {
359+
// Language Mail Template Category File
360+
$languageMailTpl = Modulebuilder\Files\Language\LanguageMailTpl::getInstance();
361+
$languageMailTpl->write($module, $table, $tableSoleName . '_comment_notify.tpl');
362+
$ret[] = $languageMailTpl->render();
363+
}
358364
}
359365
}
360366
}
@@ -502,6 +508,11 @@ public function setFilesToBuilding($module)
502508
$languageMailTpl->write($module, $table, 'global_broken_notify.tpl');
503509
$ret[] = $languageMailTpl->render();
504510
}
511+
if (in_array(1, $tableComments)) {
512+
// Language Mail Template Broken File
513+
$languageMailTpl->write($module, $table, 'global_comment_notify.tpl');
514+
$ret[] = $languageMailTpl->render();
515+
}
505516
}
506517
// Creation of sql file
507518
if (null != $table->getVar('table_name')) {
@@ -526,8 +537,6 @@ public function setFilesToBuilding($module)
526537
}
527538
// Creation of comments files
528539
if (in_array(1, $tableComments)) {
529-
/*
530-
* TODO: are this comment files required?
531540
// Include Comments File
532541
$includeComments = Modulebuilder\Files\Includes\IncludeComments::getInstance();
533542
$includeComments->write($module, $table);
@@ -545,11 +554,9 @@ public function setFilesToBuilding($module)
545554
$includeComments->write($module, $table);
546555
$ret[] = $includeComments->renderCommentsIncludes($module, 'comment_reply');
547556
// Include Comments File
548-
$includeComments = Modulebuilder\Files\Includes\IncludeComments::getInstance();
549-
$includeComments->write($module, $table);
550-
$ret[] = $includeComments->renderCommentsNew($module, 'comment_new');
551-
*/
552-
557+
//$includeComments = Modulebuilder\Files\Includes\IncludeComments::getInstance();
558+
//$includeComments->write($module, $table);
559+
//$ret[] = $includeComments->renderCommentsNew($module, 'comment_new');
553560
// Include Comment Functions File
554561
$includeCommentFunctions = Modulebuilder\Files\Includes\IncludeCommentFunctions::getInstance();
555562
$includeCommentFunctions->write($module, $table, 'comment_functions.php');

class/Files/CreateFile.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -475,16 +475,16 @@ public function getHeaderFilesComments($module, $noPhpFile = null, $namespace =
475475
$pc = Modulebuilder\Files\CreatePhpCode::getInstance();
476476
$name = $module->getVar('mod_name');
477477
$dirname = $module->getVar('mod_dirname');
478-
$version = $module->getVar('mod_version');
478+
//$version = $module->getVar('mod_version');
479479
$since = $module->getVar('mod_since');
480480
$minXoops = $module->getVar('mod_min_xoops');
481481
$author = $module->getVar('mod_author');
482-
$credits = $module->getVar('mod_credits');
482+
//$credits = $module->getVar('mod_credits');
483483
$authorMail = $module->getVar('mod_author_mail');
484484
$authorWebsiteUrl = $module->getVar('mod_author_website_url');
485485
$license = $module->getVar('mod_license');
486-
$subversion = $module->getVar('mod_subversion');
487-
$date = date('D Y-m-d H:i:s');
486+
//$subversion = $module->getVar('mod_subversion');
487+
//$date = date('D Y-m-d H:i:s');
488488
if (null === $noPhpFile) {
489489
$ret = "<?php";
490490
} elseif (is_string($noPhpFile)) {
@@ -539,7 +539,7 @@ public function renderFile()
539539
if (!$this->xf->write($this->getContent(), $mode, true)) {
540540
$ret .= sprintf($notCreated, $fileName, $folderName);
541541
$GLOBALS['xoopsTpl']->assign('created', false);
542-
exit();
542+
return $ret;
543543
}
544544
// Created
545545
$ret .= sprintf($created, $fileName, $folderName);

class/Files/CreateXoopsCode.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -717,7 +717,8 @@ public function getXcDeleteRight($anchor, $permString = '', $mid = '', $var = ''
717717
*/
718718
public function getXcHandlerLine($tableName, $t = '')
719719
{
720-
return "{$t}\${$tableName}Handler = \$helper->getHandler('{$tableName}');\n";
720+
$ucfTableName = ucfirst($tableName);
721+
return "{$t}\${$tableName}Handler = \$helper->getHandler('{$ucfTableName}');\n";
721722
}
722723

723724
/**
@@ -1020,7 +1021,7 @@ public function getXcXoopsConfirm($tableName, $language, $fieldId, $fieldMain, $
10201021
$stuOptions = mb_strtoupper($options);
10211022
$ccFieldId = Modulebuilder\Files\CreateFile::getInstance()->getCamelCase($fieldId, false, true);
10221023
$pc = Modulebuilder\Files\CreatePhpCode::getInstance();
1023-
$array = "array('ok' => 1, '{$fieldId}' => \${$ccFieldId}, 'op' => '{$options}')";
1024+
$array = "['ok' => 1, '{$fieldId}' => \${$ccFieldId}, 'op' => '{$options}']";
10241025
$server = $pc->getPhpCodeGlobalsVariables('REQUEST_URI', 'SERVER');
10251026
$getVar = $this->getXcGetVar('', $tableName . 'Obj', $fieldMain, true, '');
10261027
$sprintf = $pc->getPhpCodeSprintf($language . 'FORM_SURE_' . $stuOptions, $getVar);
@@ -1770,7 +1771,6 @@ public function getXcCommonPagesDelete($language, $tableName, $tableSoleName, $f
17701771
$cf = Modulebuilder\Files\CreateFile::getInstance();
17711772

17721773
$ccFieldId = $cf->getCamelCase($fieldId, false, true);
1773-
$stuFieldMain = mb_strtoupper($fieldMain);
17741774
$ccFieldMain = $cf->getCamelCase($fieldMain, false, true);
17751775

17761776
$ret = $xc->getXcHandlerGet($tableName, $ccFieldId, 'Obj', $tableName . 'Handler', '', $t);

0 commit comments

Comments
 (0)