Skip to content

Commit 9f6f9bd

Browse files
committed
transfered class::getInstance() to class _construct
1 parent 856304a commit 9f6f9bd

55 files changed

Lines changed: 2729 additions & 2653 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

class/Files/Admin/AdminBroken.php

Lines changed: 57 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,31 @@
3131
*/
3232
class AdminBroken extends Files\CreateFile
3333
{
34+
/**
35+
* @var mixed
36+
*/
37+
private $axc = null;
38+
39+
/**
40+
* @var string
41+
*/
42+
private $xc = null;
43+
44+
/**
45+
* @var string
46+
*/
47+
private $pc = null;
48+
3449
/**
3550
* @public function constructor
3651
* @param null
3752
*/
3853
public function __construct()
3954
{
4055
parent::__construct();
56+
$this->xc = Modulebuilder\Files\CreateXoopsCode::getInstance();
57+
$this->pc = Modulebuilder\Files\CreatePhpCode::getInstance();
58+
$this->axc = Modulebuilder\Files\Admin\AdminXoopsCode::getInstance();
4159
}
4260

4361
/**
@@ -78,19 +96,16 @@ public function write($module, $tables, $filename)
7896
*/
7997
private function getAdminBrokenHeader($moduleDirname, $tableName, $t = '')
8098
{
81-
$pc = Modulebuilder\Files\CreatePhpCode::getInstance();
82-
$xc = Modulebuilder\Files\CreateXoopsCode::getInstance();
83-
$axc = Modulebuilder\Files\Admin\AdminXoopsCode::getInstance();
84-
$ret = $pc->getPhpCodeUseNamespace(['Xmf', 'Request'], '', '');
85-
$ret .= $pc->getPhpCodeUseNamespace(['XoopsModules', $moduleDirname], '', '');
86-
$ret .= $pc->getPhpCodeUseNamespace(['XoopsModules', $moduleDirname, 'Constants']);
99+
$ret = $this->pc->getPhpCodeUseNamespace(['Xmf', 'Request'], '', '');
100+
$ret .= $this->pc->getPhpCodeUseNamespace(['XoopsModules', $moduleDirname], '', '');
101+
$ret .= $this->pc->getPhpCodeUseNamespace(['XoopsModules', $moduleDirname, 'Constants']);
87102
$ret .= $this->getInclude();
88-
$ret .= $pc->getPhpCodeBlankLine();
89-
$ret .= $pc->getPhpCodeCommentLine('Define Stylesheet', '', $t);
90-
$ret .= $xc->getXcXoThemeAddStylesheet('style', $t);
91-
$ret .= $axc->getAdminTemplateMain($moduleDirname, $tableName, $t);
92-
$navigation = $axc->getAdminDisplayNavigation($tableName);
93-
$ret .= $xc->getXcXoopsTplAssign('navigation', $navigation, true, $t);
103+
$ret .= $this->pc->getPhpCodeBlankLine();
104+
$ret .= $this->pc->getPhpCodeCommentLine('Define Stylesheet', '', $t);
105+
$ret .= $this->xc->getXcXoThemeAddStylesheet('style', $t);
106+
$ret .= $this->axc->getAdminTemplateMain($moduleDirname, $tableName, $t);
107+
$navigation = $this->axc->getAdminDisplayNavigation($tableName);
108+
$ret .= $this->xc->getXcXoopsTplAssign('navigation', $navigation, true, $t);
94109

95110
return $ret;
96111
}
@@ -104,20 +119,17 @@ private function getAdminBrokenHeader($moduleDirname, $tableName, $t = '')
104119
*/
105120
private function getAdminBrokenList($tables, $language, $t = '')
106121
{
107-
$pc = Modulebuilder\Files\CreatePhpCode::getInstance();
108-
$xc = Modulebuilder\Files\CreateXoopsCode::getInstance();
109-
110122
$ret = '';
111123
foreach (array_keys($tables) as $i) {
112124
if (1 === (int)$tables[$i]->getVar('table_broken')) {
113125
$tableName = $tables[$i]->getVar('table_name');
114126
$tableSoleName = $tables[$i]->getVar('table_solename');
115127
$ucfTableName = ucfirst($tableName);
116-
$ret .= $pc->getPhpCodeBlankLine();
117-
$ret .= $pc->getPhpCodeCommentLine('Check table', $tableName, $t);
118-
$ret .= $xc->getXcXoopsRequest('start', 'start' . $ucfTableName, '0', 'Int', false, $t);
119-
$adminpager = $xc->getXcGetConfig('adminpager');
120-
$ret .= $xc->getXcXoopsRequest('limit', 'limit' . $ucfTableName, $adminpager, 'Int', false, $t);
128+
$ret .= $this->pc->getPhpCodeBlankLine();
129+
$ret .= $this->pc->getPhpCodeCommentLine('Check table', $tableName, $t);
130+
$ret .= $this->xc->getXcXoopsRequest('start', 'start' . $ucfTableName, '0', 'Int', false, $t);
131+
$adminpager = $this->xc->getXcGetConfig('adminpager');
132+
$ret .= $this->xc->getXcXoopsRequest('limit', 'limit' . $ucfTableName, $adminpager, 'Int', false, $t);
121133
$critName = 'cr' . $ucfTableName;
122134

123135
$fields = $this->getTableFields($tables[$i]->getVar('table_mid'), $tables[$i]->getVar('table_id'));
@@ -137,34 +149,34 @@ private function getAdminBrokenList($tables, $language, $t = '')
137149
}
138150
}
139151

140-
$ret .= $xc->getXcCriteriaCompo($critName, $t);
141-
$constant = $xc->getXcGetConstants('STATUS_BROKEN');
142-
$crit = $xc->getXcCriteria('', "'{$fieldSatus}'", $constant, '', true);
143-
$ret .= $xc->getXcCriteriaAdd($critName, $crit, $t, "\n");
144-
$ret .= $xc->getXcHandlerCountClear($tableName . 'Count', $tableName, '$' . $critName, $t);
145-
$ret .= $xc->getXcXoopsTplAssign($tableName . '_count', "\${$tableName}Count", true, $t);
146-
$sprintf = $pc->getPhpCodeSprintf($language . 'BROKEN_RESULT', "'{$ucfTableName}'");
147-
$ret .= $xc->getXcXoopsTplAssign($tableName . '_result', $sprintf, true, $t);
148-
149-
$ret .= $xc->getXcCriteriaSetStart($critName,'$start', $t);
150-
$ret .= $xc->getXcCriteriaSetLimit($critName,'$limit', $t);
151-
$contIf = $xc->getXcHandlerAllClear("{$tableName}All", $tableName, "\${$critName}", $t . "\t");
152-
$foreach = $xc->getXcEqualsOperator("\${$tableSoleName}['table']", "'{$ucfTableName}'", '', $t . "\t\t");
153-
$foreach .= $xc->getXcEqualsOperator("\${$tableSoleName}['key']", "'{$fieldId}'", '', $t . "\t\t");
154-
$foreach .= $xc->getXcGetVar("{$tableSoleName}['keyval']", "{$tableName}All[\$i]", "{$fieldId}", false, $t . "\t\t");
155-
$foreach .= $xc->getXcGetVar("{$tableSoleName}['main']", "{$tableName}All[\$i]", "{$fieldMain}", false, $t . "\t\t");
156-
$foreach .= $xc->getXcXoopsTplAppend("{$tableName}_list", "\${$tableSoleName}", $t . "\t\t");
157-
$contIf .= $pc->getPhpCodeForeach("{$tableName}All", true, false, 'i', $foreach, $t . "\t");
158-
$contIf .= $xc->getXcPageNav($tableName, $t . "\t", 'start' . $ucfTableName, "'op=list&limit{$ucfTableName}=' . \$limit");
159-
$sprintf = $pc->getPhpCodeSprintf($language . 'BROKEN_NODATA', "'{$ucfTableName}'");
160-
$contElse = $xc->getXcXoopsTplAssign('nodata' . $ucfTableName, $sprintf, true, $t . "\t");
161-
162-
$ret .= $pc->getPhpCodeConditions("\${$tableName}Count", ' > ', '0', $contIf, $contElse, $t);
163-
$ret .= $pc->getPhpCodeUnset($critName, $t);
152+
$ret .= $this->xc->getXcCriteriaCompo($critName, $t);
153+
$constant = $this->xc->getXcGetConstants('STATUS_BROKEN');
154+
$crit = $this->xc->getXcCriteria('', "'{$fieldSatus}'", $constant, '', true);
155+
$ret .= $this->xc->getXcCriteriaAdd($critName, $crit, $t, "\n");
156+
$ret .= $this->xc->getXcHandlerCountClear($tableName . 'Count', $tableName, '$' . $critName, $t);
157+
$ret .= $this->xc->getXcXoopsTplAssign($tableName . '_count', "\${$tableName}Count", true, $t);
158+
$sprintf = $this->pc->getPhpCodeSprintf($language . 'BROKEN_RESULT', "'{$ucfTableName}'");
159+
$ret .= $this->xc->getXcXoopsTplAssign($tableName . '_result', $sprintf, true, $t);
160+
161+
$ret .= $this->xc->getXcCriteriaSetStart($critName,'$start', $t);
162+
$ret .= $this->xc->getXcCriteriaSetLimit($critName,'$limit', $t);
163+
$contIf = $this->xc->getXcHandlerAllClear("{$tableName}All", $tableName, "\${$critName}", $t . "\t");
164+
$foreach = $this->xc->getXcEqualsOperator("\${$tableSoleName}['table']", "'{$ucfTableName}'", '', $t . "\t\t");
165+
$foreach .= $this->xc->getXcEqualsOperator("\${$tableSoleName}['key']", "'{$fieldId}'", '', $t . "\t\t");
166+
$foreach .= $this->xc->getXcGetVar("{$tableSoleName}['keyval']", "{$tableName}All[\$i]", "{$fieldId}", false, $t . "\t\t");
167+
$foreach .= $this->xc->getXcGetVar("{$tableSoleName}['main']", "{$tableName}All[\$i]", "{$fieldMain}", false, $t . "\t\t");
168+
$foreach .= $this->xc->getXcXoopsTplAppend("{$tableName}_list", "\${$tableSoleName}", $t . "\t\t");
169+
$contIf .= $this->pc->getPhpCodeForeach("{$tableName}All", true, false, 'i', $foreach, $t . "\t");
170+
$contIf .= $this->xc->getXcPageNav($tableName, $t . "\t", 'start' . $ucfTableName, "'op=list&limit{$ucfTableName}=' . \$limit");
171+
$sprintf = $this->pc->getPhpCodeSprintf($language . 'BROKEN_NODATA', "'{$ucfTableName}'");
172+
$contElse = $this->xc->getXcXoopsTplAssign('nodata' . $ucfTableName, $sprintf, true, $t . "\t");
173+
174+
$ret .= $this->pc->getPhpCodeConditions("\${$tableName}Count", ' > ', '0', $contIf, $contElse, $t);
175+
$ret .= $this->pc->getPhpCodeUnset($critName, $t);
164176
}
165177
}
166178

