Пример #1
0
 function html()
 {
     global $conf;
     $first = $_REQUEST['first'];
     if (!is_numeric($first)) {
         $first = 0;
     }
     $num = $conf['recent'] ? $conf['recent'] : 20;
     ptln('<h1>' . $this->getLang('menu') . '</h1>');
     $threads = $this->_getThreads();
     // slice the needed chunk of discussion pages
     $more = count($threads) > $first + $num ? true : false;
     $threads = array_slice($threads, $first, $num);
     foreach ($threads as $thread) {
         $comments = $this->_getComments($thread);
         $this->_threadHead($thread);
         if ($comments === false) {
             ptln('</div>', 6);
             // class="level2"
             continue;
         }
         ptln('<form method="post" action="' . wl($thread['id']) . '">', 8);
         ptln('<div class="no">', 10);
         ptln('<input type="hidden" name="do" value="admin" />', 10);
         ptln('<input type="hidden" name="page" value="discussion" />', 10);
         echo html_buildlist($comments, 'admin_discussion', array($this, '_commentItem'), array($this, '_li_comment'));
         $this->_actionButtons($thread['id']);
     }
     $this->_browseDiscussionLinks($more, $first, $num);
 }
Пример #2
0
 /**
  * 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'));
 }
Пример #3
0
 /**
  * AJAX call handler for ACL plugin
  *
  * @param Doku_Event $event  event object by reference
  * @param mixed $param  empty
  * @return void
  */
 public function handle_ajax_call_acl(Doku_Event &$event, $param)
 {
     if ($event->data !== 'plugin_acl') {
         return;
     }
     $event->stopPropagation();
     $event->preventDefault();
     global $ID;
     global $INPUT;
     if (!auth_isadmin()) {
         echo 'for admins only';
         return;
     }
     if (!checkSecurityToken()) {
         echo 'CRSF Attack';
         return;
     }
     $ID = getID();
     /** @var $acl admin_plugin_acl */
     $acl = plugin_load('admin', 'acl');
     $acl->handle();
     $ajax = $INPUT->str('ajax');
     header('Content-Type: text/html; charset=utf-8');
     if ($ajax == 'info') {
         $acl->_html_info();
     } elseif ($ajax == 'tree') {
         $ns = $INPUT->str('ns');
         if ($ns == '*') {
             $ns = '';
         }
         $ns = cleanID($ns);
         $lvl = count(explode(':', $ns));
         $ns = utf8_encodeFN(str_replace(':', '/', $ns));
         $data = $acl->_get_tree($ns, $ns);
         foreach (array_keys($data) as $item) {
             $data[$item]['level'] = $lvl + 1;
         }
         echo html_buildlist($data, 'acl', array($acl, '_html_list_acl'), array($acl, '_html_li_acl'));
     }
 }
Пример #4
0
 /**
  * Render a subtree
  *
  * @param Doku_Event $event
  * @param            $params
  */
 public function handle_ajax_call(Doku_Event $event, $params)
 {
     if ($event->data != 'plugin_move_tree') {
         return;
     }
     $event->preventDefault();
     $event->stopPropagation();
     global $INPUT;
     global $USERINFO;
     if (!auth_ismanager($_SERVER['REMOTE_USER'], $USERINFO['grps'])) {
         http_status(403);
         exit;
     }
     /** @var admin_plugin_move_tree $plugin */
     $plugin = plugin_load('admin', 'move_tree');
     $ns = cleanID($INPUT->str('ns'));
     if ($INPUT->bool('is_media')) {
         $type = admin_plugin_move_tree::TYPE_MEDIA;
     } else {
         $type = admin_plugin_move_tree::TYPE_PAGES;
     }
     $data = $plugin->tree($type, $ns, $ns);
     echo html_buildlist($data, 'tree_list', array($plugin, 'html_list'), array($plugin, 'html_li'));
 }
Пример #5
0
 /**
  * Return the index 
  * @author Samuele Tognini <*****@*****.**>
  *
  * This function is a simple hack of Dokuwiki html_index($ns)
  * @author Andreas Gohr <*****@*****.**>
  */
 function _indexmenu($myns)
 {
     global $conf;
     $ns = $myns[0];
     $js_opts = $myns[1];
     $this->sort = $myns[2];
     $this->msort = $myns[3];
     $this->rsort = $myns[4];
     $this->nsort = $myns[5];
     $opts = $myns[6];
     $output = false;
     $data = array();
     $js_name = "indexmenu_";
     $fsdir = "/" . utf8_encodeFN(str_replace(':', '/', $ns));
     if ($this->sort || $this->msort || $this->rsort) {
         $custsrch = $this->_search($data, $conf['datadir'], array($this, '_search_index'), $opts, $fsdir);
     } else {
         search($data, $conf['datadir'], array($this, '_search_index'), $opts, $fsdir);
     }
     if (!$data) {
         return false;
     }
     // Id generation method
     if (is_numeric($js_opts['gen_id'])) {
         $js_name .= $js_opts['gen_id'];
     } elseif ($js_opts['gen_id'] == 'ns') {
         $js_name .= sprintf("%u", crc32($ns));
     } else {
         $js_name .= uniqid(rand());
     }
     //javascript index
     if ($opts['js']) {
         $ns = str_replace('/', ':', $ns);
         $output_tmp = $this->_jstree($data, $ns, $js_opts, $js_name, $opts['max']);
         //remove unwanted nodes from standard index
         $this->_clean_data($data);
     } else {
         $output .= "<script type='text/javascript' charset='utf-8'>\n";
         $output .= "<!--//--><![CDATA[//><!--\n";
         $output .= "indexmenu_nojsqueue.push(new Array('" . $js_name . "','" . utf8_encodeFN($js_opts['jsajax']) . "'));\n";
         $output .= "addInitEvent(function(){indexmenu_loadJs(DOKU_BASE+'lib/plugins/indexmenu/nojsindex.js');});\n";
         $output .= "//--><!]]>\n";
         $output .= "</script>\n";
     }
     //Nojs dokuwiki index
     $output .= "\n" . '<div id="nojs_' . $js_name . '" class="indexmenu_nojs"';
     $output .= ">\n";
     $output .= html_buildlist($data, 'idx', array($this, "_html_list_index"), "html_li_index");
     $output .= "</div>\n";
     $output .= $output_tmp;
     return $output;
 }
