Karima Rafes has submitted this change and it was merged.

Change subject: Ready for Wikidata version beta Fix the bug about JQuery 
($.browser) Fix bug with template
......................................................................


Ready for Wikidata version beta
Fix the bug about JQuery ($.browser)
Fix bug with template

Change-Id: I938d7a5d669ef57e54d31985fcfcfcc4110ff924
---
M LinkedWiki.php
M README
A js/FlintSparqlEditor/sparql/lib/jquery-migrate-1.0.0.js
M lib/SPARQL/Curl.php
M lib/SPARQL/Endpoint.php
M lib/SPARQL/README.md
M specialpages/SpecialSparqlQuery.php
7 files changed, 619 insertions(+), 17 deletions(-)

Approvals:
  Karima Rafes: Verified; Looks good to me, approved



diff --git a/LinkedWiki.php b/LinkedWiki.php
index 59372d9..b94abe4 100644
--- a/LinkedWiki.php
+++ b/LinkedWiki.php
@@ -57,6 +57,7 @@
        'ext.LinkedWiki.flint' => $linkedWikiTpl + array(
                'scripts' => array(
                        'FlintSparqlEditor/sparql/lib/codemirror.js',
+                       'FlintSparqlEditor/sparql/lib/jquery-migrate-1.0.0.js',
                        'FlintSparqlEditor/sparql/sparql10querymode_ll1.js',
                        'FlintSparqlEditor/sparql/sparql11querymode_ll1.js',
                        'FlintSparqlEditor/sparql/sparql11updatemode_ll1.js',
@@ -72,7 +73,8 @@
 );
 
 //Default Config
-$wgLinkedWikiConfigDefaultEndpoint = "http://dbpedia.org/sparql";;
+#$wgLinkedWikiConfigDefaultEndpoint = "http://dbpedia.org/sparql";;
+$wgLinkedWikiConfigDefaultEndpoint = 
"https://query.wikidata.org/bigdata/namespace/wdq/sparql";;
 $wgLinkedWikiConfigProxyHost = null;//example : "http://proxy.XXXXX.com";
 $wgLinkedWikiConfigProxyPort = null;//example 888
 
@@ -383,8 +385,12 @@
                                }
                        }
                }
