Forums / Developer / Problem with an eZPedia article

Problem with an eZPedia article

Author Message

Sébastien Antoniotti

Friday 09 February 2007 12:36:38 pm

Hi,

I'm trying to run this script : http://ezpedia.org/wiki/en/ez/snippet_ez_cli_data_creation_script_unstable

But I get this error

Parse error: syntax error, unexpected '&' in /var/www/eztest/seb.php on line 26

Here is the line 26 :

24 if ( !$class = eZContentClass::fetch( $classID ) )
25 {
26     $cli->output('Error: Could not fetch class');
27 }

And I don't know the signification of this : $cli->

Thanks in advance for your help !

eZ Publish Freelance
web : http://www.webaxis.fr

Paul Borgermans

Friday 09 February 2007 1:22:01 pm

Ok, trouble with conversion of characters:

24 if ( !$class = eZContentClass::fetch( $classID ) )
25 {
26    $cli->output('Error: Could not fetch class');
27 }

hth
Paul

eZ Publish, eZ Find, Solr expert consulting and training
http://twitter.com/paulborgermans

Sébastien Antoniotti

Friday 09 February 2007 2:09:46 pm

Sorry it was very basic !

eZ Publish Freelance
web : http://www.webaxis.fr

kracker (the)

Friday 09 February 2007 6:23:19 pm

An I knowingly admit respect for the contributor of this article,
yet simply because of the reasons above and ... principle,
could we change the primary storage location for this source
code to reside (with crosslinks) in PubSVN instead of eZpeadia.

Let us all read eZpedia but keep the runtime sources for completed tools like this in PubSVN no?

//kracker

<b>DMX - Ruff Ryders Anthem...</b>
It's just an idea, not a believe ... I swear.

Member since: 2001.07.13 || http://ezpedia.se7enx.com/

Sébastien Antoniotti

Friday 09 February 2007 11:52:08 pm

I'm sorry but I don't understand all the sense of your last reply (my english is poor...).

eZ Publish Freelance
web : http://www.webaxis.fr

Sébastien Antoniotti

Saturday 10 February 2007 12:07:51 am

It's me again =)

I get a new error trying to insert html data like "word<br />word2" into a xml bloc attribute.

I have found this page : http://ez.no/ezpublish/documentation/development/importing_attribute_data

and here is how I use it :

$classID = 17;
$nodeID = 79;
 
if ( !$class = eZContentClass::fetch( $classID ) )
{
    $cli->output('Error: Could not fetch class');
}
 
$node = eZContentObjectTreeNode::fetch($nodeID);
if (!$node)
{    
    $cli->output('Error: no mapped parent node');        
}
 
$object =& $class->instantiate();        
if (!$object)
{
    $cli->output('Error: could not create object');
}
 
$objectID = $object->attribute( 'id' );
$cli->output('Object ID: ' . $objectID);
$cli->output('Node ID: ' . $nodeID);
$cli->output();
$nodeAssignment = eZNodeAssignment::create( array( 'contentobject_id' => $objectID,
                                                   'contentobject_version' => 1,
                                                   'parent_node' => $nodeID,
                                                   'is_main' => 1 ) 
                                           );
$nodeAssignment->store();
 
$dataMap =& $object->dataMap();
foreach( array_keys( $dataMap ) as $key )
{
    $cli->output($key);
 
    $attribute =& $dataMap[$key];
    $classAttributeID = $attribute->attribute( 'contentclassattribute_id' );
    switch ($key){
    	case 'titre':
		    $attribute->setAttribute( 'data_text',$title );    
    		break;
    	case 'contenu':
    		$contentClassAttribute = $attribute->attribute( 'contentclass_attribute' ); 
			$dummy = "";            
			$converter = new text2xml( $dummy, 0, $contentClassAttribute );            
			$converter->validateText( $introtext, $contentClassAttribute );            
			$attribute->SetAttribute( 'data_int', EZ_XMLTEXT_VERSION_TIMESTAMP );  
    		break;    	
    		
    }

    $attribute->store();
}
 
if ( !eZOperationHandler::execute( 'content', 'publish', array( 'object_id' => $objectID, 'version' => 1 ) ) )
{
    // TODO:
    // add to the list of errors
    $cli->output('Error: Could not execute');
}

$introtext is my html text queried in a database, and the definition of the text2xml class is included at bottom of the script.(I have paste them into an external php file).

So I get this error :

Fatal error: Call to a member function on a non-object in /var/www/eztest/convert.php on line 97

And here is the line 97 :

           $objects =& $dom->elementsByName( 'object' );

If I don't try to set this xml bloc attribute my object is nicely created, so the rest of the code is ok (I get it on eZpedia ;-))

Sorry for all this questions !

eZ Publish Freelance
web : http://www.webaxis.fr

eZ debug

Timing: Jan 31 2025 01:25:34
Script start
Timing: Jan 31 2025 01:25:34
Module start 'content'
Timing: Jan 31 2025 01:25:34
Module end 'content'
Timing: Jan 31 2025 01:25:34
Script end

Main resources:

Total runtime0.2427 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.0082 587.9297370.2969
Module start 'content' 0.00820.0118 958.22661,009.6406
Module end 'content' 0.02000.2225 1,967.86723,898.1875
Script end 0.2426  5,866.0547 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00451.8401200.0002
Check MTime0.00130.5167200.0001
Mysql Total
Database connection0.00080.344610.0008
Mysqli_queries0.153663.29791410.0011
Looping result0.00130.55121390.0000
Template Total0.222191.510.2221
Template load0.00080.338010.0008
Template processing0.221291.168510.2212
Override
Cache load0.00060.227110.0006
Sytem overhead
Fetch class attribute can translate value0.00200.825810.0020
XML
Image XML parsing0.00030.117510.0003
General
dbfile0.00532.1735200.0003
String conversion0.00000.003030.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