Skip to content

Commit 23b76c0

Browse files
committed
improvements for notifications
1 parent 43693ac commit 23b76c0

9 files changed

Lines changed: 389 additions & 58 deletions

File tree

class/Files/Classes/ClassSpecialFiles.php

Lines changed: 83 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,7 @@ public function renderConstants()
267267
return $this->renderFile();
268268
}
269269

270-
public function renderConstantsTestInterface()
270+
public function renderConstantsInterface_Version_Zyspec()
271271
{
272272
$pc = Modulebuilder\Files\CreatePhpCode::getInstance();
273273

@@ -283,14 +283,29 @@ public function renderConstantsTestInterface()
283283
$contentFile = $this->getHeaderFilesComments($module, null, $namespace);
284284
$contentFile .= $pc->getPhpCodeDefined();
285285
$contentFile .= $pc->getPhpCodeCommentMultiLine(['Interface ' => $this->className]);
286-
$contentClass = '';
286+
287+
$contentClass = $pc->getPhpCodeBlankLine();
288+
$contentClass .= $pc->getPhpCodeCommentLine('Constants for tables', '', "\t");
289+
foreach (array_keys($tables) as $t) {
290+
$tablePermissions[] = $tables[$t]->getVar('table_permissions');
291+
$stuTableName = mb_strtoupper($tables[$t]->getVar('table_name'));
292+
$contentClass .= $pc->getPhpCodeConstant("TABLE_" . $stuTableName, $t, "\t",'protected static');
293+
}
294+
295+
$contentClass .= $pc->getPhpCodeBlankLine();
296+
$contentClass .= $pc->getPhpCodeCommentLine('Constants for status', '', "\t");
297+
$contentClass .= $pc->getPhpCodeConstant("STATUS_NONE ", 0, "\t",'protected static');
298+
$contentClass .= $pc->getPhpCodeConstant("STATUS_OFFLINE ", 1, "\t",'protected static');
299+
$contentClass .= $pc->getPhpCodeConstant("STATUS_SUBMITTED", 2, "\t",'protected static');
300+
$contentClass .= $pc->getPhpCodeConstant("STATUS_APPROVED ", 3, "\t",'protected static');
301+
$contentClass .= $pc->getPhpCodeConstant("STATUS_BROKEN ", 4, "\t",'protected static');
287302
if (in_array(1, $tablePermissions)) {
288303
$constPerm = $pc->getPhpCodeBlankLine();
289304
$constPerm .= $pc->getPhpCodeCommentLine('Constants for permissions', '', "\t");
290-
$constPerm .= $pc->getPhpCodeConstant("PERM_GLOBAL_NONE ", 0, 'protected static',"\t");
291-
$constPerm .= $pc->getPhpCodeConstant("PERM_GLOBAL_VIEW ", 1, 'protected static',"\t");
292-
$constPerm .= $pc->getPhpCodeConstant("PERM_GLOBAL_SUBMIT ", 2, 'protected static',"\t");
293-
$constPerm .= $pc->getPhpCodeConstant("PERM_GLOBAL_APPROVE", 3, 'protected static',"\t");
305+
$constPerm .= $pc->getPhpCodeConstant("PERM_GLOBAL_NONE ", 0, "\t",'protected static');
306+
$constPerm .= $pc->getPhpCodeConstant("PERM_GLOBAL_VIEW ", 1,"\t", 'protected static');
307+
$constPerm .= $pc->getPhpCodeConstant("PERM_GLOBAL_SUBMIT ", 2,"\t", 'protected static');
308+
$constPerm .= $pc->getPhpCodeConstant("PERM_GLOBAL_APPROVE", 3,"\t", 'protected static');
294309
$contentClass .= $constPerm;
295310
}
296311
$contentClass .= $pc->getPhpCodeBlankLine();
@@ -308,4 +323,66 @@ public function renderConstantsTestInterface()
308323
return $this->renderFile();
309324
}
310325

