public function test_localparse() { $source = '{{just:some.svg?400x500 |test}}'; $parser_response = p_get_instructions($source); $calls = array(array('document_start', array()), array('p_open', array()), array('plugin', array('svgpureinsert', array('id' => 'just:some.svg', 'title' => 'test', 'align' => 'left', 'width' => 400, 'height' => 500, 'cache' => 'cache'), 5, $source)), array('cdata', array(null)), array('p_close', array()), array('document_end', array())); $this->assertEquals($calls, array_map('stripbyteindex', $parser_response)); }
function testVideoOGVInternal() { $file = 'wiki:kind_zu_katze.ogv'; $parser_response = p_get_instructions('{{' . $file . '}}'); $calls = array(array('document_start', array()), array('p_open', array()), array('internalmedia', array($file, null, null, null, null, 'cache', 'details')), array('cdata', array(null)), array('p_close', array()), array('document_end', array())); $this->assertEquals(array_map('stripbyteindex', $parser_response), $calls); $Renderer = new Doku_Renderer_xhtml(); $url = $Renderer->externalmedia($file, null, null, null, null, 'cache', 'details', true); $video = '<video class="media" width="320" height="240" controls="controls" poster="' . DOKU_BASE . 'lib/exe/fetch.php?media=wiki:kind_zu_katze.png">'; $substr_start = 0; $substr_len = strlen($video); $this->assertEquals($video, substr($url, $substr_start, $substr_len)); // find $source_webm in $url $source_webm = '<source src="' . DOKU_BASE . 'lib/exe/fetch.php?media=wiki:kind_zu_katze.webm" type="video/webm" />'; $substr_start = strpos($url, $source_webm, $substr_start + $substr_len); $this->assertNotSame(false, $substr_start, 'Substring not found.'); // find $source_ogv in $url $source_ogv = '<source src="' . DOKU_BASE . 'lib/exe/fetch.php?media=wiki:kind_zu_katze.ogv" type="video/ogg" />'; $substr_start = strpos($url, $source_ogv, $substr_start + strlen($source_webm)); $this->assertNotSame(false, $substr_start, 'Substring not found.'); // find $a_webm in $url $a_webm = '<a href="' . DOKU_BASE . 'lib/exe/fetch.php?id=&cache=&media=wiki:kind_zu_katze.webm" class="media mediafile mf_webm" title="wiki:kind_zu_katze.webm (99.1 KB)">kind_zu_katze.webm</a>'; $substr_start = strpos($url, $a_webm, $substr_start + strlen($source_ogv)); $this->assertNotSame(false, $substr_start, 'Substring not found.'); // find $a_webm in $url $a_ogv = '<a href="' . DOKU_BASE . 'lib/exe/fetch.php?id=&cache=&media=wiki:kind_zu_katze.ogv" class="media mediafile mf_ogv" title="wiki:kind_zu_katze.ogv (44.8 KB)">kind_zu_katze.ogv</a>'; $substr_start = strpos($url, $a_ogv, $substr_start + strlen($a_webm)); $this->assertNotSame(false, $substr_start, 'Substring not found.'); $rest = '</video>' . "\n"; $substr_start = strlen($url) - strlen($rest); $this->assertEquals($rest, substr($url, $substr_start)); }
function render($mode, Doku_Renderer $renderer, $data) { if (empty($data)) { return false; } if ($mode == 'xhtml') { /** @var Doku_Renderer_xhtml $renderer */ list($state, $content, $classes, $attributes) = $data; switch ($state) { case DOKU_LEXER_ENTER: $location = $attributes['location'] ? $attributes['location'] : 'top'; $title = $attributes['title'] ? $attributes['title'] : null; $markup = sprintf('<span data-toggle="tooltip" data-html="true" data-placement="%s" title="%s" style="border-bottom:1px dotted">', $location, $title); $renderer->doc .= $markup; return true; case DOKU_LEXER_UNMATCHED: $renderer->doc .= sprintf($this->template_content, str_replace(array('<p>', '</p>'), '', p_render("xhtml", p_get_instructions($content), $info))); return true; case DOKU_LEXER_EXIT: $renderer->doc .= '</span>'; return true; } return true; } return false; }
/** * This function renders $content using the ODT-page-renderer. * It then unzips the ODT document and reads in the file contents * of the files 'content.xml', 'meta.xml' and 'styles.xml' and * saves the strings in $files ['content-xml'], $files ['meta-xml'] * and $files ['styles-xml']. * * @param array $files * @param string $content * @return boolean */ public static function getRenderedODTDocument(array &$files, $content) { // Create parser instructions for wiki page $content $instructions = p_get_instructions($content); // Render the page by looping through the instructions. $renderer = new renderer_plugin_odt_page(); foreach ($instructions as $instruction) { // Execute the callback against the Renderer if (method_exists($renderer, $instruction[0])) { call_user_func_array(array(&$renderer, $instruction[0]), $instruction[1] ? $instruction[1] : array()); } } io_savefile(TMP_DIR . '/odt/temp_test_doc.odt', $renderer->doc); $ZIP = new ZipLib(); $ok = $ZIP->Extract(TMP_DIR . '/odt/temp_test_doc.odt', TMP_DIR . '/odt/unpacked'); if ($ok == -1) { // Error unzipping document return false; } $files['content-xml'] = file_get_contents(TMP_DIR . '/odt/unpacked/content.xml'); $files['meta-xml'] = file_get_contents(TMP_DIR . '/odt/unpacked/meta.xml'); $files['styles-xml'] = file_get_contents(TMP_DIR . '/odt/unpacked/styles.xml'); // Success return true; }
/** * Create output */ public function render($format, Doku_Renderer $renderer, $indata) { if (empty($indata)) { return false; } list($state, $data) = $indata; if ($format != 'xhtml') { return false; } switch ($state) { case DOKU_LEXER_ENTER: list($class, $title) = $data; if ($title) { //$html = '<div class="plugin_codeprettify">'.hsc($title).'</div>'; $html = p_render($format, p_get_instructions($title), $info); $html = '<div class="plugin_codeprettify">' . $html . '</div>'; $renderer->doc .= $html; } $class = implode(' ', $class); $renderer->doc .= '<pre class="' . $class . '">'; break; case DOKU_LEXER_UNMATCHED: $renderer->doc .= $renderer->_xmlEntities($data); break; case DOKU_LEXER_EXIT: $renderer->doc .= '</pre>'; break; } return true; }
function render($mode, Doku_Renderer $renderer, $data) { if (empty($data)) { return false; } if ($mode == 'xhtml') { /** @var Doku_Renderer_xhtml $renderer */ list($state, $content, $classes, $attributes) = $data; switch ($state) { case DOKU_LEXER_ENTER: $type = $attributes['type'] ? $attributes['type'] : 'info'; $icon = $attributes['icon'] ? $attributes['icon'] : null; $markup = sprintf('<div class="label label-%s">', $type); if ($icon) { $markup .= sprintf('<i class="%s"></i> ', $icon); } $renderer->doc .= $markup; return true; case DOKU_LEXER_UNMATCHED: $renderer->doc .= sprintf($this->template_content, str_replace(array('<p>', '</p>'), '', p_render("xhtml", p_get_instructions($content), $info))); return true; case DOKU_LEXER_EXIT: $renderer->doc .= '</div>'; return true; } return true; } return false; }
/** * @param int|string $value * @param \Doku_Renderer $R * @param string $mode * @return bool */ public function renderValue($value, \Doku_Renderer $R, $mode) { $doc = p_render($mode, p_get_instructions($value), $info); $R->doc .= $doc; // FIXME this probably does not work for all renderers return true; }
/** * Handle matches of the articlelinks syntax * * @param string $match The match of the syntax * @param int $state The state of the handler * @param int $pos The position in the document * @param Doku_Handler $handler The handler * @return array Data for the renderer */ public function handle($match, $state, $pos, Doku_Handler $handler) { $data = array(); $type = substr($match, 1, strpos($match, '>') - 1); switch ($type) { case 'relatedarticles': $links = $this->getLang('related articles'); $endtag = '</article>'; break; case 'relatedarticle': $links = $this->getLang('related article'); $endtag = '</article>'; break; case 'mainarticle': $links = $this->getLang('main article'); $endtag = '</article>'; break; case 'relatedsection': $links = $this->getLang('related section'); $endtag = '</section>'; break; default: $links = ''; } $links .= substr($match, strpos($match, '>') + 1, strpos($match, $endtag) - strpos($match, '>') - 1); $data['links'] = p_get_instructions($links); return $data; }
function render($mode, Doku_Renderer $renderer, $data) { if (empty($data)) { return false; } if ($mode == 'xhtml') { /** @var Doku_Renderer_xhtml $renderer */ list($state, $content, $classes, $attributes) = $data; switch ($state) { case DOKU_LEXER_ENTER: $type = $attributes['type'] ? $attributes['type'] : 'info'; $icon = $attributes['icon'] ? $attributes['icon'] : null; $dismiss = $attributes['dismiss'] ? $attributes['dismiss'] : false; $markup = sprintf('<div class="alert alert-%s %s" role="alert">', $type, $dismiss ? 'alert-dismissible' : ''); if ($dismiss) { $markup .= '<button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span></button>'; } if ($icon) { $markup .= sprintf('<i class="%s"></i> ', $icon); } $renderer->doc .= $markup; return true; case DOKU_LEXER_UNMATCHED: $renderer->doc .= sprintf($this->template_content, str_replace(array('<p>', '</p>'), '', p_render("xhtml", p_get_instructions($content), $info))); return true; case DOKU_LEXER_EXIT: $renderer->doc .= '</div>'; return true; } return true; } return false; }
function render($mode, Doku_Renderer $renderer, $data) { if (empty($data)) { return false; } if ($mode == 'xhtml') { /** @var Doku_Renderer_xhtml $renderer */ list($state, $match, $attributes) = $data; switch ($state) { case DOKU_LEXER_ENTER: $placement = $attributes['placement']; $title = $attributes['title']; $html = $attributes['html']; if ($html) { $title = hsc(p_render('xhtml', p_get_instructions($title), $info)); } $markup = sprintf('<span class="bs-wrap bs-wrap-tooltip" data-toggle="tooltip" data-html="%s" data-placement="%s" title="%s" style="border-bottom:1px dotted">', $html, $placement, $title); $renderer->doc .= $markup; return true; case DOKU_LEXER_EXIT: $renderer->doc .= '</span>'; return true; } return true; } return false; }
function parse($string) { $info = array(); $rendered = p_render('xhtml', p_get_instructions($string), $info); dbglog($string, 'alphalist helper::parse before'); dbglog($rendered, 'alphalist helper::parse after'); return $rendered; }
public function test_instructions() { $instructions = p_get_instructions("~~REDIRECT>namespace:page~~"); // this is '/tmp' somewhy when ran from IDEA $doku_root = '/.'; $expected = array(0 => array(0 => 'document_start', 1 => array(), 2 => 0), 1 => array(0 => 'plugin', 1 => array(0 => 'pageredirect', 1 => array(0 => 'namespace:page', 1 => '<div class="noteredirect">This page has been moved, the new location is <a href="' . $doku_root . '/doku.php?id=namespace:page" class="wikilink2" title="namespace:page" rel="nofollow">page</a>.</div>'), 2 => 5, 3 => '~~REDIRECT>namespace:page~~'), 2 => 1), 2 => array(0 => 'document_end', 1 => array(), 2 => 1)); $this->assertEquals($expected, $instructions); }
public function test_HTMLinclusion() { $input = file_get_contents(dirname(__FILE__) . '/input.txt'); $xhtml = p_render('xhtml', p_get_instructions($input), $info); $doc = phpQuery::newDocument($xhtml); // HTML Check - there should be no bold tag anywhere $this->assertEquals(0, pq('bold', $doc)->length); }
/** * render the given text with the inverse renderer * * @param $text * @return string */ protected function render($text) { $instructions = p_get_instructions($text); $Renderer = new renderer_plugin_edittable_inverse(); foreach ($instructions as $instruction) { // Execute the callback against the Renderer call_user_func_array(array(&$Renderer, $instruction[0]), $instruction[1]); } return $Renderer->doc; }
/** * Your main program * * Arguments and options have been parsed when this is run * * @param DokuCLI_Options $options * @throws DokuCLI_Exception * @return void */ protected function main(DokuCLI_Options $options) { $renderer = $options->getOpt('renderer', 'xhtml'); // do the action $source = stream_get_contents(STDIN); $info = array(); $result = p_render($renderer, p_get_instructions($source), $info); if (is_null($result)) { throw new DokuCLI_Exception("No such renderer {$renderer}"); } echo $result; }
function test_parser() { global $ID; $ID = 'foo:bar:start'; $parser_response = p_get_instructions('~~PDFNS>.:|Foo~~'); $expected_parser_response = array('plugin', array('dw2pdf_exportlink', array('link' => '?do=export_pdfns&book_ns=foo:bar&book_title=Foo', 'title' => 'Export namespace "foo:bar:" to file Foo.pdf', 5, 1), 5, '~~PDFNS>.:|Foo~~'), 1); $this->assertEquals($expected_parser_response, $parser_response[2]); $renderer_response = p_render('xhtml', $parser_response, $info); $expected_renderer_response = 'doku.php?id=foo:bar:start&do=export_pdfns&book_ns=foo:bar&book_title=Foo" class="wikilink2" title="foo:bar:start" rel="nofollow">Export namespace "foo:bar:" to file Foo.pdf</a>'; $trimmed_renderer_response = substr($renderer_response, strpos($renderer_response, 'doku.php'), -5); $trimmed_renderer_response = trim($trimmed_renderer_response); $this->assertEquals($expected_renderer_response, $trimmed_renderer_response); }
function _render(&$event, $param) { ### _render : displays the upload form in the pages according to authorized action # INPUT : it's a dokuwiki event function # OUTPUT : void # DISPLAY : upload form global $ID, $lang; // Check if the current action is in the action allow table if (strpos($this->getConf('formDisplayRule'), $event->data) === false) { return; } // Check if the page exists if (page_exists($ID) && $event->data != "odt2dw") { return; } if (page_exists($ID)) { echo p_render('xhtml', p_get_instructions($this->getLang('formPageExistMessage')), $info); } // Check auth user can edit this page if (auth_quickaclcheck($ID) < AUTH_EDIT) { return; } // If all check is ok, display the form $message = $this->getConf('formIntroMessage'); if ($message == 'default') { $message = $this->getLang('formIntroMessage'); } if ($message) { echo p_render('xhtml', p_get_instructions($message), $info); } // FIXME create the form with dokuwiki method ? echo '<form method="post" action="" enctype="multipart/form-data"> <fieldset> <legend>' . $this->getLang('formLegend') . '</legend> <input type="hidden" name="MAX_FILE_SIZE" value="' . $this->getConf('formMaxFileSize') . '"/> <input type="hidden" name="do" value="odt2dw"/> <input type="hidden" name="id" value="' . $ID . '"/> <input type="file" name="odtFile"/> <input type="submit" value="' . $lang['btn_upload'] . '"/> </fieldset> </form>'; if ($event->data == 'odt2dw') { $event->preventDefault(); } }
/** * Handle matches of the newsticker syntax * * @param string $match The match of the syntax * @param int $state The state of the handler * @param int $pos The position in the document * @param Doku_Handler $handler The handler * @return array Data for the renderer */ public function handle($match, $state, $pos, Doku_Handler &$handler) { if ($state !== 3) { return array(); } $data = array(); $lines = explode("\n", $match); $lines = $this->cleanData($lines); foreach ($lines as $newsItem) { $instructions = p_get_instructions($newsItem); $render = p_render('xhtml', $instructions, $info); $render = trim($render); $render = ltrim($render, '<p>'); $render = rtrim($render, '</p>'); $data[] = $render; } return $data; }
/** * 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>'; }
/** * Triggers before preview xhtml render, * allows plugins to metadata render on the preview. */ public function _preview_before(&$event, $param) { global $ACT; global $TEXT; global $SUF; global $PRE; global $ID; global $METADATA_RENDERERS; if ($ACT == 'preview') { $triples =& plugin_load('helper', 'strata_triples'); $triples->beginPreview(); $text = $PRE . $TEXT . $SUF; $orig = p_read_metadata($ID); // store the original metadata in the global $METADATA_RENDERERS so p_set_metadata can use it $METADATA_RENDERERS[$ID] =& $orig; // add an extra key for the event - to tell event handlers the page whose metadata this is $orig['page'] = $ID; $evt = new Doku_Event('STRATA_PREVIEW_METADATA_RENDER', $orig); if ($evt->advise_before()) { // get instructions $instructions = p_get_instructions($text); if (is_null($instructions)) { unset($METADATA_RENDERERS[$ID]); return null; // something went wrong with the instructions } // set up the renderer $renderer = new renderer_plugin_strata(); $renderer->meta =& $orig['current']; $renderer->persistent =& $orig['persistent']; // loop through the instructions foreach ($instructions as $instruction) { // execute the callback against the renderer call_user_func_array(array(&$renderer, $instruction[0]), (array) $instruction[1]); } $evt->result = array('current' => &$renderer->meta, 'persistent' => &$renderer->persistent); } $evt->advise_after(); // clean up unset($METADATA_RENDERERS[$id]); } }
function dw_internal_links($page) { global $conf; $instructions = p_get_instructions(file_get_contents($page['file'])); $links = array(); $cns = getNS($page['id']); $exists = false; foreach ($instructions as $ins) { if ($ins[0] == 'internallink' || $conf['camelcase'] && $ins[0] == 'camelcaselink') { $mid = $ins[1][0]; resolve_pageid($cns, $mid, $exists); if (!$exists) { list($mid) = explode('#', $mid); //record pages without hashs $links[] = $mid; } } } return $links; }
function _editform(&$event, $param) { global $TEXT; if ($event->data['target'] !== 'plugin_data') { // Not a data edit return; } $event->stopPropagation(); $event->preventDefault(); unset($event->data['intro_locale']); $event->data['media_manager'] = false; echo $this->locale_xhtml('edit_intro' . ($this->getConf('edit_content_only') ? '_contentonly' : '')); require_once 'renderer_data_edit.php'; $Renderer = new Doku_Renderer_plugin_data_edit(); $Renderer->form = $event->data['form']; // Loop through the instructions $instructions = p_get_instructions($TEXT); foreach ($instructions as $instruction) { // Execute the callback against the Renderer call_user_func_array(array(&$Renderer, $instruction[0]), $instruction[1]); } }
function testVideoOGVInternal() { $this->markTestSkipped('Skipped because it is failing'); $file = 'wiki:kind_zu_katze.ogv'; $parser_response = p_get_instructions('{{' . $file . '}}'); $calls = array(array('document_start', array()), array('p_open', array()), array('internalmedia', array($file, null, null, null, null, 'cache', 'details')), array('cdata', array(null)), array('p_close', array()), array('document_end', array())); $this->assertEquals(array_map('stripbyteindex', $parser_response), $calls); $Renderer = new Doku_Renderer_xhtml(); $url = $Renderer->externalmedia($file, null, null, null, null, 'cache', 'details', true); $video = '<video class="media" width="320" height="240" controls="controls" poster="/./lib/exe/fetch.php?media=wiki:kind_zu_katze.png">'; $this->assertEquals(substr($url, 0, 125), $video); $source_webm = '<source src="/./lib/exe/fetch.php?media=wiki:kind_zu_katze.webm" type="video/webm" />'; $this->assertEquals(substr($url, 126, 85), $source_webm); $source_ogv = '<source src="/./lib/exe/fetch.php?media=wiki:kind_zu_katze.ogv" type="video/ogg" />'; $this->assertEquals(substr($url, 212, 83), $source_ogv); $a_webm = '<a href="/./lib/exe/fetch.php?id=&cache=&media=wiki:kind_zu_katze.webm" class="media mediafile mf_webm" title="wiki:kind_zu_katze.webm (99.1 KB)">kind_zu_katze.webm</a>'; $a_ogv = '<a href="/./lib/exe/fetch.php?id=&cache=&media=wiki:kind_zu_katze.ogv" class="media mediafile mf_ogv" title="wiki:kind_zu_katze.ogv (44.8 KB)">kind_zu_katze.ogv</a>'; $this->assertEquals(substr($url, 296, 176), $a_webm); $this->assertEquals(substr($url, 472, 172), $a_ogv); $rest = '</video>' . "\n"; $this->assertEquals(substr($url, 644), $rest); }
/** * Creates the actual Table Editor form * * @param Doku_Event $event */ function editform(Doku_Event $event) { global $TEXT; global $RANGE; if ($event->data['target'] !== 'table') { return; } if (!$RANGE) { // section editing failed, use default editor instead $event->data['target'] = 'section'; return; } $event->stopPropagation(); $event->preventDefault(); /** @var renderer_plugin_edittable_json $Renderer our own renderer to convert table to array */ $Renderer = plugin_load('renderer', 'edittable_json', true); $instructions = p_get_instructions($TEXT); // Loop through the instructions foreach ($instructions as $instruction) { // Execute the callback against the Renderer call_user_func_array(array(&$Renderer, $instruction[0]), $instruction[1]); } // output data and editor field /** @var Doku_Form $form */ $form =& $event->data['form']; // data for handsontable $form->addHidden('edittable_data', $Renderer->getDataJSON()); $form->addHidden('edittable_meta', $Renderer->getMetaJSON()); $form->addElement('<div id="edittable__editor"></div>'); // FIXME add explanation here if (isset($_POST['edittable__new'])) { foreach ($_POST['edittable__new'] as $k => $v) { $form->addHidden("edittable__new[{$k}]", $v); } } // set target and range to keep track during previews $form->addHidden('target', 'table'); $form->addHidden('range', $RANGE); }
function render($mode, Doku_Renderer $renderer, $data) { if (empty($data)) { return false; } if ($mode == 'xhtml') { /** @var Doku_Renderer_xhtml $renderer */ list($state, $content, $classes, ) = $data; switch ($state) { case DOKU_LEXER_ENTER: $markup = sprintf($this->template_start, @implode(' ', $classes)); $renderer->doc .= $markup; return true; case DOKU_LEXER_UNMATCHED: $renderer->doc .= sprintf($this->template_content, str_replace(array('<p>', '</p>'), '', p_render("xhtml", p_get_instructions($content), $info))); return true; case DOKU_LEXER_EXIT: $renderer->doc .= sprintf($this->template_end, ''); return true; } return true; } return false; }
function startEditForm(&$renderer, $erase = true) { global $DOKUTRANSLATE_EDITFORM; global $DOKUTRANSLATE_NEST; global $ACT; global $TEXT; # Insert saved edit form $renderer->doc .= '<div class="preview" id="scroll__here">'; $renderer->doc .= $DOKUTRANSLATE_EDITFORM; # Render preview from submitted text (the saved page may look different # if dokutranslate markup is present in the text) if ($ACT == 'preview') { $renderer->doc .= p_locale_xhtml('preview'); $DOKUTRANSLATE_NEST++; $previewIns = p_get_instructions($TEXT); $DOKUTRANSLATE_NEST--; $renderer->nest($previewIns); } $renderer->doc .= '</div>'; if ($erase) { # Insert erasure start marker $renderer->doc .= '<!-- DOKUTRANSLATE ERASE START -->'; } }
private function render_merge_interface_frame($frame, $data_array) { if ($frame == 'title') { $current_content = $this->title; } elseif ($frame == 'reference') { $current_content = $this->reference; } else { list($image, $current_content) = explode('<!-- Image -->', $this->frames[$frame]); } $current_content = trim($current_content); //remove device frames that match current frames foreach ($data_array as $index => $device) { $new_content = $this->_content($device, $frame); if (preg_replace('/[\\r\\n]*/', ' ', $current_content) == preg_replace('/[\\r\\n]*/', ' ', $new_content)) { $this->_dismiss($device, $frame); unset($data_array[$index]); } } unset($index, $device); if (!count($data_array)) { return; } foreach ($data_array as $device) { $user_array[$device] = $this->devices[$device]; } @asort($user_array); @reset($user_array); echo '<div id="frame-' . $frame . '" class="frame">'; if ($frame == 'title' || $frame == 'reference') { $frame_title = ucwords($frame); } else { $frame_title = 'Frame ' . $frame; } echo p_render('xhtml', p_get_instructions('===' . $frame_title . '==='), $info); unset($frame_title); echo '<div class="frame-content-container">'; if (!empty($image)) { echo p_render('xhtml', p_get_instructions($image), $info); } unset($image); echo '<div class="frame-content">'; if ($frame == 'title') { echo p_render('xhtml', p_get_instructions('== ' . $current_content . ' =='), $info); } elseif ($frame == 'reference') { echo p_render('xhtml', p_get_instructions('// ' . $current_content . ' //'), $info); } else { echo p_render('xhtml', p_get_instructions($current_content), $info); } echo '</div>'; echo '</div>'; echo '<div class="frame-version-selection">'; echo $this->getLang('version_to_compare') . ': '; echo '<select class="door43gitmerge-diff-switcher" data-frame="' . $frame . '">'; if (is_array($user_array) && count($user_array)) { foreach ($user_array as $device => $user) { if (!isset($first_device)) { $first_device = $device; } echo '<option value="' . $device . '">' . $user['name'] . '</option>'; } } echo '<option value="all">' . $this->getLang('show_all') . '</option>'; unset($device, $user); echo '</select>'; echo '</div>'; echo '<div class="frame-diffs">'; if (is_array($user_array) && count($user_array)) { foreach ($user_array as $device => $user) { $new_content = $this->_content($device, $frame); $this->html_diff($frame, $device, $current_content, $new_content, $device == $first_device); } } unset($device, $user, $new_content, $first_device); echo '</div>'; echo '</div>'; }
/** * 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; } }
/** * Returns the render instructions for a file * * Uses and creates a serialized cache file * * @author Andreas Gohr <*****@*****.**> */ function p_cached_instructions($file, $cacheonly = false, $id = '') { global $conf; static $run = null; if (is_null($run)) { $run = array(); } $cache = new cache_instructions($id, $file); if ($cacheonly || $cache->useCache() || isset($run[$file])) { return $cache->retrieveCache(); } else { if (@file_exists($file)) { // no cache - do some work $ins = p_get_instructions(io_readWikiPage($file, $id)); if ($cache->storeCache($ins)) { $run[$file] = true; // we won't rebuild these instructions in the same run again } else { msg('Unable to save cache file. Hint: disk full; file permissions; safe_mode setting.', -1); } return $ins; } } return null; }
/** * Print a toc preview * * @author Samuele Tognini <*****@*****.**> * @author Andreas Gohr <*****@*****.**> */ function print_toc($id) { require_once DOKU_INC . 'inc/parser/xhtml.php'; $id = cleanID($id); if (auth_quickaclcheck($id) < AUTH_READ) { return; } $meta = p_get_metadata($id); $toc = $meta['description']['tableofcontents']; $out .= '<div class="tocheader toctoggle">' . DOKU_LF; if (count($toc) > 1) { $out .= $this->render_toc($toc); } else { $out .= '<a href="' . wl($id) . '">'; $out .= $meta['title'] ? htmlspecialchars($meta['title']) : htmlspecialchars(noNS($id)); $out .= '</a>' . DOKU_LF; if ($meta['description']['abstract']) { $out .= '</div>' . DOKU_LF; $out .= '<div class="indexmenu_toc_inside">' . DOKU_LF; $out .= p_render('xhtml', p_get_instructions($meta['description']['abstract']), $info); $out .= '</div>' . DOKU_LF; } } $out .= '</div>' . DOKU_LF; return $out; }