Commit 0a5bee7d6fbe34d59a45d268e216fec21016fffd
1 parent
758e562a
Trying to Rectify Repo
Showing
12 changed files
with
0 additions
and
1382 deletions
webservice/classes/soap/IPReflectionClass.class.php deleted
| 1 | -<?php | |
| 2 | -/** | |
| 3 | - * An extended reflection/documentation class for classes | |
| 4 | - * | |
| 5 | - * This class extends the reflectionClass class by also parsing the | |
| 6 | - * comment for javadoc compatible @tags and by providing help | |
| 7 | - * functions to generate a WSDL file. THe class might also | |
| 8 | - * be used to generate a phpdoc on the fly | |
| 9 | - * | |
| 10 | - *@author KnowledgeTree Team | |
| 11 | - *@package Webservice | |
| 12 | - *@version Version 0.9 | |
| 13 | - *@extends reflectionClass | |
| 14 | - */ | |
| 15 | -class IPReflectionClass extends reflectionClass { | |
| 16 | - /** @var string class name */ | |
| 17 | - public $classname = null; | |
| 18 | - | |
| 19 | - /** @var string */ | |
| 20 | - public $fullDescription = ""; | |
| 21 | - | |
| 22 | - /** @var string */ | |
| 23 | - public $smallDescription = ""; | |
| 24 | - | |
| 25 | - /** @var IPReflectionMethod[] */ | |
| 26 | - public $methods = Array(); | |
| 27 | - | |
| 28 | - /** @var IPReflectionProperty[] */ | |
| 29 | - public $properties = Array(); | |
| 30 | - | |
| 31 | - /** @var string */ | |
| 32 | - public $extends; | |
| 33 | - | |
| 34 | - /** @var string */ | |
| 35 | - private $comment = null; | |
| 36 | - | |
| 37 | - | |
| 38 | - /** | |
| 39 | - * Constructor | |
| 40 | - * | |
| 41 | - * sets the class name and calls the constructor of the reflectionClass | |
| 42 | - * | |
| 43 | - * @param string The class name | |
| 44 | - * @return void | |
| 45 | - */ | |
| 46 | - public function __construct($classname){ | |
| 47 | - $this->classname = $classname; | |
| 48 | - parent::__construct($classname); | |
| 49 | - | |
| 50 | - $this->parseComment(); | |
| 51 | - } | |
| 52 | - | |
| 53 | - /** | |
| 54 | - *Provides all methods exposed by this class as an array | |
| 55 | - * | |
| 56 | - * @param boolean If the method should also return protected functions | |
| 57 | - * @param boolean If the method should also return private functions | |
| 58 | - * @return IPReflectionMethod[] | |
| 59 | - */ | |
| 60 | - public function getMethods($alsoProtected = true, $alsoPrivate = true){ | |
| 61 | - $ar = parent::getMethods(); | |
| 62 | - foreach($ar as $method){ | |
| 63 | - $m = new IPReflectionMethod($this->classname, $method->name); | |
| 64 | - if((!$m->isPrivate() || $alsoPrivate) && (!$m->isProtected() || $alsoProtected) && ($m->getDeclaringClass()->name == $this->classname)) | |
| 65 | - $this->methods[$method->name] = $m; | |
| 66 | - } | |
| 67 | - ksort($this->methods); | |
| 68 | - return $this->methods; | |
| 69 | - } | |
| 70 | - | |
| 71 | - /** | |
| 72 | - * Exposes an array with public properties of the class | |
| 73 | - * | |
| 74 | - * @param boolean If the method should also return protected properties | |
| 75 | - * @param boolean If the method should also return private properties | |
| 76 | - * @return IPReflectionProperty[] | |
| 77 | - */ | |
| 78 | - public function getProperties($alsoProtected=true,$alsoPrivate=true) { | |
| 79 | - $ar = parent::getProperties(); | |
| 80 | - $this->properties = Array(); | |
| 81 | - foreach($ar as $property){ | |
| 82 | - if((!$property->isPrivate() || $alsoPrivate) && (!$property->isProtected() || $alsoProtected)){ | |
| 83 | - try{ | |
| 84 | - $p = new IPReflectionProperty($this->classname, $property->getName()); | |
| 85 | - $this->properties[$property->name]=$p; | |
| 86 | - }catch(ReflectionException $exception){ | |
| 87 | - echo "Fault on property: ".$property->name."<br>\n"; | |
| 88 | - } | |
| 89 | - } | |
| 90 | - } | |
| 91 | - ksort($this->properties); | |
| 92 | - return $this->properties; | |
| 93 | - } | |
| 94 | - | |
| 95 | - /** | |
| 96 | - * Exposes annotations of the class | |
| 97 | - * @param $annotationName String the annotation name | |
| 98 | - * @param $annotationClass String the annotation class | |
| 99 | - * @return void | |
| 100 | - */ | |
| 101 | - public function getAnnotation($annotationName, $annotationClass = null){ | |
| 102 | - return IPPhpDoc::getAnnotation($this->comment, $annotationName, $annotationClass); | |
| 103 | - } | |
| 104 | - | |
| 105 | - /** | |
| 106 | - * Gets all the usefull information from the comments | |
| 107 | - * @return void | |
| 108 | - */ | |
| 109 | - private function parseComment() { | |
| 110 | - $this->comment = $this->getDocComment(); | |
| 111 | - new IPReflectionCommentParser($this->comment, $this); | |
| 112 | - } | |
| 113 | -} | |
| 114 | -?> | |
| 115 | 0 | \ No newline at end of file |
webservice/classes/soap/IPReflectionCommentParser.class.php deleted
| 1 | -<?php | |
| 2 | -/** | |
| 3 | - * Class for parsing the comment blocks for classes, functions | |
| 4 | - * methods and properties. | |
| 5 | - * | |
| 6 | - * The class parses the commentblock and extracts certain | |
| 7 | - * documentation tags and the (full/small) description | |
| 8 | - * | |
| 9 | - *@author KnowledgeTree Team | |
| 10 | - *@package Webservice | |
| 11 | - *@version Version 0.9 | |
| 12 | - */ | |
| 13 | - | |
| 14 | -class IPReflectionCommentParser{ | |
| 15 | - /** | |
| 16 | - * @var string Contains the full commen text | |
| 17 | - */ | |
| 18 | - public $comment; | |
| 19 | - | |
| 20 | - /** | |
| 21 | - * @var object refence to the IPReflection(Class|Method|Property) | |
| 22 | - */ | |
| 23 | - public $obj; | |
| 24 | - | |
| 25 | - /** @var boolean */ | |
| 26 | - public $smallDescriptionDone; | |
| 27 | - | |
| 28 | - /** @var boolean */ | |
| 29 | - public $fullDescriptionDone; | |
| 30 | - | |
| 31 | - /** | |
| 32 | - * Constructor, initiateds the parse function | |
| 33 | - * | |
| 34 | - * @param string Commentaar block | |
| 35 | - * @param string Defines if its the comment for a class, public of function | |
| 36 | - */ | |
| 37 | - function __construct($comment, $obj) { | |
| 38 | - $this->comment = $comment; | |
| 39 | - $this->obj = $obj; | |
| 40 | - $this->parse(); | |
| 41 | - } | |
| 42 | - /** | |
| 43 | - * parses the comment, line for line | |
| 44 | - * | |
| 45 | - * Will take the type of comment (class, property or function) as an | |
| 46 | - * argument and split it up in lines. | |
| 47 | - * @param string Defines if its the comment for a class, public of function | |
| 48 | - * @return void | |
| 49 | - */ | |
| 50 | - function parse() { | |
| 51 | - //reset object | |
| 52 | - $descriptionDone = false; | |
| 53 | - $this->fullDescriptionDone = false; | |
| 54 | - | |
| 55 | - //split lines | |
| 56 | - $lines = split("\n", $this->comment); | |
| 57 | - | |
| 58 | - //check lines for description or tags | |
| 59 | - foreach ($lines as $line) { | |
| 60 | - $pos = strpos($line,"* @"); | |
| 61 | - if (trim($line) == "/**" || trim($line) == "*/") { //skip the start and end line | |
| 62 | - }elseif (!($pos === false)) { //comment | |
| 63 | - $this->parseTagLine(substr($line,$pos+3)); | |
| 64 | - $descriptionDone=true; | |
| 65 | - }elseif(!$descriptionDone){ | |
| 66 | - $this->parseDescription($line); | |
| 67 | - } | |
| 68 | - } | |
| 69 | - //if full description is empty, put small description in full description | |
| 70 | - if (trim(str_replace(Array("\n","\r"), Array("", ""), $this->obj->fullDescription)) == "") | |
| 71 | - $this->obj->fullDescription = $this->obj->smallDescription; | |
| 72 | - } | |
| 73 | - | |
| 74 | - /** | |
| 75 | - * Parses the description to the small and full description properties | |
| 76 | - * | |
| 77 | - * @param string The description line | |
| 78 | - * @return void | |
| 79 | - */ | |
| 80 | - | |
| 81 | - function parseDescription($descriptionLine) { | |
| 82 | - if(strpos($descriptionLine,"*") <= 2) $descriptionLine = substr($descriptionLine, (strpos($descriptionLine,"*") + 1)); | |
| 83 | - | |
| 84 | - //geen lege comment regel indien al in grote omschrijving | |
| 85 | - if(trim(str_replace(Array("\n","\r"), Array("", ""), $descriptionLine)) == ""){ | |
| 86 | - if($this->obj->fullDescription == "") | |
| 87 | - $descriptionLine = ""; | |
| 88 | - $this->smallDescriptionDone = true; | |
| 89 | - } | |
| 90 | - | |
| 91 | - if(!$this->smallDescriptionDone)//add to small description | |
| 92 | - $this->obj->smallDescription.=$descriptionLine; | |
| 93 | - else{//add to full description | |
| 94 | - $this->obj->fullDescription.=$descriptionLine; | |
| 95 | - } | |
| 96 | - } | |
| 97 | - | |
| 98 | - /** | |
| 99 | - * Parses a tag line and extracts the tagname and values | |
| 100 | - * | |
| 101 | - * @param string The tagline | |
| 102 | - * @return void | |
| 103 | - */ | |
| 104 | - function parseTagLine($tagLine) { | |
| 105 | - $tagArr = explode(" ", $tagLine); | |
| 106 | - $tag = $tagArr[0]; | |
| 107 | - | |
| 108 | - switch(strtolower($tag)){ | |
| 109 | - case 'abstract': | |
| 110 | - $this->obj->abstract = true; break; | |
| 111 | - case 'access': | |
| 112 | - $this->obj->isPrivate = (strtolower(trim($tagArr[1]))=="private")?true:false; | |
| 113 | - break; | |
| 114 | - case 'author': | |
| 115 | - unset($tagArr[0]); | |
| 116 | - $this->obj->author = implode(" ",$tagArr); | |
| 117 | - break; | |
| 118 | - case 'copyright': | |
| 119 | - unset($tagArr[0]); | |
| 120 | - $this->obj->copyright = implode(" ",$tagArr); | |
| 121 | - break; | |
| 122 | - case 'deprecated': | |
| 123 | - case 'deprec': | |
| 124 | - $this->obj->deprecated = true; | |
| 125 | - break; | |
| 126 | - case 'extends': break; | |
| 127 | - case 'global': | |
| 128 | - $this->obj->globals[] = $tagArr[1]; | |
| 129 | - break; | |
| 130 | - case 'param': | |
| 131 | - $o = new stdClass(); | |
| 132 | - $o->type = trim($tagArr[1]); | |
| 133 | - $o->comment = implode(" ",$tagArr); | |
| 134 | - $this->obj->params[] = $o; | |
| 135 | - break; | |
| 136 | - case 'return': | |
| 137 | - $this->obj->return = trim($tagArr[1]); break; | |
| 138 | - case 'link':break; | |
| 139 | - case 'see':break; | |
| 140 | - case 'since': | |
| 141 | - $this->obj->since = trim($tagArr[1]); break; | |
| 142 | - case 'static': | |
| 143 | - $this->obj->static = true; break; | |
| 144 | - case 'throws': | |
| 145 | - unset($tagArr[0]); | |
| 146 | - $this->obj->throws = implode(" ",$tagArr); | |
| 147 | - break; | |
| 148 | - case 'todo': | |
| 149 | - unset($tagArr[0]); | |
| 150 | - $this->obj->todo[] = implode(" ",$tagArr); | |
| 151 | - break; | |
| 152 | - case 'var': | |
| 153 | - $this->obj->type = trim($tagArr[1]); | |
| 154 | - unset($tagArr[0],$tagArr[1]); | |
| 155 | - $comment=implode(" ",$tagArr); | |
| 156 | - //check if its an optional property | |
| 157 | - $this->obj->optional = strpos($comment,"[OPTIONAL]") !== FALSE; | |
| 158 | - $this->obj->autoincrement = strpos($comment,"[AUTOINCREMENT]") !== FALSE; | |
| 159 | - $this->obj->description = str_replace("[OPTIONAL]", "", $comment); | |
| 160 | - break; | |
| 161 | - case 'version': | |
| 162 | - $this->obj->version = $tagArr[1]; | |
| 163 | - break; | |
| 164 | - default: | |
| 165 | - //echo "\nno valid tag: '".strtolower($tag)."' at tagline: '$tagLine' <br>"; | |
| 166 | - //do nothing | |
| 167 | - } | |
| 168 | - } | |
| 169 | -} | |
| 170 | -?> | |
| 171 | 0 | \ No newline at end of file |
webservice/classes/soap/IPReflectionMethod.class.php deleted
| 1 | -<?php | |
| 2 | -/** | |
| 3 | - * An extended reflection/documentation class for class methods | |
| 4 | - * | |
| 5 | - * This class extends the reflectioMethod class by also parsing the | |
| 6 | - * comment for javadoc compatible @tags and by providing help | |
| 7 | - * functions to generate a WSDL file. The class might also | |
| 8 | - * be used to generate a phpdoc on the fly | |
| 9 | - * | |
| 10 | - *@author KnowledgeTree Team | |
| 11 | - *@package Webservice | |
| 12 | - *@version Version 0.9 | |
| 13 | - *@extends reflectionMethod | |
| 14 | - */ | |
| 15 | - | |
| 16 | -class IPReflectionMethod extends reflectionMethod{ | |
| 17 | - /** @var string class name */ | |
| 18 | - public $classname; | |
| 19 | - | |
| 20 | - /** @var string The return type for this method */ | |
| 21 | - public $return = ""; | |
| 22 | - | |
| 23 | - /** @var IPReflectionParameter[] Associative array with reflectionParameter objects */ | |
| 24 | - public $parameters = array(); | |
| 25 | - | |
| 26 | - /** @var string */ | |
| 27 | - public $fullDescription = ""; | |
| 28 | - | |
| 29 | - /** @var string */ | |
| 30 | - public $smallDescription = ""; | |
| 31 | - | |
| 32 | - /** @var string */ | |
| 33 | - public $throws=""; | |
| 34 | - | |
| 35 | - /** | |
| 36 | - * Constructor which calls the parent constructor and makes sure the comment | |
| 37 | - * of the method is parsed | |
| 38 | - * | |
| 39 | - * @param string The class name | |
| 40 | - * @param string The method name | |
| 41 | - */ | |
| 42 | - public function __construct($class,$method){ | |
| 43 | - $this->classname = $class; | |
| 44 | - parent::__construct($class,$method); | |
| 45 | - $this->parseComment(); | |
| 46 | - } | |
| 47 | - | |
| 48 | - /** | |
| 49 | - * Returns the full function name, including arguments | |
| 50 | - * @return string | |
| 51 | - */ | |
| 52 | - public function getFullName(){ | |
| 53 | - $args = $this->getParameters(); | |
| 54 | - $argstr = ""; | |
| 55 | - | |
| 56 | - foreach((array)$args as $arg){ | |
| 57 | - if($argstr!="")$argstr.=", "; | |
| 58 | - $argstr.= $arg->type ." $".$arg->name; | |
| 59 | - } | |
| 60 | - return $this->return." ".$this->name."(".$argstr.")"; | |
| 61 | - } | |
| 62 | - | |
| 63 | - /** | |
| 64 | - * Returns an array with parameter objects, containing type info etc. | |
| 65 | - * | |
| 66 | - * @return ReflectionParameter[] Associative array with parameter objects | |
| 67 | - */ | |
| 68 | - public function getParameters(){ | |
| 69 | - $this->parameters = Array(); | |
| 70 | - $ar = parent::getParameters(); | |
| 71 | - $i = 0; | |
| 72 | - | |
| 73 | - foreach((array)$ar as $parameter){ | |
| 74 | - $parameter->type = $this->params[$i++]->type; | |
| 75 | - $this->parameters[$parameter->name] = $parameter; | |
| 76 | - } | |
| 77 | - | |
| 78 | - return $this->parameters; | |
| 79 | - } | |
| 80 | - | |
| 81 | - /** | |
| 82 | - * | |
| 83 | - * @param $annotationName String the annotation name | |
| 84 | - * @param $annotationClass String the annotation class | |
| 85 | - * @return void | |
| 86 | - */ | |
| 87 | - public function getAnnotation($annotationName, $annotationClass = null){ | |
| 88 | - return IPPhpDoc::getAnnotation($this->comment, $annotationName, $annotationClass); | |
| 89 | - } | |
| 90 | - | |
| 91 | - /** | |
| 92 | - * Parses the comment and adds found properties to this class | |
| 93 | - * @return void | |
| 94 | - */ | |
| 95 | - private function parseComment(){ | |
| 96 | - $this->comment = $this->getDocComment(); | |
| 97 | - new IPReflectionCommentParser($this->comment, $this); | |
| 98 | - } | |
| 99 | -} | |
| 100 | -?> | |
| 101 | 0 | \ No newline at end of file |
webservice/classes/soap/IPReflectionProperty.class.php deleted
| 1 | -<?php | |
| 2 | -/** | |
| 3 | - * An extended reflection/documentation class for class properties | |
| 4 | - * | |
| 5 | - * This class extends the reflectionProperty class by also parsing the | |
| 6 | - * comment for javadoc compatible @tags and by providing help | |
| 7 | - * functions to generate a WSDL file. The class might also | |
| 8 | - * be used to generate a phpdoc on the fly | |
| 9 | - * | |
| 10 | - *@author KnowledgeTree Team | |
| 11 | - *@package Webservice | |
| 12 | - *@version Version 0.9 | |
| 13 | - *@extends reflectionProperty | |
| 14 | - */ | |
| 15 | -class IPReflectionProperty extends reflectionProperty { | |
| 16 | - /** @var string Classname to whom this property belongs */ | |
| 17 | - public $classname; | |
| 18 | - | |
| 19 | - /** @var string Type description of the property */ | |
| 20 | - public $type = ""; | |
| 21 | - | |
| 22 | - /** @var boolean Determens if the property is a private property */ | |
| 23 | - public $isPrivate = false; | |
| 24 | - | |
| 25 | - /** @var string */ | |
| 26 | - public $description; | |
| 27 | - | |
| 28 | - /** @var boolean */ | |
| 29 | - public $optional = false; | |
| 30 | - | |
| 31 | - /** @var boolean */ | |
| 32 | - public $autoincrement = false; | |
| 33 | - | |
| 34 | - /** @var string */ | |
| 35 | - public $fullDescription = ""; | |
| 36 | - | |
| 37 | - /** @var string */ | |
| 38 | - public $smallDescription = ""; | |
| 39 | - | |
| 40 | - /** @var string */ | |
| 41 | - public $name = null; | |
| 42 | - | |
| 43 | - /** @var string */ | |
| 44 | - private $comment = null; | |
| 45 | - | |
| 46 | - /** | |
| 47 | - * constructor. will initiate the commentParser | |
| 48 | - * | |
| 49 | - * @param string Class name | |
| 50 | - * @param string Property name | |
| 51 | - * @return void | |
| 52 | - */ | |
| 53 | - public function __construct($class, $property){ | |
| 54 | - $this->classname = $class; | |
| 55 | - parent::__construct($class, $property); | |
| 56 | - $this->parseComment(); | |
| 57 | - } | |
| 58 | - | |
| 59 | - /** | |
| 60 | - * | |
| 61 | - * @param $annotationName String the annotation name | |
| 62 | - * @param $annotationClass String the annotation class | |
| 63 | - * @return void | |
| 64 | - */ | |
| 65 | - public function getAnnotation($annotationName, $annotationClass = null){ | |
| 66 | - return IPPhpDoc::getAnnotation($this->comment, $annotationName, $annotationClass); | |
| 67 | - } | |
| 68 | - | |
| 69 | - private function parseComment(){ | |
| 70 | - // No getDocComment available for properties in php 5.0.3 :( | |
| 71 | - $this->comment = $this->getDocComment(); | |
| 72 | - new IPReflectionCommentParser($this->comment, $this); | |
| 73 | - } | |
| 74 | -} | |
| 75 | -?> | |
| 76 | 0 | \ No newline at end of file |
webservice/classes/soap/WSDLException.class.php deleted
| 1 | -<?php | |
| 2 | -/** | |
| 3 | - * Exception class which can be thrown by | |
| 4 | - * the WSDLStruct class. | |
| 5 | - * | |
| 6 | - *@author KnowledgeTree Team | |
| 7 | - *@package Webservice | |
| 8 | - *@version Version 0.9 | |
| 9 | - */ | |
| 10 | -class WSDLException extends Exception { | |
| 11 | - /** | |
| 12 | - * @param string The error message | |
| 13 | - * @return void | |
| 14 | - */ | |
| 15 | - function __construct($msg) { | |
| 16 | - $this->msg = $msg; | |
| 17 | - } | |
| 18 | - /** | |
| 19 | - * @return void | |
| 20 | - */ | |
| 21 | - function Display() { | |
| 22 | - print "Error creating WSDL document:".$this->msg; | |
| 23 | - //var_dump(debug_backtrace()); | |
| 24 | - } | |
| 25 | -} | |
| 26 | -?> | |
| 27 | 0 | \ No newline at end of file |
webservice/classes/soap/WSDLStruct.class.php deleted
| 1 | -<?php | |
| 2 | -/** | |
| 3 | - * Class that can generate a WSDL document from PHP code | |
| 4 | - * | |
| 5 | - * This class generates a WSDL document for the given | |
| 6 | - * methods when the the methods and parameters are documented | |
| 7 | - * enough. When there is not enough documentation available (ie | |
| 8 | - * unclear what the type of a variable or return type is) a | |
| 9 | - * WSDLException is thrown. | |
| 10 | - * | |
| 11 | - * | |
| 12 | - *@author KnowledgeTree Team | |
| 13 | - *@package Webservice | |
| 14 | - *@version Version 0.9 | |
| 15 | - */ | |
| 16 | -class WSDLStruct { | |
| 17 | - /** @var boolean */ | |
| 18 | - public $_debug = false; | |
| 19 | - | |
| 20 | - /** @var int binding type: SOAP_RPC | SOAP_DOCUMENT */ | |
| 21 | - public $binding_style; | |
| 22 | - | |
| 23 | - /** @var int use: SOAP_LITERAL | SOAP_ENCODED */ | |
| 24 | - public $use; | |
| 25 | - /************************** Private properties ***************************/ | |
| 26 | - | |
| 27 | - /** @var SOAPService[] */ | |
| 28 | - private $services = Array(); | |
| 29 | - | |
| 30 | - /** @var domElement[] */ | |
| 31 | - private $serviceTags = Array(); | |
| 32 | - | |
| 33 | - /** @var domElement[] */ | |
| 34 | - private $operationTags = Array(); | |
| 35 | - | |
| 36 | - /** @var domElement[] references to the portType tags. servicename as key */ | |
| 37 | - private $portTypeTags = Array(); | |
| 38 | - | |
| 39 | - /** @var domElement[] references to the binding tags. servicename as key */ | |
| 40 | - private $bindingTags = Array(); | |
| 41 | - | |
| 42 | - /** @var domElement[] references to the binding operation tags. servicename as first key, operationname as second */ | |
| 43 | - private $bindingOperationTags = Array(); | |
| 44 | - | |
| 45 | - /** @var domDocument */ | |
| 46 | - private $doc; | |
| 47 | - | |
| 48 | - /** @var domelement */ | |
| 49 | - private $definitions; | |
| 50 | - | |
| 51 | - /** @var domelement Refference tot the types tag*/ | |
| 52 | - private $typesTag; | |
| 53 | - | |
| 54 | - /** @var domelement Refference to the xsd:schema tag*/ | |
| 55 | - private $xsdSchema; | |
| 56 | - | |
| 57 | - /** @var IPXMLSchema */ | |
| 58 | - private $xmlSchema; | |
| 59 | - | |
| 60 | - //namespaces used | |
| 61 | - const NS_WSDL = "http://schemas.xmlsoap.org/wsdl/"; | |
| 62 | - const NS_SOAP = "http://schemas.xmlsoap.org/wsdl/soap/"; | |
| 63 | - const NS_ENC = "http://schemas.xmlsoap.org/soap/encoding/"; | |
| 64 | - const NS_XSD = "http://www.w3.org/2001/XMLSchema"; | |
| 65 | - | |
| 66 | - const CREATE_EMPTY_INPUTS = true; | |
| 67 | - | |
| 68 | - /* | |
| 69 | - * @param string Target namespace | |
| 70 | - * @param string URL for the webservice | |
| 71 | - * @return void | |
| 72 | - */ | |
| 73 | - public function __construct($tns, $url, $type = SOAP_RPC, $use = SOAP_ENCODED){ | |
| 74 | - if($type != SOAP_RPC && $type != SOAP_DOCUMENT) throw new Exception("Webservice type parameter should be either SOAP_RPC or SOAP_DOCUMENT"); | |
| 75 | - if($use != SOAP_ENCODED && $use != SOAP_LITERAL) throw new Exception("Webservice use parameter should be either SOAP_ENCODED or SOAP_LITERAL"); | |
| 76 | - | |
| 77 | - $this->use = $use; | |
| 78 | - $this->binding_style=$type; | |
| 79 | - $this->tns = $tns; | |
| 80 | - $this->url = $url; | |
| 81 | - $this->doc = new domDocument(); | |
| 82 | - $this->definitions = $this->addElement("wsdl:definitions",$this->doc); | |
| 83 | - | |
| 84 | - $this->typesTag = $this->addElement("wsdl:types", $this->definitions); | |
| 85 | - $this->xsdSchema = $this->addElement("xsd:schema", $this->typesTag); | |
| 86 | - $this->xsdSchema->setAttribute("targetNamespace", $this->tns); | |
| 87 | - $this->xmlSchema = new IPXMLSchema($this->xsdSchema); | |
| 88 | - | |
| 89 | - } | |
| 90 | - | |
| 91 | - /** | |
| 92 | - * Adds the class to the services for this WSDL | |
| 93 | - * | |
| 94 | - * @param IPReflectionClass The service | |
| 95 | - * @return void | |
| 96 | - */ | |
| 97 | - public function setService(IPReflectionClass $class){ | |
| 98 | - $this->services[$class->classname] = $class; | |
| 99 | - $this->services[$class->classname]->getMethods(false, false); | |
| 100 | - } | |
| 101 | - /** | |
| 102 | - * @return string The WSDL document for this structure | |
| 103 | - */ | |
| 104 | - public function generateDocument(){ | |
| 105 | - $this->addToDebug("Generating document"); | |
| 106 | - | |
| 107 | - //add all definitions | |
| 108 | - $definitions=$this->definitions; | |
| 109 | - $definitions->setAttribute("xmlns", self::NS_WSDL); | |
| 110 | - $definitions->setAttribute("xmlns:soap", self::NS_SOAP); | |
| 111 | - $definitions->setAttribute("xmlns:SOAP-ENC", self::NS_ENC); | |
| 112 | - $definitions->setAttribute("xmlns:wsdl", self::NS_WSDL); | |
| 113 | - $definitions->setAttribute("xmlns:xsd", self::NS_XSD); | |
| 114 | - $definitions->setAttribute("xmlns:tns", $this->tns); | |
| 115 | - $definitions->setAttribute("targetNamespace", $this->tns); | |
| 116 | - | |
| 117 | - //add all the services | |
| 118 | - foreach((array)$this->services as $serviceName => $service){ | |
| 119 | - //add the portType | |
| 120 | - $portType = $this->addPortType($serviceName); | |
| 121 | - | |
| 122 | - //add binding | |
| 123 | - $binding = $this->addBinding($serviceName); | |
| 124 | - | |
| 125 | - //loop the operations | |
| 126 | - foreach((array)$service->methods as $operation){ | |
| 127 | - $operationName = $operation->name; | |
| 128 | - $operationTag = $this->addOperation($operationName, $serviceName); | |
| 129 | - | |
| 130 | - //input | |
| 131 | - //only when to operation needs arguments | |
| 132 | - $parameters = $operation->getParameters(); | |
| 133 | - if(count($parameters)>0 || self::CREATE_EMPTY_INPUTS){ | |
| 134 | - $messageName = $operationName."Request"; | |
| 135 | - $input=$this->addElement("wsdl:input", $operationTag); | |
| 136 | - $input->setAttribute("message", "tns:".$messageName); | |
| 137 | - $para=Array(); | |
| 138 | - foreach((array)$parameters as $parameterName => $parameter){ | |
| 139 | - $para[$parameterName] = $parameter->type; | |
| 140 | - } | |
| 141 | - $this->addMessage($messageName, $para); | |
| 142 | - $this->addInput($this->bindingOperationTags[$serviceName][$operationName]); | |
| 143 | - } | |
| 144 | - | |
| 145 | - | |
| 146 | - //output | |
| 147 | - //only when the operation returns something | |
| 148 | - if(!$operation->return || trim($operation->return) == "") throw new WSDLException('No return type for '.$operationName); | |
| 149 | - if(strtolower(trim($operation->return))!='void'){ | |
| 150 | - $messageName = $operationName."Response"; | |
| 151 | - $output = $this->addElement("wsdl:output", $operationTag); | |
| 152 | - $output->setAttribute("message", "tns:".$messageName); | |
| 153 | - $this->addOutput($this->bindingOperationTags[$serviceName][$operationName]); | |
| 154 | - $this->addMessage($messageName,Array($operation->name."Return" => $operation->return)); | |
| 155 | - } | |
| 156 | - } | |
| 157 | - // SH. now add the portType and binding | |
| 158 | - $this->definitions->AppendChild($portType); | |
| 159 | - $this->definitions->AppendChild($binding); | |
| 160 | - | |
| 161 | - //add the service | |
| 162 | - $this->addService($serviceName); | |
| 163 | - | |
| 164 | - } | |
| 165 | - return $this->doc->saveXML(); | |
| 166 | - } | |
| 167 | - | |
| 168 | - /** | |
| 169 | - * Adds a new operation to the given service | |
| 170 | - * @param string operation name | |
| 171 | - * @param string service name | |
| 172 | - * @return domElement | |
| 173 | - */ | |
| 174 | - private function addOperation($operationName, $serviceName){ | |
| 175 | - $this->addToDebug("Adding Operation: '$operationName : $serviceName'"); | |
| 176 | - $operationTag = $this->addElement("wsdl:operation",$this->portTypeTags[$serviceName]); | |
| 177 | - $operationTag->setAttribute("name",$operationName); | |
| 178 | - | |
| 179 | - //create operation tag for binding | |
| 180 | - $bindingOperationTag = $this->addElement("wsdl:operation",$this->bindingTags[$serviceName]); | |
| 181 | - $bindingOperationTag->setAttribute("name",$operationName); | |
| 182 | - | |
| 183 | - //soap operation tag | |
| 184 | - $soapOperationTag = $this->addElement("soap:operation",$bindingOperationTag); | |
| 185 | - $soapOperationTag->setAttribute("soapAction",$this->url."&method=".$operationName); | |
| 186 | - $soapOperationTag->setAttribute("style",($this->binding_style == SOAP_RPC)? "rpc" : "document"); | |
| 187 | - | |
| 188 | - //save references | |
| 189 | - $this->operationTags[$serviceName][$operationName] = $operationTag; | |
| 190 | - $this->bindingOperationTags[$serviceName][$operationName] = $bindingOperationTag; | |
| 191 | - | |
| 192 | - //and return | |
| 193 | - return $operationTag; | |
| 194 | - } | |
| 195 | - | |
| 196 | - /** | |
| 197 | - * adds a new service tag to the WSDL file | |
| 198 | - * @param string the service name | |
| 199 | - * @return domElement | |
| 200 | - */ | |
| 201 | - private function addService($serviceName){ | |
| 202 | - $this->addToDebug("Adding service: '$serviceName'"); | |
| 203 | - //create service | |
| 204 | - $serviceTag=$this->addElement("wsdl:service",$this->definitions); | |
| 205 | - $serviceTag->setAttribute("name",$serviceName); | |
| 206 | - | |
| 207 | - //port tag | |
| 208 | - $portTag=$this->addElement("wsdl:port", $serviceTag); | |
| 209 | - $portTag->setAttribute("name", $serviceName."Port"); | |
| 210 | - $portTag->setAttribute("binding", "tns:".$serviceName."Binding"); | |
| 211 | - | |
| 212 | - //address tag | |
| 213 | - $addressTag = $this->addElement("soap:address", $portTag); | |
| 214 | - $addressTag->setAttribute("location", $this->url); | |
| 215 | - | |
| 216 | - //keep a reference | |
| 217 | - $this->serviceTags[$serviceName] = $serviceTag; | |
| 218 | - //and return | |
| 219 | - return $serviceTag; | |
| 220 | - } | |
| 221 | - | |
| 222 | - /** | |
| 223 | - * Adds a new portType to the WSDL structure | |
| 224 | - * @param string the service name for which we create a portType | |
| 225 | - * @return domElement | |
| 226 | - */ | |
| 227 | - private function addPortType($serviceName){ | |
| 228 | - $this->addToDebug("Adding portType: '$serviceName'"); | |
| 229 | - // SH don't add to main doc just yet | |
| 230 | - // $portTypeTag=$this->addElement("wsdl:portType", $this->definitions); | |
| 231 | - $portTypeTag = $this->addElement("wsdl:portType"); | |
| 232 | - $portTypeTag->setAttribute("name", $serviceName."PortType"); | |
| 233 | - | |
| 234 | - //keep a reference | |
| 235 | - $this->portTypeTags[$serviceName]=$portTypeTag; | |
| 236 | - //and return | |
| 237 | - return $portTypeTag; | |
| 238 | - } | |
| 239 | - | |
| 240 | - /** | |
| 241 | - * Adds a new binding to the WSDL structure | |
| 242 | - * @param string serviceName to bind | |
| 243 | - * @return domElement | |
| 244 | - */ | |
| 245 | - private function addBinding($serviceName){ | |
| 246 | - $this->addToDebug("Adding binding: '$serviceName'"); | |
| 247 | - // SH. don't add to main doc just yet | |
| 248 | - // $bindingTag=$this->addElement("binding"); | |
| 249 | - $bindingTag=$this->addElement("binding",$this->definitions); | |
| 250 | - $bindingTag->setAttribute("name", $serviceName."Binding"); | |
| 251 | - $bindingTag->setAttribute("type", "tns:".$serviceName."PortType"); | |
| 252 | - | |
| 253 | - //soap binding tag | |
| 254 | - $soapBindingTag = $this->addElement("soap:binding", $bindingTag); | |
| 255 | - $soapBindingTag->setAttribute("style", ($this->binding_style == SOAP_RPC)? "rpc" : "document"); | |
| 256 | - $soapBindingTag->setAttribute("transport", "http://schemas.xmlsoap.org/soap/http"); | |
| 257 | - | |
| 258 | - //keep a reference | |
| 259 | - $this->bindingTags[$serviceName] = $bindingTag; | |
| 260 | - //and return | |
| 261 | - return $bindingTag; | |
| 262 | - } | |
| 263 | - | |
| 264 | - /** | |
| 265 | - * Adds a message tag to the WSDL document | |
| 266 | - * @param string Message name | |
| 267 | - * @param Array[string=>string] Array with variables & types | |
| 268 | - */ | |
| 269 | - private function addMessage($name, $parts){ | |
| 270 | - $this->addToDebug("Adding message: '$name'"); | |
| 271 | - $msg = $this->addElement("message", $this->definitions); | |
| 272 | - $msg->setAttribute("name", $name); | |
| 273 | - foreach((array)$parts as $partName => $partType){ | |
| 274 | - $this->addToDebug("Adding Message part: '$partName => $partType'"); | |
| 275 | - $part=$this->addElement("part", $msg); | |
| 276 | - $part->setAttribute("name", $partName); | |
| 277 | - | |
| 278 | - //check if it is a valid XML Schema datatype | |
| 279 | - if($t = IPXMLSchema::checkSchemaType(strtolower($partType))) | |
| 280 | - $part->setAttribute("type", "xsd:".$t); | |
| 281 | - else{ | |
| 282 | - //If it is an array, change the type name | |
| 283 | - $partName = (substr($partType,-2) == "[]")?substr($partType,0,strpos($partType,"["))."Array":$partType; | |
| 284 | - | |
| 285 | - $part->setAttribute("type", "tns:".$partName); | |
| 286 | - $this->xmlSchema->addComplexType($partType, $partName); | |
| 287 | - } | |
| 288 | - } | |
| 289 | - } | |
| 290 | - | |
| 291 | - /** | |
| 292 | - * Adds an input element to the given parent (an operation tag) | |
| 293 | - * @param domNode The Parent domNode | |
| 294 | - * @param boolean Kind of tag. true=input tag, false=output tag | |
| 295 | - * @return domNode The input/output node | |
| 296 | - */ | |
| 297 | - private function addInput($parent, $input=true){ | |
| 298 | - $name = $input ? "wsdl:input" : "wsdl:output"; | |
| 299 | - $tag=$this->addElement($name, $parent); | |
| 300 | - $soapOperation=$this->addElement("soap:body", $tag); | |
| 301 | - $soapOperation->setAttribute("use", ($this->use == SOAP_ENCODED)? "encoded" : "literal"); | |
| 302 | - $soapOperation->setAttribute("namespace", $this->tns); | |
| 303 | - if($this->use == SOAP_ENCODED) | |
| 304 | - $soapOperation->setAttribute("encodingStyle", self::NS_ENC); | |
| 305 | - } | |
| 306 | - | |
| 307 | - /** | |
| 308 | - * Adds an output element to the given parent (an operation tag) | |
| 309 | - * @param domNode The Parent domNode | |
| 310 | - * @return domNode The output node | |
| 311 | - */ | |
| 312 | - private function addOutput($parent){ | |
| 313 | - return $this->addInput($parent,false); | |
| 314 | - } | |
| 315 | - | |
| 316 | - /************************* Supporting functions ****************************/ | |
| 317 | - | |
| 318 | - private function addToDebug($msg){ | |
| 319 | - if($this->_debug) echo '-'.$msg." <br>\n"; | |
| 320 | - } | |
| 321 | - | |
| 322 | - /** | |
| 323 | - * Adds an child element to the parent | |
| 324 | - * @param string The name element | |
| 325 | - * @param domNode | |
| 326 | - * @return domNode | |
| 327 | - */ | |
| 328 | - private function addElement($name, $parent=false, $ns=false){ | |
| 329 | - if($ns) | |
| 330 | - $el=$this->doc->createElementNS($ns,$name); | |
| 331 | - else | |
| 332 | - $el=$this->doc->createElement($name); | |
| 333 | - if($parent) | |
| 334 | - $parent->appendChild($el); | |
| 335 | - return $el; | |
| 336 | - } | |
| 337 | -} | |
| 338 | -?> | |
| 339 | 0 | \ No newline at end of file |
webservice/classes/soap/WSException.class.php deleted
| 1 | -<?php | |
| 2 | -/** | |
| 3 | - * Exception class which can be thrown by | |
| 4 | - * the WSHelper class. | |
| 5 | - *@author KnowledgeTree Team | |
| 6 | - *@package Webservice | |
| 7 | - *@version Version 0.9 | |
| 8 | - */ | |
| 9 | -class WSException extends Exception { | |
| 10 | - /** | |
| 11 | - * @param string The error message | |
| 12 | - * @return void | |
| 13 | - */ | |
| 14 | - public function __construct($msg) { | |
| 15 | - $this->msg = $msg; | |
| 16 | - } | |
| 17 | - /** | |
| 18 | - * @return void | |
| 19 | - */ | |
| 20 | - public function Display() { | |
| 21 | - echo $this->msg; | |
| 22 | - } | |
| 23 | -} | |
| 24 | -?> | |
| 25 | 0 | \ No newline at end of file |
webservice/classes/soap/WSHelper.class.php deleted
| 1 | -<?php | |
| 2 | -/** | |
| 3 | - * Class that generates a WSDL file and creates documentation | |
| 4 | - * for the webservices. | |
| 5 | - * | |
| 6 | - *@author KnowledgeTree Team | |
| 7 | - *@package Webservice | |
| 8 | - *@version Version 0.9 | |
| 9 | - */ | |
| 10 | -class WSHelper { | |
| 11 | - private $uri; | |
| 12 | - private $class = null; //IPReflectionClass object | |
| 13 | - private $name; //class name | |
| 14 | - private $persistence = SOAP_PERSISTENCE_SESSION; | |
| 15 | - private $wsdlfile; //wsdl file name | |
| 16 | - private $server; //soap server object | |
| 17 | - | |
| 18 | - public $actor; | |
| 19 | - public $structureMap = array(); | |
| 20 | - public $classNameArr = array(); | |
| 21 | - public $wsdlFolder; //WSDL cache folder | |
| 22 | - public $useWSDLCache = true; | |
| 23 | - | |
| 24 | - public $type = SOAP_RPC; | |
| 25 | - public $use = SOAP_LITERAL; | |
| 26 | - | |
| 27 | - /** | |
| 28 | - * Constructor | |
| 29 | - * @param string The Uri name | |
| 30 | - * @return void | |
| 31 | - */ | |
| 32 | - public function __construct($uri, $class=null){ | |
| 33 | - $this->uri = $uri; | |
| 34 | - $this->setWSDLCacheFolder($_SERVER['DOCUMENT_ROOT'].dirname($_SERVER['PHP_SELF'])."/wsdl/"); | |
| 35 | - if($class) $this->setClass($class); | |
| 36 | - } | |
| 37 | - | |
| 38 | - /** | |
| 39 | - * Adds the given class name to the list of classes | |
| 40 | - * to be included in the documentation/WSDL/Request handlers | |
| 41 | - * @param string | |
| 42 | - * @return void | |
| 43 | - */ | |
| 44 | - public function setClass($name){ | |
| 45 | - $this->name = $name; | |
| 46 | - $this->wsdlfile = $this->wsdlFolder.$this->name.".wsdl"; | |
| 47 | - } | |
| 48 | - | |
| 49 | - public function setWSDLCacheFolder($folder) { | |
| 50 | - $this->wsdlFolder = $folder; | |
| 51 | - //reset wsdlfile | |
| 52 | - $this->wsdlfile = $this->wsdlFolder.$this->name.".wsdl"; | |
| 53 | - } | |
| 54 | - /** | |
| 55 | - * Sets the persistence level for the soap class | |
| 56 | - */ | |
| 57 | - public function setPersistence($persistence) { | |
| 58 | - $this->persistence = $persistence; | |
| 59 | - } | |
| 60 | - | |
| 61 | - /** | |
| 62 | - * Handles everything. Makes sure the webservice is handled, | |
| 63 | - * documentations is generated, or the wsdl is generated, | |
| 64 | - * according to the page request | |
| 65 | - * @return void | |
| 66 | - */ | |
| 67 | - public function handle(){ | |
| 68 | - if(substr($_SERVER['QUERY_STRING'], -4) == 'wsdl'){ | |
| 69 | - $this->showWSDL(); | |
| 70 | - }elseif(isset($GLOBALS['HTTP_RAW_POST_DATA']) && strlen($GLOBALS['HTTP_RAW_POST_DATA'])>0){ | |
| 71 | - $this->handleRequest(); | |
| 72 | - }else{ | |
| 73 | - $this->createDocumentation(); | |
| 74 | - } | |
| 75 | - } | |
| 76 | - /** | |
| 77 | - * Checks if the current WSDL is up-to-date, regenerates if necessary and outputs the WSDL | |
| 78 | - * @return void | |
| 79 | - */ | |
| 80 | - public function showWSDL(){ | |
| 81 | - //check if it's a legal webservice class | |
| 82 | - if(!in_array($this->name, $this->classNameArr)) | |
| 83 | - throw new Exception("No valid webservice class."); | |
| 84 | - | |
| 85 | - //@TODO: nog een mooie oplossing voor het cachen zoeken | |
| 86 | - header("Content-type: text/xml"); | |
| 87 | - if($this->useWSDLCache && file_exists($this->wsdlfile)){ | |
| 88 | - readfile($this->wsdlfile); | |
| 89 | - }else{ | |
| 90 | - //make sure to refresh PHP WSDL cache system | |
| 91 | - ini_set("soap.wsdl_cache_enabled",0); | |
| 92 | - echo $this->createWSDL(); | |
| 93 | - } | |
| 94 | - } | |
| 95 | - | |
| 96 | - private function createWSDL(){ | |
| 97 | - $this->class = new IPReflectionClass($this->name); | |
| 98 | - $wsdl = new WSDLStruct($this->uri, "http://".$_SERVER['HTTP_HOST'].$_SERVER['SCRIPT_NAME']."?class=".$this->name, $this->type, $this->use); | |
| 99 | - $wsdl->setService($this->class); | |
| 100 | - | |
| 101 | - try { | |
| 102 | - $gendoc = $wsdl->generateDocument(); | |
| 103 | - } catch (WSDLException $exception) { | |
| 104 | - $exception->Display(); | |
| 105 | - exit(); | |
| 106 | - } | |
| 107 | - | |
| 108 | - $fh = fopen($this->wsdlfile, "w+"); | |
| 109 | - fwrite($fh, $gendoc); | |
| 110 | - fclose($fh); | |
| 111 | - | |
| 112 | - return $gendoc; | |
| 113 | - } | |
| 114 | - | |
| 115 | - /** | |
| 116 | - * Lets the native PHP5 soap implementation handle the request | |
| 117 | - * after registrating the class | |
| 118 | - * @return void | |
| 119 | - */ | |
| 120 | - private function handleRequest(){ | |
| 121 | - //check if it's a legal webservice class | |
| 122 | - if(!in_array($this->name, $this->classNameArr)) | |
| 123 | - throw new Exception("No valid webservice class."); | |
| 124 | - | |
| 125 | - //check cache | |
| 126 | - //if(!file_exists($this->wsdlfile)) | |
| 127 | - $this->createWSDL(); | |
| 128 | - | |
| 129 | - $options = Array('actor' => $this->actor, 'classmap' => $this->structureMap); | |
| 130 | - | |
| 131 | - header("Content-type: text/xml"); | |
| 132 | - $this->server = new SoapServer($this->wsdlfile, $options); | |
| 133 | - $this->server->setClass($this->name); | |
| 134 | - $this->server->setPersistence($this->persistence); | |
| 135 | - | |
| 136 | - use_soap_error_handler(true); | |
| 137 | - $this->server->handle(); | |
| 138 | - } | |
| 139 | - | |
| 140 | - /** | |
| 141 | - * @param string code | |
| 142 | - * @param string string | |
| 143 | - * @param string actor | |
| 144 | - * @param mixed details | |
| 145 | - * @param string name | |
| 146 | - * @return void | |
| 147 | - */ | |
| 148 | - public function fault($code, $string, $actor, $details, $name='') { | |
| 149 | - return $this->server->fault($code, $string, $actor, $details, $name); | |
| 150 | - } | |
| 151 | - | |
| 152 | - /** | |
| 153 | - * Generates the documentations for the webservice usage. | |
| 154 | - * @TODO: "int", "boolean", "double", "float", "string", "void" | |
| 155 | - * @param string Template filename | |
| 156 | - * @return void | |
| 157 | - */ | |
| 158 | - public function createDocumentation($template="classes/soap/templates/docclass.xsl") { | |
| 159 | - if(!is_file($template)) | |
| 160 | - throw new WSException("Could not find the template file: '$template'"); | |
| 161 | - $this->class = new IPReflectionClass($this->name); | |
| 162 | - $xtpl = new IPXSLTemplate($template); | |
| 163 | - $documentation = Array(); | |
| 164 | - $documentation['menu'] = Array(); | |
| 165 | - //loop menu items | |
| 166 | - sort($this->classNameArr); | |
| 167 | - foreach($this->classNameArr as $className) { | |
| 168 | - $documentation['menu'][] = new IPReflectionClass($className); | |
| 169 | - } | |
| 170 | - | |
| 171 | - if($this->class){ | |
| 172 | - $this->class->properties = $this->class->getProperties(false, false); | |
| 173 | - $this->class->methods = $this->class->getMethods(false, false); | |
| 174 | - foreach((array)$this->class->methods as $method) { | |
| 175 | - $method->params = $method->getParameters(); | |
| 176 | - } | |
| 177 | - | |
| 178 | - $documentation['class'] = $this->class; | |
| 179 | - } | |
| 180 | - echo $xtpl->execute($documentation); | |
| 181 | - } | |
| 182 | -} | |
| 183 | -?> | |
| 184 | 0 | \ No newline at end of file |
webservice/classes/soap/common.php deleted
| 1 | -<?php | |
| 2 | -/** | |
| 3 | -* Implements a cleaner wrapper for webservices API for KnowledgeTree. | |
| 4 | -* | |
| 5 | -* KnowledgeTree Community Edition | |
| 6 | -* Document Management Made Simple | |
| 7 | -* Copyright (C) 2008,2009 KnowledgeTree Inc. | |
| 8 | -* Portions copyright The Jam Warehouse Software (Pty) Limited | |
| 9 | -* | |
| 10 | -* This program is free software; you can redistribute it and/or modify it under | |
| 11 | -* the terms of the GNU General Public License version 3 as published by the | |
| 12 | -* Free Software Foundation. | |
| 13 | -* | |
| 14 | -* This program is distributed in the hope that it will be useful, but WITHOUT | |
| 15 | -* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS | |
| 16 | -* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more | |
| 17 | -* details. | |
| 18 | -* | |
| 19 | -* You should have received a copy of the GNU General Public License | |
| 20 | -* along with this program. If not, see <http://www.gnu.org/licenses/>. | |
| 21 | -* | |
| 22 | -* You can contact KnowledgeTree Inc., PO Box 7775 #87847, San Francisco, | |
| 23 | -* California 94120-7775, or email info@knowledgetree.com. | |
| 24 | -* | |
| 25 | -* The interactive user interfaces in modified source and object code versions | |
| 26 | -* of this program must display Appropriate Legal Notices, as required under | |
| 27 | -* Section 5 of the GNU General Public License version 3. | |
| 28 | -* | |
| 29 | -* In accordance with Section 7(b) of the GNU General Public License version 3, | |
| 30 | -* these Appropriate Legal Notices must retain the display of the "Powered by | |
| 31 | -* KnowledgeTree" logo and retain the original copyright notice. If the display of the | |
| 32 | -* logo is not reasonably feasible for technical reasons, the Appropriate Legal Notices | |
| 33 | -* must display the words "Powered by KnowledgeTree" and retain the original | |
| 34 | -* copyright notice. | |
| 35 | -* | |
| 36 | -* @copyright 2008-2009, KnowledgeTree Inc. | |
| 37 | -* @license GNU General Public License version 3 | |
| 38 | -* @author KnowledgeTree Team | |
| 39 | -* @package Webservice | |
| 40 | -* @version Version 0.1 | |
| 41 | -*/ | |
| 42 | - | |
| 43 | - | |
| 44 | -error_reporting(E_ALL); | |
| 45 | -ob_start("ob_gzhandler"); | |
| 46 | - | |
| 47 | -require_once ("config.php"); | |
| 48 | - | |
| 49 | -if(!extension_loaded("soap")) | |
| 50 | - die("Soap extension not loaded!"); | |
| 51 | - | |
| 52 | -session_start(); | |
| 53 | - | |
| 54 | -/** autoload function for PHP5 | |
| 55 | -* Loads all the classes in the model | |
| 56 | -* | |
| 57 | -*/ | |
| 58 | -function __autoload($classname) { | |
| 59 | - try{ | |
| 60 | - if(file_exists("classes/soap/model/$classname.class.php")) | |
| 61 | - include("classes/soap/model/$classname.class.php"); | |
| 62 | - elseif(file_exists("classes/soap/$classname.class.php")) | |
| 63 | - include("classes/soap/$classname.class.php"); | |
| 64 | - elseif(file_exists("classes/soap/$classname.class.php")) | |
| 65 | - include("classes/soap/$classname.class.php"); | |
| 66 | - } catch (Exception $e) { | |
| 67 | - echo $e->getMessage(); | |
| 68 | - } | |
| 69 | - | |
| 70 | -} | |
| 71 | - | |
| 72 | -/** Write out debug file */ | |
| 73 | -function debug($txt,$file="debug.txt"){ | |
| 74 | - $fp = fopen($file, "a"); | |
| 75 | - fwrite($fp, str_replace("\n","\r\n","\r\n".$txt)); | |
| 76 | - fclose($fp); | |
| 77 | -} | |
| 78 | - | |
| 79 | -/** Write out object in the debug log */ | |
| 80 | -function debugObject($txt,$obj){ | |
| 81 | - ob_start(); | |
| 82 | - print_r($obj); | |
| 83 | - $data = ob_get_contents(); | |
| 84 | - ob_end_clean(); | |
| 85 | - debug($txt."\n".$data); | |
| 86 | -} | |
| 87 | -?> |
webservice/classes/soap/templates/docclass.xsl deleted
| 1 | -<xsl:stylesheet | |
| 2 | - version="1.0" | |
| 3 | - xmlns:xsl="http://www.w3.org/1999/XSL/Transform" | |
| 4 | - xmlns:php="http://php.net/xsl" | |
| 5 | - xmlns:ipub="http://www.ipublisher.nl/4.0" | |
| 6 | - xmlns:exsl="http://exslt.org/common" | |
| 7 | - xmlns:str="http://exslt.org/strings" | |
| 8 | - xmlns:date="http://exslt.org/dates-and-times" | |
| 9 | - extension-element-prefixes="str exsl date" | |
| 10 | - > | |
| 11 | -<xsl:include href="str.replace.function.xsl"/> | |
| 12 | -<xsl:output method="html" encoding="utf-8" indent="yes" doctype-public="-//W3C//DTD XHTML 1.0 Transitional//EN" doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" media-type="text/html"/> | |
| 13 | - | |
| 14 | -<xsl:template match="/model"> | |
| 15 | - <html> | |
| 16 | - <head> | |
| 17 | - <title>Webservices</title> | |
| 18 | - <link rel="stylesheet" href="classes/soap/templates/css/doc.css" type="text/css" ></link> | |
| 19 | - </head> | |
| 20 | - <body> | |
| 21 | - <div id="main"> | |
| 22 | - <div id="mainheader"> | |
| 23 | - <div id="mainheaderpadded"> | |
| 24 | - <xsl:if test="class != ''"> | |
| 25 | - <h1><xsl:value-of select="class/name" /> <a href="?class={class/name}&wsdl"> [WSDL]</a></h1> | |
| 26 | - </xsl:if> | |
| 27 | - </div> | |
| 28 | - </div> | |
| 29 | - <div id="mainpadded"> | |
| 30 | - <table cellpadding="0" cellspacing="0"> | |
| 31 | - <tr> | |
| 32 | - <td id="menu"> | |
| 33 | - <h2>Classes</h2> | |
| 34 | - <xsl:for-each select="/model/menu/*"> | |
| 35 | - <a href="?class={name}"><xsl:value-of select="name"/></a><br /> | |
| 36 | - </xsl:for-each> | |
| 37 | - </td> | |
| 38 | - <td id="content"> | |
| 39 | - <xsl:if test="fault != ''"> | |
| 40 | - <xsl:value-of select="fault" /> | |
| 41 | - </xsl:if> | |
| 42 | - <xsl:if test="class != '' and not(fault)"> | |
| 43 | - | |
| 44 | - <h2>Full description</h2> | |
| 45 | - <p><xsl:value-of select="class/fullDescription" /></p> | |
| 46 | - | |
| 47 | - <h2>Properties</h2> | |
| 48 | - <xsl:for-each select="class/properties/*"> | |
| 49 | - <a name="property_{name}"></a> | |
| 50 | - <div class="property{warning}"> | |
| 51 | - <b><xsl:value-of select="name" /></b><br /> | |
| 52 | - <xsl:choose> | |
| 53 | - <xsl:when test="type != ''"> | |
| 54 | - <xsl:choose> | |
| 55 | - <xsl:when test="contains('int,boolean,double,float,string,void', type)"> | |
| 56 | - <i>type <xsl:value-of select="type" /></i><br /> | |
| 57 | - </xsl:when> | |
| 58 | - <xsl:otherwise> | |
| 59 | - <i>type <a href="?class={str:replace(type,'[]','')}"><xsl:value-of select="type" /></a></i><br /> | |
| 60 | - </xsl:otherwise> | |
| 61 | - </xsl:choose> | |
| 62 | - </xsl:when> | |
| 63 | - <xsl:otherwise> | |
| 64 | - <div class='warning'><img src='classes/soap/templates/images/doc/warning.gif'/> missing type info</div><br /> | |
| 65 | - </xsl:otherwise> | |
| 66 | - </xsl:choose> | |
| 67 | - <xsl:value-of select="fullDescription" /> | |
| 68 | - </div> | |
| 69 | - </xsl:for-each> | |
| 70 | - | |
| 71 | - <h2>Methods</h2> | |
| 72 | - <xsl:for-each select="class/methods/*"> | |
| 73 | - <a name="method_{name}"></a> | |
| 74 | - <div class="method{warning}"> | |
| 75 | - <b><xsl:value-of select="name" /></b>( | |
| 76 | - <xsl:for-each select="params/*"> | |
| 77 | - <xsl:value-of select="name"/> | |
| 78 | - <xsl:if test="position() != last()">,</xsl:if> | |
| 79 | - </xsl:for-each> | |
| 80 | - ) | |
| 81 | - <br /> | |
| 82 | - <xsl:choose> | |
| 83 | - <xsl:when test="return != ''"> | |
| 84 | - <xsl:choose> | |
| 85 | - <xsl:when test="contains('int,boolean,double,float,string,void', return)"> | |
| 86 | - <i>returns <xsl:value-of select="return" /></i><br /> | |
| 87 | - </xsl:when> | |
| 88 | - <xsl:otherwise> | |
| 89 | - <i>returns <a href="?class={str:replace(return,'[]','')}"><xsl:value-of select="return" /></a></i><br /> | |
| 90 | - </xsl:otherwise> | |
| 91 | - </xsl:choose> | |
| 92 | - </xsl:when> | |
| 93 | - <xsl:otherwise> | |
| 94 | - <div class='warning'><img src='images/doc/warning.gif'/> missing return value</div><br /> | |
| 95 | - </xsl:otherwise> | |
| 96 | - </xsl:choose> | |
| 97 | - <xsl:choose> | |
| 98 | - <xsl:when test="throws != ''"> | |
| 99 | - <i>throws <xsl:value-of select="throws" /></i><br /> | |
| 100 | - </xsl:when> | |
| 101 | - </xsl:choose> | |
| 102 | - <xsl:value-of select="fullDescription" /><br /> | |
| 103 | - </div> | |
| 104 | - </xsl:for-each> | |
| 105 | - </xsl:if> | |
| 106 | - </td> | |
| 107 | - </tr> | |
| 108 | - </table> | |
| 109 | - | |
| 110 | - </div> | |
| 111 | - <div id="mainfooter"><img src="images/doc/backbottom.jpg" /></div> | |
| 112 | - </div> | |
| 113 | - </body> | |
| 114 | - </html> | |
| 115 | -</xsl:template> | |
| 116 | -</xsl:stylesheet> | |
| 117 | 0 | \ No newline at end of file |
webservice/classes/soap/templates/str.replace.function.xsl deleted
| 1 | -<?xml version="1.0"?> | |
| 2 | -<xsl:stylesheet version="1.0" | |
| 3 | - xmlns:xsl="http://www.w3.org/1999/XSL/Transform" | |
| 4 | - xmlns:str="http://exslt.org/strings" | |
| 5 | - xmlns:func="http://exslt.org/functions" | |
| 6 | - xmlns:exsl="http://exslt.org/common" | |
| 7 | - extension-element-prefixes="str exsl func"> | |
| 8 | - | |
| 9 | -<func:function name="str:replace"> | |
| 10 | - <xsl:param name="string" select="''" /> | |
| 11 | - <xsl:param name="search" select="/.." /> | |
| 12 | - <xsl:param name="replace" select="/.." /> | |
| 13 | - <xsl:choose> | |
| 14 | - <xsl:when test="not($string)"> | |
| 15 | - <func:result select="/.." /> | |
| 16 | - </xsl:when> | |
| 17 | - <xsl:when test="function-available('exsl:node-set')"> | |
| 18 | - <!-- this converts the search and replace arguments to node sets | |
| 19 | - if they are one of the other XPath types --> | |
| 20 | - <xsl:variable name="search-nodes-rtf"> | |
| 21 | - <xsl:copy-of select="$search" /> | |
| 22 | - </xsl:variable> | |
| 23 | - <xsl:variable name="replace-nodes-rtf"> | |
| 24 | - <xsl:copy-of select="$replace" /> | |
| 25 | - </xsl:variable> | |
| 26 | - <xsl:variable name="replacements-rtf"> | |
| 27 | - <xsl:for-each select="exsl:node-set($search-nodes-rtf)/node()"> | |
| 28 | - <xsl:variable name="pos" select="position()" /> | |
| 29 | - <replace search="{.}"> | |
| 30 | - <xsl:copy-of select="exsl:node-set($replace-nodes-rtf)/node()[$pos]" /> | |
| 31 | - </replace> | |
| 32 | - </xsl:for-each> | |
| 33 | - </xsl:variable> | |
| 34 | - <xsl:variable name="sorted-replacements-rtf"> | |
| 35 | - <xsl:for-each select="exsl:node-set($replacements-rtf)/replace"> | |
| 36 | - <xsl:sort select="string-length(@search)" data-type="number" order="descending" /> | |
| 37 | - <xsl:copy-of select="." /> | |
| 38 | - </xsl:for-each> | |
| 39 | - </xsl:variable> | |
| 40 | - <xsl:variable name="result"> | |
| 41 | - <xsl:choose> | |
| 42 | - <xsl:when test="not($search)"> | |
| 43 | - <xsl:value-of select="$string" /> | |
| 44 | - </xsl:when> | |
| 45 | - <xsl:otherwise> | |
| 46 | - <xsl:call-template name="str:_replace"> | |
| 47 | - <xsl:with-param name="string" select="$string" /> | |
| 48 | - <xsl:with-param name="replacements" select="exsl:node-set($sorted-replacements-rtf)/replace" /> | |
| 49 | - </xsl:call-template> | |
| 50 | - </xsl:otherwise> | |
| 51 | - </xsl:choose> | |
| 52 | - </xsl:variable> | |
| 53 | - <func:result select="exsl:node-set($result)/node()" /> | |
| 54 | - </xsl:when> | |
| 55 | - <xsl:otherwise> | |
| 56 | - <xsl:message terminate="yes"> | |
| 57 | - ERROR: function implementation of str:replace() relies on exsl:node-set(). | |
| 58 | - </xsl:message> | |
| 59 | - </xsl:otherwise> | |
| 60 | - </xsl:choose> | |
| 61 | -</func:function> | |
| 62 | - | |
| 63 | -<xsl:template name="str:_replace"> | |
| 64 | - <xsl:param name="string" select="''" /> | |
| 65 | - <xsl:param name="replacements" select="/.." /> | |
| 66 | - <xsl:choose> | |
| 67 | - <xsl:when test="not($string)" /> | |
| 68 | - <xsl:when test="not($replacements)"> | |
| 69 | - <xsl:value-of select="$string" /> | |
| 70 | - </xsl:when> | |
| 71 | - <xsl:otherwise> | |
| 72 | - <xsl:variable name="replacement" select="$replacements[1]" /> | |
| 73 | - <xsl:variable name="search" select="$replacement/@search" /> | |
| 74 | - <xsl:choose> | |
| 75 | - <xsl:when test="not(string($search))"> | |
| 76 | - <xsl:value-of select="substring($string, 1, 1)" /> | |
| 77 | - <xsl:copy-of select="$replacement/node()" /> | |
| 78 | - <xsl:call-template name="str:_replace"> | |
| 79 | - <xsl:with-param name="string" select="substring($string, 2)" /> | |
| 80 | - <xsl:with-param name="replacements" select="$replacements" /> | |
| 81 | - </xsl:call-template> | |
| 82 | - </xsl:when> | |
| 83 | - <xsl:when test="contains($string, $search)"> | |
| 84 | - <xsl:call-template name="str:_replace"> | |
| 85 | - <xsl:with-param name="string" select="substring-before($string, $search)" /> | |
| 86 | - <xsl:with-param name="replacements" select="$replacements[position() > 1]" /> | |
| 87 | - </xsl:call-template> | |
| 88 | - <xsl:copy-of select="$replacement/node()" /> | |
| 89 | - <xsl:call-template name="str:_replace"> | |
| 90 | - <xsl:with-param name="string" select="substring-after($string, $search)" /> | |
| 91 | - <xsl:with-param name="replacements" select="$replacements" /> | |
| 92 | - </xsl:call-template> | |
| 93 | - </xsl:when> | |
| 94 | - <xsl:otherwise> | |
| 95 | - <xsl:call-template name="str:_replace"> | |
| 96 | - <xsl:with-param name="string" select="$string" /> | |
| 97 | - <xsl:with-param name="replacements" select="$replacements[position() > 1]" /> | |
| 98 | - </xsl:call-template> | |
| 99 | - </xsl:otherwise> | |
| 100 | - </xsl:choose> | |
| 101 | - </xsl:otherwise> | |
| 102 | - </xsl:choose> | |
| 103 | -</xsl:template> | |
| 104 | - | |
| 105 | -</xsl:stylesheet> | |
| 106 | 0 | \ No newline at end of file |
webservice/tests/annotations.php deleted
| 1 | -<? | |
| 2 | -chdir(".."); | |
| 3 | -include "common.php"; | |
| 4 | - | |
| 5 | -class DefaultController { | |
| 6 | - const TYPE_PLAIN = 1; | |
| 7 | - const TYPE_HTML = 2; | |
| 8 | - public $type; | |
| 9 | - public $length; | |
| 10 | -} | |
| 11 | -/** | |
| 12 | - * @ann1('me'=>'you'); | |
| 13 | - */ | |
| 14 | -class something{ | |
| 15 | - /** | |
| 16 | - * @var string | |
| 17 | - * @Controller(type => DefaultController::TYPE_PLAIN, length => 100) | |
| 18 | - */ | |
| 19 | - public $propertyA; | |
| 20 | - | |
| 21 | - /** | |
| 22 | - * @var string | |
| 23 | - * @Controller(type => DefaultController::TYPE_HTML, length => 100) | |
| 24 | - */ | |
| 25 | - public function methodB () { | |
| 26 | - return "aap"; | |
| 27 | - } | |
| 28 | -} | |
| 29 | - | |
| 30 | -/* Annotation example */ | |
| 31 | -$rel = new IPReflectionClass("something"); | |
| 32 | -$properties = $rel->getProperties(); | |
| 33 | -$methods = $rel->getMethods(); | |
| 34 | - | |
| 35 | -var_dump($rel->getAnnotation("ann1", "stdClass")); | |
| 36 | - | |
| 37 | -$property = $properties["propertyA"]; | |
| 38 | -$ann = $property->getAnnotation("Controller", "DefaultController"); | |
| 39 | -var_dump($ann); | |
| 40 | - | |
| 41 | -$method = $methods["methodB"]; | |
| 42 | -$ann = $method->getAnnotation("Controller", "DefaultController"); | |
| 43 | -var_dump($ann); | |
| 44 | -?> | |
| 45 | 0 | \ No newline at end of file |