]> git.mjollnir.org Git - moodle.git/commitdiff
webservice MDL-20803 add switch to disable documentation, fix renderer call on login...
authorjerome mouneyrac <jerome@moodle.com>
Mon, 21 Dec 2009 04:01:02 +0000 (04:01 +0000)
committerjerome mouneyrac <jerome@moodle.com>
Mon, 21 Dec 2009 04:01:02 +0000 (04:01 +0000)
admin/settings/plugins.php
lang/en_utf8/admin.php
lang/en_utf8/webservice.php
webservice/renderer.php
webservice/wsdoc.css [new file with mode: 0644]
webservice/wsdoc.php

index f5d6f09a60abb75cfff7defe342efda0faeb15d4..11e44b42f1ceb6db16ac52abb4620bd606dd6866 100644 (file)
@@ -249,6 +249,7 @@ if ($hassiteconfig) {
     if (empty($CFG->enablewebservices)) {
         $temp->add(new admin_setting_heading('webservicesaredisabled', '', get_string('disabledwarning', 'webservice')));
     }
+    $temp->add(new admin_setting_configcheckbox('enablewsdocumentation', get_string('enablewsdocumentation', 'admin'), get_string('configenablewsdocumentation', 'admin'), false));
     $ADMIN->add('webservicesettings', $temp);
     $webservices_available = get_plugin_list('webservice');
     $active_webservices = empty($CFG->webserviceprotocols) ? array() : explode(',', $CFG->webserviceprotocols);
index a31d5e3a8a00ba63d5779dd576ab2e817e9a5e5d..b7026a98a47f6ba32fe36f095be878984246bb04 100644 (file)
@@ -161,6 +161,7 @@ $string['configenablesafebrowserintegration'] = 'This adds the choice \'Require
 $string['configenablestats'] = 'If you choose \'yes\' here, Moodle\'s cronjob will process the logs and gather some statistics.  Depending on the amount of traffic on your site, this can take awhile. If you enable this, you will be able to see some interesting graphs and statistics about each of your courses, or on a sitewide basis.';
 $string['configenabletrusttext'] = 'By default Moodle will always thoroughly clean text that comes from users to remove any possible bad scripts, media etc that could be a security risk.  The Trusted Content system is a way of giving particular users that you trust the ability to include these advanced features in their content without interference.  To enable this system, you need to first enable this setting, and then grant the Trusted Content permission to a specific Moodle role.  Texts created or uploaded by such users will be marked as trusted and will not be cleaned before display.';
 $string['configenablewebservices'] = 'Web services enable other systems to log in to this Moodle and perform operations.  For extra security this feature should be disabled unless you are really using it.';
+$string['configenablewsdocumentation'] = 'Enable auto-generation of web services documentation. A web service user can access to his own documentation without login into Moodle. It display the documentation for the enabled protocols only.';
 $string['configenrolmentplugins'] = 'Please choose the enrolment plugins you wish to use. Don\'t forget to configure the settings properly.<br /><br />You have to indicate which plugins are enabled, and <strong>one</strong> plugin can be set as the default plugin for <em>interactive</em> enrolment. To disable interactive enrolment, set \"enrollable\" to \"No\" in required courses.';
 $string['configerrorlevel'] = 'Choose the amount of PHP warnings that you want to be displayed.  Normal is usually the best choice.';
 $string['configexperimentalsplitrestore'] = 'If enabled, course backup files will be checked for XML errors and split into smaller parts for use in the restore process. This will result in improvements to restore robustness and execution times, particularly for medium to large course backups.';
@@ -427,6 +428,7 @@ $string['enablesafebrowserintegration'] = 'Enable Safe Exam Browser integration'
 $string['enablestats'] = 'Enable statistics';
 $string['enabletrusttext'] = 'Enable Trusted Content';
 $string['enablewebservices'] = 'Enable web services';
+$string['enablewsdocumentation'] = 'Web services documentation';
 $string['allowbeforeblock'] = 'Allowed list will be processed first';
 $string['allowbeforeblockdesc'] = 'By Default, blocked list will be processed first, if this option enabled, allowed IPs list will be processed before blocked list.';
 $string['encoding'] = 'Encoding';
index dfc031cf147897fcf37c4004081f12d166693a73..e1ba2b8521091d10c7d84d338cd1196bdf095690 100644 (file)
@@ -58,6 +58,7 @@ $string['testclient'] = 'Web service test client';
 $string['validuntil'] = 'Valid until';
 $string['webservices'] = 'Web services';
 $string['wsdocumentation'] = 'Web service documentation';
+$string['wsdocumentationdisable'] = 'Web service documentation is disabled.';
 $string['wsdocumentationintro'] = 'Following a listing of web service functions available for the username <b>$a</b>.<br/>In order to create a client we advice you to read the <a href=\"http://docs.moodle.org/en/Development:Creating_a_web_service_and_a_web_service_function#Create_your_own_client\">Moodle documentation</a>';
 $string['wsdocumentationlogin'] = 'Enter your web service username and password.';
 $string['wspassword'] = 'Web service password';
index fa0f074057890722be428f05e6040e2108b22e0d..a17d2fd80656b7c6fd29a3b191c2e8b2ff1e57a9 100644 (file)
@@ -170,8 +170,8 @@ EOF;
 
         $restresponsehtml = "";
 
+        $restresponsehtml .= "<ins><div style=\"border:solid 1px #DEDEDE;background:#FEEBE5;color:#222222;padding:4px;\">";
         $restresponsehtml .= "<pre>";
-        $restresponsehtml .= "<div style=\"border:solid 1px #DEDEDE;background:#FEEBE5;color:#222222;padding:4px;\">";
         $restresponsehtml .= '<b>'.get_string('restcode', 'webservice').'</b><br/>';
         $brakeline = <<<EOF
 
@@ -181,8 +181,7 @@ EOF;
         $content .= $this->description_in_indented_xml_format($returndescription);
         $content .="</RESPONSE>".$brakeline;
         $restresponsehtml .= $brakeline.htmlentities($content).$brakeline;
-        $restresponsehtml .= "</div>";
-        $restresponsehtml .= "</pre>";
+        $restresponsehtml .= "</pre></div></ins>";
         return $restresponsehtml;
     }
 
