|
eZ Publish
[trunk]
|
Static Public Member Functions | |
| static | createAndPublishObject ($params) |
| Creates and publishes a new content object. | |
| static | updateAndPublishObject (eZContentObject $object, array $params) |
| Updates an existing content object. | |
Definition at line 11 of file ezcontentfunctions.php.
| 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 }
?>
| 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 :
|
Definition at line 88 of file ezcontentfunctions.php.
Referenced by eZSiteInstaller\createContentObject().
| 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' ); } ?>
| eZContentObject | an eZContentObject object |
| array | an array with the attributes to update |
Definition at line 228 of file ezcontentfunctions.php.