コード例 #1
0
 function &generatePubDateDom(&$doc, $pubdate, $pubstatus)
 {
     $root =& XMLCustomWriter::createElement($doc, 'PubDate');
     XMLCustomWriter::setAttribute($root, 'PubStatus', $pubstatus);
     XMLCustomWriter::createChildWithText($doc, $root, 'Year', date('Y', strtotime($pubdate)));
     XMLCustomWriter::createChildWithText($doc, $root, 'Month', date('m', strtotime($pubdate)), false);
     XMLCustomWriter::createChildWithText($doc, $root, 'Day', date('d', strtotime($pubdate)), false);
     return $root;
 }
コード例 #2
0
ファイル: UserExportDom.inc.php プロジェクト: JovanyJeff/hrp
 function &exportUsers(&$journal, &$users, $allowedRoles = null)
 {
     $roleDao =& DAORegistry::getDAO('RoleDAO');
     $doc =& XMLCustomWriter::createDocument('users', USERS_DTD_ID, USERS_DTD_URL);
     $root =& XMLCustomWriter::createElement($doc, 'users');
     foreach ($users as $user) {
         $userNode =& XMLCustomWriter::createElement($doc, 'user');
         XMLCustomWriter::createChildWithText($doc, $userNode, 'username', $user->getUserName(), false);
         $passwordNode =& XMLCustomWriter::createChildWithText($doc, $userNode, 'password', $user->getPassword());
         XMLCustomWriter::setAttribute($passwordNode, 'encrypted', Config::getVar('security', 'encryption'));
         XMLCustomWriter::createChildWithText($doc, $userNode, 'salutation', $user->getSalutation(), false);
         XMLCustomWriter::createChildWithText($doc, $userNode, 'first_name', $user->getFirstName());
         XMLCustomWriter::createChildWithText($doc, $userNode, 'middle_name', $user->getMiddleName(), false);
         XMLCustomWriter::createChildWithText($doc, $userNode, 'last_name', $user->getLastName());
         XMLCustomWriter::createChildWithText($doc, $userNode, 'initials', $user->getInitials(), false);
         XMLCustomWriter::createChildWithText($doc, $userNode, 'gender', $user->getGender(), false);
         XMLCustomWriter::createChildWithText($doc, $userNode, 'email', $user->getEmail());
         XMLCustomWriter::createChildWithText($doc, $userNode, 'url', $user->getUrl(), false);
         XMLCustomWriter::createChildWithText($doc, $userNode, 'phone', $user->getPhone(), false);
         XMLCustomWriter::createChildWithText($doc, $userNode, 'fax', $user->getFax(), false);
         XMLCustomWriter::createChildWithText($doc, $userNode, 'mailing_address', $user->getMailingAddress(), false);
         XMLCustomWriter::createChildWithText($doc, $userNode, 'country', $user->getCountry(), false);
         if (is_array($user->getAffiliation(null))) {
             foreach ($user->getAffiliation(null) as $locale => $value) {
                 $affiliationNode =& XMLCustomWriter::createChildWithText($doc, $userNode, 'affiliation', $value, false);
                 if ($affiliationNode) {
                     XMLCustomWriter::setAttribute($affiliationNode, 'locale', $locale);
                 }
                 unset($affiliationNode);
             }
         }
         if (is_array($user->getSignature(null))) {
             foreach ($user->getSignature(null) as $locale => $value) {
                 $signatureNode =& XMLCustomWriter::createChildWithText($doc, $userNode, 'signature', $value, false);
                 if ($signatureNode) {
                     XMLCustomWriter::setAttribute($signatureNode, 'locale', $locale);
                 }
                 unset($signatureNode);
             }
         }
         $interestsNode =& XMLCustomWriter::createChildWithText($doc, $userNode, 'interests', $user->getInterests(), false);
         if ($interestsNode) {
             XMLCustomWriter::setAttribute($interestsNode, 'locale', $locale);
         }
         if (is_array($user->getGossip(null))) {
             foreach ($user->getGossip(null) as $locale => $value) {
                 $gossipNode =& XMLCustomWriter::createChildWithText($doc, $userNode, 'gossip', $value, false);
                 if ($gossipNode) {
                     XMLCustomWriter::setAttribute($gossipNode, 'locale', $locale);
                 }
                 unset($gossipNode);
             }
         }
         if (is_array($user->getBiography(null))) {
             foreach ($user->getBiography(null) as $locale => $value) {
                 $biographyNode =& XMLCustomWriter::createChildWithText($doc, $userNode, 'biography', $value, false);
                 if ($biographyNode) {
                     XMLCustomWriter::setAttribute($biographyNode, 'locale', $locale);
                 }
                 unset($biographyNode);
             }
         }
         XMLCustomWriter::createChildWithText($doc, $userNode, 'locales', join(':', $user->getLocales()), false);
         $roles =& $roleDao->getRolesByUserId($user->getId(), $journal->getId());
         foreach ($roles as $role) {
             $rolePath = $role->getRolePath();
             if ($allowedRoles !== null && !in_array($rolePath, $allowedRoles)) {
                 continue;
             }
             $roleNode =& XMLCustomWriter::createElement($doc, 'role');
             XMLCustomWriter::setAttribute($roleNode, 'type', $rolePath);
             XMLCustomWriter::appendChild($userNode, $roleNode);
             unset($roleNode);
         }
         XMLCustomWriter::appendChild($root, $userNode);
     }
     XMLCustomWriter::appendChild($doc, $root);
     return $doc;
 }
