Wednesday 17 May 2006 10:52:44 am
I'm writing a batch inserting class from XML data (importing document from a thord party information system).
You'll read below the extract which is populating content object attributes...
The target eZContentObject has string, date, keyword and objectrelationlist fields. I can achieve insertion for <i>string</i>, <i>date</i> and <i>keywords</i> field, but what about updating object relation list with with the target object's simple ID ? ---------------------------------------------------------------------------------
<i><b>
$itemType = $itemObj->get_attribute("type");
switch ($itemType) {
case _NOTES_XML_STRING_TYPE :
$ezItem->setAttribute('data_text', $fieldValue);
$cli->notice("Setting STRING value : " . $fieldValue);
break;
case _NOTES_XML_DATE_TYPE :
$dateElements = split("/", $fieldValue);
$dateSerial = mktime(0, 0, 0, $dateElements[1], $dateElements[0], $dateElements[2]);
$ezItem->setAttribute('data_int', $dateSerial);
$cli->notice("Setting DATE value : " . $dateSerial);
unset ($dateElements);
unset ($dateSerial);
break;
case _NOTES_XML_KEYWORDS_TYPE :
$keywordField = & $ezItem->attribute('content');
$cli->notice("Setting KEYWORDS value : " . $fieldValue);
$keywordField->initializeKeyword($fieldValue);
unset ($keywordField);
break;
}
$ezItem->store(); </b></i>
|