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;
 }
 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;
 }
Ejemplo n.º 3
0
Archivo: do.php Proyecto: rauschen/do
 function handle($match, $state, $pos, &$handler)
 {
     $data = array('task' => array(), 'state' => $state);
     switch ($state) {
         case DOKU_LEXER_ENTER:
             $match = trim(substr($match, 3, -1));
             if (preg_match('/\\b(\\d\\d\\d\\d-\\d\\d-\\d\\d)\\b/', $match, $grep)) {
                 $data['task']['date'] = $grep[1];
                 $match = trim(str_replace($data['task']['date'], '', $match));
             }
             if ($match !== '') {
                 //FIXME call $auth->cleanUser()
                 $data['task']['user'] = $match;
             }
             $ReWriter = new Doku_Handler_Nest($handler->CallWriter, 'plugin_do_do');
             $handler->CallWriter =& $ReWriter;
             $handler->addPluginCall('do_do', $data, $state, $pos, $match);
             break;
         case DOKU_LEXER_UNMATCHED:
             $handler->_addCall('cdata', array($match), $pos);
             break;
         case DOKU_LEXER_EXIT:
             global $ID;
             $data['task']['text'] = trim(strip_tags(p_render('xhtml', array_slice($handler->CallWriter->calls, 1), $ignoreme)));
             $data['task']['md5'] = md5(utf8_strtolower(preg_replace('/\\s/', '', $data['task']['text'])) . $ID);
             // Add missing data from ENTER and EXIT to the other
             $handler->CallWriter->calls[0][1][1]['task'] += $data['task'];
             $data['task'] += $handler->CallWriter->calls[0][1][1]['task'];
             $handler->addPluginCall('do_do', $data, $state, $pos, $match);
             $handler->CallWriter->process();
             $ReWriter =& $handler->CallWriter;
             $handler->CallWriter =& $ReWriter->CallWriter;
     }
     return false;
 }
 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">&times;</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;
 }
Ejemplo n.º 5
0
 /**
  * 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;
 }
Ejemplo n.º 6
0
 /**
  * @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;
 }
 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;
 }
 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);
 }
Ejemplo n.º 9
0
 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;
 }
Ejemplo n.º 10
0
 /**
  * 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&amp;do=export_pdfns&amp;book_ns=foo:bar&amp;book_title=Foo" class="wikilink2" title="foo:bar:start" rel="nofollow">Export namespace &quot;foo:bar:&quot; 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);
 }
Ejemplo n.º 12
0
 protected function override_cached_output($file, $format = 'xhtml', $id = '')
 {
     // we are not caching this page because it interferes with language switching
     $parsed = p_render($format, $this->override_cached_instructions($file, false, $id), $info);
     // if there is a user logged in, insert the translate button
     if ($GLOBALS['USERINFO'] != null && !empty($GLOBALS['USERINFO']['grps'])) {
         $ns = $this->getNamespace();
         if (!empty($ns) && $ns != 'en') {
             $parsed .= PHP_EOL . $this->getButton();
         }
     }
     return $parsed;
 }
Ejemplo n.º 13
0
    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();
        }
    }
Ejemplo n.º 14
0
 /**
  * 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;
 }
Ejemplo n.º 15
0
/**
 * 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>';
}
Ejemplo n.º 16
0
    function _handle_tpl_act(&$event, $param)
    {
        global $TEXT;

	    if($event->data != 'weaki') return;//check if is "weaki" after do= in URL
	    $event->preventDefault();//prevent default behaviour

        $filenames = $this->_get_filenames();
        $TEXT = $this->_weaki_headers($filenames);

        if($_GET["action"] == 'save'){
            act_save('save');
        }else{
            print $this -> _html_weaki_box();
        }

        $instructions = p_get_instructions($TEXT);
        $html .= p_render('xhtml',$instructions,$info); // render the instructions on the fly
        print $html;
    }
 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;
 }
Ejemplo n.º 18
0
 /**
  * Build a ODT from the articles
  *
  * @param string $cachefile
  * @param string $title
  */
 protected function generateODT($cachefile, $title)
 {
     global $ID;
     global $REV;
     /** @var renderer_plugin_odt_book $odt */
     $odt = plugin_load('renderer', 'odt_book');
     // store original pageid
     $keep = $ID;
     // loop over all pages
     $xmlcontent = '';
     $cnt = count($this->list);
     for ($n = 0; $n < $cnt; $n++) {
         $page = $this->list[$n];
         // set global pageid to the rendered page
         $ID = $page;
         $xmlcontent .= p_render('odt_book', p_cached_instructions(wikiFN($page, $REV), false, $page), $info);
     }
     //restore ID
     $ID = $keep;
     $odt->doc = $xmlcontent;
     $odt->setTitle($title);
     $odt->finalize_ODTfile();
     // write to cache file
     io_savefile($cachefile, $odt->doc);
 }