コード例 #3
0
ファイル: EruditExportDom.inc.php プロジェクト: alenoosh/ojs
 function &generateArticleDom(&$doc, &$journal, &$issue, &$article, &$galley)
 {
     $unavailableString = Locale::translate('plugins.importexport.erudit.unavailable');
     $root =& XMLCustomWriter::createElement($doc, 'article');
     XMLCustomWriter::setAttribute($root, 'idprop', $journal->getJournalId() . '-' . $issue->getIssueId() . '-' . $article->getArticleId() . '-' . $galley->getGalleyId(), false);
     XMLCustomWriter::setAttribute($root, 'arttype', 'article');
     $lang = $article->getLanguage();
     XMLCustomWriter::setAttribute($root, 'lang', isset($lang) ? $lang : 'en');
     XMLCustomWriter::setAttribute($root, 'processing', 'cart');
     /* --- admin --- */
     $adminNode =& XMLCustomWriter::createElement($doc, 'admin');
     XMLCustomWriter::appendChild($root, $adminNode);
     /* --- articleinfo --- */
     $articleInfoNode =& XMLCustomWriter::createElement($doc, 'articleinfo');
     XMLCustomWriter::appendChild($adminNode, $articleInfoNode);
     // The first public ID should be a full URL to the article.
     $urlIdNode =& XMLCustomWriter::createChildWithText($doc, $articleInfoNode, 'idpublic', Request::url($journal->getPath(), 'article', 'view', array($article->getArticleId(), $galley->getGalleyId())));
     XMLCustomWriter::setAttribute($urlIdNode, 'scheme', 'sici');
     /* --- journal --- */
     $journalNode =& XMLCustomWriter::createElement($doc, 'journal');
     XMLCustomWriter::appendChild($adminNode, $journalNode);
     XMLCustomWriter::setAttribute($journalNode, 'id', 'ojs-' . $journal->getPath());
     XMLCustomWriter::createChildWithText($doc, $journalNode, 'jtitle', $journal->getJournalTitle());
     XMLCustomWriter::createChildWithText($doc, $journalNode, 'jshorttitle', $journal->getLocalizedSetting('initials'), false);
     if (!($printIssn = $journal->getSetting('printIssn'))) {
         $printIssn = $unavailableString;
     }
     XMLCustomWriter::createChildWithText($doc, $journalNode, 'idissn', $printIssn);
     if (!($onlineIssn = $journal->getSetting('onlineIssn'))) {
         $onlineIssn = $unavailableString;
     }
     XMLCustomWriter::createChildWithText($doc, $journalNode, 'iddigissn', $onlineIssn);
     /* --- issue --- */
     $issueNode =& XMLCustomWriter::createElement($doc, 'issue');
     XMLCustomWriter::appendChild($adminNode, $issueNode);
     XMLCustomWriter::setAttribute($issueNode, 'id', 'ojs-' . $issue->getBestIssueId());
     XMLCustomWriter::createChildWithText($doc, $issueNode, 'volume', $issue->getVolume(), false);
     XMLCustomWriter::createChildWithText($doc, $issueNode, 'issueno', $issue->getNumber(), false);
     $pubNode =& XMLCustomWriter::createElement($doc, 'pub');
     XMLCustomWriter::appendChild($issueNode, $pubNode);
     XMLCustomWriter::createChildWithText($doc, $pubNode, 'year', $issue->getYear());
     $digPubNode =& XMLCustomWriter::createElement($doc, 'digpub');
     XMLCustomWriter::appendChild($issueNode, $digPubNode);
     XMLCustomWriter::createChildWithText($doc, $digPubNode, 'date', EruditExportDom::formatDate($issue->getDatePublished()));
     /* --- Publisher & DTD --- */
     $publisherInstitution =& $journal->getSetting('publisherInstitution');
     $publisherNode =& XMLCustomWriter::createElement($doc, 'publisher');
     XMLCustomWriter::setAttribute($publisherNode, 'id', 'ojs-' . $journal->getJournalId() . '-' . $issue->getIssueId() . '-' . $article->getArticleId());
     XMLCustomWriter::appendChild($adminNode, $publisherNode);
     $publisherInstitution = $unavailableString;
     if (empty($publisherInstitution)) {
         $publisherInstitution = $unavailableString;
     }
     XMLCustomWriter::createChildWithText($doc, $publisherNode, 'orgname', $publisherInstitution);
     $digprodNode =& XMLCustomWriter::createElement($doc, 'digprod');
     XMLCustomWriter::createChildWithText($doc, $digprodNode, 'orgname', $publisherInstitution);
     XMLCustomWriter::setAttribute($digprodNode, 'id', 'ojs-prod-' . $journal->getJournalId() . '-' . $issue->getIssueId() . '-' . $article->getArticleId());
     XMLCustomWriter::appendChild($adminNode, $digprodNode);
     $digdistNode =& XMLCustomWriter::createElement($doc, 'digdist');
     XMLCustomWriter::createChildWithText($doc, $digdistNode, 'orgname', $publisherInstitution);
     XMLCustomWriter::setAttribute($digdistNode, 'id', 'ojs-dist-' . $journal->getJournalId() . '-' . $issue->getIssueId() . '-' . $article->getArticleId());
     XMLCustomWriter::appendChild($adminNode, $digdistNode);
     $dtdNode =& XMLCustomWriter::createElement($doc, 'dtd');
     XMLCustomWriter::appendChild($adminNode, $dtdNode);
     XMLCustomWriter::setAttribute($dtdNode, 'name', 'Erudit Article');
     XMLCustomWriter::setAttribute($dtdNode, 'version', '3.0.0');
     /* --- copyright --- */
     $copyright = $journal->getLocalizedSetting('copyrightNotice');
     XMLCustomWriter::createChildWithText($doc, $adminNode, 'copyright', empty($copyright) ? $unavailableString : $copyright);
     /* --- frontmatter --- */
     $frontMatterNode =& XMLCustomWriter::createElement($doc, 'frontmatter');
     XMLCustomWriter::appendChild($root, $frontMatterNode);
     $titleGroupNode =& XMLCustomWriter::createElement($doc, 'titlegr');
     XMLCustomWriter::appendChild($frontMatterNode, $titleGroupNode);
     XMLCustomWriter::createChildWithText($doc, $titleGroupNode, 'title', strip_tags($article->getArticleTitle()));
     /* --- authorgr --- */
     $authorGroupNode =& XMLCustomWriter::createElement($doc, 'authorgr');
     XMLCustomWriter::appendChild($frontMatterNode, $authorGroupNode);
     $authorNum = 1;
     foreach ($article->getAuthors() as $author) {
         $authorNode =& XMLCustomWriter::createElement($doc, 'author');
         XMLCustomWriter::appendChild($authorGroupNode, $authorNode);
         XMLCustomWriter::setAttribute($authorNode, 'id', 'ojs-' . $journal->getJournalId() . '-' . $issue->getIssueId() . '-' . $article->getArticleId() . '-' . $galley->getGalleyId() . '-' . $authorNum);
         $persNameNode =& XMLCustomWriter::createElement($doc, 'persname');
         XMLCustomWriter::appendChild($authorNode, $persNameNode);
         // Opatan Inc.
         foreach ((array) $author->getFirstName(null) as $locale => $firstName) {
             $firstName = strip_tags($firstName);
             $firstNameNode =& XMLCustomWriter::createElement($doc, 'firstname');
             XMLCustomWriter::setAttribute($firstNameNode, 'lang', $locale);
             XMLCustomWriter::appendChild($persNameNode, $firstNameNode);
             XMLCustomWriter::createChildWithText($doc, $firstNameNode, 'blocktext', $firstName);
             unset($firstNameNode);
         }
         // Opatan Inc.
         foreach ((array) $author->getMiddleName(null) as $locale => $middleName) {
             $middleName = strip_tags($middleName);
             $middleNameNode =& XMLCustomWriter::createElement($doc, 'middlename');
             XMLCustomWriter::setAttribute($middleNameNode, 'lang', $locale);
             XMLCustomWriter::appendChild($persNameNode, $middleNameNode);
             XMLCustomWriter::createChildWithText($doc, $middleNameNode, 'blocktext', $middleName);
             unset($middleNameNode);
         }
         // Opatan Inc.
         foreach ((array) $author->getLastName(null) as $locale => $lastName) {
             $lastName = strip_tags($lastName);
             $lastNameNode =& XMLCustomWriter::createElement($doc, 'familyname');
             XMLCustomWriter::setAttribute($lastNameNode, 'lang', $locale);
             XMLCustomWriter::appendChild($persNameNode, $lastNameNode);
             XMLCustomWriter::createChildWithText($doc, $lastNameNode, 'blocktext', $lastName);
             unset($lastNameNode);
         }
         // Opatan Inc.
         foreach ((array) $author->getAffiliation(null) as $locale => $affiliation) {
             $affiliation = strip_tags($affiliation);
             $affiliationNode =& XMLCustomWriter::createElement($doc, 'affiliation');
             XMLCustomWriter::setAttribute($affiliationNode, 'lang', $locale);
             XMLCustomWriter::appendChild($authorNode, $affiliationNode);
             XMLCustomWriter::createChildWithText($doc, $affiliationNode, 'blocktext', $affiliation, false);
         }
         $authorNum++;
     }
     /* --- abstract and keywords --- */
     foreach ((array) $article->getAbstract(null) as $locale => $abstract) {
         $abstract = strip_tags($abstract);
         $abstractNode =& XMLCustomWriter::createElement($doc, 'abstract');
         XMLCustomWriter::setAttribute($abstractNode, 'lang', $locale);
         XMLCustomWriter::appendChild($frontMatterNode, $abstractNode);
         XMLCustomWriter::createChildWithText($doc, $abstractNode, 'blocktext', $abstract);
         unset($abstractNode);
     }
     if ($keywords = $article->getArticleSubject()) {
         $keywordGroupNode =& XMLCustomWriter::createElement($doc, 'keywordgr');
         XMLCustomWriter::setAttribute($keywordGroupNode, 'lang', ($language = $article->getLanguage()) ? $language : 'en');
         foreach (explode(';', $keywords) as $keyword) {
             XMLCustomWriter::createChildWithText($doc, $keywordGroupNode, 'keyword', trim($keyword), false);
         }
         XMLCustomWriter::appendChild($frontMatterNode, $keywordGroupNode);
     }
     /* --- body --- */
     $bodyNode =& XMLCustomWriter::createElement($doc, 'body');
     XMLCustomWriter::appendChild($root, $bodyNode);
     import('file.ArticleFileManager');
     $articleFileManager =& new ArticleFileManager($article->getArticleId());
     $file =& $articleFileManager->getFile($galley->getFileId());
     $parser =& SearchFileParser::fromFile($file);
     if (isset($parser)) {
         if ($parser->open()) {
             // File supports text indexing.
             $textNode =& XMLCustomWriter::createElement($doc, 'text');
             XMLCustomWriter::appendChild($bodyNode, $textNode);
             while (($line = $parser->read()) !== false) {
                 $line = trim($line);
                 if ($line != '') {
                     XMLCustomWriter::createChildWithText($doc, $textNode, 'blocktext', $line, false);
                 }
             }
             $parser->close();
         }
     }
     return $root;
 }
