コード例 #1
0
 /**
  * (non-PHPdoc)
  * @see extension/sqliimport/classes/sourcehandlers/ISQLIImportHandler::process()
  */
 public function process($row)
 {
     // $row is a SimpleXMLElement object
     $this->currentGUID = $row->id;
     $contentOptions = new SQLIContentOptions(array('class_identifier' => 'issue_post', 'remote_id' => (string) $row->id));
     $content = SQLIContent::create($contentOptions);
     $published = (string) $row->published;
     $updated = (string) $row->updated;
     $skipUpdated = false;
     if ($published && $published != '' && $published != 0) {
         $content->setAttribute('published', strtotime($published));
         $content->store();
     } elseif ((!$published || ${$published} == '' || $published == 0) && ($updated && $updated != '' && $updated != 0)) {
         $content->setAttribute('published', strtotime($updated));
         $content->setAttribute('modified', strtotime($updated));
         $content->store();
         $skipUpdated = true;
     }
     if (!$skipUpdated && $updated && $updated != '' && $updated != 0) {
         $content->setAttribute('modified', strtotime($updated));
         $content->store();
     } elseif (!$skipUpdated && (!$updated || ${$updated} == '' || $updated == 0) && ($published && $published != '' && $published != 0)) {
         $content->setAttribute('published', strtotime($published));
         $content->setAttribute('modified', strtotime($published));
         $content->store();
     }
     // $title = strip_tags( html_entity_decode( (string)$row->title ) );
     $classToDecode = new eZecosystemSimpleOperators();
     $title = strip_tags($classToDecode->html_entity_decode_numeric((string) $row->title));
     /*
     echo "\n\n";
     print_r( $title );
     echo "\n\n";
     */
     $content->fields->title = $title;
     $content->fields->blog_post_author = (string) $row->author->name;
     $content->fields->blog_post_url = (string) $row->link["href"];
     $content->fields->publication_date = strtotime((string) $row->updated);
     // Handle HTML content
     $message = (string) $row->content;
     $content->fields->blog_post_description_text_block = (string) $row->content;
     // Proxy method to SQLIContentUtils::getRichContent()
     $issueTicketID = $this->getIssueFromGitCommitMessage($title, strip_tags($message));
     // echo "\n\n"; print_r($issueTicketID); echo "\n\n"; die();
     $content->fields->tags = $issueTicketID;
     // Now publish content
     $content->addLocation(SQLILocation::fromNodeID($this->handlerConfArray['DefaultParentNodeID']));
     $publisher = SQLIContentPublisher::getInstance();
     $publisher->publish($content);
     // Clear cache
     $defaultParentNodeID = $this->handlerConfArray['DefaultParentNodeID'];
     $parentNode = eZContentObjectTreeNode::fetch($defaultParentNodeID, 'eng-US');
     if ($parentNode != false) {
         $objectID = $parentNode->attribute('object')->attribute('id');
         eZContentCacheManager::clearContentCacheIfNeeded($objectID);
     }
     // Free some memory. Internal methods eZContentObject::clearCache() and eZContentObject::resetDataMap() will be called
     // @see SQLIContent::__destruct()
     unset($content);
 }
 /**
  * (non-PHPdoc)
  * @see extension/sqliimport/classes/sourcehandlers/ISQLIImportHandler::process()
  */
 public function process($row)
 {
     // $row is a SimpleXMLElement object
     $this->currentGUID = $row->id;
     $contentOptions = new SQLIContentOptions(array('class_identifier' => 'blog_post', 'remote_id' => (string) $row->id));
     $content = SQLIContent::create($contentOptions);
     $published = (string) $row->published;
     $updated = (string) $row->updated;
     $skipUpdated = false;
     if ($published && $published != '' && $published != 0) {
         $content->setAttribute('published', strtotime($published));
         $content->store();
     } elseif ((!$published || ${$published} == '' || $published == 0) && ($updated && $updated != '' && $updated != 0)) {
         $content->setAttribute('published', strtotime($updated));
         $content->setAttribute('modified', strtotime($updated));
         $content->store();
         $skipUpdated = true;
     }
     if (!$skipUpdated && $updated && $updated != '' && $updated != 0) {
         $content->setAttribute('modified', strtotime($updated));
         $content->store();
     } elseif (!$skipUpdated && (!$updated || ${$updated} == '' || $updated == 0) && ($published && $published != '' && $published != 0)) {
         $content->setAttribute('published', strtotime($published));
         $content->setAttribute('modified', strtotime($published));
         $content->store();
     }
     $content->fields->title = 'Gist: ' . (string) $row->title;
     $content->fields->blog_post_author = (string) $row->author->name;
     $content->fields->blog_post_url = (string) $row->link["href"];
     $content->fields->publication_date = strtotime((string) $row->updated);
     // Handle HTML content
     $content->fields->blog_post_description_text_block = (string) $row->content;
     // Proxy method to SQLIContentUtils::getRichContent()
     /*
     if( preg_match( '/1624060/', $row->id[0] ) )
     {
     echo "\n\n\n"; 
     print_r( $row->id[0] );
     echo "\n\n\n";
     // print_r( (string)$row->content );
     
     print_r( SQLILocation::fromNodeID( $this->handlerConfArray['DefaultParentNodeID'] ) );
     echo "\n\n\n";
     }
     */
     // Now publish content
     $content->addLocation(SQLILocation::fromNodeID($this->handlerConfArray['DefaultParentNodeID']));
     $publisher = SQLIContentPublisher::getInstance();
     $publisher->publish($content);
     // Clear cache
     $defaultParentNodeID = $this->handlerConfArray['DefaultParentNodeID'];
     $parentNode = eZContentObjectTreeNode::fetch($defaultParentNodeID, 'eng-US');
     if ($parentNode != false) {
         $objectID = $parentNode->attribute('object')->attribute('id');
         eZContentCacheManager::clearContentCacheIfNeeded($objectID);
     }
     // Free some memory. Internal methods eZContentObject::clearCache() and eZContentObject::resetDataMap() will be called
     // @see SQLIContent::__destruct()
     unset($content);
 }
