Forums / Developer / how to instanciat a eZDataType classe ?

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

eZ debug

Timing: Jan 30 2025 19:47:44
Script start
Timing: Jan 30 2025 19:47:44
Module start 'content'
Timing: Jan 30 2025 19:47:44
Module end 'content'
Timing: Jan 30 2025 19:47:44
Script end

Main resources:

Total runtime0.3189 sec
Peak memory usage8,192.0000 KB
Database Queries141

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0074 587.9531370.2891
Module start 'content' 0.00740.0141 958.24221,009.6563
Module end 'content' 0.02150.2974 1,967.89843,898.4922
Script end 0.3189  5,866.3906 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00481.5053200.0002
Check MTime0.00150.4775200.0001
Mysql Total
Database connection0.00070.204410.0007
Mysqli_queries0.215667.59491410.0015
Looping result0.00180.54981390.0000
Template Total0.296993.110.2969
Template load0.00110.331510.0011
Template processing0.295892.747710.2958
Override
Cache load0.00080.246110.0008
Sytem overhead
Fetch class attribute can translate value0.00190.608910.0019
XML
Image XML parsing0.00020.071210.0002
General
dbfile0.00912.8380200.0005
String conversion0.00000.002230.0000
Note: percentages do not add up to 100% because some accumulators overlap

CSS/JS files loaded with "ezjscPacker" during request:

CacheTypePacklevelSourceFiles
CSS0extension/community/design/community/stylesheets/ext/jquery.autocomplete.css
extension/community_design/design/suncana/stylesheets/scrollbars.css
extension/community_design/design/suncana/stylesheets/tabs.css
extension/community_design/design/suncana/stylesheets/roadmap.css
extension/community_design/design/suncana/stylesheets/content.css
extension/community_design/design/suncana/stylesheets/star-rating.css
extension/community_design/design/suncana/stylesheets/syntax_and_custom_tags.css
extension/community_design/design/suncana/stylesheets/buttons.css
extension/community_design/design/suncana/stylesheets/tweetbox.css
extension/community_design/design/suncana/stylesheets/jquery.fancybox-1.3.4.css
extension/bcsmoothgallery/design/standard/stylesheets/magnific-popup.css
extension/sevenx/design/simple/stylesheets/star_rating.css
extension/sevenx/design/simple/stylesheets/libs/fontawesome/css/all.min.css
extension/sevenx/design/simple/stylesheets/main.v02.css
extension/sevenx/design/simple/stylesheets/main.v02.res.css
JS0extension/ezjscore/design/standard/lib/yui/3.17.2/build/yui/yui-min.js
extension/ezjscore/design/standard/javascript/jquery-3.7.0.min.js
extension/community_design/design/suncana/javascript/jquery.ui.core.min.js
extension/community_design/design/suncana/javascript/jquery.ui.widget.min.js
extension/community_design/design/suncana/javascript/jquery.easing.1.3.js
extension/community_design/design/suncana/javascript/jquery.ui.tabs.js
extension/community_design/design/suncana/javascript/jquery.hoverIntent.min.js
extension/community_design/design/suncana/javascript/jquery.popmenu.js
extension/community_design/design/suncana/javascript/jScrollPane.js
extension/community_design/design/suncana/javascript/jquery.mousewheel.js
extension/community_design/design/suncana/javascript/jquery.cycle.all.js
extension/sevenx/design/simple/javascript/jquery.scrollTo.js
extension/community_design/design/suncana/javascript/jquery.cookie.js
extension/community_design/design/suncana/javascript/ezstarrating_jquery.js
extension/community_design/design/suncana/javascript/jquery.initboxes.js
extension/community_design/design/suncana/javascript/app.js
extension/community_design/design/suncana/javascript/twitterwidget.js
extension/community_design/design/suncana/javascript/community.js
extension/community_design/design/suncana/javascript/roadmap.js
extension/community_design/design/suncana/javascript/ez.js
extension/community_design/design/suncana/javascript/ezshareevents.js
extension/sevenx/design/simple/javascript/main.js

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1pagelayout.tpl<No override>extension/sevenx/design/simple/templates/pagelayout.tplEdit templateOverride template
 Number of times templates used: 1
 Number of unique templates used: 1

Time used to render debug report: 0.0001 secs