-               foreach ( $TableFormatTemplates as $TableFormatTemplate) {
-                       $str .= $separateur  . 
"{{".$TableFormatTemplate."|".implode ( "|", $arrayParameters)."}}";
+               foreach ( $TableFormatTemplates as $key => 
$TableFormatTemplate) {
+                       if(empty($TableFormatTemplate)){                        
+                           $str .= $separateur  . $row[$variables[$key]];
+                       }else{
+                           $str .= $separateur  . 
"{{".$TableFormatTemplate."|".implode ( "|", $arrayParameters)."}}";
+                       }
                        $separateur = "||";
                }
                $str .= "\n";
diff --git a/README b/README
index 68f428c..8342c94 100644
--- a/README
+++ b/README
@@ -37,6 +37,11 @@
 
 == Release-Notes ==
 
+* V2.1.0 Beta 1 version Extension LinkedWiki by Karima Rafes 
<karima.ra...@bordercloud.com>
+       - Ready for Wikidata version beta
+       - Fix the bug about JQuery ($.browser)
+       - Fix bug with template
+
 * V2.0.0 Alpha 1 version Extension LinkedWiki by Karima Rafes 
<karima.ra...@bordercloud.com>
        - simplify client SPARQL for MediaWiki (with or without SMW) 
        - Remove ARC2 and replace with the SPARQL (simple)
diff --git a/js/FlintSparqlEditor/sparql/lib/jquery-migrate-1.0.0.js 
b/js/FlintSparqlEditor/sparql/lib/jquery-migrate-1.0.0.js
new file mode 100644
index 0000000..cc84234
--- /dev/null
+++ b/js/FlintSparqlEditor/sparql/lib/jquery-migrate-1.0.0.js
@@ -0,0 +1,498 @@
+/*!
+ * jQuery Migrate - v1.0.0 - 2013-01-14
+ * https://github.com/jquery/jquery-migrate
+ * Copyright 2005, 2013 jQuery Foundation, Inc. and other contributors; 
Licensed MIT
+ */
+(function( jQuery, window, undefined ) {
+"use strict";
+
+
+var warnedAbout = {};
+
+// List of warnings already given; public read only
+jQuery.migrateWarnings = [];
+
+// Set to true to prevent console output; migrateWarnings still maintained
+// jQuery.migrateMute = false;
+
+// Forget any warnings we've already given; public
+jQuery.migrateReset = function() {
+       warnedAbout = {};
+       jQuery.migrateWarnings.length = 0;
+};
+
+function migrateWarn( msg) {
+       if ( !warnedAbout[ msg ] ) {
+               warnedAbout[ msg ] = true;
+               jQuery.migrateWarnings.push( msg );
+               if ( window.console && console.warn && !jQuery.migrateMute ) {
+                       console.warn( "JQMIGRATE: " + msg );
+               }
+       }
+}
+
+function migrateWarnProp( obj, prop, value, msg ) {
+       if ( Object.defineProperty ) {
+               // On ES5 browsers (non-oldIE), warn if the code tries to get 
prop;
+               // allow property to be overwritten in case some other plugin 
wants it
+               try {
+                       Object.defineProperty( obj, prop, {
+                               configurable: true,
+                               enumerable: true,
+                               get: function() {
+                                       migrateWarn( msg );
+                                       return value;
+                               },
+                               set: function( newValue ) {
+                                       migrateWarn( msg );
+                                       value = newValue;
+                               }
+                       });
+                       return;
+               } catch( err ) {
+                       // IE8 is a dope about Object.defineProperty, can't 
warn there
+               }
+       }
+
+       // Non-ES5 (or broken) browser; just set the property
+       jQuery._definePropertyBroken = true;
+       obj[ prop ] = value;
+}
+
+if ( document.compatMode === "BackCompat" ) {
+       // jQuery has never supported or tested Quirks Mode
+       migrateWarn( "jQuery is not compatible with Quirks Mode" );
+}
+
+
+var attrFn = {},
+       attr = jQuery.attr,
+       valueAttrGet = jQuery.attrHooks.value && jQuery.attrHooks.value.get ||
+               function() { return null; },
+       valueAttrSet = jQuery.attrHooks.value && jQuery.attrHooks.value.set ||
+               function() { return undefined; },
+       rnoType = /^(?:input|button)$/i,
+       rnoAttrNodeType = /^[238]$/,
+       rboolean = 
/^(?:autofocus|autoplay|async|checked|controls|defer|disabled|hidden|loop|multiple|open|readonly|required|scoped|selected)$/i,
+       ruseDefault = /^(?:checked|selected)$/i;
+
+// jQuery.attrFn
+migrateWarnProp( jQuery, "attrFn", attrFn, "jQuery.attrFn is deprecated" );
+
+jQuery.attr = function( elem, name, value, pass ) {
+       var lowerName = name.toLowerCase(),
+               nType = elem && elem.nodeType;
+
+       if ( pass ) {
+               migrateWarn("jQuery.fn.attr( props, pass ) is deprecated");
+               if ( elem && !rnoAttrNodeType.test( nType ) && 
jQuery.isFunction( jQuery.fn[ name ] ) ) {
+                       return jQuery( elem )[ name ]( value );
+               }
+       }
+
+       // Warn if user tries to set `type` since it breaks on IE 6/7/8
+       if ( name === "type" && value !== undefined && rnoType.test( 
elem.nodeName ) ) {
+               migrateWarn("Can't change the 'type' of an input or button in 
IE 6/7/8");
+       }
+
+       // Restore boolHook for boolean property/attribute synchronization
+       if ( !jQuery.attrHooks[ lowerName ] && rboolean.test( lowerName ) ) {
+               jQuery.attrHooks[ lowerName ] = {
+                       get: function( elem, name ) {
+                               // Align boolean attributes with corresponding 
properties
+                               // Fall back to attribute presence where some 
booleans are not supported
+                               var attrNode,
+                                       property = jQuery.prop( elem, name );
+                               return property === true || typeof property !== 
"boolean" &&
+                                       ( attrNode = 
elem.getAttributeNode(name) ) && attrNode.nodeValue !== false ?
+
+                                       name.toLowerCase() :
+                                       undefined;
+                       },
+                       set: function( elem, value, name ) {
+                               var propName;
+                               if ( value === false ) {
+                                       // Remove boolean attributes when set 
to false
+                                       jQuery.removeAttr( elem, name );
+                               } else {
+                                       // value is true since we know at this 
point it's type boolean and not false
+                                       // Set boolean attributes to the same 
name and set the DOM property
+                                       propName = jQuery.propFix[ name ] || 
name;
+                                       if ( propName in elem ) {
+                                               // Only set the IDL 
specifically if it already exists on the element
+                                               elem[ propName ] = true;
+                                       }
+
+                                       elem.setAttribute( name, 
name.toLowerCase() );
+                               }
+                               return name;
+                       }
+               };
+
+               // Warn only for attributes that can remain distinct from their 
properties post-1.9
+               if ( ruseDefault.test( lowerName ) ) {
+                       migrateWarn( "jQuery.fn.attr(" + lowerName + ") may use 
property instead of attribute" );
+               }
+       }
+
+       return attr.call( jQuery, elem, name, value );
+};
+
+// attrHooks: value
+jQuery.attrHooks.value = {
+       get: function( elem, name ) {
+               var nodeName = ( elem.nodeName || "" ).toLowerCase();
+               if ( nodeName === "button" ) {
+                       return valueAttrGet.apply( this, arguments );
+               }
+               if ( nodeName !== "input" && nodeName !== "option" ) {
+                       migrateWarn("property-based jQuery.fn.attr('value') is 
deprecated");
+               }
+               return name in elem ?
+                       elem.value :
+                       null;
+       },
+       set: function( elem, value ) {
+               var nodeName = ( elem.nodeName || "" ).toLowerCase();
+               if ( nodeName === "button" ) {
+                       return valueAttrSet.apply( this, arguments );
+               }
+               if ( nodeName !== "input" && nodeName !== "option" ) {
+                       migrateWarn("property-based jQuery.fn.attr('value', 
val) is deprecated");
+               }
+               // Does not return so that setAttribute is also used
+               elem.value = value;
+       }
+};
+
+
+var matched, browser,
+       oldInit = jQuery.fn.init,
+       // Note this does NOT include the # XSS fix from 1.7!
+       rquickExpr = /^(?:.*(<[\w\W]+>)[^>]*|#([\w\-]*))$/;
+
+// $(html) "looks like html" rule change
+jQuery.fn.init = function( selector, context, rootjQuery ) {
+       var match;
+
+       if ( selector && typeof selector === "string" && !jQuery.isPlainObject( 
context ) &&
+                       (match = rquickExpr.exec( selector )) && match[1] ) {
+               // This is an HTML string according to the "old" rules; is it 
still?
+               if ( selector.charAt( 0 ) !== "<" ) {
+                       migrateWarn("$(html) HTML strings must start with '<' 
character");
+               }
+               // Now process using loose rules; let pre-1.8 play too
+               if ( context && context.context ) {
+                       // jQuery object as context; parseHTML expects a DOM 
object
+                       context = context.context;
+               }
+               if ( jQuery.parseHTML ) {
+                       return oldInit.call( this, jQuery.parseHTML( 
jQuery.trim(selector), context, true ),
+                                       context, rootjQuery );
+               }
+       }
+       return oldInit.apply( this, arguments );
+};
+jQuery.fn.init.prototype = jQuery.fn;
+
+jQuery.uaMatch = function( ua ) {
+       ua = ua.toLowerCase();
+
+       var match = /(chrome)[ \/]([\w.]+)/.exec( ua ) ||
+               /(webkit)[ \/]([\w.]+)/.exec( ua ) ||
+               /(opera)(?:.*version|)[ \/]([\w.]+)/.exec( ua ) ||
+               /(msie) ([\w.]+)/.exec( ua ) ||
+               ua.indexOf("compatible") < 0 && /(mozilla)(?:.*? 
rv:([\w.]+)|)/.exec( ua ) ||
+               [];
+
+       return {
+               browser: match[ 1 ] || "",
+               version: match[ 2 ] || "0"
+       };
+};
+
+matched = jQuery.uaMatch( navigator.userAgent );
+browser = {};
+
+if ( matched.browser ) {
+       browser[ matched.browser ] = true;
+       browser.version = matched.version;
+}
+
+// Chrome is Webkit, but Webkit is also Safari.
+if ( browser.chrome ) {
+       browser.webkit = true;
+} else if ( browser.webkit ) {
+       browser.safari = true;
+}
+
+jQuery.browser = browser;
+
+// Warn if the code tries to get jQuery.browser
+migrateWarnProp( jQuery, "browser", browser, "jQuery.browser is deprecated" );
+
+jQuery.sub = function() {
+       function jQuerySub( selector, context ) {
+               return new jQuerySub.fn.init( selector, context );
+       }
+       jQuery.extend( true, jQuerySub, this );
+       jQuerySub.superclass = this;
+       jQuerySub.fn = jQuerySub.prototype = this();
+       jQuerySub.fn.constructor = jQuerySub;
+       jQuerySub.sub = this.sub;
+       jQuerySub.fn.init = function init( selector, context ) {
+               if ( context && context instanceof jQuery && !(context 
instanceof jQuerySub) ) {
+                       context = jQuerySub( context );
+               }
+
+               return jQuery.fn.init.call( this, selector, context, 
rootjQuerySub );
+       };
+       jQuerySub.fn.init.prototype = jQuerySub.fn;
+       var rootjQuerySub = jQuerySub(document);
+       migrateWarn( "jQuery.sub() is deprecated" );
+       return jQuerySub;
+};
+
+
+var oldFnData = jQuery.fn.data;
+
+jQuery.fn.data = function( name ) {
+       var ret, evt,
+               elem = this[0];
+
+       // Handles 1.7 which has this behavior and 1.8 which doesn't
+       if ( elem && name === "events" && arguments.length === 1 ) {
+               ret = jQuery.data( elem, name );
+               evt = jQuery._data( elem, name );
+               if ( ( ret === undefined || ret === evt ) && evt !== undefined 
) {
+                       migrateWarn("Use of jQuery.fn.data('events') is 
deprecated");
+                       return evt;
+               }
+       }
+       return oldFnData.apply( this, arguments );
+};
+
+
+var rscriptType = /\/(java|ecma)script/i,
+       oldSelf = jQuery.fn.andSelf || jQuery.fn.addBack,
+       oldFragment = jQuery.buildFragment;
+
+jQuery.fn.andSelf = function() {
+       migrateWarn("jQuery.fn.andSelf() replaced by jQuery.fn.addBack()");
+       return oldSelf.apply( this, arguments );
+};
+
+// Since jQuery.clean is used internally on older versions, we only shim if 
it's missing
+if ( !jQuery.clean ) {
+       jQuery.clean = function( elems, context, fragment, scripts ) {
+               // Set context per 1.8 logic
+               context = context || document;
+               context = !context.nodeType && context[0] || context;
+               context = context.ownerDocument || context;
+
+               migrateWarn("jQuery.clean() is deprecated");
+
+               var i, elem, handleScript, jsTags,
+                       ret = [];
+
+               jQuery.merge( ret, jQuery.buildFragment( elems, context 
).childNodes );
+
+               // Complex logic lifted directly from jQuery 1.8
+               if ( fragment ) {
+                       // Special handling of each script element
+                       handleScript = function( elem ) {
+                               // Check if we consider it executable
+                               if ( !elem.type || rscriptType.test( elem.type 
) ) {
+                                       // Detach the script and store it in 
the scripts array (if provided) or the fragment
+                                       // Return truthy to indicate that it 
has been handled
+                                       return scripts ?
+                                               scripts.push( elem.parentNode ? 
elem.parentNode.removeChild( elem ) : elem ) :
+                                               fragment.appendChild( elem );
+                               }
+                       };
+
+                       for ( i = 0; (elem = ret[i]) != null; i++ ) {
+                               // Check if we're done after handling an 
executable script
+                               if ( !( jQuery.nodeName( elem, "script" ) && 
handleScript( elem ) ) ) {
+                                       // Append to fragment and handle 
embedded scripts
+                                       fragment.appendChild( elem );
+                                       if ( typeof elem.getElementsByTagName 
!== "undefined" ) {
+                                               // handleScript alters the DOM, 
so use jQuery.merge to ensure snapshot iteration
+                                               jsTags = jQuery.grep( 
jQuery.merge( [], elem.getElementsByTagName("script") ), handleScript );
+
+                                               // Splice the scripts into ret 
after their former ancestor and advance our index beyond them
+                                               ret.splice.apply( ret, [i + 1, 
0].concat( jsTags ) );
+                                               i += jsTags.length;
+                                       }
+                               }
+                       }
+               }
+
+               return ret;
+       };
+}
+
+jQuery.buildFragment = function( elems, context, scripts, selection ) {
+       var ret,
+               warning = "jQuery.buildFragment() is deprecated";
+
+       // Set context per 1.8 logic
+       context = context || document;
+       context = !context.nodeType && context[0] || context;
+       context = context.ownerDocument || context;
+
+       try {
+               ret = oldFragment.call( jQuery, elems, context, scripts, 
selection );
+
+       // jQuery < 1.8 required arrayish context; jQuery 1.9 fails on it
+       } catch( x ) {
+               ret = oldFragment.call( jQuery, elems, context.nodeType ? [ 
context ] : context[ 0 ], scripts, selection );
+
+               // Success from tweaking context means buildFragment was called 
by the user
+               migrateWarn( warning );
+       }
+
+       // jQuery < 1.9 returned an object instead of the fragment itself
+       if ( !ret.fragment ) {
+               migrateWarnProp( ret, "fragment", ret, warning );
+               migrateWarnProp( ret, "cacheable", false, warning );
+       }
+
+       return ret;
+};
+
+var eventAdd = jQuery.event.add,
+       eventRemove = jQuery.event.remove,
+       eventTrigger = jQuery.event.trigger,
+       oldToggle = jQuery.fn.toggle,
+       oldLive = jQuery.fn.live,
+       oldDie = jQuery.fn.die,
+       ajaxEvents = 
"ajaxStart|ajaxStop|ajaxSend|ajaxComplete|ajaxError|ajaxSuccess",
+       rajaxEvent = new RegExp( "\\b(?:" + ajaxEvents + ")\\b" ),
+       rhoverHack = /(?:^|\s)hover(\.\S+|)\b/,
+       hoverHack = function( events ) {
+               if ( typeof( events ) != "string" || jQuery.event.special.hover 
) {
+                       return events;
+               }
+               if ( rhoverHack.test( events ) ) {
+                       migrateWarn("'hover' pseudo-event is deprecated, use 
'mouseenter mouseleave'");
+               }
+               return events && events.replace( rhoverHack, "mouseenter$1 
mouseleave$1" );
+       };
+
+// Event props removed in 1.9, put them back if needed; no practical way to 
warn them
+if ( jQuery.event.props && jQuery.event.props[ 0 ] !== "attrChange" ) {
+       jQuery.event.props.unshift( "attrChange", "attrName", "relatedNode", 
"srcElement" );
+}
+
+// Undocumented jQuery.event.handle was "deprecated" in jQuery 1.7
+migrateWarnProp( jQuery.event, "handle", jQuery.event.dispatch, 
"jQuery.event.handle is undocumented and deprecated" );
+
+// Support for 'hover' pseudo-event and ajax event warnings
+jQuery.event.add = function( elem, types, handler, data, selector ){
+       if ( elem !== document && rajaxEvent.test( types ) ) {
+               migrateWarn( "AJAX events should be attached to document: " + 
types );
+       }
+       eventAdd.call( this, elem, hoverHack( types || "" ), handler, data, 
selector );
+};
+jQuery.event.remove = function( elem, types, handler, selector, mappedTypes ){
+       eventRemove.call( this, elem, hoverHack( types ) || "", handler, 
selector, mappedTypes );
+};
+
+jQuery.fn.error = function() {
+       var args = Array.prototype.slice.call( arguments, 0);
+       migrateWarn("jQuery.fn.error() is deprecated");
+       args.splice( 0, 0, "error" );
+       if ( arguments.length ) {
+               return this.bind.apply( this, args );
+       }
+       // error event should not bubble to window, although it does pre-1.7
+       this.triggerHandler.apply( this, args );
+       return this;
+};
+
+jQuery.fn.toggle = function( fn, fn2 ) {
+
+       // Don't mess with animation or css toggles
+       if ( !jQuery.isFunction( fn ) || !jQuery.isFunction( fn2 ) ) {
+               return oldToggle.apply( this, arguments );
+       }
+       migrateWarn("jQuery.fn.toggle(handler, handler...) is deprecated");
+
+       // Save reference to arguments for access in closure
+       var args = arguments,
+               guid = fn.guid || jQuery.guid++,
+               i = 0,
+               toggler = function( event ) {
+                       // Figure out which function to execute
+                       var lastToggle = ( jQuery._data( this, "lastToggle" + 
fn.guid ) || 0 ) % i;
+                       jQuery._data( this, "lastToggle" + fn.guid, lastToggle 
+ 1 );
+
+                       // Make sure that clicks stop
+                       event.preventDefault();
+
+                       // and execute the function
+                       return args[ lastToggle ].apply( this, arguments ) || 
false;
+               };
+
+       // link all the functions, so any of them can unbind this click handler
+       toggler.guid = guid;
+       while ( i < args.length ) {
+               args[ i++ ].guid = guid;
+       }
+
+       return this.click( toggler );
+};
+
+jQuery.fn.live = function( types, data, fn ) {
+       migrateWarn("jQuery.fn.live() is deprecated");
+       if ( oldLive ) {
+               return oldLive.apply( this, arguments );
+       }
+       jQuery( this.context ).on( types, this.selector, data, fn );
+       return this;
+};
+
+jQuery.fn.die = function( types, fn ) {
+       migrateWarn("jQuery.fn.die() is deprecated");
+       if ( oldDie ) {
+               return oldDie.apply( this, arguments );
+       }
+       jQuery( this.context ).off( types, this.selector || "**", fn );
+       return this;
+};
+
+// Turn global events into document-triggered events
+jQuery.event.trigger = function( event, data, elem, onlyHandlers  ){
+       if ( !elem & !rajaxEvent.test( event ) ) {
+               migrateWarn( "Global events are undocumented and deprecated" );
+       }
+       return eventTrigger.call( this,  event, data, elem || document, 
onlyHandlers  );
+};
+jQuery.each( ajaxEvents.split("|"),
+       function( _, name ) {
+               jQuery.event.special[ name ] = {
+                       setup: function() {
+                               var elem = this;
+
+                               // The document needs no shimming; must be !== 
for oldIE
+                               if ( elem !== document ) {
+                                       jQuery.event.add( document, name + "." 
+ jQuery.guid, function() {
+                                               jQuery.event.trigger( name, 
null, elem, true );
+                                       });
+                                       jQuery._data( this, name, jQuery.guid++ 
);
+                               }
+                               return false;
+                       },
+                       teardown: function() {
+                               if ( this !== document ) {
+                                       jQuery.event.remove( document, name + 
"." + jQuery._data( this, name ) );
+                               }
+                               return false;
+                       }
+               };
+       }
+);
+
+
+})( jQuery, window );
diff --git a/lib/SPARQL/Curl.php b/lib/SPARQL/Curl.php
index 9c50cd4..3126ad5 100644
--- a/lib/SPARQL/Curl.php
+++ b/lib/SPARQL/Curl.php
@@ -118,7 +118,7 @@
         * @param string url
         * @param array assoc post data array ie. $foo['post_var_name'] = $value
         * @param string ip address to bind (default null)
-        * @param int timeout in sec for complete curl operation (default 10)
+        * @param int timeout in sec for complete curl operation (default 600)
         * @return string data
         * @access public
     */
@@ -200,18 +200,45 @@
         * fetch data from target URL
         * return data returned from url or false if error occured
         * @param string url
+        * @param array assoc get data array ie. $foo['post_var_name'] = $value
         * @param string ip address to bind (default null)
-        * @param int timeout in sec for complete curl operation (default 5)
+        * @param int timeout in sec for complete curl operation (default 600)
         * @return string data
         * @access public
     */
-       function fetch_url($url, $ip=null, $timeout=5)
+       function fetch_url($url,$getdata=null, $ip=null, $timeout=600)
        {
                if($this->debug)
                        curl_setopt($this->ch, CURLOPT_VERBOSE, true);
                        
+                       
+               //generate get string
+               $get_array = array();
+               if(is_array($getdata))
+               {                 
+                   foreach($getdata as $key=>$value)
+                   {
+                           $get_array[] = urlencode($key) . "=" . 
urlencode($value);
+                   }
+                   $get_string = implode("&",$get_array);
+               
+                   if($this->debug)
+                   {
+                           curl_setopt($this->ch, CURLOPT_VERBOSE, true);
+                           echo "GET String: $get_string\n";
+                   }
+               }
+               else
+               {
+                   $get_string = null;
+               }
+               
                // set url to post to
-               curl_setopt($this->ch, CURLOPT_URL,$url);
+               if(empty($get_string)){
+                 curl_setopt($this->ch, CURLOPT_URL,$url);
+               }else{
+                 curl_setopt($this->ch, CURLOPT_URL,$url."?".$get_string);     
        
+               }
 
                //set method to get
                curl_setopt($this->ch, CURLOPT_HTTPGET,true);
diff --git a/lib/SPARQL/Endpoint.php b/lib/SPARQL/Endpoint.php
index 8d4b5bb..cceae5d 100644
--- a/lib/SPARQL/Endpoint.php
+++ b/lib/SPARQL/Endpoint.php
@@ -214,18 +214,25 @@
        private $_parserSparqlResult;
        
        /**
-        * Name of parameter HTTP GET to send a query SPARQL to read data.
+        * Name of parameter HTTP to send a query SPARQL to read data.
         * @access private
         * @var string
         */
        private $_nameParameterQueryRead;
        
        /**
-        * Name of parameter HTTP POST to send a query SPARQL to write data.
+        * Name of parameter HTTP to send a query SPARQL to write data.
         * @access private
         * @var string
         */
        private $_nameParameterQueryWrite;
+       
+       /**
+        * Method HTTP to send a query SPARQL to read data.
+        * @access private
+        * @var string
+        */
+       private $_MethodHTTP;
        
 
        private $_login;
@@ -292,8 +299,25 @@
                $this->_nameParameterQueryWrite = "update";             
 
                //init parser
-               $this->_parserSparqlResult = new ParserSparqlResult();          
+               $this->_parserSparqlResult = new ParserSparqlResult();
                
+               //FIX for Wikidata
+               if( $endpoint == 
"https://query.wikidata.org/bigdata/namespace/wdq/sparql";){
+                  $this->_MethodHTTP= "GET";
+               }else{
+                  $this->_MethodHTTP= "POST"; // by default
+               }
+               
+       }
+       
+       //FIX for WIKIDATA
+       /**
+        * Set the method HTTP to read
+        * @param string $method : HTTP method (GET or POST) for reading data 
(by default is POST)
+        * @access public
+        */
+       public function setMethodHTTP($method) {
+               $this->_MethodHTTP = $method;
        }
        
        /**
@@ -490,15 +514,26 @@
                $sUri    = $this->_endpoint;    
                $response ="";
                
+               
+               
+               
                if($typeOutput == null){
                        $data = array($this->_nameParameterQueryRead =>   
$query);
-                       $response = $client->send_post_data($sUri,$data);
+                       if($this->_MethodHTTP == "POST"){
+                           $response = $client->send_post_data($sUri,$data);
+                       }else{
+                           $response = $client->fetch_url($sUri,$data);//fix 
for wikidata
+                       }
                }else{
                        $data = array($this->_nameParameterQueryRead =>   
$query,
                        //"output" => 
ConversionMimetype::getShortnameOfMimetype($typeOutput), //possible fix for 
4store/fuseki..
                        "Accept" => $typeOutput); //fix for sesame
                        //print_r($data);
-                       $response = 
$client->send_post_data($sUri,$data,array('Accept: '.$typeOutput));
+                       if($this->_MethodHTTP == "POST"){
+                          $response = 
$client->send_post_data($sUri,$data,array('Accept: '.$typeOutput));
+                       }else{
+                          $response = $client->fetch_url($sUri,$data);//fix 
for wikidata
+                       }
                }               
 
                $code = $client->get_http_response_code();
diff --git a/lib/SPARQL/README.md b/lib/SPARQL/README.md
index 561b70e..a3d76e2 100644
--- a/lib/SPARQL/README.md
+++ b/lib/SPARQL/README.md
@@ -95,6 +95,37 @@
 ```
 
 ### Examples
+Send a simple query to Wikidata :
+```php
+<?php
+
+require_once('../Endpoint.php');
+
+$endpoint ="https://query.wikidata.org/bigdata/namespace/wdq/sparql";;
+$sp_readonly = new Endpoint($endpoint);
+$q = "select *  where {?x ?y ?z.} LIMIT 5";
+$rows = $sp_readonly->query($q, 'rows');
+$err = $sp_readonly->getErrors();
+if ($err) {
+      print_r($err);
+      throw new Exception(print_r($err,true));
+}
+
+foreach($rows["result"]["variables"] as $variable){
+        printf("%-20.20s",$variable);
+        echo '|';
+ }
+ echo "\n";
+
+foreach ($rows["result"]["rows"] as $row){
+        foreach($rows["result"]["variables"] as $variable){
+                printf("%-20.20s",$row[$variable]);
+        echo '|';
+        }
+        echo "\n";
+ }
+?>
+```
 
 Send a simple query to DBpedia :
 ```php
@@ -179,7 +210,7 @@
 
 ### Release-Notes 
 
-* V1.O.0.0 version SPARQL.Pro lib PHP by Karima Rafes 
<karima.ra...@bordercloud.com>
+* V1.1.0.0 version SPARQL.Pro lib PHP by Karima Rafes 
<karima.ra...@bordercloud.com>
 
 ### license 
 SPARQL.Pro lib PHP (c)2014 by Karima Rafes - BorderCloud
@@ -191,7 +222,7 @@
 work. If not, see <http://creativecommons.org/licenses/by-sa/4.0/>. 
 
 ### Compile DOC 
-php ../vendor/phpdocumentor/phpdocumentor/bin/phpdoc.php -d . --template="xml"
-../vendor/evert/phpdoc-md/bin/phpdocmd ./output/structure.xml doc
+php vendor/phpdocumentor/phpdocumentor/bin/phpdoc.php --template="xml" -f 
Base.php -f ConversionMimetype.php  -f Endpoint.php   -f ParserCSV.php -f 
ToolsConvert.php -f Curl.php  -f Net.php  -f ParserSparqlResult.php -f 
Namespace.php -f ParserTurtle.php -f ToolsBlankNode.php
+vendor/evert/phpdoc-md/bin/phpdocmd ./output/structure.xml doc
 
 
diff --git a/specialpages/SpecialSparqlQuery.php 
b/specialpages/SpecialSparqlQuery.php
index 4d33fbb..95aa1fa 100644
--- a/specialpages/SpecialSparqlQuery.php
+++ b/specialpages/SpecialSparqlQuery.php
@@ -33,10 +33,10 @@
        }
 
        public function execute($par = null) {
-               global $wgOut,$wgScriptPath; 
+               global $wgOut,$wgScriptPath,$wgLinkedWikiConfigDefaultEndpoint; 
                $queryWithoutPrefix = 
isset($_REQUEST["queryWithoutPrefix"])?stripslashes($_REQUEST["queryWithoutPrefix"]):"";
                $query = 
isset($_REQUEST["query"])?stripslashes($_REQUEST["query"]):"";
-               $endpoint = 
isset($_REQUEST["endpoint"])?stripslashes(trim($_REQUEST["endpoint"])):"http://dbpedia.org/sparql";;
+               $endpoint = 
isset($_REQUEST["endpoint"])?stripslashes(trim($_REQUEST["endpoint"])):$wgLinkedWikiConfigDefaultEndpoint;
                $output = 
isset($_REQUEST["output"])?stripslashes($_REQUEST["output"]):"";
                $titleRequest = 
isset($_REQUEST["titleRequest"])?stripslashes($_REQUEST["titleRequest"]):"";
                $description = 
isset($_REQUEST["description"])?stripslashes($_REQUEST["description"]):"";

-- 
To view, visit https://gerrit.wikimedia.org/r/239749
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I938d7a5d669ef57e54d31985fcfcfcc4110ff924
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/LinkedWiki
Gerrit-Branch: master
Gerrit-Owner: Karima Rafes <karima.ra...@gmail.com>
Gerrit-Reviewer: Karima Rafes <karima.ra...@gmail.com>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to