コード例 #3
0
 /**
  * Main method to process current row returned by getNextRow() method.
  * You may throw an exception if something goes wrong. It will be logged but won't break the import process
  * @param mixed $row Depending on your data format, can be DOMNode, SimpleXMLIterator, SimpleXMLElement, CSV row...
  */
 public function process($row)
 {
     $contentOptions = new SQLIContentOptions(array('class_identifier' => 'user', 'remote_id' => (string) $row->login));
     $content = SQLIContent::create($contentOptions);
     $content->fields->first_name = (string) $row->firstName;
     $content->fields->last_name = (string) $row->lastName;
     $userParts = array((string) $row->login, (string) $row->email);
     //password management : if empty, generate it, use custom default or fixed default
     $password = $row->password;
     if (!$password) {
         if (isset($this->options->generate_password) && $this->options->generate_password) {
             $password = eZUser::createPassword(6);
         } elseif (isset($this->options->default_password) && $this->options->default_password) {
             $password = $this->options->default_password;
         } else {
             $password = '******';
         }
     }
     $userParts[] = $password;
     $userParts[] = eZUser::createHash((string) $row->login, $password, eZUser::site(), eZUser::hashType());
     $userParts[] = eZUser::hashType();
     $content->fields->user_account = implode('|', $userParts);
     // Now publish content
     $content->addLocation(SQLILocation::fromNodeID($this->handlerConfArray['DefaultParentNodeID']));
     $publisher = SQLIContentPublisher::getInstance();
     $publisher->publish($content);
     // Free some memory. Internal methods eZContentObject::clearCache() and eZContentObject::resetDataMap() will be called
     // @see SQLIContent::__destruct()
     unset($content);
     $this->csv->rows->next();
 }
 /**
  * (non-PHPdoc)
  * @see extension/sqliimport/classes/sourcehandlers/ISQLIImportHandler::process()
  */
 public function process($row)
 {
     // $row is a SimpleXMLElement object
     $this->currentGUID = $row->id;
     $contentOptions = new SQLIContentOptions(array('class_identifier' => 'forum_topic', 'remote_id' => (string) $row->id));
     $content = SQLIContent::create($contentOptions);
     // print_r( $row ); die();
     $published = (string) $row->published;
     $updated = (string) $row->updated;
     $skipUpdated = false;
     if ($published && $published != '' && $published != 0) {
         $content->setAttribute('published', strtotime($published));
         $content->store();
     } elseif ((!$published || ${$published} == '' || $published == 0) && ($updated && $updated != '' && $updated != 0)) {
         $content->setAttribute('published', strtotime($updated));
         $content->setAttribute('modified', strtotime($updated));
         $content->store();
         $skipUpdated = true;
     }
     if (!$skipUpdated && $updated && $updated != '' && $updated != 0) {
         $content->setAttribute('modified', strtotime($updated));
         $content->store();
     } elseif (!$skipUpdated && (!$updated || ${$updated} == '' || $updated == 0) && ($published && $published != '' && $published != 0)) {
         $content->setAttribute('published', strtotime($published));
         $content->setAttribute('modified', strtotime($published));
         $content->store();
     }
     $defaultParentNodeID = $this->handlerConfArray['DefaultParentNodeID'];
     $title = (string) $row->title;
     $content->fields->subject = $title;
     $content->fields->forum_topic_author = '<a href="' . (string) $row->author->uri . '" title="' . (string) $row->author->uri . '">' . (string) $row->author->name . '</a>';
     $content->fields->link = (string) $row->link["href"];
     $content->fields->publication_date = strtotime((string) $row->updated);
     // Handle HTML content
     $message = (string) $row->summary;
     $content->fields->message = $message;
     // Proxy method to SQLIContentUtils::getRichContent()
     //      $content->fields->message = str_replace( 'href="/', 'href="http://stackoverflow.com/', $message ); // Proxy method to SQLIContentUtils::getRichContent()
     //echo "\n\nCorrupt-ObjectID: "; print_r( $content->attribute( 'id' ) ); echo "\n\n";
     // Now publish content
     $content->addLocation(SQLILocation::fromNodeID($defaultParentNodeID));
     $publisher = SQLIContentPublisher::getInstance();
     $publisher->publish($content);
     // Clear cache
     $defaultParentNodeID = $this->handlerConfArray['DefaultParentNodeID'];
     $parentNode = eZContentObjectTreeNode::fetch($defaultParentNodeID, 'eng-US');
     if ($parentNode != false) {
         $objectID = $parentNode->attribute('object')->attribute('id');
         eZContentCacheManager::clearContentCacheIfNeeded($objectID);
     }
     // Free some memory. Internal methods eZContentObject::clearCache() and eZContentObject::resetDataMap() will be called
     // @see SQLIContent::__destruct()
     unset($content);
 }
