|
3 | 3 | namespace XoopsModules\Modulebuilder\Files\Blocks; |
4 | 4 |
|
5 | 5 | use XoopsModules\Modulebuilder; |
6 | | -use XoopsModules\Modulebuilder\Files; |
7 | | -use XoopsModules\Modulebuilder\Constants; |
| 6 | +use XoopsModules\Modulebuilder\{ |
| 7 | + Files, |
| 8 | + Constants |
| 9 | +}; |
8 | 10 |
|
9 | 11 | /* |
10 | 12 | You may not change or alter any portion of this comment or credits |
@@ -96,22 +98,34 @@ private function getBlocksShow($moduleDirname, $tableName, $tableFieldname, $tab |
96 | 98 | $ucfTableName = \ucfirst($tableName); |
97 | 99 | $critName = 'cr' . $ucfTableName; |
98 | 100 | $stuModuleDirname = \mb_strtoupper($moduleDirname); |
| 101 | + $ucfModuleDirname = \ucfirst($moduleDirname); |
99 | 102 |
|
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 | + } |
101 | 110 |
|
| 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 | + } |
102 | 117 | //$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"); |
110 | 122 | $func .= $this->pc->getPhpCodeArrayShift('$options', "\t"); |
111 | 123 | $func .= $this->pc->getPhpCodeArrayShift('$options', "\t"); |
112 | 124 | $func .= $this->pc->getPhpCodeArrayShift('$options', "\t"); |
113 | 125 | $func .= $this->pc->getPhpCodeBlankLine(); |
114 | | - |
| 126 | + $func .= $this->xc->getXcHandlerLine($tableName, "\t"); |
| 127 | + $func .= $this->pc->getPhpCodeBlankLine(); |
| 128 | + $func .= $this->xc->getXcCriteriaCompo($critName, "\t"); |
115 | 129 | //content if: parent |
116 | 130 | $contIf = $this->xc->getXcEqualsOperator("\${$tableName}", "{$moduleDirname}_getMyItemIds('{$moduleDirname}_view', '{$moduleDirname}')", null, "\t"); |
117 | 131 | $crit = $this->xc->getXcCriteria('', "'cid'", "'(' . \implode(',', \${$tableName}) . ')'", "'IN'", true); |
@@ -230,12 +244,13 @@ private function getBlocksShow($moduleDirname, $tableName, $tableFieldname, $tab |
230 | 244 | } |
231 | 245 | if (1 == $fields[$f]->getVar('field_block')) { |
232 | 246 | switch ($fieldElement) { |
233 | | - case 2: |
| 247 | + case Constants::FIELD_ELE_TEXT: |
234 | 248 | $contentForeach .= $this->xc->getXcEqualsOperator("\$block[\$i]['{$rpFieldName}']", "\htmlspecialchars(\${$tableName}All[\$i]->getVar('{$fieldName}'), ENT_QUOTES | ENT_HTML5)", null, "\t\t\t"); |
235 | 249 | 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"); |
239 | 254 | break; |
240 | 255 | case 8: |
241 | 256 | $contentForeach .= $this->xc->getXcEqualsOperator("\$block[\$i]['{$rpFieldName}']", "\XoopsUser::getUnameFromId(\${$tableName}All[\$i]->getVar('{$fieldName}'))", null, "\t\t\t"); |
|
0 commit comments