167-
$ret .= $pc->getPhpCodeBlankLine();
179+
$ret .= $this->pc->getPhpCodeBlankLine();
168180

169181
return $ret;
170182
}

class/Files/Admin/AdminIndex.php

Lines changed: 57 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,31 @@
3131
*/
3232
class AdminIndex extends Files\CreateFile
3333
{
34+
/**
35+
* @var mixed
36+
*/
37+
private $axc = null;
38+
39+
/**
40+
* @var string
41+
*/
42+
private $xc = null;
43+
44+
/**
45+
* @var string
46+
*/
47+
private $pc = null;
48+
3449
/**
3550
* @public function constructor
3651
* @param null
3752
*/
3853
public function __construct()
3954
{
4055
parent::__construct();
56+
$this->xc = Modulebuilder\Files\CreateXoopsCode::getInstance();
57+
$this->pc = Modulebuilder\Files\CreatePhpCode::getInstance();
58+
$this->axc = Modulebuilder\Files\Admin\AdminXoopsCode::getInstance();
4159
}
4260

4361
/**
@@ -76,73 +94,71 @@ public function write($module, $tables, $filename)
7694
*/
7795
private function getAdminIndex($module)
7896
{
79-
$pc = Modulebuilder\Files\CreatePhpCode::getInstance();
80-
$xc = Modulebuilder\Files\CreateXoopsCode::getInstance();
81-
$axc = Modulebuilder\Files\Admin\AdminXoopsCode::getInstance();
97+
8298
$moduleDirname = $module->getVar('mod_dirname');
8399
$tables = $this->getTableTables($module->getVar('mod_id'), 'table_order');
84100
$language = $this->getLanguage($moduleDirname, 'AM');
85101
$languageThereAre = $this->getLanguage($moduleDirname, 'AM', 'THEREARE_');
86102

87103
$ret = $this->getSimpleString('');
88-
$ret .= $pc->getPhpCodeUseNamespace(['XoopsModules', $moduleDirname, 'Common']);
89-
$ret .= $pc->getPhpCodeIncludeDir('dirname(__DIR__)', 'preloads/autoloader', true);
104+
$ret .= $this->pc->getPhpCodeUseNamespace(['XoopsModules', $moduleDirname, 'Common']);
105+
$ret .= $this->pc->getPhpCodeIncludeDir('dirname(__DIR__)', 'preloads/autoloader', true);
90106
$ret .= $this->getInclude();
91-
$ret .= $pc->getPhpCodeBlankLine();
92-
$ret .= $pc->getPhpCodeCommentLine('Template Index');
93-
$ret .= $axc->getAdminTemplateMain((string)$moduleDirname, 'index');
94-
$ret .= $pc->getPhpCodeBlankLine();
95-
$ret .= $pc->getPhpCodeCommentLine('Count elements');
107+
$ret .= $this->pc->getPhpCodeBlankLine();
108+
$ret .= $this->pc->getPhpCodeCommentLine('Template Index');
109+
$ret .= $this->axc->getAdminTemplateMain((string)$moduleDirname, 'index');
110+
$ret .= $this->pc->getPhpCodeBlankLine();
111+
$ret .= $this->pc->getPhpCodeCommentLine('Count elements');
96112
$tableName = null;
97113
foreach (array_keys($tables) as $i) {
98114
$tableName = $tables[$i]->getVar('table_name');
99115
$ucfTableName = ucfirst($tableName);
100-
$ret .= $xc->getXcEqualsOperator("\$count{$ucfTableName}", "\${$tableName}Handler->getCount()");
116+
$ret .= $this->xc->getXcEqualsOperator("\$count{$ucfTableName}", "\${$tableName}Handler->getCount()");
101117
}
102-
$ret .= $pc->getPhpCodeBlankLine();
103-
$ret .= $pc->getPhpCodeCommentLine('InfoBox Statistics');
104-
$ret .= $axc->getAxcAddInfoBox($language . 'STATISTICS');
105-
$ret .= $pc->getPhpCodeCommentLine('Info elements');
118+
$ret .= $this->pc->getPhpCodeBlankLine();
119+
$ret .= $this->pc->getPhpCodeCommentLine('InfoBox Statistics');
120+
$ret .= $this->axc->getAxcAddInfoBox($language . 'STATISTICS');
121+
$ret .= $this->pc->getPhpCodeCommentLine('Info elements');
106122
$tableInstall = [];
107123
foreach (array_keys($tables) as $i) {
108124
$tableName = $tables[$i]->getVar('table_name');
109125
$tableInstall[] = $tables[$i]->getVar('table_install');
110126
$stuTableName = $languageThereAre . mb_strtoupper($tableName);
111127
$ucfTableName = ucfirst($tableName);
112-
$ret .= $axc->getAxcAddInfoBoxLine($stuTableName, "\$count{$ucfTableName}");
128+
$ret .= $this->axc->getAxcAddInfoBoxLine($stuTableName, "\$count{$ucfTableName}");
113129
}
114130

115131
if (null === $tableName) {
116-
$ret .= $axc->getAxcAddInfoBoxLine('No statistics', '0');
132+
$ret .= $this->axc->getAxcAddInfoBoxLine('No statistics', '0');
117133
}
118134

119135
if (is_array($tables) && in_array(1, $tableInstall)) {
120-
$ret .= $pc->getPhpCodeBlankLine();
121-
$ret .= $pc->getPhpCodeCommentLine('Upload Folders');
122-
$ret .= $xc->getXcEqualsOperator('$configurator', 'new Common\Configurator()');
136+
$ret .= $this->pc->getPhpCodeBlankLine();
137+
$ret .= $this->pc->getPhpCodeCommentLine('Upload Folders');
138+
$ret .= $this->xc->getXcEqualsOperator('$configurator', 'new Common\Configurator()');
123139
$cond = '$configurator->uploadFolders && is_array($configurator->uploadFolders)';
124-
$fe_action = $xc->getXcEqualsOperator('$folder[]', '$configurator->uploadFolders[$i]', '',"\t\t");
125-
$condIf = $pc->getPhpCodeForeach('configurator->uploadFolders', true, false, 'i', $fe_action, "\t");
126-
$ret .= $pc->getPhpCodeConditions($cond, '', '', $condIf, false);
127-
128-
$ret .= $pc->getPhpCodeCommentLine('Uploads Folders Created');
129-
$boxLine = $axc->getAxcAddConfigBoxLine('$folder[$i]', 'folder', '', "\t");
130-
$boxLine .= $axc->getAxcAddConfigBoxLine("array(\$folder[\$i], '777')", 'chmod', '', "\t");
131-
$ret .= $pc->getPhpCodeForeach('folder', true, false, 'i', $boxLine, '') . PHP_EOL;
140+
$fe_action = $this->xc->getXcEqualsOperator('$folder[]', '$configurator->uploadFolders[$i]', '',"\t\t");
141+
$condIf = $this->pc->getPhpCodeForeach('configurator->uploadFolders', true, false, 'i', $fe_action, "\t");
142+
$ret .= $this->pc->getPhpCodeConditions($cond, '', '', $condIf, false);
143+
144+
$ret .= $this->pc->getPhpCodeCommentLine('Uploads Folders Created');
145+
$boxLine = $this->axc->getAxcAddConfigBoxLine('$folder[$i]', 'folder', '', "\t");
146+
$boxLine .= $this->axc->getAxcAddConfigBoxLine("array(\$folder[\$i], '777')", 'chmod', '', "\t");
147+
$ret .= $this->pc->getPhpCodeForeach('folder', true, false, 'i', $boxLine, '') . PHP_EOL;
132148
}
133-
$ret .= $pc->getPhpCodeCommentLine('Render Index');
134-
$ret .= $xc->getXcXoopsTplAssign('navigation', "\$adminObject->displayNavigation('index.php')");
135-
$ret .= $pc->getPhpCodeCommentLine('Test Data');
136-
$condIf = $xc->getXcXoopsLoadLanguage('admin/modulesadmin',"\t", 'system');
137-
$condIf .= $pc->getPhpCodeIncludeDir('dirname(__DIR__)', 'testdata/index', true, '','',"\t");
138-
$condIf .= $axc->getAdminItemButton("constant('CO_' . \$moduleDirNameUpper . '_ADD_SAMPLEDATA')", '', '', $op = '__DIR__ . /../../testdata/index.php?op=load', $type = 'samplebutton', $t = "\t");
139-
$condIf .= $axc->getAdminItemButton("constant('CO_' . \$moduleDirNameUpper . '_SAVE_SAMPLEDATA')", '', '', $op = '__DIR__ . /../../testdata/index.php?op=save', $type = 'samplebutton', $t = "\t");
140-
$condIf .= "//" . $axc->getAdminItemButton("constant('CO_' . \$moduleDirNameUpper . '_EXPORT_SCHEMA')", '', '', $op = '__DIR__ . /../../testdata/index.php?op=exportschema', $type = 'samplebutton', $t = "\t");
141-
$condIf .= $axc->getAdminDisplayButton('left', "\t");
142-
$cond = $xc->getXcGetConfig('displaySampleButton');
143-
$ret .= $pc->getPhpCodeConditions($cond, '', '', $condIf, false);
144-
$ret .= $xc->getXcXoopsTplAssign('index', '$adminObject->displayIndex()');
145-
$ret .= $pc->getPhpCodeCommentLine('End Test Data');
149+
$ret .= $this->pc->getPhpCodeCommentLine('Render Index');
150+
$ret .= $this->xc->getXcXoopsTplAssign('navigation', "\$adminObject->displayNavigation('index.php')");
151+
$ret .= $this->pc->getPhpCodeCommentLine('Test Data');
152+
$condIf = $this->xc->getXcXoopsLoadLanguage('admin/modulesadmin',"\t", 'system');
153+
$condIf .= $this->pc->getPhpCodeIncludeDir('dirname(__DIR__)', 'testdata/index', true, '','',"\t");
154+
$condIf .= $this->axc->getAdminItemButton("constant('CO_' . \$moduleDirNameUpper . '_ADD_SAMPLEDATA')", '', '', $op = '__DIR__ . /../../testdata/index.php?op=load', $type = 'samplebutton', $t = "\t");
155+
$condIf .= $this->axc->getAdminItemButton("constant('CO_' . \$moduleDirNameUpper . '_SAVE_SAMPLEDATA')", '', '', $op = '__DIR__ . /../../testdata/index.php?op=save', $type = 'samplebutton', $t = "\t");
156+
$condIf .= "//" . $this->axc->getAdminItemButton("constant('CO_' . \$moduleDirNameUpper . '_EXPORT_SCHEMA')", '', '', $op = '__DIR__ . /../../testdata/index.php?op=exportschema', $type = 'samplebutton', $t = "\t");
157+
$condIf .= $this->axc->getAdminDisplayButton('left', "\t");
158+
$cond = $this->xc->getXcGetConfig('displaySampleButton');
159+
$ret .= $this->pc->getPhpCodeConditions($cond, '', '', $condIf, false);
160+
$ret .= $this->xc->getXcXoopsTplAssign('index', '$adminObject->displayIndex()');
161+
$ret .= $this->pc->getPhpCodeCommentLine('End Test Data');
146162

147163
$ret .= $this->getInclude('footer');
148164

0 commit comments

Comments
 (0)