Skip to content

Commit d9fe946

Browse files
committed
- fixed bug with upload file/images in admin pages
- fixed bug with save permissions in admin pages - fixed bugs in tpl creation - improved tpl creation
1 parent 3774ff7 commit d9fe946

66 files changed

Lines changed: 1680 additions & 582 deletions

Some content is hidden

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

_TODO.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Notifications:
2+
there are too much notification, which are not needed/working
3+
TODO:
4+
- reduce xoops_version.php to needed
5+
- adapt language/modinfo.php

admin/building.php

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,17 @@
2626
$templateMain = 'tdmcreate_building.tpl';
2727

2828
include __DIR__ . '/header.php';
29-
$op = \Xmf\Request::getString('op', 'default');
30-
$mid = \Xmf\Request::getInt('mod_id');
31-
$moduleObj = $helper->getHandler('Modules')->get($mid);
32-
$cachePath = XOOPS_VAR_PATH . '/caches/tdmcreate_cache';
29+
$op = \Xmf\Request::getString('op', 'default');
30+
$mid = \Xmf\Request::getInt('mod_id');
31+
$inroot_copy = \Xmf\Request::getInt('inroot_copy');
32+
$moduleObj = $helper->getHandler('Modules')->get($mid);
33+
$cachePath = XOOPS_VAR_PATH . '/caches/tdmcreate_cache';
34+
if (!is_dir($cachePath)) {
35+
if (!mkdir($cachePath, 0777) && !is_dir($cachePath)) {
36+
throw new \RuntimeException(sprintf('Directory "%s" was not created', $cachePath));
37+
}
38+
chmod($cachePath, 0777);
39+
}
3340
// Clear cache
3441
if (file_exists($cache = $cachePath . '/classpaths.cache')) {
3542
unlink($cache);
@@ -75,9 +82,10 @@
7582
}
7683
unset($build);
7784
// Directory to saved all files
78-
$GLOBALS['xoopsTpl']->assign('building_directory', sprintf(_AM_TDMCREATE_BUILDING_DIRECTORY, $moduleDirname));
85+
$building_directory = sprintf(_AM_TDMCREATE_BUILDING_DIRECTORY, $moduleDirname);
86+
7987
// Copy this module in root modules
80-
if (1 == $moduleObj->getVar('mod_inroot_copy')) {
88+
if (1 === $inroot_copy) {
8189
$building = Tdmcreate\Building::getInstance();
8290
if (isset($moduleDirname)) {
8391
// Clear this module if it's in root/modules
@@ -89,7 +97,9 @@
8997
}
9098
}
9199
$building->copyDir($fromDir, $toDir);
100+
$building_directory .= sprintf(_AM_TDMCREATE_BUILDING_DIRECTORY_INROOT, $toDir);
92101
}
102+
$GLOBALS['xoopsTpl']->assign('building_directory', $building_directory);
93103
break;
94104
case 'default':
95105
default:

admin/modules.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,7 @@
2727

2828
include __DIR__ . '/header.php';
2929
// Recovered value of argument op in the URL $
30-
$op = \Xmf\Request::getString('op', 'list');
31-
30+
$op = \Xmf\Request::getString('op', 'list');
3231
$modId = \Xmf\Request::getInt('mod_id');
3332

