Skip to content

Commit 60b66c4

Browse files
committed
fixed bug with short text in block
1 parent a45a0a1 commit 60b66c4

2 files changed

Lines changed: 31 additions & 15 deletions

File tree

class/Files/Blocks/BlocksFiles.php

Lines changed: 30 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,10 @@
33
namespace XoopsModules\Modulebuilder\Files\Blocks;
44

55
use XoopsModules\Modulebuilder;
6-
use XoopsModules\Modulebuilder\Files;
7-
use XoopsModules\Modulebuilder\Constants;
6+
use XoopsModules\Modulebuilder\{
7+
Files,
8+
Constants
9+
};
810

911
/*
1012
You may not change or alter any portion of this comment or credits
@@ -96,22 +98,34 @@ private function getBlocksShow($moduleDirname, $tableName, $tableFieldname, $tab
9698
$ucfTableName = \ucfirst($tableName);
9799
$critName = 'cr' . $ucfTableName;
98100
$stuModuleDirname = \mb_strtoupper($moduleDirname);
101+
$ucfModuleDirname = \ucfirst($moduleDirname);
99102

100-
$ret = $this->pc->getPhpCodeCommentMultiLine(['Function' => 'show block', '@param $options' => '', '@return' => 'array']);
103+
$configMaxchar = 0;
104+
foreach (\array_keys($fields) as $f) {
105+
$fieldElement = $fields[$f]->getVar('field_element');
106+
if (Constants::FIELD_ELE_TEXTAREA == $fieldElement || Constants::FIELD_ELE_DHTMLTEXTAREA == $fieldElement) {
107+
$configMaxchar = 1;
108+
}
109+
}
101110

111+
$ret = $this->pc->getPhpCodeCommentMultiLine(['Function' => 'show block', '@param $options' => '', '@return' => 'array']);
112+
$func = $this->xc->getXcEqualsOperator('$helper ', 'Helper::getInstance()','',"\t");
113+
if (1 === $configMaxchar) {
114+
$func .= $this->xc->getXcEqualsOperator('$utility ', "new \XoopsModules\\{$ucfModuleDirname}\Utility()", '',"\t");
115+
$func .= $this->xc->getXcEqualsOperator('$editorMaxchar', $this->xc->getXcGetConfig('editor_maxchar'), false, "\t");
116+
}
102117
//$func .= $this->xc->getXcEqualsOperator('$myts', 'MyTextSanitizer::getInstance()', '',"\t");
103-
$func = $this->xc->getXcEqualsOperator('$block ', '[]', '',"\t");
104-
$func .= $this->xc->getXcEqualsOperator('$typeBlock ', '$options[0]','',"\t");
105-
$func .= $this->xc->getXcEqualsOperator('$limit ', '$options[1]','',"\t");
106-
$func .= $this->xc->getXcEqualsOperator('$lenghtTitle', '$options[2]','',"\t");
107-
$func .= $this->xc->getXcEqualsOperator('$helper ', 'Helper::getInstance()','',"\t");
108-
$func .= $this->xc->getXcHandlerLine($tableName, "\t");
109-
$func .= $this->xc->getXcCriteriaCompo($critName, "\t");
118+
$func .= $this->xc->getXcEqualsOperator('$block ', '[]', '',"\t");
119+
$func .= $this->xc->getXcEqualsOperator('$typeBlock ', '$options[0]','',"\t");
120+
$func .= $this->xc->getXcEqualsOperator('$limit ', '$options[1]','',"\t");
121+
$func .= $this->xc->getXcEqualsOperator('$lenghtTitle ', '$options[2]','',"\t");
110122
$func .= $this->pc->getPhpCodeArrayShift('$options', "\t");
111123
$func .= $this->pc->getPhpCodeArrayShift('$options', "\t");
112124
$func .= $this->pc->getPhpCodeArrayShift('$options', "\t");
113125
$func .= $this->pc->getPhpCodeBlankLine();
114-
126+
$func .= $this->xc->getXcHandlerLine($tableName, "\t");
127+
$func .= $this->pc->getPhpCodeBlankLine();
128+
$func .= $this->xc->getXcCriteriaCompo($critName, "\t");
115129
//content if: parent
116130
$contIf = $this->xc->getXcEqualsOperator("\${$tableName}", "{$moduleDirname}_getMyItemIds('{$moduleDirname}_view', '{$moduleDirname}')", null, "\t");
117131
$crit = $this->xc->getXcCriteria('', "'cid'", "'(' . \implode(',', \${$tableName}) . ')'", "'IN'", true);
@@ -230,12 +244,13 @@ private function getBlocksShow($moduleDirname, $tableName, $tableFieldname, $tab
230244
}
231245
if (1 == $fields[$f]->getVar('field_block')) {
232246
switch ($fieldElement) {
233-
case 2:
247+
case Constants::FIELD_ELE_TEXT:
234248
$contentForeach .= $this->xc->getXcEqualsOperator("\$block[\$i]['{$rpFieldName}']", "\htmlspecialchars(\${$tableName}All[\$i]->getVar('{$fieldName}'), ENT_QUOTES | ENT_HTML5)", null, "\t\t\t");
235249
break;
236-
case 3:
237-
case 4:
238-
$contentForeach .= $this->xc->getXcEqualsOperator("\$block[\$i]['{$rpFieldName}']", "\strip_tags(\${$tableName}All[\$i]->getVar('{$fieldName}'))", null, "\t\t\t");
250+
case Constants::FIELD_ELE_TEXTAREA:
251+
case Constants::FIELD_ELE_DHTMLTEXTAREA:
252+
$contentForeach .= $this->xc->getXcEqualsOperator("\$block[\$i]['{$rpFieldName}_text']", "\${$tableName}All[\$i]->getVar('{$fieldName}', 'e')", null, "\t\t\t");
253+
$contentForeach .= $this->xc->getXcEqualsOperator("\$block[\$i]['{$rpFieldName}_short']", "\$utility::truncateHtml(\${$tableName}All[\$i]->getVar('{$fieldName}', 'e'), \$editorMaxchar)", null, "\t\t\t");
239254
break;
240255
case 8:
241256
$contentForeach .= $this->xc->getXcEqualsOperator("\$block[\$i]['{$rpFieldName}']", "\XoopsUser::getUnameFromId(\${$tableName}All[\$i]->getVar('{$fieldName}'))", null, "\t\t\t");

docs/changelog.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
- fixed bug for truncated text (goffy)
1515
- added field prefix again (goffy)
1616
- fixed bug in block links (goffy)
17+
- fixed bug with short text in block (goffy)
1718

1819
<h5>3.7.0 Alpha [2023-07-06]</h5> Dev: XOOPS 2.5.11 RC2, PHP 8.0
1920
- implemented smarty 3 (zivXP/goffy)

0 commit comments

Comments
 (0)