@@ -262,29 +261,24 @@ EOF;
                 $required = $paramdesc->required?get_string('required', 'webservice'):get_string('optional', 'webservice');
                 $documentationhtml .= "<b>".$paramname . "</b> (" .$required. ")<br/>";
                 $documentationhtml .= "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;".$paramdesc->desc." <br/><br/>";
+                $documentationhtml .= "<ins><div style=\"border:solid 1px #DEDEDE;background:#FFF1BC;color:#222222;padding:4px;\">";
                 $documentationhtml .= "<pre>";
-                $documentationhtml .= "<div style=\"border:solid 1px #DEDEDE;background:#FFF1BC;color:#222222;padding:4px;\">";
-                //$documentationhtml .= print_collapsible_region_start('', 'aera_'.$functionname."_".$paramname,'<b>'.get_string('generalstructure', 'webservice').'</b>',false,true,true);
                 $documentationhtml .= '<b>'.get_string('generalstructure', 'webservice').'</b><br/>';
                 $documentationhtml .= $brakeline.$this->detailed_description_html($paramdesc);
-                //$documentationhtml .= print_collapsible_region_end(true);
-                $documentationhtml .= "</div>";
-                $documentationhtml .= "</pre><br/>";
+                $documentationhtml .= "</pre></div></ins><br/>";
                 if (!empty($activatedprotocol['xmlrpc'])) {
+                    $documentationhtml .= "<ins><div style=\"border:solid 1px #DEDEDE;background:#DFEEE7;color:#222222;padding:4px;\">";
                     $documentationhtml .= "<pre>";
-                    $documentationhtml .= "<div style=\"border:solid 1px #DEDEDE;background:#DFEEE7;color:#222222;padding:4px;\">";
                     $documentationhtml .= '<b>'.get_string('phpparam', 'webservice').'</b><br/>';
                     $documentationhtml .= $brakeline.'['.$paramname.'] =>'.htmlentities($this->xmlrpc_param_description_html($paramdesc)). $brakeline. $brakeline;
-                    $documentationhtml .= "</div><br/>";
-                    $documentationhtml .= "</pre>";
+                    $documentationhtml .= "</pre></div></ins><br/>";
                 }
                 if (!empty($activatedprotocol['rest'])) {
+                    $documentationhtml .= "<ins><div style=\"border:solid 1px #DEDEDE;background:#FEEBE5;color:#222222;padding:4px;\">";
                     $documentationhtml .= "<pre>";
-                    $documentationhtml .= "<div style=\"border:solid 1px #DEDEDE;background:#FEEBE5;color:#222222;padding:4px;\">";
                     $documentationhtml .= '<b>'.get_string('restparam', 'webservice').'</b><br/>';
                     $documentationhtml .= $brakeline.htmlentities($this->rest_param_description_html($paramdesc,$paramname)). $brakeline. $brakeline;
-                    $documentationhtml .= "</div>";
-                    $documentationhtml .= "</pre>";
+                    $documentationhtml .= "</pre></div></ins>";
                 }
                 $documentationhtml .= "</span>";
             }