3433
switch ($op) {
@@ -150,7 +149,7 @@
150149
$modulesObj->setVar('mod_comments', in_array('comments', $moduleOption));
151150
$modulesObj->setVar('mod_notifications', in_array('notifications', $moduleOption));
152151
$modulesObj->setVar('mod_permissions', in_array('permissions', $moduleOption));
153-
$modulesObj->setVar('mod_inroot_copy', in_array('inroot_copy', $moduleOption));
152+
//$modulesObj->setVar('mod_inroot_copy', in_array('inroot_copy', $moduleOption));
154153

155154
if ($helper->getHandler('Modules')->insert($modulesObj)) {
156155
if ($modulesObj->isNew()) {

admin/settings.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@
132132
$settingsObj->setVar('set_comments', in_array('comments', $settingOption));
133133
$settingsObj->setVar('set_notifications', in_array('notifications', $settingOption));
134134
$settingsObj->setVar('set_permissions', in_array('permissions', $settingOption));
135-
$settingsObj->setVar('set_inroot_copy', in_array('inroot', $settingOption));
135+
//$settingsObj->setVar('set_inroot_copy', in_array('inroot', $settingOption));
136136
if (\Xmf\Request::hasVar('set_type')) {
137137
$settingsObj->setVar('set_type', \Xmf\Request::getString('set_type', '', 'POST'));
138138
}

class/Building.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,21 +55,23 @@ public static function getInstance()
5555
*/
5656
public function getForm($action = false)
5757
{
58-
$tc = Tdmcreate\Helper::getInstance();
58+
$helper = Tdmcreate\Helper::getInstance();
5959
if (false === $action) {
6060
$action = \Xmf\Request::getString('REQUEST_URI', '', 'SERVER');
6161
}
6262
xoops_load('XoopsFormLoader');
6363
$form = new \XoopsThemeForm(_AM_TDMCREATE_ADMIN_CONST, 'buildform', $action, 'post', true);
6464
$form->setExtra('enctype="multipart/form-data"');
65-
$moduleObj = $tc->getHandler('modules')->getObjects(null);
65+
$moduleObj = $helper->getHandler('modules')->getObjects(null);
6666
$mod_select = new \XoopsFormSelect(_AM_TDMCREATE_CONST_MODULES, 'mod_id', 'mod_id');
6767
$mod_select->addOption('', _AM_TDMCREATE_BUILD_MODSELOPT);
6868
foreach ($moduleObj as $mod) {
6969
$mod_select->addOption($mod->getVar('mod_id'), $mod->getVar('mod_name'));
7070
}
7171
$form->addElement($mod_select, true);
72-
72+
73+
$form->addElement(new \XoopsFormRadioYN(_AM_TDMCREATE_MODULE_INROOT_COPY, 'inroot_copy', $helper->getConfig('inroot_copy')));
74+
7375
$form->addElement(new \XoopsFormHidden('op', 'build'));
7476
$form->addElement(new \XoopsFormButton(_REQUIRED . ' <sup class="red bold">*</sup>', 'submit', _SUBMIT, 'submit'));
7577

class/Files/Blocks/BlocksFiles.php

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -155,8 +155,9 @@ function b_{$moduleDirname}_{$tableName}_show(\$options)
155155
\$criteria->setLimit(\$limit);
156156
\${$tableName}All = \${$tableName}Handler->getAll(\$criteria);
157157
unset(\$criteria);
158-
foreach(array_keys(\${$tableName}All) as \$i)
159-
{\n
158+
if (count(\${$tableName}All) > 0) {
159+
foreach(array_keys(\${$tableName}All) as \$i)
160+
{\n
160161
EOT;
161162
foreach (array_keys($fields) as $f) {
162163
$fieldName = $fields[$f]->getVar('field_name');
@@ -168,34 +169,35 @@ function b_{$moduleDirname}_{$tableName}_show(\$options)
168169
switch ($fieldElement) {
169170
case 2:
170171
$ret .= <<<EOT
171-
\$block[\$i]['{$rpFieldName}'] = \$myts->htmlSpecialChars(\${$tableName}All[\$i]->getVar('{$fieldName}'));\n
172+
\$block[\$i]['{$rpFieldName}'] = \$myts->htmlSpecialChars(\${$tableName}All[\$i]->getVar('{$fieldName}'));\n
172173
EOT;
173174
break;
174175
case 3:
175176
case 4:
176177
$ret .= <<<EOT
177-
\$block[\$i]['{$rpFieldName}'] = strip_tags(\${$tableName}All[\$i]->getVar('{$fieldName}'));\n
178+
\$block[\$i]['{$rpFieldName}'] = strip_tags(\${$tableName}All[\$i]->getVar('{$fieldName}'));\n
178179
EOT;
179180
break;
180181
case 8:
181182
$ret .= <<<EOT
182-
\$block[\$i]['{$rpFieldName}'] = \XoopsUser::getUnameFromId(\${$tableName}All[\$i]->getVar('{$fieldName}'));\n
183+
\$block[\$i]['{$rpFieldName}'] = \XoopsUser::getUnameFromId(\${$tableName}All[\$i]->getVar('{$fieldName}'));\n
183184
EOT;
184185
break;
185186
case 15:
186187
$ret .= <<<EOT
187-
\$block[\$i]['{$rpFieldName}'] = formatTimeStamp(\${$tableName}All[\$i]->getVar('{$fieldName}'));\n
188+
\$block[\$i]['{$rpFieldName}'] = formatTimeStamp(\${$tableName}All[\$i]->getVar('{$fieldName}'));\n
188189
EOT;
189190
break;
190191
default:
191192
$ret .= <<<EOT
192-
\$block[\$i]['{$rpFieldName}'] = \${$tableName}All[\$i]->getVar('{$fieldName}');\n
193+
\$block[\$i]['{$rpFieldName}'] = \${$tableName}All[\$i]->getVar('{$fieldName}');\n
193194
EOT;
194195
break;
195196
}
196197
}
197198
}
198199
$ret .= <<<EOT
200+
}
199201
}
200202
return \$block;
201203
}\n\n

class/Files/Classes/ClassFormElements.php

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -412,17 +412,23 @@ private function getXoopsFormUploadImage($language, $moduleDirname, $tableName,
412412
*/
413413
private function getXoopsFormUploadFile($language, $moduleDirname, $tableName, $fieldName, $required = 'false')
414414
{
415-
$tf = Tdmcreate\Files\CreateFile::getInstance();
416-
$pc = Tdmcreate\Files\CreatePhpCode::getInstance();
417-
$xc = Tdmcreate\Files\CreateXoopsCode::getInstance();
418-
$cc = Tdmcreate\Files\Classes\ClassXoopsCode::getInstance();
419-
$ucfFieldName = $tf->getCamelCase($fieldName, true);
420-
$stuTableName = mb_strtoupper($tableName);
421-
$t = "\t\t";
422-
$ret = $pc->getPhpCodeCommentLine('Form', 'File ' . $ucfFieldName, $t);
423-
$getConfig = $xc->getXcGetConfig($moduleDirname, 'maxsize');
424-
$xoopsFormFile = $cc->getClassXoopsFormFile('', $language . '_' . $stuTableName, $fieldName, $getConfig, true, '');
425-
$ret .= $cc->getClassAddElement('form', $xoopsFormFile, $t);
415+
$tf = Tdmcreate\Files\CreateFile::getInstance();
416+
$pc = Tdmcreate\Files\CreatePhpCode::getInstance();
417+
$xc = Tdmcreate\Files\CreateXoopsCode::getInstance();
418+
$cc = Tdmcreate\Files\Classes\ClassXoopsCode::getInstance();
419+
$ucfFieldName = $tf->getCamelCase($fieldName, true);
420+
$stuTableName = mb_strtoupper($tableName);
421+
$t = "\t\t";
422+
$ret = $pc->getPhpCodeCommentLine('Form', 'File ' . $ucfFieldName, $t);
423+
$ret .= $cc->getClassXoopsFormElementTray('fileUploadTray', $language . 'FORM_UPLOAD_FILE_' . $stuTableName, '<br>', $t);
424+
$getVar = $xc->getXcGetVar('', 'this', $fieldName, true);
425+
$xoopsFormLabel = $cc->getClassXoopsFormLabel('', "''", $getVar, true);
426+
$condIf = $cc->getClassAddElement('fileUploadTray', $xoopsFormLabel, $t . "\t");
427+
$ret .= $pc->getPhpCodeConditions('!$this->isNew()', null, null, $condIf, false, "\t\t");
428+
$getConfig = $xc->getXcGetConfig($moduleDirname, 'maxsize');
429+
$xoopsFormFile = $cc->getClassXoopsFormFile('', "''", $fieldName, $getConfig, true, '');
430+
$ret .= $cc->getClassAddElement('fileUploadTray', $xoopsFormFile, $t);
431+
$ret .= $cc->getClassAddElement('form', '$fileUploadTray', $t);
426432

427433
return $ret;
428434
}
@@ -742,7 +748,7 @@ public function renderElements()
742748
$ret .= $this->getXoopsFormUploadImage($languageFunct, $moduleDirname, $tableName, $tableSoleName, $fieldName, $required);
743749
break;
744750
case 14:
745-
$ret .= $this->getXoopsFormUploadFile($language, $moduleDirname, $tableName, $fieldName, $required);
751+
$ret .= $this->getXoopsFormUploadFile($languageFunct, $moduleDirname, $tableName, $fieldName, $required);
746752
break;
747753
case 15:
748754
$ret .= $this->getXoopsFormTextDateSelect($language, $fieldName, $required);

class/Files/CreateArchitecture.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -292,11 +292,11 @@ public function setFilesToBuilding($module)
292292
if (in_array(1, $tableCategory)) {
293293
// User List Templates File
294294
$userTemplatesCategories = Templates\User\Categories::getInstance();
295-
$userTemplatesCategories->write($module, $table, $moduleDirname . '_' . $tableName . '.tpl');
295+
$userTemplatesCategories->write($module, $table, $moduleDirname . '_' . $tableName . '_cat.tpl');
296296
$ret[] = $userTemplatesCategories->render();
297297
// User List Templates File
298298
$userTemplatesCategoriesList = Templates\User\CategoriesList::getInstance();
299-
$userTemplatesCategoriesList->write($module, $table, $moduleDirname . '_' . $tableName . '_list' . '.tpl');
299+
$userTemplatesCategoriesList->write($module, $table, $moduleDirname . '_' . $tableName . '_cat_list' . '.tpl');
300300
$ret[] = $userTemplatesCategoriesList->render();
301301
}
302302
}

0 commit comments

Comments
 (0)