当前位置: 首页>>代码示例>>PHP>>正文


PHP PublicFileManager::copyJournalFile方法代码示例

本文整理汇总了PHP中PublicFileManager::copyJournalFile方法的典型用法代码示例。如果您正苦于以下问题:PHP PublicFileManager::copyJournalFile方法的具体用法?PHP PublicFileManager::copyJournalFile怎么用?PHP PublicFileManager::copyJournalFile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PublicFileManager的用法示例。


在下文中一共展示了PublicFileManager::copyJournalFile方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: handleArticleCoverNode

 function handleArticleCoverNode(&$journal, &$coverNode, &$article, &$errors, $isCommandLine)
 {
     $errors = array();
     $hasErrors = false;
     $journalSupportedLocales = array_keys($journal->getSupportedLocaleNames());
     // => journal locales must be set up before
     $journalPrimaryLocale = $journal->getPrimaryLocale();
     $locale = $coverNode->getAttribute('locale');
     if ($locale == '') {
         $locale = $journalPrimaryLocale;
     } elseif (!in_array($locale, $journalSupportedLocales)) {
         $errors[] = array('plugins.importexport.native.import.error.coverLocaleUnsupported', array('issueTitle' => $issue->getIssueIdentification(), 'locale' => $locale));
         return false;
     }
     $article->setShowCoverPage(1, $locale);
     if ($node = $coverNode->getChildByName('altText')) {
         $article->setCoverPageAltText($node->getValue(), $locale);
     }
     if ($node = $coverNode->getChildByName('image')) {
         import('classes.file.PublicFileManager');
         $publicFileManager = new PublicFileManager();
         $newName = 'cover_article_' . $article->getId() . "_{$locale}" . '.';
         if ($href = $node->getChildByName('href')) {
             $url = $href->getAttribute('src');
             if ($isCommandLine || NativeImportDom::isAllowedMethod($url)) {
                 if ($isCommandLine && NativeImportDom::isRelativePath($url)) {
                     // The command-line tool does a chdir; we need to prepend the original pathname to relative paths so we're not looking in the wrong place.
                     $url = PWD . '/' . $url;
                 }
                 $originalName = basename($url);
                 $newName .= $publicFileManager->getExtension($originalName);
                 if (!$publicFileManager->copyJournalFile($journal->getId(), $url, $newName)) {
                     $errors[] = array('plugins.importexport.native.import.error.couldNotCopy', array('url' => $url));
                     $hasErrors = true;
                 }
                 $article->setFileName($newName, $locale);
                 $article->setOriginalFileName($publicFileManager->truncateFileName($originalName, 127), $locale);
             }
         }
         if ($embed = $node->getChildByName('embed')) {
             if (($type = $embed->getAttribute('encoding')) !== 'base64') {
                 $errors[] = array('plugins.importexport.native.import.error.unknownEncoding', array('type' => $type));
                 $hasErrors = true;
             } else {
                 $originalName = $embed->getAttribute('filename');
                 $newName .= $publicFileManager->getExtension($originalName);
                 $article->setFileName($newName, $locale);
                 $article->setOriginalFileName($publicFileManager->truncateFileName($originalName, 127), $locale);
                 if ($publicFileManager->writeJournalFile($journal->getId(), $newName, base64_decode($embed->getValue())) === false) {
                     $errors[] = array('plugins.importexport.native.import.error.couldNotWriteFile', array('originalName' => $originalName));
                     $hasErrors = true;
                 }
             }
         }
         // Store the image dimensions.
         list($width, $height) = getimagesize($publicFileManager->getJournalFilesPath($journal->getId()) . '/' . $newName);
         $article->setWidth($width, $locale);
         $article->setHeight($height, $locale);
     }
     if ($hasErrors) {
         return false;
     }
     return true;
 }
开发者ID:ingmarschuster,项目名称:MindResearchRepository,代码行数:64,代码来源:NativeImportDom.inc.php