@@ -297,21 +291,17 @@ EOF;
             }
 
             if (!empty($description->returns_desc)) {
+                $documentationhtml .= "<ins><div style=\"border:solid 1px #DEDEDE;background:#FFF1BC;color:#222222;padding:4px;\">";
                 $documentationhtml .= "<pre>";
-                $documentationhtml .= "<div style=\"border:solid 1px #DEDEDE;background:#FFF1BC;color:#222222;padding:4px;\">";
-                //$documentationhtml .= print_collapsible_region_start('', 'aera_'.$functionname."_xmlrpc_return",'<b>'.get_string('generalstructure', 'webservice').'</b>',false,true,true);
                 $documentationhtml .= '<b>'.get_string('generalstructure', 'webservice').'</b><br/>';
                 $documentationhtml .= $brakeline.$this->detailed_description_html($description->returns_desc);
-                //$documentationhtml .= print_collapsible_region_end(true);
-                $documentationhtml .= "</div>";
-                $documentationhtml .= "</pre><br/>";
+                $documentationhtml .= "</pre></div></ins><br/>";
                 if (!empty($activatedprotocol['xmlrpc'])) {
+                    $documentationhtml .= "<ins><div style=\"border:solid 1px #DEDEDE;background:#DFEEE7;color:#222222;padding:4px;\">";
                     $documentationhtml .= "<pre>";
-                    $documentationhtml .= "<div style=\"border:solid 1px #DEDEDE;background:#DFEEE7;color:#222222;padding:4px;\">";
                     $documentationhtml .= '<b>'.get_string('phpresponse', 'webservice').'</b><br/>';
                     $documentationhtml .= htmlentities($this->xmlrpc_param_description_html($description->returns_desc)).$brakeline.$brakeline;
-                    $documentationhtml .= "</div>";
-                    $documentationhtml .= "</pre><br/>";
+                    $documentationhtml .= "</pre></div></ins><br/>";
                 }
                 if (!empty($activatedprotocol['rest'])) {
                     $documentationhtml .= $this->rest_response_html($functionname, $description->returns_desc);
@@ -323,10 +313,9 @@ EOF;
 
             if (!empty($activatedprotocol['rest'])) {
                 $documentationhtml .= "<span style=\"color:#EA33A6\">".get_string('errorcodes', 'webservice')."</span><br/>";
-                $documentationhtml .= "<span style=\"font-size:80%\">";
+                $documentationhtml .= "<br/><span style=\"font-size:80%\">";
+                $documentationhtml .= "<ins><div style=\"border:solid 1px #DEDEDE;background:#FEEBE5;color:#222222;padding:4px;\">";
                 $documentationhtml .= "<pre>";
-                $documentationhtml .= "<div style=\"border:solid 1px #DEDEDE;background:#FEEBE5;color:#222222;padding:4px;\">";
-
                 $documentationhtml .= '<b>'.get_string('restexception', 'webservice').'</b><br/>';
                 $errormessage = get_string('invalidparameter', 'debug');
                 $restexceptiontext =<<<EOF
@@ -337,8 +326,7 @@ EOF;
 </EXCEPTION>
 EOF;
                 $documentationhtml .= $brakeline.htmlentities($restexceptiontext);
-                $documentationhtml .= "</div>";
-                $documentationhtml .= "</pre><br/>";
+                $documentationhtml .= "</pre></div></ins><br/>";
             $documentationhtml .= "</span>";
             }
             $documentationhtml .= "<br/><br/>";
diff --git a/webservice/wsdoc.css b/webservice/wsdoc.css
new file mode 100644 (file)
index 0000000..e181acc
--- /dev/null
@@ -0,0 +1,26 @@
+/*//////////////////////////////////////////////////////////////////////////
+//                                                                       //
+// This file is part of Moodle - http://moodle.org/                      //
+// Moodle - Modular Object-Oriented Dynamic Learning Environment         //
+//                                                                       //
+// Moodle is free software: you can redistribute it and/or modify        //
+// it under the terms of the GNU General Public License as published by  //
+// the Free Software Foundation, either version 3 of the License, or     //
+// (at your option) any later version.                                   //
+//                                                                       //
+// Moodle is distributed in the hope that it will be useful,             //
+// but WITHOUT ANY WARRANTY; without even the implied warranty of        //
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         //
+// GNU General Public License for more details.                          //
+//                                                                       //
+// You should have received a copy of the GNU General Public License     //
+// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.       //
+//                                                                       //
+//////////////////////////////////////////////////////////////////////////*/
+
+table, td
+{
+    text-align: left;
+    border: 0px solid black;
+}
+
index 33471e5b44ba93a12997f12b0615fe7b5f6ae30a..e94053cca9a626900e6e3c46fc052b123e87f6bc 100644 (file)
@@ -59,7 +59,6 @@ class webservice_documentation_generator {
 
     /**
      * Run the documentation generation
-     * @param bool $simple use simple authentication
      * @return void
      */
     public function run() {
@@ -222,14 +221,17 @@ class webservice_documentation_generator {
      * Generate and display the documentation
      */
     protected function display_documentation_html() {
-        global $PAGE, $OUTPUT, $SITE;
+        global $PAGE, $OUTPUT, $SITE, $CFG;
 
         $PAGE->set_url('/webservice/wsdoc');
         $PAGE->set_docs_path('');
         $PAGE->set_title($SITE->fullname." ".get_string('wsdocumentation', 'webservice'));
         $PAGE->set_heading($SITE->fullname." ".get_string('wsdocumentation', 'webservice'));
         $PAGE->set_pagelayout('popup');
+        $PAGE->set_pagetype('webservice-doc-generator');
 
+        $PAGE->requires->css('webservice/wsdoc.css');
+    
         echo $OUTPUT->header();
 
         $activatedprotocol = array();
@@ -258,10 +260,15 @@ class webservice_documentation_generator {
         $PAGE->set_title($SITE->fullname." ".get_string('wsdocumentation', 'webservice'));
         $PAGE->set_heading($SITE->fullname." ".get_string('wsdocumentation', 'webservice'));
         $PAGE->set_pagelayout('popup');
+        $PAGE->set_pagetype('webservice-doc-generator-login');
+        
+        $PAGE->requires->css('webservice/wsdoc.css');
 
         echo $OUTPUT->header();
-        $renderer = $PAGE->get_renderer('core', 'wsdoc');
+
+        $renderer = $PAGE->get_renderer('core', 'webservice');
         echo $renderer->login_page_html($errormessage);
+        
         echo $OUTPUT->footer();
 
     }
@@ -273,6 +280,11 @@ class webservice_documentation_generator {
 /////// RUN THE SCRIPT ////
 ///////////////////////////
 
+if (empty($CFG->enablewsdocumentation)) {
+    echo get_string('wsdocumentationdisable', 'webservice');
+    die;
+}
+
 //run the documentation generator
 $generator = new webservice_documentation_generator();
 $generator->run();