Overview

Packages

  • Reflection

Classes

  • Horde_Reflection
  • Horde_Reflection_CLI
  • Horde_Reflection_Html
  • Horde_Reflection_Wiki
  • Overview
  • Package
  • Class
  • Tree
  1: <?php
  2: /**
  3:  * The Horde_Reflection_Html class renders method documention in the HTML
  4:  * format.
  5:  *
  6:  * Based on the PEAR XML_RPC2_Server_Method class by Sergio Carvalho
  7:  *
  8:  * Copyright 2004-2006 Sergio Gonalves Carvalho
  9:  *                     (<sergio.carvalho@portugalmail.com>)
 10:  * Copyright 2008-2012 Horde LLC (http://www.horde.org/)
 11:  *
 12:  * See the enclosed file COPYING for license information (LGPL). If you
 13:  * did not receive this file, see http://www.horde.org/licenses/lgpl21.
 14:  *
 15:  * @author  Sergio Carvalho <sergio.carvalho@portugalmail.com>
 16:  * @author  Duck <duck@obala.net>
 17:  * @author  Jan Schneider <jan@horde.org>
 18:  * @package Reflection
 19:  */
 20: class Horde_Reflection_Html extends Horde_Reflection {
 21: 
 22:     /**
 23:      * Returns a signature of the method.
 24:      *
 25:      * @return string  Method signature.
 26:      */
 27:     private function _getSignature()
 28:     {
 29:         $name = $this->_name;
 30:         $returnType = $this->_returns;
 31:         $result  = "<span class=\"type\">($returnType)</span> ";
 32:         $result .= "<span class=\"name\">$name</span>";
 33:         $result .= "<span class=\"other\">(</span>";
 34:         $first = true;
 35:         $nbr = 0;
 36:         while (list($name, $parameter) = each($this->_parameters)) {
 37:             $nbr++;
 38:             if ($nbr == $this->_numberOfRequiredParameters + 1) {
 39:                 $result .= "<span class=\"other\">[</span>";
 40:             }
 41:             if ($first) {
 42:                 $first = false;
 43:             } else {
 44:                 $result .= ', ';
 45:             }
 46:             $type = $parameter['type'];
 47:             $result .= "<span class=\"paratype\">($type) </span>";
 48:             $result .= "<span class=\"paraname\">$name</span>";
 49:         }
 50:         reset($this->_parameters);
 51:         if ($nbr > $this->_numberOfRequiredParameters) {
 52:             $result .= "<span class=\"other\">]</span>";
 53:         }
 54:         $result .= "<span class=\"other\">)</span>";
 55:         return $result;
 56:     }
 57: 
 58:     /**
 59:      * Returns a complete HTML description of the method.
 60:      *
 61:      * @return string  A HTML snippet with the method documentation.
 62:      */
 63:     public function autoDocument()
 64:     {
 65:         $signature = $this->_getSignature();
 66:         $id = md5($this->_name);
 67:         $help = nl2br(htmlentities($this->_help));
 68:         $html = $this->_header();
 69:         $html .= "  <h3><a name=\"$id\">$signature</a></h3>\n";
 70:         $html .= "      <p><b>Description :</b></p>\n";
 71:         $html .= "      <div class=\"description\">\n";
 72:         $html .= "        $help\n";
 73:         $html .= "      </div>\n";
 74:         if (count($this->_parameters)>0) {
 75:             $html .= "      <p><b>Parameters : </b></p>\n";
 76:             if (count($this->_parameters)>0) {
 77:                 $html .= "      <table>\n";
 78:                 $html .= "        <tr><td><b>Type</b></td><td><b>Name</b></td><td><b>Documentation</b></td></tr>\n";
 79:                 while (list($name, $parameter) = each($this->_parameters)) {
 80:                     $type = $parameter['type'];
 81:                     if (is_array($type)) {
 82:                         $type = implode(' | ', $type);
 83:                     }
 84:                     if (isset($parameter['doc'])) {
 85:                         $doc = htmlentities($parameter['doc']);
 86:                     } else {
 87:                         $doc = '';
 88:                         echo 'Missing doc for ' . $this->_name . '<br />';
 89:                     }
 90:                     $html .= "        <tr><td>$type</td><td>$name</td><td>$doc</td></tr>\n";
 91:                 }
 92:                 reset($this->_parameters);
 93:                 $html .= "      </table>\n";
 94:             }
 95:         }
 96:         $html .= $this->_footer();
 97: 
 98:         return $html;
 99:     }
100: 
101:     private function _header()
102:     {
103:         $html = '
104:         <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
105:         <html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
106:         <head>
107:             <meta http-equiv="Content-Type" content="text/HTML; charset=UTF-8"  />
108:             <title>Available XMLRPC methods for this server</title>
109:             <style type="text/css">
110:             li,p { font-size: 10pt; font-family: Arial,Helvetia,sans-serif; }
111:             a:link { background-color: white; color: blue; text-decoration: underline; font-weight: bold; }
112:             a:visited { background-color: white; color: blue; text-decoration: underline; font-weight: bold; }
113:             table { border-collapse:collapse; width: 100% }
114:             table,td { padding: 5px; border: 1px solid black; }
115:             div.bloc { border: 1px dashed gray; padding: 10px; margin-bottom: 20px; }
116:             div.description { border: 1px solid black; padding: 10px; }
117:             span.type { background-color: white; color: gray; font-weight: normal; }
118:             span.paratype { background-color: white; color: gray; font-weight: normal; }
119:             span.name { background-color: white; color: #660000; }
120:             span.paraname { background-color: white; color: #336600; }
121:             img { border: 0px; }
122:             li { font-size: 12pt; }
123:             </style>
124:         </head>
125:         <body>
126:         ';
127: 
128:         return $html;
129:     }
130: 
131:     private function _footer()
132:     {
133:         return '  </body></html>';
134:     }
135: 
136: }
137: 
138: 
API documentation generated by ApiGen