コード例 #5
0
 /**
  * (non-PHPdoc)
  * @see extension/sqliimport/classes/sourcehandlers/ISQLIImportHandler::process()
  */
 public function process($row)
 {
     // $row is a SimpleXMLElement object
     $this->currentGUID = $row->guid;
     $contentOptions = new SQLIContentOptions(array('class_identifier' => 'article', 'remote_id' => (string) $row->guid));
     $content = SQLIContent::create($contentOptions);
     $content->fields->title = (string) $row->title;
     $content->fields->author = (string) $row->author . '|noreply@sqli.com|-1';
     // @see eZAuthorType::fromString()
     // Handle HTML content
     $content->fields->intro = $this->getRichContent((string) $row->description);
     // Proxy method to SQLIContentUtils::getRichContent()
     // Now publish content
     $content->addLocation(SQLILocation::fromNodeID($this->handlerConfArray['DefaultParentNodeID']));
     $publisher = SQLIContentPublisher::getInstance();
     $publisher->publish($content);
     // Free some memory. Internal methods eZContentObject::clearCache() and eZContentObject::resetDataMap() will be called
     // @see SQLIContent::__destruct()
     unset($content);
 }
コード例 #6
0
 /**
  * (non-PHPdoc)
  * @see extension/sqliimport/classes/sourcehandlers/ISQLIImportHandler::process()
  */
 public function process($row)
 {
     $this->currentID = $row['zupid'];
     $remoteID = 'concert_fb-' . $row['zupid'];
     $reviewOptions = new SQLIContentOptions(array('class_identifier' => self::CONTENT_CLASS, 'remote_id' => $remoteID));
     $content = SQLIContent::create($reviewOptions);
     $publisher = SQLIContentPublisher::getInstance();
     $parentLocation = SQLILocation::fromNodeID($this->handlerConfArray['DefaultParentNodeID']);
     $content->fields->name = (string) $row->name;
     $content->fields->link = (string) $row->deepLink;
     $timestampFrom = strtotime((string) $row->validFrom);
     $timestampTo = strtotime((string) $row->validTo);
     $content->fields->date_from = $timestampFrom;
     $content->fields->date_to = $timestampTo;
     $content->fields->unpublish_date = $timestampTo > 0 ? $timestampTo + 86400 : $timestampFrom + 86400;
     // Dépublication 1j après la date de fin
     $content->fields->price = (string) $row->price . '|1|1';
     $content->fields->currency = (string) $row->currencyCode;
     $content->fields->image_small = (string) $row->smallImage;
     $content->fields->image_medium = (string) $row->mediumImage;
     $content->fields->image_large = (string) $row->largeImage;
     $content->fields->place = (string) $row->manufacturer . ' (' . (string) ucwords($row->extra2) . ')';
     if (strpos((string) $row->shippingHandling, '1|0') === 0) {
         $latitude = '';
         $longitude = '';
     } else {
         list($gps1, $gps2, $latitude, $longitude) = explode('|', (string) $row->shippingHandling);
     }
     $location = '1|#' . $latitude . '|#' . $longitude . '|#' . (string) $row->longDescription . ', ' . (string) $row->extra2 . ', ' . (string) $row->description;
     $content->fields->gmap_location = $location;
     $zip = (string) $row->terms;
     $content->fields->zip_code = $zip;
     $content->fields->region = substr($zip, 0, 2);
     $content->fields->country = (string) $row->description;
     $content->addLocation($parentLocation);
     $publisher->publish($content);
     unset($content);
 }
