Author
|
Message
|
Felipe Jaramillo
|
Wednesday 28 September 2005 5:39:03 pm
Hi, CSV import is essential for most projects.
We have been using the import extention located at: http://zev.ez.no/svn/extensions/csv/ and it works great through the admin interface. Using it through command line returns an undefined function or object error. I'd like to know if someone knows who did this extension since it does not appear in the code. We have added partial support for importing ezenhancedobjectrelation data types and we'd like to share this. Ive wondered why this extension is not listed in the Contribs area in ez.no.
Regards, Felipe
Felipe Jaramillo
eZ Certified Extension Developer
http://www.aplyca.com | Bogotá, Colombia
|
Gabriel Ambuehl
|
Thursday 29 September 2005 4:14:02 am
I've been wondering about the stuff on zev myself. While I very much welcome support for ezenhancedobjectrelation, make SURE that the changes will also work without it installed or eZ isn't gonan like it.
Visit http://triligon.org
|
Felipe Jaramillo
|
Friday 30 September 2005 8:42:50 am
Thanks for your reply Gabriel.
One question: Have you managed to get the CLI version to work? Regarding the ezenhancedobjectrelation, its simply a new case in a long switch, and it doesnt execute unless the datatype is: ezenhancedobjectrelation. Can this cause trouble?
Regards, Felipe
Felipe Jaramillo
eZ Certified Extension Developer
http://www.aplyca.com | Bogotá, Colombia
|
Gabriel Ambuehl
|
Friday 30 September 2005 11:41:43 am
Haven't tried CLI so far. It should not cause trouble: when looking at 3.6, eor doesn't use anything special outside its own templates, all the datastructures are shared with the rest of the relation datatypes so unless you're calling code from the datatype (which shouldnt be needed), it will be safe. And might even work for the other relation types, too.
Visit http://triligon.org
|
Felipe Jaramillo
|
Friday 30 September 2005 2:15:58 pm
Thanks Gabriel, If you could test the CLI on 3.6 it'd be great. I need to automate the CSV import so CLI is a must and I'm getting a: Fatal error: Call to a member function on a non-object in server_path/import.php on line 478.
Fatal error: eZ publish did not finish its request The execution of eZ publish was abruptly ended, the debug output is present below. This corresponds to line: $contentObject =& $class->instantiate( $creatorID, $sectionID ); BTW, how can I commit my changes to zev.ez.no? Maybe someone from the ez crew could clarify who the user "kh" or "wy" is.
Regards, Felipe
Felipe Jaramillo
eZ Certified Extension Developer
http://www.aplyca.com | Bogotá, Colombia
|
Kristian Hole
|
Tuesday 04 October 2005 2:17:31 am
Hi! I know who KH and WY is. This is an old script made for 3.4(?) by Wenue. I added it to the extensions with the intentions of updating it for newer versions, but unfortunately, i did not have time for it. Hope this gave you some answers ;-)
Kristian
http://ez.no/ez_publish/documenta...tricks/show_which_templates_are_used
http://ez.no/doc/ez_publish/techn...te_operators/miscellaneous/attribute
|
Albert Hornos
|
Friday 02 December 2005 1:46:00 am
Hi!
I'm trying to import two new types of attribute with this extension. I'm trying to import URL type and Selection Type, but I've no hits yet. Could anyone help me?? Anyone haked this extension to support this types of attributes?? Thank you!
|
Felipe Jaramillo
|
Friday 02 December 2005 9:10:19 am
First of all, thank you Kristian for your reply. We decided not to use the CSV extension and instead write custom modules to access the data directly on a mysql database. Next time it would be good to implement ezPersistentObject. Albert, the extension is not hard to customize for other datatypes. We added support for enhancedobjectrelation datatype. This one is tricky because it requires a query to get the id, but you will get the point.
In import.php (for CLI) or modules/csvimport.php you can add this case in the attribute switch:
case 'ezobjectrelation':
{
$relatedObjectName = $attributeContent;
if ( $relatedObjectName != "" )
{
$relatedObject = $db->arrayQuery( "SELECT id FROM ezcontentobject WHERE name='$relatedObjectName' AND contentclass_id='$objectRelationClassID'" );
if ( count( $relatedObject ) > 0 )
{
$contentObjectAttribute->setAttribute( 'data_int', $relatedObject[0]['id'] );
$contentObjectAttribute->store();
}
}
break;
}
To make this code work, we had to add some global variables to make them available inside the case.
If you want to download the final file with these changes, you may do so here:
http://www.aplyca.com/csvimport_aplyca.tar.gz Note: the areas we edited are enlosed by
//Edit Aplyca
//End Edit Aplyca
Good luck, Felipe
Felipe Jaramillo
eZ Certified Extension Developer
http://www.aplyca.com | Bogotá, Colombia
|
Vytautas Germanavičius
|
Tuesday 13 December 2005 6:16:35 am
Doe's this extension works on 3.6?
{set-block scope=root variable=cache_ttl}0{/set-block}
|
Felipe Jaramillo
|
Friday 16 December 2005 11:17:43 am
We were able to import through the website with 3.6. Using the CLI version didn't work for us. Let me know your experience.
Regards, Felipe
Felipe Jaramillo
eZ Certified Extension Developer
http://www.aplyca.com | Bogotá, Colombia
|
Daniele Nocentini
|
Thursday 02 March 2006 1:31:59 am
I try this extension on ez 3.7.2 and 3.6.4 in sometimes works fine but in some case ez crash and show this message:
Fatal error: eZ publish did not finish its request
The execution of eZ publish was abruptly ended, the debug output is present below.
It's strange because my csv file test is the same. For example if I import two rows from csv file the extension works fine for the first time but If I try to import the same rows from the same csv file for second time the extension crash ez.
Antica Bottega Digitale srl
http://www.abd.it
|
Patrick Renaud
|
Tuesday 16 January 2007 10:26:18 am
Hi,
I am working on this csv import extension and extended it so that it works with any number of object relation and object relations. But I didn't succeed with the importation of xml blocs. My first tries were stopped by a
Fatal error: Call to a member function on a non-object in .../extension/csv/modules/csv/csvimport.php on line 942
Fatal error: eZ publish did not finish its request
When looking in the code, this stands for :
case 'ezxmltext' :
{
$inputData = "<section xmlns:image='http://ez.no/namespaces/ezpublish3/image/' xmlns:xhtml='http://ez.no/namespaces/ezp
ublish3/xhtml/' xmlns:custom='http://ez.no/namespaces/ezpublish3/custom/'>";
$inputData .= "<paragraph>";
if ( $convertTag == true )
$inputData .= convert( $attributeContent, $tagList );
else
$inputData .= $attributeContent;
$inputData .= "</paragraph>";
$inputData .= "</section>";
include_once("kernel/classes/datatypes/ezxmltext/handlers/input/ezsimplifiedxmlinput.php");
$dumpdata = "";
$simplifiedXMLInput = new eZSimplifiedXMLInput( $dumpdata, null, null );
$inputData = $simplifiedXMLInput->convertInput( $inputData );
$input = $inputData[0]->toString(); /*- THIS line -*/
$contentObjectAttribute->setAttribute( 'data_text', $input );
$contentObjectAttribute->store();
break;
}
After investigating a little, it seems that this function is not implemented in the ezsimplifiedxmlinput class, nor in the ezxmlinputhandler class. Did I miss something ? Anyway, I tried this instead, which <i>should</i> work :
case 'ezxmltext':
{
include_once('kernel/classes/datatypes/ezxmltext/handlers/input/ezsimplifiedxmlinputparser.php');
$contentObjectID = $contentObjectAttribute->attribute('contentobject_id');
$parser = new eZSimplifiedXMLInputParser( $contentObjectID, false, 0);
$document = $parser->process($attributeContent);
if (!is_object($document))
{
$this->messages[] = $this->message("Error", "Adding creating EZXMLText");
return false;
}
$domString = eZXMLTextType::domString($document);
echo "<hr />\nDomString = ".$domString."\n<hr />\n";
$contentObjectAttribute->setAttribute('data_text', $domString);
$contentObjectAttribute->store();
}
}
But then, when I import xml attributes, they remain empty. $domString has the right value (checked), but the content is not stored... Could please someone give me a hint ? I'm growing really desperate. [Edit : code indentation]
Ca, c'est fait !
|
Kristof Coomans
|
Tuesday 16 January 2007 10:49:08 am
Hello Patrick, welcome to the eZ community!
if (!is_object($document))
What was the result of this condition? In case the simplified parser returns false, then it can be useful to ask it where it failed:
$errors = $parser->getMessages();
$errors is an array now with human-readable error strings
independent eZ Publish developer and service provider | http://blog.coomanskristof.be | http://ezpedia.org
|
Patrick Renaud
|
Wednesday 17 January 2007 12:39:45 am
Many thanks for your reply, Kristof, I've read some contributions of yours for some time, and it is an honor. This condition if (!is_object($document))
returns always false, wether $attributeContent (that is, the value of the xml input field) is empty or not (meaning that is_object($document) is true and that $parser->getMessages() returns no error messages). In fact, this code behaves as if the last two lines didn't work. Coulde there be any reason ?
$contentObjectAttribute->setAttribute( 'data_text', $domString );
$contentObjectAttribute->store();
Ca, c'est fait !
|
Patrick Renaud
|
Friday 09 February 2007 9:09:43 am
It appears the problem was somewhere else. The input file must be encoded in utf8, and it works perfectly.
Ca, c'est fait !
|
philippe G
|
Thursday 05 April 2007 8:52:18 am
hi all
first thanks to Patrick Renaud to help mee to download this extension
i test this extension on ez 3.9.1 and i have the same problem and same errors :
Fatal error: Call to a member function on a non-object in /var/www/html/mysite/extension/csv/modules/csv/csvimport.php on line 733 Fatal error: eZ publish did not finish its request
i have 6 field and 2 of them are xml field.
I have edit my text.csv file to put in very simple text with no accent or something like that and no more good result. What do you mean about utf-8 encodage ? Thanks for your help
|
Renaud Patrick
|
Friday 06 April 2007 12:54:46 am
Hi Philippe, I use Open Office, which let you namely specify the encoding used when saving a document. Saving my csv file using UTF-8 encoding solved the problem with xml blocks.
|
philippe G
|
Friday 06 April 2007 2:40:13 am
Hi Patrick
I have test with openOffice document and i have the same error. So you think it's better to test with yrou code's modifications ?
I use a very simple file to test like this :
"test0";"test0";"bla bla bla";"bla bla bla";"bla bla bla" "test1";"test1";"bla bla bla";"bla bla bla";"bla bla bla"
and in my csv.ini file i have this :
FileFieldSeparator=;
Field[1]=title ----> text line
Field[2]=short_title ----> text line
Field[3]=intro ----> xml bloc
Field[4]=body ----> xml bloc Field[5]=reference ----> xml bloc
|
philippe G
|
Friday 06 April 2007 6:14:11 am
ok it's work fine now. I have add your modification Patrick, the first near line 733 to replace :
case 'ezxmltext':
{
$inputData = "<section xmlns:image='http://ez.no/namespaces/ezpublish3/image/' xmlns:xhtml='http://ez.no/namespaces/ezpublish3/xhtml/' xmlns:custom='http://ez.no/namespaces/ezpublish3/custom/' >";
$inputData .= "<paragraph>";
if ( $convertTag == true )
$inputData .= convert( $attributeContent, $tagList );
else
$inputData .= $attributeContent;
$inputData .= "</paragraph>";
$inputData .= "</section>";
include_once( "kernel/classes/datatypes/ezxmltext/handlers/input/ezsimplifiedxmlinput.php" );
$dumpdata = "";
$simplifiedXMLInput = new eZSimplifiedXMLInput( $dumpdata, null, null );
$inputData = $simplifiedXMLInput->convertInput( $inputData );
$input = $inputData[0]->toString();
$contentObjectAttribute->setAttribute( 'data_text', $input );
$contentObjectAttribute->store();
break;
}
by
case 'ezxmltext':
{
include_once('kernel/classes/datatypes/ezxmltext/handlers/input/ezsimplifiedxmlinputparser.php');
$contentObjectID = $contentObjectAttribute->attribute('contentobject_id');
$parser = new eZSimplifiedXMLInputParser( $contentObjectID, false, 0);
$document = $parser->process($attributeContent);
if (!is_object($document))
{
$this->messages[] = $this->message("Error", "Adding creating EZXMLText");
return false;
}
$domString = eZXMLTextType::domString($document);
//echo "<hr />\nDomString = ".$domString."\n<hr />\n";
$contentObjectAttribute->setAttribute('data_text', $domString);
$contentObjectAttribute->store();
}
and in the second part, near line 579 to replace code :
foreach ( array_keys ( $contentObjectAttributes ) as $attributeKey )
{
$contentObjectAttribute =& $contentObjectAttributes[$attributeKey];
$contentClassAttributeID = $contentObjectAttribute->attribute( 'contentclassattribute_id' );
foreach ( array_keys ( $dataArray ) as $key )
{
if ( $key == $contentClassAttributeID )
{
storeAttributeContent( $contentObjectAttribute, $dataArray[$key], $convertTag, $tagList, $objectRelationClassID );
}
}
}
include_once( 'lib/ezutils/classes/ezoperationhandler.php' );
$operationResult = eZOperationHandler::execute( 'content', 'publish', array( 'object_id' => $contentObjectID,
'version' => $versionNr ) );
$mainNode = $contentObject->attribute( 'main_node' );
$nodeID = $mainNode->attribute( 'node_id' );
$objectName = $mainNode->attribute( 'name' );
$publishedContentObject = eZContentObject::fetch( $contentObjectID );
$publishedContentObject->setAttribute('modified', $pdate );
$publishedContentObject->setAttribute('published', $pdate );
$publishedContentObject->store();
$logMessage = implode( " | ", $logArray );
$messages[] = message( "Notice", "Updated <a href='$URL/content/view/full/$nodeID'>$objectName</a>", $logMessage );
by
foreach ( array_keys ( $contentObjectAttributes ) as $attributeKey )
{
$contentObjectAttribute =& $contentObjectAttributes[$attributeKey];
$contentClassAttributeID = $contentObjectAttribute->attribute( 'contentclassattribute_id' );
$contentClassAttributeName = $contentObjectAttribute->attribute( 'contentclassattribute_identifier' );
foreach ( array_keys ( $dataArray ) as $key )
{
if ( $key == $contentClassAttributeID )
{
$currentObjectRelationClassID = $mapping_relations[$contentClassAttributeID];
storeAttributeContent( $contentObjectAttribute, $dataArray[$key], $convertTag, $tagList, $currentObjectRelationClassID );
}
}
}
include_once( 'lib/ezutils/classes/ezoperationhandler.php' );
$operationResult = eZOperationHandler::execute( 'content', 'publish', array( 'object_id' => $contentObjectID,'version' => $versionNr ) );
$mainNode = $contentObject->attribute( 'main_node' );
$nodeID = $mainNode->attribute( 'node_id' );
$objectName = $mainNode->attribute( 'name' );
$publishedContentObject = eZContentObject::fetch( $contentObjectID );
$publishedContentObject->setAttribute('modified', $pdate );
$publishedContentObject->setAttribute('published', $pdate );
$publishedContentObject->store();
$logMessage = implode( " | ", $logArray );
$messages[] = message( "Notice", "Updated <a href='$URL/content/view/full/$nodeID'>$objectName</a>", $logMessage );
i have only change one thing in your code, i replace
'version' => 1
by
'version' => $versionNr
Thanks a lot for your help !
|
Renaud Patrick
|
Tuesday 10 April 2007 8:03:23 am
You're welcome, even though I didn't do anything. ;)
|