コード例 #4
0
ファイル: DOAJExportDom.inc.php プロジェクト: reconciler/ojs
 /**
  * Generate the author export DOM tree.
  * @param $doc object DOM object
  * @param $journal object Journal
  * @param $issue object Issue
  * @param $article object Article
  * @param $author object Author
  * @param $affilList array List of author affiliations
  */
 function &generateAuthorDom(&$doc, &$journal, &$issue, &$article, &$author, &$affilList)
 {
     $root =& XMLCustomWriter::createElement($doc, 'author');
     XMLCustomWriter::createChildWithText($doc, $root, 'name', $author->getFullName());
     XMLCustomWriter::createChildWithText($doc, $root, 'email', $author->getEmail(), false);
     if (in_array($author->getLocalizedAffiliation(), $affilList) && !empty($affilList[0])) {
         XMLCustomWriter::createChildWithText($doc, $root, 'affiliationId', current(array_keys($affilList, $author->getLocalizedAffiliation())));
     }
     return $root;
 }
コード例 #5
0
 /**
  * Create a formats element list.
  * @param $articleFile ArticleFile
  * @return XMLNode|DOMImplementation|null Can be null if a format
  *  cannot be identified for the given object.
  */
 function &_formatsElement(&$articleFile)
 {
     $format = $articleFile->getFileType();
     if (empty($format)) {
         $nullVar = null;
         return $nullVar;
     }
     $formatsElement =& XMLCustomWriter::createElement($this->getDoc(), 'formats');
     XMLCustomWriter::createChildWithText($this->getDoc(), $formatsElement, 'format', $format);
     return $formatsElement;
 }
