service.php 4.48 KB
<?php
/**
 * @file	service.php
 * @category freeSN
 * @mailto	code [at] netz.coop
 * @version 0.4.200901
 * @link http://netz.coop
 * 
 *  @copyright Copyright by netz.coop e.G. 2015
 *  
 *
 *   This program 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 3 of the License, or
 *  (at your option) any later version.
 *
 *   This program 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 this program.  If not, see <http://www.gnu.org/licenses/>.
 * 
 */
require_once("include/config.php");
require_once($_LOSP_PATH_TO_ROOT."include/System/php/RequireClass.inc.php");

header('Content-Type: text/xml; charset='.$_LOSP_CHARSET);


if(!array_key_exists($_GET['output'], CONFIG::getConfigServices())) {
	return false;
}


$var_DB = StorableFactory::create($_LOSP_STORABLE_KINDOF, $_LOSP_STORABLE_DATA);

$var_HostAccount = BasisElement::createNewInstance($var_DB, 'Account', 0);

$var_DOMDocument = new DOMDocument('1.0', $_LOSP_CHARSET);
$var_DOMDocument->formatOutput = TRUE;
$var_ResultDOMElement = $var_DOMDocument->appendChild($var_DOMDocument->createElement('content'));
$var_ResultDOMElement->setAttribute('Tree', $_TREE);

LospAuth::login($var_HostAccount, $var_DB);
//Controller::showAccountManagement($var_HostAccount, $var_DB, $var_DOMDocument, $DOMElement_MainMenu, $var_ResultDOMElement, $ErrorDisplay, $_GET);

{
	if(is_array($_GET['p']) && $_GET['p'][0]=='showSingle' && $_GET['p'][1]=='ID'  && is_numeric($_GET['p'][2])) {
               
		if(array_key_exists('TreePart',TreeCONFIG::$Config) && array_key_exists($_GET['p'][2],TreeCONFIG::$Config['TreePart'])){
			$var_MultimediaTextClassName=TreeCONFIG::$Config['TreePart'][$_GET['p'][2]];
		}
		else{
			$var_MultimediaTextClassName='*';
		}

		$var_PartOfBE =& MultimediaText::loadElement($var_HostAccount, $var_DB, $var_MultimediaTextClassName, $var_PartOfID=$_GET['p'][2]);
		BasisElement::loadObjectLevel($var_HostAccount, $var_DB, $var_PartOfBE, 'ForShowSingle' );
		if(array_key_exists(3,$_GET['p']) && $_GET['p'][3]) {
			$var_BasisClipboardname = $_GET['p'][3];
		}else{
			$var_BasisClipboardname = null;
		}
	}
}


if(is_object($var_PartOfBE)) {
	$var_PartOfBEDOMElement = $var_ResultDOMElement->appendChild($var_PartOfBE->getObjDOMElement($var_HostAccount, $var_DB, $var_DOMDocument));
	Controller::runTree($var_HostAccount, $var_DB, $var_DOMDocument, $var_BasisClipboardname, $param_MenuLink=null, $var_PartOfBEDOMElement, $var_PartOfBE, $param_GET_index=3, null, $_GET, null, $param_showDefault=0, $param_MaxDetph=0);
} else {
	$var_ResultDOMElement->appendChild($var_DOMDocument->createElement('Error', 'Could not load BasisElement'));
}

$var_DB->disconnect();
if($_LOSP_DEV_XMLOUTPUT)
{
	/**
	 * @if	$_LOSP_DEV	(kann innerhalb @see config gesetzt werden)
	 *
	 * 		folgende Ausgaben sind nur für die Entwicklungszeit gedacht
	 */
	file_put_contents ( $_LOSP_PATH_TO_ROOT."Temp/XMLOutput.service.$_TREE.xml",  $var_DOMDocument->saveXML());
	$br = '';
	file_put_contents ( $_LOSP_PATH_TO_ROOT."Temp/Service.Calls.$_TREE.txt",date('c').' - remote('.$_SERVER['REMOTE_ADDR'].':'.$_SERVER['REMOTE_PORT'].') - '.$_SERVER['HTTP_COOKIE'].' - '.$_SERVER['QUERY_STRING'].$br,  FILE_APPEND);
}

/**
 * xml (default output)
 */
if(!array_key_exists('output', $_GET)  || $_GET['output']=='xml') {
	$var_ResultDOMElement->setAttribute('output', 'xml');
	echo $var_DOMDocument->saveXML();
	/**
	 * special output
	 */
}
/*else if ($_GET['output']=='hCalendar'){
	Ics::exportIcs($var_DOMDocument);
}*/
else {
	/**
	 * XSLTProcessor
	 */
	{
		$var_ResultDOMElement->setAttribute('output', $_GET['output']);
		$stylesheet = new DOMDocument;
		$stylesheet->load($_LOSP_PATH_TO_ROOT.'include/System/xsl/service.'.$_GET['output'].'.xsl');
		$processor = new XSLTProcessor;
		$processor->registerPHPFunctions();
		$processor->importStylesheet($stylesheet);
		if($_GET['output']!='iCalendar'){
			echo $processor->transformToDoc($var_DOMDocument)->saveXML();
		}
		else{
			Ics::exportIcs($processor->transformToDoc($var_DOMDocument)->saveXML(), $var_PartOfBE->getObjVar('Name'));
		}
	}
}
//echo('||||||**'.$_LOSP_SERVERNAME.'  =>  $_LOSP_PATH_TO_ROOT('.$_LOSP_PATH_TO_ROOT.') $_LOSP_DEV('.$_LOSP_DEV.') **|||');

?>