Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
124 changes: 71 additions & 53 deletions admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,12 @@ function handle() {
// reset the client
$this->client = null;
}

if($_REQUEST['delprofile']){
$this->_profileDel();
$this->profno = '';
$this->client = null;
}
}

/**
Expand Down Expand Up @@ -151,6 +157,7 @@ function html() {
echo $this->locale_xhtml('intro');

echo '<div class="sync_left">';

$this->_profilelist($this->profno);
if($this->profno !=='' ){
echo '<br />';
Expand Down Expand Up @@ -182,6 +189,13 @@ function _profileSave(){
$profiles = $conf['metadir'].'/sync.profiles';
io_saveFile($profiles,serialize($this->profiles));
}

function _profileDel(){
global $conf;
$profiles = $conf['metadir'].'/sync.profiles';
unset($this->profiles[$this->profno]);
io_saveFile($profiles,serialize($this->profiles));
}

/**
* Check connection for choosen profile and display last sync date.
Expand Down Expand Up @@ -220,20 +234,19 @@ function _profileView(){
function _profilelist($no=''){
echo '<form action="" method="post">';
echo '<fieldset><legend>'.$this->getLang('profile').'</legend>';
echo '<select name="no" class="edit"';
echo '<select name="no" class="edit">';
echo ' <option value="">'.$this->getLang('newprofile').'</option>';
foreach($this->profiles as $pno => $opts){
$srv = parse_url($opts['server']);

echo '<option value="'.hsc($pno).'" '.(($no!=='' && $pno == $no)?'selected="selected"':'').'>';
echo ($no+1).'. ';
if($opts['user']) echo hsc($opts['user']).'@';
echo hsc($srv['host']);
if($opts['ns']) echo ':'.hsc($opts['ns']);
echo ($pno+1).'. ';
echo hsc($opts['name']);
echo '</option>';
}
echo '</select>';
echo '<input type="submit" value="'.$this->getLang('select').'" class="button" />';
echo '<input type="submit" value="'.$this->getLang('delete').'" class="button" name="delprofile"/>';
echo '</fieldset>';
echo '</form>';
}
Expand All @@ -253,6 +266,9 @@ function _profileform($no=''){

echo '<input type="hidden" name="no" value="'.hsc($no).'" />';

echo '<label for="sync__name">'.$this->getLang('name').'</label> ';
echo '<input type="text" name="prf[name]" id="sync__name" class="edit" value="'.hsc($this->profiles[$no]['name']).'" />';

echo '<label for="sync__server">'.$this->getLang('server').'</label> ';
echo '<input type="text" name="prf[server]" id="sync__server" class="edit" value="'.hsc($this->profiles[$no]['server']).'" />';
echo '<samp>http://example.com/dokuwiki/lib/exe/xmlrpc.php</samp>';
Expand Down Expand Up @@ -603,59 +619,61 @@ function _getSyncList($type='pages'){
global $conf;
$no = $this->profno;
$list = array();
$ns = $this->profiles[$no]['ns'];
$namespaces = explode(",",$this->profiles[$no]['ns']);

// get remote file list
if($type == 'pages'){
$ok = $this->client->query('dokuwiki.getPagelist',$ns,
array('depth' => (int) $this->profiles[$no]['depth'],
'hash' => true));
}else{
$ok = $this->client->query('wiki.getAttachments',$ns,
array('depth' => (int) $this->profiles[$no]['depth'],
'hash' => true));
}
if(!$ok){
msg('Failed to fetch remote file list. '.
$this->client->getErrorMessage(),-1);
return false;
}
$remote = $this->client->getResponse();
// put into synclist
foreach($remote as $item){
$list[$item['id']]['remote'] = $item;
unset($list[$item['id']]['remote']['id']);
}
unset($remote);
foreach($namespaces as $ns){
// get remote file list
if($type == 'pages'){
$ok = $this->client->query('dokuwiki.getPagelist',$ns,
array('depth' => (int) $this->profiles[$no]['depth'],
'hash' => true));
}else{
$ok = $this->client->query('wiki.getAttachments',$ns,
array('depth' => (int) $this->profiles[$no]['depth'],
'hash' => true));
}
if(!$ok){
msg('Failed to fetch remote file list. '.
$this->client->getErrorMessage(),-1);
return false;
}
$remote = $this->client->getResponse();
// put into synclist
foreach($remote as $item){
$list[$item['id']]['remote'] = $item;
unset($list[$item['id']]['remote']['id']);
}
unset($remote);

// get local file list
$local = array();
$dir = utf8_encodeFN(str_replace(':', '/', $ns));
require_once(DOKU_INC.'inc/search.php');
if($type == 'pages'){
search($local, $conf['datadir'], 'search_allpages',
array('depth' => (int) $this->profiles[$no]['depth'],
'hash' => true), $dir);
}else{
search($local, $conf['mediadir'], 'search_media',
array('depth' => (int) $this->profiles[$no]['depth'],
'hash' => true), $dir);
}
// get local file list
$local = array();
$dir = utf8_encodeFN(str_replace(':', '/', $ns));
require_once(DOKU_INC.'inc/search.php');
if($type == 'pages'){
search($local, $conf['datadir'], 'search_allpages',
array('depth' => (int) $this->profiles[$no]['depth'],
'hash' => true), $dir);
}else{
search($local, $conf['mediadir'], 'search_media',
array('depth' => (int) $this->profiles[$no]['depth'],
'hash' => true), $dir);
}

// put into synclist
foreach($local as $item){
// skip identical files
if($list[$item['id']]['remote']['hash'] == $item['hash']){
unset($list[$item['id']]);
continue;
// put into synclist
foreach($local as $item){
// skip identical files
if($list[$item['id']]['remote']['hash'] == $item['hash']){
unset($list[$item['id']]);
continue;
}

$list[$item['id']]['local'] = $item;
unset($list[$item['id']]['local']['id']);
}
unset($local);

$list[$item['id']]['local'] = $item;
unset($list[$item['id']]['local']['id']);
ksort($list);
}
unset($local);

ksort($list);
return $list;
}

Expand Down Expand Up @@ -688,4 +706,4 @@ function _diff($id){
echo '</table>';
}
}
//Setup VIM: ex: et ts=4 enc=utf-8 :
//Setup VIM: ex: et ts=4 :
2 changes: 2 additions & 0 deletions lang/en/lang.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,11 @@
$lang['profile'] = 'Sync Profile';
$lang['newprofile'] = 'New Profile...';
$lang['select'] = 'Select';
$lang['delete'] = 'Delete';
$lang['create'] = 'Create new Sync Profile';
$lang['edit'] = 'Edit Sync Profile';

$lang['name'] = 'Profile Name';
$lang['server'] = 'XMLRPC URL';
$lang['user'] = 'Username';
$lang['pass'] = 'Password';
Expand Down
4 changes: 4 additions & 0 deletions lang/es/intro.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
====== Sincronización de la Wiki ======

Esta herramienta le permite sincronizar el contenido de su wiki con otras wikis. Múltiples wikis pueden ser configuradas usando perfiles de sincronización. La Sincronización puede ser restringida a ciertos namespaces.

60 changes: 60 additions & 0 deletions lang/es/lang.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
<?php

$lang['menu'] = 'Sincronizar Wikis';

$lang['syncstart'] = 'Comenzar Sincronización';
$lang['lastsync'] = 'Última Sincronización:';
$lang['remotever'] = 'Versión de la Wiki Remota:';

$lang['xmlerr'] = 'Fallo al conectar con wiki remota. Asegúrese que la wiki remota permite solicitudes XMLRPC y que ha configurado correctamente la URL.';
$lang['loginerr'] = 'Fallo al iniciar sesión en la wiki remota. Asegúrese que las credenciales provistas son válidas en la wiki remota.';
$lang['versionerr'] = 'La versión XMLRPC API de la wiki remota es demasiado antigua. Necesita actualizar la wiki remota para usar este plugin.';

$lang['neversync'] = 'Este perfil nunca ha sido sincronizado antes.';
$lang['profile'] = 'Prerfil de Sincronización';
$lang['newprofile'] = 'Nuevo Perfil...';
$lang['select'] = 'Seleccionar';
$lang['create'] = 'Crear nuevo Perfil de Sincronización';
$lang['edit'] = 'Editar Perfil de Sincronización';

$lang['server'] = 'XMLRPC URL';
$lang['user'] = 'Usuario';
$lang['pass'] = 'Contraseña';
$lang['ns'] = 'Namespace';
$lang['depth'] = 'Profundidad de Sincronización';
$lang['level0'] = 'Todos los sub-namespaces';
$lang['level1'] = 'No sub-namespaces';
$lang['level2'] = 'Namespace + 1 sub namespace';
$lang['level3'] = 'Namespace + 2 sub namespaces';
$lang['type'] = 'Qué sincronizar';
$lang['type0'] = 'Todo';
$lang['type1'] = 'Sólo Páginas';
$lang['type2'] = 'Archivo Multimedia';


$lang['save'] = 'Guardar';
$lang['changewarn'] = 'Guardar este perfil borrará el registro de sincronización existente. Usted tendrá que elegir manualmente la dirección de sincronización para todos los archivos la próxima vez que sincronice.';

$lang['lockfail'] = 'no se pudo bloquear y se omitirá:';
$lang['pullfail'] = 'fallo al obtener:';
$lang['pullok'] = 'éxito al obtener:';
$lang['localdelok'] = 'eliminación local exitosa:';
$lang['localdelfail'] = 'eliminación local fallida:';
$lang['pushfail'] = 'fallo al enviar:';
$lang['pushok'] = 'éxito al enviar:';
$lang['remotedelok'] = 'eliminación remota exitosa:';
$lang['remotedelfail'] = 'eliminación remota fallida:';
$lang['skipped'] = 'omitido:';

$lang['file'] = 'Página o Archivo Multimedia';
$lang['local'] = 'Wiki Local';
$lang['remote'] = 'Wiki Remote';
$lang['diff'] = 'Diferencias';

$lang['push'] = 'Enviar revisión local a la wiki remota.';
$lang['pushdel'] = 'Eliminar revisión en la wiki remota.';
$lang['pull'] = 'Obtener revisión remota en la wiki local.';
$lang['pulldel'] = 'Eliminar revisión local.';
$lang['keep'] = 'Omitir este archivo y mantener ambas revisiones tal como están.';

$lang['syncdone'] = 'Sincronización finalizada.';
4 changes: 4 additions & 0 deletions lang/es/list.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
====== Archivos a Sincronizar ======

Una lista de archivos que difiere entre la wiki local y la remota puede verse más abajo. Usted necesita decidir qué revisión desea conservar.

5 changes: 5 additions & 0 deletions lang/es/nochange.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
====== Las Wikis están Sincronizadas ======

No se encontraron diferencias entre su wiki local y la wiki remota. No es necesario sincronizar.


4 changes: 4 additions & 0 deletions lang/es/sync.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
====== Sincronización... ======

El proceso de sincronización ha iniciado. Verifique el progreso más abajo.

3 changes: 3 additions & 0 deletions lang/zh/intro.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
====== Wiki 同步 ======

这个工具允许您将当前 Wiki 与其它多个 Wiki 的内容同步。用来同步的其它 Wiki 可以通过配置文件选择。同步可以限制在特定的命名空间。
62 changes: 62 additions & 0 deletions lang/zh/lang.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
<?php

$lang['menu'] = '同步 Wiki';

$lang['syncstart'] = '开始同步';
$lang['lastsync'] = '最后一次同步:';
$lang['remotever'] = '远端 Wiki 版本:';

$lang['xmlerr'] = '无法连接到远端 Wiki。请确保远端 Wiki 允许XMLRPC请求,并且您正确设置了URL。';
$lang['loginerr'] = '无法登录到远端 Wiki。请确保提供了有效的验证信息。';
$lang['versionerr'] = '远端 Wiki 的XMLRPC API版本过于陈旧。您需要升级远端 Wiki 以使用同步插件。';

$lang['neversync'] = '这个配置文件从未同步过。';
$lang['profile'] = '配置文件';
$lang['newprofile'] = '新配置文件...';
$lang['select'] = '选择';
$lang['delete'] = '删除';
$lang['create'] = '创建新配置文件';
$lang['edit'] = '编辑配置文件';

$lang['name'] = '配置文件名称';
$lang['server'] = 'XMLRPC地址';
$lang['user'] = '用户名';
$lang['pass'] = '密码';
$lang['ns'] = '命名空间';
$lang['depth'] = '同步深度';
$lang['level0'] = '所有子命名空间';
$lang['level1'] = '不包括子命名空间';
$lang['level2'] = '命名空间+1个子命名空间';
$lang['level3'] = '命名空间+2个子命名空间';
$lang['type'] = '同步内容';
$lang['type0'] = '所有';
$lang['type1'] = '仅页面';
$lang['type2'] = '媒体文件';


$lang['save'] = '保存';
$lang['changewarn'] = '重新保存这个配置文件将会重置同步时间。您需要在下次同步中手动为所有文件选择同步的方向。';

$lang['lockfail'] = '无法锁定并跳过:';
$lang['pullfail'] = '拉取失败:';
$lang['pullok'] = '拉取成功:';
$lang['localdelok'] = '本地删除成功:';
$lang['localdelfail'] = '本地删除失败:';
$lang['pushfail'] = '推送失败:';
$lang['pushok'] = '推送成功:';
$lang['remotedelok'] = '远端删除成功:';
$lang['remotedelfail'] = '远端删除失败:';
$lang['skipped'] = '跳过:';

$lang['file'] = '页面或媒体文件';
$lang['local'] = '本地 Wiki';
$lang['remote'] = '远端 Wiki';
$lang['diff'] = '差异';

$lang['push'] = '推送本地版本到远端 Wiki。';
$lang['pushdel'] = '删除远端 Wiki 的版本。';
$lang['pull'] = '拉取远端版本到本地。';
$lang['pulldel'] = '删除本地版本。';
$lang['keep'] = '跳过这个文件,维持两边的版本。';

$lang['syncdone'] = '同步结束。';
3 changes: 3 additions & 0 deletions lang/zh/list.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
====== 要同步的文件 ======

下面列出了两个 Wiki 中不同的文件。您需要决定保存哪个版本。
3 changes: 3 additions & 0 deletions lang/zh/nochange.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
====== Wiki 正在同步 ======

在您的本地 Wiki 和远端 Wiki 间没有发现差异。不需要同步。
3 changes: 3 additions & 0 deletions lang/zh/sync.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
====== 正在同步 ======

同步进程已经启动。请检查同步过程。