Exponential 6.0.13 Exponential Enterprise Open Source CMS - PHP Class Reference

Static Public Member Functions | List of all members
eZContentFunctions Class Reference

## Static Public Member Functions
static | createAndPublishObject ( $params)
static | updateAndPublishObject (eZContentObject $object, array $params)

## Detailed Description

Definition at line 11 of file ezcontentfunctions.php.

## Member Function Documentation

## ◆ createAndPublishObject()

static eZContentFunctions::createAndPublishObject | ( |  | $params | ) |
| static

Creates and publishes a new content object.

This function takes all the variables passes in the $params argument and creates a new content object out of it.

Here is an example `<?php`

`// admin user $creatorID = 14;`

`// folder content class $classIdentifier = 'folder';`

`// root node $parentNodeID = 2;`

`// have a look at the folder content class' definition ;) // basically the array is the following : // key : attribute identifier ( not attribute ID !! ) // value : value for this attribute // // Please refer to each fromString/toString function to see // how to organize your data`

`$xmlDeclaration = '<?xml version="1.0" encoding="utf-8"?> <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/">';`

`$attributeList = array( 'name' => 'A newly created folder object', 'short_name' => 'A new folder', 'short_description' => $xmlDeclaration .'<paragraph>This is the short description</paragraph></section>', 'description' => $xmlDeclaration . '<section><section><header>Some header</header><paragraph>Some paragraph with a <link target="_blank" url_id="1">link</link></paragraph> </section></section></section>', 'show_children' => true);`

`// Creates the data import array $params = array(); $params['creator_id'] = $creatorID; $params['class_identifier'] = $classIdentifier; $params['parent_node_id'] = $parentNodeID; $params['attributes'] = $attributeList;`

`$contentObject = eZContentFunctions::createAndPublishObject( $params );`

`if( $contentObject ) { // do anything you want here }`

`?>`

Parameters

  array | $params | An array with all the informations to store. This array must contains a strict list of key/value pairs. The possible keys are the following : 'parent_node_id' : The parentNodeID for this new object. 'class_identifier' : The classIdentifier for this new object. using the classID is not possible. 'creator_id' : The eZUser::contentObjectID to use as creator of this new eZContentObject, uses current user and stores object id in current session if not set 'attributes' : The list of attributes to store, in order to now which values you can use for this key, you have to read the code of the fromString and toString functions of the attribute's datatype you use 'storage_dir' : 'remote_id' : The value for the remoteID (optional) 'section_id' : The value for the sectionID (optional)

Returns
  eZContentObject|false An eZContentObject object if success, false otherwise

Definition at line 88 of file ezcontentfunctions.php.

References eZNodeAssignment\create(), eZDateTime\currentTimeStamp(), eZOperationHandler\execute(), eZContentObjectTreeNode\fetch(), eZContentClass\fetchByIdentifier(), eZDB\instance(), eZContentObjectVersion\STATUS_DRAFT, and eZDebug\writeError().

Referenced by eZSiteInstaller\createContentObject().

## ◆ updateAndPublishObject()

static eZContentFunctions::updateAndPublishObject | ( | eZContentObject | $object,
|  | array | $params
| ) |  |
| static

Updates an existing content object.

This function works like createAndPublishObject

Here is an example ``

`<?php $contentObjectID = 1; $contentObject = eZContentObject::fetch( $contentObjectID );`

`if( $contentObject instanceof eZContentObject ) { $xmlDeclaration = '<?xml version="1.0" encoding="utf-8"?> <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/">';`

`$now = $now = date( 'Y/m/d H:i:s', time() ); $xmlDeclaration = '<?xml version="1.0" encoding="utf-8"?> <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/">';`

`$attributeList = array( 'name' => 'Name ' . $now, 'short_name' => 'Short name ' . $now, 'short_description' => $xmlDeclaration . '<paragraph>Short description '. $now . '</paragraph></section>', 'description' => $xmlDeclaration . '<paragraph>Description '. $now . '</paragraph></section>', 'show_children' => false);`

`$params = array(); $params['attributes'] = $attributeList; // $params['remote_id'] = $now; // $params['section_id'] = 3; // $params['language'] = 'ger-DE';`

`$result = eZContentFunctions::updateAndPublishObject( $contentObject, $params );`

`if( $result ) print( 'Update OK' ); else print( 'Failed' ); } ?>`

Parameters

  eZContentObject | an eZContentObject object
  array | an array with the attributes to update

Returns
  bool true if the object has been successfully updated, false otherwise

Definition at line 227 of file ezcontentfunctions.php.

References eZPersistentObject\attribute(), eZContentObject\createNewVersion(), eZOperationHandler\execute(), eZContentLanguage\fetch(), eZDB\instance(), eZPersistentObject\setAttribute(), eZModuleOperationInfo\STATUS_CONTINUE, eZContentObject\store(), and eZDebug\writeError().

The documentation for this class was generated from the following file:

- ezcontentfunctions.php

Copyright © 1998 – 2026 7x. All rights reserved. Licensed under the GNU GPLv2+.