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


PHP Opus_Document::fromXml方法代码示例

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


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

示例1: import

 /**
  * Imports metadata from an XML-Document
  *
  * @param DOMDocument $data XML-Document to be imported
  * @return array information about the document that has been imported
  */
 public function import($document)
 {
     $this->collections = array();
     $this->values = array();
     $this->series = array();
     $this->personSortOrder = array();
     $this->document = $document;
     $this->oldId = $this->document->getElementsByTagName('IdentifierOpus3')->Item(0)->getAttribute('Value');
     $this->skipEmptyFields();
     $this->validatePersonSubmitterEmail();
     $this->checkTitleMainAbstractForDuplicateLanguage();
     $this->checkTitleAdditional();
     $this->mapDocumentTypeAndLanguage();
     $this->mapElementLanguage();
     $this->mapClassifications();
     $this->mapCollections();
     $this->mapValues();
     $this->getSortOrder();
     $this->createNewEnrichmentKeys();
     $imported = array();
     $doc = null;
     try {
         $doc = Opus_Document::fromXml('<Opus>' . $this->completeXML->saveXML($this->document) . '</Opus>');
         // ThesisGrantor and ThesisPublisher only for Thesis-Documents
         if (in_array($doc->getType(), $this->thesistypes)) {
             if (array_key_exists('grantor', $this->values)) {
                 $dnbGrantor = new Opus_DnbInstitute($this->values['grantor']);
                 $doc->setThesisGrantor($dnbGrantor);
             }
             if (array_key_exists('publisherUniversity', $this->values)) {
                 $dnbPublisher = new Opus_DnbInstitute($this->values['publisherUniversity']);
                 $doc->setThesisPublisher($dnbPublisher);
             }
         }
         if (array_key_exists('licence', $this->values)) {
             $doc->addLicence(new Opus_Licence($this->values['licence']));
         }
         // TODO Opus4.x : Handle SortOrder via Opus_Document_Model
         foreach ($doc->getPersonAuthor() as $a) {
             $lastname = $a->getLastName();
             $firstname = $a->getFirstName();
             $sortorder = $this->personSortOrder[$lastname . "," . $firstname];
             $a->setSortOrder($sortorder);
         }
         foreach ($this->collections as $c) {
             $coll = new Opus_Collection($c);
             $coll->setVisible(1);
             $coll->store();
             $doc->addCollection($coll);
         }
         foreach ($this->series as $s) {
             $series = new Opus_Series($s[0]);
             $doc->addSeries($series)->setNumber($s[1]);
         }
         //$this->logger->log("(3):".$this->completeXML->saveXML($this->document), Zend_Log::DEBUG);
         $doc->store();
         $imported['result'] = 'success';
         $imported['oldid'] = $this->oldId;
         $imported['newid'] = $doc->getId();
         if (array_key_exists('role', $this->values)) {
             $imported['roleid'] = $this->values['role'];
             //$this->logger->log("ROLE_ID'" . $this->values['roleid'] . "', Zend_Log::DEBUG);
         }
     } catch (Exception $e) {
         $imported['result'] = 'failure';
         $imported['message'] = $e->getMessage();
         if (!is_null($doc)) {
             $imported['entry'] = $doc->toXml()->saveXML();
         } else {
             $imported['entry'] = $this->completeXML->saveXML($this->document);
         }
         $imported['oldid'] = $this->oldId;
     }
     unset($this->collections);
     unset($this->series);
     unset($this->values);
     unset($this->document);
     unset($this->oldId);
     return $imported;
 }
开发者ID:alexukua,项目名称:opus4,代码行数:86,代码来源:Opus3XMLImport.php

示例2: dirname

 *
 * LICENCE
 * OPUS is free software; you can redistribute it and/or modify it under the
 * terms of the GNU General Public License as published by the Free Software
 * Foundation; either version 2 of the Licence, or any later version.
 * OPUS is distributed in the hope that it will be useful, but WITHOUT ANY
 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
 * details. You should have received a copy of the GNU General Public License 
 * along with OPUS; if not, write to the Free Software Foundation, Inc., 51 
 * Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 *
 * @category    Application
 * @author      Thoralf Klein <thoralf.klein@zib.de>
 * @copyright   Copyright (c) 2011, OPUS 4 development team
 * @license     http://www.gnu.org/licenses/gpl.html General Public License
 * @version     $Id$
 */
// Bootstrapping
require_once dirname(__FILE__) . '/common/bootstrap.php';
// Remove first argument
array_shift($argv);
// Dump given documents
error_log("dumping document(s): " . implode(", ", $argv));
foreach ($argv as $filename) {
    error_log("loading filename {$filename}...");
    $content = file_get_contents($filename);
    $doc = Opus_Document::fromXml($content);
    $docId = $doc->store();
    error_log("loading filename {$filename}... done.  Document {$docId}.");
}
开发者ID:belapp,项目名称:opus4-application,代码行数:31,代码来源:opus-import-document-xml.php


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