Importer/PKP/ArticleFileImporter.php
public function importArticleFiles($article, $oldId, $slug)
    {
        $fileIdsSql = "SELECT DISTINCT file_id FROM article_files WHERE article_id = :id";
        $fileIdsStatement = $this->dbalConnection->prepare($fileIdsSql);
        $fileIdsStatement->bindValue('id', $oldId);
        $fileIdsStatement->execute();

        $fileIds = $fileIdsStatement->fetchAll();
        $articleFiles = array();

        foreach ($fileIds as $fileId) {
            $articleFileSql = "SELECT file_id, file_type, original_file_name, revision FROM article_files" .
            " WHERE article_id = :id AND file_id = :fileId ORDER BY revision DESC LIMIT 1";
            $articleFileStatement = $this->dbalConnection->prepare($articleFileSql);
            $articleFileStatement->bindValue('fileId', $fileId['file_id']);
            $articleFileStatement->bindValue('id', $oldId);
            $articleFileStatement->execute();

            $articleFiles[] = $articleFileStatement->fetch();
        }
        
        foreach ($articleFiles as $articleFile) {
            $this->importArticleFile($articleFile, $oldId, $article, $slug);
        }
    }
public function importArticleFiles($article, $oldId, $slug)
    {
        $fileIdsSql = "SELECT DISTINCT file_id FROM article_files WHERE article_id = :id";
        $fileIdsStatement = $this->dbalConnection->prepare($fileIdsSql);
        $fileIdsStatement->bindValue('id', $oldId);
        $fileIdsStatement->execute();

        $fileIds = $fileIdsStatement->fetchAll();
        $articleFiles = array();

        foreach ($fileIds as $fileId) {
            $articleFileSql = "SELECT file_id, file_type, original_file_name, revision FROM article_files" .
            " WHERE article_id = :id AND file_id = :fileId ORDER BY revision DESC LIMIT 1";
            $articleFileStatement = $this->dbalConnection->prepare($articleFileSql);
            $articleFileStatement->bindValue('fileId', $fileId['file_id']);
            $articleFileStatement->bindValue('id', $oldId);
            $articleFileStatement->execute();

            $articleFiles[] = $articleFileStatement->fetch();
        }
        
        foreach ($articleFiles as $articleFile) {
            $this->importArticleFile($articleFile, $oldId, $article, $slug);
        }
    }
public function importArticleFiles ( $ article , $ oldId , $ slug ) { $ fileIdsSql = "SELECT DISTINCT file_id FROM article_files WHERE article_id = :id" ; $ fileIdsStatement = $ this -> dbalConnection -> prepare ( $ fileIdsSql ) ; $ fileIdsStatement -> bindValue ( 'id' , $ oldId ) ; $ fileIdsStatement -> execute ( ) ; $ fileIds = $ fileIdsStatement -> fetchAll ( ) ; $ articleFiles = array ( ) ; foreach ( $ fileIds as $ fileId ) { $ articleFileSql = "SELECT file_id, file_type, original_file_name, revision FROM article_files" . " WHERE article_id = :id AND file_id = :fileId ORDER BY revision DESC LIMIT 1" ; $ articleFileStatement = $ this -> dbalConnection -> prepare ( $ articleFileSql ) ; $ articleFileStatement -> bindValue ( 'fileId' , $ fileId [ 'file_id' ] ) ; $ articleFileStatement -> bindValue ( 'id' , $ oldId ) ; $ articleFileStatement -> execute ( ) ; $ articleFiles [ ] = $ articleFileStatement -> fetch ( ) ; } foreach ( $ articleFiles as $ articleFile ) { $ this -> importArticleFile ( $ articleFile , $ oldId , $ article , $ slug ) ; } }
Imports files of the given article
@param Article $article The Article whose files are going to be imported
@param int     $oldId   Old ID of the article
@param String  $slug    Journal's slug
@throws \Doctrine\DBAL\DBALException
Imports files of the given article