<?php
//
// +--------------------------------------------------------------------+
// | Sourdough PHP Application Framework |
// +--------------------------------------------------------------------+
// | Copyright (c) 2001-2007 Philip Iezzi, phpee.com |
// | Web http://sourdough.phpee.com/ |
// | License GNU Lesser General Public License (LGPL) |
// +--------------------------------------------------------------------+
// | This library is free software; you can redistribute it and/or |
// | modify it under the terms of the GNU Lesser General Public |
// | License as published by the Free Software Foundation; either |
// | version 2.1 of the License, or (at your option) any later version. |
// +--------------------------------------------------------------------+
//
/**
* Sourdough PHP Application Framework
* @package sourdough
* @subpackage xslt
*/
/**
* SOURDOUGH XSL transformation class for XSLTproc, a command line xslt processor
*
* @package sourdough
* @subpackage xslt
* @author Philip Iezzi <pipo at phpee dot com>
* @author based on XSLT class http://www.neokraft.net, original author: Olivier Meunier
* @copyright Copyright (c) 2001-2007 PHPEE.COM
* @license http://opensource.org/licenses/lgpl-license.php GNU Lesser General Public License
* @version $Id: Sd_Xslt_xsltproc.class.php 3003 2007-12-08 11:05:17Z piezzi $
*/
class Sd_Xslt_xsltproc extends Sd_Xslt {
//[start] Constructor
/**
* Sd_Xslt_xsltproc constructor
*
* @param Sourdough $Sourd Sourdough global object
*/
public function __construct(Sourdough $Sourd)
{
$this->Sourdough = $Sourd;
parent::__construct();
}
//[end]
//[start] Public Methods
/**
* XSLTPROC XSL transformation
*
* @return void
*/
public function transform()
{
$xml = $this->XML;
$xsl = $this->XSL;
if(file_exists($xml) && file_exists($xsl)) {
$cmd = $this->conf['xsltproc_bin'];
if($this->conf['xsltproc_nonet'])
$cmd .= ' -nonet ';
if(is_array($this->params)) {
foreach($this->params as $k => $v) {
$cmd .= ' --param '.$k." \"'".addslashes($v)."'\" ";
}
}
$cmd .= $xsl.' '.$xml;
if($this->conf['show_error'])
$cmd .= ' 2>&1 ';
else
$cmd .= ' 2>/dev/null ';
$output = array();
$returnValue = 0;
exec($cmd,$output,$returnValue);
if($returnValue == 0) {
$this->out = implode("\n", $output);
} else {
if($this->conf['show_error']) {
$this->out = '<pre>'.htmlentities(implode("\n", $output)).'</pre>';
}
}
$this->cmd = $cmd;
} else {
Sd_ErrorManager::raiseError(0, 'XSLT error: xsltproc cannot handle files.');
}
}
/**
* Return XSLTPROC output
*
* @return string
*/
public function output()
{
return str_replace('/>',' />',$this->out);
}
//[end]
}
?>