Ejemplo n.º 19
0
 /**
  * Check for new messages from upstream
  *
  * @author Samuele Tognini <*****@*****.**>
  */
 function _checkupdates()
 {
     require_once DOKU_INC . 'inc/HTTPClient.php';
     global $conf;
     global $INFO;
     $w = -1;
     $date = $this->getInfo('date');
     $date = $date['date'];
     $data = $this->_remotequery("http://samuele.netsons.org/dokuwiki/lib/plugins/indexmenu/remote.php?check={$date}");
     if ($data === "") {
         msg($this->getLang('noupdates'), 1);
         $data .= @preg_replace('/\\n\\n.*$/s', '', @io_readFile(DOKU_PLUGIN . 'indexmenu/changelog')) . "\n%\n";
         $w = 1;
     } else {
         $data = preg_replace('/\\<br(\\s*)?\\/?\\>/i', "", $data);
         $data = preg_replace('/\\t/', " ", $data);
     }
     $data = preg_replace('/\\[\\[(?!(http|https))(.:)(.*?)\\]\\]/s', "[[plugin:\$3]]", $data);
     $data = preg_replace('/\\[\\[(?!(http|https))(.*?)\\]\\]/s', "[[http://www.dokuwiki.org/\$2]]", $data);
     $msgs = explode("\n%\n", $data);
     foreach ($msgs as $msg) {
         if ($msg) {
             $msg = p_render('xhtml', p_get_instructions($msg), $info);
             msg($msg, $w);
         }
     }
 }
Ejemplo n.º 20
0
 public function handle_tpl_act_render(Doku_Event &$event, $param)
 {
     global $ID;
     global $INFO;
     global $DOKUTRANSLATE_EDITFORM;
     if (!@file_exists(metaFN($ID, '.translate'))) {
         return;
     }
     # Disable TOC on translated pages
     $INFO['prependTOC'] = false;
     if (in_array($event->data, array('edit', 'preview'))) {
         # Take the event over
         $event->preventDefault();
         # Save the edit form for later
         html_edit();
         $DOKUTRANSLATE_EDITFORM = ob_get_clean();
         ob_start();
         # Render the page (renderer inserts saved edit form
         # and preview in the right cell)
         echo p_render('xhtml', p_cached_instructions(wikiFN($ID)), $INFO);
     }
 }