Пример #6
0
}
if (!auth_isadmin()) {
    die('for admins only');
}
if (!checkSecurityToken()) {
    die('CRSF Attack');
}
$ID = getID();
$acl = plugin_load('admin', 'acl');
$acl->handle();
$ajax = $_REQUEST['ajax'];
header('Content-Type: text/html; charset=utf-8');
if ($ajax == 'info') {
    $acl->_html_info();
} elseif ($ajax == 'tree') {
    global $conf;
    global $ID;
    $dir = $conf['datadir'];
    $ns = $_REQUEST['ns'];
    if ($ns == '*') {
        $ns = '';
    }
    $ns = cleanID($ns);
    $lvl = count(explode(':', $ns));
    $ns = utf8_encodeFN(str_replace(':', '/', $ns));
    $data = $acl->_get_tree($ns, $ns);
    foreach (array_keys($data) as $item) {
        $data[$item]['level'] = $lvl + 1;
    }
    echo html_buildlist($data, 'acl', array($acl, '_html_list_acl'), array($acl, '_html_li_acl'));
}
Пример #7
0
/**
 * Build a tree outline of available media namespaces
 *
 * @author Andreas Gohr <*****@*****.**>
 */
function media_nstree($ns)
{
    global $conf;
    global $lang;
    // currently selected namespace
    $ns = cleanID($ns);
    if (empty($ns)) {
        global $ID;
        $ns = (string) getNS($ID);
    }
    $ns_dir = utf8_encodeFN(str_replace(':', '/', $ns));
    $data = array();
    search($data, $conf['mediadir'], 'search_index', array('ns' => $ns_dir, 'nofiles' => true));
    // wrap a list with the root level around the other namespaces
    array_unshift($data, array('level' => 0, 'id' => '', 'open' => 'true', 'label' => '[' . $lang['mediaroot'] . ']'));
    // insert the current ns into the hierarchy if it isn't already part of it
    $ns_parts = explode(':', $ns);
    $tmp_ns = '';
    $pos = 0;
    foreach ($ns_parts as $level => $part) {
        if ($tmp_ns) {
            $tmp_ns .= ':' . $part;
        } else {
            $tmp_ns = $part;
        }
        // find the namespace parts or insert them
        while ($data[$pos]['id'] != $tmp_ns) {
            if ($pos >= count($data) || $data[$pos]['level'] <= $level + 1 && strnatcmp(utf8_encodeFN($data[$pos]['id']), utf8_encodeFN($tmp_ns)) > 0) {
                array_splice($data, $pos, 0, array(array('level' => $level + 1, 'id' => $tmp_ns, 'open' => 'true')));
                break;
            }
            ++$pos;
        }
    }
    echo html_buildlist($data, 'idx', 'media_nstree_item', 'media_nstree_li');
}
Пример #8
0
/**
 * Return the TOC rendered to XHTML
 *
 * @author Andreas Gohr <*****@*****.**>
 */
function html_TOC($toc)
{
    if (!count($toc)) {
        return '';
    }
    global $lang;
    global $conf;
    $out = '<!-- TOC START -->' . DOKU_LF;
    $out .= '<div class="toc">' . DOKU_LF;
    $out .= '<div class="tocheader toctoggle" id="toc__header">';
    $out .= $lang['toc'];
    $out .= '</div>' . DOKU_LF;
    $out .= $conf['toctoggled'] ? '<div id="toc__inside" style="display:none">' . DOKU_LF : '<div id="toc__inside">' . DOKU_LF;
    $out .= html_buildlist($toc, 'toc', 'html_list_toc');
    $out .= '</div>' . DOKU_LF . '</div>' . DOKU_LF;
    $out .= '<!-- TOC END -->' . DOKU_LF;
    return $out;
}
Пример #9
0
/**
 * Renders the Index
 *
 */
