Skip to content

Commit 6cc3ee1

Browse files
authored
Merge pull request #2 from ggoffy/master
move broken handling and submit
2 parents f76470a + 54e2440 commit 6cc3ee1

25 files changed

Lines changed: 975 additions & 183 deletions
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -162,8 +162,8 @@ public function getUserBrokenSave($moduleDirname, $fields, $tableName, $tableSol
162162

163163
$condElse = $pc->getPhpCodeCommentLine('Insert Data', null, $t . "\t");
164164
$insert = $xc->getXcHandlerInsert($tableName, $tableName, 'Obj');
165-
$redirctHeader = $xc->getXcRedirectHeader('index', '', '2', "{$language}FORM_OK", true, $t . "\t\t");
166-
$condElse .= $pc->getPhpCodeConditions($insert, '', '', $redirctHeader, false, $t . "\t");
165+
$redirectHeader = $xc->getXcRedirectHeader('index', '', '2', "{$language}FORM_OK", true, $t . "\t\t");
166+
$condElse .= $pc->getPhpCodeConditions($insert, '', '', $redirectHeader, false, $t . "\t");
167167
$assigne = $xc->getXcXoopsTplAssign('error_message', '$errorMessage', true, $t . "\t");
168168
$ret .= $pc->getPhpCodeConditions('$error', ' === ', 'true', $assigne, $condElse, $t);
169169

class/Files/Admin/AdminBroken.php

Lines changed: 195 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,195 @@
1+
<?php
2+
3+
namespace XoopsModules\Tdmcreate\Files\Admin;
4+
5+
use XoopsModules\Tdmcreate;
6+
use XoopsModules\Tdmcreate\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+
* tdmcreate module.
19+
*
20+
* @copyright XOOPS Project (https://xoops.org)
21+
* @license GNU GPL 2 (http://www.gnu.org/licenses/old-licenses/gpl-2.0.html)
22+
*
23+
* @since 2.5.0
24+
*
25+
* @author Txmod Xoops http://www.txmodxoops.org
26+
*
27+
*/
28+
29+
/**
30+
* Class AdminBroken.
31+
*/
32+
class AdminBroken extends Files\CreateFile
33+
{
34+
/**
35+
* @public function constructor
36+
* @param null
37+
*/
38+
public function __construct()
39+
{
40+
parent::__construct();
41+
}
42+
43+
/**
44+
* @static function getInstance
45+
* @param null
46+
*
47+
* @return AdminBroken
48+
*/
49+
public static function getInstance()
50+
{
51+
static $instance = false;
52+
if (!$instance) {
53+
$instance = new self();
54+
}
55+
56+
return $instance;
57+
}
58+
59+
/**
60+
* @public function write
61+
* @param $module
62+
* @param $tables
63+
* @param $filename
64+
*/
65+
public function write($module, $tables, $filename)
66+
{
67+
$this->setModule($module);
68+
$this->setTables($tables);
69+
$this->setFileName($filename);
70+
}
71+
72+
/**
73+
* @private function getAdminBrokenHeader
74+
* @param $moduleDirname
75+
* @param $fieldId
76+
* @return string
77+
*/
78+
private function getAdminBrokenHeader($moduleDirname, $tableName, $t = '')
79+
{
80+
$pc = Tdmcreate\Files\CreatePhpCode::getInstance();
81+
$xc = Tdmcreate\Files\CreateXoopsCode::getInstance();
82+
$axc = Tdmcreate\Files\Admin\AdminXoopsCode::getInstance();
83+
$ret = $pc->getPhpCodeUseNamespace(['Xmf', 'Request'], '', '');
84+
$ret .= $pc->getPhpCodeUseNamespace(['XoopsModules', $moduleDirname], '', '');
85+
$ret .= $pc->getPhpCodeUseNamespace(['XoopsModules', $moduleDirname, 'Constants']);
86+
$ret .= $this->getInclude();
87+
$ret .= $pc->getPhpCodeBlankLine();
88+
$ret .= $pc->getPhpCodeCommentLine('Define Stylesheet', '', $t);
89+
$ret .= $xc->getXcXoThemeAddStylesheet('style', $t);
90+
$ret .= $axc->getAdminTemplateMain($moduleDirname, $tableName, $t);
91+
$navigation = $axc->getAdminDisplayNavigation($tableName);
92+
$ret .= $xc->getXcXoopsTplAssign('navigation', $navigation, true, $t);
93+
94+
return $ret;
95+
}
96+
97+
/**
98+
* @private function getAdminBrokenList
99+
* @param $table
100+
* @param $language
101+
* @param string $t
102+
* @return string
103+
*/
104+
private function getAdminBrokenList($tables, $language, $t = '')
105+
{
106+
$pc = Tdmcreate\Files\CreatePhpCode::getInstance();
107+
$xc = Tdmcreate\Files\CreateXoopsCode::getInstance();
108+
109+
$ret = '';
110+
foreach (array_keys($tables) as $i) {
111+
if (1 === (int)$tables[$i]->getVar('table_broken')) {
112+
$tableName = $tables[$i]->getVar('table_name');
113+
$tableSoleName = $tables[$i]->getVar('table_solename');
114+
$ucfTableName = ucfirst($tableName);
115+
$ret .= $pc->getPhpCodeBlankLine();
116+
$ret .= $pc->getPhpCodeCommentLine('Check table', $tableName, $t);
117+
$ret .= $xc->getXcXoopsRequest('start', 'start' . $ucfTableName, '0', 'Int', false, $t);
118+
$adminpager = $xc->getXcGetConfig('adminpager');
119+
$ret .= $xc->getXcXoopsRequest('limit', 'limit' . $ucfTableName, $adminpager, 'Int', false, $t);
120+
$critName = 'cr' . $ucfTableName;
121+
122+
$fields = $this->getTableFields($tables[$i]->getVar('table_mid'), $tables[$i]->getVar('table_id'));
123+
$fieldId = '';
124+
$fieldMain = '';
125+
$fieldSatus = '';
126+
foreach (array_keys($fields) as $f) {
127+
$fieldName = $fields[$f]->getVar('field_name');
128+
if (0 == $f) {
129+
$fieldId = $fieldName;
130+
}
131+
if (1 == $fields[$f]->getVar('field_main')) {
132+
$fieldMain = $fieldName;
133+
}
134+
if (16 == $fields[$f]->getVar('field_element')) {
135+
$fieldSatus = $fieldName;
136+
}
137+
}
138+
139+
$ret .= $xc->getXcCriteriaCompo($critName, $t);
140+
$crit = $xc->getXcCriteria('', "'{$fieldSatus}'", 'Constants::STATUS_BROKEN', '', true);
141+
$ret .= $xc->getXcCriteriaAdd($critName, $crit, $t, "\n");
142+
$ret .= $xc->getXcHandlerCountClear($tableName . 'Count', $tableName, '$' . $critName, $t);
143+
$ret .= $xc->getXcXoopsTplAssign($tableName . '_count', "\${$tableName}Count", true, $t);
144+
$sprintf = $pc->getPhpCodeSprintf($language . 'BROKEN_RESULT', "'{$ucfTableName}'");
145+
$ret .= $xc->getXcXoopsTplAssign($tableName . '_result', $sprintf, true, $t);
146+
147+
$ret .= $xc->getXcCriteriaSetStart($critName,'$start', $t);
148+
$ret .= $xc->getXcCriteriaSetLimit($critName,'$limit', $t);
149+
$contIf = $xc->getXcHandlerAllClear("{$tableName}All", $tableName, "\${$critName}", $t . "\t");
150+
$foreach = $xc->getXcEqualsOperator("\${$tableSoleName}['table']", "'{$ucfTableName}'", '', $t . "\t\t");
151+
$foreach .= $xc->getXcEqualsOperator("\${$tableSoleName}['key']", "'{$fieldId}'", '', $t . "\t\t");
152+
$foreach .= $xc->getXcGetVar("{$tableSoleName}['keyval']", "{$tableName}All[\$i]", "{$fieldId}", false, $t . "\t\t");
153+
$foreach .= $xc->getXcGetVar("{$tableSoleName}['main']", "{$tableName}All[\$i]", "{$fieldMain}", false, $t . "\t\t");
154+
$foreach .= $xc->getXcXoopsTplAppend("{$tableName}_list", "\${$tableSoleName}", $t . "\t\t");
155+
$contIf .= $pc->getPhpCodeForeach("{$tableName}All", true, false, 'i', $foreach, $t . "\t");
156+
$contIf .= $xc->getXcPageNav($tableName, $t . "\t", 'start' . $ucfTableName, "'op=list&limit{$ucfTableName}=' . \$limit");
157+
$sprintf = $pc->getPhpCodeSprintf($language . 'BROKEN_NODATA', "'{$ucfTableName}'");
158+
$contElse = $xc->getXcXoopsTplAssign('nodata' . $ucfTableName, $sprintf, true, $t . "\t");
159+
160+
$ret .= $pc->getPhpCodeConditions("\${$tableName}Count", ' > ', '0', $contIf, $contElse, $t);
161+
$ret .= $pc->getPhpCodeUnset($critName, $t);
162+
}
163+
}
164+
165+
$ret .= $pc->getPhpCodeBlankLine();
166+
167+
return $ret;
168+
}
169+
170+
/**
171+
* @public function render
172+
* @param null
173+
*
174+
* @return bool|string
175+
*/
176+
public function render()
177+
{
178+
$tf = Tdmcreate\Files\CreateFile::getInstance();
179+
180+
$module = $this->getModule();
181+
$tables = $this->getTables();
182+
$filename = $this->getFileName();
183+
$moduleDirname = $module->getVar('mod_dirname');
184+
$language = $this->getLanguage($moduleDirname, 'AM');
185+
186+
$content = $this->getHeaderFilesComments($module);
187+
$content .= $this->getAdminBrokenHeader($moduleDirname, 'broken');
188+
$content .= $this->getAdminBrokenList($tables, $language);
189+
$content .= $this->getInclude('footer');
190+
191+
$tf->create($moduleDirname, 'admin', $filename, $content, _AM_TDMCREATE_FILE_CREATED, _AM_TDMCREATE_FILE_NOTCREATED);
192+
193+
return $tf->renderFile();
194+
}
195+
}

class/Files/Admin/AdminMenu.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,14 +168,21 @@ private function getAdminMenuList($module, $language, $langAbout, $menu)
168168
$ret = '';
169169
$tables = $this->getTableTables($module->getVar('mod_id'), 'table_order');
170170
$tablePermissions = [];
171+
$tableBroken = [];
171172
foreach (array_keys($tables) as $t) {
172173
$tablePermissions[] = $tables[$t]->getVar('table_permissions');
174+
$tableBroken[] = $tables[$t]->getVar('table_broken');
173175
if (1 == $tables[$t]->getVar('table_admin')) {
174176
++$menu;
175177
$param1 = ['title' => "{$language}{$menu}", 'link' => "'admin/{$tables[$t]->getVar('table_name')}.php'", 'icon' => "'assets/icons/32/{$tables[$t]->getVar('table_image')}'"];
176178
$ret .= $this->getAdminMenuArray($param1, true);
177179
}
178180
}
181+
if (in_array(1, $tableBroken)) {
182+
++$menu;
183+
$param2 = ['title' => "{$language}{$menu}", 'link' => "'admin/broken.php'", 'icon' => "\$sysPathIcon32.'/brokenlink.png'"];
184+
$ret .= $this->getAdminMenuArray($param2, true);
185+
}
179186
if (in_array(1, $tablePermissions)) {
180187
++$menu;
181188
$param2 = ['title' => "{$language}{$menu}", 'link' => "'admin/permissions.php'", 'icon' => "\$sysPathIcon32.'/permissions.png'"];

class/Files/Classes/ClassFormElements.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -630,6 +630,7 @@ private function getXoopsFormSelectStatus($language, $moduleDirname, $fieldName,
630630
$ret .= $cxc->getClassAddOption($ccFieldName . 'Select', "Constants::STATUS_OFFLINE, {$languageShort}STATUS_OFFLINE", $t);
631631
$ret .= $cxc->getClassAddOption($ccFieldName . 'Select', "Constants::STATUS_SUBMITTED, {$languageShort}STATUS_SUBMITTED", $t);
632632
$ret .= $cxc->getClassAddOption($ccFieldName . 'Select', "Constants::STATUS_APPROVED, {$languageShort}STATUS_APPROVED", $t);
633+
$ret .= $cxc->getClassAddOption($ccFieldName . 'Select', "Constants::STATUS_BROKEN, {$languageShort}STATUS_BROKEN", $t);
633634
$ret .= $cxc->getClassAddElement('form', "\${$ccFieldName}Select{$required}", $t);
634635

635636
return $ret;

class/Files/Classes/ClassSpecialFiles.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,8 @@ public function renderConstants()
242242
$contentClass .= $pc->getPhpCodeConstant("STATUS_OFFLINE ", 1, "\t");
243243
$contentClass .= $pc->getPhpCodeConstant("STATUS_SUBMITTED", 2, "\t");
244244
$contentClass .= $pc->getPhpCodeConstant("STATUS_APPROVED ", 3, "\t");
245+
$contentClass .= $pc->getPhpCodeConstant("STATUS_BROKEN ", 4, "\t");
246+
245247

246248
if (in_array(1, $tablePermissions)) {
247249
$constPerm = $pc->getPhpCodeBlankLine();

class/Files/CreateArchitecture.php

Lines changed: 11 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -423,6 +423,17 @@ public function setFilesToBuilding($module)
423423
$languageBlocks->write($module, $tables, 'blocks.php');
424424
$ret[] = $languageBlocks->render();
425425
}
426+
// Creation of admin broken files
427+
if (in_array(1, $tableBroken)) {
428+
// Admin broken File
429+
$adminPermissions = Tdmcreate\Files\Admin\AdminBroken::getInstance();
430+
$adminPermissions->write($module, $tables, 'broken.php');
431+
$ret[] = $adminPermissions->render();
432+
// Templates Admin broken File
433+
$adminTemplatesPermissions = Tdmcreate\Files\Templates\Admin\TemplatesAdminBroken::getInstance();
434+
$adminTemplatesPermissions->write($module, $tables, $moduleDirname . '_admin_broken.tpl');
435+
$ret[] = $adminTemplatesPermissions->render();
436+
}
426437
// Creation of admin permission files
427438
if (in_array(1, $tablePermissions)) {
428439
// Admin Permissions File
@@ -540,20 +551,6 @@ public function setFilesToBuilding($module)
540551
$userNotificationUpdate->write($module, 'notification_update.php');
541552
$ret[] = $userNotificationUpdate->render();
542553
}
543-
// User Broken File
544-
if (in_array(1, $tableBroken)) {
545-
$userBroken = Tdmcreate\Files\User\UserBroken::getInstance();
546-
$userBroken->write($module, $table, 'broken.php');
547-
$ret[] = $userBroken->render();
548-
// User Templates Broken File
549-
if ($templateType == 'bootstrap') {
550-
$userTemplatesBroken = Tdmcreate\Files\Templates\User\Bootstrap\Broken::getInstance();
551-
} else {
552-
$userTemplatesBroken = Tdmcreate\Files\Templates\User\Defstyle\Broken::getInstance();
553-
}
554-
$userTemplatesBroken->write($module, $table, $moduleDirname . '_broken.tpl');
555-
$ret[] = $userTemplatesBroken->render();
556-
}
557554
// User Pdf File
558555
if (in_array(1, $tablePdf)) {
559556
$userPdf = Tdmcreate\Files\User\UserPdf::getInstance();
@@ -626,21 +623,6 @@ public function setFilesToBuilding($module)
626623
$userTemplatesSingle->write($module, $table, $moduleDirname . '_single.tpl');
627624
$ret[] = $userTemplatesSingle->render();
628625
}
629-
630-
// User Submit File
631-
if (in_array(1, $tableSubmit)) {
632-
$userSubmit = Tdmcreate\Files\User\UserSubmit::getInstance();
633-
$userSubmit->write($module, $table, 'submit.php');
634-
$ret[] = $userSubmit->render();
635-
// User Templates Submit File
636-
if ($templateType == 'bootstrap') {
637-
$userTemplatesSubmit = Tdmcreate\Files\Templates\User\Bootstrap\Submit::getInstance();
638-
} else {
639-
$userTemplatesSubmit = Tdmcreate\Files\Templates\User\Defstyle\Submit::getInstance();
640-
}
641-
$userTemplatesSubmit->write($module, $table, $moduleDirname . '_submit.tpl');
642-
$ret[] = $userTemplatesSubmit->render();
643-
}
644626
// User Visit File
645627
if (in_array(1, $tableVisit)) {
646628
$userVisit = Tdmcreate\Files\User\UserVisit::getInstance();

class/Files/CreateSmartyCode.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,11 +132,12 @@ public function getSmartyNoSimbol($noSimbol = '', $t = '')
132132
* @param string $language
133133
* @param mixed $const
134134
* @param string $t
135+
* @param string $n
135136
* @return string
136137
*/
137-
public function getSmartyConst($language, $const, $t = '')
138+
public function getSmartyConst($language, $const, $t = '', $n = '')
138139
{
139-
return "{$t}<{\$smarty.const.{$language}{$const}}>";
140+
return "{$t}<{\$smarty.const.{$language}{$const}}>{$n}";
140141
}
141142

142143
/**

0 commit comments

Comments
 (0)