Ejemplo n.º 21
0
 /**
  * Retrieves the facebook events and parses them to HTML.
  */
 function render($mode, &$renderer, $data)
 {
     $info = $this->getInfo();
     $content = '';
     if ($mode == 'xhtml') {
         // Catch errors
         if ($this->error) {
             $renderer->doc .= 'Error in Plugin ' . $info['name'] . ': ' . $this->error;
             return;
         }
         // Make a query to get the events for a fanpageid
         $fql = "SELECT eid, name, pic, pic_small, pic_big, pic_square, start_time, end_time, location, description " . " FROM event WHERE eid IN ( SELECT eid FROM event_member WHERE uid = " . $data['fanpageid'] . " ) " . " ORDER BY start_time " . $data[FB_EVENTS_SORT];
         // Initialise Facebook
         $facebook = new Facebook(array('appId' => $data['appid'], 'secret' => $data['secret'], 'cookie' => true));
         // Set the parameters
         $param = array('method' => 'fql.query', 'query' => $fql, 'callback' => '');
         // Get the date format
         $date_format = $this->getConf(FB_WALL_DATE_FORMAT);
         $time_format = $this->getConf(FB_WALL_TIME_FORMAT);
         // Remember the "old" timezone"
         $origin_timezone = date_default_timezone_get();
         // Set it to Facebook timezone
         date_default_timezone_set('America/Los_Angeles');
         // Execute the query
         $fql_results = $facebook->api($param);
         $displayed_entries = 0;
         // Loop through the results
         foreach ($fql_results as $keys => $values) {
             $entry = $data['template'];
             if (!$values['description']) {
                 $values['description'] = $this->getLang('no_description');
             }
             if (!$values['end_time']) {
                 $values['end_time'] = $values['start_time'];
             }
             // If the date is lower than the from date, skip to the next
             if ($data[FB_EVENTS_FROM_DATE] && $values['start_time'] < $data[FB_EVENTS_FROM_DATE]) {
                 continue;
             }
             // If the date is higher than the to data, skip to the next
             if ($data[FB_EVENTS_TO_DATE] && $values['end_time'] > $data[FB_EVENTS_TO_DATE]) {
                 continue;
             }
             // Limit?
             if (isset($data[FB_EVENTS_LIMIT]) && $data[FB_EVENTS_LIMIT] > 0) {
                 if (strlen($values['description']) > $data[FB_EVENTS_LIMIT]) {
                     $values['description'] = substr($values['description'], 0, $data[FB_EVENTS_LIMIT]) . '...';
                 }
             }
             // Process the description
             $values['description'] = str_replace("\r\n", '<html><br /></html>', $values['description']);
             $values['description'] = str_replace("\n", '<html><br /></html>', $values['description']);
             // Prepare the entry
             $entry = str_replace('{title}', $values['name'], $entry);
             $entry = str_replace('{description}', $values['description'], $entry);
             $entry = str_replace('{location}', $values['location'], $entry);
             $entry = str_replace('{image}', $values['pic'], $entry);
             $entry = str_replace('{image_large}', $values['pic_big'], $entry);
             $entry = str_replace('{image_small}', $values['pic_small'], $entry);
             $entry = str_replace('{image_square}', $values['pic_square'], $entry);
             // Dates
             if (!isset($data[FB_EVENTS_SHOW_END_TIMES]) || $data[FB_EVENTS_SHOW_END_TIMES] == '1') {
                 // Are they the same date?
                 $start_date = date("Ymd", $values['start_time']);
                 $end_date = date("Ymd", $values['end_time']);
                 if ($start_date == $end_date) {
                     $date_string = strftime($date_format, $values['start_time']);
                     $datetime_string = $date_string . ' ' . strftime($time_format, $values['start_time']) . '-' . strftime($time_format, $values['end_time']);
                     $entry = str_replace('{date}', $date_string, $entry);
                     $entry = str_replace('{datetime}', $datetime_string, $entry);
                 } else {
                     $date_string = strftime($date_format, $values['start_time']) . ' - ' . strftime($date_format, $values['end_time']);
                     $datetime_string = strftime($date_format, $values['start_time']) . ' ' . strftime($time_format, $values['start_time']) . ' - ' . strftime($date_format, $values['end_time']) . ' ' . strftime($time_format, $values['end_time']);
                     $entry = str_replace('{date}', $date_string, $entry);
                     $entry = str_replace('{datetime}', $datetime_string, $entry);
                 }
             } else {
                 $entry = str_replace('{date}', strftime($date_format, $values['start_time']), $entry);
                 $entry = str_replace('{datetime}', strftime($date_format, $values['start_time']) . ' ' . strftime($time_format, $values['start_time']), $entry);
             }
             $entry = str_replace('{timestamp}', $values['start_time'], $entry);
             $entry = str_replace('{startdate}', strftime($date_format, $values['start_time']), $entry);
             $entry = str_replace('{starttime}', strftime($time_format, $values['start_time']), $entry);
             $entry = str_replace('{startdatetime}', strftime($date_format, $values['start_time']) . ' ' . strftime($time_format, $values['start_time']), $entry);
             $entry = str_replace('{enddate}', strftime($date_format, $values['end_time']), $entry);
             $entry = str_replace('{endtime}', strftime($time_format, $values['end_time']), $entry);
             $entry = str_replace('{enddatetime}', strftime($date_format, $values['end_time']) . ' ' . strftime($time_format, $values['end_time']), $entry);
             // [[ url | read more ]
             $event_url = "http://www.facebook.com/events/" . $values['eid'];
             $entry = str_replace('{url}', $event_url, $entry);
             $entry = str_replace('{more}', '[[' . $event_url . '|' . $this->getLang('read_more') . ']]', $entry);
             // Add the entry to the content
             $content .= $entry;
             // Only display a maximum number of entries
             $displayed_entries++;
             if (isset($data[FB_EVENTS_NR_ENTRIES]) && $displayed_entries >= $data[FB_EVENTS_NR_ENTRIES]) {
                 break;
             }
         }
         //$renderer->doc .= $ret;
         $html = p_render($mode, p_get_instructions($content), $info);
         $renderer->doc .= $html;
         // Set the timezone back to the original
         date_default_timezone_set($origin_timezone);
         return true;
     }
     return false;
 }