function p_index_xhtml($ns)
{
    require_once DOKU_INC . 'inc/search.php';
    global $conf;
    global $ID;
    $dir = $conf['datadir'];
    $tpl = $conf['template'];
    $start = isset($conf['start']) ? $conf['start'] : 'start';
    $ns = getNS($ns);
    $data = array();
    search($data, $conf['datadir'], 'search_index', array('ns' => $ns));
    $i = 0;
    $cleanindexlist = array();
    if (tpl_getConf('cleanindexlist')) {
        $cleanindexlist = explode(',', tpl_getConf('cleanindexlist'));
        $i = 0;
        foreach ($cleanindexlist as $tmpitem) {
            $cleanindexlist[$i] = trim($tmpitem);
            $i++;
        }
    }
    $i = 0;
    foreach ($data as $item) {
        if (tpl_getConf('cleanindex')) {
            if (count($cleanindexlist)) {
                if (strpos($item['id'], ':')) {
                    list($tmpitem) = explode(':', $item['id']);
                } else {
                    $tmpitem = $item['id'];
                }
                if (in_array($tmpitem, $cleanindexlist)) {
                    unset($data[$i]);
                }
            }
        }
        if ($item['id'] == 'sidebar' or $item['id'] == $start or preg_match('/:' . $start . '$/', $item['id']) or !empty($conf['hidepages']) and preg_match('/' . $conf['hidepages'] . '$/', $item['id']) or $item['id'] == $conf['tpl']['dokukit']['extlinks']) {
            unset($data[$i]);
        }
        $i++;
    }
    # echo index with empty items removed
    echo html_buildlist($data, 'idx', '_html_list_index', 'html_li_index');
}
Пример #10
0
/**
 * Return sub index for index view
 *
 * @author Andreas Gohr <*****@*****.**>
 */
function ajax_index()
{
    global $conf;
    global $INPUT;
    // wanted namespace
    $ns = cleanID($INPUT->post->str('idx'));
    $dir = utf8_encodeFN(str_replace(':', '/', $ns));
    $lvl = count(explode(':', $ns));
    $data = array();
    search($data, $conf['datadir'], 'search_index', array('ns' => $ns), $dir);
    foreach (array_keys($data) as $item) {
        $data[$item]['level'] = $lvl + 1;
    }
    echo html_buildlist($data, 'idx', 'html_list_index', 'html_li_index');
}
Пример #11
0
/**
 * Renders the Index
 *
 * copy of html_index located in /inc/html.php
 * updated to the new index
 *
 * @author Matthieu Bouthors <*****@*****.**>
 */
function mbo_html_index($ns)
{
    global $conf;
    global $ID;
    $dir = $conf['datadir'];
    $ns = cleanID($ns);
    #fixme use appropriate function
    if (empty($ns)) {
        $ns = dirname(str_replace(':', '/', $ID));
        if ($ns == '.') {
            $ns = '';
        }
    }
    $ns = utf8_encodeFN(str_replace(':', '/', $ns));
    //    echo p_locale_xhtml('index');
    echo '<h1>Index</h1>';
    echo '<div id="index__tree">';
    $data = array();
    search($data, $conf['datadir'], 'search_index', array('ns' => $ns));
    echo html_buildlist($data, 'idx', 'html_list_index', 'html_li_index');
    echo '</div>';
}
Пример #12
0
 /**
  * Return the TOC rendered to XHTML
  *
  * @author Andreas Gohr <*****@*****.**>
  */
 function render_TOC()
 {
     if (count($this->toc) < 3) {
         return '';
     }
     global $lang;
     $out = '<div class="toc">' . DOKU_LF;
     $out .= '<div class="tocheader toctoggle" id="toc__header">';
     $out .= $lang['toc'];
     $out .= '</div>' . DOKU_LF;
     $out .= '<div id="toc__inside">' . DOKU_LF;
     $out .= html_buildlist($this->toc, 'toc', array($this, '_tocitem'));
     $out .= '</div>' . DOKU_LF . '</div>' . DOKU_LF;
     return $out;
 }
Пример #13
0
/**
 * Display page index
 *
 * @author Andreas Gohr <*****@*****.**>
 */
function html_index($ns)
{
    require_once DOKU_INC . 'inc/search.php';
    global $conf;
    global $ID;
    $dir = $conf['datadir'];
    $ns = cleanID($ns);
    #fixme use appropriate function
    if (empty($ns)) {
        $ns = dirname(str_replace(':', '/', $ID));
        if ($ns == '.') {
            $ns = '';
        }
    }
    $ns = utf8_encodeFN(str_replace(':', '/', $ns));
    print p_locale_xhtml('index');
    $data = array();
    search($data, $conf['datadir'], 'search_index', array('ns' => $ns));
    print html_buildlist($data, 'idx', 'html_list_index', 'html_li_index');
}
Пример #14
0
 /**
  * Display a tree menu to select a page or namespace
  *
  */
 function htmlExplorer($name, $base = '', $current = null)
 {
     global $lang;
     if ($base == '' || $base == '*') {
         $base = ':';
     }
     if (!($o = $this->loadRoute($name))) {
         return "<div>Invalid explorertree route!</div>";
         //TODO: replace with lang...
     }
     $data = $this->getTree($base);
     // wrap a list with the root level around the other namespaces
     if ($base == ':') {
         array_unshift($data, array('level' => 0, 'id' => ':', 'type' => 'd', 'open' => 'true', 'label' => '[' . $lang['mediaroot'] . ']'));
     }
     $list = html_buildlist($data, $class = $o['vars']['class'], array($this, '_html_list_tree'), array($this, '_html_li_tree'));
     if (strncasecmp(trim($list), '<ul ', 4)) {
         $list = "<ul class='{$class}' >" . $list . "</ul>";
     }
     if (!($id = $o['vars']['id'])) {
         $id = "explorertree_{$name}";
     }
     if ($base == ':') {
         return "<div class='{$class}_root' id='{$id}'>" . $list . "</div>" . "<script type='text/javascript'>jQuery(document).ready(function(){jQuery('#{$id}').explorerTree(" . $this->_treeOpts($name, $current === null ? $base : $current) . ")});</script>";
     }
     return $list;
 }
