Skip to content

Commit dd57785

Browse files
committed
- added new field elements SelectStatus, SelectCombo, Password, SelectCountry and SelectLang
- rebuilt include/search.inc.php - fixed various bugs -code cleaning
1 parent 58df387 commit dd57785

221 files changed

Lines changed: 12594 additions & 744 deletions

File tree

Some content is hidden

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

class/FieldElements.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ public function __construct()
4141
$this->initVar('fieldelement_tid', XOBJ_DTYPE_INT);
4242
$this->initVar('fieldelement_name', XOBJ_DTYPE_TXTBOX);
4343
$this->initVar('fieldelement_value', XOBJ_DTYPE_TXTBOX);
44+
$this->initVar('fieldelement_sort', XOBJ_DTYPE_INT);
4445
}
4546

4647
/**
@@ -87,6 +88,7 @@ public function getValuesFieldElements($keys = null, $format = null, $maxDepth =
8788
$ret['tid'] = $this->getVar('fieldelement_tid');
8889
$ret['name'] = $this->getVar('fieldelement_name');
8990
$ret['value'] = $this->getVar('fieldelement_value');
91+
$ret['sort'] = $this->getVar('fieldelement_sort');
9092

9193
return $ret;
9294
}

class/FieldElementsHandler.php

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,4 +125,28 @@ private function getFieldElementsCriteria($crFieldElemsCriteria, $start, $limit,
125125

126126
return $crFieldElemsCriteria;
127127
}
128+
129+
/**
130+
* Get FieldElements Criteria.
131+
* @param $crFieldElemsCriteria
132+
* @param $start
133+
* @param $limit
134+
* @param $sort
135+
* @param $order
136+
* @return mixed
137+
*/
138+
public function getFieldElementsList($crFieldElemsCriteria, $start = 0, $limit = 0, $sort = 'fieldelement_sort', $order = 'ASC')
139+
{
140+
$crFieldElems = $this->getFieldElementsCriteria($crFieldElemsCriteria, $start, $limit, $sort, $order);
141+
$fieldeleArr = $this->getAll($crFieldElems);
142+
foreach (array_keys($fieldeleArr) as $i) {
143+
$stuFeName = mb_strtoupper($fieldeleArr[$i]->getVar('fieldelement_name'));
144+
if (1 == $i) {
145+
$fieldele[$i] = '...';
146+
} else {
147+
$fieldele[$i] = constant ('_AM_TDMCREATE_FIELD_ELE_' . $stuFeName);
148+
}
149+
}
150+
return $fieldele;
151+
}
128152
}

