how to instanciat a eZDataType classe ?

Author Message

Peretjatko Alexandre

Tuesday 24 June 2008 7:56:57 am

Hi,

I d'ont understand how to use the eZDataType classe.
In the documentation, I've found :

eZDataType::eZDataType(  	$dataTypeString,
		$name,
		$properties = array()	 
	) 	
Initializes the datatype with the string id $dataTypeString and the name $name.

So I've write :

	
include_once('kernel/classes/ezdatatype.php');
$l_OBJ_File =& eZDataType::eZDataType("dataType", "name");

and I got the message :
Fatal error: Call to undefined method: stdClass->isindexable() in C:\eZpublish\ezpublish\kernel\classes\ezdatatype.php on line 88

I use an ezpublish 3.10. Is it a bugging version for this classe ? What's wrong in my code ?

Thanks for your help.

Regards

Alex.
--------------------------------------------------------------
Personnal website : http://www.alex-design.fr

Vidar Langseid

Thursday 03 July 2008 2:33:10 am

eZDataType is meant as base class for other datatypes.

I am not sure what you want to do, but trying to instantiate a datatype doesn't make much sense. The content needs to be stored in a attribute in a contentobject. Once you have the content object, the different datatypes will be instantiated for you

Best regards,
Vidar

Peretjatko Alexandre

Thursday 03 July 2008 2:55:16 am

Thanks for your answer.

Well.... My first problem was to read a file content from an uploaded file and during all my investigations, I've found the classe eZDataType which seems to be ok to do the job for me.

But reading your answer I should be on a wrong way.

Regards

Alex.
--------------------------------------------------------------
Personnal website : http://www.alex-design.fr

Hans Melis

Thursday 03 July 2008 2:29:36 pm

It depends on where you're handling uploaded files, but if you're in your own module I suggest you take a look at the eZHTTPFile class. You can find it in the lib/ezutils/classes dir.

If that's not what you're trying to do, please explain your problem in greater detail :-)

Hans
http://blog.hansmelis.be

Peretjatko Alexandre

Friday 04 July 2008 1:18:22 am

Thanks Hans Melis,

Your right, my problem is not well explain.
- The user, upload a file in the Back Office in a file object. For that, I've create a file object in the BO, in a specific folder. The user will use always the same object, so I'll have different version. This is a text file.
- With a cron job I have to import in a specific database datas stored in the file. For that, I have to read my file content with a php script, and my trouble is to point that file.

But I don't know how to read my text file content. So I search in eZDataType classe without success. And I'm not sure that the eZHTTPFile class is the good one.

Regards

Alex.
--------------------------------------------------------------
Personnal website : http://www.alex-design.fr

Hans Melis

Friday 04 July 2008 4:17:20 am

eZHTTPFile is indeed not what you need in your case. You are actually trying to access a file that is a part of a content object.

So first of all, you need to fetch the object in some way. Once you have it, you'll have an instance of the eZContentObject class. Objects of that class have a method called <i>dataMap</i>. That method returns an array with the following structure:
- key: identifier of the attribute as specified in the content class
- value: instance of eZContentObjectAttribute

The class eZContentObjectAttribute actually (for the real data at least) wraps around the datatype. If you query the eZContentObjectAttribute instance for content(), you will get the content that has been stored by the corresponding datatype. That content can be a scalar value, an array or even an object of class. The latter is the case for attributes of the type file.

The datatype for files is called ezbinaryfile (kernel/classes/datatypes) and the content of that datatype returns an instance of the class eZBinaryFile.

That should get you on the road. I obviously left some things out, but the goal is that you actually learn something. So it's your task to connect the dots ;-)

hth

Hans
http://blog.hansmelis.be

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 11:21:59
Script start
Timing: Jan 18 2025 11:21:59
Module start 'layout'
Timing: Jan 18 2025 11:21:59
Module start 'content'
Timing: Jan 18 2025 11:22:00
Module end 'content'
Timing: Jan 18 2025 11:22:00
Script end

Main resources:

Total runtime0.8159 sec
Peak memory usage4,096.0000 KB
Database Queries68

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0064 589.1328152.6250
Module start 'layout' 0.00640.0033 741.757839.4453
Module start 'content' 0.00970.8048 781.2031610.0938
Module end 'content' 0.81450.0013 1,391.296916.1563
Script end 0.8158  1,407.4531 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00330.4087160.0002
Check MTime0.00140.1669160.0001
Mysql Total
Database connection0.00100.124210.0010
Mysqli_queries0.753192.3030680.0111
Looping result0.00070.0864660.0000
Template Total0.780895.720.3904
Template load0.00220.267120.0011
Template processing0.778695.428720.3893
Template load and register function0.00020.026610.0002
states
state_id_array0.00160.193910.0016
state_identifier_array0.00110.138420.0006
Override
Cache load0.00190.2324420.0000
Sytem overhead
Fetch class attribute can translate value0.00070.081530.0002
Fetch class attribute name0.00110.137370.0002
XML
Image XML parsing0.00060.068930.0002
class_abstraction
Instantiating content class attribute0.00000.002080.0000
General
dbfile0.00080.0969150.0001
String conversion0.00000.001040.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
6content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
12content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
5content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
2content/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
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 29
 Number of unique templates used: 7

Time used to render debug report: 0.0001 secs