当前位置: 首页>>代码示例>>PHP>>正文


PHP eZContentObject::store方法代码示例

本文整理汇总了PHP中eZContentObject::store方法的典型用法代码示例。如果您正苦于以下问题:PHP eZContentObject::store方法的具体用法?PHP eZContentObject::store怎么用?PHP eZContentObject::store使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在eZContentObject的用法示例。


在下文中一共展示了eZContentObject::store方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: setOptions

 /**
  * Allows to set options to content
  * Enter description here ...
  * @param $options
  */
 public function setOptions(SQLIContentOptions $options)
 {
     $this->options = $options;
     foreach ($options as $optionName => $option) {
         switch ($optionName) {
             case 'language':
                 $this->setActiveLanguage($option);
                 break;
             default:
                 $this->contentObject->setAttribute($optionName, $option);
         }
     }
     $this->contentObject->store();
 }
开发者ID:nicolasaguenot,项目名称:sqliimport,代码行数:19,代码来源:sqlicontent.php

示例2: updateAndPublishObject

 /**
  * Updates an existing content object.
  *
  * This function works like createAndPublishObject
  *
  * Here is an example
  * <code>
  *
  * <?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' );
  * }
  * ?>
  * </code>
  * @param eZContentObject an eZContentObject object
  * @param array an array with the attributes to update
  * @static
  * @return bool true if the object has been successfully updated, false otherwise
  */
 public static function updateAndPublishObject(eZContentObject $object, array $params)
 {
     if (!array_key_exists('attributes', $params) and !is_array($params['attributes']) and count($params['attributes']) > 0) {
         eZDebug::writeError('No attributes specified for object' . $object->attribute('id'), __METHOD__);
         return false;
     }
     $storageDir = '';
     $languageCode = false;
     $mustStore = false;
     if (array_key_exists('remote_id', $params)) {
         $object->setAttribute('remote_id', $params['remote_id']);
         $mustStore = true;
     }
     if (array_key_exists('section_id', $params)) {
         $object->setAttribute('section_id', $params['section_id']);
         $mustStore = true;
     }
     if ($mustStore) {
         $object->store();
     }
     if (array_key_exists('storage_dir', $params)) {
         $storageDir = $params['storage_dir'];
     }
     if (array_key_exists('language', $params) and $params['language'] != false) {
         $languageCode = $params['language'];
     } else {
         $initialLanguageID = $object->attribute('initial_language_id');
         $language = eZContentLanguage::fetch($initialLanguageID);
         $languageCode = $language->attribute('locale');
     }
     $db = eZDB::instance();
     $db->begin();
     $newVersion = $object->createNewVersion(false, true, $languageCode);
     if (!$newVersion instanceof eZContentObjectVersion) {
         eZDebug::writeError('Unable to create a new version for object ' . $object->attribute('id'), __METHOD__);
         $db->rollback();
         return false;
     }
     $newVersion->setAttribute('modified', time());
     $newVersion->store();
     $attributeList = $newVersion->attribute('contentobject_attributes');
     $attributesData = $params['attributes'];
     foreach ($attributeList as $attribute) {
         $attributeIdentifier = $attribute->attribute('contentclass_attribute_identifier');
         if (array_key_exists($attributeIdentifier, $attributesData)) {
             $dataString = $attributesData[$attributeIdentifier];
             switch ($datatypeString = $attribute->attribute('data_type_string')) {
                 case 'ezimage':
                 case 'ezbinaryfile':
//.........这里部分代码省略.........
开发者ID:jordanmanning,项目名称:ezpublish,代码行数:101,代码来源:ezcontentfunctions.php


注:本文中的eZContentObject::store方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。