Пример #15
0
 /**
  * Handle remote directories
  */
 function _directory($url, &$renderer, $path, $refresh)
 {
     global $conf;
     $cache = getCacheName($url . $path, '.repo');
     $mtime = @filemtime($cache);
     // 0 if it doesn't exist
     if ($mtime != 0 && !$_REQUEST['purge'] && $mtime > time() - $refresh) {
         $idx = io_readFile($cache, false);
         if ($conf['allowdebug']) {
             $idx .= "\n<!-- cachefile {$cache} used -->\n";
         }
     } else {
         $items = $this->_index($url, $path);
         $idx = html_buildlist($items, 'idx', 'repo_list_index', 'html_li_index');
         io_saveFile($cache, $idx);
         if ($conf['allowdebug']) {
             $idx .= "\n<!-- no cachefile used, but created -->\n";
         }
     }
     $renderer->doc .= $idx;
 }
Пример #16
0
session_write_close();
if (!auth_isadmin()) {
    die('for admins only');
}
if (!checkSecurityToken()) {
    die('CRSF Attack');
}
$ID = getID();
$dokutranslate = plugin_load('admin', 'dokutranslate');
$dokutranslate->handle();
$ajax = $_REQUEST['ajax'];
header('Content-Type: text/html; charset=utf-8');
if ($ajax == 'modform') {
    $dokutranslate->_html_modform();
} elseif ($ajax == 'tree') {
    global $conf;
    global $ID;
    $dir = $conf['datadir'];
    $ns = $_REQUEST['ns'];
    if ($ns == '*') {
        $ns = '';
    }
    $ns = cleanID($ns);
    $lvl = count(explode(':', $ns));
    $ns = utf8_encodeFN(str_replace(':', '/', $ns));
    $data = $dokutranslate->_get_tree($ns, $ns);
    foreach (array_keys($data) as $item) {
        $data[$item]['level'] = $lvl + 1;
    }
    echo html_buildlist($data, 'dokutranslate', array($dokutranslate, '_html_list_acl'), array($dokutranslate, '_html_li_acl'));
}
Пример #17
0
 function html()
 {
     global $conf;
     $first = $_REQUEST['first'];
     if (!is_numeric($first)) {
         $first = 0;
     }
     $num = $conf['recent'];
     ptln('<h1>' . $this->getLang('menu') . '</h1>');
     $targets = $this->_getTargets();
     // slice the needed chunk of linkback targets
     $more = count($targets) > $first + $num ? true : false;
     $targets = array_slice($targets, $first, $num);
     foreach ($targets as $target) {
         $linkbacks = $this->_getLinkbacks($target);
         $this->_targetHead($target);
         if ($linkbacks === false) {
             ptln('</div>', 6);
             // class="level2"
             continue;
         }
         ptln('<form method="post" action="' . wl($target['id']) . '">', 8);
         ptln('<div class="no">', 10);
         ptln('<input type="hidden" name="do" value="admin" />', 10);
         ptln('<input type="hidden" name="page" value="linkback" />', 10);
         echo html_buildlist($linkbacks, 'admin_linkback', array($this, '_linkbackItem'), array($this, '_li_linkback'));
         $this->_actionButtons($target['id']);
     }
     $this->_browseLinkbackLinks($more, $first, $num);
 }
Пример #18
0
/**
 * Build a tree outline of available media namespaces
 *
 * @author Andreas Gohr <*****@*****.**>
 */
