Skip to content

Commit 297fba2

Browse files
committed
adapted editor handling
1 parent 1c38250 commit 297fba2

15 files changed

Lines changed: 146 additions & 51 deletions

File tree

class/Fields.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ private function getFormNewLine($form, $class, $i, $fieldMid, $fieldTid, $fName,
228228
$fieldAttributesSelect->addOptionArray($helper->getHandler('Fieldattributes')->getList());
229229
$form->addElement(new Tdmcreate\Html\FormLabel('<td class="center">' . $fieldAttributesSelect->render() . '</td>'));
230230
// Field Null
231-
$value = (1 == $i && 1 == $tableAutoincrement) ? '2' : '2';
231+
$value = (1 == $i) && (1 == $tableAutoincrement) ? '2' : '2';
232232
$fieldNullSelect = new \XoopsFormSelect(_AM_TDMCREATE_FIELD_NULL, 'field_null[' . $i . ']', $value);
233233
$fieldNullSelect->addOptionArray($helper->getHandler('Fieldnull')->getList());
234234
$form->addElement(new Tdmcreate\Html\FormLabel('<td class="center">' . $fieldNullSelect->render() . '</td>'));

class/Files/Classes/ClassFiles.php

Lines changed: 27 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,11 @@ private function getInitVars($fields)
134134
case 16:
135135
case 17:
136136
case 18:
137-
$ret .= $this->getInitVar($fieldName, 'TXTAREA');
137+
if ((int)$fields[$f]->getVar('field_element') == 4) {
138+
$ret .= $this->getInitVar($fieldName, 'OTHER');
139+
} else {
140+
$ret .= $this->getInitVar($fieldName, 'TXTAREA');
141+
}
138142
break;
139143
case 19:
140144
case 20:
@@ -380,17 +384,27 @@ private function getValuesInObject($moduleDirname, $table, $fields)
380384
$ucfTableName = ucfirst($table->getVar('table_name'));
381385
$ret = $pc->getPhpCodeCommentMultiLine(['Get' => 'Values', '@param null $keys' => '', '@param null $format' => '', '@param null$maxDepth' => '', '@return' => 'array'], "\t");
382386
$ucfModuleDirname = ucfirst($moduleDirname);
383-
$getValues = $xc->getXcGetInstance('helper', "\XoopsModules\\{$ucfModuleDirname}\Helper", "\t\t");
384-
$getValues .= $xc->getXcEqualsOperator('$ret', '$this->getValues($keys, $format, $maxDepth)', null, "\t\t");
387+
$getValues = $xc->getXcEqualsOperator('$ret', '$this->getValues($keys, $format, $maxDepth)', null, "\t\t");
385388
$fieldMainTopic = null;
389+
$helper = 0;
390+
$utility = 0;
391+
$header = '';
386392
foreach (array_keys($fields) as $f) {
387393
$fieldName = $fields[$f]->getVar('field_name');
388394
$fieldElement = $fields[$f]->getVar('field_element');
389395
$rpFieldName = $this->getRightString($fieldName);
390396
switch ($fieldElement) {
391397
case 3:
398+
$getValues .= $pc->getPhpCodeStripTags("ret['{$rpFieldName}']", "\$this->getVar('{$fieldName}', 'e')", false, "\t\t");
399+
$getValues .= $pc->getPhpCodeStripTags("ret['{$rpFieldName}_short']", "\$this->getVar('{$fieldName}', 'e')", false, "\t\t");
400+
$utility = 1;
401+
break;
392402
case 4:
393-
$getValues .= $pc->getPhpCodeStripTags("ret['{$rpFieldName}']", "\$this->getVar('{$fieldName}')", false, "\t\t");
403+
$getValues .= $xc->getXcGetVar("ret['{$rpFieldName}']", 'this', $fieldName, false, "\t\t", ", 'e'");
404+
$getValues .= $xc->getXcEqualsOperator('$editorMaxchar', $xc->getXcGetConfig('editor_maxchar'), false, "\t\t");
405+
$truncate = $ucfModuleDirname . "\Utility::truncateHtml(\$ret['{$rpFieldName}'], \$editorMaxchar)";
406+
$getValues .= $xc->getXcEqualsOperator("\$ret['{$rpFieldName}_short']", $truncate, false, "\t\t");
407+
$utility = 1;
394408
break;
395409
case 6:
396410
$getValues .= $xc->getXcEqualsOperator("\$ret['{$rpFieldName}']", "(int)\$this->getVar('{$fieldName}') > 0 ? _YES : _NO", false, "\t\t");
@@ -424,16 +438,23 @@ private function getValuesInObject($moduleDirname, $table, $fields)
424438
$getValues .= $xc->getXcEqualsOperator("\${$topicTableName}Obj", $getTopicTable, null, "\t\t");
425439
$fMainTopic = "\${$topicTableName}Obj->getVar('{$fieldMainTopic}')";
426440
$getValues .= $xc->getXcEqualsOperator("\$ret['{$rpFieldName}']", $fMainTopic, null, "\t\t");
427-
441+
$helper = 1;
428442
} else {
429443
$getValues .= $xc->getXcGetVar("ret['{$rpFieldName}']", 'this', $fieldName, false, "\t\t");
430444
}
431445
break;
432446
}
433447
}
448+
if ($helper > 0) {
449+
$header .= $xc->getXcGetInstance('helper', "\XoopsModules\\{$ucfModuleDirname}\Helper", "\t\t");
450+
}
451+
452+
if ($utility > 0) {
453+
$header .= $xc->getXcGetInstance('helper', "\XoopsModules\\{$ucfModuleDirname}\Helper", "\t\t");
454+
}
434455
$getValues .= $this->getSimpleString('return $ret;', "\t\t");
435456

