예제 #1
0
 /**
  * Replace various variables in the code template with data
  * relevant to the assigned article.
  * @param PublishedArticle $publishedArticle
  */
 function replaceCodeVars($publishedArticle = null)
 {
     $application = Application::getApplication();
     $request = $application->getRequest();
     $router = $request->getRouter();
     $context = $request->getContext();
     $code = $this->getCode();
     $codeVariables = array('journalUrl' => $router->url($request, null, 'index'), 'journalName' => $context->getLocalizedName());
     if (isset($publishedArticle)) {
         $codeVariables = array_merge($codeVariables, array('articleUrl' => $router->url($request, null, 'article', 'view', $publishedArticle->getId()), 'articleTitle' => $publishedArticle->getLocalizedTitle()));
     }
     // Replace variables in message with values
     foreach ($codeVariables as $key => $value) {
         if (!is_object($value)) {
             $code = str_replace('{$' . $key . '}', $value, $code);
         }
     }
     $this->setCode($code);
 }
예제 #2
0
 /**
  * @covers PubObjectCache
  */
 public function testAddSeveralGalleys()
 {
     $nullVar = null;
     $cache = new PubObjectCache();
     $article = new PublishedArticle();
     $article->setId('2');
     $article->setIssueId('1');
     $articleGalley1 = new ArticleGalley();
     $articleGalley1->setId('3');
     $articleGalley1->setArticleId($article->getId());
     $articleGalley2 = new ArticleGalley();
     $articleGalley2->setId('4');
     $articleGalley2->setArticleId($article->getId());
     // Add galleys in the wrong order.
     $cache->add($articleGalley2, $article);
     $cache->add($articleGalley1, $article);
     $cache->markComplete('galleysByArticle', $article->getId());
     // Retrieve them in the right order.
     $retrievedGalleys = $cache->get('galleysByArticle', $article->getId());
     $expectedGalleys = array(3 => $articleGalley1, 4 => $articleGalley2);
     self::assertEquals($expectedGalleys, $retrievedGalleys);
     // And they should still be cached.
     self::assertTrue($cache->isCached('galleysByArticle', $article->getId()));
 }
예제 #3
0
 /**
  * Class-specific methods for published submissions.
  * @param PublishedArticle $submission
  * @param DOMElement $node
  * @return PublishedArticle
  */
 function populatePublishedSubmission($submission, $node)
 {
     $deployment = $this->getDeployment();
     $issue = $deployment->getIssue();
     if (empty($issue)) {
         $issueIdentificationNodes = $node->getElementsByTagName('issue_identification');
         if ($issueIdentificationNodes->length != 1) {
             $titleNodes = $node->getElementsByTagName('title');
             $deployment->addError(ASSOC_TYPE_SUBMISSION, $submission->getId(), __('plugins.importexport.native.import.error.issueIdentificationMissing', array('articleTitle' => $titleNodes->item(0)->textContent)));
         } else {
             $issueIdentificationNode = $issueIdentificationNodes->item(0);
             $issue = $this->parseIssueIdentification($issueIdentificationNode);
         }
     }
     $submission->setSequence($node->getAttribute('seq'));
     $submission->setAccessStatus($node->getAttribute('access_status'));
     if ($issue) {
         $submission->setIssueId($issue->getId());
     }
     return $submission;
 }