function media_nstree($ns)
{
    global $conf;
    global $lang;
    // currently selected namespace
    $ns = cleanID($ns);
    if (empty($ns)) {
        global $ID;
        $ns = dirname(str_replace(':', '/', $ID));
        if ($ns == '.') {
            $ns = '';
        }
    }
    $ns = utf8_encodeFN(str_replace(':', '/', $ns));
    $data = array();
    search($data, $conf['mediadir'], 'search_index', array('ns' => $ns, 'nofiles' => true));
    // wrap a list with the root level around the other namespaces
    array_unshift($data, array('level' => 0, 'id' => '', 'open' => 'true', 'label' => '[' . $lang['mediaroot'] . ']'));
    echo html_buildlist($data, 'idx', 'media_nstree_item', 'media_nstree_li');
}
Пример #19
0
 /**
  * Build thanks message, trigger indexing and rendering of new pages.
  *
  * @param string $thanks
  * @return string html of thanks message or when redirect the first page id of created pages
  */
 protected function buildThankYouPage($thanks)
 {
     global $ID;
     $backupID = $ID;
     $html = "<p>{$thanks}</p>";
     // Build result tree
     $pages = array_keys($this->targetpages);
     usort($pages, array($this, '_sorttargetpages'));
     $data = array();
     $last_folder = array();
     foreach ($pages as $ID) {
         $lvl = substr_count($ID, ':');
         for ($n = 0; $n < $lvl; ++$n) {
             if (!isset($last_folder[$n]) || strpos($ID, $last_folder[$n]['id']) !== 0) {
                 $last_folder[$n] = array('id' => substr($ID, 0, strpos($ID, ':', ($n > 0 ? strlen($last_folder[$n - 1]['id']) : 0) + 1) + 1), 'level' => $n + 1, 'open' => 1);
                 $data[] = $last_folder[$n];
             }
         }
         $data[] = array('id' => $ID, 'level' => 1 + substr_count($ID, ':'), 'type' => 'f');
     }
     $html .= html_buildlist($data, 'idx', array($this, 'html_list_index'), 'html_li_index');
     // Add indexer bugs for every just-created page
     $html .= '<div class="no">';
     ob_start();
     foreach ($pages as $ID) {
         // indexerWebBug uses ID and INFO[exists], but the bureaucracy form
         // page always exists, as does the just-saved page, so INFO[exists]
         // is correct in any case
         tpl_indexerWebBug();
         // the iframe will trigger real rendering of the pages to make sure
         // any used plugins are initialized (eg. the do plugin)
         echo '<iframe src="' . wl($ID, array('do' => 'export_html')) . '" width="1" height="1" style="visibility:hidden"></iframe>';
     }
     $html .= ob_get_contents();
     ob_end_clean();
     $html .= '</div>';
     $ID = $backupID;
     return $html;
 }
Пример #20
0
 /**
  * Display a tree menu to select a page or namespace
  *
  * @author Andreas Gohr <*****@*****.**>
  */
 function _html_explorer()
 {
     global $conf;
     global $ID;
     global $lang;
     $dir = $conf['datadir'];
     $ns = $this->ns;
     if (empty($ns)) {
         $ns = dirname(str_replace(':', '/', $ID));
         if ($ns == '.') {
             $ns = '';
         }
     } elseif ($ns == '*') {
         $ns = '';
     }
     $ns = utf8_encodeFN(str_replace(':', '/', $ns));
     $data = $this->_get_tree($ns);
     // wrap a list with the root level around the other namespaces
     array_unshift($data, array('level' => 0, 'id' => '*', 'type' => 'd', 'open' => 'true', 'label' => '[' . $lang['mediaroot'] . ']'));
     echo html_buildlist($data, 'acl', array($this, '_html_list_acl'), array($this, '_html_li_acl'));
 }
Пример #21
0
 /**
  * Display a tree menu to select a page or namespace
  *
  * @author Andreas Gohr <*****@*****.**>
  */
 function _html_explorer()
 {
     require_once DOKU_INC . 'inc/search.php';
     global $conf;
     global $ID;
     global $lang;
     $dir = $conf['datadir'];
     $ns = $this->ns;
     if (empty($ns)) {
         $ns = dirname(str_replace(':', '/', $ID));
         if ($ns == '.') {
             $ns = '';
         }
     } elseif ($ns == '*') {
         $ns = '';
     }
     $ns = utf8_encodeFN(str_replace(':', '/', $ns));
     $data = $this->_get_tree($ns);
     // wrap a list with the root level around the other namespaces
     $item = array('level' => 0, 'id' => '*', 'type' => 'd', 'open' => 'true', 'label' => '[' . $lang['mediaroot'] . ']');
     echo '<ul class="acltree">';
     echo $this->_html_li_acl($item);
     echo '<div class="li">';
     echo $this->_html_list_acl($item);
     echo '</div>';
     echo html_buildlist($data, 'acl', array($this, '_html_list_acl'), array($this, '_html_li_acl'));
     echo '</li>';
     echo '</ul>';
 }
Пример #22
0
 /**
  * Print index nodes
  *
  * @author Samuele Tognini <*****@*****.**>
  * @author Andreas Gohr <*****@*****.**>
  */
 function print_index($ns)
 {
     require_once DOKU_PLUGIN . 'indexmenu/syntax/indexmenu.php';
     global $conf;
     $idxm = new syntax_plugin_indexmenu_indexmenu();
     $ns = $idxm->_parse_ns($ns);
     $level = -1;
     $max = 0;
     $data = array();
     if ($_REQUEST['max'] > 0) {
         $max = $_REQUEST['max'];
         $level = $max;
     }
     $nss = $_REQUEST['nss'] ? cleanID($_REQUEST['nss']) : '';
     $idxm->sort = $_REQUEST['sort'];
     $idxm->msort = $_REQUEST['msort'];
     $idxm->rsort = $_REQUEST['rsort'];
     $idxm->nsort = $_REQUEST['nsort'];
     $fsdir = "/" . utf8_encodeFN(str_replace(':', '/', $ns));
     $opts = array('level' => $level, 'nons' => $_REQUEST['nons'], 'nss' => array(array($nss, 1)), 'max' => $max, 'js' => false, 'nopg' => $_REQUEST['nopg'], 'skip_index' => $idxm->getConf('skip_index'), 'skip_file' => $idxm->getConf('skip_file'), 'headpage' => $idxm->getConf('headpage'), 'hide_headpage' => $idxm->getConf('hide_headpage'));
     if ($idxm->sort || $idxm->msort || $idxm->rsort) {
         $idxm->_search($data, $conf['datadir'], array($idxm, '_search_index'), $opts, $fsdir);
     } else {
         search($data, $conf['datadir'], array($idxm, '_search_index'), $opts, $fsdir);
     }
     if ($_REQUEST['nojs']) {
         require_once DOKU_INC . 'inc/html.php';
         $out_tmp = html_buildlist($data, 'idx', array($idxm, "_html_list_index"), "html_li_index");
         $out .= preg_replace('/<ul class="idx">(.*)<\\/ul>/s', "\$1", $out_tmp);
     } else {
         $nodes = $idxm->_jsnodes($data, '', 0);
         $out = "ajxnodes = [";
         $out .= rtrim($nodes[0], ",");
         $out .= "];";
     }
     return $out;
 }