class/Fields.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ private function getFormNewLine($form, $class, $i, $fieldMid, $fieldTid, $fName,
228228
$crTable = new \CriteriaCompo();
229229
$crTable->add(new \Criteria('fieldelement_mid', $fieldMid));
230230
$fieldElementsSelect = new \XoopsFormSelect(_AM_TDMCREATE_FIELD_ELEMENT_NAME, 'field_element[' . $i . ']');
231-
$fieldElementsSelect->addOptionArray($helper->getHandler('Fieldelements')->getList($crElement));
231+
$fieldElementsSelect->addOptionArray($helper->getHandler('Fieldelements')->getFieldElementsList($crElement));
232232
$fieldElementsSelect->addOptionArray($helper->getHandler('Fieldelements')->getList($crTable));
233233
unset($crElement, $crTable);
234234
$parametersTray->addElement($fieldElementsSelect);
@@ -378,7 +378,8 @@ public function getFormEdit($fieldMid = null, $fieldTid = null, $action = false)
378378
$crTable = new \CriteriaCompo();
379379
$crTable->add(new \Criteria('fieldelement_mid', $fieldMid));
380380
$fieldElementsSelect = new \XoopsFormSelect(_AM_TDMCREATE_FIELD_ELEMENT_NAME, 'field_element[' . $id . ']', $field->getVar('field_element'));
381-
$fieldElementsSelect->addOptionArray($helper->getHandler('Fieldelements')->getList($crElement));
381+
//$fieldElementsSelect->addOptionArray($helper->getHandler('Fieldelements')->getList($crElement));
382+
$fieldElementsSelect->addOptionArray($helper->getHandler('Fieldelements')->getFieldElementsList($crElement));
382383
$fieldElementsSelect->addOptionArray($helper->getHandler('Fieldelements')->getList($crTable));
383384
unset($crElement, $crTable);
384385
$parametersTray->addElement($fieldElementsSelect);

class/Files/Admin/AdminHeader.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -114,13 +114,13 @@ private function getAdminHeader($moduleDirname)
114114
if (is_array($tables)) {
115115
foreach (array_keys($tables) as $i) {
116116
$tableName = $tables[$i]->getVar('table_name');
117-
$ret .= $this->xc->getXcEqualsOperator("\${$tableName}Handler", "\$helper->getHandler('{$tableName}')", null, true);
117+
$ret .= $this->xc->getXcHandlerLine($tableName);
118118
}
119119
}
120-
$ret .= $this->xc->getXcEqualsOperator('$myts', 'MyTextSanitizer::getInstance()', null, false);
120+
$ret .= $this->xc->getXcEqualsOperator('$myts', 'MyTextSanitizer::getInstance()');
121121
$ret .= $this->pc->getPhpCodeCommentLine();
122122
$template = $this->pc->getPhpCodeIncludeDir('XOOPS_ROOT_PATH', 'class/template', true, false, 'include', "\t");
123-
$template .= $this->xc->getXcEqualsOperator('$xoopsTpl', 'new \XoopsTpl()', null, false, "\t");
123+
$template .= $this->xc->getXcEqualsOperator('$xoopsTpl', 'new \XoopsTpl()', null,"\t");
124124
$ret .= $this->pc->getPhpCodeConditions('!isset($xoopsTpl)', ' || ', '!is_object($xoopsTpl)', $template, false);
125125
$ret .= $this->pc->getPhpCodeBlankLine();
126126
$ret .= $this->pc->getPhpCodeCommentLine('Load languages');

class/Files/Admin/AdminIndex.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ private function getAdminIndex($module)
121121
$ret .= $pc->getPhpCodeCommentLine('Upload Folders');
122122
$ret .= $xc->getXcEqualsOperator('$configurator', 'new Common\Configurator()');
123123
$cond = '$configurator->uploadFolders && is_array($configurator->uploadFolders)';
124-
$fe_action = $xc->getXcEqualsOperator('$folder[]', '$configurator->uploadFolders[$i]', '','', "\t\t");
124+
$fe_action = $xc->getXcEqualsOperator('$folder[]', '$configurator->uploadFolders[$i]', '',"\t\t");
125125
$condIf = $pc->getPhpCodeForeach('configurator->uploadFolders', true, false, 'i', $fe_action, "\t");
126126
$ret .= $pc->getPhpCodeConditions($cond, '', '', $condIf, false);
127127

class/Files/Admin/AdminMenu.php

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ public function write($module, $filename)
7474
*
7575
* @return string
7676
*/
77-
private function getAdminMenuArray($param = [], $adminObject = false, $ref = false)
77+
private function getAdminMenuArray($param = [], $adminObject = false)
7878
{
7979
$xc = Tdmcreate\Files\CreateXoopsCode::getInstance();
8080
$ret = '';
@@ -86,11 +86,7 @@ private function getAdminMenuArray($param = [], $adminObject = false, $ref = fal
8686
$ret .= $this->getSimpleString("];");
8787
} else {
8888
foreach ($param as $key => $value) {
89-
if ($ref) {
90-
$ret .= $xc->getXcEqualsOperator((string)$key, (string)$value, null, true);
91-
} else {
92-
$ret .= $xc->getXcEqualsOperator((string)$key, (string)$value);
93-
}
89+
$ret .= $xc->getXcEqualsOperator((string)$key, (string)$value);
9490
}
9591
}
9692

class/Files/Admin/AdminPermissions.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ private function getPermissionsBody($module, $language)
194194
$foreach1 = $xc->getXcAddItem('permform', '$gPermId', '$gPermName', "\t\t");
195195
$if1 = $pc->getPhpCodeForeach('globalPerms', false, 'gPermId', 'gPermName', $foreach1, "\t");
196196
$if1 .= $xc->getXcXoopsTplAssign('form', '$permform->render()', true, "\t");
197-
$if1 .= $xc->getXcEqualsOperator('$permFound', 'true', null, false, "\t");
197+
$if1 .= $xc->getXcEqualsOperator('$permFound', 'true', null, "\t");
198198
$ret .= $pc->getPhpCodeConditions('$op', ' === ', "'global'", $if1, false);
199199

200200
foreach (array_keys($tables) as $t) {
@@ -222,7 +222,7 @@ private function getPermissionsBody($module, $language)
222222
$if_count .= $pc->getPhpCodeForeach("{$tableName}All", true, false, 'i', $fe_content, "\t\t");
223223
$if_count .= $xc->getXcXoopsTplAssign('form', '$permform->render()', true, "\t\t");
224224
$if_table .= $pc->getPhpCodeConditions("\${$tableName}Count", ' > ', '0', $if_count, false, "\t");
225-
$if_table .= $xc->getXcEqualsOperator('$permFound', 'true', null, false, "\t");
225+
$if_table .= $xc->getXcEqualsOperator('$permFound', 'true', null, "\t");
226226
$cond = "\$op === 'approve_{$tableName}' || \$op === 'submit_{$tableName}' || \$op === 'view_{$tableName}'";
227227
$ret .= $pc->getPhpCodeConditions($cond, '', '', $if_table, false);
228228
}

class/Files/Blocks/BlocksFiles.php

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -87,25 +87,25 @@ private function getBlocksShow($moduleDirname, $tableName, $tableFieldname, $fie
8787
$ucfTableName = ucfirst($tableName);
8888
$critName = 'cr' . $ucfTableName;
8989

90-
$ret = $pc->getPhpCodeCommentMultiLine(['Function' => 'show block', '@param $options' => '', '@return' => 'form']);
90+
$ret = $pc->getPhpCodeCommentMultiLine(['Function' => 'show block', '@param $options' => '', '@return' => 'array']);
9191

9292
$func = $pc->getPhpCodeIncludeDir("XOOPS_ROOT_PATH . '/modules/{$moduleDirname}/class/{$tableName}.php'",'',true, true, '', "\t");
9393
$func .= $xc->getXcEqualsOperator('$myts', 'MyTextSanitizer::getInstance()', '','', "\t");
9494
$func .= $xc->getXcXoopsTplAssign("{$moduleDirname}_upload_url","{$stuModuleDirname}_UPLOAD_URL",'',"\t");
95-
$func .= $xc->getXcEqualsOperator('$block ', '[]', '','', "\t");
96-
$func .= $xc->getXcEqualsOperator('$typeBlock ', '$options[0]','','', "\t");
97-
$func .= $xc->getXcEqualsOperator('$limit ', '$options[1]','','', "\t");
98-
$func .= $xc->getXcEqualsOperator('$lenghtTitle', '$options[2]','','', "\t");
99-
$func .= $xc->getXcEqualsOperator('$helper ', 'Helper::getInstance()','','', "\t");
100-
$func .= $xc->getXcEqualsOperator("\${$tableName}Handler", "\$helper->getHandler('{$tableName}')", null, true, "\t");
95+
$func .= $xc->getXcEqualsOperator('$block ', '[]', '',"\t");
96+
$func .= $xc->getXcEqualsOperator('$typeBlock ', '$options[0]','',"\t");
97+
$func .= $xc->getXcEqualsOperator('$limit ', '$options[1]','',"\t");
98+
$func .= $xc->getXcEqualsOperator('$lenghtTitle', '$options[2]','',"\t");
99+
$func .= $xc->getXcEqualsOperator('$helper ', 'Helper::getInstance()','',"\t");
100+
$func .= $xc->getXcHandlerLine($tableName, "\t");
101101
$func .= $xc->getXcCriteriaCompo($critName, "\t");
102102
$func .= $pc->getPhpCodeArrayShift('$options', "\t");
103103
$func .= $pc->getPhpCodeArrayShift('$options', "\t");
104104
$func .= $pc->getPhpCodeArrayShift('$options', "\t");
105105
$func .= $pc->getPhpCodeBlankLine();
106106

107107
//content if: parent
108-
$contIf = $xc->getXcEqualsOperator("\${$tableName}", "{$moduleDirname}_getMyItemIds('{$moduleDirname}_view', '{$moduleDirname}')", null, false, "\t");
108+
$contIf = $xc->getXcEqualsOperator("\${$tableName}", "{$moduleDirname}_getMyItemIds('{$moduleDirname}_view', '{$moduleDirname}')", null, "\t");
109109
$crit = $xc->getXcCriteria('', "'cid'", "'(' . implode(',', \${$tableName}) . ')'", "'IN'", true);
110110
$contIf .= $xc->getXcCriteriaAdd($critName, $crit, "\t");
111111
$crit = $xc->getXcCriteria('', "'{$fieldId}'", "{$moduleDirname}_block_addCatSelect(\$options)", "'IN'", true);
@@ -135,17 +135,17 @@ private function getBlocksShow($moduleDirname, $tableName, $tableFieldname, $fie
135135
if ('' !== $fieldStatus) {
136136
$case1[] = $critStatus;
137137
}
138-
$case1[] = $xc->getXcCriteriaSetSort($critName, "'{$tableFieldname}_created'","\t\t\t");
138+
$case1[] = $xc->getXcCriteriaSetSort($critName, "'{$tableFieldname}_date'","\t\t\t");
139139
$case1[] = $xc->getXcCriteriaSetOrder($critName, "'DESC'","\t\t\t");
140140
$case2[] = $pc->getPhpCodeCommentLine("For the block: {$tableName} new",'',"\t\t\t");
141141
if ('' !== $fieldStatus) {
142142
$case2[] = $critStatus;
143143
}
144-
$crit = $xc->getXcCriteria('', "'{$tableFieldname}_created'", 'strtotime(date(_SHORTDATESTRING))', "'>='", true);
144+
$crit = $xc->getXcCriteria('', "'{$tableFieldname}_date'", 'strtotime(date(_SHORTDATESTRING))', "'>='", true);
145145
$case2[] = $xc->getXcCriteriaAdd($critName, $crit,"\t\t\t");
146-
$crit = $xc->getXcCriteria('', "'{$tableFieldname}_created'", 'strtotime(date(_SHORTDATESTRING))+86400', "'<='", true);
146+
$crit = $xc->getXcCriteria('', "'{$tableFieldname}_date'", 'strtotime(date(_SHORTDATESTRING))+86400', "'<='", true);
147147
$case2[] = $xc->getXcCriteriaAdd($critName, $crit,"\t\t\t");
148-
$case2[] = $xc->getXcCriteriaSetSort($critName, "'{$tableFieldname}_created'","\t\t\t");
148+
$case2[] = $xc->getXcCriteriaSetSort($critName, "'{$tableFieldname}_date'","\t\t\t");
149149
$case2[] = $xc->getXcCriteriaSetOrder($critName, "'ASC'","\t\t\t");
150150
$case3[] = $pc->getPhpCodeCommentLine("For the block: {$tableName} hits",'',"\t\t\t");
151151
if ('' !== $fieldStatus) {
@@ -196,20 +196,20 @@ private function getBlocksShow($moduleDirname, $tableName, $tableFieldname, $fie
196196
if (1 == $fields[$f]->getVar('field_block')) {
197197
switch ($fieldElement) {
198198
case 2:
199-
$contentForeach .= $xc->getXcEqualsOperator("\$block[\$i]['{$rpFieldName}']", "\$myts->htmlSpecialChars(\${$tableName}All[\$i]->getVar('{$fieldName}'))", null, false, "\t\t\t");
199+
$contentForeach .= $xc->getXcEqualsOperator("\$block[\$i]['{$rpFieldName}']", "\$myts->htmlSpecialChars(\${$tableName}All[\$i]->getVar('{$fieldName}'))", null, "\t\t\t");
200200
break;
201201
case 3:
202202
case 4:
203-
$contentForeach .= $xc->getXcEqualsOperator("\$block[\$i]['{$rpFieldName}']", "strip_tags(\${$tableName}All[\$i]->getVar('{$fieldName}'))", null, false, "\t\t\t");
203+
$contentForeach .= $xc->getXcEqualsOperator("\$block[\$i]['{$rpFieldName}']", "strip_tags(\${$tableName}All[\$i]->getVar('{$fieldName}'))", null, "\t\t\t");
204204
break;
205205
case 8:
206-
$contentForeach .= $xc->getXcEqualsOperator("\$block[\$i]['{$rpFieldName}']", "\XoopsUser::getUnameFromId(\${$tableName}All[\$i]->getVar('{$fieldName}'))", null, false, "\t\t\t");
206+
$contentForeach .= $xc->getXcEqualsOperator("\$block[\$i]['{$rpFieldName}']", "\XoopsUser::getUnameFromId(\${$tableName}All[\$i]->getVar('{$fieldName}'))", null, "\t\t\t");
207207
break;
208208
case 15:
209-
$contentForeach .= $xc->getXcEqualsOperator("\$block[\$i]['{$rpFieldName}']","formatTimeStamp(\${$tableName}All[\$i]->getVar('{$fieldName}'))", null, false, "\t\t\t");
209+
$contentForeach .= $xc->getXcEqualsOperator("\$block[\$i]['{$rpFieldName}']","formatTimeStamp(\${$tableName}All[\$i]->getVar('{$fieldName}'))", null, "\t\t\t");
210210
break;
211211
default:
212-
$contentForeach .= $xc->getXcEqualsOperator("\$block[\$i]['{$rpFieldName}']","\${$tableName}All[\$i]->getVar('{$fieldName}')", null, false, "\t\t\t");
212+
$contentForeach .= $xc->getXcEqualsOperator("\$block[\$i]['{$rpFieldName}']","\${$tableName}All[\$i]->getVar('{$fieldName}')", null, "\t\t\t");
213213
break;
214214
}
215215
}
@@ -245,15 +245,15 @@ private function getBlocksEdit($moduleDirname, $tableName, $fieldId, $fieldMain,
245245
$ucfTableName = ucfirst($tableName);
246246
$critName = 'cr' . $ucfTableName;
247247

248-
$ret = $pc->getPhpCodeCommentMultiLine(['Function' => 'edit block', '@param $options' => '', '@return' => 'form']);
248+
$ret = $pc->getPhpCodeCommentMultiLine(['Function' => 'edit block', '@param $options' => '', '@return' => 'string']);
249249
$func = $pc->getPhpCodeIncludeDir("XOOPS_ROOT_PATH . '/modules/{$moduleDirname}/class/{$tableName}.php'",'',true, true, '', "\t");
250-
$func .= $xc->getXcEqualsOperator('$helper', 'Helper::getInstance()', '','', "\t");
251-
$func .= $xc->getXcEqualsOperator("\${$tableName}Handler", "\$helper->getHandler('{$tableName}')", null, true, "\t");
250+
$func .= $xc->getXcEqualsOperator('$helper', 'Helper::getInstance()', '',"\t");
251+
$func .= $xc->getXcHandlerLine($tableName, "\t");
252252
$func .= $xc->getXcXoopsTplAssign("{$moduleDirname}_upload_url","{$stuModuleDirname}_UPLOAD_URL",'',"\t");
253-
$func .= $xc->getXcEqualsOperator('$form', "{$language}DISPLAY", '','', "\t");
254-
$func .= $xc->getXcEqualsOperator('$form', "\"<input type='hidden' name='options[0]' value='\".\$options[0].\"' />\"", '.',false, "\t");
255-
$func .= $xc->getXcEqualsOperator('$form', "\"<input type='text' name='options[1]' size='5' maxlength='255' value='\" . \$options[1] . \"' />&nbsp;<br>\"", '.',false, "\t");
256-
$func .= $xc->getXcEqualsOperator('$form', "{$language}TITLE_LENGTH . \" : <input type='text' name='options[2]' size='5' maxlength='255' value='\" . \$options[2] . \"' /><br><br>\"", '.',false, "\t");
253+
$func .= $xc->getXcEqualsOperator('$form', "{$language}DISPLAY", '',"\t");
254+
$func .= $xc->getXcEqualsOperator('$form', "\"<input type='hidden' name='options[0]' value='\".\$options[0].\"' />\"", '.',"\t");
255+
$func .= $xc->getXcEqualsOperator('$form', "\"<input type='text' name='options[1]' size='5' maxlength='255' value='\" . \$options[1] . \"' />&nbsp;<br>\"", '.',"\t");
256+
$func .= $xc->getXcEqualsOperator('$form', "{$language}TITLE_LENGTH . \" : <input type='text' name='options[2]' size='5' maxlength='255' value='\" . \$options[2] . \"' /><br><br>\"", '.',"\t");
257257
$func .= $pc->getPhpCodeArrayShift('$options', "\t");
258258
$func .= $pc->getPhpCodeArrayShift('$options', "\t");
259259
$func .= $pc->getPhpCodeArrayShift('$options', "\t");
@@ -265,12 +265,12 @@ private function getBlocksEdit($moduleDirname, $tableName, $fieldId, $fieldMain,
265265
$func .= $xc->getXcCriteriaSetOrder($critName, "'ASC'","\t","\n");
266266
$func .= $xc->getXcHandlerAllClear("{$tableName}All", $tableName, "\${$critName}", "\t");
267267
$func .= $pc->getPhpCodeUnset($critName, "\t");
268-
$func .= $xc->getXcEqualsOperator('$form', "{$language}{$stuTableName}_TO_DISPLAY . \"<br><select name='options[]' multiple='multiple' size='5'>\"", '.',false, "\t");
269-
$func .= $xc->getXcEqualsOperator('$form', "\"<option value='0' \" . (in_array(0, \$options) == false ? '' : \"selected='selected'\") . '>' . {$language}ALL_{$stuTableName} . '</option>'", '.',false, "\t");
270-
$contentForeach = $xc->getXcEqualsOperator("\${$fieldId}", "\${$tableName}All[\$i]->getVar('{$fieldId}')", '','', "\t\t");
271-
$contentForeach .= $xc->getXcEqualsOperator('$form', "\"<option value='\" . \${$fieldId} . \"' \" . (in_array(\${$fieldId}, \$options) == false ? '' : \"selected='selected'\") . '>' . \${$tableName}All[\$i]->getVar('{$fieldMain}') . '</option>'", '.',false, "\t\t");
268+
$func .= $xc->getXcEqualsOperator('$form', "{$language}{$stuTableName}_TO_DISPLAY . \"<br><select name='options[]' multiple='multiple' size='5'>\"", '.',"\t");
269+
$func .= $xc->getXcEqualsOperator('$form', "\"<option value='0' \" . (in_array(0, \$options) == false ? '' : \"selected='selected'\") . '>' . {$language}ALL_{$stuTableName} . '</option>'", '.',"\t");
270+
$contentForeach = $xc->getXcEqualsOperator("\${$fieldId}", "\${$tableName}All[\$i]->getVar('{$fieldId}')", '',"\t\t");
271+
$contentForeach .= $xc->getXcEqualsOperator('$form', "\"<option value='\" . \${$fieldId} . \"' \" . (in_array(\${$fieldId}, \$options) == false ? '' : \"selected='selected'\") . '>' . \${$tableName}All[\$i]->getVar('{$fieldMain}') . '</option>'", '.',"\t\t");
272272
$func .= $pc->getPhpCodeForeach("{$tableName}All", true, false, 'i', $contentForeach, "\t");
273-
$func .= $xc->getXcEqualsOperator('$form', "'</select>'", '.',false, "\t");
273+
$func .= $xc->getXcEqualsOperator('$form', "'</select>'", '.',"\t");
274274
$func .= $pc->getPhpCodeBlankLine();
275275
$func .= $this->getSimpleString('return $form;', "\t");
276276
$func .= $pc->getPhpCodeBlankLine();

0 commit comments

Comments
 (0)