/** * Advanced property handling * * @param array $propertyValues */ protected function saveAdvProperty($propertyValues) { // might break using hard $range = array(); foreach ($propertyValues as $key => $value) { if (is_array($value)) { // set the range foreach ($value as $v) { $range[] = new core_kernel_classes_Class(tao_helpers_Uri::decode($v)); } } else { $values[tao_helpers_Uri::decode($key)] = tao_helpers_Uri::decode($value); } } //if label is empty $validator = new tao_helpers_form_validators_NotEmpty(array('message' => __('Property\'s label field is required'))); if (!$validator->evaluate($values[RDFS_LABEL])) { throw new Exception($validator->getMessage()); } $property = new core_kernel_classes_Property($values['uri']); unset($values['uri']); $property->removePropertyValues(new core_kernel_classes_Property(RDFS_RANGE)); if (!empty($range)) { foreach ($range as $r) { $property->setRange($r); } } $this->bindProperties($property, $values); }
/** * Function returns list of errors in the delivery data. * @param array $data delivery data (uri=>value) * (evaluate {@link self::getEvaluatedParams()} raw data before) * @return array */ public function getErrors($data) { $data = $this->mapDeliveryProperties($data); $errors = array(); $notEmptyValidator = new \tao_helpers_form_validators_NotEmpty(); $numericValidator = new \tao_helpers_form_validators_Numeric(); if (!$notEmptyValidator->evaluate($data[TAO_DELIVERY_START_PROP])) { $errors[TAO_DELIVERY_START_PROP] = $notEmptyValidator->getMessage(); } if (!$notEmptyValidator->evaluate($data[TAO_DELIVERY_END_PROP])) { $errors[TAO_DELIVERY_END_PROP] = $notEmptyValidator->getMessage(); } if ($data[TAO_DELIVERY_END_PROP] < $data[TAO_DELIVERY_START_PROP]) { $errors[TAO_DELIVERY_START_PROP] = __('start date must be before end date'); } if (!$notEmptyValidator->evaluate($data[RDFS_LABEL])) { $errors[RDFS_LABEL] = $notEmptyValidator->getMessage(); } if (isset($data[TAO_DELIVERY_MAXEXEC_PROP]) && !$numericValidator->evaluate($data[TAO_DELIVERY_MAXEXEC_PROP])) { $errors[TAO_DELIVERY_MAXEXEC_PROP] = $numericValidator->getMessage(); } return $errors; }