/**
 * Return the TOC rendered to XHTML with Bootstrap3 style
 *
 * @author Andreas Gohr <*****@*****.**>
 * @author Giuseppe Di Terlizzi <*****@*****.**>
 *
 * @param array $toc
 * @return string html
 */
function bootstrap3_html_toc($toc)
{
    if (!count($toc)) {
        return '';
    }
    global $lang;
    $out = '';
    $out .= '<!-- TOC START -->' . DOKU_LF;
    $out .= '<nav id="dokuwiki__toc" role="navigation" class="small">' . DOKU_LF;
    $out .= '<h6 data-toggle="collapse" data-target="#dokuwiki__toc .toc-body" title="' . $lang['toc'] . '" class="toc-title"><i class="fa fa-fw fa-th-list"></i> ';
    $out .= '<span>' . $lang['toc'] . '</span>';
    $out .= ' <i class="caret"></i></h6>' . DOKU_LF;
    $out .= '<div class="toc-body collapse in">' . DOKU_LF;
    $out .= bootstrap3_lists(html_buildlist($toc, 'nav toc', 'html_list_toc', 'html_li_default', true)) . DOKU_LF;
    $out .= '</div>' . DOKU_LF;
    $out .= '</nav>' . DOKU_LF;
    $out .= '<!-- TOC END -->' . DOKU_LF;
    return $out;
}
Пример #24
0
 /**
  * Return the index
  *
  * @author Samuele Tognini <*****@*****.**>
  *
  * This function is a simple hack of Dokuwiki @see html_index($ns)
  * @author Andreas Gohr <*****@*****.**>
  *
  * @param array $myns the options for indexmenu
  * @return bool|string return html for a nojs index and when enabled the js rendered index, otherwise false
  */
 private function _indexmenu($myns)
 {
     global $conf;
     $ns = $myns[0];
     $js_opts = $myns[1];
     //theme, identifier, nocookie, navbar, noscroll, maxjs, notoc, jsajax, context, nomenu
     $this->sort = $myns[2];
     $this->msort = $myns[3];
     $this->rsort = $myns[4];
     $this->nsort = $myns[5];
     $opts = $myns[6];
     //level, nons, nopg, nss, max, js, skip_index, skip_file, headpage, hide_headpage
     $this->hsort = $myns[7];
     $data = array();
     $js_name = "indexmenu_" . $js_opts['identifier'];
     $fsdir = "/" . utf8_encodeFN(str_replace(':', '/', $ns));
     if ($this->sort || $this->msort || $this->rsort || $this->hsort) {
         $this->_search($data, $conf['datadir'], array($this, '_search_index'), $opts, $fsdir);
     } else {
         search($data, $conf['datadir'], array($this, '_search_index'), $opts, $fsdir);
     }
     if (!$data) {
         return false;
     }
     // javascript index
     $output_tmp = "";
     if ($opts['js']) {
         $ns = str_replace('/', ':', $ns);
         $output_tmp = $this->_jstree($data, $ns, $js_opts, $js_name, $opts['max']);
         //remove unwanted nodes from standard index
         $this->_clean_data($data);
     }
     // Nojs dokuwiki index
     //    extra div needed when index is first element in sidebar of dokuwiki template, template uses this to toggle sidebar
     //    the toggle interacts with hide needed for js option.
     $output = "\n";
     $output .= '<div><div id="nojs_' . $js_name . '" data-jsajax="' . utf8_encodeFN($js_opts['jsajax']) . '" class="indexmenu_nojs">' . "\n";
     $output .= html_buildlist($data, 'idx', array($this, "_html_list_index"), "html_li_index");
     $output .= "</div></div>\n";
     $output .= $output_tmp;
     return $output;
 }
/**
 * Renders the Index
 *
 * copy of html_index located in /inc/html.php
 *
 * TODO update to new AJAX index possible?
 *
 * @author Andreas Gohr <*****@*****.**>
 * @author Michael Klier <*****@*****.**>
 */