示例2: execute

 /**
  * Save issue settings.
  * @param $request PKPRequest
  * @return int Issue ID for created/updated issue
  */
 function execute($request)
 {
     $journal = $request->getJournal();
     $issueDao = DAORegistry::getDAO('IssueDAO');
     if ($this->issue) {
         $isNewIssue = false;
         $issue = $this->issue;
     } else {
         $issue = $issueDao->newDataObject();
         $isNewIssue = true;
     }
     $volume = $this->getData('volume');
     $number = $this->getData('number');
     $year = $this->getData('year');
     $issue->setJournalId($journal->getId());
     $issue->setTitle($this->getData('title'), null);
     // Localized
     $issue->setVolume(empty($volume) ? 0 : $volume);
     $issue->setNumber(empty($number) ? 0 : $number);
     $issue->setYear(empty($year) ? 0 : $year);
     if (!$isNewIssue) {
         $issue->setDatePublished($this->getData('datePublished'));
     }
     $issue->setDescription($this->getData('description'), null);
     // Localized
     $issue->setStoredPubId('publisher-id', $this->getData('publicIssueId'));
     $issue->setShowVolume($this->getData('showVolume'));
     $issue->setShowNumber($this->getData('showNumber'));
     $issue->setShowYear($this->getData('showYear'));
     $issue->setShowTitle($this->getData('showTitle'));
     $issue->setAccessStatus($this->getData('accessStatus') ? $this->getData('accessStatus') : ISSUE_ACCESS_OPEN);
     // See bug #6324
     if ($this->getData('enableOpenAccessDate')) {
         $issue->setOpenAccessDate($this->getData('openAccessDate'));
     } else {
         $issue->setOpenAccessDate(null);
     }
     // consider the additional field names from the public identifer plugins
     import('classes.plugins.PubIdPluginHelper');
     $pubIdPluginHelper = new PubIdPluginHelper();
     $pubIdPluginHelper->execute($this, $issue);
     // if issueId is supplied, then update issue otherwise insert a new one
     if (!$isNewIssue) {
         parent::execute();
         $issueDao->updateObject($issue);
     } else {
         $issue->setPublished(0);
         $issue->setCurrent(0);
         $issueDao->insertObject($issue);
     }
     // Copy an uploaded CSS file for the issue, if there is one.
     // (Must be done after insert for new issues as issue ID is in the filename.)
     if ($temporaryFileId = $this->getData('temporaryFileId')) {
         $user = $request->getUser();
         $temporaryFileDao = DAORegistry::getDAO('TemporaryFileDAO');
         $temporaryFile = $temporaryFileDao->getTemporaryFile($temporaryFileId, $user->getId());
         import('classes.file.PublicFileManager');
         $publicFileManager = new PublicFileManager();
         $newFileName = 'style_' . $issue->getId() . '.css';
         $publicFileManager->copyJournalFile($journal->getId(), $temporaryFile->getFilePath(), $newFileName);
         $issue->setStyleFileName($newFileName);
         $issue->setOriginalStyleFileName($publicFileManager->truncateFileName($temporaryFile->getOriginalFileName(), 127));
         $issueDao->updateObject($issue);
     }
 }
开发者ID:jalperin,项目名称:ojs,代码行数:70,代码来源:IssueForm.inc.php

示例3: execute

 /**
  * Save issue settings.
  * @param $request PKPRequest
  * @return int Issue ID for created/updated issue
  */
 function execute($request)
 {
     $journal = $request->getJournal();
     $issueDao = DAORegistry::getDAO('IssueDAO');
     if ($this->issue) {
         $isNewIssue = false;
         $issue = $this->issue;
     } else {
         $issue = $issueDao->newDataObject();
         $isNewIssue = true;
     }
     $volume = $this->getData('volume');
     $number = $this->getData('number');
     $year = $this->getData('year');
     $issue->setJournalId($journal->getId());
     $issue->setTitle($this->getData('title'), null);
     // Localized
     $issue->setVolume(empty($volume) ? 0 : $volume);
     $issue->setNumber(empty($number) ? 0 : $number);
     $issue->setYear(empty($year) ? 0 : $year);
     if (!$isNewIssue) {
         $issue->setDatePublished($this->getData('datePublished'));
     }
     $issue->setDescription($this->getData('description'), null);
     // Localized
     $issue->setShowVolume($this->getData('showVolume'));
     $issue->setShowNumber($this->getData('showNumber'));
     $issue->setShowYear($this->getData('showYear'));
     $issue->setShowTitle($this->getData('showTitle'));
     $issue->setAccessStatus($this->getData('accessStatus') ? $this->getData('accessStatus') : ISSUE_ACCESS_OPEN);
     // See bug #6324
     if ($this->getData('enableOpenAccessDate')) {
         $issue->setOpenAccessDate($this->getData('openAccessDate'));
     } else {
         $issue->setOpenAccessDate(null);
     }
     // If it is a new issue, first insert it, then update the cover
     // because the cover name needs an issue id.
     if ($isNewIssue) {
         $issue->setPublished(0);
         $issue->setCurrent(0);
         $issueDao->insertObject($issue);
     }
     // Copy an uploaded cover file for the issue, if there is one.
     if ($temporaryFileId = $this->getData('temporaryFileId')) {
         $user = $request->getUser();
         $temporaryFileDao = DAORegistry::getDAO('TemporaryFileDAO');
         $temporaryFile = $temporaryFileDao->getTemporaryFile($temporaryFileId, $user->getId());
         import('classes.file.PublicFileManager');
         $publicFileManager = new PublicFileManager();
         $newFileName = 'cover_issue_' . $issue->getId() . $publicFileManager->getImageExtension($temporaryFile->getFileType());
         $journal = $request->getJournal();
         $publicFileManager->copyJournalFile($journal->getId(), $temporaryFile->getFilePath(), $newFileName);
         $issue->setCoverImage($newFileName);
         $issueDao->updateObject($issue);
     }
     $issue->setCoverImageAltText($this->getData('coverImageAltText'));
     parent::execute();
     $issueDao->updateObject($issue);
 }
