Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Request #11170 script to generate Command/<command>.xml

git-svn-id: http://svn.php.net/repository/pear/pear-core/pear/pear-core/trunk@275053 c90b9560-bf6c-de11-be94-00142212c4b1
  • Loading branch information...
commit 5b867e7c6f003dbfae4f98664eb0647b34b80b29 1 parent c5febe3
dufuz authored
Showing with 57 additions and 0 deletions.
  1. +57 −0 make-command-xml.php
View
57 make-command-xml.php
@@ -0,0 +1,57 @@
+<?php
+/**
+ * Generate the Command/<command>.xml file from its php file
+ * Outputs the XML to stdout.
+ */
+
+// Name of the command, eg 'Remote' for Remote.php's XML output
+$dir = 'PEAR/Command/';
+foreach (scandir($dir) as $file) {
+ $file = explode('.', $file);
+ if (isset($file[1]) && $file[1] === 'php') {
+ generateXML($file[0]);
+ }
+}
+
+function generateXML($name)
+{
+ $file = 'PEAR/Command/' . $name . '.php';
+ if (!file_exists($file)) {
+ die('File '.$file.' doesn\'t exist, perhaps '.$name.' is not a valid command name.');
+ }
+
+ require_once $file;
+ $cmd_name = 'PEAR_Command_' . $name;
+ $a = 't';
+ $cmd = new $cmd_name($a, $a);
+
+ $xml = '<commands version="1.0">'."\n";
+ foreach ($cmd->commands as $command => $docs) {
+ $command = htmlentities($command, ENT_QUOTES, 'UTF-8');
+ $xml .= ' <'.$command.'>'."\n";
+ $xml .= ' <summary>'.htmlentities($docs['summary'], ENT_QUOTES, 'UTF-8', false)."</summary>\n";
+ $xml .= ' <function>'.htmlentities($docs['function'], ENT_QUOTES, 'UTF-8', false)."</function>\n";
+ $xml .= ' <shortcut>'.htmlentities($docs['shortcut'], ENT_QUOTES, 'UTF-8', false)."</shortcut>\n";
+ if (count($docs['options']) === 0) {
+ $xml .= " <options />\n";
+ } else {
+ $xml .= " <options>\n";
+ foreach($docs['options'] as $option => $opt_docs) {
+ $option = htmlentities($option, ENT_QUOTES, 'UTF-8', false);
+ $xml .= ' <'.$option.'>'."\n";
+ $xml .= ' <shortopt>'.htmlentities($opt_docs['shortopt'], ENT_QUOTES, 'UTF-8', false)."</shortopt>\n";
+ $xml .= ' <doc>'.htmlentities($opt_docs['doc'], ENT_QUOTES, 'UTF-8', false)."</doc>\n";
+ if (isset($opt_docs['arg']) && $opt_docs['arg'] != '') {
+ $xml .= ' <arg>'.htmlentities($opt_docs['arg'], ENT_QUOTES, 'UTF-8', false)."</arg>\n";
+ }
+ $xml .= ' </'.$option.'>'."\n";
+ }
+ $xml .= " </options>\n";
+ }
+ $xml .= ' <doc>'.htmlentities($docs['doc'], ENT_QUOTES, 'UTF-8', false)."</doc>\n";
+ $xml .= ' </'.$command.'>'."\n";
+ }
+ $xml .= '</commands>';
+
+ file_put_contents('PEAR/Command/' . $name . '.xml', $xml);
+}
Please sign in to comment.
Something went wrong with that request. Please try again.