public function __construct(SQLIImportHandlerOptions $options = null) { parent::__construct($options); if (isset($this->options['debug']) && $this->options['debug'] == '1') { MMSynchLog::$cli = $this->cli; MMSynchLog::$level = 4; } else { MMSynchLog::$level = 3; } $this->synchronizer = MMSynchronizer::instance(); $archive = $this->synchronizer->archive; if (isset($this->options['test']) && $this->options['test'] == '1') { $this->cli->warning('Test mode enabled : import_status not fill'); $this->synchronizer->test = true; $archive = false; } if (!$archive || isset($this->options['archive'])) { if ($this->options['archive'] == '1') { $this->cli->warning('Archiving enabled'); $archive = true; } elseif (!$archive || $this->options['archive'] == '0') { $this->cli->warning('Archiving disabled'); $archive = false; } } $this->synchronizer->archive = $archive; }
protected function populate() { parent::populate(); $id = false; if ($this->source['video_brightcoveid'] != '') { $id = $this->source['video_brightcoveid']; } $filepath = false; if ($this->source['m_file']) { try { $this->file = MMSynchFileManager::fromRoot($this->getPublisher(), MMSynchFileManager::VIDEO_FOLDER, $this->source['m_file']); $filepath = $this->file->getFullPath(); } catch(Exception $e) { if ($id) { MMSynchLog::warning($this, $e->getMessage()); } else { throw MMSynchException::fromException($e); } } } $this->content->fields->file = sprintf('%s|%s|%s', $filepath, $id, $this->getPublisher()->getFolder()); $this->content->fields->screen_capture = MMSynchHelper::binaryToFile($this->source['video_screen_capture']); $this->content->fields->duration = $this->source['video_duration']; $this->content->fields->original_size = $this->source['video_original_size']; }
protected function synchronize() { parent::synchronize(); $ini = eZIni::instance('sqliimport.ini'); $publishersOptions = array( 'publish' => true, 'data_map' => array('default' => array('name' => $this->source['p_path'])), 'language' => $this->source['pf_default_language'] ); // Master content folder $options = array( 'publish' => false, 'remote_id' => $this->remoteId(), 'class_identifier' => self::$class_identifier, 'parent_node_id' => $ini->variable('MMSynchPublisherFolder', 'ContentRootNodeId') ); $this->content = self::create(array_merge($publishersOptions, $options)); $this->populate(); //MMSynchLog::debug($this->content, 'Synchronize content folder #' . $this->content->defaultLocation->getNodeId()); $this->publish(); // Media content folder $options = array( 'remote_id' => $this->remoteIdMedia(), 'class_identifier' => 'folder', 'parent_node_id' => $ini->variable('MMSynchPublisherFolder', 'MediaRootNodeId') ); $this->contentMedia = self::create(array_merge($publishersOptions, $options)); MMSynchLog::debug($this->contentMedia, 'Synchronize media folder #' . $this->contentMedia->defaultLocation->getNodeId()); $this->contentMediaImage = self::create(array( 'publish' => true, 'class_identifier' => 'folder', 'remote_id' => $this->remoteIdMediaImage(), 'parent_node_id' => $this->contentMedia->defaultLocation->getNodeId(), 'data_map' => array('default' => array('name' => 'Image')), 'language' => $this->source['pf_default_language'] )); MMSynchLog::debug($this->contentMediaImage, 'Synchronize image media folder in #' . $this->contentMedia->defaultLocation->getNodeId()); $this->contentMediaFile = self::create(array( 'publish' => true, 'class_identifier' => 'folder', 'remote_id' => $this->remoteIdMediaFile(), 'parent_node_id' => $this->contentMedia->defaultLocation->getNodeId(), 'data_map' => array('default' => array('name' => 'File')), 'language' => $this->source['pf_default_language'] )); MMSynchLog::debug($this->contentMediaFile, 'Synchronize file media folder in #' . $this->contentMedia->defaultLocation->getNodeId()); $this->contentMediaDownFile = self::create(array( 'publish' => true, 'class_identifier' => 'folder', 'remote_id' => $this->remoteIdMediaDownFile(), 'parent_node_id' => $this->contentMedia->defaultLocation->getNodeId(), 'data_map' => array('default' => array('name' => 'Download File')), 'language' => $this->source['pf_default_language'] )); MMSynchLog::debug($this->contentMediaDownFile, 'Synchronize download file media folder in #' . $this->contentMedia->defaultLocation->getNodeId()); $this->contentMediaVideo = self::create(array( 'publish' => true, 'class_identifier' => 'folder', 'remote_id' => $this->remoteIdMediaVideo(), 'parent_node_id' => $this->contentMedia->defaultLocation->getNodeId(), 'data_map' => array('default' => array('name' => 'Video')), 'language' => $this->source['pf_default_language'] )); MMSynchLog::debug($this->contentMediaVideo, 'Synchronize video media folder in #' . $this->contentMedia->defaultLocation->getNodeId()); $this->contentMediaAudio = self::create(array( 'publish' => true, 'class_identifier' => 'folder', 'remote_id' => $this->remoteIdMediaAudio(), 'parent_node_id' => $this->contentMedia->defaultLocation->getNodeId(), 'data_map' => array('default' => array('name' => 'Audio')), 'language' => $this->source['pf_default_language'] )); MMSynchLog::debug($this->contentMediaAudio, 'Synchronize audio media folder in #' . $this->contentMedia->defaultLocation->getNodeId()); $this->contentMediaLink = self::create(array( 'publish' => true, 'class_identifier' => 'folder', 'remote_id' => $this->remoteIdMediaLink(), 'parent_node_id' => $this->contentMedia->defaultLocation->getNodeId(), 'data_map' => array('default' => array('name' => 'Link')), 'language' => $this->source['pf_default_language'] )); MMSynchLog::debug($this->contentMediaLink, 'Synchronize link media folder in #' . $this->contentMedia->defaultLocation->getNodeId()); $this->contentMediaHtml = self::create(array( 'publish' => true, 'class_identifier' => 'folder', 'remote_id' => $this->remoteIdMediaHtml(), 'parent_node_id' => $this->contentMedia->defaultLocation->getNodeId(), 'data_map' => array('default' => array('name' => 'Html')), 'language' => $this->source['pf_default_language'] )); MMSynchLog::debug($this->contentMediaHtml, 'Synchronize html media folder in #' . $this->contentMedia->defaultLocation->getNodeId()); $this->contentMediaHtmlTable = self::create(array( 'publish' => true, 'class_identifier' => 'folder', 'remote_id' => $this->remoteIdMediaHtmlTable(), 'parent_node_id' => $this->contentMedia->defaultLocation->getNodeId(), 'data_map' => array('default' => array('name' => 'Html Table')), 'language' => $this->source['pf_default_language'] )); MMSynchLog::debug($this->contentMediaHtml, 'Synchronize html table media folder in #' . $this->contentMedia->defaultLocation->getNodeId()); $this->contentMediaQuiz = self::create(array( 'publish' => true, 'class_identifier' => 'folder', 'remote_id' => $this->remoteIdMediaQuiz(), 'parent_node_id' => $this->contentMedia->defaultLocation->getNodeId(), 'data_map' => array('default' => array('name' => 'Quiz')), 'language' => $this->source['pf_default_language'] )); MMSynchLog::debug($this->contentMediaQuiz, 'Synchronize quiz media folder in #' . $this->contentMedia->defaultLocation->getNodeId()); $this->contentMediaHtmlMedia = self::create(array( 'publish' => true, 'class_identifier' => 'folder', 'remote_id' => $this->remoteIdMediaHtmlMedia(), 'parent_node_id' => $this->contentMedia->defaultLocation->getNodeId(), 'data_map' => array('default' => array('name' => 'Html Media')), 'language' => $this->source['pf_default_language'] )); MMSynchLog::debug($this->contentMediaHtmlMedia, 'Synchronize html_media media folder in #' . $this->contentMedia->defaultLocation->getNodeId()); // User content folder $options = array( 'remote_id' => $this->remoteIdUser(), 'class_identifier' => 'user_group', 'parent_node_id' => $ini->variable('MMSynchPublisherFolder', 'UserRootNodeId') ); $this->contentUser = self::create(array_merge($publishersOptions, $options)); MMSynchLog::debug($this->contentUser, 'Synchronize user folder #' . $this->contentUser->defaultLocation->getNodeId()); // Création de la taxonomy $this->createTaxonomy(); }
protected function publish() { parent::publish(); if ($this->synchronizer()->test == false) { $query = 'UPDATE content SET must_update=0 WHERE id=%s;'; self::synchronizer()->db->query(sprintf($query, $this->source['c_id'])); } MMSynchLog::endSection(); }
public function archive() { if ($this->archived) return true; if (!$this->getCanArchived()) { throw new MMSynchException(sprintf('File "%s" not ready to be archived', $this->getFullPath())); } if (MMSynchronizer::instance()->archive == false) { $moved = true; } else { $importINI = eZINI::instance('sqliimport.ini'); $modeUAT = false; if ( $importINI->hasVariable( 'XMLImportSettings', 'ModeUAT' ) && $importINI->variable( 'XMLImportSettings', 'ModeUAT' ) == 'enabled' ) { $modeUAT = true; } if ( $modeUAT ) { $moved = copy($this->getFullPath(), $this->getArchivePath()); } else { $moved = rename($this->getFullPath(), $this->getArchivePath()); } } if ($moved === false) { throw new Exception(sprintf('Fail to move "%s" to archive file "%s"', $this->fullPath, $this->getArchivePath())); } else { MMSynchLog::debug(false, sprintf('Archive %s to %s', $this->getFullPath(), $this->getArchivePath())); } $this->archived = true; return true; }
'use-session' => false, 'use-modules' => true, 'use-extensions' => true ) ); $script->startup(); $options = $script->getOptions( '[article:][force]', "", array( 'article' => 'Article Id in merck_model', 'force' => 'Force la mise à jour' )); $script->initialize(); $cli = eZCLI::instance(); MMSynchLog::$cli = $cli; MMSynchLog::$level = MMSynchLog::DEBUG; // Create lock $lockFileName = 'synch.lock'; if (file_exists($lockFileName)) { $tm = file_get_contents($lockFileName); if ($tm > (time() - (60 * 1))) { MMSynchLog::$cli->notice('== Synchronisation lock =='); $script->shutdown(); return; } } file_put_contents($lockFileName, time()); // user admin
public function addWarning($message) { MMSynchLog::warning($this, $message); }
'description' => ( 'Publisher folder synchronization' ), 'use-modules' => true, 'use-extensions' => true, 'debug-output' => false, ) ); $script->startup(); $options = $script->getOptions( '[clusterIdentifier:][auto]', "", array( 'clusterIdentifier' => "(optional) Cluster Identifier to filter Interactive List", 'auto' => "(optional) Cluster Identifier to filter Interactive List", ) ); $script->initialize(); $cli = new QuestionInteractiveCli(); MMSynchLog::$cli = eZCli::instance(); SQLIContentPublisher::getInstance()->setOptions(new SQLIContentPublishOptions(array( 'modification_check' => false, 'update_null_field' => true ) ) ); // Use admin $user = eZUser::fetchByName( 'admin' ); $userID = $user->attribute( 'contentobject_id' ); eZUser::setCurrentlyLoggedInUser( $user, $userID ); $whereClause = ""; $query = "select f.id, f.path as path from mm_application_has_publisher_folder as h
public function addWarning($message) { MMSynchLog::warning($this, $message); $this->warnings[] = $message; }
public function __destruct() { $warnings = self::archive('default'); foreach($warnings as $warning) { MMSynchLog::warning(null, $warning); } }