locale_xhtml('tree'); echo ''; echo '
'; echo '
'; echo '

' . $this->getLang('move_pages') . '

'; $this->htmlTree(self::TYPE_PAGES); echo '
'; echo '
'; echo '

' . $this->getLang('move_media') . '

'; $this->htmlTree(self::TYPE_MEDIA); echo '
'; /** @var helper_plugin_move_plan $plan */ $plan = plugin_load('helper', 'move_plan'); echo '
'; if($plan->isCommited()) { echo '
' . $this->getLang('moveinprogress') . '
'; } else { $form = new Doku_Form(array('action' => wl($ID), 'id' => 'plugin_move__tree_execute')); $form->addHidden('id', $ID); $form->addHidden('page', 'move_main'); $form->addHidden('json', ''); $form->addElement(form_makeCheckboxField('autoskip', '1', $this->getLang('autoskip'), '', '', ($this->getConf('autoskip') ? array('checked' => 'checked') : array()))); $form->addElement('
'); $form->addElement(form_makeCheckboxField('autorewrite', '1', $this->getLang('autorewrite'), '', '', ($this->getConf('autorewrite') ? array('checked' => 'checked') : array()))); $form->addElement('
'); $form->addElement('
'); $form->addElement(form_makeButton('submit', 'admin', $this->getLang('btn_start'))); $form->printForm(); } echo '
'; echo '
'; } /** * print the HTML tree structure * * @param int $type */ protected function htmlTree($type = self::TYPE_PAGES) { $data = $this->tree($type); // wrap a list with the root level around the other namespaces array_unshift( $data, array( 'level' => 0, 'id' => '*', 'type' => 'd', 'open' => 'true', 'label' => $this->getLang('root') ) ); echo html_buildlist( $data, 'tree_list idx', array($this, 'html_list'), array($this, 'html_li') ); } /** * Build a tree info structure from media or page directories * * @param int $type * @param string $open The hierarchy to open FIXME not supported yet * @param string $base The namespace to start from * @return array */ public function tree($type = self::TYPE_PAGES, $open = '', $base = '') { global $conf; $opendir = utf8_encodeFN(str_replace(':', '/', $open)); $basedir = utf8_encodeFN(str_replace(':', '/', $base)); $opts = array( 'pagesonly' => ($type == self::TYPE_PAGES), 'listdirs' => true, 'listfiles' => true, 'sneakyacl' => $conf['sneaky_index'], 'showmsg' => false, 'depth' => 1, 'showhidden' => true ); $data = array(); if($type == self::TYPE_PAGES) { search($data, $conf['datadir'], 'search_universal', $opts, $basedir); } elseif($type == self::TYPE_MEDIA) { search($data, $conf['mediadir'], 'search_universal', $opts, $basedir); } return $data; } /** * Item formatter for the tree view * * User function for html_buildlist() * * @author Andreas Gohr */ function html_list($item) { $ret = ''; // what to display if(!empty($item['label'])) { $base = $item['label']; } else { $base = ':' . $item['id']; $base = substr($base, strrpos($base, ':') + 1); } if($item['id'] == '*') $item['id'] = ''; if ($item['id']) { $ret .= ' '; } // namespace or page? if($item['type'] == 'd') { $ret .= ''; $ret .= $base; $ret .= ''; } else { $ret .= ''; $ret .= noNS($item['id']); $ret .= ''; } if($item['id']) $ret .= ''; else $ret .= ''; return $ret; } /** * print the opening LI for a list item * * @param array $item * @return string */ function html_li($item) { if($item['id'] == '*') $item['id'] = ''; $params = array(); $params['class'] = ' type-' . $item['type']; if($item['type'] == 'd') $params['class'] .= ' ' . ($item['open'] ? 'open' : 'closed'); $params['data-name'] = noNS($item['id']); $params['data-id'] = $item['id']; $attr = buildAttributes($params); return "
  • "; } }