IXR_Value example


    function __construct( $data$type = false )
    {
        $this->data = $data;
        if (!$type) {
            $type = $this->calculateType();
        }
        $this->type = $type;
        if ($type == 'struct') {
            // Turn all the values in the array in to new IXR_Value objects             foreach ($this->data as $key => $value) {
                $this->data[$key] = new IXR_Value($value);
            }
        }
        if ($type == 'array') {
            for ($i = 0, $j = count($this->data)$i < $j$i++) {
                $this->data[$i] = new IXR_Value($this->data[$i]);
            }
        }
    }

    /** * PHP4 constructor. */
if ($this->message->messageType != 'methodCall') {
            $this->error(-32600, 'server error. invalid xml-rpc. not conforming to spec. Request must be a methodCall');
        }
        $result = $this->call($this->message->methodName, $this->message->params);

        // Is the result an error?         if (is_a($result, 'IXR_Error')) {
            $this->error($result);
        }

        // Encode the result         $r = new IXR_Value($result);
        $resultxml = $r->getXml();

        // Create the XML         $xml = <<<EOD <methodResponse> <params> <param> <value> $resultxml </value> </param> </params> </methodResponse>
$this->method = $method;
        $this->args = $args;
        $this->xml = <<<EOD <?xml version="1.0"?> <methodCall> <methodName>{$this->method}</methodName> <params> EOD;
        foreach ($this->args as $arg) {
            $this->xml .= '<param><value>';
            $v = new IXR_Value($arg);
            $this->xml .= $v->getXml();
            $this->xml .= "</value></param>\n";
        }
        $this->xml .= '</params></methodCall>';
    }

    /** * PHP4 constructor. */
    public function IXR_Request( $method$args ) {
        self::__construct( $method$args );
    }
Home | Imprint | This part of the site doesn't use cookies.