function convertRawValuestoRealValues($value, $handle, $returnFlat = false) { if (!is_array($value)) { $value = array(0 => $value); $arrayWasPassedIn = false; } else { $arrayWasPassedIn = true; } $element_handler = xoops_getmodulehandler('elements', 'formulize'); $thisElement = $element_handler->get($handle); if (!is_object($thisElement)) { if ($arrayWasPassedIn) { return $value; } else { return $value[0]; } } $ele_value = $thisElement->getVar('ele_value'); $isLinkedSelectBox = false; $isNamesList = false; if (is_array($ele_value)) { if (isset($ele_value[2])) { if (strstr($ele_value[2], "#*=:*")) { $isLinkedSelectBox = true; $linkedMetaData = formulize_isLinkedSelectBox($thisElement->getVar('ele_id')); } elseif (isset($ele_value[2]["{FULLNAMES}"]) or isset($ele_value[2]["{USERNAMES}"])) { $isNamesList = isset($ele_value[2]["{FULLNAMES}"]) ? 'name' : 'uname'; } } } $allRealValuesNames = array(); foreach ($value as $thisValue) { if ($isLinkedSelectBox) { // convert the pointers for the linked selectbox values, to their source values $sourceMeta = explode("#*=:*", $linkedMetaData[2]); $data_handler = new formulizeDataHandler($sourceMeta[0]); $realValues = $data_handler->findAllValuesForEntries($sourceMeta[1], explode(",", trim($thisValue, ","))); // trip opening and closing commas and split by comma into an array // findAllValuesForEntries method returns an array, so convert to a single value if (is_array($realValues) and $returnFlat) { $realValues = implode(", ", $realValues); } $allRealValues[] = $realValues; } elseif (strstr($thisValue, "*=+*:")) { $allRealValues[] = str_replace("*=+*:", ", ", ltrim($thisValue, "*=+*:")); // replace the separator with commas between values } elseif ($isNamesList) { $allRealValuesNames[] = $thisValue; } else { $allRealValues[] = $thisValue; } } if (count($allRealValuesNames) > 0) { // convert all uids found into names with only one query $user_handler = xoops_gethandler('user'); $criteria = new CriteriaCompo(); foreach ($allRealValuesNames as $thisUid) { if (is_numeric($thisUid)) { $criteria->add(new Criteria('uid', $thisUid), 'OR'); } } $users = $user_handler->getObjects($criteria, true); // true causes key of returned array to be uids foreach ($allRealValuesNames as $thisUid) { if (is_numeric($thisUid) and isset($users[$thisUid])) { $allRealValues[] = $users[$thisUid]->getVar($isNamesList); } else { $allRealValues[] = _formulize_BLANK_KEYWORD; } } } if ($arrayWasPassedIn) { return $allRealValues; } else { return $allRealValues[0]; } }