326+
public function renderConstantsInterface()
327+
{
328+
$pc = Modulebuilder\Files\CreatePhpCode::getInstance();
329+
330+
$module = $this->getModule();
331+
$filename = $this->getFileName();
332+
$tables = $this->getTables();
333+
$tablePermissions = [];
334+
foreach (array_keys($tables) as $t) {
335+
$tablePermissions[] = $tables[$t]->getVar('table_permissions');
336+
}
337+
$moduleDirname = $module->getVar('mod_dirname');
338+
$ucfModuleDirname = ucfirst($moduleDirname);
339+
$namespace = $pc->getPhpCodeNamespace(['XoopsModules', $moduleDirname]);
340+
$contentFile = $this->getHeaderFilesComments($module, null, $namespace);
341+
$contentFile .= $pc->getPhpCodeDefined();
342+
$contentFile .= $pc->getPhpCodeBlankLine();
343+
344+
$contentInterface = $pc->getPhpCodeCommentMultiLine(['Interface ' => $ucfModuleDirname . 'Interface']);
345+
346+
347+
$contentInterface .= $pc->getPhpCodeCommentLine('Constants for tables', '', "\t");
348+
foreach (array_keys($tables) as $t) {
349+
$tablePermissions[] = $tables[$t]->getVar('table_permissions');
350+
$stuTableName = mb_strtoupper($tables[$t]->getVar('table_name'));
351+
$contentInterface .= $pc->getPhpCodeConstant("TABLE_" . $stuTableName, $t, "\t",'public const');
352+
}
353+
354+
$contentInterface .= $pc->getPhpCodeBlankLine();
355+
$contentInterface .= $pc->getPhpCodeCommentLine('Constants for status', '', "\t");
356+
$contentInterface .= $pc->getPhpCodeConstant("STATUS_NONE ", 0, "\t",'public const' );
357+
$contentInterface .= $pc->getPhpCodeConstant("STATUS_OFFLINE ", 1, "\t",'public const');
358+
$contentInterface .= $pc->getPhpCodeConstant("STATUS_SUBMITTED", 2, "\t",'public const' );
359+
$contentInterface .= $pc->getPhpCodeConstant("STATUS_APPROVED ", 3, "\t",'public const');
360+
$contentInterface .= $pc->getPhpCodeConstant("STATUS_BROKEN ", 4, "\t",'public const');
361+
if (in_array(1, $tablePermissions)) {
362+
$constPerm = $pc->getPhpCodeBlankLine();
363+
$constPerm .= $pc->getPhpCodeCommentLine('Constants for permissions', '', "\t");
364+
$constPerm .= $pc->getPhpCodeConstant("PERM_GLOBAL_NONE ", 0, "\t",'public const');
365+
$constPerm .= $pc->getPhpCodeConstant("PERM_GLOBAL_VIEW ", 1,"\t", 'public const');
366+
$constPerm .= $pc->getPhpCodeConstant("PERM_GLOBAL_SUBMIT ", 2,"\t", 'public const');
367+
$constPerm .= $pc->getPhpCodeConstant("PERM_GLOBAL_APPROVE", 3,"\t", 'public const');
368+
$contentInterface .= $constPerm;
369+
}
370+
$contentInterface .= $pc->getPhpCodeBlankLine();
371+
$contentFile .= $pc->getPhpCodeInterface($ucfModuleDirname . 'Interface', $contentInterface);
372+
$contentFile .= $pc->getPhpCodeBlankLine();
373+
374+
$contentClass = $pc->getPhpCodeBlankLine();
375+
$func = $pc->getPhpCodeCommentLine('trigger a warning if invalid "constant" requested', '', "\t\t");
376+
$if = $pc->getPhpCodeTriggerError("\"Invalid Constant requested ('{\$val}')\"", 'E_USER_WARNING', "\t\t\t");
377+
$if .= $this->getSimpleString("return false;", "\t\t\t");
378+
$func .= $pc->getPhpCodeConditions('!defined(constant("self::$val"))', null, null, $if, false, "\t\t");
379+
$func .= $this->getSimpleString('return constant("self::$val");', "\t");
380+
$contentClass .= $pc->getPhpCodeFunction('getConstant', '$val', $func, 'final public static ', false, "\t");
381+
382+
$contentFile .= $pc->getPhpCodeClass($this->className, $contentClass, null, null, $ucfModuleDirname . 'Interface');
383+
384+
$this->create($moduleDirname, 'class', $filename, $contentFile, _AM_MODULEBUILDER_FILE_CREATED, _AM_MODULEBUILDER_FILE_NOTCREATED);
385+
386+
return $this->renderFile();
387+
}
311388
}

