public function testInnerToOuter()
 {
     $thirdHTML = p_wiki_xhtml('test:plugin_include:nested:third');
     $secondHTML = p_wiki_xhtml('test:plugin_include:nested:second');
     $mainHTML = p_wiki_xhtml('test:plugin_include:nested:start');
     $this->_validateContent($mainHTML, $secondHTML, $thirdHTML);
 }
function tpl_sidebar($user_defined_page_name = "")
{
    global $ID, $REV, $conf;
    // save globals
    $saveID = $ID;
    $saveREV = $REV;
    // discover file to be displayed in navigation sidebar
    $fileSidebar = '';
    // damien
    $pagename = "";
    if ($user_defined_page_name != "") {
        $pagename = $user_defined_page_name;
    } else {
        if (isset($conf['sidebar']['page'])) {
            $pagename = $conf['sidebar']['page'];
        }
    }
    if ($pagename != "") {
        $fileSidebar = getSidebarFN(getNS($ID), $pagename);
    }
    // determine what to display
    if ($fileSidebar) {
        $ID = $fileSidebar;
        $REV = '';
        print p_wiki_xhtml($ID, $REV, false);
    } else {
        global $IDX;
        html_index($IDX);
    }
    // restore globals
    $ID = $saveID;
    $REV = $saveREV;
}
function p_file_xhtml($id, $excuse = false)
{
    if (@file_exists($id)) {
        return p_cached_output($id, 'xhtml', $id);
    }
    return p_wiki_xhtml($id, '', $excuse);
}
function _getMenu($menu, $edit)
{
    global $conf, $ID, $REV, $INFO, $lang;
    $currID = false;
    // Remember $ID and $REV
    $svID = $ID;
    $svREV = $REV;
    // Parent side ID
    $sub = substr($ID, 0, strpos($ID, ":"));
    $menuOutput = "";
    if (file_exists(wikiFN($ID . "/" . $menu))) {
        $menuOutput = p_wiki_xhtml($ID . "/" . $menu, '', false);
        $currID = $ID;
        $menuID = $currID . ":" . $menu;
    } else {
        if (file_exists(wikiFN($sub . "/" . $menu))) {
            $menuOutput = p_wiki_xhtml($sub . "/" . $menu, '', false);
            $currID = $sub;
            $menuID = $currID . ":" . $menu;
        }
    }
    if ($INFO['perm'] > AUTH_READ && true == $edit) {
        $menuOutput = '<ul><li><a href="?id=' . $menuID . '&amp;do=edit" class="wikilink1" title="Edit Menu"><b>Edit Menu</b></a></li></ul>';
    }
    $ID = $svID;
    $REV = $svREV;
    return $menuOutput;
}
Example #5
0
 public function test_basic_weekpicker_syntax()
 {
     global $INFO;
     $id = 'test:plugin_datepicker:syntax4';
     $INFO['id'] = $id;
     saveWikiText($id, '<weekpicker 14/02>' . DOKU_LF . '<weekpicker# 14/02>' . DOKU_LF . '<weekpicker\\ 14/02>' . DOKU_LF, 'test');
     $xhtml = p_wiki_xhtml($id);
     $doc = phpQuery::newDocument($xhtml);
     $mselector = pq("span.weekpicker", $doc);
     $this->assertTrue($mselector->length === 3);
     $this->assertEquals('14/02', trim($mselector->eq(0)->text()));
     $this->assertEquals('14/02', trim($mselector->eq(1)->text()));
     $this->assertEquals('14/02', trim($mselector->eq(2)->text()));
 }
 function _show404(&$event, $param)
 {
     global $ACT;
     if ($ACT != 'notfound') {
         return false;
     }
     $event->stopPropagation();
     $event->preventDefault();
     global $ID;
     $oldid = $ID;
     $ID = $this->getConf('404page');
     echo p_wiki_xhtml($ID, '', false);
     $ID = $oldid;
     $ACT = 'show';
     return true;
 }
