improve code coverage for demo files
[plcapi.git] / demo / client / introspect.php
index e11ac0e..f8bb6b0 100644 (file)
@@ -1,14 +1,12 @@
-<html>
+<?php require_once __DIR__ . "/_prepend.php"; ?><html lang="en">
 <head><title>xmlrpc - Introspect demo</title></head>
 <body>
 <h1>Introspect demo</h1>
 <h2>Query server for available methods and their description</h2>
 <h3>The code demonstrates usage of multicall and introspection methods</h3>
+<p>You can see the source to this page here: <a href="introspect.php?showSource=1">introspect.php</a></p>
 <?php
 
-include_once __DIR__ . "/../../src/Autoloader.php";
-PhpXmlRpc\Autoloader::register();
-
 function display_error($r)
 {
     print "An error occurred: ";
@@ -16,7 +14,7 @@ function display_error($r)
         . " Reason: '" . $r->faultString() . "'<br/>";
 }
 
-$client = new PhpXmlRpc\Client("http://phpxmlrpc.sourceforge.net/server.php");
+$client = new PhpXmlRpc\Client(XMLRPCSERVER);
 
 // First off, let's retrieve the list of methods available on the remote server
 print "<h3>methods available at http://" . $client->server . $client->path . "</h3>\n";
@@ -29,8 +27,7 @@ if ($resp->faultCode()) {
     $v = $resp->value();
 
     // Then, retrieve the signature and help text of each available method
-    for ($i = 0; $i < $v->arraysize(); $i++) {
-        $methodName = $v->arraymem($i);
+    foreach ($v as $methodName) {
         print "<h4>" . $methodName->scalarval() . "</h4>\n";
         // build messages first, add params later
         $m1 = new PhpXmlRpc\Request('system.methodHelp');
@@ -60,16 +57,15 @@ if ($resp->faultCode()) {
             // note: using PhpXmlRpc\Encoder::decode() here would lead to cleaner code
             $val = $rs[1]->value();
             if ($val->kindOf() == "array") {
-                for ($j = 0; $j < $val->arraysize(); $j++) {
-                    $x = $val->arraymem($j);
-                    $ret = $x->arraymem(0);
-                    print "<code>" . $ret->scalarval() . " "
-                        . $methodName->scalarval() . "(";
-                    if ($x->arraysize() > 1) {
-                        for ($k = 1; $k < $x->arraysize(); $k++) {
-                            $y = $x->arraymem($k);
-                            print $y->scalarval();
-                            if ($k < $x->arraysize() - 1) {
+                foreach ($val as $x) {
+                    $ret = $x[0];
+                    print "<code>" . htmlspecialchars($ret->scalarval()) . " "
+                        . htmlspecialchars($methodName->scalarval()) . "(";
+                    if ($x->count() > 1) {
+                        for ($k = 1; $k < $x->count(); $k++) {
+                            $y = $x[$k];
+                            print htmlspecialchars($y->scalarval());
+                            if ($k < $x->count() - 1) {
                                 print ", ";
                             }
                         }
@@ -85,4 +81,4 @@ if ($resp->faultCode()) {
 }
 ?>
 </body>
-</html>
+</html><?php require_once __DIR__ . "/_append.php"; ?>