Introduce the Restbase Virtual REST Service class
[lhc/web/wiklou.git] / includes / libs / virtualrest / ParsoidVirtualRESTService.php
index 34e43f9..32a27f7 100644 (file)
@@ -34,13 +34,18 @@ class ParsoidVirtualRESTService extends VirtualRESTService {
         *   * body: array( 'wikitext' => ... ) or array( 'wikitext' => ..., 'body' => true/false )
         *   * $title is optional
         * @param array $params Key/value map
-        *   - URL            : Parsoid server URL
+        *   - url            : Parsoid server URL
         *   - prefix         : Parsoid prefix for this wiki
         *   - timeout        : Parsoid timeout (optional)
         *   - forwardCookies : Cookies to forward to Parsoid, or false. (optional)
         *   - HTTPProxy      : Parsoid HTTP proxy (optional)
         */
        public function __construct( array $params ) {
+               // for backwards compatibility:
+               if ( isset( $params['URL'] ) ) {
+                       $params['url'] = $params['URL'];
+                       unset( $params['URL'] );
+               }
                parent::__construct( $params );
        }
 
@@ -59,11 +64,11 @@ class ParsoidVirtualRESTService extends VirtualRESTService {
                                throw new Exception( "Only 'local' target wiki is currently supported" );
                        } elseif ( $version !== 'v1' ) {
                                throw new Exception( "Only version 1 exists" );
-                       } else if ( $reqType !== 'page' && $reqType !== 'transform' ) {
+                       } elseif ( $reqType !== 'page' && $reqType !== 'transform' ) {
                                throw new Exception( "Request type must be either 'page' or 'transform'" );
                        }
 
-                       $req['url'] = $this->params['URL'] . '/' . urlencode( $this->params['prefix'] ) . '/';
+                       $req['url'] = $this->params['url'] . '/' . urlencode( $this->params['prefix'] ) . '/';
 
                        if ( $reqType === 'page' ) {
                                $title = $parts[3];
@@ -88,8 +93,8 @@ class ParsoidVirtualRESTService extends VirtualRESTService {
                                        if ( !isset( $req['body']['html'] ) ) {
                                                throw new Exception( "You must set an 'html' body key for this request" );
                                        }
-                                       if ( isset( $parts[6] ) ) {
-                                               $req['body']['oldid'] = $parts[6];
+                                       if ( isset( $parts[7] ) ) {
+                                               $req['body']['oldid'] = $parts[7];
                                        }
                                } elseif ( $parts[3] == 'wikitext' && $parts[5] == 'html' ) {
                                        if ( !isset( $req['body']['wikitext'] ) ) {