19 require_once(BASE.
"wcmf/lib/core/class.WCMFException.php");
20 require_once(BASE.
"wcmf/lib/util/class.Message.php");
21 require_once(BASE.
"wcmf/lib/util/class.StringUtil.php");
22 require_once(BASE.
"wcmf/lib/util/class.InifileParser.php");
23 require_once(BASE.
"wcmf/lib/presentation/class.DefaultControlRenderer.php");
24 require_once(BASE.
"wcmf/lib/util/class.SessionData.php");
25 require_once(BASE.
"wcmf/lib/i18n/class.Localization.php");
48 $this->_language = $language;
52 $this->_controlRenderer = &$objectFactory->createInstanceFromConfig(
'implementation',
'ControlRenderer');
53 if ($this->_controlRenderer == null) {
67 $FIELD_DELIMITER =
'-';
70 if(($fieldDelimiter = $parser->getValue(
'inputFieldNameDelimiter',
'htmlform')) ===
false) {
71 $fieldDelimiter = $FIELD_DELIMITER;
73 return $fieldDelimiter;
94 public function getInputControl($name, $inputType, $value, $editable=
true, $addEmptyValue=
false)
96 $value = strval($value);
99 if (strPos($inputType,
'#'))
101 list($def, $list) = split(
'#', $inputType, 2);
102 $listMap = $this->
getListMap($list, $value, null, $addEmptyValue);
112 if ($list !=
'' && strPos($value,
',')) {
113 $value = split(
",", $value);
116 $value = htmlspecialchars($value);
124 preg_match_all(
"/[\w][^\[\]]+/", $def, $matches);
125 if (sizeOf($matches[0]) > 0) {
126 list($type, $attributes) = $matches[0];
128 if (!$type || $type ==
'') {
133 if (strPos($attributes,
'multiple')) {
140 return $this->_controlRenderer->renderControl($type, $editable, $name, $value, $session->getError($name), $attributes, $listMap, $inputType);
156 private function getListMap($description, $value=null, $nodeOid=null, $addEmptyValue=
false)
159 $mapKey = $description.$value.$addEmptyValue;
160 if (isset($this->_lists[$mapKey])) {
161 return $this->_lists[$mapKey];
166 if (!strPos($description,
':')) {
170 list($type, $list) = split(
':', $description, 2);
178 if (strPos($list,
'$') === 0) {
179 $entries =
$GLOBALS[subStr($list,1)];
182 $entries = split(
'\|', $list);
184 if (!is_array($entries))
190 foreach($entries as $curEntry)
192 preg_match_all(
"/([^\[]*)\[*([^\]]*)\]*/", $curEntry, $matches);
193 if (sizeOf($matches) > 0)
195 $val1 = htmlentities($matches[1][0], ENT_QUOTES,
'UTF-8');
196 $val2 = htmlentities($matches[2][0], ENT_QUOTES,
'UTF-8');
198 if (!function_exists(
'html_entity_decode')) {
199 $val1 = html_entity_decode($val1, ENT_QUOTES,
'UTF-8');
219 $parts = split(
'\|', $list);
220 $name = array_shift($parts);
221 $params = join(
'|', $parts);
222 if (function_exists($name)) {
223 $map = call_user_func_array($name, split(
',', $params));
231 $map = $parser->getSection($list);
232 if (($map = $parser->getSection($list,
false)) ===
false) {
238 $parts = split(
'\|', $list);
239 $entityType = array_shift($parts);
243 $oidParts[
'type'] = $entityType;
244 $oidParts[
'id'] = $value;
253 $ids = split(
',', $value);
254 foreach ($ids as $id)
259 if ($resolvedValue) {
260 $map[$id] = $resolvedValue;
265 if (
sizeof($map) == 0) {
266 $map = array($value => $value);
271 $parts = split(
'\|', $list);
273 foreach($parts as $key=>$entityType)
276 $ids = split(
',', $value);
277 foreach ($ids as $id)
286 if ($this->_language != null) {
287 $localization->loadTranslation($obj, $this->_language);
289 $map[$id] = $obj->getDisplayValue();
295 if (
sizeof($map) == 0) {
296 $map = array($value => $value);
306 foreach($map as $key => $value) {
311 if ($addEmptyValue ==
true && !array_key_exists(
'', $result)) {
312 $result = array(
'' =>
Message::get(
'keine Angabe')) + $result;
316 if ($nodeOid == null) {
317 $this->_lists[$mapKey] = $result;
339 if ($this->_language != null) {
340 $localization->loadTranslation($obj, $this->_language);
342 $result = $obj->getDisplayValue();
344 }
catch (Exception $ex) {
361 public function translateValue($value, $inputType, $replaceBR=
false, $nodeOid = null)
365 if (strPos($inputType,
'#') && $value !=
'')
367 list(,$list) = split(
'#', $inputType, 2);
368 $map = $this->
getListMap($list, $value, $nodeOid);
369 if ($list !=
'' && strPos($value,
',')) {
370 $value = split(
",", $value);
372 if (is_array($value))
374 foreach($value as $curValue) {
375 $translated .= $map[$curValue].
", ";
380 $translated = $map[$value];
384 $value = nl2br($value);
386 $value = str_replace(
'<br />',
' ', $value);
removeTrailingComma($string)
get($message, $parameters=null, $domain='', $lang='')
throwEx($message, $file='', $line='')
decomposeOID($oid, $validate=true)