コード例 #7
0
ファイル: pdf.php プロジェクト: sushilbshinde/ezpublish-study
    protected function synchronize()
    {
        parent::synchronize();

        $locale         = $this->source['m_language'];
        $this->content  = SQLIContent::create(new SQLIContentOptions( array(
            'class_identifier'      => self::$class_identifier,
            'remote_id'             => $this->remoteId(),
            'language'              => $locale
        )));

        // Positionnement sous le publisher
        $publisher = MMSynchPublisherFolder::fetch($this->source['p_id']);
        MMSynchHelper::addLocation($this->content, $publisher->getContentMediaFile()->defaultLocation);

        if (!isset($this->content->fields[$locale]))
            $this->content->addTranslation($locale);

        $this->content->setActiveLanguage($locale);

        $this->populate();
        $this->publish();
    }
コード例 #8
0
ファイル: content.php プロジェクト: nicolasaguenot/sqliimport
<?php

include 'extension/sqliimport/stubs/scriptinit.php';
eZINI::instance()->setVariable('ContentSettings', 'ViewCaching', 'disabled');
eZINI::instance()->setVariable('SearchSettings', 'DelayedIndexing', 'enabled');
// =================================================
$objectID = 27395;
// Enter an ObjectID here
$nodeID = 53115;
// Enter a NodeID here
//$contentObject = eZContentObject::fetch( $objectID );
//$content = SQLIContent::fromContentObject( $contentObject );
$content = SQLIContent::fromNodeID($nodeID);
$content->setActiveLanguage('fre-FR');
$cli->notice("Object name : {$content}");
$cli->notice();
$cli->notice('Available locales for this object : ');
foreach ($content->fields as $locale => $fieldset) {
    $cli->notice($locale . ' - ' . $fieldset->getLanguage());
}
$cli->notice();
// =================================================
// ===== CONTENT EDITING
// =================================================
$cli->notice('Now publishing new version of object #' . $objectID . ' (NodeID #' . $nodeID . ')');
$content->fields['eng-US']->author = 'Oscar Wilde';
$content->fields['fre-FR']->author = 'Victor Hugo';
$content->fields['fre-FR']->name = 'Test FR5';
$content->fields['eng-US']->name = 'Test US5';
$content->fields['eng-GB']->name = 'Test GB5';
$content->fields['ita-IT']->name = 'Test IT5';
コード例 #9
0
<?php

