Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100755 57 lines (52 sloc) 2.322 kb
5b867e7c » dufuz
2009-02-02 Request #11170 script to generate Command/<command>.xml
1 <?php
2 /**
3 * Generate the Command/<command>.xml file from its php file
4 * Outputs the XML to stdout.
5 */
6
7 // Name of the command, eg 'Remote' for Remote.php's XML output
8 $dir = 'PEAR/Command/';
9 foreach (scandir($dir) as $file) {
10 $file = explode('.', $file);
3221bd9d » dufuz
2009-08-02 make sure Common.php doesn't have a .xml generated
11 if (isset($file[1]) && $file[1] === 'php' && $file[0] != 'Common') {
5b867e7c » dufuz
2009-02-02 Request #11170 script to generate Command/<command>.xml
12 generateXML($file[0]);
13 }
14 }
15
16 function generateXML($name)
17 {
18 $file = 'PEAR/Command/' . $name . '.php';
19 if (!file_exists($file)) {
20 die('File '.$file.' doesn\'t exist, perhaps '.$name.' is not a valid command name.');
21 }
22
23 require_once $file;
24 $cmd_name = 'PEAR_Command_' . $name;
25 $a = 't';
26 $cmd = new $cmd_name($a, $a);
27
28 $xml = '<commands version="1.0">'."\n";
29 foreach ($cmd->commands as $command => $docs) {
30 $command = htmlentities($command, ENT_QUOTES, 'UTF-8');
31 $xml .= ' <'.$command.'>'."\n";
32 $xml .= ' <summary>'.htmlentities($docs['summary'], ENT_QUOTES, 'UTF-8', false)."</summary>\n";
33 $xml .= ' <function>'.htmlentities($docs['function'], ENT_QUOTES, 'UTF-8', false)."</function>\n";
34 $xml .= ' <shortcut>'.htmlentities($docs['shortcut'], ENT_QUOTES, 'UTF-8', false)."</shortcut>\n";
35 if (count($docs['options']) === 0) {
36 $xml .= " <options />\n";
37 } else {
38 $xml .= " <options>\n";
39 foreach($docs['options'] as $option => $opt_docs) {
40 $option = htmlentities($option, ENT_QUOTES, 'UTF-8', false);
41 $xml .= ' <'.$option.'>'."\n";
42 $xml .= ' <shortopt>'.htmlentities($opt_docs['shortopt'], ENT_QUOTES, 'UTF-8', false)."</shortopt>\n";
43 $xml .= ' <doc>'.htmlentities($opt_docs['doc'], ENT_QUOTES, 'UTF-8', false)."</doc>\n";
44 if (isset($opt_docs['arg']) && $opt_docs['arg'] != '') {
45 $xml .= ' <arg>'.htmlentities($opt_docs['arg'], ENT_QUOTES, 'UTF-8', false)."</arg>\n";
46 }
47 $xml .= ' </'.$option.'>'."\n";
48 }
49 $xml .= " </options>\n";
50 }
51 $xml .= ' <doc>'.htmlentities($docs['doc'], ENT_QUOTES, 'UTF-8', false)."</doc>\n";
52 $xml .= ' </'.$command.'>'."\n";
53 }
54 $xml .= '</commands>';
55
56 file_put_contents('PEAR/Command/' . $name . '.xml', $xml);
57 }
Something went wrong with that request. Please try again.