Import image process into kernel

Author Message

thibaut colin

Thursday 25 June 2009 6:08:14 am

Hi everybody,

I'm developping a xml import script who create and publish object on eZ database. There are many link to image on these files and I search into the kernel what are the methods and classes I have to use in order to insert correctly all image as well as I make all this process into Admin interface.

I see that the datatype ezimage is link to the ezPersistentObject class like an ezString but ezimage have to be declared with a xml matrix in data_text.

I suppose it will be more complicated that only use this kind of code :

$objDataMap=$this->current_eZ_object->dataMap();
$imageAttr=$objDataMap['image'];
$imageAttr->setAttribute('data_text',$tag->nodeValue);
$nameAttr->store();

In fact, I search for all process that eZ use for create an object with ezimage attribute without the Admin interface.

Have you any idea who could help me ?

Thanks

Jérôme Vieilledent

Saturday 27 June 2009 3:22:25 am

Hi Thibault.

First, know that it already exists extensions to import data (<b>Data Import</b>, and I'm about to release mine, <b>NovenImportXMLStream</b>).

Now for your question, you should use the <i>fromString()</i> method of the <i>ezimage</i> datatype. Every datatypes (well at least the built-in ones) have this very useful method since eZ Publish 3.9.
So if you want to grab an external image, you must first grab it in a temporary folder on your local filesystem (in your <b>var/</b> directory for instance, check your <b>VarDir</b> directive in site.ini), and then you pass the full path (use <b>realpath</b> PHP function) of your image to the <i>fromString()</i> method.

Damien Pobel

Monday 29 June 2009 3:48:00 am

Hi,

In addition, you can have a look to ezcsvimport.php script [1] bundled with eZ Publish which is a quite simple example of what Jérôme explains.

[1] http://pubsvn.ez.no/nextgen/trunk/bin/php/ezcsvimport.php

Damien
Planet eZ Publish.fr : http://www.planet-ezpublish.fr
Certification : http://auth.ez.no/certification/verify/372448
Publications about eZ Publish : http://pwet.fr/tags/keywords/weblog/ez_publish

thibaut colin

Tuesday 30 June 2009 2:38:18 am

Thanks for your help. I'm going to test all this.

Powered by eZ Publish™ CMS Open Source Web Content Management. Copyright © 1999-2014 eZ Systems AS (except where otherwise noted). All rights reserved.

eZ debug

Timing: Jan 18 2025 19:26:02
Script start
Timing: Jan 18 2025 19:26:02
Module start 'layout'
Timing: Jan 18 2025 19:26:02
Module start 'content'
Timing: Jan 18 2025 19:26:03
Module end 'content'
Timing: Jan 18 2025 19:26:03
Script end

Main resources:

Total runtime0.8854 sec
Peak memory usage4,096.0000 KB
Database Queries62

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0054 589.0547152.6250
Module start 'layout' 0.00540.0026 741.679739.4453
Module start 'content' 0.00810.8756 781.1250595.2422
Module end 'content' 0.88370.0017 1,376.367212.1563
Script end 0.8853  1,388.5234 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00330.3681160.0002
Check MTime0.00130.1524160.0001
Mysql Total
Database connection0.00060.068010.0006
Mysqli_queries0.832994.0733620.0134
Looping result0.00060.0715600.0000
Template Total0.858196.920.4291
Template load0.00210.240120.0011
Template processing0.856096.682320.4280
Template load and register function0.00020.025710.0002
states
state_id_array0.00080.092310.0008
state_identifier_array0.00140.156920.0007
Override
Cache load0.00160.1849240.0001
Sytem overhead
Fetch class attribute can translate value0.00080.096030.0003
Fetch class attribute name0.00140.162060.0002
XML
Image XML parsing0.00110.128330.0004
class_abstraction
Instantiating content class attribute0.00000.001360.0000
General
dbfile0.00100.1111230.0000
String conversion0.00000.001240.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1node/view/full.tplfull/forum_topic.tplextension/sevenx/design/simple/override/templates/full/forum_topic.tplEdit templateOverride template
4content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
6content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
1content/datatype/view/ezxmltags/literal.tpl<No override>extension/community/design/standard/templates/content/datatype/view/ezxmltags/literal.tplEdit templateOverride template
2content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
1content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 16
 Number of unique templates used: 7

Time used to render debug report: 0.0001 secs