/** * (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); }
/** * (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); }
/** * 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); }
/** * (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); }
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(); }
<?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();
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; }
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); }
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; } }
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; }