コード例 #6
0
ファイル: SolrWebService.inc.php プロジェクト: mosvits/ojs
 /**
  * Add the metadata XML of a single article to an
  * XML article list.
  *
  * @param $articleDoc DOMDocument
  * @param $article PublishedArticle
  * @param $journal Journal
  * @param $markToDelete boolean If true the returned XML
  *  will only contain a deletion marker.
  */
 function _addArticleXml(&$articleDoc, &$article, &$journal, $markToDelete = false)
 {
     assert(is_a($article, 'Article'));
     // Get the root node of the list.
     assert(is_a($articleDoc, 'DOMDocument'));
     $articleList =& $articleDoc->documentElement;
     // Create a new article node.
     $articleNode =& XMLCustomWriter::createElement($articleDoc, 'article');
     // Add ID information.
     XMLCustomWriter::setAttribute($articleNode, 'id', $article->getId());
     XMLCustomWriter::setAttribute($articleNode, 'sectionId', $article->getSectionId());
     XMLCustomWriter::setAttribute($articleNode, 'journalId', $article->getJournalId());
     XMLCustomWriter::setAttribute($articleNode, 'instId', $this->_instId);
     // Set the load action.
     $loadAction = $markToDelete ? 'delete' : 'replace';
     XMLCustomWriter::setAttribute($articleNode, 'loadAction', $loadAction);
     XMLCustomWriter::appendChild($articleList, $articleNode);
     // The XML for an article marked to be deleted contains no metadata.
     if ($markToDelete) {
         return;
     }
     assert(is_a($article, 'PublishedArticle'));
     // Add authors.
     $authors = $article->getAuthors();
     if (!empty($authors)) {
         $authorList =& XMLCustomWriter::createElement($articleDoc, 'authorList');
         foreach ($authors as $author) {
             /* @var $author Author */
             XMLCustomWriter::createChildWithText($articleDoc, $authorList, 'author', $author->getFullName(true));
         }
         XMLCustomWriter::appendChild($articleNode, $authorList);
     }
     // We need the request to retrieve locales and build URLs.
     $request = PKPApplication::getRequest();
     // Get all supported locales.
     $site = $request->getSite();
     $supportedLocales = $site->getSupportedLocales() + array_keys($journal->getSupportedLocaleNames());
     assert(!empty($supportedLocales));
     // Add titles.
     $titleList =& XMLCustomWriter::createElement($articleDoc, 'titleList');
     // Titles are used for sorting, we therefore need
     // them in all supported locales.
     assert(!empty($supportedLocales));
     foreach ($supportedLocales as $locale) {
         $localizedTitle = $article->getLocalizedTitle($locale);
         if (!is_null($localizedTitle)) {
             // Add the localized title.
             $titleNode =& XMLCustomWriter::createChildWithText($articleDoc, $titleList, 'title', $localizedTitle);
             XMLCustomWriter::setAttribute($titleNode, 'locale', $locale);
             // If the title does not exist in the given locale
             // then use the localized title for sorting only.
             $title = $article->getTitle($locale);
             $sortOnly = empty($title) ? 'true' : 'false';
             XMLCustomWriter::setAttribute($titleNode, 'sortOnly', $sortOnly);
         }
     }
     XMLCustomWriter::appendChild($articleNode, $titleList);
     // Add abstracts.
     $abstracts = $article->getAbstract(null);
     // return all locales
     if (!empty($abstracts)) {
         $abstractList =& XMLCustomWriter::createElement($articleDoc, 'abstractList');
         foreach ($abstracts as $locale => $abstract) {
             $abstractNode =& XMLCustomWriter::createChildWithText($articleDoc, $abstractList, 'abstract', $abstract);
             XMLCustomWriter::setAttribute($abstractNode, 'locale', $locale);
         }
         XMLCustomWriter::appendChild($articleNode, $abstractList);
     }
     // Add discipline.
     $disciplines = $article->getDiscipline(null);
     // return all locales
     if (!empty($disciplines)) {
         $disciplineList =& XMLCustomWriter::createElement($articleDoc, 'disciplineList');
         foreach ($disciplines as $locale => $discipline) {
             $disciplineNode =& XMLCustomWriter::createChildWithText($articleDoc, $disciplineList, 'discipline', $discipline);
             XMLCustomWriter::setAttribute($disciplineNode, 'locale', $locale);
         }
         XMLCustomWriter::appendChild($articleNode, $disciplineList);
     }
     // Add subjects and subject classes.
     $subjectClasses = $article->getSubjectClass(null);
     $subjects = $article->getSubject(null);
     if (!empty($subjectClasses) || !empty($subjects)) {
         $subjectList =& XMLCustomWriter::createElement($articleDoc, 'subjectList');
         if (!is_array($subjectClasses)) {
             $subjectClasses = array();
         }
         if (!is_array($subjects)) {
             $subjects = array();
         }
         $locales = array_unique(array_merge(array_keys($subjectClasses), array_keys($subjects)));
         foreach ($locales as $locale) {
             $subject = '';
             if (isset($subjectClasses[$locale])) {
                 $subject .= $subjectClasses[$locale];
             }
             if (isset($subjects[$locale])) {
                 if (!empty($subject)) {
                     $subject .= ' ';
                 }
                 $subject .= $subjects[$locale];
             }
             $subjectNode =& XMLCustomWriter::createChildWithText($articleDoc, $subjectList, 'subject', $subject);
             XMLCustomWriter::setAttribute($subjectNode, 'locale', $locale);
         }
         XMLCustomWriter::appendChild($articleNode, $subjectList);
     }
     // Add type.
     $types = $article->getType(null);
     // return all locales
     if (!empty($types)) {
         $typeList =& XMLCustomWriter::createElement($articleDoc, 'typeList');
         foreach ($types as $locale => $type) {
             $typeNode =& XMLCustomWriter::createChildWithText($articleDoc, $typeList, 'type', $type);
             XMLCustomWriter::setAttribute($typeNode, 'locale', $locale);
         }
         XMLCustomWriter::appendChild($articleNode, $typeList);
     }
     // Add coverage.
     $coverageGeo = $article->getCoverageGeo(null);
     $coverageChron = $article->getCoverageChron(null);
     $coverageSample = $article->getCoverageSample(null);
     if (!empty($coverageGeo) || !empty($coverageChron) || !empty($coverageSample)) {
         $coverageList =& XMLCustomWriter::createElement($articleDoc, 'coverageList');
         if (!is_array($coverageGeo)) {
             $coverageGeo = array();
         }
         if (!is_array($coverageChron)) {
             $coverageChron = array();
         }
         if (!is_array($coverageSample)) {
             $coverageSample = array();
         }
         $locales = array_unique(array_merge(array_keys($coverageGeo), array_keys($coverageChron), array_keys($coverageSample)));
         foreach ($locales as $locale) {
             $coverage = '';
             if (isset($coverageGeo[$locale])) {
                 $coverage .= $coverageGeo[$locale];
             }
             if (isset($coverageChron[$locale])) {
                 if (!empty($coverage)) {
                     $coverage .= '; ';
                 }
                 $coverage .= $coverageChron[$locale];
             }
             if (isset($coverageSample[$locale])) {
                 if (!empty($coverage)) {
                     $coverage .= '; ';
                 }
                 $coverage .= $coverageSample[$locale];
             }
             $coverageNode =& XMLCustomWriter::createChildWithText($articleDoc, $coverageList, 'coverage', $coverage);
             XMLCustomWriter::setAttribute($coverageNode, 'locale', $locale);
         }
         XMLCustomWriter::appendChild($articleNode, $coverageList);
     }
     // Add journal titles.
     $journalTitleList =& XMLCustomWriter::createElement($articleDoc, 'journalTitleList');
     // Journal titles are used for sorting, we therefore need
     // them in all supported locales.
     foreach ($supportedLocales as $locale) {
         $localizedTitle = $journal->getName($locale);
         $sortOnly = false;
         if (is_null($localizedTitle)) {
             // If the title does not exist in the given locale
             // then use the localized title for sorting only.
             $journalTitle = $journal->getLocalizedName();
             $sortOnly = true;
         } else {
             $journalTitle = $localizedTitle;
         }
         $journalTitleNode =& XMLCustomWriter::createChildWithText($articleDoc, $journalTitleList, 'journalTitle', $journalTitle);
         XMLCustomWriter::setAttribute($journalTitleNode, 'locale', $locale);
         $sortOnly = $sortOnly ? 'true' : 'false';
         XMLCustomWriter::setAttribute($journalTitleNode, 'sortOnly', $sortOnly);
     }
     XMLCustomWriter::appendChild($articleNode, $journalTitleList);
     // Add publication dates.
     $publicationDate = $article->getDatePublished();
     if (!empty($publicationDate)) {
         // Transform and store article publication date.
         $publicationDate = $this->_convertDate($publicationDate);
         $dateNode =& XMLCustomWriter::createChildWithText($articleDoc, $articleNode, 'publicationDate', $publicationDate);
     }
     $issueId = $article->getIssueId();
     if (is_numeric($issueId)) {
         $issueDao = DAORegistry::getDAO('IssueDAO');
         /* @var $issueDao IssueDAO */
         $issue = $issueDao->getById($issueId);
         if (is_a($issue, 'Issue')) {
             $issuePublicationDate = $issue->getDatePublished();
             if (!empty($issuePublicationDate)) {
                 // Transform and store issue publication date.
                 $issuePublicationDate = $this->_convertDate($issuePublicationDate);
                 $dateNode =& XMLCustomWriter::createChildWithText($articleDoc, $articleNode, 'issuePublicationDate', $issuePublicationDate);
             }
         }
     }
     // We need the router to build file URLs.
     $router = $request->getRouter();
     /* @var $router PageRouter */
     // Add galley files
     $articleGalleyDao = DAORegistry::getDAO('ArticleGalleyDAO');
     $galleys = $articleGalleyDao->getBySubmissionId($article->getId());
     $galleyList = null;
     while ($galley = $galleys->next()) {
         /* @var $galley ArticleGalley */
         $locale = $galley->getLocale();
         $galleyUrl = $router->url($request, $journal->getPath(), 'article', 'download', array(intval($article->getId()), intval($galley->getId())));
         if (!empty($locale) && !empty($galleyUrl)) {
             if (is_null($galleyList)) {
                 $galleyList =& XMLCustomWriter::createElement($articleDoc, 'galleyList');
             }
             $galleyNode =& XMLCustomWriter::createElement($articleDoc, 'galley');
             XMLCustomWriter::setAttribute($galleyNode, 'locale', $locale);
             XMLCustomWriter::setAttribute($galleyNode, 'fileName', $galleyUrl);
             XMLCustomWriter::appendChild($galleyList, $galleyNode);
         }
     }
     // Wrap the galley XML as CDATA.
     if (!is_null($galleyList)) {
         if (is_callable(array($articleDoc, 'saveXml'))) {
             $galleyXml = $articleDoc->saveXml($galleyList);
         } else {
             $galleyXml = $galleyList->toXml();
         }
         $galleyOuterNode =& XMLCustomWriter::createElement($articleDoc, 'galley-xml');
         if (is_callable(array($articleDoc, 'createCDATASection'))) {
             $cdataNode = $articleDoc->createCDATASection($galleyXml);
         } else {
             $cdataNode = new XMLNode();
             $cdataNode->setValue('<![CDATA[' . $galleyXml . ']]>');
         }
         XMLCustomWriter::appendChild($galleyOuterNode, $cdataNode);
         XMLCustomWriter::appendChild($articleNode, $galleyOuterNode);
     }
 }