function p_index_xhtml($ns, $pos)
{
    require_once DOKU_INC . 'inc/search.php';
    global $conf;
    global $ID;
    $dir = $conf['datadir'];
    $ns = cleanID($ns);
    #fixme use appropriate function
    if (empty($ns)) {
        $ns = dirname(str_replace(':', '/', $ID));
        if ($ns == '.') {
            $ns = '';
        }
    }
    $ns = utf8_encodeFN(str_replace(':', '/', $ns));
    // extract only the headline
    preg_match('/<h1>.*?<\\/h1>/', p_locale_xhtml('index'), $match);
    print preg_replace('#<h1(.*?id=")(.*?)(".*?)h1>#', '<h1\\1sidebar_' . $pos . '_\\2\\3h1>', $match[0]);
    $data = array();
    search($data, $conf['datadir'], 'search_index', array('ns' => $ns));
    print '<div id="' . $pos . '__index__tree">' . DOKU_LF;
    print html_buildlist($data, 'idx', 'html_list_index', 'html_li_index');
    print '</div>' . DOKU_LF;
}
 function run($data, $thanks, $argv)
 {
     global $ID;
     global $conf;
     global $USERINFO;
     list($tpl, $pagename, $sep) = $argv;
     if (is_null($sep)) {
         $sep = $conf['sepchar'];
     }
     $runas = $this->getConf('runas');
     $patterns = array();
     $values = array();
     $templates = array();
     // run through fields
     foreach ($data as $opt) {
         $label = $opt->getParam('label');
         $value = $opt->getParam('value');
         // prepare replacements
         if (!is_null($label)) {
             $patterns[$label] = '/(@@|##)' . preg_quote($label, '/') . '(?:\\|([^|]*?))' . (is_null($value) ? '' : '?') . '\\1/si';
             $values[$label] = is_null($value) ? '$2' : $value;
             $patterns[$label . '|'] = '/(@@|##)' . preg_quote($label, '/') . '(?:\\|(.*?))(?:\\|(.*?))\\1/si';
             $values[$label . '|'] = is_null($value) ? '$2' : '$3';
         }
         // handle pagenames
         $pname = $opt->getParam('pagename');
         if (!is_null($pname)) {
             $pagename .= $sep . $pname;
         }
         if (!is_null($opt->getParam('page_tpl')) && !is_null($opt->getParam('page_tgt'))) {
             $page_tpl = $this->replace($patterns, $values, $opt->getParam('page_tpl'));
             if (auth_aclcheck($page_tpl, $runas ? $runas : $_SERVER['REMOTE_USER'], $USERINFO['grps']) >= AUTH_READ) {
                 $templates[$opt->getParam('page_tgt')] = rawWiki($page_tpl);
             }
         }
     }
     $pagename = $this->replace($patterns, $values, $pagename);
     // check pagename
     $pagename = cleanID($pagename);
     if ($pagename === '') {
         throw new Exception($this->getLang('e_pagename'));
     }
     $_templates = array();
     foreach ($templates as $k => $v) {
         $_templates[cleanID("{$pagename}:{$k}")] = $v;
     }
     $templates = $_templates;
     // get templates
     if ($tpl == '_') {
         // use namespace template
         if (!isset($templates[$pagename])) {
             $templates[$pagename] = pageTemplate(array($pagename));
         }
     } elseif ($tpl !== '!') {
         // Namespace link
         require_once DOKU_INC . 'inc/search.php';
         if ($runas) {
             // Hack user credentials.
             global $USERINFO;
             $backup = array($_SERVER['REMOTE_USER'], $USERINFO['grps']);
             $_SERVER['REMOTE_USER'] = $runas;
             $USERINFO['grps'] = array();
         }
         $t_pages = array();
         search($t_pages, $conf['datadir'], 'search_universal', array('depth' => 0, 'listfiles' => true), str_replace(':', '/', getNS($tpl)));
         foreach ($t_pages as $t_page) {
             $t_name = cleanID($t_page['id']);
             $p_name = preg_replace('/^' . preg_quote_cb(cleanID($tpl)) . '($|:)/', $pagename . '$1', $t_name);
             if ($p_name === $t_name) {
                 // When using a single-page template, ignore other pages
                 // in the same namespace.
                 continue;
             }
             if (!isset($templates[$p_name])) {
                 // load page data and do default pattern replacements like
                 // namespace templates do
                 $data = array('id' => $p_name, 'tpl' => rawWiki($t_name), 'doreplace' => true);
                 parsePageTemplate($data);
                 $templates[$p_name] = $data['tpl'];
             }
         }
         if ($runas) {
             /* Restore user credentials. */
             global $USERINFO;
             list($_SERVER['REMOTE_USER'], $USERINFO['grps']) = $backup;
         }
     }
     if (empty($templates)) {
         throw new Exception(sprintf($this->getLang('e_template'), $tpl));
     }
     // check all target pagenames
     foreach (array_keys($templates) as $pname) {
         // prevent overriding already existing pages
         if (page_exists($pname)) {
             throw new Exception(sprintf($this->getLang('e_pageexists'), html_wikilink($pname)));
         }
         // check auth
         if ($runas) {
             $auth = auth_aclcheck($pname, $runas, array());
         } else {
             $auth = auth_quickaclcheck($pname);
         }
         if ($auth < AUTH_CREATE) {
             throw new Exception($this->getLang('e_denied'));
         }
     }
     foreach ($templates as $pname => $template) {
         // set NSBASE var to make certain dataplugin constructs easier
         $patterns['__nsbase__'] = '/@NSBASE@/';
         $values['__nsbase__'] = noNS(getNS($pname));
         // save page
         saveWikiText($pname, $this->replace($patterns, $values, $template, false), sprintf($this->getLang('summary'), $ID));
     }
     $ret = "<p>{$thanks}</p>";
     // Build result tree
     $pages = array_keys($templates);
     usort($pages, array($this, '_sort'));
     $oldid = $ID;
     $data = array();
     $last_folder = array();
     foreach ($pages as $ID) {
         $lvl = substr_count($ID, ':');
         for ($n = 0; $n < $lvl; ++$n) {
             if (!isset($last_folder[$n]) || strpos($ID, $last_folder[$n]['id']) !== 0) {
                 $last_folder[$n] = array('id' => substr($ID, 0, strpos($ID, ':', ($n > 0 ? strlen($last_folder[$n - 1]['id']) : 0) + 1) + 1), 'level' => $n + 1, 'open' => 1);
                 $data[] = $last_folder[$n];
             }
         }
         $data[] = array('id' => $ID, 'level' => 1 + substr_count($ID, ':'), 'type' => 'f');
     }
     $ret .= html_buildlist($data, 'idx', array($this, 'html_list_index'), 'html_li_index');
     // Add indexer bugs for every just-created page
     $ret .= '<div class="no">';
     ob_start();
     foreach ($pages as $ID) {
         // indexerWebBug uses ID and INFO[exists], but the bureaucracy form
         // page always exists, as does the just-saved page, so INFO[exists]
         // is correct in any case
         tpl_indexerWebBug();
         // the iframe will trigger real rendering of the pages to make sure
         // any used plugins are initialized (eg. the do plugin)
         echo '<iframe src="' . wl($ID, array('do' => 'export_html')) . '" width="1" height="1" style="visibility:hidden"></iframe>';
     }
     $ret .= ob_get_contents();
     ob_end_clean();
     $ID = $oldid;
     $ret .= '</div>';
     return $ret;
 }
