/** * Assign parameters to template * @param $paramArray array */ function assignParams($paramArray = array()) { $submission = $this->submission; $application = PKPApplication::getApplication(); $request = $application->getRequest(); parent::assignParams(array_merge(array('submissionTitle' => strip_tags($submission->getLocalizedTitle()), 'submissionId' => $submission->getId(), 'submissionAbstract' => PKPString::html2text($submission->getLocalizedAbstract()), 'authorString' => strip_tags($submission->getAuthorString())), $paramArray)); }
/** * @see OAIMetadataFormat#toXml */ function toXml(&$record, $format = null) { $article = $record->getData('article'); $journal = $record->getData('journal'); $templateMgr = TemplateManager::getManager(); $templateMgr->assign(array('journal' => $journal, 'article' => $article, 'issue' => $record->getData('issue'), 'section' => $record->getData('section'))); $subjects = array_merge_recursive($this->stripAssocArray((array) $article->getDiscipline(null)), $this->stripAssocArray((array) $article->getSubject(null))); $templateMgr->assign(array('subject' => isset($subjects[$journal->getPrimaryLocale()]) ? $subjects[$journal->getPrimaryLocale()] : '', 'abstract' => PKPString::html2text($article->getAbstract($article->getLocale())), 'language' => AppLocale::get3LetterIsoFromLocale($article->getLocale()))); return $templateMgr->fetch(dirname(__FILE__) . '/record.tpl'); }
/** * @copydoc NotificationManagerDelegate::getNotificationMessage() */ public function getNotificationMessage($request, $notification) { assert($notification->getAssocType() == ASSOC_TYPE_QUERY); $queryDao = DAORegistry::getDAO('QueryDAO'); $query = $queryDao->getById($notification->getAssocId()); $headNote = $query->getHeadNote(); assert($headNote); switch ($notification->getType()) { case NOTIFICATION_TYPE_NEW_QUERY: $user = $headNote->getUser(); return __('submission.query.new', array('creatorName' => $user->getFullName(), 'noteContents' => substr(PKPString::html2text($headNote->getContents()), 0, 200), 'noteTitle' => substr($headNote->getTitle(), 0, 200))); case NOTIFICATION_TYPE_QUERY_ACTIVITY: $notes = $query->getReplies(null, NOTE_ORDER_ID, SORT_DIRECTION_DESC); $latestNote = $notes->next(); $user = $latestNote->getUser(); $notes->close(); return __('submission.query.activity', array('responderName' => $user->getFullName(), 'noteContents' => substr(PKPString::html2text($latestNote->getContents()), 0, 200), 'noteTitle' => substr($headNote->getTitle(), 0, 200))); default: assert(false); } }
/** * Send the email. * @return boolean */ function send() { if (HookRegistry::call('Mail::send', array($this))) { return; } // Replace all the private parameters for this message. $mailBody = $this->getBody(); if (is_array($this->privateParams)) { foreach ($this->privateParams as $name => $value) { $mailBody = str_replace($name, $value, $mailBody); } } require_once 'lib/pkp/lib/vendor/phpmailer/phpmailer/class.phpmailer.php'; $mailer = new PHPMailer(); $mailer->IsHTML(true); if (Config::getVar('email', 'smtp')) { $mailer->IsSMTP(); $mailer->Port = Config::getVar('email', 'smtp_port'); if (($s = Config::getVar('email', 'smtp_auth')) != '') { $mailer->SMTPSecure = $s; $mailer->SMTPAuth = true; } $mailer->Host = Config::getVar('email', 'smtp_server'); $mailer->Username = Config::getVar('email', 'smtp_username'); $mailer->Password = Config::getVar('email', 'smtp_password'); } $mailer->CharSet = Config::getVar('i18n', 'client_charset'); if (($t = $this->getContentType()) != null) { $mailer->ContentType = $t; } $mailer->XMailer = 'Public Knowledge Project Suite v2'; $mailer->WordWrap = MAIL_WRAP; foreach ((array) $this->getHeaders() as $header) { $mailer->AddCustomHeader($header['key'], $mailer->SecureHeader($header['content'])); } if (($s = $this->getEnvelopeSender()) != null) { $mailer->Sender = $s; } if (($f = $this->getFrom()) != null) { $mailer->SetFrom($f['email'], $f['name']); } if (($r = $this->getReplyTo()) != null) { $mailer->AddReplyTo($r['email'], $r['name']); } foreach ((array) $this->getRecipients() as $recipientInfo) { $mailer->AddAddress($recipientInfo['email'], $recipientInfo['name']); } foreach ((array) $this->getCcs() as $ccInfo) { $mailer->AddCC($ccInfo['email'], $ccInfo['name']); } foreach ((array) $this->getBccs() as $bccInfo) { $mailer->AddBCC($bccInfo['email'], $bccInfo['name']); } $mailer->Subject = $this->getSubject(); $mailer->Body = $mailBody; $mailer->AltBody = PKPString::html2text($mailBody); $remoteAddr = $mailer->SecureHeader(Request::getRemoteAddr()); if ($remoteAddr != '') { $mailer->AddCustomHeader("X-Originating-IP: {$remoteAddr}"); } foreach ((array) $this->getAttachments() as $attachmentInfo) { $mailer->AddAttachment($attachmentInfo['path'], $attachmentInfo['filename'], 'base64', $attachmentInfo['content-type']); } try { $mailer->Send(); } catch (phpmailerException $e) { error_log($mailer->ErrorInfo); return false; } return true; }
/** * Create a description text node. * @param $doc DOMDocument * @param $locale string * @param $description string * @return DOMElement */ function createOtherTextNode($doc, $locale, $description) { $deployment = $this->getDeployment(); $otherTextNode = $doc->createElementNS($deployment->getNamespace(), 'OtherText'); // Text Type $otherTextNode->appendChild($node = $doc->createElementNS($deployment->getNamespace(), 'TextTypeCode', O4DOI_TEXT_TYPE_MAIN_DESCRIPTION)); // Text $language = AppLocale::get3LetterIsoFromLocale($locale); assert(!empty($language)); $otherTextNode->appendChild($node = $doc->createElementNS($deployment->getNamespace(), 'Text', htmlspecialchars(PKPString::html2text($description), ENT_COMPAT, 'UTF-8'))); $node->setAttribute('textformat', O4DOI_TEXTFORMAT_ASCII); $node->setAttribute('language', $language); return $otherTextNode; }
/** * Import all free-text/review form reviews to paste into message * @param $args array * @param $request PKPRequest * @return JSONMessage JSON object */ function importPeerReviews($args, $request) { // Retrieve the authorized submission. $submission = $this->getAuthorizedContextObject(ASSOC_TYPE_SUBMISSION); // Retrieve the current review round. $reviewRound = $this->getAuthorizedContextObject(ASSOC_TYPE_REVIEW_ROUND); // Retrieve peer reviews. $reviewAssignmentDao = DAORegistry::getDAO('ReviewAssignmentDAO'); $submissionCommentDao = DAORegistry::getDAO('SubmissionCommentDAO'); $reviewFormResponseDao = DAORegistry::getDAO('ReviewFormResponseDAO'); $reviewFormElementDao = DAORegistry::getDAO('ReviewFormElementDAO'); $reviewAssignments = $reviewAssignmentDao->getBySubmissionId($submission->getId(), $reviewRound->getId()); $reviewIndexes = $reviewAssignmentDao->getReviewIndexesForRound($submission->getId(), $reviewRound->getId()); AppLocale::requireComponents(LOCALE_COMPONENT_PKP_SUBMISSION); $body = ''; $textSeparator = '------------------------------------------------------'; foreach ($reviewAssignments as $reviewAssignment) { // If the reviewer has completed the assignment, then import the review. if ($reviewAssignment->getDateCompleted() != null && !$reviewAssignment->getCancelled()) { // Get the comments associated with this review assignment $submissionComments = $submissionCommentDao->getSubmissionComments($submission->getId(), COMMENT_TYPE_PEER_REVIEW, $reviewAssignment->getId()); $body .= "<br><br>{$textSeparator}<br>"; // If it is an open review, show reviewer's name. if ($reviewAssignment->getReviewMethod() == SUBMISSION_REVIEW_METHOD_OPEN) { $body .= $reviewAssignment->getReviewerFullName() . "<br>\n"; } else { $body .= __('submission.comments.importPeerReviews.reviewerLetter', array('reviewerLetter' => PKPString::enumerateAlphabetically($reviewIndexes[$reviewAssignment->getId()]))) . "<br>\n"; } while ($comment = $submissionComments->next()) { // If the comment is viewable by the author, then add the comment. if ($comment->getViewable()) { $body .= PKPString::html2text($comment->getComments()) . "\n\n"; } } $body .= "<br>{$textSeparator}<br><br>"; if ($reviewFormId = $reviewAssignment->getReviewFormId()) { $reviewId = $reviewAssignment->getId(); $reviewFormElements = $reviewFormElementDao->getByReviewFormId($reviewFormId); if (!$submissionComments) { $body .= "{$textSeparator}\n"; $body .= __('submission.comments.importPeerReviews.reviewerLetter', array('reviewerLetter' => PKPString::enumerateAlphabetically($reviewIndexes[$reviewAssignment->getId()]))) . "\n\n"; } while ($reviewFormElement = $reviewFormElements->next()) { $body .= PKPString::html2text($reviewFormElement->getLocalizedQuestion()) . ": \n"; $reviewFormResponse = $reviewFormResponseDao->getReviewFormResponse($reviewId, $reviewFormElement->getId()); if ($reviewFormResponse) { $possibleResponses = $reviewFormElement->getLocalizedPossibleResponses(); if (in_array($reviewFormElement->getElementType(), $reviewFormElement->getMultipleResponsesElementTypes())) { if ($reviewFormElement->getElementType() == REVIEW_FORM_ELEMENT_TYPE_CHECKBOXES) { foreach ($reviewFormResponse->getValue() as $value) { $body .= "\t" . PKPString::html2text($possibleResponses[$value]) . "\n"; } } else { $body .= "\t" . PKPString::html2text($possibleResponses[$reviewFormResponse->getValue()]) . "\n"; } $body .= "\n"; } else { $body .= "\t" . PKPString::html2text($reviewFormResponse->getValue()) . "\n\n"; } } } $body .= "{$textSeparator}\n\n"; } } } if (empty($body)) { return new JSONMessage(false, __('editor.review.noReviews')); } else { return new JSONMessage(true, $body); } }
/** * Create descriptions node list. * @param $doc DOMDocument * @param $issue Issue * @param $article PublishedArticle * @param $galley Alley * @param $galleyFile SubmissionFile * @param $objectLocalePrecedence array * @return DOMElement|null Can be null if a size * cannot be identified for the given object. */ function createDescriptionsNode($doc, $issue, $article, $galley, $galleyFile, $objectLocalePrecedence) { $deployment = $this->getDeployment(); $descriptions = array(); switch (true) { case isset($galley): if (is_a($galleyFile, 'SupplementaryFile')) { $suppFileDesc = $this->getPrimaryTranslation($galleyFile->getDescription(null), $objectLocalePrecedence); if (!empty($suppFileDesc)) { $descriptions[DATACITE_DESCTYPE_OTHER] = $suppFileDesc; } } break; case isset($article): $articleAbstract = $this->getPrimaryTranslation($article->getAbstract(null), $objectLocalePrecedence); if (!empty($articleAbstract)) { $descriptions[DATACITE_DESCTYPE_ABSTRACT] = $articleAbstract; } break; case isset($issue): $issueDesc = $this->getPrimaryTranslation($issue->getDescription(null), $objectLocalePrecedence); if (!empty($issueDesc)) { $descriptions[DATACITE_DESCTYPE_OTHER] = $issueDesc; } $descriptions[DATACITE_DESCTYPE_TOC] = $this->getIssueToc($issue, $objectLocalePrecedence); break; default: assert(false); } if (isset($article)) { // Articles and galleys. $descriptions[DATACITE_DESCTYPE_SERIESINFO] = $this->getIssueInformation($issue, $objectLocalePrecedence); } $descriptionsNode = null; if (!empty($descriptions)) { $descriptionsNode = $doc->createElementNS($deployment->getNamespace(), 'descriptions'); foreach ($descriptions as $descType => $description) { $descriptionsNode->appendChild($node = $doc->createElementNS($deployment->getNamespace(), 'description', htmlspecialchars(PKPString::html2text($description), ENT_COMPAT, 'UTF-8'))); $node->setAttribute('descriptionType', $descType); } } return $descriptionsNode; }
/** * Create a contributor node. * @param $doc DOMDocument * @param $author Author * @param $objectLocalePrecedence array * @return DOMElement */ function createContributorNode($doc, $author, $objectLocalePrecedence) { $deployment = $this->getDeployment(); $contributorNode = $doc->createElementNS($deployment->getNamespace(), 'Contributor'); // Sequence number $seq = $author->getSequence(); assert(!empty($seq)); $contributorNode->appendChild($node = $doc->createElementNS($deployment->getNamespace(), 'SequenceNumber', $seq)); // Contributor role (mandatory) $contributorNode->appendChild($node = $doc->createElementNS($deployment->getNamespace(), 'ContributorRole', O4DOI_CONTRIBUTOR_ROLE_ACTUAL_AUTHOR)); // Person name (mandatory) $personName = $author->getFullName(); assert(!empty($personName)); $contributorNode->appendChild($node = $doc->createElementNS($deployment->getNamespace(), 'PersonName', $personName)); // Inverted person name $invertedPersonName = $author->getFullName(true); assert(!empty($invertedPersonName)); $contributorNode->appendChild($node = $doc->createElementNS($deployment->getNamespace(), 'PersonNameInverted', $invertedPersonName)); // Affiliation $affiliation = $this->getPrimaryTranslation($author->getAffiliation(null), $objectLocalePrecedence); if (!empty($affiliation)) { $affiliationNode = $doc->createElementNS($deployment->getNamespace(), 'ProfessionalAffiliation'); $affiliationNode->appendChild($node = $doc->createElementNS($deployment->getNamespace(), 'Affiliation', $affiliation)); $contributorNode->appendChild($affiliationNode); } // Biographical note $bioNote = $this->getPrimaryTranslation($author->getBiography(null), $objectLocalePrecedence); if (!empty($bioNote)) { $contributorNode->appendChild($node = $doc->createElementNS($deployment->getNamespace(), 'BiographicalNote', PKPString::html2text($bioNote))); } return $contributorNode; }
/** * @see DOIExportDom::generate() */ function &generate(&$object) { $falseVar = false; // Declare variables that will contain publication objects. $journal = $this->getJournal(); $issue = null; /* @var $issue Issue */ $article = null; /* @var $article PublishedArticle */ $galley = null; /* @var $galley ArticleGalley */ $articlesByIssue = null; $galleysByArticle = null; // Retrieve required publication objects (depends on the object to be exported). $pubObjects =& $this->retrievePublicationObjects($object); extract($pubObjects); // Identify an object implementing a SubmissionFile (if any). $submissionFile = $galley; // Identify the object locale. $objectLocalePrecedence = $this->getObjectLocalePrecedence($article, $galley); // The publisher is required. $publisher = $this->getPublisher($objectLocalePrecedence); // The publication date is required. $publicationDate = is_a($article, 'PublishedArticle') ? $article->getDatePublished() : null; if (empty($publicationDate)) { $publicationDate = $issue->getDatePublished(); } assert(!empty($publicationDate)); // Create the XML document and its root element. $doc =& $this->getDoc(); $rootElement =& $this->rootElement(); XMLCustomWriter::appendChild($doc, $rootElement); // DOI (mandatory) if (($identifierElement =& $this->_identifierElement($object)) === false) { return false; } XMLCustomWriter::appendChild($rootElement, $identifierElement); // Creators (mandatory) XMLCustomWriter::appendChild($rootElement, $this->_creatorsElement($object, $objectLocalePrecedence, $publisher)); // Title (mandatory) XMLCustomWriter::appendChild($rootElement, $this->_titlesElement($object, $objectLocalePrecedence)); // Publisher (mandatory) XMLCustomWriter::createChildWithText($this->getDoc(), $rootElement, 'publisher', $publisher); // Publication Year (mandatory) XMLCustomWriter::createChildWithText($this->getDoc(), $rootElement, 'publicationYear', date('Y', strtotime($publicationDate))); // Subjects if (!empty($article)) { $this->_appendNonMandatoryChild($rootElement, $this->_subjectsElement($article, $objectLocalePrecedence)); } // Dates XMLCustomWriter::appendChild($rootElement, $this->_datesElement($issue, $article, $submissionFile, $publicationDate)); // Language XMLCustomWriter::createChildWithText($this->getDoc(), $rootElement, 'language', AppLocale::get3LetterIsoFromLocale($objectLocalePrecedence[0])); // Resource Type $resourceTypeElement =& $this->_resourceTypeElement($object); XMLCustomWriter::appendChild($rootElement, $resourceTypeElement); // Alternate Identifiers $this->_appendNonMandatoryChild($rootElement, $this->_alternateIdentifiersElement($object, $issue, $article, $submissionFile)); // Related Identifiers $this->_appendNonMandatoryChild($rootElement, $this->_relatedIdentifiersElement($object, $articlesByIssue, $galleysByArticle, $issue, $article)); // Sizes $sizesElement =& $this->_sizesElement($object, $article); if ($sizesElement) { XMLCustomWriter::appendChild($rootElement, $sizesElement); } // Formats if (!empty($submissionFile)) { XMLCustomWriter::appendChild($rootElement, $this->_formatsElement($submissionFile)); } // Rights $rights = $this->getPrimaryTranslation($journal->getSetting('copyrightNotice', null), $objectLocalePrecedence); if (!empty($rights)) { XMLCustomWriter::createChildWithText($this->getDoc(), $rootElement, 'rights', PKPString::html2text($rights)); } // Descriptions $descriptionsElement =& $this->_descriptionsElement($issue, $article, $objectLocalePrecedence, $articlesByIssue); if ($descriptionsElement) { XMLCustomWriter::appendChild($rootElement, $descriptionsElement); } return $doc; }
/** * Create a content item element. * * @param $author Author * @param $objectLocalePrecedence array * * @return XMLNode|DOMImplementation */ function &_contributorElement(&$author, $objectLocalePrecedence) { $contributorElement =& XMLCustomWriter::createElement($this->getDoc(), 'Contributor'); // Sequence number $seq = $author->getSequence(); assert(!empty($seq)); XMLCustomWriter::createChildWithText($this->getDoc(), $contributorElement, 'SequenceNumber', $seq); // Contributor role (mandatory) XMLCustomWriter::createChildWithText($this->getDoc(), $contributorElement, 'ContributorRole', O4DOI_CONTRIBUTOR_ROLE_ACTUAL_AUTHOR); // Person name (mandatory) $personName = $author->getFullName(); assert(!empty($personName)); XMLCustomWriter::createChildWithText($this->getDoc(), $contributorElement, 'PersonName', $personName); // Inverted person name $invertedPersonName = $author->getFullName(true); assert(!empty($invertedPersonName)); XMLCustomWriter::createChildWithText($this->getDoc(), $contributorElement, 'PersonNameInverted', $invertedPersonName); // Affiliation $affiliation = $this->getPrimaryTranslation($author->getAffiliation(null), $objectLocalePrecedence); if (!empty($affiliation)) { $affiliationElement = XMLCustomWriter::createElement($this->getDoc(), 'ProfessionalAffiliation'); XMLCustomWriter::createChildWithText($this->getDoc(), $affiliationElement, 'Affiliation', $affiliation); XMLCustomWriter::appendChild($contributorElement, $affiliationElement); } // Biographical note $bioNote = $this->getPrimaryTranslation($author->getBiography(null), $objectLocalePrecedence); if (!empty($bioNote)) { XMLCustomWriter::createChildWithText($this->getDoc(), $contributorElement, 'BiographicalNote', PKPString::html2text($bioNote)); } return $contributorElement; }
/** * Create an XML element with a text node. * * FIXME: Move this to XMLCustomWriter? I leave the decision up to PKP... * * @param $name string * @param $value string * @param $attributes array An array with the attribute names as array * keys and attribute values as array values. * * @return XMLNode|DOMImplementation */ function &createElementWithText($name, $value, $attributes = array()) { $element =& XMLCustomWriter::createElement($this->getDoc(), $name); $elementContent =& XMLCustomWriter::createTextNode($this->getDoc(), PKPString::html2text($value)); XMLCustomWriter::appendChild($element, $elementContent); foreach ($attributes as $attributeName => $attributeValue) { XMLCustomWriter::setAttribute($element, $attributeName, $attributeValue); } return $element; }
/** * @copydoc Form::fetch() */ function fetch($request) { $context = $request->getContext(); $user = $request->getUser(); // Get the review method options. $reviewAssignmentDao = DAORegistry::getDAO('ReviewAssignmentDAO'); $reviewMethods = $reviewAssignmentDao->getReviewMethodsTranslationKeys(); $submission = $this->getSubmission(); $templateMgr = TemplateManager::getManager($request); $templateMgr->assign('reviewMethods', $reviewMethods); $templateMgr->assign('reviewerActions', $this->getReviewerFormActions()); $reviewFormDao = DAORegistry::getDAO('ReviewFormDAO'); $reviewForms = array(0 => __('editor.article.selectReviewForm')); $reviewFormsIterator = $reviewFormDao->getActiveByAssocId(Application::getContextAssocType(), $context->getId()); while ($reviewForm = $reviewFormsIterator->next()) { $reviewForms[$reviewForm->getId()] = $reviewForm->getLocalizedTitle(); } $templateMgr->assign('reviewForms', $reviewForms); $templateMgr->assign('emailVariables', array('reviewerName' => __('user.name'), 'responseDueDate' => __('reviewer.submission.responseDueDate'), 'reviewDueDate' => __('reviewer.submission.reviewDueDate'), 'submissionReviewUrl' => __('common.url'), 'reviewerUserName' => __('user.username'), 'contextName' => $context->getLocalizedName(), 'contextUrl' => __('common.url'), 'editorialContactSignature' => PKPString::stripUnsafeHtml($user->getContactSignature()), 'submissionTitle' => PKPString::stripUnsafeHtml($submission->getLocalizedTitle()), 'submissionAbstract' => PKPString::html2text($submission->getLocalizedAbstract()))); // Allow the default template $templateKeys[] = $this->_getMailTemplateKey($request->getContext()); // Determine if the current user can use any custom templates defined. $roleDao = DAORegistry::getDAO('RoleDAO'); $userRoles = $roleDao->getByUserId($user->getId(), $submission->getContextId()); foreach ($userRoles as $userRole) { if (in_array($userRole->getId(), array(ROLE_ID_MANAGER, ROLE_ID_SUB_EDITOR, ROLE_ID_ASSISTANT))) { $emailTemplateDao = DAORegistry::getDAO('EmailTemplateDAO'); $customTemplates = $emailTemplateDao->getCustomTemplateKeys(Application::getContextAssocType(), $submission->getContextId()); $templateKeys = array_merge($templateKeys, $customTemplates); break; } } foreach ($templateKeys as $templateKey) { $template = new SubmissionMailTemplate($submission, $templateKey, null, null, null, false); $template->assignParams(array()); $templates[$templateKey] = $template->getSubject(); } $templateMgr->assign('templates', $templates); // Get the reviewer user groups for the create new reviewer/enroll existing user tabs $context = $request->getContext(); $userGroupDao = DAORegistry::getDAO('UserGroupDAO'); /* @var $userGroupDao UserGroupDAO */ $reviewRound = $this->getReviewRound(); $reviewerUserGroups = $userGroupDao->getUserGroupsByStage($context->getId(), $reviewRound->getStageId(), false, false, ROLE_ID_REVIEWER); $userGroups = array(); while ($userGroup = $reviewerUserGroups->next()) { $userGroups[$userGroup->getId()] = $userGroup->getLocalizedName(); } $this->setData('userGroups', $userGroups); return parent::fetch($request); }
/** * @see Filter::process() * @param $pubObjects array Array of PublishedArticles * @return DOMDocument */ function &process(&$pubObjects) { // Create the XML document $doc = new DOMDocument('1.0', 'utf-8'); $doc->preserveWhiteSpace = false; $doc->formatOutput = true; $deployment = $this->getDeployment(); $context = $deployment->getContext(); $plugin = $deployment->getPlugin(); $cache = $plugin->getCache(); // Create the root node $rootNode = $this->createRootNode($doc); $doc->appendChild($rootNode); foreach ($pubObjects as $pubObject) { $issueId = $pubObject->getIssueId(); if ($cache->isCached('issues', $issueId)) { $issue = $cache->get('issues', $issueId); } else { $issueDao = DAORegistry::getDAO('IssueDAO'); /* @var $issueDao IssueDAO */ $issue = $issueDao->getById($issueId, $context->getId()); if ($issue) { $cache->add($issue, null); } } // Record $recordNode = $doc->createElement('record'); $rootNode->appendChild($recordNode); // Language $language = AppLocale::get3LetterIsoFromLocale($pubObject->getLocale()); if (!empty($language)) { $recordNode->appendChild($node = $doc->createElement('language', $language)); } // Publisher name (i.e. institution name) $publisher = $context->getSetting('publisherInstitution'); if (!empty($publisher)) { $recordNode->appendChild($node = $doc->createElement('publisher', htmlspecialchars($publisher, ENT_COMPAT, 'UTF-8'))); } // Journal's title (M) $journalTitle = $context->getName($context->getPrimaryLocale()); $recordNode->appendChild($node = $doc->createElement('journalTitle', htmlspecialchars($journalTitle, ENT_COMPAT, 'UTF-8'))); // Identification Numbers $issn = $context->getSetting('printIssn'); if (!empty($issn)) { $recordNode->appendChild($node = $doc->createElement('issn', $issn)); } $eissn = $context->getSetting('onlineIssn'); if (!empty($eissn)) { $recordNode->appendChild($node = $doc->createElement('eissn', $eissn)); } // Article's publication date, volume, issue if ($pubObject->getDatePublished()) { $recordNode->appendChild($node = $doc->createElement('publicationDate', $this->formatDate($pubObject->getDatePublished()))); } else { $recordNode->appendChild($node = $doc->createElement('publicationDate', $this->formatDate($issue->getDatePublished()))); } $volume = $issue->getVolume(); if (!empty($volume) && $issue->getShowVolume()) { $recordNode->appendChild($node = $doc->createElement('volume', htmlspecialchars($volume, ENT_COMPAT, 'UTF-8'))); } $issueNumber = $issue->getNumber(); if (!empty($issueNumber) && $issue->getShowNumber()) { $recordNode->appendChild($node = $doc->createElement('issue', htmlspecialchars($issueNumber, ENT_COMPAT, 'UTF-8'))); } /** --- FirstPage / LastPage (from PubMed plugin)--- * there is some ambiguity for online journals as to what * "page numbers" are; for example, some journals (eg. JMIR) * use the "e-location ID" as the "page numbers" in PubMed */ $pages = $pubObject->getPages(); if (preg_match("/([0-9]+)\\s*-\\s*([0-9]+)/i", $pages, $matches)) { // simple pagination (eg. "pp. 3-8") $recordNode->appendChild($node = $doc->createElement('startPage', htmlspecialchars($matches[1], ENT_COMPAT, 'UTF-8'))); $recordNode->appendChild($node = $doc->createElement('endPage', htmlspecialchars($matches[2], ENT_COMPAT, 'UTF-8'))); } elseif (preg_match("/(e[0-9]+)/i", $pages, $matches)) { // elocation-id (eg. "e12") $recordNode->appendChild($node = $doc->createElement('startPage', htmlspecialchars($matches[1], ENT_COMPAT, 'UTF-8'))); $recordNode->appendChild($node = $doc->createElement('endPage', htmlspecialchars($matches[1], ENT_COMPAT, 'UTF-8'))); } // DOI $doi = $pubObject->getStoredPubId('doi'); if (!empty($doi)) { $recordNode->appendChild($node = $doc->createElement('doi', htmlspecialchars($doi, ENT_COMPAT, 'UTF-8'))); } // publisherRecordId $recordNode->appendChild($node = $doc->createElement('publisherRecordId', htmlspecialchars($pubObject->getId(), ENT_COMPAT, 'UTF-8'))); // documentType $type = $pubObject->getType($pubObject->getLocale()); if (!empty($type)) { $recordNode->appendChild($node = $doc->createElement('documentType', htmlspecialchars($type, ENT_COMPAT, 'UTF-8'))); } // Article title foreach ((array) $pubObject->getTitle(null) as $locale => $title) { if (!empty($title)) { $recordNode->appendChild($node = $doc->createElement('title', htmlspecialchars($title, ENT_COMPAT, 'UTF-8'))); $node->setAttribute('language', AppLocale::get3LetterIsoFromLocale($locale)); } } // Authors and affiliations $authorsNode = $doc->createElement('authors'); $recordNode->appendChild($authorsNode); $affilList = $this->createAffiliationsList($pubObject->getAuthors(), $pubObject); foreach ($pubObject->getAuthors() as $author) { $authorsNode->appendChild($this->createAuthorNode($doc, $pubObject, $author, $affilList)); } if (!empty($affilList[0])) { $affilsNode = $doc->createElement('affiliationsList'); $recordNode->appendChild($affilsNode); for ($i = 0; $i < count($affilList); $i++) { $affilsNode->appendChild($node = $doc->createElement('affiliationName', htmlspecialchars($affilList[$i], ENT_COMPAT, 'UTF-8'))); $node->setAttribute('affiliationId', $i); } } // Abstract foreach ((array) $pubObject->getAbstract(null) as $locale => $abstract) { if (!empty($abstract)) { $recordNode->appendChild($node = $doc->createElement('abstract', htmlspecialchars(PKPString::html2text($abstract), ENT_COMPAT, 'UTF-8'))); $node->setAttribute('language', AppLocale::get3LetterIsoFromLocale($locale)); } } // FullText URL $recordNode->appendChild($node = $doc->createElement('fullTextUrl', htmlspecialchars(Request::url(null, 'article', 'view', $pubObject->getId()), ENT_COMPAT, 'UTF-8'))); $node->setAttribute('format', 'html'); // Keywords $keywordsNode = $doc->createElement('keywords'); $recordNode->appendChild($keywordsNode); $subjects = array_map('trim', explode(';', $pubObject->getSubject($pubObject->getLocale()))); foreach ($subjects as $keyword) { if (!empty($keyword)) { $keywordsNode->appendChild($node = $doc->createElement('keyword', htmlspecialchars($keyword, ENT_COMPAT, 'UTF-8'))); } } } return $doc; }
/** * @copydoc ReportPlugin::display() */ function display($args, $request) { $journal = $request->getJournal(); $journalId = $journal->getId(); $userDao = DAORegistry::getDAO('UserDAO'); $countryDao = DAORegistry::getDAO('CountryDAO'); $subscriptionTypeDao = DAORegistry::getDAO('SubscriptionTypeDAO'); $individualSubscriptionDao = DAORegistry::getDAO('IndividualSubscriptionDAO'); $institutionalSubscriptionDao = DAORegistry::getDAO('InstitutionalSubscriptionDAO'); header('content-type: text/comma-separated-values'); header('content-disposition: attachment; filename=subscriptions-' . date('Ymd') . '.csv'); $fp = fopen('php://output', 'wt'); // Columns for individual subscriptions $columns = array(__('subscriptionManager.individualSubscriptions')); fputcsv($fp, array_values($columns)); $columnsCommon = array('subscription_id' => __('common.id'), 'status' => __('subscriptions.status'), 'type' => __('common.type'), 'format' => __('subscriptionTypes.format'), 'date_start' => __('manager.subscriptions.dateStart'), 'date_end' => __('manager.subscriptions.dateEnd'), 'membership' => __('manager.subscriptions.membership'), 'reference_number' => __('manager.subscriptions.referenceNumber'), 'notes' => __('common.notes')); $columnsIndividual = array('name' => __('user.name'), 'mailing_address' => __('common.mailingAddress'), 'country' => __('common.country'), 'email' => __('user.email'), 'phone' => __('user.phone')); $columns = array_merge($columnsCommon, $columnsIndividual); // Write out individual subscription column headings to file fputcsv($fp, array_values($columns)); // Iterate over individual subscriptions and write out each to file $individualSubscriptions = $individualSubscriptionDao->getSubscriptionsByJournalId($journalId); while ($subscription = $individualSubscriptions->next()) { $user = $userDao->getById($subscription->getUserId()); $subscriptionType = $subscriptionTypeDao->getSubscriptionType($subscription->getTypeId()); foreach ($columns as $index => $junk) { switch ($index) { case 'subscription_id': $columns[$index] = $subscription->getId(); break; case 'status': $columns[$index] = $subscription->getStatusString(); break; case 'type': $columns[$index] = $subscription->getSubscriptionTypeSummaryString(); break; case 'format': $columns[$index] = __($subscriptionType->getFormatString()); break; case 'date_start': $columns[$index] = $subscription->getDateStart(); break; case 'date_end': $columns[$index] = $subscription->getDateEnd(); break; case 'membership': $columns[$index] = $subscription->getMembership(); break; case 'reference_number': $columns[$index] = $subscription->getReferenceNumber(); break; case 'notes': $columns[$index] = PKPString::html2text($subscription->getNotes()); break; case 'name': $columns[$index] = $user->getFullName(); break; case 'mailing_address': $columns[$index] = PKPString::html2text($user->getMailingAddress()); break; case 'country': $columns[$index] = $countryDao->getCountry($user->getCountry()); break; case 'email': $columns[$index] = $user->getEmail(); break; case 'phone': $columns[$index] = $user->getPhone(); break; default: $columns[$index] = ''; } } fputcsv($fp, $columns); } // Columns for institutional subscriptions $columns = array(''); fputcsv($fp, array_values($columns)); $columns = array(__('subscriptionManager.institutionalSubscriptions')); fputcsv($fp, array_values($columns)); $columnsInstitution = array('institution_name' => __('manager.subscriptions.institutionName'), 'institution_mailing_address' => __('plugins.reports.subscriptions.institutionMailingAddress'), 'domain' => __('manager.subscriptions.domain'), 'ip_ranges' => __('plugins.reports.subscriptions.ipRanges'), 'contact' => __('manager.subscriptions.contact'), 'mailing_address' => __('common.mailingAddress'), 'country' => __('common.country'), 'email' => __('user.email'), 'phone' => __('user.phone')); $columns = array_merge($columnsCommon, $columnsInstitution); // Write out institutional subscription column headings to file fputcsv($fp, array_values($columns)); // Iterate over institutional subscriptions and write out each to file $institutionalSubscriptions =& $institutionalSubscriptionDao->getSubscriptionsByJournalId($journalId); while ($subscription = $institutionalSubscriptions->next()) { $user = $userDao->getById($subscription->getUserId()); $subscriptionType = $subscriptionTypeDao->getSubscriptionType($subscription->getTypeId()); foreach ($columns as $index => $junk) { switch ($index) { case 'subscription_id': $columns[$index] = $subscription->getId(); break; case 'status': $columns[$index] = $subscription->getStatusString(); break; case 'type': $columns[$index] = $subscription->getSubscriptionTypeSummaryString(); break; case 'format': $columns[$index] = __($subscriptionType->getFormatString()); break; case 'date_start': $columns[$index] = $subscription->getDateStart(); break; case 'date_end': $columns[$index] = $subscription->getDateEnd(); break; case 'membership': $columns[$index] = $subscription->getMembership(); break; case 'reference_number': $columns[$index] = $subscription->getReferenceNumber(); break; case 'notes': $columns[$index] = PKPString::html2text($subscription->getNotes()); break; case 'institution_name': $columns[$index] = $subscription->getInstitutionName(); break; case 'institution_mailing_address': $columns[$index] = PKPString::html2text($subscription->getInstitutionMailingAddress()); break; case 'domain': $columns[$index] = $subscription->getDomain(); break; case 'ip_ranges': $columns[$index] = $this->_formatIPRanges($subscription->getIPRanges()); break; case 'contact': $columns[$index] = $user->getFullName(); break; case 'mailing_address': $columns[$index] = PKPString::html2text($user->getMailingAddress()); break; case 'country': $columns[$index] = $countryDao->getCountry($user->getCountry()); break; case 'email': $columns[$index] = $user->getEmail(); break; case 'phone': $columns[$index] = $user->getPhone(); break; default: $columns[$index] = ''; } } fputcsv($fp, $columns); } fclose($fp); }
/** * Auto-fill the DOAJ form. * @param $journal object */ function contact($journal, $send = false) { $request = $this->getRequest(); $user = $request->getUser(); $issn = $journal->getSetting('printIssn'); $paramArray = array('name' => $user->getFullName(), 'email' => $user->getEmail(), 'title' => $journal->getLocalizedName(), 'description' => PKPString::html2text($journal->getLocalizedSetting('focusScopeDesc')), 'url' => $request->url($journal->getPath()), 'charging' => $journal->getSetting('submissionFee') > 0 ? 'Y' : 'N', 'issn' => $issn, 'eissn' => $journal->getSetting('onlineIssn'), 'pub' => $journal->getSetting('publisherInstitution'), 'language' => AppLocale::getLocale(), 'keywords' => $journal->getLocalizedSetting('searchKeywords'), 'contact_person' => $journal->getSetting('contactName'), 'contact_email' => $journal->getSetting('contactEmail')); $url = 'http://www.doaj.org/doaj?func=suggest&owner=1'; foreach ($paramArray as $name => $value) { $url .= '&' . urlencode($name) . '=' . urlencode($value); } $request->redirectUrl($url); }
/** * Create a title node. * @param $doc DOMDocument * @param $locale string e.g. 'en_US' * @param $localizedTitle string * @param $titleType string One of the O4DOI_TITLE_TYPE_* constants. * @return DOMElement */ function createTitleNode($doc, $locale, $localizedTitle, $titleType) { $deployment = $this->getDeployment(); $titleNode = $doc->createElementNS($deployment->getNamespace(), 'Title'); // Text format $titleNode->setAttribute('textformat', O4DOI_TEXTFORMAT_ASCII); // Language $language = AppLocale::get3LetterIsoFromLocale($locale); assert(!empty($language)); $titleNode->setAttribute('language', $language); // Title type (mandatory) $titleNode->appendChild($node = $doc->createElementNS($deployment->getNamespace(), 'TitleType', $titleType)); // Title text (mandatory) $titleNode->appendChild($node = $doc->createElementNS($deployment->getNamespace(), 'TitleText', PKPString::html2text($localizedTitle))); return $titleNode; }