function do_updateFieldset() { global $main; $GLOBALS['default']->log->error(print_r($_REQUEST, true)); header('Content-Type: application/xml'); $oFieldset =& $this->oValidator->validateFieldset($_REQUEST['fieldset']); $matches = array(); $aFields = array(); foreach ($_REQUEST as $k => $v) { if (preg_match('/^metadata_(\\d+)$/', $k, $matches)) { $aValues[$matches[1]] = $v; } } $aNextFieldValues =& KTMetadataUtil::getNext($oFieldset, $aValues); $sWidgets = ''; // convert these into widgets using the ever-evil... // function getWidgetForMetadataField($field, $current_value, $page, $errors = null, $vocab = null) foreach ($aNextFieldValues as $aFieldInfo) { $vocab = array(); $vocab[''] = 'Unset'; foreach ($aFieldInfo['values'] as $md_v) { $vocab[$md_v->getName()] = $md_v->getName(); } $req = $aFieldInfo['field']->getIsMandatory(); $oWidget = getWidgetForMetadataField($aFieldInfo['field'], null, $main, null, $vocab, array('required' => $req)); $sWidgets .= $oWidget->render(); } return $sWidgets; }
function renderEdit($document_data) { global $main; // FIXME remove direct access to $main $aFields = array(); $fields =& $this->fieldset->getFields(); foreach ($fields as $oField) { $val = KTUtil::arrayGet($document_data['field_values'], $oField->getId(), null); $has_errors = KTUtil::arrayGet($document_data['errors'], $oField->getId(), false); if ($has_errors !== false) { // FIXME when the actual errors (meaningful) are passed out, fix this. $errors = array(_kt('The system rejected your value for this field.')); } else { $errors = null; } $aFields[] = getWidgetForMetadataField($oField, $val, $main, $errors); // FIXME handle errors } $fieldset_name = $this->fieldset->getName(); $fieldset_description = $this->fieldset->getDescription(); $oTemplating =& KTTemplating::getSingleton(); $oTemplate = $oTemplating->loadTemplate('kt3/fieldsets/simple_editable'); $aTemplateData = array('context' => $this, 'fields' => $aFields, 'title' => $fieldset_name, 'description' => $fieldset_description); return $oTemplate->render($aTemplateData); }