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; }
function p_render($mode, $instructions, &$info) { if (is_null($instructions)) { return ''; } // msg("Memory Usage p_render start: ". memory_get_usage(), -1); // require_once DOKU_INC."inc/parser/$mode.php"; $rclass = "Doku_Renderer_{$mode}"; if (!class_exists($rclass)) { trigger_error("Unable to resolve render class {$rclass}", E_USER_ERROR); } $Renderer =& new $rclass(); #FIXME any way to check for class existance? $Renderer->smileys = getSmileys(); $Renderer->entities = getEntities(); $Renderer->latexentities = $this->_texit_conf['latexentities']; $Renderer->acronyms = getAcronyms(); $Renderer->interwiki = getInterwiki(); $Renderer->info = $info; // Loop through the instructions foreach ($instructions as $instruction) { // Execute the callback against the Renderer call_user_func_array(array(&$Renderer, $instruction[0]), $instruction[1]); } //set info array $info = $Renderer->info; // msg("Memory Usage p_render end: ". memory_get_usage(), -1); // Return the output return $Renderer->doc; }
/** * Renders a list of instruction to the specified output mode * * In the $info array is information from the renderer returned * * @author Harry Fuecks <*****@*****.**> * @author Andreas Gohr <*****@*****.**> */ function p_render($mode, $instructions, &$info) { if (is_null($instructions)) { return ''; } $Renderer =& p_get_renderer($mode); if (is_null($Renderer)) { return null; } $Renderer->reset(); $Renderer->smileys = getSmileys(); $Renderer->entities = getEntities(); $Renderer->acronyms = getAcronyms(); $Renderer->interwiki = getInterwiki(); // Loop through the instructions foreach ($instructions as $instruction) { // Execute the callback against the Renderer call_user_func_array(array(&$Renderer, $instruction[0]), $instruction[1]); } //set info array $info = $Renderer->info; // Post process and return the output $data = array($mode, &$Renderer->doc); trigger_event('RENDERER_CONTENT_POSTPROCESS', $data); return $Renderer->doc; }
/** * Renders a list of instruction to the specified output mode * * In the $info array are informations from the renderer returned * * @author Harry Fuecks <*****@*****.**> * @author Andreas Gohr <*****@*****.**> */ function p_render($mode, $instructions, &$info) { if (is_null($instructions)) { return ''; } if ($mode == 'wiki') { msg("Renderer for {$mode} not valid", -1); return null; } //FIXME!! remove this line when inc/parser/wiki.php works. // Create the renderer if (!@file_exists(DOKU_INC . "inc/parser/{$mode}.php")) { msg("No renderer for {$mode} found", -1); return null; } require_once DOKU_INC . "inc/parser/{$mode}.php"; $rclass = "Doku_Renderer_{$mode}"; if (!class_exists($rclass)) { trigger_error("Unable to resolve render class {$rclass}", E_USER_WARNING); msg("Renderer for {$mode} not valid", -1); return null; } $Renderer = new $rclass(); #FIXME any way to check for class existance? $Renderer->smileys = getSmileys(); $Renderer->entities = getEntities(); $Renderer->acronyms = getAcronyms(); $Renderer->interwiki = getInterwiki(); #$Renderer->badwords = getBadWords(); // Loop through the instructions foreach ($instructions as $instruction) { // Execute the callback against the Renderer call_user_func_array(array(&$Renderer, $instruction[0]), $instruction[1]); } //set info array $info = $Renderer->info; // Post process and return the output $data = array($mode, &$Renderer->doc); trigger_event('RENDERER_CONTENT_POSTPROCESS', $data); return $Renderer->doc; }
function render($mode, &$renderer, $data) { list($ns, $num, $flags, $refine) = $data; $first = $_REQUEST['first']; if (!is_numeric($first)) { $first = 0; } // get the blog entries for our namespace if ($my =& plugin_load('helper', 'blog')) { $entries = $my->getBlog($ns); } // use tag refinements? if ($refine) { if (plugin_isdisabled('tag') || !($tag =& plugin_load('helper', 'tag'))) { msg($this->getLang('missing_tagplugin'), -1); } else { $entries = $tag->tagRefine($entries, $refine); } } // any create form overrides? $formpos = $this->getConf('formposition'); if (in_array('topform', $flags)) { $formpos = 'top'; } elseif (in_array('bottomform', $flags)) { $formpos = 'bottom'; } elseif (in_array('noform', $flags)) { $formpos = 'none'; } if (!$entries) { if (auth_quickaclcheck($ns . ':*') >= AUTH_CREATE && $mode == 'xhtml') { $renderer->info['cache'] = false; if ($formpos != 'none') { $renderer->doc .= $this->_newEntryForm($ns); } } return true; // nothing to display } // slice the needed chunk of pages $more = count($entries) > $first + $num ? true : false; $entries = array_slice($entries, $first, $num); // load the include helper plugin if (plugin_isdisabled('include') || !($include =& plugin_load('helper', 'include'))) { msg($this->getLang('missing_includeplugin'), -1); return false; } if ($mode == 'xhtml') { // prevent caching to ensure the included pages are always fresh $renderer->info['cache'] = false; // show new entry form $perm_create = auth_quickaclcheck($ns . ':*') >= AUTH_CREATE; if ($perm_create && $formpos == 'top') { $renderer->doc .= $this->_newEntryForm($ns); } // current section level $clevel = 0; preg_match_all('|<div class="level(\\d)">|i', $renderer->doc, $matches, PREG_SET_ORDER); $n = count($matches) - 1; if ($n > -1) { $clevel = $matches[$n][1]; } // close current section if ($clevel) { $renderer->doc .= '</div>' . DOKU_LF; } $renderer->doc .= '<div class="hfeed">' . DOKU_LF; } // we need our own renderer $include_renderer =& p_get_renderer('xhtml'); $include_renderer->smileys = getSmileys(); $include_renderer->entities = getEntities(); $include_renderer->acronyms = getAcronyms(); $include_renderer->interwiki = getInterwiki(); // now include the blog entries foreach ($entries as $entry) { if ($mode == 'xhtml') { if (auth_quickaclcheck($entry['id']) >= AUTH_READ) { $renderer->doc .= $this->render_XHTML($include, $include_renderer, $entry['id'], $clevel, $flags); } } elseif ($mode == 'metadata') { $renderer->meta['relation']['haspart'][$entry['id']] = true; } } if ($mode == 'xhtml') { // resume the section $renderer->doc .= '</div>' . DOKU_LF; if ($clevel) { $renderer->doc .= '<div class="level' . $clevel . '">' . DOKU_LF; } // BEGIN MODIFIED by harukasan if (!in_array('nofollowlink', $flags)) { // show older / newer entries links $renderer->doc .= $this->_browseEntriesLinks($more, $first, $num); } // END MODIFIED // show new entry form if ($perm_create && $formpos == 'bottom') { $renderer->doc .= $this->_newEntryForm($ns); } } return true; }
function parsed($string) { require_once DOKU_INC . 'inc/parser/xhtml.php'; require_once DOKU_INC . 'inc/parser/parser.php'; $Parser =& new Doku_Parser(); $Parser->Handler =& new Doku_Handler(); $Parser->addMode('listblock', new Doku_Parser_Mode_ListBlock()); $Parser->addMode('preformatted', new Doku_Parser_Mode_Preformatted()); $Parser->addMode('notoc', new Doku_Parser_Mode_NoToc()); $Parser->addMode('header', new Doku_Parser_Mode_Header()); $Parser->addMode('table', new Doku_Parser_Mode_Table()); $Parser->addMode('linebreak', new Doku_Parser_Mode_Linebreak()); $Parser->addMode('footnote', new Doku_Parser_Mode_Footnote()); $Parser->addMode('hr', new Doku_Parser_Mode_HR()); $Parser->addMode('unformatted', new Doku_Parser_Mode_Unformatted()); $Parser->addMode('php', new Doku_Parser_Mode_PHP()); $Parser->addMode('html', new Doku_Parser_Mode_HTML()); $Parser->addMode('code', new Doku_Parser_Mode_Code()); $Parser->addMode('file', new Doku_Parser_Mode_File()); $Parser->addMode('quote', new Doku_Parser_Mode_Quote()); $Parser->addMode('acronym', new Doku_Parser_Mode_Acronym(array_keys(getAcronyms()))); $Parser->addMode('multiplyentity', new Doku_Parser_Mode_MultiplyEntity()); $Parser->addMode('quotes', new Doku_Parser_Mode_Quotes()); $Parser->addMode('camelcaselink', new Doku_Parser_Mode_CamelCaseLink()); $Parser->addMode('internallink', new Doku_Parser_Mode_InternalLink()); $Parser->addMode('media', new Doku_Parser_Mode_Media()); $Parser->addMode('externallink', new Doku_Parser_Mode_ExternalLink()); $Parser->addMode('windowssharelink', new Doku_Parser_Mode_WindowsShareLink()); $Parser->addMode('filelink', new Doku_Parser_Mode_FileLink()); $Parser->addMode('eol', new Doku_Parser_Mode_Eol()); $formats = array('strong', 'emphasis', 'underline', 'monospace', 'subscript', 'superscript', 'deleted'); foreach ($formats as $format) { $Parser->addMode($format, new Doku_Parser_Mode_Formatting($format)); } $instructions = $Parser->parse($string); // Get a list of instructions $Renderer =& new Doku_Renderer_XHTML(); // Create a renderer // Loop through the instructions foreach ($instructions as $instruction) { call_user_func_array(array(&$Renderer, $instruction[0]), $instruction[1]); } return trim(substr($Renderer->doc, 4, -5)); }