From: stronk7 Date: Thu, 28 May 2009 00:19:59 +0000 (+0000) Subject: MDL-19307 xmldb documentation - generate all the documentation in a BIG report X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=0fa07dab85f6c96ea55d22d04e3ee5e76c18ea2e;p=moodle.git MDL-19307 xmldb documentation - generate all the documentation in a BIG report --- diff --git a/admin/xmldb/actions/generate_all_documentation/generate_all_documentation.class.php b/admin/xmldb/actions/generate_all_documentation/generate_all_documentation.class.php new file mode 100644 index 0000000000..657dde6a43 --- /dev/null +++ b/admin/xmldb/actions/generate_all_documentation/generate_all_documentation.class.php @@ -0,0 +1,124 @@ +. + +/** + * @package xmldb-editor + * @copyright (C) 2001-3001 Eloy Lafuente (stronk7) {@link http://contiento.com} + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ + +/** + * This class will produce the documentation for all the XMLDB files in the server, + * via XSL, performing the output in HTML format. + * + * @package xmldb-editor + * @copyright (C) 2001-3001 Eloy Lafuente (stronk7) {@link http://contiento.com} + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ +class generate_all_documentation extends XMLDBAction { + + /** + * Init method, every subclass will have its own + */ + function init() { + parent::init(); + + /// Set own custom attributes + + /// Get needed strings + $this->loadStrings(array( + 'backtomainview' => 'xmldb', + 'documentationintro' => 'xmldb', + 'docindex' => 'xmldb' + )); + } + + /** + * Invoke method, every class will have its own + * returns true/false on completion, setting both + * errormsg and output as necessary + */ + function invoke() { + parent::invoke(); + + $result = true; + + /// Set own core attributes + $this->does_generate = ACTION_GENERATE_HTML; + + /// These are always here + global $CFG, $XMLDB; + + /// Do the job, setting $result as needed + + /// Add link back to home + $b = '

'; + $b .= ' [' . $this->str['backtomainview'] . ']'; + $b .= '

'; + $this->output=$b; + + $c = '

'; + $c .= $this->str['documentationintro']; + $c .= '

'; + $this->output.=$c; + + $this->docs = ''; + + if(class_exists('XSLTProcessor')) { + + $doc = new DOMDocument(); + $xsl = new XSLTProcessor(); + + $doc->load(dirname(__FILE__).'/../generate_documentation/xmldb.xsl'); + $xsl->importStyleSheet($doc); + + $dbdirs = get_db_directories(); + sort($dbdirs); + $index = $this->str['docindex'] . ' '; + foreach ($dbdirs as $path) { + + if (!file_exists($path . '/install.xml')) { + continue; + } + + $dir = trim(dirname(str_replace($CFG->dirroot, '', $path)), '/'); + $index .= '' . $dir . ', '; + $this->docs .= '
'; + $this->docs .= '

' . $dir . '

'; + + $doc->load($path . '/install.xml'); + $this->docs.=$xsl->transformToXML($doc); + + $this->docs .= '
'; + } + + $this->output .= '
' . trim($index, ' ,') . '
' . $this->docs; + + $this->output.=$b; + } else { + $this->output.=get_string('extensionrequired','xmldb','xsl'); + } + + /// Launch postaction if exists (leave this unmodified) + if ($this->getPostAction() && $result) { + return $this->launch($this->getPostAction()); + } + + return $result; + } +} +?>