コード例 #7
0
 /**
  * Generate publisher date - order matters
  * @param $doc XMLNode
  * @param $pubdate string
  * @return XMLNode
  */
 function &_generatePublisherDateDom(&$doc, $pubdate)
 {
     $publicationDateNode =& XMLCustomWriter::createElement($doc, 'publication_date');
     XMLCustomWriter::setAttribute($publicationDateNode, 'media_type', 'online');
     $parsedPubdate = strtotime($pubdate);
     XMLCustomWriter::createChildWithText($doc, $publicationDateNode, 'year', date('Y', $parsedPubdate));
     return $publicationDateNode;
 }
コード例 #8
0
 function &getMetadataPage($pageNum, &$errors)
 {
     import('xml.XMLCustomWriter');
     import('db.DBResultRange');
     $journal =& Request::getJournal();
     $journalId = $journal->getJournalId();
     $falseVar = false;
     if ($pageNum < 1) {
         return $falseVar;
     }
     $rangeInfo =& new DBResultRange(GOOGLE_SCHOLAR_ITEMS_PER_PAGE, $pageNum);
     $document =& XMLCustomWriter::createDocument('articles', 'articles.dtd');
     $articlesNode =& XMLCustomWriter::createElement($document, 'articles');
     XMLCustomWriter::appendChild($document, $articlesNode);
     $publishedArticleDao =& DAORegistry::getDAO('PublishedArticleDAO');
     $publishedArticles =& $publishedArticleDao->getPublishedArticlesByJournalId($journalId, $rangeInfo);
     $issueDao =& DAORegistry::getDAO('IssueDAO');
     $issueCache = array();
     while ($publishedArticle =& $publishedArticles->next()) {
         $articleNode =& XMLCustomWriter::createElement($document, 'article');
         XMLCustomWriter::appendChild($articlesNode, $articleNode);
         $frontNode =& XMLCustomWriter::createElement($document, 'front');
         XMLCustomWriter::appendChild($articleNode, $frontNode);
         $journalMetaNode =& XMLCustomWriter::createElement($document, 'journal-meta');
         XMLCustomWriter::appendChild($frontNode, $journalMetaNode);
         // Journal Metadata
         $journal =& Request::getJournal();
         XMLCustomWriter::createChildWithText($document, $journalMetaNode, 'journal-title', $journal->getJournalTitle(), true);
         XMLCustomWriter::createChildWithText($document, $journalMetaNode, 'abbrev-journal-title', $journal->getLocalizedSetting('initials'), false);
         $issn = $journal->getSetting('onlineIssn');
         if (empty($issn)) {
             array_push($errors, Locale::translate('plugins.gateways.googleScholar.errors.noIssn'));
             return $falseVar;
         }
         XMLCustomWriter::createChildWithText($document, $journalMetaNode, 'issn', $issn, false);
         $publisherNode =& XMLCustomWriter::createElement($document, 'publisher');
         $publisherName = $this->getSetting($journalId, 'publisher-name');
         if (empty($publisherName)) {
             array_push($errors, Locale::translate('plugins.gateways.googleScholar.errors.noPublisherName'));
             return $falseVar;
         }
         XMLCustomWriter::createChildWithText($document, $publisherNode, 'publisher-name', $publisherName, true);
         XMLCustomWriter::appendChild($journalMetaNode, $publisherNode);
         $articleMetaNode =& XMLCustomWriter::createElement($document, 'article-meta');
         XMLCustomWriter::appendChild($frontNode, $articleMetaNode);
         // Article Metadata
         $titleGroupNode =& XMLCustomWriter::createElement($document, 'title-group');
         XMLCustomWriter::appendChild($articleMetaNode, $titleGroupNode);
         $titles = $publishedArticle->getTitle(null);
         $primaryLocale = $journal->getPrimaryLocale();
         XMLCustomWriter::createChildWithText($document, $titleGroupNode, 'article-title', $titles[$primaryLocale], true);
         unset($titles[$primaryLocale]);
         foreach ($titles as $locale => $title) {
             XMLCustomWriter::createChildWithText($document, $titleGroupNode, 'trans-title', $title, false);
         }
         $contribGroupNode =& XMLCustomWriter::createElement($document, 'contrib-group');
         XMLCustomWriter::appendChild($articleMetaNode, $contribGroupNode);
         foreach ($publishedArticle->getAuthors() as $author) {
             $contribNode =& XMLCustomWriter::createElement($document, 'contrib');
             XMLCustomWriter::appendChild($contribGroupNode, $contribNode);
             XMLCustomWriter::setAttribute($contribNode, 'contrib-type', 'author');
             $nameNode =& XMLCustomWriter::createElement($document, 'name');
             XMLCustomWriter::appendChild($contribNode, $nameNode);
             // Opatan Inc.
             XMLCustomWriter::createChildWithText($document, $nameNode, 'surname', $author->getAuthorLastName(), true);
             // Given names in the form: FirstName MiddleName, where MiddleName is optional
             $name = $author->getAuthorFirstName();
             // Opatan Inc. : gets Localized author firstName
             if (($middleName = $author->getAuthorMiddleName()) != '') {
                 $name .= " {$middleName}";
             }
             // Opatan Inc.
             XMLCustomWriter::createChildWithText($document, $nameNode, 'given-names', $name, true);
         }
         $dateParts = getdate(strtotime($publishedArticle->getDatePublished()));
         $pubDateNode =& XMLCustomWriter::createElement($document, 'pub-date');
         XMLCustomWriter::appendChild($articleMetaNode, $pubDateNode);
         XMLCustomWriter::createChildWithText($document, $pubDateNode, 'day', $dateParts['mday']);
         XMLCustomWriter::createChildWithText($document, $pubDateNode, 'month', $dateParts['mon']);
         XMLCustomWriter::createChildWithText($document, $pubDateNode, 'year', $dateParts['year']);
         $issueId = $publishedArticle->getIssueId();
         if (!isset($issueCache[$issueId])) {
             $issueCache[$issueId] =& $issueDao->getIssueById($issueId);
         }
         $issue =& $issueCache[$issueId];
         XMLCustomWriter::createChildWithText($document, $articleMetaNode, 'volume', $issue->getVolume());
         XMLCustomWriter::createChildWithText($document, $articleMetaNode, 'issue', $issue->getNumber());
         $canonicalUriNode =& XMLCustomWriter::createElement($document, 'self-uri');
         XMLCustomWriter::setAttribute($canonicalUriNode, 'xlink:href', Request::url(null, 'article', 'viewArticle', array($publishedArticle->getArticleId())));
         XMLCustomWriter::appendChild($articleMetaNode, $canonicalUriNode);
         foreach ($publishedArticle->getGalleys() as $galley) {
             $galleyUriNode =& XMLCustomWriter::createElement($document, 'self-uri');
             if ($galley->isHTMLGalley()) {
                 XMLCustomWriter::setAttribute($galleyUriNode, 'xlink:href', Request::url(null, 'article', 'viewArticle', array($publishedArticle->getArticleId(), $galley->getGalleyId())));
             } else {
                 XMLCustomWriter::setAttribute($galleyUriNode, 'xlink:href', Request::url(null, 'article', 'viewFile', array($publishedArticle->getArticleId(), $galley->getGalleyId())));
             }
             XMLCustomWriter::appendChild($articleMetaNode, $galleyUriNode);
         }
         unset($issue);
     }
     return $document;
 }
 /**
  * Add ID-nodes to the given node.
  * @param $doc DOMDocument
  * @param $node DOMNode
  * @param $pubObject object
  * @param $journalId int
  */
 function generatePubId(&$doc, &$node, &$pubObject, $journalId)
 {
     $pubIdPlugins =& PluginRegistry::loadCategory('pubIds', true, $journalId);
     foreach ($pubIdPlugins as $pubIdPlugin) {
         $pubIdType = $pubIdPlugin->getPubIdType();
         $pubId = $pubObject->getStoredPubId($pubIdType);
         if ($pubId) {
             $pubObjectType = $pubIdPlugin->getPubObjectType($pubObject);
             $pubIdNode =& XMLCustomWriter::createChildWithText($doc, $node, 'pubId', $pubId);
             XMLCustomWriter::setAttribute($pubIdNode, 'pubIdType', $pubIdType);
             XMLCustomWriter::setAttribute($pubIdNode, 'pubObjectType', $pubObjectType);
             XMLCustomWriter::setAttribute($pubIdNode, 'pubObjectId', $pubObject->getId());
         }
     }
 }
コード例 #10
0
ファイル: NLMExportDom.inc.php プロジェクト: ramonsodoma/ocs
 function &generateAuthorDom(&$doc, &$author)
 {
     $root =& XMLCustomWriter::createElement($doc, 'Author');
     $foreName = trim($author->getFirstName() . ' ' . $author->getMiddleName());
     XMLCustomWriter::createChildWithText($doc, $root, 'LastName', ucfirst($author->getLastName()));
     XMLCustomWriter::createChildWithText($doc, $root, 'ForeName', ucwords($foreName));
     return $root;
 }
コード例 #11
0
 /**
  * Add ID-nodes to the given node.
  * @param $doc DOMDocument
  * @param $node DOMNode
  * @param $pubObject object
  * @param $issue Issue
  */
 function generatePubId(&$doc, &$node, &$pubObject, &$issue)
 {
     $pubIdPlugins =& PluginRegistry::loadCategory('pubIds', true, $issue->getJournalId());
     if (is_array($pubIdPlugins)) {
         foreach ($pubIdPlugins as $pubIdPlugin) {
             if ($issue->getPublished()) {
                 $pubId = $pubIdPlugin->getPubId($pubObject);
             } else {
                 $pubId = $pubIdPlugin->getPubId($pubObject, true);
             }
             if ($pubId) {
                 $pubIdType = $pubIdPlugin->getPubIdType();
                 $idNode =& XMLCustomWriter::createChildWithText($doc, $node, 'id', $pubId);
                 XMLCustomWriter::setAttribute($idNode, 'type', $pubIdType);
             }
         }
     }
 }
コード例 #12
0
 function insertRecordCallback($hookName, $args)
 {
     // Load a cached list of search form elements for which we will index.
     static $searchFormElementCache;
     static $fieldsToSearchFormElements;
     $searchFormElementDao =& DAORegistry::getDAO('SearchFormElementDAO');
     if (!isset($searchFormElementCache)) {
         $searchFormElements =& $searchFormElementDao->getSearchFormElements();
         while ($searchFormElement =& $searchFormElements->next()) {
             $searchFormElementId = $searchFormElement->getSearchFormElementId();
             $searchFormElementCache[$searchFormElementId] =& $searchFormElement;
             $searchFormElementFields =& $searchFormElementDao->getFieldsBySearchFormElement($searchFormElementId);
             while ($field =& $searchFormElementFields->next()) {
                 $fieldsToSearchFormElements[$field->getFieldId()][] = $searchFormElementId;
                 unset($field);
             }
             unset($searchFormElement, $searchFormElementFields);
         }
         unset($searchFormElements);
     }
     // Now handle the record.
     $record =& $args[0];
     $isUsingSolr = $this->isUsingSolr();
     if (!$isUsingSolr) {
         $doc = new Zend_Search_Lucene_Document();
     } else {
         import('lib.pkp.classes.xml.XMLCustomWriter');
         $doc =& XMLCustomWriter::createDocument('add', SOLR_DTD_ID, SOLR_DTD_URL);
         $addNode =& XMLCustomWriter::createElement($doc, 'add');
         XMLCustomWriter::appendChild($doc, $addNode);
         $docNode =& XMLCustomWriter::createElement($doc, 'doc');
         XMLCustomWriter::appendChild($addNode, $docNode);
     }
     $schemaPlugin =& $record->getSchemaPlugin();
     $schemaPluginName = $schemaPlugin->getName();
     $fieldDao =& DAORegistry::getDAO('FieldDAO');
     foreach ($schemaPlugin->getFieldList() as $fieldName) {
         $field =& $fieldDao->buildField($fieldName, $schemaPluginName);
         if (isset($fieldsToSearchFormElements[$field->getFieldId()])) {
             // This field belongs to one or more search form elements;
             // make sure it is indexed against that element.
             foreach ($fieldsToSearchFormElements[$field->getFieldId()] as $searchFormElementId) {
                 $searchFormElement =& $searchFormElementCache[$searchFormElementId];
                 switch ($searchFormElement->getType()) {
                     case SEARCH_FORM_ELEMENT_TYPE_STRING:
                         $fieldValue = $schemaPlugin->getFieldValue($record, $fieldName, SORT_ORDER_TYPE_STRING);
                         if ($isUsingSolr) {
                             $fieldNode =& XMLCustomWriter::createChildWithText($doc, $docNode, 'field', $fieldValue, false);
                             if ($fieldNode) {
                                 $fieldNode->setAttribute('name', $searchFormElement->getSymbolic());
                             }
                             unset($fieldNode);
                         } else {
                             $doc->addField(Zend_Search_Lucene_Field::UnStored($searchFormElement->getSymbolic(), $fieldValue));
                         }
                         break;
                     case SEARCH_FORM_ELEMENT_TYPE_SELECT:
                         $fieldValue = $schemaPlugin->getFieldValue($record, $fieldName, SORT_ORDER_TYPE_STRING);
                         if ($isUsingSolr) {
                             $fieldNode =& XMLCustomWriter::createChildWithText($doc, $docNode, 'field', $fieldValue, false);
                             if ($fieldNode) {
                                 $fieldNode->setAttribute('name', $searchFormElement->getSymbolic());
                             }
                             unset($fieldNode);
                         } else {
                             $doc->addField(Zend_Search_Lucene_Field::UnStored($searchFormElement->getSymbolic(), $fieldValue));
                         }
                         if (!$searchFormElementDao->searchFormElementOptionExists($searchFormElementId, $fieldValue)) {
                             $searchFormElementDao->insertSearchFormElementOption($searchFormElementId, $fieldValue);
                         }
                         break;
                     case SEARCH_FORM_ELEMENT_TYPE_DATE:
                         $fieldValue = $schemaPlugin->getFieldValue($record, $fieldName, SORT_ORDER_TYPE_DATE);
                         $fieldValue = strftime('%Y-%m-%dT%H:%M:%SZ', $fieldValue);
                         if ($fieldValue !== null) {
                             // Don't index values that could not be parsed
                             if ($isUsingSolr) {
                                 $fieldNode =& XMLCustomWriter::createChildWithText($doc, $docNode, 'field', $fieldValue, false);
                                 if ($fieldNode) {
                                     $fieldNode->setAttribute('name', $searchFormElement->getSymbolic());
                                 }
                                 unset($fieldNode);
                             } else {
                                 $doc->addField(Zend_Search_Lucene_Field::Keyword($searchFormElement->getSymbolic(), $fieldValue));
                             }
                         }
                         break;
                     default:
                         fatalError('Unknown search form element type!');
                 }
                 unset($searchFormElement);
             }
         } else {
             // This is not a search form element field; dump it under
             // "other" so that it is still indexed.
             $fieldValue = $schemaPlugin->getFieldValue($record, $fieldName, SORT_ORDER_TYPE_STRING);
             if ($isUsingSolr) {
                 $fieldNode =& XMLCustomWriter::createChildWithText($doc, $docNode, 'field', $fieldValue, false);
                 if ($fieldNode) {
                     $fieldNode->setAttribute('name', 'text');
                 }
                 unset($fieldNode);
             } else {
                 $doc->addField(Zend_Search_Lucene_Field::UnStored('harvesterOther', $fieldValue));
             }
         }
     }
     if ($isUsingSolr) {
         foreach (array('id' => $record->getRecordId(), 'harvesterArchiveId' => $record->getArchiveId(), 'harvesterIdentifier' => $record->getIdentifier()) as $name => $value) {
             $fieldNode =& XMLCustomWriter::createChildWithText($doc, $docNode, 'field', $value);
             if ($fieldNode) {
                 $fieldNode->setAttribute('name', $name);
             }
             unset($fieldNode);
         }
         $this->solrQuery($doc);
     } else {
         $doc->addField(Zend_Search_Lucene_Field::Keyword('harvesterRecordId', $record->getRecordId()));
         $doc->addField(Zend_Search_Lucene_Field::Keyword('harvesterArchiveId', $record->getArchiveId()));
         $doc->addField(Zend_Search_Lucene_Field::Keyword('harvesterIdentifier', $record->getIdentifier()));
         $index =& $this->getIndex();
         $index->addDocument($doc);
     }
     return false;
 }