Ejemplo n.º 22
0
 /**
  * output text string through the parser, allows dokuwiki markup to be used
  * very ineffecient for small pieces of data - try not to use
  */
 function render($text, $format = 'xhtml')
 {
     return p_render($format, p_get_instructions($text), $info);
 }
Ejemplo n.º 23
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;
    }
}
Ejemplo n.º 24
0
 /**
  * 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;
 }
/**
 * Dispatches the given sidebar type to return the right content
 *
 * @author Michael Klier <*****@*****.**>
 */
function tpl_sidebar_dispatch($sb, $pos)
{
    global $lang;
    global $conf;
    global $ID;
    global $REV;
    global $INFO;
    global $TOC;
    $svID = $ID;
    // save current ID
    $svREV = $REV;
    // save current REV
    $svTOC = $TOC;
    // save current TOC
    $pname = tpl_getConf('pagename');
    switch ($sb) {
        case 'main':
            if (tpl_getConf('closedwiki') && !isset($_SERVER['REMOTE_USER'])) {
                return;
            }
            $main_sb = $pname;
            if (@page_exists($main_sb) && auth_quickaclcheck($main_sb) >= AUTH_READ) {
                $always = tpl_getConf('main_sidebar_always');
                if ($always or !$always && !getNS($ID)) {
                    print '<div class="main_sidebar sidebar_box">' . DOKU_LF;
                    print p_sidebar_xhtml($main_sb, $pos) . DOKU_LF;
                    print '</div>' . DOKU_LF;
                }
            } elseif (!@page_exists($main_sb) && auth_quickaclcheck($main_sb) >= AUTH_CREATE) {
                if (@file_exists(DOKU_TPLINC . 'lang/' . $conf['lang'] . '/nonidebar.txt')) {
                    $out = p_render('xhtml', p_get_instructions(io_readFile(DOKU_TPLINC . 'lang/' . $conf['lang'] . '/nosidebar.txt')), $info);
                } else {
                    $out = p_render('xhtml', p_get_instructions(io_readFile(DOKU_TPLINC . 'lang/en/nosidebar.txt')), $info);
                }
                $link = '<a href="' . wl($pname) . '" class="wikilink2">' . $pname . '</a>' . DOKU_LF;
                print '<div class="main_sidebar sidebar_box">' . DOKU_LF;
                print str_replace('LINK', $link, $out);
                print '</div>' . DOKU_LF;
            }
            break;
        case 'namespace':
            if (tpl_getConf('closedwiki') && !isset($_SERVER['REMOTE_USER'])) {
                return;
            }
            $user_ns = tpl_getConf('user_sidebar_namespace');
            $group_ns = tpl_getConf('group_sidebar_namespace');
            if (!preg_match("/^" . $user_ns . ":.*?\$|^" . $group_ns . ":.*?\$/", $svID)) {
                // skip group/user sidebars and current ID
                $ns_sb = _getNsSb($svID);
                if ($ns_sb && auth_quickaclcheck($ns_sb) >= AUTH_READ) {
                    print '<div class="namespace_sidebar sidebar_box">' . DOKU_LF;
                    print p_sidebar_xhtml($ns_sb, $pos) . DOKU_LF;
                    print '</div>' . DOKU_LF;
                }
            }
            break;
        case 'user':
            if (tpl_getConf('closedwiki') && !isset($_SERVER['REMOTE_USER'])) {
                return;
            }
            $user_ns = tpl_getConf('user_sidebar_namespace');
            if (isset($INFO['userinfo']['name'])) {
                $user = $_SERVER['REMOTE_USER'];
                $user_sb = $user_ns . ':' . $user . ':' . $pname;
                if (@page_exists($user_sb)) {
                    $subst = array('pattern' => array('/@USER@/'), 'replace' => array($user));
                    print '<div class="user_sidebar sidebar_box">' . DOKU_LF;
                    print p_sidebar_xhtml($user_sb, $pos, $subst) . DOKU_LF;
                    print '</div>';
                }
                // check for namespace sidebars in user namespace too
                if (preg_match('/' . $user_ns . ':' . $user . ':.*/', $svID)) {
                    $ns_sb = _getNsSb($svID);
                    if ($ns_sb && $ns_sb != $user_sb && auth_quickaclcheck($ns_sb) >= AUTH_READ) {
                        print '<div class="namespace_sidebar sidebar_box">' . DOKU_LF;
                        print p_sidebar_xhtml($ns_sb, $pos) . DOKU_LF;
                        print '</div>' . DOKU_LF;
                    }
                }
            }
            break;
        case 'group':
            if (tpl_getConf('closedwiki') && !isset($_SERVER['REMOTE_USER'])) {
                return;
            }
            $group_ns = tpl_getConf('group_sidebar_namespace');
            if (isset($INFO['userinfo']['name'], $INFO['userinfo']['grps'])) {
                foreach ($INFO['userinfo']['grps'] as $grp) {
                    $group_sb = $group_ns . ':' . $grp . ':' . $pname;
                    if (@page_exists($group_sb) && auth_quickaclcheck(cleanID($group_sb)) >= AUTH_READ) {
                        $subst = array('pattern' => array('/@GROUP@/'), 'replace' => array($grp));
                        print '<div class="group_sidebar sidebar_box">' . DOKU_LF;
                        print p_sidebar_xhtml($group_sb, $pos, $subst) . DOKU_LF;
                        print '</div>' . DOKU_LF;
                    }
                }
            }
            break;
        case 'index':
            if (tpl_getConf('closedwiki') && !isset($_SERVER['REMOTE_USER'])) {
                return;
            }
            print '<div class="index_sidebar sidebar_box">' . DOKU_LF;
            print '  ' . p_index_xhtml($svID, $pos) . DOKU_LF;
            print '</div>' . DOKU_LF;
            break;
        case 'toc':
            if (tpl_getConf('closedwiki') && !isset($_SERVER['REMOTE_USER'])) {
                return;
            }
            if (auth_quickaclcheck($svID) >= AUTH_READ) {
                $toc = tpl_toc(true);
                // replace ids to keep XHTML compliance
                if (!empty($toc)) {
                    $toc = preg_replace('/id="(.*?)"/', 'id="sb__' . $pos . '__\\1"', $toc);
                    print '<div class="toc_sidebar sidebar_box">' . DOKU_LF;
                    print $toc;
                    print '</div>' . DOKU_LF;
                }
            }
            break;
        case 'toolbox':
            if (tpl_getConf('hideactions') && !isset($_SERVER['REMOTE_USER'])) {
                return;
            }
            if (tpl_getConf('closedwiki') && !isset($_SERVER['REMOTE_USER'])) {
                print '<div class="toolbox_sidebar sidebar_box">' . DOKU_LF;
                print '  <div class="level1">' . DOKU_LF;
                print '    <ul>' . DOKU_LF;
                print '      <li><div class="li">';
                tpl_actionlink('login');
                print '      </div></li>' . DOKU_LF;
                print '    </ul>' . DOKU_LF;
                print '  </div>' . DOKU_LF;
                print '</div>' . DOKU_LF;
            } else {
                $actions = array('admin', 'revert', 'edit', 'history', 'recent', 'backlink', 'subscription', 'index', 'login', 'profile', 'top');
                print '<div class="toolbox_sidebar sidebar_box">' . DOKU_LF;
                print '  <div class="level1">' . DOKU_LF;
                print '    <ul>' . DOKU_LF;
                foreach ($actions as $action) {
                    if (!actionOK($action)) {
                        continue;
                    }
                    // start output buffering
                    if ($action == 'edit') {
                        // check if new page button plugin is available
                        if (!plugin_isdisabled('npd') && ($npd =& plugin_load('helper', 'npd'))) {
                            $npb = $npd->html_new_page_button(true);
                            if ($npb) {
                                print '    <li><div class="li">';
                                print $npb;
                                print '</div></li>' . DOKU_LF;
                            }
                        }
                    }
                    ob_start();
                    print '     <li><div class="li">';
                    if (tpl_actionlink($action)) {
                        print '</div></li>' . DOKU_LF;
                        ob_end_flush();
                    } else {
                        ob_end_clean();
                    }
                }
                print '    </ul>' . DOKU_LF;
                print '  </div>' . DOKU_LF;
                print '</div>' . DOKU_LF;
            }
            break;
        case 'trace':
            if (tpl_getConf('closedwiki') && !isset($_SERVER['REMOTE_USER'])) {
                return;
            }
            print '<div class="trace_sidebar sidebar_box">' . DOKU_LF;
            print '  <h1>' . $lang['breadcrumb'] . '</h1>' . DOKU_LF;
            print '  <div class="breadcrumbs">' . DOKU_LF;
            $conf['youarehere'] != 1 ? tpl_breadcrumbs() : tpl_youarehere();
            print '  </div>' . DOKU_LF;
            print '</div>' . DOKU_LF;
            break;
        case 'extra':
            if (tpl_getConf('closedwiki') && !isset($_SERVER['REMOTE_USER'])) {
                return;
            }
            print '<div class="extra_sidebar sidebar_box">' . DOKU_LF;
            @(include dirname(__FILE__) . '/' . $pos . '_sidebar.html');
            print '</div>' . DOKU_LF;
            break;
        default:
            if (tpl_getConf('closedwiki') && !isset($_SERVER['REMOTE_USER'])) {
                return;
            }
            // check for user defined sidebars
            if (@file_exists(DOKU_TPLINC . 'sidebars/' . $sb . '/sidebar.php')) {
                print '<div class="' . $sb . '_sidebar sidebar_box">' . DOKU_LF;
                @(require_once DOKU_TPLINC . 'sidebars/' . $sb . '/sidebar.php');
                print '</div>' . DOKU_LF;
            }
            break;
    }
    // restore ID, REV and TOC
    $ID = $svID;
    $REV = $svREV;
    $TOC = $svTOC;
}
Ejemplo n.º 26
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;
    }
}
Ejemplo n.º 27
0
/**
 * Returns the given file parsed into the requested output format
 *
 * @author Andreas Gohr <*****@*****.**>
 * @author Chris Smith <*****@*****.**>
 */
