本文整理汇总了PHP中XMLCustomWriter::createElement方法的典型用法代码示例。如果您正苦于以下问题:PHP XMLCustomWriter::createElement方法的具体用法?PHP XMLCustomWriter::createElement怎么用?PHP XMLCustomWriter::createElement使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类XMLCustomWriter
的用法示例。
在下文中一共展示了XMLCustomWriter::createElement方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: isset
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);
//.........这里部分代码省略.........
示例2: current
/**
* 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;
}
示例3: explode
/**
* Create a new XML node.
* @param $doc XMLNode|DOMImplementation
* @param $nodePath string an XPath-like string that describes the
* node to be created.
* @param $value string the value to be added as a text node (if any)
* @return XMLNode|DOMDocument
*/
function &_createNode($doc, $nodePath, $value = null)
{
// Separate the element name from the attributes.
$elementPlusAttributes = explode('[', $nodePath);
$element = $elementPlusAttributes[0];
assert(!empty($element));
// Create the element.
$newNode =& XMLCustomWriter::createElement($doc, $element);
// Add attributes.
if (count($elementPlusAttributes) == 2) {
// Separate the attribute key/value pairs.
$unparsedAttributes = explode('@', rtrim(ltrim($elementPlusAttributes[1], '@'), ']'));
foreach ($unparsedAttributes as $unparsedAttribute) {
// Split attribute expressions into key and value.
list($attributeName, $attributeValue) = explode('=', rtrim($unparsedAttribute, ' '));
$attributeValue = trim($attributeValue, '"');
XMLCustomWriter::setAttribute($newNode, $attributeName, $attributeValue);
}
}
// Insert a text node if we got a value for it.
if (!is_null($value)) {
$textNode =& XMLCustomWriter::createTextNode($doc, $value);
XMLCustomWriter::appendChild($newNode, $textNode);
}
return $newNode;
}
示例4: import
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);
//.........这里部分代码省略.........
示例5: exportArticles
function exportArticles(&$results, $outputFile = null)
{
$this->import('NativeExportDom');
$doc =& XMLCustomWriter::createDocument('articles', NATIVE_DTD_ID, NATIVE_DTD_URL);
$articlesNode =& XMLCustomWriter::createElement($doc, 'articles');
XMLCustomWriter::appendChild($doc, $articlesNode);
foreach ($results as $result) {
$article =& $result['publishedArticle'];
$section =& $result['section'];
$issue =& $result['issue'];
$journal =& $result['journal'];
$articleNode =& NativeExportDom::generateArticleDom($doc, $journal, $issue, $section, $article);
XMLCustomWriter::appendChild($articlesNode, $articleNode);
}
if (!empty($outputFile)) {
if (($h = fopen($outputFile, 'w')) === false) {
return false;
}
fwrite($h, XMLCustomWriter::getXML($doc));
fclose($h);
} else {
header("Content-Type: application/xml");
header("Cache-Control: private");
header("Content-Disposition: attachment; filename=\"articles.xml\"");
XMLCustomWriter::printXML($doc);
}
return true;
}
示例6: exportSchedConfs
function exportSchedConfs(&$conference, &$schedConfIdArray)
{
$this->import('MetsExportDom');
$schedConfDAO =& DAORegistry::getDAO('SchedConfDAO');
$doc =& XMLCustomWriter::createDocument();
$root =& XMLCustomWriter::createElement($doc, 'METS:mets');
XMLCustomWriter::setAttribute($root, 'xmlns:METS', 'http://www.loc.gov/METS/');
XMLCustomWriter::setAttribute($root, 'xmlns:xlink', 'http://www.w3.org/TR/xlink');
XMLCustomWriter::setAttribute($root, 'xmlns:xsi', 'http://www.w3.org/2001/XMLSchema-instance');
XMLCustomWriter::setAttribute($root, 'PROFILE', 'Australian METS Profile 1.0');
XMLCustomWriter::setAttribute($root, 'TYPE', 'conference');
XMLCustomWriter::setAttribute($root, 'OBJID', 'C-' . $conference->getId());
XMLCustomWriter::setAttribute($root, 'xsi:schemaLocation', 'http://www.loc.gov/METS/ http://www.loc.gov/mets/mets.xsd');
$headerNode =& MetsExportDom::createmetsHdr($doc);
XMLCustomWriter::appendChild($root, $headerNode);
MetsExportDom::generateConfDmdSecDom($doc, $root, $conference);
$fileSec =& XMLCustomWriter::createElement($doc, 'METS:fileSec');
$fileGrp =& XMLCustomWriter::createElement($doc, 'METS:fileGrp');
XMLCustomWriter::setAttribute($fileGrp, 'USE', 'original');
$i = 0;
while ($i < sizeof($schedConfIdArray)) {
$schedConf =& $schedConfDAO->getSchedConf($schedConfIdArray[$i]);
MetsExportDom::generateSchedConfDmdSecDom($doc, $root, $conference, $schedConf);
MetsExportDom::generateSchedConfFileSecDom($doc, $fileGrp, $conference, $schedConf);
$i++;
}
$amdSec =& MetsExportDom::createmetsamdSec($doc, $root, $conference);
XMLCustomWriter::appendChild($root, $amdSec);
XMLCustomWriter::appendChild($fileSec, $fileGrp);
XMLCustomWriter::appendChild($root, $fileSec);
MetsExportDom::generateConfstructMapWithSchedConfsIdArray($doc, $root, $conference, $schedConfIdArray);
XMLCustomWriter::appendChild($doc, $root);
header("Content-Type: application/xml");
header("Cache-Control: private");
header("Content-Disposition: attachment; filename=\"" . $conference->getPath() . "-mets.xml\"");
XMLCustomWriter::printXML($doc);
return true;
}
示例7: strtotime
/**
* 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: date
/**
* 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;
}
示例9: exportPubIdsForIssues
/**
* Export public identifiers of one or more issues.
* @param $journal object
* @param $issues array
* @param $outputFile xml file containing the exported public identifiers
*/
function exportPubIdsForIssues($journal, $issues, $outputFile = null)
{
$doc =& XMLCustomWriter::createDocument('pubIds', PID_DTD_URL, PID_DTD_URL);
$pubIdsNode =& XMLCustomWriter::createElement($doc, 'pubIds');
XMLCustomWriter::appendChild($doc, $pubIdsNode);
foreach ($issues as $issue) {
$this->generatePubId($doc, $pubIdsNode, $issue, $journal->getId());
$publishedArticleDao = DAORegistry::getDAO('PublishedArticleDAO');
foreach ($publishedArticleDao->getPublishedArticles($issue->getId()) as $publishedArticle) {
$this->generatePubId($doc, $pubIdsNode, $publishedArticle, $journal->getId());
$articleGalleyDao = DAORegistry::getDAO('ArticleGalleyDAO');
$galleys = $articleGalleyDao->getBySubmissionId($publishedArticle->getId());
while ($galley = $galleys->next()) {
$this->generatePubId($doc, $pubIdsNode, $galley, $journal->getId());
}
}
}
if (!empty($outputFile)) {
if (($h = fopen($outputFile, 'w')) === false) {
return false;
}
fwrite($h, XMLCustomWriter::getXML($doc));
fclose($h);
} else {
header("Content-Type: application/xml");
header("Cache-Control: private");
header("Content-Disposition: attachment; filename=\"pubIds.xml\"");
XMLCustomWriter::printXML($doc);
}
return true;
}
示例10: trim
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: switch
function &generateSuppFileDom(&$doc, &$journal, &$issue, &$article, &$suppFile)
{
$root =& XMLCustomWriter::createElement($doc, 'supplemental_file');
NativeExportDom::generatePubId($doc, $root, $suppFile, $issue);
// FIXME: These should be constants!
switch ($suppFile->getType()) {
case __('author.submit.suppFile.researchInstrument'):
$suppFileType = 'research_instrument';
break;
case __('author.submit.suppFile.researchMaterials'):
$suppFileType = 'research_materials';
break;
case __('author.submit.suppFile.researchResults'):
$suppFileType = 'research_results';
break;
case __('author.submit.suppFile.transcripts'):
$suppFileType = 'transcripts';
break;
case __('author.submit.suppFile.dataAnalysis'):
$suppFileType = 'data_analysis';
break;
case __('author.submit.suppFile.dataSet'):
$suppFileType = 'data_set';
break;
case __('author.submit.suppFile.sourceText'):
$suppFileType = 'source_text';
break;
default:
$suppFileType = 'other';
break;
}
XMLCustomWriter::setAttribute($root, 'type', $suppFileType);
XMLCustomWriter::setAttribute($root, 'public_id', $suppFile->getPubId('publisher-id'), false);
XMLCustomWriter::setAttribute($root, 'language', $suppFile->getLanguage(), false);
XMLCustomWriter::setAttribute($root, 'show_reviewers', $suppFile->getShowReviewers() ? 'true' : '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);
}
}
//.........这里部分代码省略.........
示例12: callbackFinish
/**
* Index rebuild cleanup: mark select options as clean.
*/
function callbackFinish($hookName, $args)
{
$searchFormElementDao =& DAORegistry::getDAO('SearchFormElementDAO');
$searchFormElements =& $searchFormElementDao->getSearchFormElements();
while ($searchFormElement =& $searchFormElements->next()) {
$searchFormElement->setIsClean(true);
$searchFormElementDao->updateSearchFormElement($searchFormElement);
unset($searchFormElement);
}
if ($this->isUsingSolr()) {
import('lib.pkp.classes.xml.XMLCustomWriter');
$doc =& XMLCustomWriter::createDocument('commit', SOLR_DTD_ID, SOLR_DTD_URL);
$docNode =& XMLCustomWriter::createElement($doc, 'commit');
XMLCustomWriter::appendChild($doc, $docNode);
$this->solrQuery($doc);
unset($doc);
$doc =& XMLCustomWriter::createDocument('optimize', SOLR_DTD_ID, SOLR_DTD_URL);
$docNode =& XMLCustomWriter::createElement($doc, 'optimize');
XMLCustomWriter::appendChild($doc, $docNode);
$this->solrQuery($doc);
unset($doc);
} else {
$index =& $this->getIndex();
$index->optimize();
}
}
示例13: explode
/**
* Create a new XML node.
* @param $doc XMLNode|DOMImplementation
* @param $nodePath string an XPath-like string that describes the
* node to be created.
* @param $value string the value to be added as a text node (if any)
* @return XMLNode|DOMDocument
*/
function &_createNode($doc, $nodePath, $value = null)
{
// Separate the element name from the attributes.
$elementPlusAttributes = explode('[', $nodePath);
$element = $elementPlusAttributes[0];
assert(!empty($element));
// Create the element.
$newNode =& XMLCustomWriter::createElement($doc, $element);
// Check for configurable attributes in element value, remove them from value
// and add them to regular attributes
$attributeOffset = strpos($value, '[@');
if ($attributeOffset !== false) {
// no configurable attributes
if (count($elementPlusAttributes) < 2) {
$elementPlusAttributes[] = '';
}
if ($attributeOffset !== 0) {
$elementPlusAttributes[1] = rtrim($elementPlusAttributes[1], ']') . ltrim(substr($value, $attributeOffset), '[');
$value = substr($value, 0, $attributeOffset);
} else {
$elementPlusAttributes[1] = rtrim($elementPlusAttributes[1], ']') . ltrim(substr($value, $attributeOffset), '[');
$value = "";
}
}
// Add attributes.
if (count($elementPlusAttributes) == 2) {
// Separate the attribute key/value pairs.
$unparsedAttributes = explode('@', rtrim(ltrim($elementPlusAttributes[1], '@'), ']'));
foreach ($unparsedAttributes as $unparsedAttribute) {
// Split attribute expressions into key and value.
list($attributeName, $attributeValue) = explode('=', rtrim($unparsedAttribute, ' '));
$attributeValue = trim($attributeValue, '"');
XMLCustomWriter::setAttribute($newNode, $attributeName, $attributeValue);
}
}
// Insert a text node if we got a value for it.
if (!is_null($value)) {
$textNode =& XMLCustomWriter::createTextNode($doc, $value);
XMLCustomWriter::appendChild($newNode, $textNode);
}
return $newNode;
}
示例14: date
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;
}
示例15: exportIssues
function exportIssues(&$journal, &$issues, $outputFile = null)
{
$this->import('CrossRefExportDom');
$doc =& CrossRefExportDom::generateCrossRefDom();
$doiBatchNode =& CrossRefExportDom::generateDoiBatchDom($doc);
$journal =& Request::getJournal();
// Create Head Node and all parts inside it
$head =& CrossRefExportDom::generateHeadDom($doc, $journal);
// attach it to the root node
XMLCustomWriter::appendChild($doiBatchNode, $head);
$bodyNode =& XMLCustomWriter::createElement($doc, 'body');
XMLCustomWriter::appendChild($doiBatchNode, $bodyNode);
$sectionDao =& DAORegistry::getDAO('SectionDAO');
$publishedArticleDao =& DAORegistry::getDAO('PublishedArticleDAO');
foreach ($issues as $issue) {
foreach ($sectionDao->getSectionsForIssue($issue->getId()) as $section) {
foreach ($publishedArticleDao->getPublishedArticlesBySectionId($section->getId(), $issue->getId()) as $article) {
// Create the metadata node
// this does not need to be repeated for every article
// but its allowed to be and its simpler to do so
$journalNode =& XMLCustomWriter::createElement($doc, 'journal');
$journalMetadataNode =& CrossRefExportDom::generateJournalMetadataDom($doc, $journal);
XMLCustomWriter::appendChild($journalNode, $journalMetadataNode);
$journalIssueNode =& CrossRefExportDom::generateJournalIssueDom($doc, $journal, $issue, $section, $article);
XMLCustomWriter::appendChild($journalNode, $journalIssueNode);
// Article node
$journalArticleNode =& CrossRefExportDom::generateJournalArticleDom($doc, $journal, $issue, $section, $article);
XMLCustomWriter::appendChild($journalNode, $journalArticleNode);
// DOI data node
$DOIdataNode =& CrossRefExportDom::generateDOIdataDom($doc, $article->getDOI(), Request::url(null, 'article', 'view', $article->getId()));
XMLCustomWriter::appendChild($journalArticleNode, $DOIdataNode);
XMLCustomWriter::appendChild($bodyNode, $journalNode);
}
}
}
// dump out results
if (!empty($outputFile)) {
if (($h = fopen($outputFile, 'w')) === false) {
return false;
}
fwrite($h, XMLCustomWriter::getXML($doc));
fclose($h);
} else {
header("Content-Type: application/xml");
header("Cache-Control: private");
header("Content-Disposition: attachment; filename=\"crossref.xml\"");
XMLCustomWriter::printXML($doc);
}
return true;
}