Exemplo n.º 1
0
 /**
  * Generates the documentation page with all classes, methods etc.
  *
  * @param string Template file (optional)
  *
  * @return string
  */
 public function getDocumentation($template = null)
 {
     if ($template === null) {
         $template = __DIR__ . '/../../doc/templates/docclass.xsl';
     }
     if (!is_file($template)) {
         throw new WSException("Could not find the template file: '{$template}'");
     }
     $xtpl = new IPXSLTemplate($template);
     $documentation = array();
     $documentation['menu'] = array();
     //loop menu items
     $documentation['menu'] = $this->getClasses();
     if ($this->class) {
         if ($this->class->isUserDefined()) {
             $this->class->properties = $this->class->getProperties(false, false);
             $this->class->methods = $this->class->getMethods(false, false);
             foreach ((array) $this->class->methods as $method) {
                 $method->params = $method->getParameters();
             }
         } else {
             $documentation['fault'] = 'Native class';
         }
         $documentation['class'] = $this->class;
     }
     echo $xtpl->execute($documentation);
 }
Exemplo n.º 2
0
 /** Makes a XML node from an object/ array / text */
 static function makeXML($model, $parent, $addToParent = false)
 {
     if (is_array($model)) {
         foreach ($model as $name => $value) {
             if (!is_numeric($name)) {
                 $node = $parent->ownerDocument->createElement($name);
                 $parent->appendChild($node);
                 IPXSLTemplate::makeXml($value, $node, true);
             } else {
                 $node = $parent;
                 IPXSLTemplate::makeXml($value, $node);
             }
         }
     } elseif (is_object($model)) {
         if ($addToParent) {
             $node = $parent;
         } else {
             $node = $parent->ownerDocument->createElement(get_class($model));
             $parent->appendChild($node);
         }
         foreach ($model as $propertyName => $propertyValue) {
             $property = $parent->ownerDocument->createElement($propertyName);
             $node->appendChild($property);
             IPXSLTemplate::makeXml($propertyValue, $property);
         }
     } else {
         $parent->appendChild($parent->ownerDocument->createTextNode($model));
     }
 }
Exemplo n.º 3
0
 /**
  * Generates the documentations for the webservice usage.
  *
  * @TODO: "int", "boolean", "double", "float", "string", "void"
  *
  * @param string Template filename
  */
 public function createDocumentation($template = '')
 {
     if ($template == '') {
         $template = $this->docTemplate;
     }
     if ($template == '') {
         throw new WSException('No template file to generate documentation');
     }
     if (!is_file($template)) {
         throw new WSException("Could not find the template file: '{$template}'");
     }
     $this->class = new IPReflectionClass($this->name);
     $xtpl = new IPXSLTemplate($template);
     $documentation = array();
     $documentation['menu'] = array();
     //loop menu items
     sort($this->classNameArr);
     //ff sorteren
     foreach ($this->classNameArr as $className) {
         $documentation['menu'][] = new IPReflectionClass($className);
     }
     if ($this->class) {
         $this->class->properties = $this->class->getProperties(false, false);
         $this->class->methods = $this->class->getMethods(false, false);
         foreach ((array) $this->class->methods as $method) {
             $method->params = $method->getParameters();
         }
         $documentation['class'] = $this->class;
     }
     echo $xtpl->execute($documentation);
 }