开发者ID:bkroll,项目名称:ojs,代码行数:65,代码来源:IssueForm.inc.php

示例4: execute

 /**
  * Save changes to submission.
  * @param $request PKPRequest
  */
 function execute($request)
 {
     parent::execute($request);
     $submission = $this->getSubmission();
     $submissionDao = Application::getSubmissionDAO();
     // if section changed consider reordering
     $reorder = false;
     $oldSectionId = $submission->getSectionId();
     if ($oldSectionId != $this->getData('sectionId')) {
         $reorder = true;
         $submission->setSectionId($this->getData('sectionId'));
     }
     $locale = AppLocale::getLocale();
     // Copy an uploaded cover file for the article, if there is one.
     if ($temporaryFileId = $this->getData('temporaryFileId')) {
         $user = $request->getUser();
         $temporaryFileDao = DAORegistry::getDAO('TemporaryFileDAO');
         $temporaryFile = $temporaryFileDao->getTemporaryFile($temporaryFileId, $user->getId());
         import('classes.file.PublicFileManager');
         $publicFileManager = new PublicFileManager();
         $newFileName = 'article_' . $submission->getId() . '_cover_' . $locale . $publicFileManager->getImageExtension($temporaryFile->getFileType());
         $journal = $request->getJournal();
         $publicFileManager->copyJournalFile($journal->getId(), $temporaryFile->getFilePath(), $newFileName);
         $submission->setCoverImage($newFileName, $locale);
     }
     $submission->setCoverImageAltText($this->getData('coverImageAltText'), $locale);
     $submissionDao->updateObject($submission);
     if ($reorder) {
         // see if it is a published article
         $publishedArticleDao = DAORegistry::getDAO('PublishedArticleDAO');
         $publishedArticle = $publishedArticleDao->getPublishedArticleByArticleId($submission->getId(), null, false);
         /* @var $publishedArticle PublishedArticle */
         if ($publishedArticle) {
             // Resequence the articles.
             $publishedArticle->setSequence(REALLY_BIG_NUMBER);
             $publishedArticleDao->updatePublishedArticle($publishedArticle);
             $publishedArticleDao->resequencePublishedArticles($submission->getSectionId(), $publishedArticle->getIssueId());
             // The reordering for the old section is not necessary, but for the correctness sake
             $publishedArticleDao->resequencePublishedArticles($oldSectionId, $publishedArticle->getIssueId());
         }
     }
     if ($submission->getDatePublished()) {
         import('classes.search.ArticleSearchIndex');
         ArticleSearchIndex::articleMetadataChanged($submission);
     }
 }
开发者ID:pkp,项目名称:ojs,代码行数:50,代码来源:SubmissionMetadataViewForm.inc.php

