From cd6c110f396c5903251f2047e5e8c59e5d4b43f5 Mon Sep 17 00:00:00 2001 From: Kamil Date: Tue, 11 Dec 2018 15:24:23 +0500 Subject: [PATCH] Update functions.php --- assets/plugins/evocollection/functions.php | 47 +++++++++++++++++++--- 1 file changed, 42 insertions(+), 5 deletions(-) diff --git a/assets/plugins/evocollection/functions.php b/assets/plugins/evocollection/functions.php index 977b6ee..d1708bd 100644 --- a/assets/plugins/evocollection/functions.php +++ b/assets/plugins/evocollection/functions.php @@ -7,7 +7,9 @@ function get_output($config) { global $modx; if ($config['user_func']) return $modx->runSnippet($config['user_func'], $config); - extract($config); + extract($config); + + $delimiter = isset($delimiter) ? $delimiter : '||'; switch($mode) { @@ -90,11 +92,33 @@ function get_output($config) else return '
Нет
'; break; - case 'select': + case 'dropdown': + case 'select': + $table = $table ? $table : $_POST['table']; + $id = $id ? $id : $_POST['id']; + $parent = $parent ? $parent : $_POST['parent']; + $delimiter = $delimiter ? $delimiter : $_POST['delimiter']; + $elements = $elements ? $elements : $_POST['elements']; + $field = $field ? $field : $_POST['field']; + $type = $type ? $type : $_POST['type']; + $user_func = $user_func ? $user_func : $_POST['user_func']; + $value = $value ? $value : $_POST['value']; + $table = $table ? $table : $_POST['table']; $s='Не выбрано'; + if ($elements{0} === '@') { + if(substr($elements, 0, 5) === '@EVAL') { + $eval_str = trim(substr($elements, 6)); + $elements = eval($eval_str); + } + elseif(substr($elements, 0, 7) === '@SELECT') { + $select_str = trim(substr($elements, 1)); + $elements = implode($delimiter, array_map(function ($item) { + return implode('==', $item); + }, $modx->db->makeArray($modx->db->query($select_str)))); + } + } foreach(explode($delimiter,$elements) as $str) - { - + { $col = explode('==',$str); if (isset($col[1])) { @@ -169,8 +193,21 @@ function get_output($config) $return = ''; break; + case 'dropdown': case 'select': - $s = ''; + if ($elements{0} === '@') { + if(substr($elements, 0, 5) === '@EVAL') { + $eval_str = trim(substr($elements, 6)); + $elements = eval($eval_str); + } + elseif(substr($elements, 0, 7) === '@SELECT') { + $select_str = trim(substr($elements, 1)); + $elements = implode($delimiter, array_map(function ($item) { + return implode('==', $item); + }, $modx->db->makeArray($modx->db->query($select_str)))); + } + } foreach(explode($delimiter,$elements) as $str) { $col = explode('==',$str);