include 'extension/sqliimport/stubs/scriptinit.php';
eZINI::instance()->setVariable('ContentSettings', 'ViewCaching', 'disabled');
$cli->notice('Creation of a new "comment" object');
$options = new SQLIContentOptions(array('class_identifier' => 'comment', 'remote_id' => 'my_ubber_cool_remote_id', 'language' => 'fre-FR'));
$comment = SQLIContent::create($options);
$cli->notice('Current version : ' . $comment->current_version);
$comment->fields->subject = 'Mon super sujet';
$comment->fields->author = 'Moi !';
$comment->fields->message = 'Le commentaire de la mort';
$comment->addTranslation('eng-US');
$comment->fields['eng-US']->subject = 'My great subject';
$comment->fields['eng-US']->author = 'Batman';
$comment->fields['eng-US']->message = 'Death comment';
$comment->addLocation(SQLILocation::fromNodeID(2));
$comment->addLocation(SQLILocation::fromNodeID(43));
$publisher = SQLIContentPublisher::getInstance();
$publisher->publish($comment);
$cli->notice('Current version : ' . $comment->current_version);
// Loop against locations
foreach ($comment->locations as $nodeID => $location) {
    $cli->notice($nodeID . ' => ' . $location->path_string . ' (' . $comment->locations[$nodeID]->path_identification_string . ')');
}
$script->shutdown();
コード例 #10
0
    protected function getNamedContent($name, $forceSynchronization)
    {
        $contentName = 'content' . $name;
        if (!$this->$contentName)
        {
            $contentObject = eZContentObject::fetchByRemoteID( $this->{'remoteId' . $name}() );

            if ( !$forceSynchronization && !$this->synchronizer->option('ForceSynchronization') && $contentObject instanceof eZContentObject )
            {
                $this->$contentName = SQLIContent::fromContentObject( $contentObject );
                if ($this->$contentName instanceof SQLIContent)
                {
                    $this->{$contentName}->setActiveLanguage($this->source['pf_default_language']);
                }
            }
            else
            {
                $this->synchronize();
            }
        }

        return $this->$contentName;
    }
コード例 #11
0
 /**
  * Adds a location to provided content.
  * Prefer using SQLIContent::addLocation() instead of calling this method directly
  * @param SQLILocation $location
  * @param SQLIContent $content
  * @internal
  */
 public function addLocationToContent(SQLILocation $location, SQLIContent $content)
 {
     $nodeID = $content->attribute('main_node_id');
     if (!$nodeID) {
         // No main node ID, object has not been published at least once
         throw new SQLIContentException(__METHOD__ . ' => Cannot directly add a location to a not-yet-published content. Content Object ID = ' . $content->attribute('id') . '. Try to use SQLIContent::addLocation()');
     }
     $objectID = $content->attribute('id');
     $locationNodeID = $location->getNodeID();
     // Check first if content has already an assigned node in provided location
     $assignedNodes = $content->assignedNodes(false);
     for ($i = 0, $iMax = count($assignedNodes); $i < $iMax; ++$i) {
         if ($locationNodeID == $assignedNodes[$i]['parent_node_id']) {
             eZDebug::writeWarning(__METHOD__ . ' => Content with ObjectID #' . $objectID . ' already has a location as a child of node #' . $locationNodeID);
             return;
         }
     }
     eZDebug::accumulatorStart('sqlicontentpublisher_add_location', 'sqlicontentpublisher', 'Adding a location for object #' . $objectID);
     $selectedNodeIDArray = array($locationNodeID);
     if (eZOperationHandler::operationIsAvailable('content_addlocation')) {
         $operationResult = eZOperationHandler::execute('content', 'addlocation', array('node_id' => $nodeID, 'object_id' => $objectID, 'select_node_id_array' => $selectedNodeIDArray), null, true);
     } else {
         eZContentOperationCollection::addAssignment($nodeID, $objectID, $selectedNodeIDArray);
     }
     $content->refreshLocations();
     eZDebug::accumulatorStop('sqlicontentpublisher_add_location');
 }