Example #7
0
    function print_overlay(&$event, $param)
    {
        global $ID;
        $overlay = '';
        $paths = $this->getConf('nsoverlays');
        $namespace = getNS($ID);
        $sort_paths = $this->_natsort_ns($paths);
        $sort_paths = explode(',', $sort_paths);
        $overlays = $this->_get_overlays($sort_paths);
        $parent_ns = $this->_get_parent_ns($namespace);
        foreach ($overlays as $key => $val) {
            // first check if was specified an overlay for a specific namespace
            if ($val[1] != '') {
                if ($val[1] == ':') {
                    $overlay = $overlays[$key][0];
                } elseif (strpos($namespace, $val[1]) === 0) {
                    $overlay = $overlays[$key][0];
                    break;
                }
            } else {
                if ($overlay == '') {
                    if ('' == $val[1]) {
                        foreach ($parent_ns as $ns) {
                            $wikifile = wikiFN($ns . ':' . $val[0]);
                            if (file_exists($wikifile)) {
                                $overlay = str_replace('/', ':', $ns) . ':' . $val[0];
                                break 2;
                            }
                        }
                    }
                }
            }
        }
        if (auth_quickaclcheck($ID) >= AUTH_READ) {
            $insert = p_wiki_xhtml($overlay);
        }
        if (!$insert) {
            return;
        }
        $close = trim($this->getLang('close'));
        $text = <<<TEXT
<div id='overlay'><div  class = "close">
<a href="javascript:jQuery('#overlay').toggle();void(0);" rel="nofollow" title="{$close}">{$close}</a>
</div> {$insert}</div>
TEXT;
        echo $text;
    }
 function test_topic_tag()
 {
     saveWikiText('tagged_page', '{{tag>mytag test2tag}}', 'Test');
     saveWikiText('topic_page', '{{topic>mytag}}' . DOKU_LF . DOKU_LF . '{{tag>topictag mytag}}' . DOKU_LF, 'Test');
     idx_addPage('topic_page');
     idx_addPage('tagged_page');
     $this->assertContains('tag:topictag', p_wiki_xhtml('topic_page'), 'Page with tag syntax doesn\'t contain tag output');
     $this->assertNotContains('tag:test2tag', p_wiki_xhtml('topic_page'), 'Page with tag and topic syntax tag which is listed in a page that is listed in the topic syntax but not on the page itself');
     $this->assertContains('topic_page', p_wiki_xhtml('topic_page'), 'Page with topic and tag syntax doesn\'t list itself in the topic syntax');
     $this->assertContains('tagged_page', p_wiki_xhtml('topic_page'), 'Page with topic syntax doesn\'t list matching page');
     $this->assertContains('tag:mytag', p_wiki_xhtml('tagged_page'), 'Page with tag syntax doesn\'t contain tag output');
     $this->assertContains('tag:test2tag', p_wiki_xhtml('tagged_page'), 'Page with tag syntax doesn\'t contain tag output');
     $this->assertNotContains('tag:topictag', p_wiki_xhtml('tagged_page'), 'Page with tag syntax contains tag from a page in which it is listed in the topic syntax');
     saveWikiText('tagged_page', '{{tag>test2tag}}', 'Deleted mytag');
     $this->assertNotContains('tagged_page', p_wiki_xhtml('topic_page'), 'Page that no longer contains the tag is still listed in the topic syntax (caching problems?)');
     $this->assertNotContains('tag:mytag', p_wiki_xhtml('tagged_page'), 'Removed tag is still listed in XHTML output');
 }
Example #9
0
/**
 * Renders the topbar
 *
 * @author Michael Klier <*****@*****.**>
 * @author Louis Wolf <*****@*****.**>
 */
function tpl_topbar()
{
    global $ID;
    $found = false;
    $tbar = '';
    $path = explode(':', $ID);
    while (!$found && count($path) >= 0) {
        $tbar = implode(':', $path) . ':' . 'topbar';
        $found = @file_exists(wikiFN($tbar));
        array_pop($path);
        // check if nothing was found
        if (!$found && $tbar == ':topbar') {
            return;
        }
    }
    if ($found && auth_quickaclcheck($tbar) >= AUTH_READ) {
        $toolbar = p_wiki_xhtml($tbar, '', false);
        $lines = explode("\n", $toolbar);
        $nr = count($lines);
        $open_ul = 0;
        $primary_ul = 0;
        $positions = array();
        for ($i = 0; $i < $nr; $i++) {
            if (trim($lines[$i]) == '<ul>') {
                $open_ul = $open_ul + 1;
                if ($open_ul == 1) {
                    $primary_ul++;
                    $lines[$i] = '<ul class="primary">' . "\n";
                    array_push($positions, $i);
                }
            } else {
                if (strpos($lines[$i], '</ul>') !== false) {
                    $open_ul = $open_ul - 1;
                }
            }
        }
        $first_position = $positions[0];
        $last_position = $positions[count($positions) - 1];
        $lines[$first_position] = '<ul class="primary start">' . "\n";
        $lines[$last_position] = '<ul class="primary end">' . "\n";
        $width = $primary_ul * 150;
        print '<div id="tpl_simple_navi" style="width:' . $width . 'px;">';
        print implode($lines);
        print '</div>';
    }
}
Example #10
0
/**
 * Includes the rendered HTML of a given page
 *
 * This function is useful to populate sidebars or similar features in a
 * template
 */
function template_tpl_include_page($pageid, $print = true, $propagate = false, $rev = '')
{
    if (!$pageid) {
        return false;
    }
    if ($propagate) {
        $pageid = page_findnearest($pageid);
    }
    global $TOC;
    $oldtoc = $TOC;
    $html = p_wiki_xhtml($pageid, $rev, false);
    $TOC = $oldtoc;
    if (!$print) {
        return $html;
    }
    echo $html;
    return $html;
}
/**
 * Prints the navigation
 *
 * @author Michael Klier <*****@*****.**>
 */
function tpl_navigation()
{
    global $ID;
    global $conf;
    $navpage = tpl_getConf('navigation_page');
    print '<div class="navigation">' . DOKU_LF;
    if (!page_exists($navpage)) {
        if (@file_exists(DOKU_TPLINC . 'lang/' . $conf['lang'] . '/nonavigation.txt')) {
            $out = p_render('xhtml', p_get_instructions(io_readFile(DOKU_TPLINC . 'lang/' . $conf['lang'] . '/nonavigation.txt')), $info);
        } else {
            $out = p_render('xhtml', p_get_instructions(io_readFile(DOKU_TPLINC . 'lang/en/nonavigation.txt')), $info);
        }
        $link = '<a href="' . wl($navpage) . '" class="wikilink2">' . $navpage . '</a>' . DOKU_LF;
        print str_replace('LINK', $link, $out);
    } else {
        print p_wiki_xhtml($navpage);
    }
    print '</div>';
}
 /**
  * @group slow
  */
 function test_cache_handling()
 {
     $testid = 'wiki:bar:test';
     saveWikiText($testid, '[[wiki:foo:]]', 'Test setup');
     idx_addPage($testid);
     saveWikiText('wiki:foo:start', 'bar', 'Test setup');
     idx_addPage('wiki:foo:start');
     sleep(1);
     // wait in order to make sure that conditions with < give the right result.
     p_wiki_xhtml($testid);
     // populate cache
     $cache = new cache_renderer($testid, wikiFN($testid), 'xhtml');
     $this->assertTrue($cache->useCache());
     /** @var helper_plugin_move_op $move */
     $move = plugin_load('helper', 'move_op');
     $this->assertTrue($move->movePage('wiki:foo:start', 'wiki:foo2:start'));
     $cache = new cache_renderer($testid, wikiFN($testid), 'xhtml');
     $this->assertFalse($cache->useCache());
 }
 /**
  * Alters login page via HTML_LOGINFORM_OUTPUT event
  * @param $event
  * @param $param
  */
 public function alterLoginPageBefore($event, $param)
 {
     print '<div class="login container">' . NL;
     $helpId = $this->getConf(self::CONF_HELP_PAGE);
     global $conf;
     if (!empty($conf['lang'])) {
         $lang = $conf['lang'];
         if (!empty($conf['plugin']['translation']['translations']) && preg_match("/{$lang}/", $conf['plugin']['translation']['translations'])) {
             $helpId = ':' . $lang . $helpId;
         }
     }
     if (page_exists($helpId)) {
         print '<div class="login help">' . p_wiki_xhtml($helpId) . '</div>' . NL;
     }
     if (!empty($this->getConf(self::CONF_RENAME_LOCAL))) {
         /** @var Doku_Form $form */
         $form = $event->data;
         $form->_content[0]['_legend'] = $this->getLang('login_local');
     }
 }
Example #14
0
function renderBar($page, $fallbackToIndex = false)
{
    global $ID, $REV;
    // save globals
    $saveID = $ID;
    $saveREV = $REV;
    $fileSidebar = getBarFN(getNS($ID), $page);
    // determine what to display
    if ($fileSidebar) {
        $ID = $fileSidebar;
        $REV = '';
        print p_wiki_xhtml($ID, $REV, false);
    } elseif ($fallbackToIndex) {
        global $IDX;
        html_index($IDX);
    }
    // restore globals
    $ID = $saveID;
    $REV = $saveREV;
}
function tpl_sidebar()
{
    global $ID, $REV, $conf;
    // save globals
    $saveID = $ID;
    $saveREV = $REV;
    // discover file to be displayed in navigation sidebar
    $fileSidebar = '';
    $sidebar_name = tpl_getConf('btl_sidebar_name');
    if (isset($sidebar_name)) {
        $fileSidebar = getSidebarFN(getNS($ID), $sidebar_name);
    }
    // determine what to display
    if ($fileSidebar) {
        $ID = $fileSidebar;
        $REV = '';
        $sidebar = p_wiki_xhtml($ID, $REV, false);
        $lines = explode("\n", $sidebar);
        $open_ul = 0;
        for ($i = 0; $i < count($lines); $i++) {
            if (trim($lines[$i]) == '<ul>') {
                $open_ul = $open_ul + 1;
                if ($open_ul == 1) {
                    $lines[$i] = '<ul class="primary">' . "\n";
                }
            } else {
                if (strpos($lines[$i], '</ul>') != false) {
                    $open_ul = $open_ul - 1;
                }
            }
        }
        print implode($lines);
    } else {
        global $IDX;
        html_index($IDX);
    }
    // restore globals
    $ID = $saveID;
    $REV = $saveREV;
}
/**
 * Displays the menu2 
 *
 */
function tpl_menu2()
{
    global $conf, $ID, $REV, $INFO, $lang;
    $currID = false;
    if ($conf['tpl_mmClean']['menu2Permanent']) {
        $path = "";
    } else {
        if (false != strpos($ID, ":")) {
            $path = substr($ID, 0, strpos($ID, ":"));
        } else {
            $path = $ID;
        }
        $path .= ":";
    }
    print "<h1>";
    print tpl_pagetitle();
    print "</h1>";
    print p_wiki_xhtml($path . "menu2", '', false);
    if ($INFO['perm'] > AUTH_READ) {
        print '<ul><li><a href="?id=' . $path . 'menu2&amp;do=edit" class="wikilink1" title="Edit"><b>Edit</b></a></li></ul>';
    }
}
Example #17
0
 /**
  * Handles the AJAX calls
  *
  * @author Michael Klier <*****@*****.**>
  */
 function handle_ajax_call(&$event, $param)
 {
     global $lang;
     if ($event->data == 'snippet_preview' or $event->data == 'snippet_insert') {
         $event->preventDefault();
         $event->stopPropagation();
         $id = cleanID($_REQUEST['id']);
         if (page_exists($id)) {
             if ($event->data == 'snippet_preview') {
                 if (auth_quickaclcheck($id) >= AUTH_READ) {
                     print p_wiki_xhtml($id);
                 } else {
                     print p_locale_xhtml('denied');
                 }
             } elseif ($event->data == 'snippet_insert') {
                 if (auth_quickaclcheck($id) >= AUTH_READ) {
                     print "\n\n";
                     // always start on a new line (just to be safe)
                     print trim(preg_replace('/<snippet>.*?<\\/snippet>/s', '', io_readFile(wikiFN($id))));
                 }
             }
         }
     }
 }
/**
 * Removes the TOC of the sidebar pages and 
 * shows a edit button if the user has enough rights
 *
 * TODO sidebar caching
 * 
 * @author Michael Klier <*****@*****.**>
 */
function p_sidebar_xhtml($sb, $pos, $subst = array())
{
    $data = p_wiki_xhtml($sb, '', false);
    if (!empty($subst)) {
        $data = preg_replace($subst['pattern'], $subst['replace'], $data);
    }
    if (auth_quickaclcheck($sb) >= AUTH_EDIT) {
        $data .= '<div class="secedit">' . html_btn('secedit', $sb, '', array('do' => 'edit', 'rev' => '', 'post')) . '</div>';
    }
    // strip TOC
    $data = preg_replace('/<div class="toc">.*?(<\\/div>\\n<\\/div>)/s', '', $data);
    // replace headline ids for XHTML compliance
    $data = preg_replace('/(<h.*?><a.*?name=")(.*?)(".*?id=")(.*?)(">.*?<\\/a><\\/h.*?>)/', '\\1sb_' . $pos . '_\\2\\3sb_' . $pos . '_\\4\\5', $data);
    return $data;
}
Example #19
0
/**
 * Show a wiki page
 *
 * @author Andreas Gohr <*****@*****.**>
 *
 * @param null|string $txt wiki text or null for showing $ID
 */
function html_show($txt = null)
{
    global $ID;
    global $REV;
    global $HIGH;
    global $INFO;
    global $DATE_AT;
    //disable section editing for old revisions or in preview
    if ($txt || $REV) {
        $secedit = false;
    } else {
        $secedit = true;
    }
    if (!is_null($txt)) {
        //PreviewHeader
        echo '<br id="scroll__here" />';
        echo p_locale_xhtml('preview');
        echo '<div class="preview"><div class="pad">';
        $html = html_secedit(p_render('xhtml', p_get_instructions($txt), $info), $secedit);
        if ($INFO['prependTOC']) {
            $html = tpl_toc(true) . $html;
        }
        echo $html;
        echo '<div class="clearer"></div>';
        echo '</div></div>';
    } else {
        if ($REV || $DATE_AT) {
            $data = array('rev' => &$REV, 'date_at' => &$DATE_AT);
            trigger_event('HTML_SHOWREV_OUTPUT', $data, 'html_showrev');
        }
        $html = p_wiki_xhtml($ID, $REV, true, $DATE_AT);
        $html = html_secedit($html, $secedit);
        if ($INFO['prependTOC']) {
            $html = tpl_toc(true) . $html;
        }
        $html = html_hilight($html, $HIGH);
        echo $html;
    }
}
Example #20
0
 /**
  * Return a wiki page rendered to html
  */
 function htmlPage($id, $rev = '')
 {
     $id = $this->resolvePageId($id);
     if (auth_quickaclcheck($id) < AUTH_READ) {
         throw new RemoteAccessDeniedException('You are not allowed to read this page', 111);
     }
     return p_wiki_xhtml($id, $rev, false);
 }
Example #21
0
/**
 * Add recent changed pages to a feed object
 *
 * @author Andreas Gohr <*****@*****.**>
 * @param  object $rss - the FeedCreator Object
 * @param  array $data - the items to add
 * @param  array $opt  - the feed options
 */
function rss_buildItems(&$rss, &$data, $opt)
{
    global $conf;
    global $lang;
    global $auth;
    $eventData = array('rss' => &$rss, 'data' => &$data, 'opt' => &$opt);
    $event = new Doku_Event('FEED_DATA_PROCESS', $eventData);
    if ($event->advise_before(false)) {
        foreach ($data as $ditem) {
            if (!is_array($ditem)) {
                // not an array? then only a list of IDs was given
                $ditem = array('id' => $ditem);
            }
            $item = new FeedItem();
            $id = $ditem['id'];
            $meta = p_get_metadata($id);
            // add date
            if ($ditem['date']) {
                $date = $ditem['date'];
            } elseif ($meta['date']['modified']) {
                $date = $meta['date']['modified'];
            } else {
                $date = @filemtime(wikiFN($id));
            }
            if ($date) {
                $item->date = date('r', $date);
            }
            // add title
            if ($conf['useheading'] && $meta['title']) {
                $item->title = $meta['title'];
            } else {
                $item->title = $ditem['id'];
            }
            if ($conf['rss_show_summary'] && !empty($ditem['sum'])) {
                $item->title .= ' - ' . strip_tags($ditem['sum']);
            }
            // add item link
            switch ($opt['link_to']) {
                case 'page':
                    $item->link = wl($id, 'rev=' . $date, true, '&');
                    break;
                case 'rev':
                    $item->link = wl($id, 'do=revisions&rev=' . $date, true, '&');
                    break;
                case 'current':
                    $item->link = wl($id, '', true, '&');
                    break;
                case 'diff':
                default:
                    $item->link = wl($id, 'rev=' . $date . '&do=diff', true, '&');
            }
            // add item content
            switch ($opt['item_content']) {
                case 'diff':
                case 'htmldiff':
                    require_once DOKU_INC . 'inc/DifferenceEngine.php';
                    $revs = getRevisions($id, 0, 1);
                    $rev = $revs[0];
                    if ($rev) {
                        $df = new Diff(explode("\n", htmlspecialchars(rawWiki($id, $rev))), explode("\n", htmlspecialchars(rawWiki($id, ''))));
                    } else {
                        $df = new Diff(array(''), explode("\n", htmlspecialchars(rawWiki($id, ''))));
                    }
                    if ($opt['item_content'] == 'htmldiff') {
                        $tdf = new TableDiffFormatter();
                        $content = '<table>';
                        $content .= '<tr><th colspan="2" width="50%">' . $rev . '</th>';
                        $content .= '<th colspan="2" width="50%">' . $lang['current'] . '</th></tr>';
                        $content .= $tdf->format($df);
                        $content .= '</table>';
                    } else {
                        $udf = new UnifiedDiffFormatter();
                        $content = "<pre>\n" . $udf->format($df) . "\n</pre>";
                    }
                    break;
                case 'html':
                    $content = p_wiki_xhtml($id, $date, false);
                    // no TOC in feeds
                    $content = preg_replace('/(<!-- TOC START -->).*(<!-- TOC END -->)/s', '', $content);
                    // make URLs work when canonical is not set, regexp instead of rerendering!
                    if (!$conf['canonical']) {
                        $base = preg_quote(DOKU_REL, '/');
                        $content = preg_replace('/(<a href|<img src)="(' . $base . ')/s', '$1="' . DOKU_URL, $content);
                    }
                    break;
                case 'abstract':
                default:
                    $content = $meta['description']['abstract'];
            }
            $item->description = $content;
            //FIXME a plugin hook here could be senseful
            // add user
            # FIXME should the user be pulled from metadata as well?
            $user = null;
            $user = @$ditem['user'];
            // the @ spares time repeating lookup
            $item->author = '';
            if ($user && $conf['useacl'] && $auth) {
                $userInfo = $auth->getUserData($user);
                $item->author = $userInfo['name'];
                if ($userInfo && !$opt['guardmail']) {
                    $item->authorEmail = $userInfo['mail'];
                } else {
                    //cannot obfuscate because some RSS readers may check validity
                    $item->authorEmail = $user . '@' . $ditem['ip'];
                }
            } elseif ($user) {
                // this happens when no ACL but some Apache auth is used
                $item->author = $user;
                $item->authorEmail = $user . '@' . $ditem['ip'];
            } else {
                $item->authorEmail = 'anonymous@' . $ditem['ip'];
            }
            // add category
            if ($meta['subject']) {
                $item->category = $meta['subject'];
            } else {
                $cat = getNS($id);
                if ($cat) {
                    $item->category = $cat;
                }
            }
            // finally add the item to the feed object, after handing it to registered plugins
            $evdata = array('item' => &$item, 'opt' => &$opt, 'ditem' => &$ditem, 'rss' => &$rss);
            $evt = new Doku_Event('FEED_ITEM_ADD', $evdata);
            if ($evt->advise_before()) {
                $rss->addItem($item);
            }
            $evt->advise_after();
            // for completeness
        }
    }
    $event->advise_after();
}
Example #22
0
/**
 * Removes the TOC of the sidebar pages and 
 * shows a edit button if the user has enough rights
 *
 */
function p_sidebar_xhtml($sb)
{
    global $conf;
    $tpl = $conf['template'];
    $data = p_wiki_xhtml($sb, '', false);
    if (auth_quickaclcheck($sb) >= AUTH_EDIT and tpl_getConf('sidebaredit')) {
        $data .= '<div class="secedit">' . html_btn('secedit', $sb, '', array('do' => 'edit', 'rev' => '', 'post')) . '</div>';
    }
    // strip TOC
    $data = preg_replace('/<div class="toc">.*?(<\\/div>\\n<\\/div>)/s', '', $data);
    // replace headline ids for XHTML compliance
    $data = preg_replace('/(<h.*?><a.*?id=")(.*?)(">.*?<\\/a><\\/h.*?>)/', '\\1sb_left_\\2\\3', $data);
    return $data;
}
Example #23
0
 /**
  * Return a wiki page rendered to html
  */
 function htmlPage($id, $rev = '')
 {
     $id = cleanID($id);
     if (auth_quickaclcheck($id) < AUTH_READ) {
         return new IXR_Error(1, 'You are not allowed to read this page');
     }
     return p_wiki_xhtml($id, $rev, false);
 }
Example #24
0
 /**
  * Render a defined page as index.
  *
  * @author Samuele Tognini <*****@*****.**>
  */
 function _loadindex(&$event, $param)
 {
     if ('index' != $event->data) {
         return;
     }
     if (!file_exists(wikiFN($this->getConf('page_index')))) {
         return;
     }
     global $lang;
     print '<h1><a id="index" name="index">' . $lang['btn_index'] . "</a></h1>\n";
     print p_wiki_xhtml($this->getConf('page_index'));
     $event->preventDefault();
     $event->stopPropagation();
 }
Example #25
0
/**
 * Includes the rendered XHTML of a given page
 *
 * This function is useful to populate sidebars or similar features in a
 * template
 */
function tpl_include_page($pageid, $print = true)
{
    global $ID;
    global $TOC;
    $oldid = $ID;
    $oldtoc = $TOC;
    $html = p_wiki_xhtml($pageid, '', false);
    $ID = $oldid;
    $TOC = $oldtoc;
    if (!$print) {
        return $html;
    }
    echo $html;
    return $html;
}
 public function testExternalMediaNotConverted()
 {
     $html = p_wiki_xhtml('test:include');
     $this->assertContains('src="' . ml('https://www.dokuwiki.org/lib/tpl/dokuwiki/images/logo.png') . '"', $html);
 }
function tpl_sidebar_content()
{
    global $ID, $REV, $conf;
    // save globals
    $saveID = $ID;
    $saveREV = $REV;
    // discover file to be displayed in navigation sidebar
    $fileSidebar = '';
    if (tpl_getConf('page')) {
        $fileSidebar = getSidebarFN(getNS($ID), tpl_getConf('page'));
    }
    // determine what to display
    if ($fileSidebar) {
        $ID = $fileSidebar;
        $REV = '';
        print p_wiki_xhtml($ID, $REV, false);
    } else {
        global $IDX;
        html_index($IDX);
    }
    // restore globals
    $ID = $saveID;
    $REV = $saveREV;
}
 public function testInterWikiLinkTitleConversion() {
     $html = p_wiki_xhtml('test:include');
     $this->assertContains('src="'.ml('wiki:dokuwiki.png', array('w' => '300')).'"', $html);
 }
Example #29
0
/**
 * show a wiki page
 *
 * @author Andreas Gohr <*****@*****.**>
 */
function html_show($txt = null)
{
    global $ID;
    global $REV;
    global $HIGH;
    global $INFO;
    //disable section editing for old revisions or in preview
    if ($txt || $REV) {
        $secedit = false;
    } else {
        $secedit = true;
    }
    if (!is_null($txt)) {
        //PreviewHeader
        echo '<br id="scroll__here" />';
        echo p_locale_xhtml('preview');
        echo '<div class="preview">';
        $html = html_secedit(p_render('xhtml', p_get_instructions($txt), $info), $secedit);
        if ($INFO['prependTOC']) {
            $html = tpl_toc(true) . $html;
        }
        echo $html;
        echo '<div class="clearer"></div>';
        echo '</div>';
    } else {
        if ($REV) {
            print p_locale_xhtml('showrev');
        }
        $html = p_wiki_xhtml($ID, $REV, true);
        $html = html_secedit($html, $secedit);
        if ($INFO['prependTOC']) {
            $html = tpl_toc(true) . $html;
        }
        $html = html_hilight($html, $HIGH);
        echo $html;
    }
}
Example #30
0
/**
 * Export a wiki page for various formats
 *
 * Triggers ACTION_EXPORT_POSTPROCESS
 *
 *  Event data:
 *    data['id']      -- page id
 *    data['mode']    -- requested export mode
 *    data['headers'] -- export headers
 *    data['output']  -- export output
 *
 * @author Andreas Gohr <*****@*****.**>
 * @author Michael Klier <*****@*****.**>
 */
function act_export($act)
{
    global $ID;
    global $REV;
    global $conf;
    global $lang;
    $pre = '';
    $post = '';
    $output = '';
    $headers = array();
    // search engines: never cache exported docs! (Google only currently)
    $headers['X-Robots-Tag'] = 'noindex';
    $mode = substr($act, 7);
    switch ($mode) {
        case 'raw':
            $headers['Content-Type'] = 'text/plain; charset=utf-8';
            $headers['Content-Disposition'] = 'attachment; filename=' . noNS($ID) . '.txt';
            $output = rawWiki($ID, $REV);
            break;
        case 'xhtml':
            $pre .= '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"' . DOKU_LF;
            $pre .= ' "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">' . DOKU_LF;
            $pre .= '<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="' . $conf['lang'] . '"' . DOKU_LF;
            $pre .= ' lang="' . $conf['lang'] . '" dir="' . $lang['direction'] . '">' . DOKU_LF;
            $pre .= '<head>' . DOKU_LF;
            $pre .= '  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />' . DOKU_LF;
            $pre .= '  <title>' . $ID . '</title>' . DOKU_LF;
            // get metaheaders
            ob_start();
            tpl_metaheaders();
            $pre .= ob_get_clean();
            $pre .= '</head>' . DOKU_LF;
            $pre .= '<body>' . DOKU_LF;
            $pre .= '<div class="dokuwiki export">' . DOKU_LF;
            // get toc
            $pre .= tpl_toc(true);
            $headers['Content-Type'] = 'text/html; charset=utf-8';
            $output = p_wiki_xhtml($ID, $REV, false);
            $post .= '</div>' . DOKU_LF;
            $post .= '</body>' . DOKU_LF;
            $post .= '</html>' . DOKU_LF;
            break;
        case 'xhtmlbody':
            $headers['Content-Type'] = 'text/html; charset=utf-8';
            $output = p_wiki_xhtml($ID, $REV, false);
            break;
        default:
            $output = p_cached_output(wikiFN($ID, $REV), $mode);
            $headers = p_get_metadata($ID, "format {$mode}");
            break;
    }
    // prepare event data
    $data = array();
    $data['id'] = $ID;
    $data['mode'] = $mode;
    $data['headers'] = $headers;
    $data['output'] =& $output;
    trigger_event('ACTION_EXPORT_POSTPROCESS', $data);
    if (!empty($data['output'])) {
        if (is_array($data['headers'])) {
            foreach ($data['headers'] as $key => $val) {
                header("{$key}: {$val}");
            }
        }
        print $pre . $data['output'] . $post;
        exit;
    }
    return 'show';
}