Ejemplo n.º 1
0
 protected function synchronize()
 {
     MMSynchLog::debug($this, 'Synchronization', true);
     return parent::synchronize();
 }
    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();
    }
Ejemplo n.º 3
0
    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;
    }