/** * */ public function editAnnotation($pn_annotation_id, $pn_locale_id, $pa_properties, $pn_status, $pn_access, $pa_values = null, $pa_options = null) { if (!($vn_representation_id = $this->getPrimaryKey())) { return null; } if (!($o_coder = $this->getAnnotationPropertyCoderInstance($this->getAnnotationType()))) { // does not support annotations return null; } foreach ($o_coder->getPropertyList() as $vs_property) { if (!$o_coder->setProperty($vs_property, $pa_properties[$vs_property])) { // error setting values $this->errors = $o_coder->errors; return false; } } if (!$o_coder->validate()) { $this->errors = $o_coder->errors; return false; } $t_annotation = new ca_representation_annotations($pn_annotation_id); if ($t_annotation->getPrimaryKey() && $t_annotation->get('representation_id') == $vn_representation_id) { foreach ($o_coder->getPropertyList() as $vs_property) { $t_annotation->setPropertyValue($vs_property, $o_coder->getProperty($vs_property)); } $t_annotation->setMode(ACCESS_WRITE); $t_annotation->set('type_code', $o_coder->getType()); $t_annotation->set('locale_id', $pn_locale_id); $t_annotation->set('status', $pn_status); $t_annotation->set('access', $pn_access); $t_annotation->update(); if ($t_annotation->numErrors()) { $this->errors = $t_annotation->errors; return false; } if (is_array($pa_values)) { foreach ($pa_values as $vs_element => $va_value) { if (is_array($va_value)) { // array of values (complex multi-valued attribute) $t_annotation->addAttribute(array_merge($va_value, array('locale_id' => $pn_locale_id)), $vs_element); } else { // scalar value (simple single value attribute) if ($va_value) { $t_annotation->addAttribute(array('locale_id' => $pn_locale_id, $vs_element => $va_value), $vs_element); } } } } $t_annotation->update(); if ($t_annotation->numErrors()) { $this->errors = $t_annotation->errors; return false; } if (is_array($pa_properties) && isset($pa_properties['label'])) { $t_annotation->replaceLabel(array('name' => $pa_properties['label']), $pn_locale_id, null, true); } if (isset($pa_options['returnAnnotation']) && (bool) $pa_options['returnAnnotation']) { return $t_annotation; } return true; } return false; }