Пример #27
0
/**
 * Return the TOC rendered to XHTML
 *
 * @author Andreas Gohr <*****@*****.**>
 */
function html_TOC($toc)
{
    if (!count($toc)) {
        return '';
    }
    global $lang;
    $out = '<!-- TOC START -->' . DOKU_LF;
    $out .= '<div class="toc">' . DOKU_LF;
    $out .= '<div class="tocheader toctoggle" id="toc__header">';
    $out .= $lang['toc'];
    $out .= '</div>' . DOKU_LF;
    $out .= '<div id="toc__inside">' . DOKU_LF;
    $out .= html_buildlist($toc, 'toc', 'html_list_toc', 'html_li_default', true);
    $out .= '</div>' . DOKU_LF . '</div>' . DOKU_LF;
    $out .= '<!-- TOC END -->' . DOKU_LF;
    return $out;
}
Пример #28
0
 /**
  * Return the index
  *
  * @author Samuele Tognini <*****@*****.**>
  *
  * This function is a simple hack of Dokuwiki html_index($ns)
  * @author Andreas Gohr <*****@*****.**>
  */
 function _indexmenu($myns)
 {
     global $conf;
     $ns = $myns[0];
     $js_opts = $myns[1];
     $this->sort = $myns[2];
     $this->msort = $myns[3];
     $this->rsort = $myns[4];
     $this->nsort = $myns[5];
     $opts = $myns[6];
     $this->hsort = $myns[7];
     $data = array();
     $js_name = "indexmenu_";
     $fsdir = "/" . utf8_encodeFN(str_replace(':', '/', $ns));
     if ($this->sort || $this->msort || $this->rsort || $this->hsort) {
         $this->_search($data, $conf['datadir'], array($this, '_search_index'), $opts, $fsdir);
     } else {
         search($data, $conf['datadir'], array($this, '_search_index'), $opts, $fsdir);
     }
     if (!$data) {
         return false;
     }
     // Id generation method
     if (is_numeric($js_opts['gen_id'])) {
         $js_name .= $js_opts['gen_id'];
     } elseif ($js_opts['gen_id'] == 'ns') {
         $js_name .= sprintf("%u", crc32($ns));
     } else {
         $js_name .= uniqid(rand());
     }
     // javascript index
     $output_tmp = "";
     if ($opts['js']) {
         $ns = str_replace('/', ':', $ns);
         $output_tmp = $this->_jstree($data, $ns, $js_opts, $js_name, $opts['max']);
         //remove unwanted nodes from standard index
         $this->_clean_data($data);
     }
     // Nojs dokuwiki index
     //    extra div needed when index is first element in sidebar of dokuwiki template, template uses this to toggle sidebar
     //    the toggle interacts with hide needed for js option.
     $output = "\n";
     $output .= '<div><div id="nojs_' . $js_name . '" data-jsajax="' . utf8_encodeFN($js_opts['jsajax']) . '" class="indexmenu_nojs">' . "\n";
     $output .= html_buildlist($data, 'idx', array($this, "_html_list_index"), "html_li_index");
     $output .= "</div></div>\n";
     $output .= $output_tmp;
     return $output;
 }