[ Index ] |
PHP Cross Reference of Unnamed Project |
[Summary view] [Print] [Text view]
1 <?php 2 // This file is part of Moodle - http://moodle.org/ 3 // 4 // Moodle is free software: you can redistribute it and/or modify 5 // it under the terms of the GNU General Public License as published by 6 // the Free Software Foundation, either version 3 of the License, or 7 // (at your option) any later version. 8 // 9 // Moodle is distributed in the hope that it will be useful, 10 // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 // GNU General Public License for more details. 13 // 14 // You should have received a copy of the GNU General Public License 15 // along with Moodle. If not, see <http://www.gnu.org/licenses/>. 16 17 /** 18 * This is the main script for the complete XMLDB interface. From here 19 * all the actions supported will be launched. 20 * 21 * @package tool_xmldb 22 * @copyright (C) 1999 onwards Martin Dougiamas http://dougiamas.com, 23 * (C) 2001-3001 Eloy Lafuente (stronk7) http://contiento.com 24 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 25 */ 26 27 require('../../../config.php'); 28 require_once($CFG->libdir.'/adminlib.php'); 29 require_once($CFG->libdir.'/ddllib.php'); 30 // Add required XMLDB action classes 31 require_once ('actions/XMLDBAction.class.php'); 32 require_once ('actions/XMLDBCheckAction.class.php'); 33 34 35 admin_externalpage_setup('toolxmld'); 36 37 // Add other used libraries 38 require_once($CFG->libdir . '/xmlize.php'); 39 40 // Handle session data 41 global $XMLDB; 42 43 // State is stored in session - we have to serialise it because the classes are not loaded when creating session 44 if (!isset($SESSION->xmldb)) { 45 $XMLDB = new stdClass; 46 } else { 47 $XMLDB = unserialize($SESSION->xmldb); 48 } 49 50 // Some previous checks 51 $site = get_site(); 52 53 require_login(); 54 require_capability('moodle/site:config', context_system::instance()); 55 56 // Body of the script, based on action, we delegate the work 57 $action = optional_param ('action', 'main_view', PARAM_ALPHAEXT); 58 59 // Get the action path and invoke it 60 $actionsroot = "$CFG->dirroot/$CFG->admin/tool/xmldb/actions"; 61 $actionclass = $action . '.class.php'; 62 $actionpath = "$actionsroot/$action/$actionclass"; 63 64 // Load and invoke the proper action 65 if (file_exists($actionpath) && is_readable($actionpath)) { 66 require_once($actionpath); 67 if ($xmldb_action = new $action) { 68 // Invoke it 69 $result = $xmldb_action->invoke(); 70 // store the result in session 71 $SESSION->xmldb = serialize($XMLDB); 72 73 if ($result) { 74 // Based on getDoesGenerate() 75 switch ($xmldb_action->getDoesGenerate()) { 76 case ACTION_GENERATE_HTML: 77 78 $action = optional_param('action', '', PARAM_ALPHAEXT); 79 $postaction = optional_param('postaction', '', PARAM_ALPHAEXT); 80 // If the js exists, load it 81 if ($action) { 82 $script = $CFG->admin . '/tool/xmldb/actions/' . $action . '/' . $action . '.js'; 83 $file = $CFG->dirroot . '/' . $script; 84 if (file_exists($file) && is_readable($file)) { 85 $PAGE->requires->js('/'.$script); 86 } else if ($postaction) { 87 // Try to load the postaction javascript if exists 88 $script = $CFG->admin . '/tool/xmldb/actions/' . $postaction . '/' . $postaction . '.js'; 89 $file = $CFG->dirroot . '/' . $script; 90 if (file_exists($file) && is_readable($file)) { 91 $PAGE->requires->js('/'.$script); 92 } 93 } 94 } 95 96 // Go with standard admin header 97 echo $OUTPUT->header(); 98 echo $OUTPUT->heading($xmldb_action->getTitle()); 99 echo $xmldb_action->getOutput(); 100 echo $OUTPUT->footer(); 101 break; 102 case ACTION_GENERATE_XML: 103 header('Content-type: application/xhtml+xml; charset=utf-8'); 104 echo $xmldb_action->getOutput(); 105 break; 106 } 107 } else { 108 // TODO: need more detailed error info 109 print_error('xmldberror'); 110 } 111 } else { 112 $a = new stdClass(); 113 $a->action = $action; 114 $a->actionclass = $actionclass; 115 print_error('cannotinstantiateclass', 'tool_xmldb', '', $a); 116 } 117 } else { 118 print_error('invalidaction'); 119 } 120 121 if ($xmldb_action->getDoesGenerate() != ACTION_GENERATE_XML) { 122 if (debugging()) { 123 // print_object($XMLDB); 124 } 125 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Thu Aug 11 10:00:09 2016 | Cross-referenced by PHPXref 0.7.1 |