Commit f8a20cc2ba43db0c1e1c605139fecc1728fc2b6b
1 parent
146948c6
Add entity_radios smarty function
git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@3821 c91229c3-7414-0410-bfa2-8a42b809f60b
Showing
1 changed file
with
26 additions
and
0 deletions
lib/templating/smartytemplate.inc.php
| @@ -51,6 +51,7 @@ class KTSmartyTemplate extends KTTemplate { | @@ -51,6 +51,7 @@ class KTSmartyTemplate extends KTTemplate { | ||
| 51 | $smarty->register_function('entity_select', array('KTSmartyTemplate', 'entity_select')); | 51 | $smarty->register_function('entity_select', array('KTSmartyTemplate', 'entity_select')); |
| 52 | $smarty->register_function('boolean_checkbox', array('KTSmartyTemplate', 'boolean_checkbox')); | 52 | $smarty->register_function('boolean_checkbox', array('KTSmartyTemplate', 'boolean_checkbox')); |
| 53 | $smarty->register_function('entity_checkboxes', array('KTSmartyTemplate', 'entity_checkboxes')); | 53 | $smarty->register_function('entity_checkboxes', array('KTSmartyTemplate', 'entity_checkboxes')); |
| 54 | + $smarty->register_function('entity_radios', array('KTSmartyTemplate', 'entity_radios')); | ||
| 54 | return $smarty->fetch($this->sPath); | 55 | return $smarty->fetch($this->sPath); |
| 55 | } | 56 | } |
| 56 | 57 | ||
| @@ -133,6 +134,31 @@ class KTSmartyTemplate extends KTTemplate { | @@ -133,6 +134,31 @@ class KTSmartyTemplate extends KTTemplate { | ||
| 133 | 134 | ||
| 134 | return smarty_function_html_checkboxes($params, $smarty); | 135 | return smarty_function_html_checkboxes($params, $smarty); |
| 135 | } | 136 | } |
| 137 | + | ||
| 138 | + function entity_radios($params, &$smarty) { | ||
| 139 | + require_once $smarty->_get_plugin_filepath('function', 'html_radios'); | ||
| 140 | + | ||
| 141 | + $entities = KTUtil::arrayGet($params, 'entities'); | ||
| 142 | + if (is_null($entities)) { | ||
| 143 | + $smarty->trigger_error("assign: missing 'entities' parameter"); | ||
| 144 | + return; | ||
| 145 | + } | ||
| 146 | + | ||
| 147 | + $idmethod = KTUtil::arrayGet($params, 'idmethod', 'getId'); | ||
| 148 | + $method = KTUtil::arrayGet($params, 'method', 'getName'); | ||
| 149 | + | ||
| 150 | + $params['values'] = array(); | ||
| 151 | + $params['output'] = array(); | ||
| 152 | + foreach ($entities as $oEntity) { | ||
| 153 | + $params['values'][] = call_user_func(array(&$oEntity, $idmethod)); | ||
| 154 | + $params['output'][] = call_user_func(array(&$oEntity, $method)); | ||
| 155 | + } | ||
| 156 | + unset($params['entities']); | ||
| 157 | + unset($params['idmethod']); | ||
| 158 | + unset($params['method']); | ||
| 159 | + | ||
| 160 | + return smarty_function_html_radios($params, $smarty); | ||
| 161 | + } | ||
| 136 | } | 162 | } |
| 137 | 163 | ||
| 138 | ?> | 164 | ?> |