class/Files/CreateArchitecture.php

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -334,6 +334,32 @@ public function setFilesToBuilding($module)
334334
$userTemplatesCategoriesList->write($module, $table, $moduleDirname . '_' . $tableName . '_cat_list' . '.tpl');
335335
$ret[] = $userTemplatesCategoriesList->render();
336336
}
337+
// Creation of notifications files
338+
if (1 === (int)$tables[$t]->getVar('table_notifications')) {
339+
// Language Mail Template New File
340+
$languageMailTpl = Modulebuilder\Files\Language\LanguageMailTpl::getInstance();
341+
$languageMailTpl->write($module, $table, $tableName . '_new_notify.tpl');
342+
$ret[] = $languageMailTpl->render();
343+
// Language Mail Template Modify File
344+
$languageMailTpl = Modulebuilder\Files\Language\LanguageMailTpl::getInstance();
345+
$languageMailTpl->write($module, $table, $tableName . '_modify_notify.tpl');
346+
$ret[] = $languageMailTpl->render();
347+
// Language Mail Template Delete File
348+
$languageMailTpl = Modulebuilder\Files\Language\LanguageMailTpl::getInstance();
349+
$languageMailTpl->write($module, $table, $tableName . '_delete_notify.tpl');
350+
$ret[] = $languageMailTpl->render();
351+
// Language Mail Template Approve File
352+
$languageMailTpl = Modulebuilder\Files\Language\LanguageMailTpl::getInstance();
353+
$languageMailTpl->write($module, $table, $tableName . '_approve_notify.tpl');
354+
$ret[] = $languageMailTpl->render();
355+
}
356+
// Creation of notifications files
357+
if (1 === (int)$tables[$t]->getVar('table_broken')) {
358+
// Language Mail Template Category File
359+
$languageMailTpl = Modulebuilder\Files\Language\LanguageMailTpl::getInstance();
360+
$languageMailTpl->write($module, $table, $tableName . '_broken_notify.tpl');
361+
$ret[] = $languageMailTpl->render();
362+
}
337363
}
338364
}
339365

@@ -635,7 +661,7 @@ public function setFilesToBuilding($module)
635661
$languageMain = Modulebuilder\Files\Language\LanguageMain::getInstance();
636662
$languageMain->write($module, $tables, 'main.php');
637663
$ret[] = $languageMain->render();
638-
// User Templates Submit File
664+
// User Templates Breadcrumbs File
639665
if ($templateType == 'bootstrap') {
640666
$userTemplatesUserBreadcrumbs = Modulebuilder\Files\Templates\User\Bootstrap\Breadcrumbs::getInstance();
641667
} else {

class/Files/CreatePhpCode.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -253,11 +253,12 @@ public function getPhpCodeTernaryOperator($return, $condition, $one, $two, $t =
253253
*
254254
* @return string
255255
*/
256-
public function getPhpCodeClass($name = null, $content = null, $extends = null, $type = null)
256+
public function getPhpCodeClass($name = null, $content = null, $extends = null, $type = null, $implements = null)
257257
{
258258
$typ = (null != $type) ? "{$type} " : '';
259259
$ext = (null != $extends) ? " extends {$extends}" : '';
260-
$ret = "{$typ}class {$name}{$ext}\n";
260+
$imp = (null != $implements) ? " implements {$implements}" : '';
261+
$ret = "{$typ}class {$name}{$ext}{$imp}\n";
261262
$ret .= '{';
262263
$ret .= $content;
263264
$ret .= "}\n";

0 commit comments

Comments
 (0)