var xcomSites; var xcomHeaders; var xcom_action_url; var xcom_srch_str; function xcom_localSave(a_id) { var fn_sel = document.getElementById('xcom_sel'); /* if function selected, apply function to remote file */ if(fn_sel.selectedIndex > 0) { xcom_setValue('xcom_pageid',a_id); xmlrpc('xcom_action'); return; } /* save remote file to local * first ask if this is what is wanted */ if(a_id) { xcom_setValue('xcom_pageid',a_id); if(!window.confirm(JSINFO['savelocalfile'] + ' ' + a_id)) return; } var params = ""; var id =a_id ? a_id : xcom_getInputValue('xcom_pageid'); var params = 'id='+id; var jobj = xcom_json_ini('xcom_localpwd','xcom_locuser'); jobj['url'] = JSINFO['url']; var str =JSON.stringify(jobj); params +='&local=' + str; var jobj = xcom_json_ini('xcom_pwd','xcom_url','xcom_user'); str =JSON.stringify(jobj); params +='&remote=' + str; //if(!confirm("params: " + params)) return; var status =new Array("Save remote: ("+ id + ") to Local wiki"); xcom_query_status(status); jQuery.ajax({ url: DOKU_BASE + 'lib/plugins/xcom/scripts/xcom_save.php', data: params, type: 'POST', dataType: 'html', success: function(data) { data = decodeURIComponent(data); xcom_show('xcom_results'); xcom_print_data('dokuwiki.copy', data, false,""); } }); } function xmlrpc() { var xcom_action = arguments.length ? 'xcom_action' : ""; xcom_hide_all_views(xcom_action); /* xcom_hide('xcom_action'); xcom_hide('xcom_view'); xcom_hide('xcom_pre_title'); xcom_hide('xcom_htm_title'); xcom_hide('xcom_editable_title'); xcom_hide('xcom_action_title');*/ xcom_action_url = xcom_getInputValue('xcom_url'); xcom_action_url = xcom_action_url.replace(/[\/\\]$/,""); xcom_action_url += '/doku.php?'; xcom_clear('xcom_qstatus',false); var options = xcom_params(); var func = options[0]; xcom_query_status(options); var other=false; var params = 'params=' + JSON.stringify(options); params = params.replace(/\s*__comma__\s*/g,','); if(typeof options[2] == 'object' && options[2] !== null ) { try { if(options[2].hasOwnProperty('hash')) { other = 'hash'; } } catch(e) { } } var array_types = {'dokuwiki.getPagelist':1,'plugin.xcom.pageVersions':1,'plugin.xcom.getPageInfo':1,'wiki.getAllPages':1, 'wiki.getAttachmentInfo':1,'wiki.getAttachments':1, 'wiki.getRecentChanges':1,'wiki.listLinks':1,'dokuwiki.search':1,'plugin.xcom.getMedia':1, 'plugin.xcom.listNamespaces':1,'wiki.getBackLinks':1,}; var jobj = xcom_json_ini('xcom_pwd','xcom_url','xcom_user'); str =JSON.stringify(jobj); params += '&credentials=' + str; params += '&debug=' + document.getElementById('xcom_debug').checked; // if(!confirm(params)) return; jQuery.ajax({ url: DOKU_BASE + 'lib/plugins/xcom/scripts/xml.php', data: params, type: 'POST', dataType: 'html', success: function(data) { if(data.match(/XCOM_LAG/)) return; if(!array_types.hasOwnProperty(func)) { try { data = decodeURIComponent(data); } catch(err){ console.log("By-passed decoding string returned by " + func + ': ' + err.message ); } } xcom_show('xcom_results'); xcom_print_data(func, data,other,xcom_action); } }); var fn_sel = document.getElementById('xcom_sel'); fn_sel.selectedIndex = 0; return false; } function xcom_print_data(fn, data,other,xcom_action) { var id = 'xcom_pre'; var table_calls = { 'dokuwiki_getPagelist': (other=='hash') ? ['id','rev', 'mtime' ,'size','hash'] : ['id','rev', 'mtime' ,'size'] , 'plugin_xcom_pageVersions': ['user','ip','type','sum','modified','version' ], 'plugin_xcom_getPageInfo': ['name','lastModified','author','version'], 'wiki_getAllPages': ['id', 'perms', 'size', 'lastModified'], 'dokuwiki_search': ['id', 'score', 'rev', 'mtime','size','snippet'], 'plugin_xcom_getMedia': ['Media files'], 'wiki_getAttachments': ['id','size','lastModified'], 'wiki_listLinks': ['type', 'page','href'], 'wiki_getAttachmentInfo': ['id','lastModified','size'], 'plugin_xcom_listNamespaces': ['Namespace Directories'], 'wiki_getBackLinks': ['Backlinks'], 'wiki_getRecentChanges': ['name', 'lastModified', 'author','version','size'], 'wiki_getBackLinks' : ['Backlinks'], }; xcomHeaders = table_calls; switch(fn) { case 'wiki.getPage': // (string) raw Wiki text case 'wiki.getPageVersion': // (string) raw Wiki text id = 'xcom_editable' ; break; case 'plugin.xcom.GetMetaData': case 'wiki.getPageHTML': // (string) rendered HTML id = 'xcom_htm'; break; case 'dokuwiki.getPagelist': case 'plugin.xcom.pageVersions': case 'plugin.xcom.getPageInfo': case 'wiki.getAllPages': case 'dokuwiki.search': case 'plugin.xcom.getMedia': case 'wiki.getAttachments': case 'wiki.listLinks': case 'wiki.getAttachmentInfo': case 'plugin.xcom.listNamespaces': case 'wiki.getRecentChanges': case 'wiki.getBackLinks': id = xcom_action ? 'xcom_action':'xcom_htm'; try { var obj = jQuery.parseJSON(data); } catch(e) { id = 'xcom_pre'; // not a table, use code view, probably error msg obj = decodeURIComponent(data); break; } // handle tables if(obj || fn == 'wiki.getBackLinks') { var fncall = fn.replace(/\./g,'_'); data = xcom_thead(table_calls[fncall]); if(fn == 'plugin.xcom.getPageInfo' || fn == 'wiki.getAttachmentInfo') { data += xcom_hash(obj); //straight single hash } else if (fn == 'plugin.xcom.getMedia' || fn =='plugin.xcom.listNamespaces' || fn == 'wiki.getBackLinks') { data += xcom_onedim(obj); } else { data+=xcom_multidim(obj,fn); // array of arrays } } data += xcom_tclose(); //end tables break; case 'wiki.putPage': case 'dokuwiki.appendPage': id = 'xcom_editable'; break; default: break; } // end switch var d = document.getElementById(id); if(id == 'xcom_editable') { xcom_setValue(id,data); } else { d.innerHTML= data; } xcom_show(id); var title = id + '_title'; xcom_show(title); } function xcom_multidim(obj,func) { var data = ""; for(var i in obj) { data +="\n
'+ xcom_search_url(val) +' | '; } else if(type == 'id' || type == 'href' || (type =='page' && fn == 'wiki.listLinks')) { var display = val; if(val.length > 40) { var a = val.substring(0,40) + ". . . .' +display +' | '; } val =display; } else if(type == 'snippet') { return '||||
' + val + ' | '; } else if(type == 'title' && fn=='dokuwiki.search') return ""; //skip title, screws up the table design if(typeof val == 'object') val = "none"; return '' + val + ' | ' } function xcom_tclose() { return "