示例5: execute

 /**
  * Save issue settings.
  */
 function execute($request)
 {
     $issue = $this->issue;
     $issue->setCoverPageDescription($this->getData('coverPageDescription'), null);
     // Localized
     $issue->setCoverPageAltText($this->getData('coverPageAltText'), null);
     // Localized
     $showCoverPage = array_map(create_function('$arrayElement', 'return (int)$arrayElement;'), (array) $this->getData('showCoverPage'));
     foreach (array_keys($this->getData('coverPageDescription')) as $locale) {
         if (!array_key_exists($locale, $showCoverPage)) {
             $showCoverPage[$locale] = 0;
         }
     }
     $issue->setShowCoverPage($showCoverPage, null);
     // Localized
     $hideCoverPageArchives = array_map(create_function('$arrayElement', 'return (int)$arrayElement;'), (array) $this->getData('hideCoverPageArchives'));
     foreach (array_keys($this->getData('coverPageDescription')) as $locale) {
         if (!array_key_exists($locale, $hideCoverPageArchives)) {
             $hideCoverPageArchives[$locale] = 0;
         }
     }
     $issue->setHideCoverPageArchives($hideCoverPageArchives, null);
     // Localized
     $hideCoverPageCover = array_map(create_function('$arrayElement', 'return (int)$arrayElement;'), (array) $this->getData('hideCoverPageCover'));
     foreach (array_keys($this->getData('coverPageDescription')) as $locale) {
         if (!array_key_exists($locale, $hideCoverPageCover)) {
             $hideCoverPageCover[$locale] = 0;
         }
     }
     $issue->setHideCoverPageCover($hideCoverPageCover, null);
     // Localized
     parent::execute();
     $issueDao = DAORegistry::getDAO('IssueDAO');
     $issueDao->updateObject($issue);
     // Copy an uploaded cover file for the issue, if there is one.
     if ($temporaryFileId = $this->getData('temporaryFileId')) {
         $user = $request->getUser();
         $temporaryFileDao = DAORegistry::getDAO('TemporaryFileDAO');
         $temporaryFile = $temporaryFileDao->getTemporaryFile($temporaryFileId, $user->getId());
         import('classes.file.PublicFileManager');
         $publicFileManager = new PublicFileManager();
         $newFileName = 'cover_issue_' . $issue->getId() . '_' . $this->getFormLocale() . $publicFileManager->getImageExtension($temporaryFile->getFileType());
         $journal = $request->getJournal();
         $publicFileManager->copyJournalFile($journal->getId(), $temporaryFile->getFilePath(), $newFileName);
         $issue->setFileName($newFileName, $this->getFormLocale());
         $issue->setOriginalFileName($publicFileManager->truncateFileName($temporaryFile->getOriginalFileName(), 127), $this->getFormLocale());
         $issueDao->updateObject($issue);
     }
     return $issue->getId();
 }
开发者ID:mosvits,项目名称:ojs,代码行数:53,代码来源:CoverForm.inc.php

示例6: execute

 /**
  * Save changes to submission.
  * @param $request PKPRequest
  */
 function execute($request)
 {
     parent::execute($request);
     $submission = $this->getSubmission();
     $submissionDao = Application::getSubmissionDAO();
     $submission->setSectionId($this->getData('sectionId'));
     // Copy an uploaded cover file for the article, if there is one.
     if ($temporaryFileId = $this->getData('temporaryFileId')) {
         $user = $request->getUser();
         $temporaryFileDao = DAORegistry::getDAO('TemporaryFileDAO');
         $temporaryFile = $temporaryFileDao->getTemporaryFile($temporaryFileId, $user->getId());
         import('classes.file.PublicFileManager');
         $publicFileManager = new PublicFileManager();
         $newFileName = 'article_' . $submission->getId() . '_cover' . $publicFileManager->getImageExtension($temporaryFile->getFileType());
         $journal = $request->getJournal();
         $publicFileManager->copyJournalFile($journal->getId(), $temporaryFile->getFilePath(), $newFileName);
         $submission->setCoverImage($newFileName);
     }
     $submission->setCoverImageAltText($this->getData('coverImageAltText'));
     $submissionDao->updateObject($submission);
     if ($submission->getDatePublished()) {
         import('classes.search.ArticleSearchIndex');
         ArticleSearchIndex::articleMetadataChanged($submission);
     }
 }
开发者ID:bkroll,项目名称:ojs,代码行数:29,代码来源:SubmissionMetadataViewForm.inc.php

