|
Moodle
2.2.1
http://www.collinsharper.com
|
00001 <?php 00002 // This file is part of Moodle - http://moodle.org/ 00003 // 00004 // Moodle is free software: you can redistribute it and/or modify 00005 // it under the terms of the GNU General Public License as published by 00006 // the Free Software Foundation, either version 3 of the License, or 00007 // (at your option) any later version. 00008 // 00009 // Moodle is distributed in the hope that it will be useful, 00010 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00012 // GNU General Public License for more details. 00013 // 00014 // You should have received a copy of the GNU General Public License 00015 // along with Moodle. If not, see <http://www.gnu.org/licenses/>. 00016 00033 class generate_all_documentation extends XMLDBAction { 00034 00038 function init() { 00039 parent::init(); 00040 00041 // Set own custom attributes 00042 $this->sesskey_protected = false; // This action doesn't need sesskey protection 00043 00044 // Get needed strings 00045 $this->loadStrings(array( 00046 'backtomainview' => 'tool_xmldb', 00047 'documentationintro' => 'tool_xmldb', 00048 'docindex' => 'tool_xmldb' 00049 )); 00050 } 00051 00057 function invoke() { 00058 parent::invoke(); 00059 00060 $result = true; 00061 00062 // Set own core attributes 00063 $this->does_generate = ACTION_GENERATE_HTML; 00064 00065 // These are always here 00066 global $CFG, $XMLDB; 00067 00068 // Do the job, setting $result as needed 00069 00070 // Add link back to home 00071 $b = ' <p class="centerpara buttons">'; 00072 $b .= ' <a href="index.php?action=main_view#lastused">[' . $this->str['backtomainview'] . ']</a>'; 00073 $b .= '</p>'; 00074 $this->output=$b; 00075 00076 $c = ' <p class="centerpara">'; 00077 $c .= $this->str['documentationintro']; 00078 $c .= '</p>'; 00079 $this->output.=$c; 00080 00081 $this->docs = ''; 00082 00083 if(class_exists('XSLTProcessor')) { 00084 00085 $doc = new DOMDocument(); 00086 $xsl = new XSLTProcessor(); 00087 00088 $doc->load(dirname(__FILE__).'/../generate_documentation/xmldb.xsl'); 00089 $xsl->importStyleSheet($doc); 00090 00091 $dbdirs = get_db_directories(); 00092 sort($dbdirs); 00093 $index = $this->str['docindex'] . ' '; 00094 foreach ($dbdirs as $path) { 00095 00096 if (!file_exists($path . '/install.xml')) { 00097 continue; 00098 } 00099 00100 $dir = trim(dirname(str_replace($CFG->dirroot, '', $path)), '/'); 00101 $index .= '<a href="#file_' . str_replace('/', '_', $dir) . '">' . $dir . '</a>, '; 00102 $this->docs .= '<div class="file" id="file_' . str_replace('/', '_', $dir) . '">'; 00103 $this->docs .= '<h2>' . $dir . '</h2>'; 00104 00105 $doc->load($path . '/install.xml'); 00106 $this->docs.=$xsl->transformToXML($doc); 00107 00108 $this->docs .= '</div>'; 00109 } 00110 00111 $this->output .= '<div id="file_idex">' . trim($index, ' ,') . '</div>' . $this->docs; 00112 00113 $this->output.=$b; 00114 } else { 00115 $this->output.=get_string('extensionrequired','tool_xmldb','xsl'); 00116 } 00117 00118 // Launch postaction if exists (leave this unmodified) 00119 if ($this->getPostAction() && $result) { 00120 return $this->launch($this->getPostAction()); 00121 } 00122 00123 return $result; 00124 } 00125 } 00126