Compatible with DokuWiki
No compatibility info given!
This extension has not been updated in over 2 years. It may no longer be maintained or supported and may have compatibility issues.
Needed for indexmenu2, livepreview
This plugin implements Ajax (or - better say - Remote Scripting) controller. It is built on top of the excellent JsHttpRequest library. It's extremely easy to use: on client side you pass simple JavaScript variables, on server-side you receive PHP array of the same variables, and vise-versa. It does encoding conversion, implements browser-independent data transport layer, allowing to work even if browser does not support XmlHttp at all (fe. IE with disabled ActiveX).
Browser compatibility: IE5+, FF0.9+, Mozilla, Opera 7.2+, Safari/Konqueror and others.
JsHttpRequest/RemoteScript library has the interface nearly the same, as implemented in XmlHttpRequest/XMLHTTP.
How to use it.
Client-side example, taken from indexmenu2.
function fetcher (s, callback) { if ('undefined' == typeof RemoteScript) { callback ({'state' : false, 'response' : 'Plugin <a href="http://www.dokuwiki.org/plugin:remotescript" _target="blank">RemoteScript</a> is not available'}); return; } RemoteScript.query( ['indexmenu','getsubmenu'] ,{ 'src' : s ,'sort' : '{$opts['sort']}'} ,function(js, txt) { callback({'state' : !!js, 'response' : js||txt}); } ,true); }
Server-side code:
require_once (DOKU_PLUGIN.'/indexmenu/syntax/indexmenu.php'); /* * Returns submenu tree for specified namespace * * @param string $ns namespace title * @param string $sort sorting mode * @return {String} html markup for the submenu * @access public */ function indexmenu_getsubmenu ($ns,$s) { global $conf; $opts = array($ns, array('level' => 1, // get only 1st level 'ajax' => true, 'js' => false, 'navigation' => false, 'sort' => $s )); $im = & new syntax_plugin_indexmenu_indexmenu(); return preg_replace(array("#^<ul[^>]+>#i","#</ul>$#i"),"",$im->_indexmenu($opts)); }
Yes, that's all i need to write to have complete ajax-driven menu on the page.
Detailed description and use examples you can find at JsHttpRequest home.
Actually, no configuration is needed.
Search and install the plugin using the Extension Manager. Refer to Plugins on how to install plugins manually.
Two byte language encoded by UTF-8 is not correctly displayed.
I use RemoteScript with indexmenu2.
I test in Korean(UTF-8) – Alex K ( http://wiki.alexk.name )What should be displayed and what is actually displayed?
Could you, please, make a test page somewhere in the wiki?
— Ilya Lebedev 2007-11-15 15:11The error sample link is http://ukira.cafe24.com/wiki/doku.php?id=wiki:navigation
There is some broken strings like '~~/a>'.
I found a clue.
At the line 311 of source $DOKU_PLUGINS/remotescript/lib/JsHttpRequest/JsHttpRequest.php file, there is '$v = iconv($fromEnc, 'UTF-8', $v);'.
I changed it to '$v = iconv('IOS-8859-1', 'UTF-8', $v);'. Then it works well. Apache 2.x and php 5.x.
But I tested in Apache 1.x and php 4.x. It works fail again.
Becuase of this I study AJAX now. :)I solved the problem. But I don't know what I did. :(
Finally I modified JsHttpRequest.php file.
I added 3 line ( 272,275,279 line).
244 /** 245 * Called in case of error too! 246 */ 247 function _obHandler($text) 248 { 249 // Check for error. 250 if (preg_match('{'.$this->_uniqHash.'(.*?)'.$this->_uniqHash.'}sx', $text)) { 251 $text = str_replace($this->_uniqHash, '', $text); 252 } 253 254 // Make a resulting hash. 255 if (!isset($this->RESULT)) { 256 $this->RESULT = isset($GLOBALS['_RESULT'])? $GLOBALS['_RESULT'] : null; 257 } 258 $encoding = $this->SCRIPT_ENCODING; 259 $result = array( 260 'id' => $this->ID, 261 'js' => $this->RESULT, 262 'text' => $text, 263 ); 264 if (function_exists('array_walk_recursive') && function_exists('iconv') && function_exists('json_encode')) { 265 $encoding = "UTF-8"; 266 $this->_nonAsciiChars = join("", array_map('chr', range(128, 255))); 267 $this->_toUtfFailed = false; 268 array_walk_recursive($result, array(&$this, '_toUtf8_callback'), $this->SCRIPT_ENCODING); 269 if (!$this->_toUtfFailed) { 270 // If some key contains non-ASCII character, convert everything manually. 271 $text = json_encode($result); 272 $text = iconv('ISO-8859-1','UTF-8',$text);// I added this line 273 } else { 274 $text = $this->php2js($result); 275 $text = iconv('ISO-8859-1','UTF-8',$text); // I added this line 276 } 277 } else { 278 $text = $this->php2js($result); 279 $text = iconv('ISO-8859-1','UTF-8',$text); // I added this line 280 } 281
Try to rollback the changes and use the following line in 'rs.php'
$JsHttpRequest =& new JsHttpRequest('UTF-8');
Maybe, your server does not recognize lowercase encoding name. — Ilya Lebedev 2007-11-17 21:54I did it today that you said.
But, it's not a problem my server's recognition.
I add the 3 lines code again. Thank you.
Please, try to replace line in remotescript/script.js
onready(_from_utf8(req.responseJS), _from_utf8(req.responseText));
with
onready(req.responseJS, req.responseText);
This conversion was made to fix Safari UTF-8 issues, maybe it breaks multibyte strings. — Ilya Lebedev 2007-11-18 16:03