function p_cached_output($file, $format = 'xhtml', $id = '')
{
    global $conf;
    $cache = new cache_renderer($id, $file, $format);
    if ($cache->useCache()) {
        $parsed = $cache->retrieveCache(false);
        if ($conf['allowdebug'] && $format == 'xhtml') {
            $parsed .= "\n<!-- cachefile {$cache->cache} used -->\n";
        }
    } else {
        $parsed = p_render($format, p_cached_instructions($file, false, $id), $info);
        if ($info['cache']) {
            $cache->storeCache($parsed);
            //save cachefile
            if ($conf['allowdebug'] && $format == 'xhtml') {
                $parsed .= "\n<!-- no cachefile used, but created {$cache->cache} -->\n";
            }
        } else {
            $cache->removeCache();
            //try to delete cachefile
            if ($conf['allowdebug'] && $format == 'xhtml') {
                $parsed .= "\n<!-- no cachefile used, caching forbidden -->\n";
            }
        }
    }
    return $parsed;
}
Ejemplo n.º 28
0
 /**
  * Render output
  */
 function render($mode, &$renderer, $data)
 {
     global $ACT;
     global $conf;
     global $INFO;
     if ($mode == 'xhtml') {
         if ($ACT == 'preview') {
             //Check user permission to display indexmenu in a preview page
             if ($this->getConf('only_admins') && $conf['useacl'] && $INFO['perm'] < AUTH_ADMIN) {
                 return false;
             }
             //disable cookies
             $data[1]['nocookie'] = true;
         }
         //Navbar with nojs
         if ($data[1]['navbar'] && !$data[6]['js']) {
             if (!isset($data[0])) {
                 $data[0] = '..';
             }
             $data[6]['nss'][] = array(getNS($INFO['id']));
             $renderer->info['cache'] = FALSE;
         }
         if ($data[1]['context']) {
             //resolve current id relative namespaces
             $data[0] = $this->_parse_ns($data[0], $INFO['id']);
             foreach ($data[6]['nss'] as $key => $value) {
                 $data[6]['nss'][$key][0] = $this->_parse_ns($value[0], $INFO['id']);
             }
             $renderer->info['cache'] = FALSE;
         }
         $n = $this->_indexmenu($data);
         if (!@$n) {
             $n = $this->getConf('empty_msg');
             $n = str_replace('{{ns}}', cleanID($data[0]), $n);
             $n = p_render('xhtml', p_get_instructions($n), $info);
         }
         $renderer->doc .= $n;
         return true;
     } else {
         if ($mode == 'metadata') {
             if (!($data[1]['navbar'] && !$data[6]['js']) && !$data[1]['context']) {
                 //this is an indexmenu page that needs the PARSER_CACHE_USE event trigger;
                 $renderer->meta['indexmenu'] = TRUE;
             }
             $renderer->doc .= (empty($data[0]) ? $conf['title'] : nons($data[0])) . " index\n\n";
             unset($renderer->persistent['indexmenu']);
             return true;
         } else {
             return false;
         }
     }
 }
Ejemplo n.º 29
0
 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>';
 }
Ejemplo n.º 30
0
 /**
  * Returns parsed wiki instructions
  *
  * @param string|array $tpl    The template as string
  * @param array        $params A hash mapping parameters to values
  *
  * @return string The parsed template
  */
 protected function _parse_tpl($tpl, $params)
 {
     $ins = array_slice(p_get_instructions($params['display']), 2, -2);
     $tpl = p_render('xhtml', $ins, $byref_ignore);
     return '<p>' . $tpl . '</p>';
 }