Moodle  2.2.1
http://www.collinsharper.com
C:/xampp/htdocs/moodle/admin/tool/xmldb/actions/generate_documentation/generate_documentation.class.php
Go to the documentation of this file.
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 
00032 class generate_documentation extends XMLDBAction {
00033 
00037     function init() {
00038         parent::init();
00039 
00040         // Set own custom attributes
00041         $this->sesskey_protected = false; // This action doesn't need sesskey protection
00042 
00043         // Get needed strings
00044         $this->loadStrings(array(
00045             'backtomainview' => 'tool_xmldb',
00046             'documentationintro' => 'tool_xmldb'
00047         ));
00048     }
00049 
00055     function invoke() {
00056         parent::invoke();
00057 
00058         $result = true;
00059 
00060         // Set own core attributes
00061         $this->does_generate = ACTION_GENERATE_HTML;
00062 
00063         // These are always here
00064         global $CFG, $XMLDB;
00065 
00066         // Do the job, setting $result as needed
00067 
00068         // Get the dir containing the file
00069         $dirpath = required_param('dir', PARAM_PATH);
00070         $dirpath = $CFG->dirroot . $dirpath;
00071         $path = $dirpath.'/install.xml';
00072         if(!file_exists($path) || !is_readable($path)) {
00073             return false;
00074         }
00075 
00076         // Add link back to home
00077         $b = ' <p class="centerpara buttons">';
00078         $b .= '&nbsp;<a href="index.php?action=main_view#lastused">[' . $this->str['backtomainview'] . ']</a>';
00079         $b .= '</p>';
00080         $this->output=$b;
00081 
00082         $c = ' <p class="centerpara">';
00083         $c .= $this->str['documentationintro'];
00084         $c .= '</p>';
00085         $this->output.=$c;
00086 
00087         if(class_exists('XSLTProcessor')) {
00088             // Transform XML file and display it
00089             $doc = new DOMDocument();
00090             $xsl = new XSLTProcessor();
00091 
00092             $doc->load(dirname(__FILE__).'/xmldb.xsl');
00093             $xsl->importStyleSheet($doc);
00094 
00095             $doc->load($path);
00096             $this->output.=$xsl->transformToXML($doc);
00097             $this->output.=$b;
00098         } else {
00099             $this->output.=get_string('extensionrequired','tool_xmldb','xsl');
00100         }
00101 
00102         // Launch postaction if exists (leave this unmodified)
00103         if ($this->getPostAction() && $result) {
00104             return $this->launch($this->getPostAction());
00105         }
00106 
00107         return $result;
00108     }
00109 }
00110 
 All Data Structures Namespaces Files Functions Variables Enumerations