示例7: localizeArticleCoverImages

    /**
     * Localize article cover images.
     * @return boolean True indicates success.
     */
    function localizeArticleCoverImages()
    {
        $articleDao = DAORegistry::getDAO('ArticleDAO');
        $publicFileManager = new PublicFileManager();
        // remove strange old cover images with array values in the DB - from 3.alpha or 3.beta?
        $articleDao->update('DELETE FROM submission_settings WHERE setting_name = \'coverImage\' AND setting_type = \'object\'');
        // remove empty 3.0 cover images
        $articleDao->update('DELETE FROM submission_settings WHERE setting_name = \'coverImage\' AND locale = \'\' AND setting_value = \'\'');
        $articleDao->update('DELETE FROM submission_settings WHERE setting_name = \'coverImageAltText\' AND locale = \'\' AND setting_value = \'\'');
        // get cover image duplicates, from 2.4.x and 3.0
        $result = $articleDao->retrieve('SELECT DISTINCT ss1.submission_id, ss1.setting_value, s.context_id
			FROM submission_settings ss1
			LEFT JOIN submissions s ON (s.submission_id = ss1.submission_id)
			JOIN submission_settings ss2 ON (ss2.submission_id = ss1.submission_id AND ss2.setting_name = \'coverImage\')
			WHERE ss1.setting_name = \'fileName\'');
        // remove the old 2.4.x cover images, for which a new cover image exists
        while (!$result->EOF) {
            $row = $result->GetRowAssoc(false);
            $submissionId = $row['submission_id'];
            $oldFileName = $row['setting_value'];
            if ($publicFileManager->fileExists($publicFileManager->getContextFilesPath(ASSOC_TYPE_JOURNAL, $row['context_id']) . '/' . $oldFileName)) {
                $publicFileManager->removeJournalFile($row['journal_id'], $oldFileName);
            }
            $articleDao->update('DELETE FROM submission_settings WHERE submission_id = ? AND setting_name = \'fileName\' AND setting_value = ?', array((int) $submissionId, $oldFileName));
            $result->MoveNext();
        }
        $result->Close();
        // retrieve names for unlocalized article cover images
        $result = $articleDao->retrieve('SELECT ss.submission_id, ss.setting_value, j.journal_id, j.primary_locale
			FROM submission_settings ss, submissions s, journals j
			WHERE ss.setting_name = \'coverImage\' AND ss.locale = \'\'
				AND s.submission_id = ss.submission_id AND j.journal_id = s.context_id');
        // for all unlocalized article cover images
        // rename (copy + remove) the cover images files in the public folder,
        // considereing the locale (using the journal primary locale)
        while (!$result->EOF) {
            $row = $result->GetRowAssoc(false);
            $oldFileName = $row['setting_value'];
            $newFileName = str_replace('.', '_' . $row['primary_locale'] . '.', $oldFileName);
            if ($publicFileManager->fileExists($publicFileManager->getContextFilesPath(ASSOC_TYPE_JOURNAL, $row['journal_id']) . '/' . $oldFileName)) {
                $publicFileManager->copyJournalFile($row['journal_id'], $publicFileManager->getContextFilesPath(ASSOC_TYPE_JOURNAL, $row['journal_id']) . '/' . $oldFileName, $newFileName);
                $publicFileManager->removeJournalFile($row['journal_id'], $oldFileName);
            }
            $result->MoveNext();
        }
        $result->Close();
        $driver = $articleDao->getDriver();
        switch ($driver) {
            case 'mysql':
            case 'mysqli':
                // Update cover image names in the submission_settings table
                $articleDao->update('UPDATE submission_settings ss, submissions s, journals j
					SET ss.locale = j.primary_locale, ss.setting_value = CONCAT(LEFT( ss.setting_value, LOCATE(\'.\', ss.setting_value) - 1 ), \'_\', j.primary_locale, \'.\', SUBSTRING_INDEX(ss.setting_value,\'.\',-1))
					WHERE ss.setting_name = \'coverImage\' AND ss.locale = \'\' AND s.submission_id = ss.submission_id AND j.journal_id = s.context_id');
                // Update cover image alt texts in the submission_settings table
                $articleDao->update('UPDATE submission_settings ss, submissions s, journals j
					SET ss.locale = j.primary_locale
					WHERE ss.setting_name = \'coverImageAltText\' AND ss.locale = \'\' AND s.submission_id = ss.submission_id AND j.journal_id = s.context_id');
                break;
            case 'postgres':
                // Update cover image names in the submission_settings table
                $articleDao->update('UPDATE submission_settings
					SET locale = j.primary_locale, setting_value = REGEXP_REPLACE(submission_settings.setting_value, \'[\\.]\', CONCAT(\'_\', j.primary_locale, \'.\'))
					FROM submissions s, journals j
					WHERE submission_settings.setting_name = \'coverImage\' AND submission_settings.locale = \'\' AND s.submission_id = submission_settings.submission_id AND j.journal_id = s.context_id');
                // Update cover image alt texts in the submission_settings table
                $articleDao->update('UPDATE submission_settings
					SET locale = j.primary_locale
					FROM submissions s, journals j
					WHERE submission_settings.setting_name = \'coverImageAltText\' AND submission_settings.locale = \'\' AND s.submission_id = submission_settings.submission_id AND j.journal_id = s.context_id');
                break;
            default:
                fatalError('Unknown database type!');
        }
        $articleDao->flushCache();
        return true;
    }
开发者ID:pkp,项目名称:ojs,代码行数:81,代码来源:Upgrade.inc.php


注:本文中的PublicFileManager::copyJournalFile方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。