436-
$ret .= $pc->getPhpCodeFunction('getValues' . $ucfTableName, '$keys = null, $format = null, $maxDepth = null', $getValues, 'public ', false, "\t");
457+
$ret .= $pc->getPhpCodeFunction('getValues' . $ucfTableName, '$keys = null, $format = null, $maxDepth = null', $header . $getValues, 'public ', false, "\t");
437458

438459
return $ret;
439460
}

class/Files/Classes/ClassXoopsCode.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,7 @@ public function getClassXoopsFormText($var, $param1, $param2, $param3, $param4,
287287
public function getClassXoopsFormTextArea($var, $param1, $param2, $param3, $param4, $isParam = false, $t = "\t\t")
288288
{
289289
$area = 'new \XoopsFormTextArea( ';
290-
$getVarTextArea = Tdmcreate\Files\CreateXoopsCode::getInstance()->getXcGetVar('', 'this', $param2, true);
290+
$getVarTextArea = Tdmcreate\Files\CreateXoopsCode::getInstance()->getXcGetVar('', 'this', $param2, true, '', ", 'e'");
291291
if (false === $isParam) {
292292
$ret = "{$t}\${$var} = {$area}{$param1}, '{$param2}', {$getVarTextArea}, {$param3}, {$param4} );\n";
293293
} else {

class/Files/CreateXoopsCode.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -119,12 +119,12 @@ public function getXcSetVarObj($tableName, $fieldName, $var, $t = '')
119119
*
120120
* @return string
121121
*/
122-
public function getXcGetVar($varLeft = '', $handle = '', $var = '', $isParam = false, $t = '')
122+
public function getXcGetVar($varLeft = '', $handle = '', $var = '', $isParam = false, $t = '', $format = '')
123123
{
124124
if (!$isParam) {
125-
$ret = "{$t}\${$varLeft} = \${$handle}->getVar('{$var}');\n";
125+
$ret = "{$t}\${$varLeft} = \${$handle}->getVar('{$var}'{$format});\n";
126126
} else {
127-
$ret = "\${$handle}->getVar('{$var}')";
127+
$ret = "\${$handle}->getVar('{$var}'{$format})";
128128
}
129129

130130
return $ret;
@@ -1192,7 +1192,7 @@ public function getXcSaveElements($moduleDirname, $tableName, $tableSoleName, $f
11921192
$ret .= $this->getXcSetVarDateTime($tableName, $tableSoleName, $fieldName, $t);
11931193
break;
11941194
default:
1195-
$ret .= $axc->getAxcSetVarMisc($tableName, $fieldName, $fieldType, $t);
1195+
$ret .= $axc->getAxcSetVarMisc($tableName, $fieldName, $fieldType, $fieldElement, $t);
11961196
break;
11971197
}
11981198
}

class/Files/Language/LanguageModinfo.php

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -250,23 +250,30 @@ private function getLanguageUser($language)
250250
*/
251251
private function getLanguageConfig($language, $tables)
252252
{
253-
$df = LanguageDefines::getInstance();
254-
$ret = $df->getAboveDefines('Config');
255-
$fieldImage = false;
256-
$fieldFile = false;
257-
$useTag = false;
253+
$df = LanguageDefines::getInstance();
254+
$ret = $df->getAboveDefines('Config');
255+
$fieldImage = false;
256+
$fieldFile = false;
257+
$useTag = false;
258+
$fieldEditor = false;
258259
// $usePermissions = false;
259260
foreach (array_keys($tables) as $i) {
260261
$fields = $this->getTableFields($tables[$i]->getVar('table_mid'), $tables[$i]->getVar('table_id'));
262+
$ucfTablename = ucfirst($tables[$i]->getVar('table_name'));
263+
$stuTablename = mb_strtoupper($ucfTablename);
261264
foreach (array_keys($fields) as $f) {
262265
$fieldElement = $fields[$f]->getVar('field_element');
266+
if (3 == $fieldElement) {
267+
$fieldEditor = true;
268+
}
263269
if (4 == $fieldElement) {
264270
$fieldName = $fields[$f]->getVar('field_name');
265271
$rpFieldName = $this->getRightString($fieldName);
266272
$ucfFieldName = ucfirst($rpFieldName);
267273
$stuFieldName = mb_strtoupper($rpFieldName);
268-
$ret .= $df->getDefine($language, 'EDITOR_' . $stuFieldName, 'Editor');
269-
$ret .= $df->getDefine($language, 'EDITOR_' . $stuFieldName . '_DESC', 'Select the Editor ' . $ucfFieldName . ' to use');
274+
$ret .= $df->getDefine($language, 'EDITOR_' . $stuTablename . '_' . $stuFieldName, 'Editor');
275+
$ret .= $df->getDefine($language, 'EDITOR_' . $stuTablename . '_' . $stuFieldName . '_DESC', 'Select the editor to use for ' . $ucfTablename . '/'. $ucfFieldName);
276+
$fieldEditor = true;
270277
}
271278
if (13 == $fieldElement) {
272279
$fieldImage = true;
@@ -280,6 +287,10 @@ private function getLanguageConfig($language, $tables)
280287
}
281288
// if (0 != $tables[$i]->getVar('table_permissions')) {$usePermissions = true;}
282289
}
290+
if ($fieldEditor) {
291+
$ret .= $df->getDefine($language, 'EDITOR_MAXCHAR', 'Text max characters');
292+
$ret .= $df->getDefine($language, 'EDITOR_MAXCHAR_DESC', 'Max characters for showing text of a textarea or editor field in admin area');
293+
}
283294
$ret .= $df->getDefine($language, 'KEYWORDS', 'Keywords');
284295
$ret .= $df->getDefine($language, 'KEYWORDS_DESC', 'Insert here the keywords (separate by comma)');
285296
/*if (usePermissions) {

class/Files/Templates/Admin/TemplatesAdminPages.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,11 @@ private function getTemplatesAdminPagesTableTBody($moduleDirname, $tableName, $t
148148
}
149149
if (1 == $fields[$f]->getVar('field_inlist')) {
150150
switch ($fieldElement) {
151+
case 3:
152+
case 4:
153+
$double = $sc->getSmartyDoubleVar($tableSoleName, $rpFieldName . '_short');
154+
$td .= $hc->getHtmlTableData($double, 'center', '',"\t\t\t\t");
155+
break;
151156
case 5:
152157
$double = $sc->getSmartyDoubleVar($tableSoleName, $rpFieldName);
153158
$src = $sc->getSmartyNoSimbol('xoModuleIcons16') . $double . '.png';

class/Files/Templates/user/Index.php

Lines changed: 57 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ public function getTemplateUserIndexHeader($moduleDirname)
7979
{
8080
$sc = Tdmcreate\Files\CreateSmartyCode::getInstance();
8181

82-
return $sc->getSmartyIncludeFile($moduleDirname, 'header') . PHP_EOL;
82+
return $sc->getSmartyIncludeFile($moduleDirname, 'header', false, false, '', "\n");
8383
}
8484

8585
/**
@@ -98,7 +98,7 @@ private function getTemplatesUserIndexTable($moduleDirname, $tableName, $tableSo
9898
$table = $this->getTemplatesUserIndexTableThead($tableName, $language);
9999
$table .= $this->getTemplatesUserIndexTableTBody($moduleDirname, $tableName, $tableSoleName);
100100

101-
return $hc->getHtmlTable($table, 'table table-' . $single) . PHP_EOL;
101+
return $hc->getHtmlTable($table, 'table table-' . $single);
102102
}
103103

104104
/**
@@ -114,10 +114,10 @@ private function getTemplatesUserIndexTableThead($tableName, $language)
114114
$stuTableName = mb_strtoupper($tableName);
115115
$lang = $sc->getSmartyConst($language, $stuTableName);
116116
$col = $sc->getSmartySingleVar('numb_col');
117-
$th = $hc->getHtmlTableHead($lang, '', $col) . PHP_EOL;
118-
$tr = $hc->getHtmlTableRow($th, 'head') . PHP_EOL;
117+
$th = $hc->getHtmlTableHead($lang, '', $col);
118+
$tr = $hc->getHtmlTableRow($th, 'head') ;
119119

120-
return $hc->getHtmlTableThead($tr) . PHP_EOL;
120+
return $hc->getHtmlTableThead($tr);
121121
}
122122

123123
/**
@@ -134,13 +134,13 @@ private function getTemplatesUserIndexTableTBody($moduleDirname, $tableName, $ta
134134
$type = $sc->getSmartySingleVar('panel_type');
135135
$include = $sc->getSmartyIncludeFileListForeach($moduleDirname, $tableName, $tableSoleName);
136136
$div = $hc->getHtmlDiv($include, 'panel panel-' . $type);
137-
$cont = $hc->getHtmlTableData($div) . PHP_EOL;
138-
$html = $hc->getHtmlEmpty('</tr><tr>') . PHP_EOL;
139-
$cont .= $sc->getSmartyConditions($tableSoleName . '.count', ' is div by ', '$divideby', $html) . PHP_EOL;
140-
$foreach = $sc->getSmartyForeach($tableSoleName, $tableName, $cont) . PHP_EOL;
141-
$tr = $hc->getHtmlTableRow($foreach) . PHP_EOL;
137+
$cont = $hc->getHtmlTableData($div);
138+
$html = $hc->getHtmlEmpty('</tr><tr>');
139+
$cont .= $sc->getSmartyConditions($tableSoleName . '.count', ' is div by ', '$divideby', $html);
140+
$foreach = $sc->getSmartyForeach($tableSoleName, $tableName, $cont);
141+
$tr = $hc->getHtmlTableRow($foreach);
142142

143-
return $hc->getHtmlTableTbody($tr) . PHP_EOL;
143+
return $hc->getHtmlTableTbody($tr);
144144
}
145145

146146
/**
@@ -150,10 +150,10 @@ private function getTemplatesUserIndexTableTBody($moduleDirname, $tableName, $ta
150150
private function getTemplatesUserIndexTableTfoot()
151151
{
152152
$hc = Tdmcreate\Files\CreateHtmlCode::getInstance();
153-
$td = $hc->getHtmlTableData('&nbsp;') . PHP_EOL;
154-
$tr = $hc->getHtmlTableRow($td) . PHP_EOL;
153+
$td = $hc->getHtmlTableData('&nbsp;');
154+
$tr = $hc->getHtmlTableRow($td);
155155

156-
return $hc->getHtmlTableTfoot($tr) . PHP_EOL;
156+
return $hc->getHtmlTableTfoot($tr);
157157
}
158158

159159
/**
@@ -165,9 +165,50 @@ private function getTemplatesUserIndexTableTfoot()
165165
*/
166166
public function getTemplatesUserIndexBodyDefault($module, $table, $language)
167167
{
168+
$hc = Tdmcreate\Files\CreateHtmlCode::getInstance();
169+
$sc = Tdmcreate\Files\CreateSmartyCode::getInstance();
168170
$moduleDirname = $module->getVar('mod_dirname');
169171
$tableName = $table->getVar('table_name');
170-
$ret = <<<EOT
172+
$th = $hc->getHtmlTableHead("<{\$smarty.const.{$language}TITLE}> - <{\$smarty.const.{$language}DESC}>", '', '',"\t\t\t");
173+
$tr = $hc->getHtmlTableRow($th,'center',"\t\t");
174+
$thead = $hc->getHtmlTableThead($tr,'', "\t");
175+
$contTable = $thead;
176+
$li = $hc->getHtmlLi("<a href=\"<{\${$moduleDirname}_url}>\"><{\$smarty.const.{$language}INDEX}></a>",'',"\t\t\t\t\t\t");
177+
$tables = $this->getTableTables($module->getVar('mod_id'), 'table_order');
178+
foreach (array_keys($tables) as $i) {
179+
$tableNameLi = $tables[$i]->getVar('table_name');
180+
$stuTableNameLi = mb_strtoupper($tableName);
181+
$li .= $hc->getHtmlLi("<a href=\"<{\${$moduleDirname}_url}>/{$tableNameLi}.php\"><{\$smarty.const.{$language}{$stuTableNameLi}}></a>",'',"\t\t\t\t\t\t");
182+
}
183+
184+
$ul = $hc->getHtmlUl($li,'menu text-center',"\t\t\t\t\t");
185+
$td = $hc->getHtmlTableData($ul, 'bold pad5','',"\t\t\t\t", "\n", true);
186+
$tr = $hc->getHtmlTablerow($td, 'center',"\t\t\t");
187+
188+
$tbody = $hc->getHtmlTableTbody($tr,'', "\t\t");
189+
$contTable .= $tbody;
190+
191+
$tfoot = <<<EOT
192+
193+
<tfoot>
194+
<{if \$adv != ''}>
195+
<tr class="center"><td class="center bold pad5"><{\$adv}></td></tr>
196+
<{else}>
197+
<tr class="center"><td class="center bold pad5">&nbsp;</td></tr>
198+
<{/if}>
199+
</tfoot>
200+
EOT;
201+
202+
203+
$contTable .= $tfoot;
204+
$contIf = $hc->getHtmlTable($contTable);
205+
$ret = $sc->getSmartyConditions("{$tableName}Count", ' > ', '0', $contIf, false, '','',"\t");
206+
207+
208+
$ret .= '';
209+
$ret .= '*********************************************************';
210+
211+
$ret .= <<<EOT
171212
<{if \${$tableName}Count == 0}>
172213
<table class="table table-<{\$table_type}>">
173214
<thead>
@@ -332,6 +373,7 @@ public function render()
332373
if (in_array(1, $tableCategory, true) && in_array(1, $tableIndex)) {
333374
$content .= $this->getTemplateUserIndexCategories($moduleDirname, $tableName, $tableSoleName, $language);
334375
}
376+
335377
if (in_array(0, $tableCategory, true) && in_array(1, $tableIndex)) {
336378
$content .= $this->getTemplateUserIndexTable($moduleDirname, $tableName, $tableSoleName, $language);
337379
}

class/Files/User/UserXoopsVersion.php

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -497,6 +497,7 @@ private function getXoopsVersionConfig($module, $tables, $language)
497497
$moduleDirname = $module->getVar('mod_dirname');
498498
$ret = $this->getDashComment('Config');
499499

500+
$table_editors = 0;
500501
$table_permissions = 0;
501502
$table_admin = 0;
502503
$table_user = 0;
@@ -505,10 +506,13 @@ private function getXoopsVersionConfig($module, $tables, $language)
505506
$table_uploadfile = 0;
506507
foreach ($tables as $table) {
507508
$fields = $this->getTableFields($table->getVar('table_mid'), $table->getVar('table_id'));
509+
$stuTablename = mb_strtoupper($table->getVar('table_name'));
508510
foreach (array_keys($fields) as $f) {
509511
$fieldElement = (int)$fields[$f]->getVar('field_element');
510512
switch ($fieldElement) {
511513
case 3:
514+
$table_editors = 1;
515+
break;
512516
case 4:
513517
$fieldName = $fields[$f]->getVar('field_name');
514518
$rpFieldName = $this->getRightString($fieldName);
@@ -519,14 +523,15 @@ private function getXoopsVersionConfig($module, $tables, $language)
519523
$ret .= $xc->getXcEqualsOperator('$editorHandler' . $ucfFieldName, 'XoopsEditorHandler::getInstance()');
520524
$editor = [
521525
'name' => "'editor_{$rpFieldName}'",
522-
'title' => "'{$language}EDITOR_{$stuFieldName}'",
523-
'description' => "'{$language}EDITOR_{$stuFieldName}_DESC'",
526+
'title' => "'{$language}EDITOR_{$stuTablename}_{$stuFieldName}'",
527+
'description' => "'{$language}EDITOR_{$stuTablename}_{$stuFieldName}_DESC'",
524528
'formtype' => "'select'",
525529
'valuetype' => "'text'",
526530
'default' => "'dhtml'",
527531
'options' => 'array_flip($editorHandler' . $ucfFieldName . '->getList())',
528532
];
529533
$ret .= $uxc->getUserModVersionArray(2, $editor, 'config');
534+
$table_editors = 1;
530535
break;
531536
case 10:
532537
case 11:
@@ -555,7 +560,18 @@ private function getXoopsVersionConfig($module, $tables, $language)
555560
$table_tag = 1;
556561
}
557562
}
558-
563+
if (1 === $table_editors) {
564+
$ret .= $pc->getPhpCodeCommentLine('Editor : max characters admin area');
565+
$maxsize_image = [
566+
'name' => "'editor_maxchar'",
567+
'title' => "'{$language}EDITOR_MAXCHAR'",
568+
'description' => "'{$language}EDITOR_MAXCHAR_DESC'",
569+
'formtype' => "'textbox'",
570+
'valuetype' => "'int'",
571+
'default' => '50',
572+
];
573+
$ret .= $uxc->getUserModVersionArray(2, $maxsize_image, 'config');
574+
}
559575
if (1 === $table_permissions) {
560576
$ret .= $pc->getPhpCodeCommentLine('Get groups');
561577
$ret .= $xc->getXcXoopsHandler('member');

0 commit comments

Comments
 (0)