fshlp =& plugin_load('helper', 'freesync'); if(!$this->fshlp) msg('Loading the freesync helper failed. Make sure that the tags plugin is installed.', -1); } /** * return some info */ function getInfo(){ return array( 'author' => 'Mikhail I. Izmestev', 'email' => 'izmmishao5@gmail.com', 'date' => '2009-03-09', 'name' => 'freesync dokuwiki plugin', 'desc' => 'Free sync plugin', 'url' => '', ); } /** * return sort order for position in admin menu */ function getMenuSort() { return 999; } /** * handle user request */ function handle() { $fn = $_REQUEST['fn']; if (is_array($fn)) { $cmd = key($fn); $param = is_array($fn[$cmd]) ? $fn[$cmd] : null; } else { $cmd = $fn; $param = null; } $this->fshlp->loadProfile($_REQUEST['profile']); switch($cmd) { case "save_profile": $this->fshlp->saveProfile($_REQUEST['oldname'], $param); break; case "sync": $this->_sync(); break; case "dosync": $this->_dosync($_REQUEST['pages'], $_REQUEST['files'], $_REQUEST['sum']); break; } } function _dosync($pages, $files, $summary) { $this->_sum = $summary; $this->_showDoSync = 1; function needmerge($var) { return $var != 'nothing'; } if(!is_array($pages)) $pages = array(); if(!is_array($files)) $files = array(); $this->_sync_list_pages = array_filter($pages, "needmerge"); $this->_sync_list_files = array_filter($files, "needmerge"); } function _sync() { $this->_sync_list = $this->fshlp->getPagesDiff(); if(empty($this->_sync_list)) msg("All pages are synchronized"); else $this->_showSync = 1; } function _html_profileSelect() { ptln('
'); ptln(''.$this->getLang('sync_profile').''); ptln('
'); ptln(''); ptln(''); ptln('
'); ptln('
'); if($this->fshlp->getProfileName() != "") { $this->_html_startSync(); } ptln('
'); } function _html_profileEdit() { $profile = $this->fshlp->getProfile(); ptln('
'); ptln('Edit '.$this->fshlp->getProfileName().' profile'); ptln(''); ptln(''); ptln(''); ptln(''); ptln(''); ptln(''); ptln(''); ptln(''); ptln(''); ptln(''); ptln(''); ptln(''); ptln(''); ptln(''); ptln(''); ptln('
'); ptln('
'); } function _html_startSync() { ptln('
'); ptln(''.$this->getLang('start_sync').''); ptln($this->fshlp->getProfileName().'
'); ptln('
'); ptln(''); ptln(''); ptln('
'); ptln('
'); } function _html_showSync() { ptln('
'); ptln('
'); ptln(''); ptln(''); ptln(''); ptln(''); ptln(''); while(list($p, $page) = each($this->_sync_list)) { ptln(''); ptln(''); ptln(''); ptln(''); ptln(''); ptln(''); ptln(''); ptln(''); } ptln(''); ptln('
'.$this->getLang('page').''.$this->getLang('local').'>=<'.$this->getLang('remote').''.$this->getLang('diff').'
'.$p.''.(($page['llastModified'])?date("Y/m/d H:i (", $page['llastModified']).$page['lsize'].' bytes)':'-').'$page['rlastModified'])?'checked="checked"':'').'/>'.(($page['rlastModified'])?date("Y/m/d H:i (", $page['rlastModified']).$page['rsize'].' bytes)':'-').''.((!$page["file"] && $page['llastModified'] && $page['rlastModified'])?'Diff':'').'
'); ptln(''); ptln(''); ptln(''); ptln('
'); ptln('
'); } function _html_doSync() { ptln(''); ptln(''); } /** * output appropriate html */ function html() { print $this->locale_xhtml('intro'); ptln('
'); if($this->_showSync) { $this->_html_showSync(); }elseif($this->_showDoSync) { $this->_html_doSync(); }else { $this->_html_profileSelect(); $this->_html_profileEdit(); } ptln('
'); } }