/** * */ protected function _processRepresentationAnnotations($po_request, $ps_form_prefix, $ps_placement_code) { $va_rel_items = $this->getAnnotations(); $o_coder = $this->getAnnotationPropertyCoderInstance($this->getAnnotationType()); $vn_c = 0; foreach ($va_rel_items as $vn_id => $va_rel_item) { $this->clearErrors(); if (strlen($vn_status = $po_request->getParameter($ps_placement_code . $ps_form_prefix . '_ca_representation_annotations_status_' . $va_rel_item['annotation_id'], pString))) { $vn_access = $po_request->getParameter($ps_placement_code . $ps_form_prefix . '_ca_representation_annotations_access_' . $va_rel_item['annotation_id'], pInteger); $vn_locale_id = $po_request->getParameter($ps_placement_code . $ps_form_prefix . '_ca_representation_annotations_locale_id_' . $va_rel_item['annotation_id'], pInteger); $va_properties = array(); foreach ($o_coder->getPropertyList() as $vs_property) { $va_properties[$vs_property] = $po_request->getParameter($ps_placement_code . $ps_form_prefix . '_ca_representation_annotations_' . $vs_property . '_' . $va_rel_item['annotation_id'], pString); } // edit annotation $this->editAnnotation($va_rel_item['annotation_id'], $vn_locale_id, $va_properties, $vn_status, $vn_access); if ($this->numErrors()) { $po_request->addActionErrors($this->errors(), 'ca_representation_annotations', $va_rel_item['annotation_id']); } else { // try to add/edit label if ($vs_label = $po_request->getParameter($ps_placement_code . $ps_form_prefix . '_ca_representation_annotations_label_' . $va_rel_item['annotation_id'], pString)) { $t_annotation = new ca_representation_annotations($va_rel_item['annotation_id']); if ($t_annotation->getPrimaryKey()) { $t_annotation->setMode(ACCESS_WRITE); $va_pref_labels = $t_annotation->getPreferredLabels(array($vn_locale_id), false); if (sizeof($va_pref_labels)) { // edit existing label foreach ($va_pref_labels as $vn_annotation_dummy_id => $va_labels_by_locale) { foreach ($va_labels_by_locale as $vn_locale_dummy_id => $va_labels) { $t_annotation->editLabel($va_labels[0]['label_id'], array('name' => $vs_label), $vn_locale_id, null, true); } } } else { // create new label $t_annotation->addLabel(array('name' => $vs_label), $vn_locale_id, null, true); } if ($t_annotation->numErrors()) { $po_request->addActionErrors($t_annotation->errors(), 'ca_representation_annotations', 'new_' . $vn_c); $vn_c++; } } } } } else { // is it a delete key? $this->clearErrors(); if ($po_request->getParameter($ps_placement_code . $ps_form_prefix . '_ca_representation_annotations_' . $va_rel_item['annotation_id'] . '_delete', pInteger) > 0) { // delete! $this->removeAnnotation($va_rel_item['annotation_id']); if ($this->numErrors()) { $po_request->addActionErrors($this->errors(), 'ca_representation_annotations', $va_rel_item['annotation_id']); } } } } // check for new annotations to add foreach ($_REQUEST as $vs_key => $vs_value) { if (!preg_match('/^' . $ps_placement_code . $ps_form_prefix . '_ca_representation_annotations_status_new_([\\d]+)/', $vs_key, $va_matches)) { continue; } $vn_c = intval($va_matches[1]); if (strlen($vn_status = $po_request->getParameter($ps_placement_code . $ps_form_prefix . '_ca_representation_annotations_status_new_' . $vn_c, pString)) > 0) { $vn_access = $po_request->getParameter($ps_placement_code . $ps_form_prefix . '_ca_representation_annotations_access_new_' . $vn_c, pInteger); $vn_locale_id = $po_request->getParameter($ps_placement_code . $ps_form_prefix . '_ca_representation_annotations_locale_id_new_' . $vn_c, pInteger); $va_properties = array(); foreach ($o_coder->getPropertyList() as $vs_property) { $va_properties[$vs_property] = $po_request->getParameter($ps_placement_code . $ps_form_prefix . '_ca_representation_annotations_' . $vs_property . '_new_' . $vn_c, pString); } // create annotation $vs_label = $po_request->getParameter($ps_placement_code . $ps_form_prefix . '_ca_representation_annotations_label_new_' . $vn_c, pString); $vn_annotation_id = $this->addAnnotation($vs_label, $vn_locale_id, $po_request->getUserID(), $va_properties, $vn_status, $vn_access); if ($this->numErrors()) { $po_request->addActionErrors($this->errors(), 'ca_representation_annotations', 'new_' . $vn_c); } } } return true; }