From 54ab56b34924df0d610db84058d1a69ebdf2557c Mon Sep 17 00:00:00 2001 From: sam_marshall Date: Tue, 17 Feb 2009 12:53:51 +0000 Subject: [PATCH] MDL-18208: Make xmldb give sensible error if you try to generate documentation without having xsl extension installed --- .../generate_documentation.class.php | 24 +++++++++++-------- lang/en_utf8/xmldb.php | 1 + 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/admin/xmldb/actions/generate_documentation/generate_documentation.class.php b/admin/xmldb/actions/generate_documentation/generate_documentation.class.php index f733d0ec21..f45dcb6b61 100644 --- a/admin/xmldb/actions/generate_documentation/generate_documentation.class.php +++ b/admin/xmldb/actions/generate_documentation/generate_documentation.class.php @@ -74,16 +74,20 @@ class generate_documentation extends XMLDBAction { $b .= '

'; $this->output=$b; - /// Transform XML file and display it - $doc = new DOMDocument(); - $xsl = new XSLTProcessor(); - - $doc->load(dirname(__FILE__).'/xmldb.xsl'); - $xsl->importStyleSheet($doc); - - $doc->load($path); - $this->output.=$xsl->transformToXML($doc); - $this->output.=$b; + if(class_exists('XSLTProcessor')) { + /// Transform XML file and display it + $doc = new DOMDocument(); + $xsl = new XSLTProcessor(); + + $doc->load(dirname(__FILE__).'/xmldb.xsl'); + $xsl->importStyleSheet($doc); + + $doc->load($path); + $this->output.=$xsl->transformToXML($doc); + $this->output.=$b; + } else { + $this->output.=get_string('extensionrequired','xmldb','xsl'); + } /// Launch postaction if exists (leave this unmodified) if ($this->getPostAction() && $result) { diff --git a/lang/en_utf8/xmldb.php b/lang/en_utf8/xmldb.php index c2b87ffe20..1413852738 100644 --- a/lang/en_utf8/xmldb.php +++ b/lang/en_utf8/xmldb.php @@ -67,6 +67,7 @@ $string['edit_table'] = 'Edit Table'; $string['edit_xml_file'] = 'Edit XML File'; $string['enumvaluesincorrect'] = 'Incorrect values for enum field'; $string['expected'] = 'Expected'; +$string['extensionrequired'] = 'Sorry - the PHP extension \'$a\' is required for this action. Please install the extension if you want to use this feature.'; $string['field'] = 'Field'; $string['fieldnameempty'] = 'Name field empty'; $string['fields'] = 'Fields'; -- 2.39.5