Skip to content

Commit 35937da

Browse files
authored
Merge pull request #14 from ggoffy/master
- added notification event new, modify, approve
2 parents 38cd4d8 + dfbbd0e commit 35937da

29 files changed

Lines changed: 334 additions & 226 deletions

_TODO.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ I moved files, where I do not know whether they are still needed into folder _ar
99

1010
TODOs:
1111

12-
implement constants interface
12+
new xoops_confirm
1313

1414

1515
Broken files:

_archive/class/Files/User/UserBroken.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ public function getUserBrokenHeader($moduleDirname, $fields)
8585
$ret .= $pc->getPhpCodeUseNamespace(['XoopsModules', $moduleDirname], '', '');
8686
$ret .= $pc->getPhpCodeUseNamespace(['XoopsModules', $moduleDirname, 'Constants']);
8787
$ret .= $this->getInclude();
88-
$ret .= $xc->getXcXoopsRequest('op', 'op', 'list');
88+
$ret .= $xc->getXcXoopsRequest('op', 'op', 'list', 'Cmd');
8989
$ret .= $xc->getXcXoopsRequest($ccFieldId, $fieldId, '', 'Int');
9090
$ret .= $pc->getPhpCodeCommentLine('Template');
9191
$ret .= $uxc->getUserTplMain($moduleDirname, 'broken');

_archive/class/Files/User/UserSubmit.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ public function getUserSubmitHeader($moduleDirname, $tablePermissions)
8787
$ret .= $this->getInclude();
8888
$ret .= $xc->getXcXoopsLoadLanguage('admin', '', $moduleDirname);
8989
$ret .= $pc->getPhpCodeCommentLine('It recovered the value of argument op in URL$');
90-
$ret .= $xc->getXcXoopsRequest('op', 'op', 'form');
90+
$ret .= $xc->getXcXoopsRequest('op', 'op', 'form', 'Cmd');
9191
$ret .= $pc->getPhpCodeCommentLine('Template');
9292
$ret .= $uxc->getUserTplMain($moduleDirname, 'submit');
9393
$ret .= $pc->getPhpCodeIncludeDir('XOOPS_ROOT_PATH', 'header', true);

class/Files/Admin/AdminBroken.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,8 @@ public function write($module, $tables, $filename)
7272
/**
7373
* @private function getAdminBrokenHeader
7474
* @param $moduleDirname
75-
* @param $fieldId
75+
* @param $tableName
76+
* @param string $t
7677
* @return string
7778
*/
7879
private function getAdminBrokenHeader($moduleDirname, $tableName, $t = '')
@@ -96,7 +97,7 @@ private function getAdminBrokenHeader($moduleDirname, $tableName, $t = '')
9697

9798
/**
9899
* @private function getAdminBrokenList
99-
* @param $table
100+
* @param $tables
100101
* @param $language
101102
* @param string $t
102103
* @return string

class/Files/Admin/AdminPermissions.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ private function getPermissionsHeader($module, $language)
106106
$ret .= $axc->getAdminTemplateMain($moduleDirname, 'permissions');
107107
$ret .= $xc->getXcXoopsTplAssign('navigation', "\$adminObject->displayNavigation('permissions.php')");
108108
$ret .= $pc->getPhpCodeBlankLine();
109-
$ret .= $xc->getXcXoopsRequest('op', 'op', 'global');
109+
$ret .= $xc->getXcXoopsRequest('op', 'op', 'global', 'Cmd');
110110
$ret .= $pc->getPhpCodeBlankLine();
111111
$ret .= $pc->getPhpCodeCommentLine('Get Form');
112112
$ret .= $pc->getPhpCodeIncludeDir('XOOPS_ROOT_PATH', 'class/xoopsform/grouppermform', true);

class/Files/Classes/ClassFiles.php

Lines changed: 27 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -276,9 +276,10 @@ private function getFunctionForm($module, $table, $fieldId, $fieldInForm)
276276
$action = $xc->getXcEqualsOperator('$action', "\$_SERVER['REQUEST_URI']", null, "\t\t\t");
277277
$ucfModuleDirname = ucfirst($moduleDirname);
278278
$getForm = $xc->getXcGetInstance('helper', "\XoopsModules\\{$ucfModuleDirname}\Helper", "\t\t");
279-
$getForm .= $pc->getPhpCodeConditions('false', ' === ', '$action', $action, false, "\t\t");
279+
$getForm .= $pc->getPhpCodeConditions('$action', ' === ', 'false', $action, false, "\t\t");
280280
$xUser = $pc->getPhpCodeGlobals('xoopsUser');
281281
$xModule = $pc->getPhpCodeGlobals('xoopsModule');
282+
$getForm .= $xc->getXcEqualsOperator('$isAdmin', $xUser . '->isAdmin(' . $xModule . '->mid())', null, "\t\t");
282283
$permString = 'upload_groups';
283284
if (1 != $tableCategory/* && (1 == $tablePermissions)*/) {
284285
$getForm .= $pc->getPhpCodeCommentLine('Permissions for', 'uploader', "\t\t");
@@ -288,7 +289,7 @@ private function getFunctionForm($module, $table, $fieldId, $fieldInForm)
288289
$ternaryOperator = $pc->getPhpCodeTernaryOperator('permissionUpload', $checkRight, 'true', 'false', "\t\t\t");
289290
$permissionUpload = $xc->getXcEqualsOperator('$permissionUpload', 'true', null, "\t\t\t\t");
290291
$ternOperator = $pc->getPhpCodeRemoveCarriageReturn($ternaryOperator, '', "\r");
291-
$if = $pc->getPhpCodeConditions('!' . $xUser . '->isAdmin(' . $xModule . '->mid())', '', '', "\t" . $ternaryOperator, $permissionUpload, "\t\t\t");
292+
$if = $pc->getPhpCodeConditions('$isAdmin', '', '', "\t" . $ternaryOperator, $permissionUpload, "\t\t\t");
292293
$getForm .= $pc->getPhpCodeConditions($xUser, '', '', $if, $ternOperator, "\t\t");
293294
}
294295
$getForm .= $pc->getPhpCodeCommentLine('Title', '', "\t\t");
@@ -390,44 +391,57 @@ private function getValuesInObject($moduleDirname, $table, $fields)
390391
$utility = 0;
391392
$header = '';
392393
$configMaxchar = 0;
394+
$lenMaxName = 0;
395+
foreach (array_keys($fields) as $f) {
396+
$fieldName = $fields[$f]->getVar('field_name');
397+
$rpFieldName = $this->getRightString($fieldName);
398+
$len = strlen($rpFieldName);
399+
if (3 == $fields[$f]->getVar('field_element') || 4 == $fields[$f]->getVar('field_element')) {
400+
$len = $len + strlen('_short');
401+
}
402+
$lenMaxName = max($len, $lenMaxName);
403+
}
393404
foreach (array_keys($fields) as $f) {
394405
$fieldName = $fields[$f]->getVar('field_name');
395406
$fieldElement = $fields[$f]->getVar('field_element');
396407
$rpFieldName = $this->getRightString($fieldName);
408+
$spacer = str_repeat(' ', $lenMaxName - strlen($rpFieldName));
397409
switch ($fieldElement) {
398410
case 3:
399-
$getValues .= $pc->getPhpCodeStripTags("ret['{$rpFieldName}']", "\$this->getVar('{$fieldName}', 'e')", false, "\t\t");
411+
$getValues .= $pc->getPhpCodeStripTags("ret['{$rpFieldName}']{$spacer}", "\$this->getVar('{$fieldName}', 'e')", false, "\t\t");
400412
if ($configMaxchar == 0) {
401413
$getValues .= $xc->getXcEqualsOperator('$editorMaxchar', $xc->getXcGetConfig('editor_maxchar'), false, "\t\t");
402414
$configMaxchar = 1;
403415
}
404416
$truncate = "\$utility::truncateHtml(\$ret['{$rpFieldName}'], \$editorMaxchar)";
405-
$getValues .= $xc->getXcEqualsOperator("\$ret['{$rpFieldName}_short']", $truncate, false, "\t\t");
417+
$spacer = str_repeat(' ', $lenMaxName - strlen($rpFieldName) - strlen('_short'));
418+
$getValues .= $xc->getXcEqualsOperator("\$ret['{$rpFieldName}_short']{$spacer}", $truncate, false, "\t\t");
406419
$helper = 1;
407420
$utility = 1;
408421
break;
409422
case 4:
410-
$getValues .= $xc->getXcGetVar("ret['{$rpFieldName}']", 'this', $fieldName, false, "\t\t", ", 'e'");
423+
$getValues .= $xc->getXcGetVar("ret['{$rpFieldName}']{$spacer}", 'this', $fieldName, false, "\t\t", ", 'e'");
411424
if ($configMaxchar == 0) {
412425
$getValues .= $xc->getXcEqualsOperator('$editorMaxchar', $xc->getXcGetConfig('editor_maxchar'), false, "\t\t");
413426
$configMaxchar = 1;
414427
}
415428
$truncate = "\$utility::truncateHtml(\$ret['{$rpFieldName}'], \$editorMaxchar)";
416-
$getValues .= $xc->getXcEqualsOperator("\$ret['{$rpFieldName}_short']", $truncate, false, "\t\t");
429+
$spacer = str_repeat(' ', $lenMaxName - strlen($rpFieldName) - strlen('_short'));
430+
$getValues .= $xc->getXcEqualsOperator("\$ret['{$rpFieldName}_short']{$spacer}", $truncate, false, "\t\t");
417431
$helper = 1;
418432
$utility = 1;
419433
break;
420434
case 6:
421-
$getValues .= $xc->getXcEqualsOperator("\$ret['{$rpFieldName}']", "(int)\$this->getVar('{$fieldName}') > 0 ? _YES : _NO", false, "\t\t");
435+
$getValues .= $xc->getXcEqualsOperator("\$ret['{$rpFieldName}']{$spacer}", "(int)\$this->getVar('{$fieldName}') > 0 ? _YES : _NO", false, "\t\t");
422436
break;
423437
case 8:
424-
$getValues .= $xc->getXcXoopsUserUnameFromId("ret['{$rpFieldName}']", "\$this->getVar('{$fieldName}')", "\t\t");
438+
$getValues .= $xc->getXcXoopsUserUnameFromId("ret['{$rpFieldName}']{$spacer}", "\$this->getVar('{$fieldName}')", "\t\t");
425439
break;
426440
case 15:
427-
$getValues .= $xc->getXcFormatTimeStamp("ret['{$rpFieldName}']", "\$this->getVar('{$fieldName}')", 's', "\t\t");
441+
$getValues .= $xc->getXcFormatTimeStamp("ret['{$rpFieldName}']{$spacer}", "\$this->getVar('{$fieldName}')", 's', "\t\t");
428442
break;
429443
case 21:
430-
$getValues .= $xc->getXcFormatTimeStamp("ret['{$rpFieldName}']", "\$this->getVar('{$fieldName}')", 'm', "\t\t");
444+
$getValues .= $xc->getXcFormatTimeStamp("ret['{$rpFieldName}']{$spacer}", "\$this->getVar('{$fieldName}')", 'm', "\t\t");
431445
break;
432446
default:
433447
$fieldElements = $tc->getHandler('Fieldelements')->get($fieldElement);
@@ -448,10 +462,10 @@ private function getValuesInObject($moduleDirname, $table, $fields)
448462
$getTopicTable = "\${$topicTableName}Handler->get(\$this->getVar('{$fieldName}'))";
449463
$getValues .= $xc->getXcEqualsOperator("\${$topicTableName}Obj", $getTopicTable, null, "\t\t");
450464
$fMainTopic = "\${$topicTableName}Obj->getVar('{$fieldMainTopic}')";
451-
$getValues .= $xc->getXcEqualsOperator("\$ret['{$rpFieldName}']", $fMainTopic, null, "\t\t");
465+
$getValues .= $xc->getXcEqualsOperator("\$ret['{$rpFieldName}']{$spacer}", $fMainTopic, null, "\t\t");
452466
$helper = 1;
453467
} else {
454-
$getValues .= $xc->getXcGetVar("ret['{$rpFieldName}']", 'this', $fieldName, false, "\t\t");
468+
$getValues .= $xc->getXcGetVar("ret['{$rpFieldName}']{$spacer}", 'this', $fieldName, false, "\t\t");
455469
}
456470
break;
457471
}
@@ -522,7 +536,7 @@ private function getOptionsCheck($table)
522536
$rpFieldName = $this->getRightString($fieldName);
523537
if (5 == $fieldElementId) {
524538
$arrayPush = $pc->getPhpCodeArrayType('ret', 'push', "'{$rpFieldName}'", null, false, "\t\t\t");
525-
$getOptions .= $pc->getPhpCodeConditions(1, ' == ', "\$this->getVar('{$fieldName}')", $arrayPush, false, "\t\t");
539+
$getOptions .= $pc->getPhpCodeConditions("\$this->getVar('{$fieldName}')", ' == ', '1', $arrayPush, false, "\t\t");
526540
}
527541
}
528542