コード例 #13
0
ファイル: NativeExportDom.inc.php プロジェクト: Jouper/jouper
 function &generateSuppFileDom(&$doc, &$journal, &$issue, &$article, &$suppFile)
 {
     $root =& XMLCustomWriter::createElement($doc, 'supplemental_file');
     // FIXME: These should be constants!
     switch ($suppFile->getType()) {
         case Locale::translate('author.submit.suppFile.researchInstrument'):
             $suppFileType = 'research_instrument';
             break;
         case Locale::translate('author.submit.suppFile.researchMaterials'):
             $suppFileType = 'research_materials';
             break;
         case Locale::translate('author.submit.suppFile.researchResults'):
             $suppFileType = 'research_results';
             break;
         case Locale::translate('author.submit.suppFile.transcripts'):
             $suppFileType = 'transcripts';
             break;
         case Locale::translate('author.submit.suppFile.dataAnalysis'):
             $suppFileType = 'data_analysis';
             break;
         case Locale::translate('author.submit.suppFile.dataSet'):
             $suppFileType = 'data_set';
             break;
         case Locale::translate('author.submit.suppFile.sourceText'):
             $suppFileType = 'source_text';
             break;
         default:
             $suppFileType = 'other';
             break;
     }
     XMLCustomWriter::setAttribute($root, 'type', $suppFileType);
     XMLCustomWriter::setAttribute($root, 'public_id', $suppFile->getPublicSuppFileId(), false);
     XMLCustomWriter::setAttribute($root, 'language', $suppFile->getLanguage(), false);
     if (is_array($suppFile->getTitle(null))) {
         foreach ($suppFile->getTitle(null) as $locale => $title) {
             $titleNode =& XMLCustomWriter::createChildWithText($doc, $root, 'title', $title, false);
             if ($titleNode) {
                 XMLCustomWriter::setAttribute($titleNode, 'locale', $locale);
             }
             unset($titleNode);
         }
     }
     if (is_array($suppFile->getCreator(null))) {
         foreach ($suppFile->getCreator(null) as $locale => $creator) {
             $creatorNode =& XMLCustomWriter::createChildWithText($doc, $root, 'creator', $creator, false);
             if ($creatorNode) {
                 XMLCustomWriter::setAttribute($creatorNode, 'locale', $locale);
             }
             unset($creatorNode);
         }
     }
     if (is_array($suppFile->getSubject(null))) {
         foreach ($suppFile->getSubject(null) as $locale => $subject) {
             $subjectNode =& XMLCustomWriter::createChildWithText($doc, $root, 'subject', $subject, false);
             if ($subjectNode) {
                 XMLCustomWriter::setAttribute($subjectNode, 'locale', $locale);
             }
             unset($subjectNode);
         }
     }
     if ($suppFileType == 'other') {
         if (is_array($suppFile->getTypeOther(null))) {
             foreach ($suppFile->getTypeOther(null) as $locale => $typeOther) {
                 $typeOtherNode =& XMLCustomWriter::createChildWithText($doc, $root, 'type_other', $typeOther, false);
                 if ($typeOtherNode) {
                     XMLCustomWriter::setAttribute($typeOtherNode, 'locale', $locale);
                 }
                 unset($typeOtherNode);
             }
         }
     }
     if (is_array($suppFile->getDescription(null))) {
         foreach ($suppFile->getDescription(null) as $locale => $description) {
             $descriptionNode =& XMLCustomWriter::createChildWithText($doc, $root, 'description', $description, false);
             if ($descriptionNode) {
                 XMLCustomWriter::setAttribute($descriptionNode, 'locale', $locale);
             }
             unset($descriptionNode);
         }
     }
     if (is_array($suppFile->getPublisher(null))) {
         foreach ($suppFile->getPublisher(null) as $locale => $publisher) {
             $publisherNode =& XMLCustomWriter::createChildWithText($doc, $root, 'publisher', $publisher, false);
             if ($publisherNode) {
                 XMLCustomWriter::setAttribute($publisherNode, 'locale', $locale);
             }
             unset($publisherNode);
         }
     }
     if (is_array($suppFile->getSponsor(null))) {
         foreach ($suppFile->getSponsor(null) as $locale => $sponsor) {
             $sponsorNode =& XMLCustomWriter::createChildWithText($doc, $root, 'sponsor', $sponsor, false);
             if ($sponsorNode) {
                 XMLCustomWriter::setAttribute($sponsorNode, 'locale', $locale);
             }
             unset($sponsorNode);
         }
     }
     XMLCustomWriter::createChildWithText($doc, $root, 'date_created', NativeExportDom::formatDate($suppFile->getDateCreated()), false);
     if (is_array($suppFile->getSource(null))) {
         foreach ($suppFile->getSource(null) as $locale => $source) {
             $sourceNode =& XMLCustomWriter::createChildWithText($doc, $root, 'source', $source, false);
             if ($sourceNode) {
                 XMLCustomWriter::setAttribute($sourceNode, 'locale', $locale);
             }
             unset($sourceNode);
         }
     }
     import('file.ArticleFileManager');
     $articleFileManager =& new ArticleFileManager($article->getArticleId());
     $fileNode =& XMLCustomWriter::createElement($doc, 'file');
     XMLCustomWriter::appendChild($root, $fileNode);
     $embedNode =& XMLCustomWriter::createChildWithText($doc, $fileNode, 'embed', base64_encode($articleFileManager->readFile($suppFile->getFileId())));
     XMLCustomWriter::setAttribute($embedNode, 'filename', $suppFile->getOriginalFileName());
     XMLCustomWriter::setAttribute($embedNode, 'encoding', 'base64');
     XMLCustomWriter::setAttribute($embedNode, 'mime_type', $suppFile->getFileType());
     return $root;
 }
