profileManager = new ProfileManager(); if($INPUT->str('no') == 'none') { $this->profno = -1; } else { $this->profno = $INPUT->int('no', -1); } } /** * return sort order for position in admin menu */ function getMenuSort() { return 1020; } /** * handle profile saving/deleting */ function handle() { global $INPUT; $profile = $INPUT->arr('prf'); if(!$profile) return; if(!checkSecurityToken()) return; try { if($INPUT->has('sync__delete') && $this->profno !== false) { // profile deletion $this->profileManager->deleteProfileConfig($this->profno); $this->profno = false; $INPUT->remove('prf'); msg('profile deleted', 1); } else { // profile add/edit $this->profno = $this->profileManager->setProfileConfig($this->profno, $profile); msg('profile saved', 1); } } catch(SyncException $e) { msg(hsc($e->getMessage()), -1); } } /** * output appropriate html */ function html() { global $INPUT; if($INPUT->bool('startsync') && $this->profno != -1 && checkSecurityToken()) { // fixme display an intro $data = [ 'profile' => $this->profno ]; echo ''; echo ''; echo '
' . $this->getLang('remotever') . ' ' . hsc($version) . '
'); if($ltime) { $form->addHTML('' . $this->getLang('lastsync') . ' ' . dformat($ltime) . '
'); } else { $form->addHTML('' . $this->getLang('neversync') . '
'); } $form->addButton('startsync', $this->getLang('syncstart'))->attr('type', 'submit'); $form->addFieldsetClose(); echo $form->toHTML(); } /** * Dropdown list of available sync profiles */ protected function profileDropdown() { $form = new Form( [ 'action' => wl('', ['do' => 'admin', 'page' => 'sync'], false, '&'), 'method' => 'POST', ] ); $profiles = ['none' => $this->getLang('newprofile')]; $profiles = array_merge($profiles, $this->profileManager->getProfileLabels()); $form->addFieldsetOpen($this->getLang('profile')); $form->addDropdown('no', $profiles)->val($this->profno); $form->addButton('', $this->getLang('select')); $form->addFieldsetClose(); echo $form->toHTML(); } /** * Form to edit or create a sync profile */ protected function profileForm() { $form = new Form( [ 'action' => wl('', ['do' => 'admin', 'page' => 'sync'], false, '&'), 'method' => 'POST', 'class' => 'sync_profile', ] ); if($this->profno === -1) { $legend = $this->getLang('create'); $profile = $this->profileManager->getEmptyConfig(); } else { $legend = $this->getLang('edit'); $profile = $this->profileManager->getProfileConfig($this->profno); } $depths = [ ['label' => $this->getLang('level0')], ['label' => $this->getLang('level1')], ['label' => $this->getLang('level2')], ['label' => $this->getLang('level3')], ]; $types = [ ['label' => $this->getLang('type0')], ['label' => $this->getLang('type1')], ['label' => $this->getLang('type2')], ]; $form->addFieldsetOpen($legend); $form->setHiddenField('no', $this->profno); $form->addTextInput('prf[server]', $this->getLang('server'))->val($profile['server']); $form->addHTML('http://example.com/dokuwiki/lib/exe/xmlrpc.php'); $form->addTextInput('prf[ns]', $this->getLang('ns'))->val($profile['ns']); $form->addDropdown('prf[depth]', $depths, $this->getLang('depth'))->val($profile['depth']); $form->addTextInput('prf[user]', $this->getLang('user'))->val($profile['user']); $form->addPasswordInput('prf[pass]', $this->getLang('pass'))->val($profile['pass']); $form->addTextInput('prf[timeout]', $this->getLang('timeout'))->val($profile['timeout']); $form->addDropdown('prf[type]', $types, $this->getLang('type'))->val($profile['type']); $form->addButton('', $this->getLang('save'))->attr('type', 'submit'); if($this->profno !== -1 && !empty($profile['ltime'])) { echo '' . $this->getLang('changewarn') . ''; } $form->addFieldsetClose(); if($this->profno !== -1) { $form->addFieldsetOpen($this->getLang('delete')); $form->addButton('sync__delete', $this->getLang('delete')); $form->addFieldsetClose(); } echo $form->toHTML(); } }