class/Files/Classes/ClassFormElements.php

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -124,19 +124,25 @@ private function getXoopsFormDhtmlTextArea($language, $fieldName, $required = 'f
124124
$pc = Modulebuilder\Files\CreatePhpCode::getInstance();
125125
$xc = Modulebuilder\Files\CreateXoopsCode::getInstance();
126126
$cxc = Modulebuilder\Files\Classes\ClassXoopsCode::getInstance();
127-
$rpFieldName = $tf->getRightString($fieldName);
127+
//$rpFieldName = $tf->getRightString($fieldName);
128128
$ccFieldName = $tf->getCamelCase($fieldName, false, true);
129129
$ret = $pc->getPhpCodeCommentLine('Form Editor', 'DhtmlTextArea ' . $ccFieldName, "\t\t");
130130
$ret .= $pc->getPhpCodeArray('editorConfigs', null, false, "\t\t");
131-
$getConfig = $xc->getXcGetConfig('editor_default');
131+
$getConfig = $xc->getXcGetConfig('editor_admin');
132+
$contIf = $xc->getXcEqualsOperator("\$editor", $getConfig, null, "\t\t\t");
133+
$getConfig = $xc->getXcGetConfig('editor_user');
134+
$contElse = $xc->getXcEqualsOperator("\$editor", $getConfig, null, "\t\t\t");
135+
$ret .= $pc->getPhpCodeConditions('$isAdmin','','', $contIf, $contElse, "\t\t");
136+
137+
132138
$configs = [
133139
'name' => "'{$fieldName}'",
134140
'value' => "\$this->getVar('{$fieldName}', 'e')",
135141
'rows' => 5,
136142
'cols' => 40,
137143
'width' => "'100%'",
138144
'height' => "'400px'",
139-
'editor' => $getConfig,
145+
'editor' => '$editor',
140146
];
141147
foreach ($configs as $c => $d) {
142148
$ret .= $xc->getXcEqualsOperator("\$editorConfigs['{$c}']", $d, null, "\t\t");

class/Files/Classes/ClassSpecialFiles.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ public function getGlobalPerms($permId)
138138

139139
$contIfInt = $xc->getXcEqualsOperator('$my_group_ids', '[XOOPS_GROUP_ANONYMOUS]', null, "\t\t\t");
140140
$contElseInt = $xc->getXcEqualsOperator('$my_group_ids', '$memberHandler->getGroupsByUser($currentuid);', null, "\t\t\t");
141-
$globalContent .= $pc->getPhpCodeConditions('0', ' == ', '$currentuid', $contIfInt, $contElseInt, "\t\t");
141+
$globalContent .= $pc->getPhpCodeConditions('$currentuid', ' == ', '0', $contIfInt, $contElseInt, "\t\t");
142142
$globalContent .= $cond;
143143
$globalContent .= $this->getSimpleString("return false;", "\t\t");
144144
$functions .= $pc->getPhpCodeFunction($funcname, '', $globalContent, 'public ', false, "\t");

class/Files/CreateHtmlCode.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,8 @@ public function getHtmlEmpty($empty = '', $t = '', $n = '')
111111
/**
112112
* @public function getHtmlComment
113113
* @param string $htmlComment
114-
* @param string $n
114+
* @param string $t
115+
* @param string $n
115116
* @return string
116117
*/
117118
public function getHtmlComment($htmlComment = '', $t = '', $n = '')
@@ -203,6 +204,7 @@ public function getHtmlPre($content = '', $preClass = '', $t = '', $n = "\n")
203204
* @param string $spanClass
204205
* @param string $t
205206
* @param string $n
207+
* @param bool $split
206208
* @return string
207209
*/
208210
public function getHtmlSpan($content = '', $spanClass = '', $t = '', $n = "\n", $split = false)
@@ -243,6 +245,7 @@ public function getHtmlParagraph($content = '', $pClass = '', $t = '', $n = "\n"
243245
* @public function getHtmlI
244246
* @param string $content
245247
* @param string $iClass
248+
* @param string $iId
246249
* @param string $t
247250
* @param string $n
248251
* @return string

class/Files/CreatePhpCode.php

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,7 @@ public function getPhpCodeTernaryOperator($return, $condition, $one, $two, $t =
251251
* @param $extends
252252
* @param $type
253253
*
254+
* @param null $implements
254255
* @return string
255256
*/
256257
public function getPhpCodeClass($name = null, $content = null, $extends = null, $type = null, $implements = null)
@@ -337,12 +338,20 @@ public function getPhpCodeFunction($name = null, $params = null, $content = null
337338
*/
338339
public function getPhpCodeConditions($condition = null, $operator = null, $type = null, $contentIf = null, $contentElse = false, $t = '', $conditionElse = '')
339340
{
341+
if ('==' === trim($operator) || '===' === trim($operator) || '!=' === trim($operator) || '!==' === trim($operator)) {
342+
//yoda conditions
343+
$left = $type;
344+
$right = $condition;
345+
} else {
346+
$left = $condition;
347+
$right = $type;
348+
}
340349
if (false === $contentElse) {
341-
$ret = "{$t}if ({$condition}{$operator}{$type}) {\n";
350+
$ret = "{$t}if ({$left}{$operator}{$right}) {\n";
342351
$ret .= $contentIf;
343352
$ret .= "{$t}}\n";
344353
} else {
345-
$ret = "{$t}if ({$condition}{$operator}{$type}) {\n";
354+
$ret = "{$t}if ({$left}{$operator}{$right}) {\n";
346355
$ret .= $contentIf;
347356
if ('' !== $conditionElse) {
348357
$ret .= "{$t}} elseif ({$conditionElse}) {\n";

0 commit comments

Comments
 (0)