示例#1
0
    protected function populate()
    {
        parent::populate();

        $fileOrLinkPopulated = false;
        if (!empty($this->source['m_file']))
        {
            $this->file = MMSynchFileManager::fromRoot($this->getPublisher(), MMSynchFileManager::PDF_FOLDER, $this->source['m_file']);
            $this->content->fields->file = $this->file->getFullPath();
            $fileOrLinkPopulated = true;
        }
        if (!empty($this->source['pdf_link']))
        {
            $this->content->fields->link = $this->source['pdf_link'];
            $fileOrLinkPopulated = true;
        }

        if (!$fileOrLinkPopulated)
        {
            throw new MMSynchException("Either file or link should be populated for PDF file.");
        }
        $this->content->fields->source              = $this->source['pdf_source'];
        $this->content->fields->expiration_duration = $this->source['pdf_expiration_duration'];
        $this->content->fields->media_target        = $this->source['pdf_media_target'];
        $this->content->fields->link                = $this->source['pdf_link'];
    }
示例#2
0
    protected function populate()
    {
        parent::populate();

        $this->file                  = MMSynchFileManager::fromRoot($this->getPublisher(), MMSynchFileManager::FILE_FOLDER, $this->source['m_file']);
        $this->content->fields->file = $this->file->getFullPath();
        $this->content->fields->media_target        = $this->source['file_media_target'];
    }
示例#3
0
    protected function populate()
    {
        parent::populate();

        $this->file                             = MMSynchFileManager::fromRoot($this->getPublisher(), MMSynchFileManager::AUDIO_FOLDER, $this->source['m_file']);
        $this->content->fields->file            = sprintf('%s||%s', $this->file->getFullPath(), $this->getPublisher()->getFolder());
        $this->content->fields->screen_capture  = MMSynchHelper::binaryToFile($this->source['audio_screen_capture']);
        $this->content->fields->duration        = $this->source['audio_duration'];
    }
示例#4
0
    protected function populate()
    {
        parent::populate();

        $this->file                             = MMSynchFileManager::fromRoot($this->getPublisher(), MMSynchFileManager::IMAGE_FOLDER, $this->source['m_file']);
        $this->content->fields->file            = $this->file->getFullPath();
        $this->content->fields->original_size   = $this->source['i_original_size'];
        $this->content->fields->alternate_text  = $this->source['i_alternate_text'];
    }
    public static function setArticle(MMSynchArticle $article)
    {
        self::$article = $article;

        if (!isset(self::$filesByArticle[$article->remoteId()]))
        {
            self::$filesByArticle[$article->remoteId()] = array();
        }
    }
示例#6
0
    protected function getArchivePath()
    {
        if (!$this->archivePath)
        {
            $archivePathPart = array(
                MMSynchFileManager::getRootPath(),
                $this->origin,
                $this->publisherFolder,
                MMSynchFileManager::ARCHIVE_FOLDER,
                $this->folder,
                $this->fileName
            );

            $this->archivePath = implode('/', $archivePathPart);
        }

        return $this->archivePath;
    }
    protected function populate()
    {
        parent::populate();

        if(!is_null($this->source['html_media_file']) && $this->source['html_media_file'] != '')
        {
            $file                           = MMSynchFileManager::fromRoot($this->getPublisher(), MMSynchFileManager::HTML_FOLDER, $this->source['html_media_file']);
            $parser                         = new MMSynchHtmlMediaParser(self::getFileContent($file->getFullPath()), $this);
            $this->content->fields->text    = $parser->getRichContent();
        }
        else
        {
            $parser                         = new MMSynchHtmlMediaParser($this->source['html_media_html_content'], $this);
            $this->content->fields->text    = $parser->getRichContent();
        }

        $this->content->fields->title   = $this->source['html_media_headline'];
    }
示例#8
0
    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 media($attributes, $text, $tagName, $html, $embed = true)
    {
        if ( !isset($attributes['src']) || !isset($attributes['folder']) || !in_array($attributes['folder'], array('audio', 'videos')) )
        {
            throw new MMSynchException(sprintf('Mal formed media tag in core_content %s', $html));
        }

        $ids = array();
        if ( $attributes['folder'] == 'audio' && $this->article->source['a_related_inline_audio'] != "" )
        {
            $tableName = 'audio';
            $ids = explode(',', $this->article->source['a_related_inline_audio']);
        }
        elseif ( $attributes['folder'] == 'videos' && $this->article->source['a_related_inline_video'] != "" )
        {
            $tableName = 'video';
            $ids = explode(',', $this->article->source['a_related_inline_video']);
        }

        if ( count($ids) > 0 )
        {
            $filenamePos = strrpos($attributes['src'], '/');
            $fileName = substr($attributes['src'], $filenamePos ? $filenamePos + 1 : 0);

            $sql = '
                SELECT media.id as id, media.content_id as c_id, media.file as file, media.screen_capture as screen_capture, media.language as language
                FROM %s as media
                INNER JOIN content as c ON media.content_id = c.id
                WHERE media.id IN (%s) AND media.file like "%s";
            ';

            $result = MMSynchronizer::instance()->db->arrayQuery(sprintf($sql, $tableName, implode(',', $ids), '%' . $fileName));

            $screen_capture = null;
            
            if ( isset($attributes['screen_capture']) && $attributes['screen_capture'] != '' )
            {
                try
                {
                    $file = MMSynchFileManager::fromFileName($this->article->getOrigin(), $this->article->getPublisher(), MMSynchFileManager::IMAGE_FOLDER, $attributes['screen_capture']);
                    $screen_capture = file_get_contents($file->getFullPath());
                    $file->setCanArchived();
                }
                catch ( Exception $e )
                {
                    $this->article->addWarning($e->getMessage());
                }
            }

            while ( list(, $row) = each($result) )
            {
                if ( $tableName == 'audio' )
                {
                    $media = MMSynchMediaAudio::fetch($row['id']);
                    if($screen_capture)
                    {
                        $media->source['audio_screen_capture'] = $screen_capture;
                    }
                    elseif($row['screen_capture'])
                    {
                        $media->source['audio_screen_capture'] = $row['screen_capture'];
                    }
                }
                else
                {
                    $media = MMSynchMediaVideo::fetch($row['id']);
                    if($screen_capture)
                    {
                        $media->source['video_screen_capture'] = $screen_capture;
                    }
                    elseif($row['screen_capture'])
                    {
                        $media->source['video_screen_capture'] = $row['screen_capture'];
                    }
                }

                $content = $media->getContent();

                if ( !$content instanceof SQLIContent )
                {
                    throw new MMSynchException(sprintf('Media with id %s not synchronized', $row['id']));
                }

                if ( isset($attributes['view']) && $attributes['view'] == 'inline' )
                {
                    $replacement = '<embed-inline view="embed-inline" size="medium" id="eZObject_%s" />';
                }
                else
                {
                    $replacement = '<embed view="embed" size="medium" id="eZObject_%s" />';
                }

                $this->addRelatedMedia($content->attribute('id'), $row['language']);

                if($embed)
                {
                    return sprintf($replacement, $content->attribute('id'));
                }
                else
                {
                    return $content->attribute('id');
                }
            }
        }

        throw new MMSynchException(sprintf('Media with filename %s not have media table row', $attributes['src']));
    }
    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);
    }