/**
  * Singleton
  * @return SQLIContentPublisher
  */
 public static function getInstance()
 {
     if (!self::$instance instanceof SQLIContentPublisher) {
         self::$instance = new SQLIContentPublisher();
     }
     return self::$instance;
 }
 /**
  * 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->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);
 }
 /**
  * (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);
 }
Example #5
0
// 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';
$content->fields['esl-ES']->name = 'Test ES5';
$content->fields['ger-DE']->name = 'Test DE5';
$options = new SQLIContentOptions(array('remote_id' => 'myremoteid'));
$content->setOptions($options);
$publisher = SQLIContentPublisher::getInstance();
$publisher->publish($content);
$script->shutdown();
 /**
  * Adds a location for content in content tree.
  * Content must has been published at least once
  * Enter description here ...
  * @param $parentLocation
  */
 public function addLocation(SQLILocation $parentLocation)
 {
     // First check if content is new.
     // If so, location will be registered as "initial" and added at publish time
     if ($this->isNew()) {
         $this->initialLocations[] = $parentLocation;
     } else {
         $publisher = SQLIContentPublisher::getInstance();
         $publisher->addLocationToContent($parentLocation, $this);
     }
 }
 /**
  * (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();
     }
     $defaultParentNodeID = $this->handlerConfArray['DefaultParentNodeID'];
     $title = (string) $row->title;
     $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 = str_replace('href="/', 'href="http://github.com/', $message);
     // Proxy method to SQLIContentUtils::getRichContent()
     $issueTicketID = $this->getIssueFromGitCommitMessage($title, strip_tags($message));
     // echo "\n\n"; print_r($issueTicketID); echo "\n\n";
     $content->fields->tags = $issueTicketID;
     //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);
 }
<?php

// Use admin
$user   = eZUser::fetchByName('admin');
$userID = $user->attribute( 'contentobject_id' );
eZUser::setCurrentlyLoggedInUser( $user, $userID );

$options = array(
    'modification_check'    => false,
    'update_null_field'     => true
);

SQLIContentPublisher::getInstance()->setOptions(new SQLIContentPublishOptions($options));

$synchronizer   = MMSynchronizer::instance();
$result         = $synchronizer->db->arrayQuery('SELECT ts.id as ts_id, ts.name as ts_name FROM taxonomy_source as ts;');

while(list(,$row) = each($result))
{
    try
    {
        $tag = MMSynchTag::create($row['ts_id'], $row['ts_name']);

        $identifier = str_replace('&', '_', str_replace(' ', '_', strtolower($row['ts_name'])));

        $cli->output('[' . $identifier . ']');
        $cli->output('TagId=' . $tag->attribute( 'id' ));
        $cli->output('TaxonomyId=' . $row['ts_id']);
        $cli->output();
    }
    catch (Exception $e)
 static function store($content)
 {
     $publisher = SQLIContentPublisher::getInstance();
     $publisher->publish($content);
     $id = $content->id;
     unset($content);
     return $id;
 }