コード例 #12
0
    protected function createHtmlObject($filePath, $location, $publisher)
    {
        $file           = MMSynchFileManager::fromFileName($this->article->getOrigin(), $publisher, MMSynchFileManager::HTML_FOLDER, $filePath);
        $fullPath       = $file->getFullPath();
        $html           = self::getFileContent($fullPath);
        $filenamePos    = strrpos($filePath, '/');
        $fileName       = substr($filePath, $filenamePos ? $filenamePos + 1 : 0);
        $remoteID       = md5($this->article->remoteId().$fileName);
        $lang           = $this->article->getLanguage();
        $content        = SQLIContent::fromRemoteID($remoteID);

        if ( $content instanceof SQLIContent )
        {
            if ( !isset($content->fields[$lang]) )
            {
                $content->addTranslation( $lang );
            }
            $content->setActiveLanguage( $lang );
        }
        else
        {
            $content = SQLIContent::create( new SQLIContentOptions( array(
                'class_identifier'  => 'html',
                'remote_id'         => md5($this->article->remoteId() . $fileName),
                'language'          => $lang
            )));
        }

        $content->fields->title = $fileName;
        $content->fields->text  = $html;

        $content->addLocation($location);

        MMSynchContentPublisher::getInstance()->publish($content);
        $file->setCanArchived();

        return $content;
    }
コード例 #13
0
    protected function imgHandler($attributes)
    {
        $attributesName = array('alt', 'legend');
        foreach ( $attributesName as $attributeName )
        {
            if ( !isset($attributes[$attributeName]) )
            {
                $attributes[$attributeName] = '';
            }
        }

        $filePath       = $attributes['src'];
        $filenamePos    = strrpos($filePath, '/');
        $fileName       = substr($filePath, $filenamePos ? $filenamePos + 1 : 0);

        $file = SQLIContent::create( new SQLIContentOptions( array(
            'class_identifier'      => 'image',
            'remote_id'             => md5($this->article->remoteId() . $fileName),
            'language'              => $this->article->getLanguage()
        )));

        $file->fields->headline        = $attributes['alt'];
        //$file->fields->original_size   = $attributes['width'] . 'x' . $attributes['height'];
        $file->fields->alternate_text = $attributes['legend'] ? $attributes['legend'] : $attributes['alt'];
        $file->fields->language        = $this->article->getLanguage();
        $img                            = MMSynchFileManager::fromFileName($this->article->getOrigin(), $this->article->getPublisher(), MMSynchFileManager::IMAGE_FOLDER, $filePath);
        $fullPath                       = $img->getFullPath();
        $file->fields->file             = $fullPath;
        $file->fields->size             = filesize($fullPath);
        $fileInfo                       = finfo_open(FILEINFO_MIME_TYPE);
        $file->fields->media_encoding   = finfo_file($fileInfo, $fullPath);
        finfo_close($fileInfo);
        $location = $this->article->getPublisher()->getContentMediaImage()->defaultLocation;
        $file->addLocation($location);

        MMSynchContentPublisher::getInstance()->publish($file);
        $img->setCanArchived();

        $replacement = '<img src="' . '/newsletter/image/' . $file->id . '/' . $this->article->getLanguage() . '/fmc' . '" alt="' . $attributes['legend'] . '" />';

        return sprintf($replacement, $file->id);
    }
