Skip to content
Snippets Groups Projects
Commit ab3e5f39 authored by mathieugrimault's avatar mathieugrimault Committed by Demian Katz
Browse files

Allow local override of xsl files (#1288)

- Also begin checking a root /xsl directory in preparation for possible future reorganization away from modules.
parent 015bc7a0
No related merge requests found
...@@ -41,6 +41,29 @@ use XSLTProcessor; ...@@ -41,6 +41,29 @@ use XSLTProcessor;
*/ */
class Processor class Processor
{ {
/**
* Locate an XSLT file and return its full path.
*
* @param string $xslt Filename
*
* @return string
* @throws \Exception
*/
protected static function findXslt($xslt)
{
$paths = [
LOCAL_OVERRIDE_DIR . '/xsl/',
APPLICATION_PATH . '/module/VuFind/xsl/',
APPLICATION_PATH . '/xsl/',
];
foreach ($paths as $path) {
if (file_exists($path . $xslt)) {
return $path . $xslt;
}
}
throw new \Exception('Cannot locate ' . $xslt);
}
/** /**
* Perform an XSLT transformation and return the results. * Perform an XSLT transformation and return the results.
* *
...@@ -53,8 +76,7 @@ class Processor ...@@ -53,8 +76,7 @@ class Processor
public static function process($xslt, $xml, $params = []) public static function process($xslt, $xml, $params = [])
{ {
$style = new DOMDocument(); $style = new DOMDocument();
// TODO: support local overrides $style->load(static::findXslt($xslt));
$style->load(APPLICATION_PATH . '/module/VuFind/xsl/' . $xslt);
$xsl = new XSLTProcessor(); $xsl = new XSLTProcessor();
$xsl->importStyleSheet($style); $xsl->importStyleSheet($style);
$doc = new DOMDocument(); $doc = new DOMDocument();
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment