static function render($text, $type = null, $id = null, $instructions = null)
 {
     global $conf, $baseurl, $db;
     // Unfortunately dokuwiki also uses $conf
     $fs_conf = $conf;
     $conf = array();
     // Dokuwiki generates some notices
     error_reporting(E_ALL ^ E_NOTICE);
     if (!$instructions) {
         include_once BASEDIR . '/plugins/dokuwiki/inc/parser/parser.php';
     }
     require_once BASEDIR . '/plugins/dokuwiki/inc/common.php';
     require_once BASEDIR . '/plugins/dokuwiki/inc/parser/xhtml.php';
     // Create a renderer
     $Renderer = new Doku_Renderer_XHTML();
     if (!is_string($instructions) || strlen($instructions) < 1) {
         $modes = p_get_parsermodes();
         $Parser = new Doku_Parser();
         // Add the Handler
         $Parser->Handler = new Doku_Handler();
         // Add modes to parser
         foreach ($modes as $mode) {
             $Parser->addMode($mode['mode'], $mode['obj']);
         }
         $instructions = $Parser->parse($text);
         // Cache the parsed text
         if (!is_null($type) && !is_null($id)) {
             $fields = array('content' => serialize($instructions), 'type' => $type, 'topic' => $id, 'last_updated' => time());
             $keys = array('type', 'topic');
             //autoquote is always true on db class
             $db->Replace('{cache}', $fields, $keys);
         }
     } else {
         $instructions = unserialize($instructions);
     }
     $Renderer->smileys = getSmileys();
     $Renderer->entities = getEntities();
     $Renderer->acronyms = getAcronyms();
     $Renderer->interwiki = getInterwiki();
     $conf = $fs_conf;
     $conf['cachedir'] = FS_CACHE_DIR;
     // for dokuwiki
     $conf['fperm'] = 0600;
     $conf['dperm'] = 0700;
     // Loop through the instructions
     foreach ($instructions as $instruction) {
         // Execute the callback against the Renderer
         call_user_func_array(array(&$Renderer, $instruction[0]), $instruction[1]);
     }
     $return = $Renderer->doc;
     // Display the output
     if (Get::val('histring')) {
         $words = explode(' ', Get::val('histring'));
         foreach ($words as $word) {
             $return = html_hilight($return, $word);
         }
     }
     return $return;
 }
示例#2
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;
    }
}
示例#3
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;
    }
}
示例#4
0
 function _print_comment($cid, &$data, $parent, $reply, $visible, $hidden)
 {
     global $conf, $lang, $ID, $HIGH;
     $comment = $data['comments'][$cid];
     // comment head with date and user data
     ptln('<div class="hentry' . $hidden . '">', 4);
     ptln('<div class="comment_head">', 6);
     ptln('<a name="comment_' . $cid . '" id="comment_' . $cid . '"></a>', 8);
     $head = '<span class="vcard author">';
     // prepare variables
     if (is_array($comment['user'])) {
         // new format
         $user = $comment['user']['id'];
         $name = $comment['user']['name'];
         $mail = $comment['user']['mail'];
         $url = $comment['user']['url'];
         $address = $comment['user']['address'];
     } else {
         // old format
         $user = $comment['user'];
         $name = $comment['name'];
         $mail = $comment['mail'];
         $url = $comment['url'];
         $address = $comment['address'];
     }
     if (is_array($comment['date'])) {
         // new format
         $created = $comment['date']['created'];
         $modified = $comment['date']['modified'];
     } else {
         // old format
         $created = $comment['date'];
         $modified = $comment['edited'];
     }
     // show username or real name?
     if (!$this->getConf('userealname') && $user) {
         $showname = $user;
     } else {
         $showname = $name;
     }
     // show avatar image?
     if ($this->_use_avatar()) {
         $user_data['name'] = $name;
         $user_data['user'] = $user;
         $user_data['mail'] = $mail;
         $avatar = $this->avatar->getXHTML($user_data, $name, 'left');
         if ($avatar) {
             $head .= $avatar;
         }
     }
     if ($this->getConf('linkemail') && $mail) {
         $head .= $this->email($mail, $showname, 'email fn');
     } elseif ($url) {
         $head .= $this->external_link($this->_checkURL($url), $showname, 'urlextern url fn');
     } else {
         $head .= '<span class="fn">' . $showname . '</span>';
     }
     if ($address) {
         $head .= ', <span class="adr">' . $address . '</span>';
     }
     $head .= '</span>, ' . '<abbr class="published" title="' . strftime('%Y-%m-%dT%H:%M:%SZ', $created) . '">' . dformat($created, $conf['dformat']) . '</abbr>';
     if ($comment['edited']) {
         $head .= ' (<abbr class="updated" title="' . strftime('%Y-%m-%dT%H:%M:%SZ', $modified) . '">' . dformat($modified, $conf['dformat']) . '</abbr>)';
     }
     ptln($head, 8);
     ptln('</div>', 6);
     // class="comment_head"
     // main comment content
     ptln('<div class="comment_body entry-content"' . ($this->getConf('useavatar') ? $this->_get_style() : '') . '>', 6);
     echo ($HIGH ? html_hilight($comment['xhtml'], $HIGH) : $comment['xhtml']) . DOKU_LF;
     ptln('</div>', 6);
     // class="comment_body"
     if ($visible) {
         ptln('<div class="comment_buttons">', 6);
         // show reply button?
         if ($data['status'] == 1 && !$reply && $comment['show'] && ($this->getConf('allowguests') || $_SERVER['REMOTE_USER']) && $this->getConf('usethreading')) {
             $this->_button($cid, $this->getLang('btn_reply'), 'reply', true);
         }
         // show edit, show/hide and delete button?
         if ($user == $_SERVER['REMOTE_USER'] && $user != '' || auth_ismanager()) {
             $this->_button($cid, $lang['btn_secedit'], 'edit', true);
             $label = $comment['show'] ? $this->getLang('btn_hide') : $this->getLang('btn_show');
             $this->_button($cid, $label, 'toogle');
             $this->_button($cid, $lang['btn_delete'], 'delete');
         }
         ptln('</div>', 6);
         // class="comment_buttons"
     }
     ptln('</div>', 4);
     // class="hentry"
 }
示例#5
0
 function testMBboth()
 {
     $html = 'foo ДокуВики bar';
     $this->assertRegExp('/foo До<span.*>куВи<\\/span>ки bar/', html_hilight($html, '*куВи*'));
 }
 function testRegexInjectionSlash()
 {
     $html = 'Foo bar Foo';
     $this->assertPattern('/Foo bar Foo/', html_hilight($html, 'x/'));
 }
示例#7
0
/**
 * show a wiki page
 *
 * @author Andreas Gohr <*****@*****.**>
 */
function html_show($txt = '')
{
    global $ID;
    global $REV;
    global $HIGH;
    //disable section editing for old revisions or in preview
    if ($txt || $REV) {
        $secedit = false;
    } else {
        $secedit = true;
    }
    if ($txt) {
        //PreviewHeader
        print '<br id="scroll__here" />';
        print p_locale_xhtml('preview');
        print '<div class="preview">';
        print html_secedit(p_render('xhtml', p_get_instructions($txt), $info), $secedit);
        print '<div class="clearer"></div>';
        print '</div>';
    } else {
        if ($REV) {
            print p_locale_xhtml('showrev');
        }
        $html = p_wiki_xhtml($ID, $REV, true);
        $html = html_secedit($html, $secedit);
        print html_hilight($html, $HIGH);
    }
}