コード例 #14
0
 public function updateLastcorrectjob()
 {
     try {
         setlocale(LC_TIME, "it_IT");
         date_default_timezone_set('Europe/Rome');
         $dateClientobjectsync = date_create();
         // echo("->timestamp->".date_timestamp_get($date)."<-");
         $timestamp = date_timestamp_get($dateClientobjectsync);
         $dateLastcorrectjobContentOptions = new SQLIContentOptions(array('class_identifier' => 'clientobjectsync', 'remote_id' => 'clientObjectSync-lastcorrectjob'));
         $dateLastcorrectjob = SQLIContent::create($dateLastcorrectjobContentOptions);
         $dateLastcorrectjob->fields->nome = 'MyclientObjectSync';
         // Assegnazione dell'attributo lastcorrectjob
         $dateLastcorrectjob->fields->lastcorrectjob = $timestamp;
         //Prova a recuperare l'ID Nodo: 43 Media [Cartella] dal content.ini
         $contentIni = eZINI::instance('content.ini');
         $idNodoMedia = 43;
         if ($contentIni->hasVariable('NodeSettings', 'MediaRootNode')) {
             $idNodoMedia = $contentIni->variable('NodeSettings', 'MediaRootNode');
         }
         $dateLastcorrectjob->addLocation(SQLILocation::fromNodeID($idNodoMedia));
         $dateLastcorrectjobId = $this->store($dateLastcorrectjob);
     } catch (Exception $exp) {
         echo 'Got Exception message on updateLastcorrectjob: ' . $exp->getMessage() . "\n";
         $this->ocLoggerUtil->addErrorMessage('Exception on objectController -  updateLastcorrectjob: ' . $exp->getMessage());
         $this->ocLoggerUtil->writeLogs();
         return false;
     }
 }
コード例 #15
0
    public static function create($options)
    {
        $contentOptions = array();
        if (isset($options['remote_id']))
            $contentOptions['remote_id'] = $options['remote_id'];

        if (isset($options['section_id']))
            $contentOptions['section_id'] = $options['section_id'];

        if (isset($options['creator_id']))
            $contentOptions['creator_id'] = $options['creator_id'];

        if (isset($options['language']))
            $contentOptions['language'] = $options['language'];

        if (isset($options['class_identifier']))
            $contentOptions['class_identifier'] = $options['class_identifier'];

        $content = SQLIContent::create( new SQLIContentOptions($contentOptions) );

        if (isset($contentOptions['language']))
        {
            if (!isset($content->fields[$contentOptions['language']]))
            {
                $content->addTranslation($contentOptions['language']);
            }

            $content->setActiveLanguage($contentOptions['language']);
        }

        if (isset($options['parent_node_id']))
        {
            $location = SQLILocation::fromNodeID( $options['parent_node_id'] );
            $content->addLocation($location);
        }

        if (isset($options['data_map']))
        {
            if (isset($options['data_map']['default']) && is_array($options['data_map']['default']))
            {
                foreach($options['data_map']['default'] as $attributeIdentifier => $attributeString)
                {
                    $content->fields->{$attributeIdentifier} = $attributeString;
                }
            }

            foreach($options['data_map'] as $language => $dataMap)
            {
                if ($language == 'default')
                    continue;

                if (!isset($content[$language]))
                    $content->addTranslation($language);

                foreach($dataMap as $attributeIdentifier => $attributeString)
                {
                    $content->fields[$language]->{$attributeIdentifier} = $attributeString;
                }
            }
        }

        if (isset($options['publish']) && $options['publish'])
        {
            MMSynchContentPublisher::getInstance()->publish($content);
        }

        return $content;
    }
コード例 #16
0
    /**
     * Change visibility of the method private to protected
     * @param SQLIContent $content
     * @return type
     */
    protected function createNewVersion( SQLIContent $content )
    {
        eZDebug::accumulatorStart( 'sqlicontentpublisher_version', 'sqlicontentpublisher', 'Version creation' );
        $contentObject = $content->getRawContentObject();

        if( $content->isNew() )
        {
            $nodeAssignment = $this->createNodeAssignmentForContent( $content, $this->options['parent_node_id'], true ); // Main node assignment for new object
            $version        = $contentObject->currentVersion();

            $version->setAttribute( 'modified', eZDateTime::currentTimeStamp() );
            $version->setAttribute( 'status', eZContentObjectVersion::STATUS_DRAFT );
            $version->store();
        }
        else
        {
            $version = $content->getDraft();
        }

        eZDebug::accumulatorStop( 'sqlicontentpublisher_version' );

        return $version;
    }