コード例 #14
0
ファイル: MetsExportDom.inc.php プロジェクト: yuricampos/ojs
 /**
  *  Create METS:metsHdr for export
  */
 function &createmetsHdr($doc)
 {
     $root =& XMLCustomWriter::createElement($doc, 'METS:metsHdr');
     XMLCustomWriter::setAttribute($root, 'CREATEDATE', date('c'));
     XMLCustomWriter::setAttribute($root, 'LASTMODDATE', date('c'));
     $agentNode =& XMLCustomWriter::createElement($doc, 'METS:agent');
     XMLCustomWriter::setAttribute($agentNode, 'ROLE', 'DISSEMINATOR');
     XMLCustomWriter::setAttribute($agentNode, 'TYPE', 'ORGANIZATION');
     $organization = Request::getUserVar('organization');
     if ($organization == '') {
         $siteDao =& DAORegistry::getDAO('SiteDAO');
         $site = $siteDao->getSite();
         $organization = $site->getLocalizedTitle();
     }
     XMLCustomWriter::createChildWithText($doc, $agentNode, 'METS:name', $organization, false);
     XMLCustomWriter::appendChild($root, $agentNode);
     $agentNode2 =& XMLCustomWriter::createElement($doc, 'METS:agent');
     XMLCustomWriter::setAttribute($agentNode2, 'ROLE', 'CREATOR');
     XMLCustomWriter::setAttribute($agentNode2, 'TYPE', 'OTHER');
     XMLCustomWriter::createChildWithText($doc, $agentNode2, 'METS:name', MetsExportDom::getCreatorString(), false);
     XMLCustomWriter::appendChild($root, $agentNode2);
     return $root;
 }
コード例 #15
0
ファイル: SitemapHandler.inc.php プロジェクト: mariojp/ojs
 /**
  * Create a url entry with children
  * @param $doc XMLNode Reference to the XML document object
  * @param $loc string URL of page (required)
  * @param $lastmod string Last modification date of page (optional)
  * @param $changefreq Frequency of page modifications (optional)
  * @param $priority string Subjective priority assesment of page (optional) 
  * @return XMLNode
  */
 function _createUrlTree(&$doc, $loc, $lastmod = null, $changefreq = null, $priority = null)
 {
     $url =& XMLCustomWriter::createElement($doc, 'url');
     XMLCustomWriter::createChildWithText($doc, $url, htmlentities('loc'), $loc, false);
     XMLCustomWriter::createChildWithText($doc, $url, 'lastmod', $lastmod, false);
     XMLCustomWriter::createChildWithText($doc, $url, 'changefreq', $changefreq, false);
     XMLCustomWriter::createChildWithText($doc, $url, 'priority', $priority, false);
     return $url;
 }
コード例 #16
0
ファイル: O4DOIExportDom.inc.php プロジェクト: reconciler/ojs
 /**
  * Create a description text element.
  *
  * @param $workOrProduct string
  * @param $relationCode string One of the O4DOI_RELATION_* constants.
  * @param $ids array
  *
  * @return XMLNode|DOMImplementation
  */
 function &_relationElement($workOrProduct, $relationCode, $ids)
 {
     $relationElement =& XMLCustomWriter::createElement($this->getDoc(), "Related{$workOrProduct}");
     // Relation code (mandatory)
     XMLCustomWriter::createChildWithText($this->getDoc(), $relationElement, 'RelationCode', $relationCode);
     // Work/Product ID (mandatory)
     foreach ($ids as $idType => $id) {
         XMLCustomWriter::appendChild($relationElement, $this->_idElement($workOrProduct, $idType, $id));
     }
     return $relationElement;
 }
コード例 #17
0
 /**
  * Export the selected email templates as XML
  * @param $args array
  * @@param $request PKPRequest
  */
 function exportEmails($args, $request)
 {
     $this->validate();
     import('lib.pkp.classes.xml.XMLCustomWriter');
     $selectedEmailKeys = (array) $request->getUserVar('tplId');
     if (empty($selectedEmailKeys)) {
         $request->redirect(null, null, 'emails');
     }
     $journal = Request::getJournal();
     $doc = XMLCustomWriter::createDocument();
     $emailTexts = XMLCustomWriter::createElement($doc, 'email_texts');
     $emailTexts->setAttribute('locale', AppLocale::getLocale());
     $emailTexts->setAttribute('xmlns:xsi', 'http://www.w3.org/2001/XMLSchema-instance');
     $emailTemplateDao = DAORegistry::getDAO('EmailTemplateDAO');
     $emailTemplates = $emailTemplateDao->getEmailTemplates(AppLocale::getLocale(), $journal->getId());
     foreach ($emailTemplates as $emailTemplate) {
         $emailKey = $emailTemplate->getData('emailKey');
         if (!in_array($emailKey, $selectedEmailKeys)) {
             continue;
         }
         $subject = $emailTemplate->getData('subject');
         $body = $emailTemplate->getData('body');
         $emailTextNode = XMLCustomWriter::createElement($doc, 'email_text');
         XMLCustomWriter::setAttribute($emailTextNode, 'key', $emailKey);
         //append subject node
         $subjectNode = XMLCustomWriter::createChildWithText($doc, $emailTextNode, 'subject', $subject, false);
         XMLCustomWriter::appendChild($emailTextNode, $subjectNode);
         //append body node
         $bodyNode = XMLCustomWriter::createChildWithText($doc, $emailTextNode, 'body', $body, false);
         XMLCustomWriter::appendChild($emailTextNode, $bodyNode);
         //append email_text node
         XMLCustomWriter::appendChild($emailTexts, $emailTextNode);
     }
     XMLCustomWriter::appendChild($doc, $emailTexts);
     header("Content-Type: application/xml");
     header("Cache-Control: private");
     header("Content-Disposition: attachment; filename=\"email-templates-" . date('Y-m-d-H-i-s') . ".xml\"");
     XMLCustomWriter::printXML($doc);
 }