/** * Returns the parsed Wikitext in XHTML for the given id and revision. * * If $excuse is true an explanation is returned if the file * wasn't found * * @author Andreas Gohr <*****@*****.**> */ function p_wiki_xhtml($id, $rev = '', $excuse = true, $date_at = '') { $file = wikiFN($id, $rev); $ret = ''; //ensure $id is in global $ID (needed for parsing) global $ID; $keep = $ID; $ID = $id; if ($rev || $date_at) { if (@file_exists($file)) { $ret = p_render('xhtml', p_get_instructions(io_readWikiPage($file, $id, $rev)), $info, $date_at); //no caching on old revisions } elseif ($excuse) { $ret = p_locale_xhtml('norev'); } } else { if (@file_exists($file)) { $ret = p_cached_output($file, 'xhtml', $id); } elseif ($excuse) { $ret = p_locale_xhtml('newpage'); } } //restore ID (just in case) $ID = $keep; return $ret; }
/** * Preview Comments * * @author Michael Klier <*****@*****.**> */ function handle_ajax_call(&$event, $params) { if ($event->data != 'discussion_preview') { return; } $event->preventDefault(); $event->stopPropagation(); print p_locale_xhtml('preview'); print '<div class="comment_preview">'; if (!$_SERVER['REMOTE_USER'] && !$this->getConf('allowguests')) { print p_locale_xhtml('denied'); } else { print $this->_render($_REQUEST['comment']); } print '</div>'; }
/** * @param Doku_Event $event * @param array $param */ function hide(Doku_Event &$event, $param) { if (!$this->hlp->isActive()) { return; } if (!$this->hlp->isHiddenForUser()) { return; } global $ACT; if (!in_array($ACT, array('show', 'edit', 'source', 'diff'))) { return; } $ACT = 'denied'; $event->preventDefault(); $event->stopPropagation(); print p_locale_xhtml('denied'); }
/** * Returns starting summary for a page (e.g. the first few * paragraphs), marked up in XHTML. * * If $excuse is true an explanation is returned if the file * wasn't found * * @param string wiki page id * @param reference populated with page title from heading or page id * @deprecated * @author Harry Fuecks <*****@*****.**> */ function p_wiki_xhtml_summary($id, &$title, $rev = '', $excuse = true) { $file = wikiFN($id, $rev); $ret = ''; //ensure $id is in global $ID (needed for parsing) global $ID; $keep = $ID; $ID = $id; if ($rev) { if (@file_exists($file)) { //no caching on old revisions $ins = p_get_instructions(io_readWikiPage($file, $id, $rev)); } elseif ($excuse) { $ret = p_locale_xhtml('norev'); //restore ID (just in case) $ID = $keep; return $ret; } } else { if (@file_exists($file)) { // The XHTML for a summary is not cached so use the instruction cache $ins = p_cached_instructions($file); } elseif ($excuse) { $ret = p_locale_xhtml('newpage'); //restore ID (just in case) $ID = $keep; return $ret; } } $ret = p_render('xhtmlsummary', $ins, $info); if ($info['sum_pagetitle']) { $title = $info['sum_pagetitle']; } else { $title = $id; } $ID = $keep; return $ret; }
/** * Handles the AJAX calls * * @author Michael Klier <*****@*****.**> */ function handle_ajax_call(&$event, $param) { global $lang; if ($event->data == 'snippet_preview' or $event->data == 'snippet_insert') { $event->preventDefault(); $event->stopPropagation(); $id = cleanID($_REQUEST['id']); if (page_exists($id)) { if ($event->data == 'snippet_preview') { if (auth_quickaclcheck($id) >= AUTH_READ) { print p_wiki_xhtml($id); } else { print p_locale_xhtml('denied'); } } elseif ($event->data == 'snippet_insert') { if (auth_quickaclcheck($id) >= AUTH_READ) { print "\n\n"; // always start on a new line (just to be safe) print trim(preg_replace('/<snippet>.*?<\\/snippet>/s', '', io_readFile(wikiFN($id)))); } } } } }
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 -->'; } }
/** * Display the subscribe form * * @author Adrian Lang <*****@*****.**> */ function tpl_subscribe() { global $INFO; global $ID; global $lang; global $conf; $stime_days = $conf['subscribe_time'] / 60 / 60 / 24; echo p_locale_xhtml('subscr_form'); echo '<h2>' . $lang['subscr_m_current_header'] . '</h2>'; echo '<div class="level2">'; if ($INFO['subscribed'] === false) { echo '<p>' . $lang['subscr_m_not_subscribed'] . '</p>'; } else { echo '<ul>'; foreach ($INFO['subscribed'] as $sub) { echo '<li><div class="li">'; if ($sub['target'] !== $ID) { echo '<code class="ns">' . hsc(prettyprint_id($sub['target'])) . '</code>'; } else { echo '<code class="page">' . hsc(prettyprint_id($sub['target'])) . '</code>'; } $sstl = sprintf($lang['subscr_style_' . $sub['style']], $stime_days); if (!$sstl) { $sstl = hsc($sub['style']); } echo ' (' . $sstl . ') '; echo '<a href="' . wl($ID, array('do' => 'subscribe', 'sub_target' => $sub['target'], 'sub_style' => $sub['style'], 'sub_action' => 'unsubscribe', 'sectok' => getSecurityToken())) . '" class="unsubscribe">' . $lang['subscr_m_unsubscribe'] . '</a></div></li>'; } echo '</ul>'; } echo '</div>'; // Add new subscription form echo '<h2>' . $lang['subscr_m_new_header'] . '</h2>'; echo '<div class="level2">'; $ns = getNS($ID) . ':'; $targets = array($ID => '<code class="page">' . prettyprint_id($ID) . '</code>', $ns => '<code class="ns">' . prettyprint_id($ns) . '</code>'); $styles = array('every' => $lang['subscr_style_every'], 'digest' => sprintf($lang['subscr_style_digest'], $stime_days), 'list' => sprintf($lang['subscr_style_list'], $stime_days)); $form = new Doku_Form(array('id' => 'subscribe__form')); $form->startFieldset($lang['subscr_m_subscribe']); $form->addRadioSet('sub_target', $targets); $form->startFieldset($lang['subscr_m_receive']); $form->addRadioSet('sub_style', $styles); $form->addHidden('sub_action', 'subscribe'); $form->addHidden('do', 'subscribe'); $form->addHidden('id', $ID); $form->endFieldset(); $form->addElement(form_makeButton('submit', 'subscribe', $lang['subscr_m_subscribe'])); html_form('SUBSCRIBE', $form); echo '</div>'; }
/** * Renders the Index * * copy of html_index located in /inc/html.php * * TODO update to new AJAX index possible? * * @author Andreas Gohr <*****@*****.**> * @author Michael Klier <*****@*****.**> */ function p_index_xhtml($ns, $pos) { require_once DOKU_INC . 'inc/search.php'; global $conf; global $ID; $dir = $conf['datadir']; $ns = cleanID($ns); #fixme use appropriate function if (empty($ns)) { $ns = dirname(str_replace(':', '/', $ID)); if ($ns == '.') { $ns = ''; } } $ns = utf8_encodeFN(str_replace(':', '/', $ns)); // extract only the headline preg_match('/<h1>.*?<\\/h1>/', p_locale_xhtml('index'), $match); print preg_replace('#<h1(.*?id=")(.*?)(".*?)h1>#', '<h1\\1sidebar_' . $pos . '_\\2\\3h1>', $match[0]); $data = array(); search($data, $conf['datadir'], 'search_index', array('ns' => $ns)); print '<div id="' . $pos . '__index__tree">' . DOKU_LF; print html_buildlist($data, 'idx', 'html_list_index', 'html_li_index'); print '</div>' . DOKU_LF; }
/** * Form to request a new password for an existing account * * @author Benoit Chesneau <*****@*****.**> * @author Andreas Gohr <*****@*****.**> */ function html_resendpwd() { global $lang; global $conf; global $INPUT; $token = preg_replace('/[^a-f0-9]+/', '', $INPUT->str('pwauth')); if (!$conf['autopasswd'] && $token) { print p_locale_xhtml('resetpwd'); print '<div class="centeralign">' . NL; $form = new Doku_Form(array('id' => 'dw__resendpwd')); $form->startFieldset($lang['btn_resendpwd']); $form->addHidden('token', $token); $form->addHidden('do', 'resendpwd'); $form->addElement(form_makePasswordField('pass', $lang['pass'], '', 'block', array('size' => '50'))); $form->addElement(form_makePasswordField('passchk', $lang['passchk'], '', 'block', array('size' => '50'))); $form->addElement(form_makeButton('submit', '', $lang['btn_resendpwd'])); $form->endFieldset(); html_form('resendpwd', $form); print '</div>' . NL; } else { print p_locale_xhtml('resendpwd'); print '<div class="centeralign">' . NL; $form = new Doku_Form(array('id' => 'dw__resendpwd')); $form->startFieldset($lang['resendpwd']); $form->addHidden('do', 'resendpwd'); $form->addHidden('save', '1'); $form->addElement(form_makeTag('br')); $form->addElement(form_makeTextField('login', $INPUT->post->str('login'), $lang['user'], '', 'block')); $form->addElement(form_makeTag('br')); $form->addElement(form_makeTag('br')); $form->addElement(form_makeButton('submit', '', $lang['btn_resendpwd'])); $form->endFieldset(); html_form('resendpwd', $form); print '</div>' . NL; } }
<div class="page group"> <?php tpl_flush(); ?> <?php tpl_includeFile('pageheader.html'); ?> <!-- detail start --> <?php if ($ERROR) { echo '<h1>' . $ERROR . '</h1>'; } else { ?> <?php if ($REV) { echo p_locale_xhtml('showrev'); } ?> <h1><?php echo nl2br(hsc(tpl_img_getTag('simple.title'))); ?> </h1> <?php tpl_img(900, 700); /* parameters: maximum width, maximum height (and more) */ ?> <div class="img_detail"> <?php tpl_img_meta();
/** * Revised version of the html_show() */ function revised_html_show($txt = null) { // ---> Copied from html_show() - No code cleanups 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 = $this->revised_html_hilight($html, $HIGH); // <= REPLACED echo $html; } // <--- Copied from html_show() - No code cleanups }
/** * Form to request a new password for an existing account * * @author Benoit Chesneau <*****@*****.**> */ function html_resendpwd() { global $lang; global $conf; global $ID; print p_locale_xhtml('resendpwd'); print '<div class="centeralign">' . NL; $form = new Doku_Form(array('id' => 'dw__resendpwd')); $form->startFieldset($lang['resendpwd']); $form->addHidden('do', 'resendpwd'); $form->addHidden('save', '1'); $form->addElement(form_makeTag('br')); $form->addElement(form_makeTextField('login', $_POST['login'], $lang['user'], '', 'block')); $form->addElement(form_makeTag('br')); $form->addElement(form_makeTag('br')); $form->addElement(form_makeButton('submit', '', $lang['btn_resendpwd'])); $form->endFieldset(); html_form('resendpwd', $form); print '</div>' . NL; }
/** * * Show diff * between current page version and provided $text * or between the revisions provided via GET or POST * * @author Andreas Gohr <*****@*****.**> * @param string $text when non-empty: compare with this text with most current version * @param bool $intro display the intro text * @param string $type type of the diff (inline or sidebyside) */ function revisionsfull_html_diff($text = '', $intro = true, $type = null) { global $ID; global $REV; global $lang; global $INPUT; global $INFO; $pagelog = new PageChangeLog($ID); /* * Determine diff type */ if (!$type) { $type = $INPUT->str('difftype'); if (empty($type)) { $type = get_doku_pref('difftype', $type); if (empty($type) && $INFO['ismobile']) { $type = 'inline'; } } } if (!in_array($type, array('inline', 'sidebyside'))) { $type = 'full'; } /* * Determine requested revision(s) */ // we're trying to be clever here, revisions to compare can be either // given as rev and rev2 parameters, with rev2 being optional. Or in an // array in rev2. $rev1 = $REV; $rev2 = $INPUT->ref('rev2'); if (is_array($rev2)) { $rev1 = (int) $rev2[0]; $rev2 = (int) $rev2[1]; if (!$rev1) { $rev1 = $rev2; unset($rev2); } } else { $rev2 = $INPUT->int('rev2'); } /* * Determine left and right revision, its texts and the header */ $r_minor = ''; $l_minor = ''; if ($text) { // compare text to the most current revision $l_rev = ''; $l_text = rawWiki($ID, ''); $l_head = '<a class="wikilink1" href="' . wl($ID) . '">' . $ID . ' ' . dformat((int) @filemtime(wikiFN($ID))) . '</a> ' . $lang['current']; $r_rev = ''; $r_text = cleanText($text); $r_head = $lang['yours']; } else { if ($rev1 && isset($rev2) && $rev2) { // two specific revisions wanted // make sure order is correct (older on the left) if ($rev1 < $rev2) { $l_rev = $rev1; $r_rev = $rev2; } else { $l_rev = $rev2; $r_rev = $rev1; } } elseif ($rev1) { // single revision given, compare to current $r_rev = ''; $l_rev = $rev1; } else { // no revision was given, compare previous to current $r_rev = ''; $revs = $pagelog->getRevisions(0, 1); $l_rev = $revs[0]; $REV = $l_rev; // store revision back in $REV } // when both revisions are empty then the page was created just now if (!$l_rev && !$r_rev) { $l_text = ''; } else { $l_text = rawWiki($ID, $l_rev); } $r_text = rawWiki($ID, $r_rev); list($l_head, $r_head, $l_minor, $r_minor) = html_diff_head($l_rev, $r_rev, null, false, $type == 'inline'); } /* * Build navigation */ $l_nav = ''; $r_nav = ''; if (!$text) { list($l_nav, $r_nav) = html_diff_navigation($pagelog, $type, $l_rev, $r_rev); } /* * Create diff object and the formatter */ $diff = new Diff(explode("\n", $l_text), explode("\n", $r_text)); if ($type == 'inline') { $diffformatter = new InlineDiffFormatter(); } elseif ($type == 'sidebyside') { $diffformatter = new TableDiffFormatter(); } else { $diffformatter = new FullTableDiffFormatter(); } /* * Display intro */ if ($intro) { print p_locale_xhtml('diff'); } /* * Display type and exact reference */ if (!$text) { ptln('<div class="diffoptions group">'); $form = new Doku_Form(array('action' => wl())); $form->addHidden('id', $ID); $form->addHidden('rev2[0]', $l_rev); $form->addHidden('rev2[1]', $r_rev); $form->addHidden('do', 'diff'); $form->addElement(form_makeListboxField('difftype', array('full' => 'Full Side by Side', 'sidebyside' => $lang['diff_side'], 'inline' => $lang['diff_inline']), $type, $lang['diff_type'], '', '', array('class' => 'quickselect'))); $form->addElement(form_makeButton('submit', 'diff', 'Go')); $form->printForm(); ptln('<p>'); // link to exactly this view FS#2835 echo html_diff_navigationlink($type, 'difflink', $l_rev, $r_rev ? $r_rev : $INFO['currentrev']); ptln('</p>'); ptln('</div>'); // .diffoptions } /* * Display diff view table */ ?> <div class="table"> <table class="diff diff_<?php echo $type; ?> "> <?php //navigation and header if ($type == 'inline') { if (!$text) { ?> <tr> <td class="diff-lineheader">-</td> <td class="diffnav"><?php echo $l_nav; ?> </td> </tr> <tr> <th class="diff-lineheader">-</th> <th <?php echo $l_minor; ?> > <?php echo $l_head; ?> </th> </tr> <?php } ?> <tr> <td class="diff-lineheader">+</td> <td class="diffnav"><?php echo $r_nav; ?> </td> </tr> <tr> <th class="diff-lineheader">+</th> <th <?php echo $r_minor; ?> > <?php echo $r_head; ?> </th> </tr> <?php } else { if (!$text) { ?> <tr> <td colspan="2" class="diffnav"><?php echo $l_nav; ?> </td> <td colspan="2" class="diffnav"><?php echo $r_nav; ?> </td> </tr> <?php } ?> <tr> <th colspan="2" <?php echo $l_minor; ?> > <?php echo $l_head; ?> </th> <th colspan="2" <?php echo $r_minor; ?> > <?php echo $r_head; ?> </th> </tr> <?php } //diff view echo html_insert_softbreaks($diffformatter->format($diff)); ?> </table> </div> <?php }
/** * function _print * @author Myron Turner */ function _print() { global $INFO; global $lang; global $ckgedit_lang; global $ID; global $REV; global $DATE; global $PRE; global $SUF; global $SUM; $wr = $INFO['writable']; if ($wr) { if ($REV) { print p_locale_xhtml('editrev'); } $ro = false; } else { // check pseudo action 'source' if (!actionOK('source')) { msg('Command disabled: source', -1); return false; } print p_locale_xhtml('read'); $ro = 'readonly="readonly"'; } if (!$DATE) { $DATE = $INFO['lastmod']; } $guest_toolbar = $this->getConf('guest_toolbar'); $guest_media = $this->getConf('guest_media'); if (!isset($INFO['userinfo']) && !$guest_toolbar) { $toolbar = "DokuwikiNoGuest"; } else { if (!isset($INFO['userinfo']) && !$guest_media) { $toolbar = "DokuwikiGuest"; } else { $toolbar = 'Dokuwiki'; } } $height = isset($_COOKIE['ckgEdht']) && $_COOKIE['ckgEdht'] ? $_COOKIE['ckgEdht'] : 250; $doku_url = rtrim(DOKU_URL, '/'); $ckeditor_replace = <<<CKEDITOR_REPLACE \t\t ckgeditCKInstance = CKEDITOR.replace('wiki__text', \t\t { toolbar: '{$toolbar}' , height: {$height}, filebrowserImageBrowseUrl : '{$doku_url}/lib/plugins/ckgedit/fckeditor/editor/filemanager/browser/default/browser.html?Type=Image&Connector={$doku_url}/lib/plugins/ckgedit/fckeditor/editor/filemanager/connectors/php/connector.php', filebrowserBrowseUrl: '{$doku_url}/lib/plugins/ckgedit/fckeditor/editor/filemanager/browser/default/browser.html?Type=File&Connector={$doku_url}/lib/plugins/ckgedit/fckeditor/editor/filemanager/connectors/php/connector.php', } \t\t ); FCKeditor_OnComplete(ckgeditCKInstance); CKEDITOR_REPLACE; echo $this->helper->registerOnLoad($ckeditor_replace); global $skip_styling; ?> <form id="dw__editform" method="post" action="<?php echo script(); ?> " accept-charset="<?php echo $lang['encoding']; ?> "> <div class="no"> <input type="hidden" name="id" value="<?php echo $ID; ?> " /> <input type="hidden" name="rev" value="<?php echo $REV; ?> " /> <input type="hidden" name="date" value="<?php echo $DATE; ?> " /> <input type="hidden" name="prefix" value="<?php echo formText($PRE); ?> " /> <input type="hidden" name="suffix" value="<?php echo formText($SUF); ?> " /> <input type="hidden" id="ckgedit_mode_type" name="mode" value="" /> <input type="hidden" id="fck_preview_mode" name="fck_preview_mode" value="nil" /> <input type="hidden" id="fck_wikitext" name="fck_wikitext" value="__false__" /> <input type="hidden" id="styling" name="styling" value="styles" /> <?php if (function_exists('formSecurityToken')) { formSecurityToken(); } ?> </div> <textarea name="wikitext" id="wiki__text" <?php echo $ro; ?> cols="80" rows="10" class="edit" tabindex="1"><?php echo "\n" . $this->xhtml; ?> </textarea> <?php $temp = array(); trigger_event('HTML_EDITFORM_INJECTION', $temp); $DW_EDIT_disabled = ''; $guest_perm = auth_quickaclcheck($_REQUEST['id']); $guest_group = false; $guest_user = false; if (isset($INFO['userinfo']) && isset($INFO['userinfo']['grps'])) { $user_groups = $INFO['userinfo']['grps']; if (is_array($user_groups) && $user_groups) { foreach ($user_groups as $group) { if (strcasecmp('guest', $group) == 0) { $guest_group = true; break; } } } if ($INFO['client'] == 'guest') { $guest_user = true; } } if (($guest_user || $guest_group) && $guest_perm <= 2) { $DW_EDIT_disabled = 'disabled'; } $DW_EDIT_hide = $this->dw_edit_displayed(); $is_ckgeditChrome = false; if (stripos($_SERVER['HTTP_USER_AGENT'], 'Chrome') !== false) { preg_match("/Chrome\\/(\\d+)/", $_SERVER['HTTP_USER_AGENT'], $cmatch); if ((int) $cmatch[1] < 26) { $is_ckgeditChrome = true; } } ?> <div id="wiki__editbar"> <div id="size__ctl" style="display: none"></div> <?php if ($wr) { ?> <div class="editButtons"> <input type="checkbox" name="ckgedit" value="ckgedit" checked="checked" style="display: none"/> <input class="button" type="button" id = "save_button" name="do[save]" value="<?php echo $lang['btn_save']; ?> " title="<?php echo $lang['btn_save']; ?> " <?php echo $DW_EDIT_disabled; ?> /> <input class="button" id="ebtn__delete" type="submit" <?php echo $DW_EDIT_disabled; ?> name="do[delete]" value="<?php echo $lang['btn_delete']; ?> " title="<?php echo $this->getLang('title_dw_delete'); ?> " style = "font-size: 100%;" /> <?php if (!$is_ckgeditChrome) { ?> <input class="button" id = "ebtn__dwedit" <?php echo $DW_EDIT_disabled; ?> <?php echo $DW_EDIT_hide; ?> style = "font-size: 100%;" type="submit" name="do[save]" value="<?php echo $this->getLang('btn_dw_edit'); ?> " title="<?php echo $this->getLang('title_dw_edit'); ?> " /> <?php } global $INFO; $disabled = 'Disabled'; $inline = $this->test ? 'inline' : 'none'; $chrome_dwedit_link = '<a href="' . wl($INFO['id'], array('do' => 'show')) . '" ' . 'onclick="draft_delete();setDWEditCookie(2);"class="action edit" rel="nofollow" title="DW Edit"><span>DW Edit</span></a>'; $backup_btn = $this->getLang('dw_btn_backup') ? $this->getLang('dw_btn_backup') : $this->getLang('dw_btn_refresh'); $backup_title = $this->getLang('title_dw_backup') ? $this->getLang('title_dw_backup') : $this->getLang('title_dw_refresh'); $using_scayt = $this->getConf('scayt') == 'on'; ?> <input class="button" type="submit" name="do[draftdel]" id = "ebut_cancel" value="<?php echo $lang['btn_cancel']; ?> " style = "font-size: 100%;" title = "<?php echo $this->getLang('title_dw_cancel'); ?> " /> <!-- aspell button removed, not supported --> <input class="button" type="button" value = "Test" title="Test" style = 'display:<?php echo $inline; ?> ;' onmousedown="parse_wikitext('test');" /> <?php if ($this->draft_found) { ?> <input class="button" style = "background-color: yellow" id="ckgedit_draft_btn" type="button" value="<?php echo $this->getLang('btn_draft'); ?> " title="<?php echo $this->getLang('title_draft'); ?> " /> <?php } else { ?> <input class="button" type="button" id = "backup_button" value="<?php echo $backup_btn; ?> " title="<?php echo $backup_title; ?> " /> <input class="button" type="button" id = "revert_to_prev_btn" value="<?php echo $this->getLang('dw_btn_revert'); ?> " title="<?php echo $this->getLang('title_dw_revert'); ?> " /> <?php if (!$skip_styling) { ?> <input class="button" type="submit" name ="do[edit]" id = "no_styling_btn" style = "font-size: 100%;" value="<?php echo $this->getLang('dw_btn_styling'); ?> " title="<?php echo $this->getLang('title_styling'); ?> " /> <?php } ?> <?php if ($is_ckgeditChrome) { echo $chrome_dwedit_link; } ?> <br /> <?php } ?> <?php if ($this->debug) { ?> <input class="button" type="button" value = "Debug" title="Debug" onclick="HTMLParser_debug();" /> <br /> <?php } ?> <div id = "backup_msg" class="backup_msg" style=" display:none;"> <table><tr><td class = "backup_msg_td"> <div id="backup_msg_area" class="backup_msg_area"></div> <td> <td align="right"> <a href="javascript:hide_backup_msg();void(0);" class="backup_msg_close">[ close ]</a> </table> </div> <label class="nowrap" for="complex_tables" > <input type="checkbox" name="complex_tables" value="complex_tables" id = "complex_tables" /><span id='complex_tables_label'> <?php echo $this->getLang('complex_tables'); ?> </span></label> <label class="nowrap" for="editor_height"><?php echo $this->getLang('editor_height'); ?> </label> <input type="text" size= "4" name="editor_height" title = "<?php echo $this->getLang('editor_height_title'); ?> " value="<?php echo $height; ?> " id = "editor_height" onchange="setEdHeight(this.value);" /> px <input style="display:none;" class="button" id="edbtn__save" type="submit" name="do[save]" value="<?php echo $lang['btn_save']; ?> " onmouseup="draft_delete();" <?php echo $DW_EDIT_disabled; ?> title="<?php echo $lang['btn_save']; ?> " /> <!-- Not used by ckgedit but required to prevent null error when DW adds events --> <input type="button" id='edbtn__preview' style="display: none"/> <div id='saved_wiki_html' style = 'display:none;' ></div> <div id='ckgedit_draft_html' style = 'display:none;' > <?php echo $this->draft_text; ?> </div> </div> <?php } ?> <?php if ($wr) { ?> <div class="summary"> <label for="edit__summary" class="nowrap"><?php echo $lang['summary']; ?> :</label> <input type="text" class="edit" name="summary" id="edit__summary" size="50" value="<?php echo formText($SUM); ?> " tabindex="2" /> <label class="nowrap" for="minoredit"><input type="checkbox" id="minoredit" name="minor" value="1" tabindex="3" /> <span><?php echo $this->getLang('minor_changes'); ?> </span></label> </div> <?php } ?> </div> </form> <!-- draft messages from DW --> <div id="draft__status"></div> <script type="text/javascript"> //<![CDATA[ <?php echo 'var backup_empty = "' . $this->getLang('backup_empty') . '";'; ?> /* aspell_window removed, not supported */ if(window.unsetDokuWikiLockTimer) window.unsetDokuWikiLockTimer(); function getComplexTables() { return document.getElementById('complex_tables').checked; } <?php global $useComplexTables; if ($useComplexTables) { ?> document.getElementById('complex_tables').click(); <?php } ?> <?php if ($this->getConf('complex_tables')) { ?> document.getElementById('complex_tables').disabled = true; <?php } ?> <?php if (preg_match("/MISIE|Trident/", $_SERVER['HTTP_USER_AGENT'])) { echo "var isIE = true;"; } else { echo "var isIE = false;"; } echo "var doku_base = '" . DOKU_BASE . "'"; ?> var ckgedit_draft_btn = "<?php echo $this->getLang('btn_exit_draft'); ?> "; var ckgedit_draft_btn_title = "<?php echo $this->getLang('title_exit_draft'); ?> "; function ckgedit_get_draft() { var dom = GetE('ckgedit_draft_html'); var draft = dom.innerHTML; var dw_text = CKEDITOR.instances.wiki__text.getData(); CKEDITOR.instances.wiki__text.setData(draft); dom.innerHTML = dw_text; var btn = GetE('ckgedit_draft_btn'); var tmp = btn.value; btn.value = ckgedit_draft_btn; ckgedit_draft_btn = tmp; tmp = ckgedit_draft_btn_title; btn.title = ckgedit_draft_btn_title; ckgedit_draft_btn_title = tmp; } function safe_convert(value) { if(oDokuWiki_FCKEditorInstance.dwiki_fnencode && oDokuWiki_FCKEditorInstance.dwiki_fnencode == 'safe') { <?php global $updateVersion; if (!isset($updateVersion)) { $updateVersion = 0; } echo "updateVersion={$updateVersion};"; $list = plugin_list('action'); $safe_converted = false; if (in_array('safefnrecode', $list)) { $safe_converted = true; } ?> if(value.match(/%25/ && value.match(/%25[a-z0-9]/))) { value = value.replace(/%25/g,"%"); <?php if ($updateVersion > 30 || $safe_converted) { echo 'value = value.replace(/%5D/g,"]");'; } ?> value = dwikiUTF8_decodeFN(value,'safe'); } } return value; } RegExp.escape = function(str) { var specials = new RegExp("[.*+?|()\\[\\]{}\\\\]", "g"); // .*+?|()[]{}\ return str.replace(specials, "\\$&"); } var ckgedit_xcl_fonts =parseInt ("<?php echo $this->getConf('font_options'); ?> "); var ckgedit_xcl_colors =parseInt("<?php echo $this->getConf('color_options'); ?> "); var ckgedit_xcl_styles = (ckgedit_xcl_fonts + ckgedit_xcl_colors ==2) ? true : false; var HTMLParser_DEBUG = ""; <?php if ($this->debug) { ?> function HTMLParser_debug() { HTMLParser_DEBUG = ""; parse_wikitext(""); /* for(var i in oDokuWiki_FCKEditorInstance) { HTMLParser_DEBUG += i + ' = ' + oDokuWiki_FCKEditorInstance[i] + "\n";; } */ var w = window.open(); w.document.write('<pre>' + HTMLParser_DEBUG + '</pre>'); w.document.close(); } <?php } ?> <?php $url = DOKU_URL . 'lib/plugins/ckgedit/scripts/script-cmpr.js'; echo "var script_url = '{$url}';"; if ($this->test) { $parse_url = DOKU_URL . 'lib/plugins/ckgedit/scripts/parse_wiki.js.unc'; } else { $parse_url = DOKU_URL . 'lib/plugins/ckgedit/scripts/parse_wiki-cmpr.js'; } echo "var parse_url = '{$parse_url}';"; // $safe_url = DOKU_URL . 'lib/plugins/ckgedit/scripts/safeFN_cmpr.js'; ?> LoadScript(parse_url); try { if(!window.HTMLParserInstalled){ LoadScript(script_url); } } catch (ex) { LoadScript(script_url); } if(window.DWikifnEncode && window.DWikifnEncode == 'safe') { LoadScript(DOKU_BASE + 'lib/plugins/ckgedit/scripts/safeFN_cmpr.js' ); } //]]> </script> <?php }
function tpl_content_core() { global $ACT; global $TEXT; global $PRE; global $SUF; global $SUM; global $IDX; switch ($ACT) { case 'show': html_show(); break; case 'preview': html_edit($TEXT); html_show($TEXT); break; case 'recover': html_edit($TEXT); break; case 'edit': html_edit(); break; case 'draft': html_draft(); break; case 'wordblock': html_edit($TEXT, 'wordblock'); break; case 'search': html_search(); break; case 'revisions': $first = is_numeric($_REQUEST['first']) ? intval($_REQUEST['first']) : 0; html_revisions($first); break; case 'diff': html_diff(); break; case 'recent': if (is_array($_REQUEST['first'])) { $_REQUEST['first'] = array_keys($_REQUEST['first']); $_REQUEST['first'] = $_REQUEST['first'][0]; } $first = is_numeric($_REQUEST['first']) ? intval($_REQUEST['first']) : 0; html_recent($first); break; case 'index': html_index($IDX); #FIXME can this be pulled from globals? is it sanitized correctly? break; case 'backlink': html_backlinks(); break; case 'conflict': html_conflict(con($PRE, $TEXT, $SUF), $SUM); html_diff(con($PRE, $TEXT, $SUF), false); break; case 'locked': html_locked(); html_edit(); break; case 'login': html_login(); break; case 'register': html_register(); break; case 'resendpwd': html_resendpwd(); break; case 'denied': print p_locale_xhtml('denied'); break; case 'profile': html_updateprofile(); break; case 'admin': tpl_admin(); break; default: $evt = new Doku_Event('TPL_ACT_UNKNOWN', $ACT); if ($evt->advise_before()) { msg("Failed to handle command: " . hsc($ACT), -1); } $evt->advise_after(); unset($evt); return false; } return true; }
/** * Form to request a new password for an existing account * * @author Benoit Chesneau <*****@*****.**> */ function html_resendpwd() { global $lang; global $conf; global $ID; print p_locale_xhtml('resendpwd'); ?> <div class="centeralign"> <form id="dw__resendpwd" action="<?php echo wl($ID); ?> " accept-charset="<?php echo $lang['encoding']; ?> " method="post"> <fieldset> <br /> <legend><?php echo $lang['resendpwd']; ?> </legend> <input type="hidden" name="do" value="resendpwd" /> <input type="hidden" name="save" value="1" /> <label class="block"> <span><?php echo $lang['user']; ?> </span> <input type="text" name="login" value="<?php echo formText($_POST['login']); ?> " class="edit" /><br /><br /> </label><br /> <input type="submit" value="<?php echo $lang['btn_resendpwd']; ?> " class="button" /> </fieldset> </form> </div> <?php }
function xhtml_comment_preview($data) { global $lang; // FIXME ptln('<div id="blogtng__comment_preview">'); ptln(p_locale_xhtml('preview')); ptln('<br />'); $comment = new blogtng_comment(); $comment->init($data); $comment->output('default'); ptln('</div>'); }
/** * function _print * @author Myron Turner */ function _print() { global $INFO; global $lang; global $fckg_lang; global $ID; global $REV; global $DATE; global $PRE; global $SUF; global $SUM; $wr = $INFO['writable']; if ($wr) { if ($REV) { print p_locale_xhtml('editrev'); } $ro = false; } else { // check pseudo action 'source' if (!actionOK('source')) { msg('Command disabled: source', -1); return false; } print p_locale_xhtml('read'); $ro = 'readonly="readonly"'; } if (!$DATE) { $DATE = $INFO['lastmod']; } $guest_toolbar = $this->getConf('guest_toolbar'); $guest_media = $this->getConf('guest_media'); if (!isset($INFO['userinfo']) && !$guest_toolbar) { echo $this->helper->registerOnLoad(' fck = new FCKeditor("wiki__text", "100%", "600"); fck.BasePath = "' . DOKU_BASE . 'lib/plugins/fckg/' . $this->fck_location . '/"; fck.ToolbarSet = "DokuwikiNoGuest"; fck.ReplaceTextarea();'); } else { if (!isset($INFO['userinfo']) && !$guest_media) { echo $this->helper->registerOnLoad(' fck = new FCKeditor("wiki__text", "100%", "600"); fck.BasePath = "' . DOKU_BASE . 'lib/plugins/fckg/' . $this->fck_location . '/"; fck.ToolbarSet = "DokuwikiGuest"; fck.ReplaceTextarea();'); } else { echo $this->helper->registerOnLoad(' fck = new FCKeditor("wiki__text", "100%", "600"); fck.BasePath = "' . DOKU_BASE . 'lib/plugins/fckg/' . $this->fck_location . '/"; fck.ToolbarSet = "Dokuwiki"; fck.ReplaceTextarea();'); } } ?> <form id="dw__editform" method="post" action="<?php echo script(); ?> " accept-charset="<?php echo $lang['encoding']; ?> "> <div class="no"> <input type="hidden" name="id" value="<?php echo $ID; ?> " /> <input type="hidden" name="rev" value="<?php echo $REV; ?> " /> <input type="hidden" name="date" value="<?php echo $DATE; ?> " /> <input type="hidden" name="prefix" value="<?php echo formText($PRE); ?> " /> <input type="hidden" name="suffix" value="<?php echo formText($SUF); ?> " /> <input type="hidden" id="fckg_mode_type" name="mode" value="" /> <input type="hidden" id="fck_preview_mode" name="fck_preview_mode" value="nil" /> <input type="hidden" id="fck_wikitext" name="fck_wikitext" value="__false__" /> <?php if (function_exists('formSecurityToken')) { formSecurityToken(); } ?> </div> <textarea name="wikitext" id="wiki__text" <?php echo $ro; ?> cols="80" rows="10" class="edit" tabindex="1"><?php echo "\n" . $this->xhtml; ?> </textarea> <?php $temp = array(); trigger_event('HTML_EDITFORM_INJECTION', $temp); $DW_EDIT_disabled = ''; $guest_perm = auth_quickaclcheck($_REQUEST['id']); $guest_group = false; $guest_user = false; if (isset($INFO['userinfo']) && isset($INFO['userinfo']['grps'])) { $user_groups = $INFO['userinfo']['grps']; if (is_array($user_groups) && $user_groups) { foreach ($user_groups as $group) { if (strcasecmp('guest', $group) == 0) { $guest_group = true; break; } } } if ($INFO['client'] == 'guest') { $guest_user = true; } } if (($guest_user || $guest_group) && $guest_perm <= 2) { $DW_EDIT_disabled = 'disabled'; } $DW_EDIT_hide = $this->dw_edit_displayed(); ?> <div id="wiki__editbar"> <div id="size__ctl"></div> <div id = "fck_size__ctl" style="display: none"> <img src = "<?php echo DOKU_BASE; ?> lib/images/smaller.gif" title="edit window smaller" onclick="dwfck_size_ctl('smaller');" /> <img src = "<?php echo DOKU_BASE; ?> lib/images/larger.gif" title="edit window larger" onclick="dwfck_size_ctl('larger');" /> </div> <?php if ($wr) { ?> <div class="editButtons"> <input type="checkbox" name="fckg" value="fckg" checked="checked" style="display: none"/> <input class="button" type="button" name="do[save]" value="<?php echo $lang['btn_save']; ?> " title="<?php echo $lang['btn_save']; ?> " <?php echo $DW_EDIT_disabled; ?> onmousedown="parse_wikitext('edbtn__save');" /> <input class="button" id="ebtn__delete" type="submit" <?php echo $DW_EDIT_disabled; ?> name="do[delete]" value="<?php echo $lang['btn_delete']; ?> " title="<?php echo $fckg_lang['title_dw_delete']; ?> " style = "font-size: 100%;" onmouseup="draft_delete();" onclick = "return confirm('<?php echo $fckg_lang['confirm_delete']; ?> ');" /> <input type="checkbox" name="fckg" value="fckg" style="display: none"/> <input class="button" <?php echo $DW_EDIT_disabled; ?> <?php echo $DW_EDIT_hide; ?> style = "font-size: 100%;" onclick ="setDWEditCookie(2, this);parse_wikitext('edbtn__save');this.form.submit();" type="submit" name="do[save]" value="<?php echo $fckg_lang['btn_dw_edit']; ?> " title="<?php echo $fckg_lang['title_dw_edit']; ?> " /> <?php global $INFO; $disabled = 'Disabled'; $inline = $this->test ? 'inline' : 'none'; $backup_btn = isset($fckg_lang['dw_btn_backup']) ? $fckg_lang['dw_btn_backup'] : $fckg_lang['dw_btn_refresh']; $backup_title = isset($fckg_lang['title_dw_backup']) ? $fckg_lang['title_dw_backup'] : $fckg_lang['title_dw_refresh']; $using_scayt = $this->getConf('scayt') == 'on'; ?> <input class="button" type="submit" name="do[draftdel]" value="<?php echo $lang['btn_cancel']; ?> " onmouseup="draft_delete();" style = "font-size: 100%;" title = "<?php echo $fckg_lang['title_dw_cancel']; ?> " /> <?php if (!$using_scayt) { ?> <input class="button" type="button" value = "<?php echo $fckg_lang['dw_btn_lang']; ?> " title="<?php echo $fckg_lang['title_dw_lang']; ?> " onclick="aspell_window();" /> <?php } ?> <input class="button" type="button" value = "Test" title="Test" style = 'display:<?php echo $inline; ?> ;' onmousedown="parse_wikitext('test');" /> <?php if ($this->draft_found) { ?> <input class="button" onclick ="fckg_get_draft();" style = "background-color: yellow" id="fckg_draft_btn" type="button" value="<?php echo $fckg_lang['btn_draft']; ?> " title="<?php echo $fckg_lang['title_draft']; ?> " /> <?php } else { ?> <input class="button" type="button" value="<?php echo $backup_btn; ?> " title="<?php echo $backup_title; ?> " onclick="renewLock(true);" /> <input class="button" type="button" value="<?php echo $fckg_lang['dw_btn_revert']; ?> " title="<?php echo $fckg_lang['title_dw_revert']; ?> " onclick="revert_to_prev()" /> <br /> <?php } ?> <?php if ($this->debug) { ?> <input class="button" type="button" value = "Debug" title="Debug" onclick="HTMLParser_debug();" /> <br /> <?php } ?> <div id = "backup_msg" class="backup_msg" style=" display:none;"> <table><tr><td class = "backup_msg_td"> <div id="backup_msg_area" class="backup_msg_area"></div> <td> <td align="right"> <a href="javascript:hide_backup_msg();void(0);" class="backup_msg_close">[ close ]</a> </table> </div> <input type="checkbox" name="fckg_timer" value="fckg_timer" id = "fckg_timer" style = 'display:none' onclick="disableDokuWikiLockTimer();" <?php echo $disabled; ?> /><span id='fckg_timer_label' style = 'display:none'>Disable editor time-out messsages </span> <?php //global $useComplexTables; if(!$useComplexTables) { ?> <label class="nowrap" for="complex_tables" > <input type="checkbox" name="complex_tables" value="complex_tables" id = "complex_tables" onclick="setComplexTables(1);" /><span id='complex_tables_label'> <?php echo $fckg_lang['complex_tables']; ?> (<a href="https://www.dokuwiki.org/plugin:fckglite#table_handling" target='_blank'><?php echo $fckg_lang['whats_this']; ?> </a>)</span></label> <?php //} ?> <input style="display:none;" class="button" id="edbtn__save" type="submit" name="do[save]" value="<?php echo $lang['btn_save']; ?> " onmouseup="draft_delete();" <?php echo $DW_EDIT_disabled; ?> title="<?php echo $lang['btn_save']; ?> " /> <!-- Not used by fckgLite but required to prevent null error when DW adds events --> <input type="button" id='edbtn__preview' style="display: none"/> <div id='saved_wiki_html' style = 'display:none;' ></div> <div id='fckg_draft_html' style = 'display:none;' > <?php echo $this->draft_text; ?> </div> <script type="text/javascript"> //<![CDATA[ var embedComplexTableMacro = false; <?php echo 'var backup_empty = "' . $fckg_lang['backup_empty'] . '";'; ?> function aspell_window() { var DURL = "<?php echo DOKU_URL; ?> "; window.open( DURL + "/lib/plugins/fckg/fckeditor/aspell.php?dw_conf_lang=<?php global $conf; echo $conf['lang']; ?> ", "smallwin", "width=600,height=500,scrollbars=yes"); } if(unsetDokuWikiLockTimer) unsetDokuWikiLockTimer(); function dwfck_size_ctl(which) { var height = parseInt(document.getElementById('wiki__text___Frame').style.height); if(which == 'smaller') { height -= 50; } else { height += 50; } document.getElementById('wiki__text___Frame').style.height = height + 'px'; } setComplexTables = (function() { var on=false; return function(b) { if(b) on = !on; embedComplexTableMacro = on; return on; }; })(); <?php global $useComplexTables; if ($useComplexTables) { ?> document.getElementById('complex_tables').click(); <?php } ?> var fckgLPluginPatterns = new Array(); <?php global $fckgLPluginPatterns; $utf8Chars = array('À', 'Á', 'Â', 'Ã', 'Ä', 'Å', 'Æ', 'Ç', 'È', 'É', 'Ê', 'Ë', 'Ì', 'Í', 'Î', 'Ï', 'Ð', 'Ñ', 'Ò', 'Ó', 'Ô', 'Õ', 'Ö', 'Ø', 'Ù', 'Ú', 'Û', 'Ü', 'Ý', 'Þ', 'ß', 'à', 'á', 'â', 'ã', 'ä', 'å', 'æ', 'ç', 'è', 'é', 'ê', 'ë', 'ì', 'í', 'î', 'ï', 'ð', 'ñ', 'ò', 'ó', 'ô', 'õ', 'ö', 'ø', 'ù', 'ú', 'û', 'ü', 'ý', 'þ', 'ÿ', 'Œ', 'œ', 'Š', 'š', 'Ÿ', 'ƒ'); $utf8Replacments = array('À', 'Á', 'Â', 'Ã', 'Ä', 'Å', 'Æ', 'Ç', 'È', 'É', 'Ê', 'Ë', 'Ì', 'Í', 'Î', 'Ï', 'Ð', 'Ñ', 'Ò', 'Ó', 'Ô', 'Õ', 'Ö', 'Ø', 'Ù', 'Ú', 'Û', 'Ü', 'Ý', 'Þ', 'ß', 'à', 'á', 'â', 'ã', 'ä', 'å', 'æ', 'ç', 'è', 'é', 'ê', 'ë', 'ì', 'í', 'î', 'ï', 'ð', 'ñ', 'ò', 'ó', 'ô', 'õ', 'ö', 'ø', 'ù', 'ú', 'û', 'ü', 'ý', 'þ', 'ÿ', 'Œ', 'œ', 'Š', 'š', 'Ÿ', 'ƒ'); foreach ($fckgLPluginPatterns as $pat) { $pat[0] = preg_replace('/\\s+$/', "", $pat[0]); $pat[1] = str_replace('&', '&', $pat[1]); $pat[0] = str_replace('&', '&', $pat[0]); $pat[0] = str_replace('>', '>', $pat[0]); $pat[0] = str_replace('<', '<', $pat[0]); $pat[1] = str_replace('>', '>', $pat[1]); $pat[1] = str_replace('<', '<', $pat[1]); $pat[0] = preg_replace('/\\s+/', '\\s+', $pat[0]); $pat[0] = str_replace('*', '%%\\*%%', $pat[0]); $pat[0] = str_replace($utf8Chars, $utf8Replacments, $pat[0]); $pat[0] = preg_quote($pat[0], "/"); echo "fckgLPluginPatterns.push({'pat': '{$pat['0']}', 'orig': '{$pat['1']}' });\n"; } global $fckLImmutables; echo "if(!fckLImmutables) var fckLImmutables = new Array();\n"; for ($i = 0; $i < count($fckLImmutables); $i++) { echo "fckLImmutables.push('{$fckLImmutables[$i]}');\n"; } $pos = strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE'); if ($pos === false) { echo "var isIE = false;"; } else { echo "var isIE = true;"; } echo "var doku_base = '" . DOKU_BASE . "'"; ?> var fckg_draft_btn = "<?php echo $fckg_lang['btn_exit_draft']; ?> "; var fckg_draft_btn_title = "<?php echo $fckg_lang['title_exit_draft']; ?> "; function fckg_get_draft() { var dom = GetE('fckg_draft_html'); var draft = dom.innerHTML; var dw_text = oDokuWiki_FCKEditorInstance.GetData( true ); oInst = oDokuWiki_FCKEditorInstance.get_FCK(); oInst =oInst.EditorDocument.body; oInst.innerHTML = draft; dom.innerHTML = dw_text; var btn = GetE('fckg_draft_btn'); var tmp = btn.value; btn.value = fckg_draft_btn; fckg_draft_btn = tmp; tmp = fckg_draft_btn_title; btn.title = fckg_draft_btn_title; fckg_draft_btn_title = tmp; } function safe_convert(value) { if(oDokuWiki_FCKEditorInstance.dwiki_fnencode && oDokuWiki_FCKEditorInstance.dwiki_fnencode == 'safe') { <?php global $updateVersion; if (!isset($updateVersion)) { $updateVersion = 0; } echo "updateVersion={$updateVersion};"; $list = plugin_list('action'); $safe_converted = false; if (in_array('safefnrecode', $list)) { $safe_converted = true; } ?> if(value.match(/%25/ && value.match(/%25[a-z0-9]/))) { value = value.replace(/%25/g,"%"); <?php if ($updateVersion > 30 || $safe_converted) { echo 'value = value.replace(/%5D/g,"]");'; } ?> value = dwikiUTF8_decodeFN(value,'safe'); } } return value; } RegExp.escape = function(str) { var specials = new RegExp("[.*+?|()\\[\\]{}\\\\]", "g"); // .*+?|()[]{}\ return str.replace(specials, "\\$&"); } var HTMLParser_DEBUG = ""; function parse_wikitext(id) { var useComplexTables = setComplexTables(); var this_debug; <?php if ($this->debug) { ?> function show_rowspans(rows) { if(!useComplexTables) return; var str = ""; for(var i=0; i < rows.length; i++) { str+="ROW" + i + "\n"; for(var col=0; col<rows[i].length; col++) { str += "[" + col + "]"; str+= "text="+rows[i][col].text + " "; str+=" type="+rows[i][col].type + " "; str+= " rowspan=" +rows[i][col].rowspan + " "; str+= " colspan=" +rows[i][col].colspan + " "; } str += "\n"; } this_debug(str,'show_rowspans'); str = ""; for(var i=0; i < rows.length; i++) { for(var col=0; col<rows[i].length; col++) { str+= "|"+rows[i][col].text + " "; } str += "|\n"; } this_debug(str,'show_rowspans'); } function debug_row(rows,row,col,which) { var not_found = ""; try { this_debug("row:"+row +",column:"+col +", rowspans:"+ rows[row][col].rowspan +", colspans:"+ rows[row][col].colspan +", text:"+rows[row][col].text, which); }catch(ex) { not_found+="row:"+row +",column:"+col; } if(not_found) this_debug(not_found,"not_found"); } <?php } ?> function check_rowspans(rows,start_row, ini) { var tmp=new Array(); for(var i=start_row; i < rows.length; i++) { for(var col=0; col<rows[i].length; col++) { if(rows[i][col].rowspan > 0) { var _text = rows[i][col].text; tmp.push({row:i,column:col, spans: rows[i][col].rowspan,text:_text}); if(!ini) break; } } } return tmp; } function insert_rowspan(row,col,spans,rows,shift) { var prev_colspans = rows[row][col].colspan ? rows[row][col].colspan: 0; rows[row][col].rowspan = 0; for(i=0; i<spans-1;i++) { //debug_row(rows,row,col,"insert_rowspan start"); rows[++row].splice(col, 0,{type:'td', rowspan:0,colspan:prev_colspans,prev_colspan:prev_colspans,text:" ::: "}); } } function reorder_span_rows(rows) { var tmp_start = check_rowspans(rows,0,true); var num_spans = tmp_start.length; if(!num_spans) return false; var row = tmp_start[0].row; var col = tmp_start[0].column; insert_rowspan(row,col,tmp_start[0].spans,rows); num_spans--; for(var i=0; i < num_spans; i++) { row++; var tmp = check_rowspans(rows,row,false); if(tmp.length) { insert_rowspan(tmp[0].row,tmp[0].column,tmp[0].spans,rows); } } return true; } function insert_table(rows) { if(!useComplexTables) return; for(var i=0; i<rows.length;i++) { if(!reorder_span_rows(rows)) break;; } results+="\n"; for(var i=0; i < rows.length; i++) { results+="\n"; for(var col=0; col<rows[i].length; col++) { var type = rows[i][col].type == 'td'? '|': '^'; results+= type; var align = rows[i][col].align ? rows[i][col].align : false; if(align == 'center' || align == 'right') { results += " "; } results += rows[i][col].text; if(align == 'center' || align == 'left') { results += " "; } if(rows[i][col].colspan) { for(var n=0; n < rows[i][col].colspan-1; n++) { results+=type; } } } results += '|'; } } window.dwfckTextChanged = false; if(id != 'bakup') draft_delete(); var line_break = "\nL_BR_K \n"; var markup = { 'b': '**', 'i':'//', 'em': '//', 'u': '__', 'br':line_break, 'del': '<del>', 'strike': '<del>', p: "\n\n" , 'a':'[[', 'img': '\{\{', 'h1': "\n====== ", 'h2': "\n===== ", 'h3': "\n==== ", 'h4': "\n=== ", 'h5': "\n== ", 'td': "|", 'th': "^", 'tr':" ", 'table': "\n\n", 'ol':" - ", 'ul': " * ", 'li': "", 'plugin': '<plugin ', 'code': "\'\'",'pre': "\n<", 'hr': "\n\n----\n\n", 'sub': '<sub>', 'font': "\n", 'sup': '<sup>', 'div':"\n\n", 'span': "\n", 'dl': "\n", 'dd': "\n", 'dt': "\n" }; var markup_end = { 'del': '</del>', 'strike': '</del>', 'p': " ", 'br':" ", 'a': ']]','img': '\}\}', 'h1': " ======\n", 'h2': " =====\n", 'h3': " ====\n", 'h4': " ===\n", 'h5': " ==\n", 'td': " ", 'th': " ", 'tr':"|\n", 'ol':" ", 'ul': " ", 'li': "\n", 'plugin': '</plugin>', 'pre': "\n</",'sub': '</sub>', 'sup': '</sup> ', 'div':"\n\n", 'p': "\n\n", 'font': "</font> " }; markup['blank'] = ""; markup['fn_start'] = '(('; markup['fn_end'] = '))'; markup['row_span'] = ":::"; markup['p_insert'] = '_PARA__TABLE_INS_'; markup['format_space'] = '_FORMAT_SPACE_'; markup['pre_td'] = '<'; //removes newline from before < which corrupts table var format_chars = {'b':true, 'i': true, 'em':true,'u':true, 'del':true,'strike':true, 'code':true}; var results=""; var HTMLParser_LBR = false; var HTMLParser_PRE = false; var HTMLParser_Geshi = false; var HTMLParser_TABLE = false; var HTMLParser_COLSPAN = false; var HTMLParser_PLUGIN = false; var HTMLParser_FORMAT_SPACE = false; var HTMLParser_MULTI_LINE_PLUGIN = false; var HTMLParser_NOWIKI = false; var HTMLFormatInList = false; var HTMLAcroInList = false; var CurrentTable; var HTMLParserTopNotes = new Array(); var HTMLParserBottomNotes = new Array(); var HTMLParserOpenAngleBracket = false; var HTMLParserParaInsert = markup['p_insert']; // var geshi_classes = 'br0|co0|co1|co2|co3|coMULTI|es0|kw1|kw2|kw3|kw4|kw5|me1|me2|nu0|re0|re1|re2|re3|re4|st0|sy0|sy1|sy2|sy3|sy4'; var geshi_classes = '(br|co|coMULTI|es|kw|me|nu|re|st|sy)[0-9]'; String.frasl = new RegExp("⁄\|⁄\|⁄\|⁄",'g'); geshi_classes = new RegExp(geshi_classes); HTMLParser(oDokuWiki_FCKEditorInstance.GetData( true ), { attribute: "", link_title: "", link_class: "", image_link_type: "", td_align: "", in_td: false, td_colspan: 0, td_rowspan: 0, rowspan_col: 0, last_column: -1, row:0, col:0, // table_start: false, td_no: 0, tr_no: 0, current_row:false, in_table: false, in_multi_plugin: false, is_rowspan: false, list_level: 0, prev_list_level: -1, list_started: false, xcl_markup: false, in_link: false, link_formats: new Array(), last_tag: "", code_type: false, in_endnotes: false, is_smiley: false, geshi: false, downloadable_code: false, export_code: false, code_snippet: false, downloadable_file: "", external_mime: false, in_header: false, is_acronym: false, curid: false, format_in_list: false, prev_li: new Array(), immutable_plugin: false, link_only: false, in_font: false, interwiki: false, bottom_url: false, backup: function(c1,c2) { var c1_inx = results.lastIndexOf(c1); // start position of chars to delete var c2_inx = results.indexOf(c2,c1_inx); // position of expected next character if(c1_inx == -1 || c2_inx == -1) return; if(c1.length + c2_inx == c2_inx) { var left_side = results.substring(0,c1_inx); //from 0 up to but not including c1 var right_side = results.substring(c2_inx); //from c2 to end of string results = left_side + right_side; return true; } return false; }, start: function( tag, attrs, unary ) { this_debug = this.dbg; if(markup[tag]) { if(format_chars[tag] && this.in_link) { this.link_formats.push(tag); return; } if(format_chars[tag] && this.in_font) { return; } else if(tag == 'acronym') { return; } if(tag == 'ol' || tag == 'ul') { this.prev_list_level = this.list_level; this.list_level++; if(this.list_level == 1) this.list_started = false; if(this.list_started) this.prev_li.push(markup['li']) ; markup['li'] = markup[tag]; return; } else if(!this.list_level) { markup['li'] = ""; this.prev_li = new Array(); } if(tag == 'img') { var img_size="?"; var width; var height; var style = false; var img_align = ''; var alt = ""; this.is_smiley = false; this.in_link = false; } if(tag == 'a') { var local_image = true; var type = ""; this.xcl_markup = false; // set to false in end() as well, double sure this.in_link = true; this.link_pos = results.length; this.link_formats = new Array(); this.footnote = false; var bottom_note = false; this.id = ""; this.external_mime = false; var media_class=false; this.export_code = false; this.code_snippet = false; this.downloadable_file = ""; var qs_set = false; this.link_only = false; save_url = ""; this.interwiki=false; this.bottom_url=false; this.link_class=""; } if(tag == 'p') { this.in_link = false; if(this.in_table) { tag = 'p_insert'; HTMLParser_TABLE=true; } } else if(tag=='span') { var font_family = "arial"; var font_size = "9pt"; var font_weight = "normal"; var font_color; var font_bgcolor; } if(tag == 'table') { this.td_no = 0; this.tr_no = 0; this.in_table = true; this.is_rowspan = false; this.row=-1; this.rows = new Array(); CurrentTable = this.rows; this.table_start = results.length; } else if(tag == 'tr') { this.tr_no++; this.td_no = 0; this.col=-1; this.row++; this.rows[this.row] = new Array(); this.current_row = this.rows[this.row]; } else if(tag == 'td' || tag == 'th') { this.td_no++; this.col++; this.current_row[this.col] = {type:tag, rowspan:0,colspan:0,text:""}; this.cell_start = results.length; this.current_cell = this.current_row[this.col]; if(this.td_rowspan && this.rowspan_col == this.td_no && this.td_no != this.last_column) { this.is_rowspan = true; this.td_rowspan --; } else { this.is_rowspan = false; } } var matches; this.attr=false; this.format_tag = false; if(format_chars[tag])this.format_tag = true; var dwfck_note = false; for ( var i = 0; i < attrs.length; i++ ) { // if(!confirm(tag + ' ' + attrs[i].name + '="' + attrs[i].escaped + '"')) exit; if(tag == 'td' || tag == 'th') { // if(!confirm(tag + ' ' + attrs[i].name + '="' + attrs[i].escaped + '"')) exit; if(attrs[i].name =='colspan') { this.current_row[this.col].colspan = attrs[i].value; } if(attrs[i].name =='class') { if((matches=attrs[i].value.match(/(left|center|right)/))) { this.current_row[this.col].align = matches[1]; } } if(attrs[i].name == 'rowspan') { this.current_row[this.col].rowspan= attrs[i].value } } if(attrs[i].escaped == 'u' && tag == 'em' ) { tag = 'u'; this.attr='u' break; } if(tag == 'div') { if(attrs[i].name == 'class' && attrs[i].value == 'footnotes') { tag = 'blank'; this.in_endnotes = true; } break; } if(tag == 'dl' && attrs[i].name == 'class' && attrs[i].value == 'file') { this.downloadable_code = true; HTMLParser_Geshi = true; return; } if(tag == 'span' && attrs[i].name == 'class') { if(attrs[i].value == 'np_break') return; } if(tag == 'span' && attrs[i].name == 'class') { if(attrs[i].value =='curid') { this.curid = true; return; } if(attrs[i].value == 'multi_p_open') { this.in_multi_plugin = true; HTMLParser_MULTI_LINE_PLUGIN = true; return; } if(attrs[i].value == 'multi_p_close') { this.in_multi_plugin = false; return; } if(attrs[i].value.match(geshi_classes)) { tag = 'blank'; this.geshi = true; break; } } if(tag == 'span' && attrs[i].name == 'id') { if((matches= attrs[i].value.match(/imm_(\d+)/))) { this.immutable_plugin = fckLImmutables[matches[1]]; } } else if(tag == 'span') { if(attrs[i].name == 'face') { this.in_font=true; font_family = attrs[i].value; } if(attrs[i].name == 'style') { matches = attrs[i].value.match(/font-size:\s*(\d+(\w+|%))/); if(matches){ font_size = matches[1]; } matches = attrs[i].value.match(/font-weight:\s*(\w+)/); if(matches) { font_weight = matches[1]; } matches = attrs[i].value.match(/[^\-]color:\s*([#\w\s\d,\(\)]+);?/); if(matches) { font_color = matches[1]; } matches = attrs[i].value.match(/background[-]color:\s*([#\w\s\d,\(\)]+);?/i); if(matches) { font_bgcolor = matches[1]; } } else if(attrs[i].name == 'color') { font_color = attrs[i].value; } } if(tag == 'td' || tag == 'th') { if(tag == 'td') { results = results.replace(/\^$/,'|'); } this.in_td = true; if(attrs[i].name == 'align') { this.td_align =attrs[i].escaped; } else if(attrs[i].name == 'class') { matches = attrs[i].value.match(/\s+(\w+)align/); if(matches) { this.td_align = matches[1]; } } else if(attrs[i].name == 'colspan') { HTMLParser_COLSPAN = true; this.td_colspan =attrs[i].escaped; } else if(attrs[i].name == 'rowspan') { this.td_rowspan =attrs[i].escaped-1; this.rowspan_col = this.td_no; } HTMLParser_TABLE=true; } if(tag == 'a') { if(attrs[i].name == 'title') { this.link_title = attrs[i].escaped; this.link_title = this.link_title.replace(/\s+.*$/,"") ; } else if(attrs[i].name == 'class') { if(attrs[i].value.match(/fn_top/)) { this.footnote = true; } else if(attrs[i].value.match(/fn_bot/)) { bottom_note = true; } else if(attrs[i].value.match(/mf_(png|gif|jpg|jpeg)/i)) { this.link_only=true; } this.link_class= attrs[i].escaped; media_class = this.link_class.match(/mediafile/); } else if(attrs[i].name == 'id') { this.id = attrs[i].value; } else if(attrs[i].name == 'type') { type = attrs[i].value; } else if(attrs[i].name == 'href' && !this.code_type) { var http = attrs[i].escaped.match(/https*:\/\//) ? true : false; if(http) save_url = attrs[i].escaped; if(attrs[i].escaped.match(/\/lib\/exe\/detail.php/)) { this.image_link_type = 'detail'; } else if(attrs[i].escaped.match(/exe\/fetch.php/)) { this.image_link_type = 'direct'; } else { // nice urls using .htaccess var regex = new RegExp(DOKU_BASE + '_detail'); if(attrs[i].escaped.match(regex)) { this.image_link_type = 'detail'; } } // required to distinguish external images from external mime types // that are on the wiki which also use {{url}} var media_type = attrs[i].escaped.match(/fetch\.php.*?media=.*?\.(png|gif|jpg|jpeg)$/i); if(media_type) media_type = media_type[1]; if(attrs[i].escaped.match(/^https*:/)) { this.attr = attrs[i].escaped; local_image = false; } if(attrs[i].escaped.match(/^ftp:/)) { this.attr = attrs[i].escaped; local_image = false; } else if(attrs[i].escaped.match(/do=export_code/)) { this.export_code = true; } else if(attrs[i].escaped.match(/^nntp:/)) { this.attr = attrs[i].escaped; local_image = false; } else if(attrs[i].escaped.match(/^mailto:/)) { this.attr = attrs[i].escaped.replace(/mailto:/,""); local_image = false; } else if(attrs[i].escaped.match(/^file:/)) { //samba share var url= attrs[i].value.replace(/file:[\/]+/,""); url = url.replace(/[\/]/g,'\\'); url = '\\\\' + url; this.attr = url; local_image = false; } // external mime types after they've been saved first time else if(http && !media_type && (matches = attrs[i].escaped.match(/fetch\.php(.*)/)) ) { if(matches[1].match(/media=/)) { elems = matches[1].split(/=/); this.attr = elems[1]; } else { // nice urls matches[1] = matches[1].replace(/^\//,""); this.attr = matches[1]; } local_image = false; this.attr = decodeURIComponent ? decodeURIComponent(this.attr) : unescape(this.attr); if(!this.attr.match(/^:/)) { this.attr = ':' +this.attr; } this.external_mime = true; } else { local_image = false; matches = attrs[i].escaped.match(/doku.php\?id=(.*)/); if(!matches) { matches = attrs[i].escaped.match(/doku.php\/(.*)/); } /* previously saved internal link with query string requires initial ? to be recognized by DW. In Anteater and later */ if(matches) { if(!matches[1].match(/\?/) && matches[1].match(/&/)) { qs_set = true; matches[1] = matches[1].replace(/&/,'?') } } if(matches && matches[1]) { if(!matches[1].match(/^:/)) { this.attr = ':' + matches[1]; } else { this.attr = matches[1]; } if(this.attr.match(/\.\w+$/)) { // external mime's first access if(type && type == 'other_mime') { this.external_mime = true; } else { for(var n = i+1; n < attrs.length; n++) { if(attrs[n].value.match(/other_mime/)) this.external_mime = true; break; } } } } else { matches = attrs[i].value.match(/\\\\/); // Windows share if(matches) { this.attr = attrs[i].escaped; local_image = false; } } } if(this.link_class == 'media') { if(attrs[i].value.match(/http:/)) { local_image = false; } } if(!this.attr && this.link_title) { if(this.link_class == 'media') { this.attr=this.link_title; local_image = true; } } if(this.attr.match && this.attr.match(/%[a-fA-F0-9]{2}/) && (matches = this.attr.match(/userfiles\/file\/(.*)/))) { matches[1] = matches[1].replace(/\//g,':'); if(!matches[1].match(/^:/)) { matches[1] = ':' + matches[1]; } this.attr = decodeURIComponent ? decodeURIComponent(matches[1]) : unescape(matches[1]); this.attr = decodeURIComponent ? decodeURIComponent(this.attr) : unescape(this.attr); this.external_mime = true; } // alert('title: ' + this.link_title + ' class: ' + this.link_class + ' export: ' +this.export_code); if(this.link_title.match(/Snippet/)) this.code_snippet = true; /* anchors to current page without prefixing namespace:page */ if(attrs[i].value.match(/^#/) && this.link_class.match(/wikilink/)) { this.attr = attrs[i].value; this.link_title = false; } /* These two conditions catch user_rewrite not caught above */ if(this.link_class.match(/wikilink/) && this.link_title) { this.external_mime = false; if(!this.attr){ this.attr = this.link_title; } if(!this.attr.match(/^:/)) { this.attr = ':' + this.attr; } if(this.attr.match(/\?.*?=/)){ var elems = this.attr.split(/\?/); elems[0] = elems[0].replace(/\//g,':'); this.attr = elems[0] + '?' + elems[1]; } else { this.attr = this.attr.replace(/\//g,':'); } /* catch query strings attached to internal links for .htacess nice urls */ if(!qs_set && attrs[i].name == 'href') { if(!this.attr.match(/\?.*?=/) && !attrs[i].value.match(/doku.php/)) { var qs = attrs[i].value.match(/(\?.*)$/); if(qs && qs[1]) this.attr += qs[1]; } } } else if(this.link_class.match(/mediafile/) && this.link_title && !this.attr) { this.attr = this.link_title; this.external_mime = true; if(!this.attr.match(/^:/)) { this.attr = ':' + this.attr; } } else if(this.link_class.match(/interwiki/)) { var iw_type = this.link_class.match(/iw_(\w+)/); var iw_title = this.link_title.split(/\//); var interwiki_label = iw_title[iw_title.length-1]; interwiki_label = interwiki_label.replace(String.frasl,"\/"); this.attr = iw_type[1] + '>' + interwiki_label; this.interwiki=true; } if(this.link_class == 'urlextern') { this.attr = save_url; this.external_mime=false; // prevents external links to images from being converted to image links } if(this.in_endnotes) { if(this.link_title) { this.bottom_url= this.link_title; //save for bottom urls } else if(this.attr) { this.bottom_url= this.attr; } } this.link_title = ""; this.link_class= ""; // break; } } if(tag == 'plugin') { if(isIE) HTMLParser_PLUGIN = true; if(attrs[i].name == 'title') { this.attr = ' title="' + attrs[i].escaped + '" '; break; } } if(tag == 'sup') { if(attrs[i].name == 'class') { matches = attrs[i].value.split(/\s+/); if(matches[0] == 'dwfcknote') { this.attr = matches[0]; tag = 'blank'; if(oDokuWiki_FCKEditorInstance.oinsertHtmlCodeObj.notes[matches[1]]) { dwfck_note = '(('+ oDokuWiki_FCKEditorInstance.oinsertHtmlCodeObj.notes[matches[1]] + '))'; } break; } } } if(tag == 'pre') { if(attrs[i].name == 'class') { var elems = attrs[i].escaped.split(/\s+/); if(elems.length > 1) { this.attr = attrs[i].value; this.code_type = elems[0]; } else { this.attr = attrs[i].escaped; this.code_type = this.attr; } if(this.downloadable_code) { this.attr = this.attr.replace(/\s*code\s*/,""); this.code_type='file'; } HTMLParser_PRE = true; if(this.in_table) tag = 'pre_td'; break; } } else if(tag == 'img') { if(attrs[i].name == 'alt') { alt=attrs[i].value; } if(attrs[i].name == 'type') { this.image_link_type = attrs[i].value; } if(attrs[i].name == 'src') { // alert(attrs[i].name + ' = ' + attrs[i].value + ', fnencode=' + oDokuWiki_FCKEditorInstance.dwiki_fnencode); var src = ""; // fetched by fetch.php if(matches = attrs[i].escaped.match(/fetch\.php.*?(media=.*)/)) { var elems = matches[1].split('='); src = elems[1]; if(matches = attrs[i].escaped.match(/(media.*)/)) { var elems = matches[1].split('='); var uri = elems[1]; src = decodeURIComponent ? decodeURIComponent(uri) : unescape(uri); } if(!src.match(/https?:/) && !src.match(/^:/)) src = ':' + src; } else if(attrs[i].escaped.match(/http:\/\//)){ src = attrs[i].escaped; } // url rewrite 1 else if(matches = attrs[i].escaped.match(/\/_media\/(.*)/)) { var elems = matches[1].split(/\?/); src = elems[0]; src = src.replace(/\//g,':'); if(!src.match(/^:/)) src = ':' + src; } // url rewrite 2 else if(matches = attrs[i].escaped.match(/\/lib\/exe\/fetch.php\/(.*)/)) { var elems = matches[1].split(/\?/); src = elems[0]; if(!src.match(/^:/)) src = ':' + src; } else { // first insertion from media mananger matches = attrs[i].escaped.match(/^.*?\/userfiles\/image\/(.*)/); if(!matches) { // windows style var regex = doku_base + 'data/media/'; regex = regex.replace(/([\/\\])/g, "\\$1"); regex = '^.*?' + regex + '(.*)'; regex = new RegExp(regex); matches = attrs[i].escaped.match(regex); } if(matches && matches[1]) { src = matches[1].replace(/\//g, ':'); src = ':' + src; src = safe_convert(src); } else { src = decodeURIComponent ? decodeURIComponent(attrs[i].escaped) : unescape(attrs[i].escaped); // src = unescape(attrs[i].escaped); // external image (or smiley) } if(src.match(/lib\/images\/smileys/)) { // src = 'http://' + window.location.host + src; this.is_smiley = true; } } this.attr = src; if(this.attr.match && this.attr.match(/%[a-fA-F0-9]{2}/)) { this.attr = decodeURIComponent ? decodeURIComponent(this.attr) : unescape(this.attr); this.attr = decodeURIComponent ? decodeURIComponent(this.attr) : unescape(this.attr); } } // src end else if (attrs[i].name == 'width' && !style) { width=attrs[i].value; } else if (attrs[i].name == 'height' && !style) { height=attrs[i].value; } else if(attrs[i].name == 'style') { var match = attrs[i].escaped.match(/width:\s*(\d+)/); if(match) { width=match[1]; var match = attrs[i].escaped.match(/height:\s*(\d+)/); if(match) height = match[1]; } } else if(attrs[i].name == 'align' || attrs[i].name == 'class') { if(attrs[i].escaped.match(/(center|middle)/)) { img_align = 'center'; } else if(attrs[i].escaped.match(/right/)) { img_align = 'right'; } else if(attrs[i].escaped.match(/left/)) { img_align = 'left'; } else { img_align = ''; } } } // End img } // End Attributes Loop if(this.is_smiley) { if(alt) { results += alt + ' '; alt = ""; } this.is_smiley = false; return; } if(this.link_only) tag = 'img'; if(tag == 'br') { if(this.in_multi_plugin) { results += "\n"; return; } if(!this.code_type) { HTMLParser_LBR = true; } else if(this.code_type) { results += "\n"; return; } if(this.in_table) { results += HTMLParserParaInsert; return; } if(this.list_started) { results += '_LIST_EOFL_'; /* enables newlines in lists: abc \\def */ } else { results += '\\\\ '; return; } } else if(tag.match(/^h(\d+|r)/)) { var str_len = results.length; if(tag.match(/h(\d+)/)) { this.in_header = true; } if(str_len) { if(results.charCodeAt(str_len -1) == 32) { results = results.replace(/\x20+$/,""); } } } else if(this.last_col_pipes) { if(format_chars[tag]) results += markup[tag]; tag = 'blank'; } else if(dwfck_note) { results += dwfck_note; return; } if(tag == 'b' || tag == 'i' && this.list_level) { if(results.match(/(\/\/|\*)(\x20)+/)) { results = results.replace(/(\/\/|\*)(\x20+)\-/,"$1\n"+"$2-"); } } if(tag == 'li' && this.list_level) { if(this.list_level == 1 & !this.list_started) { results += "\n"; this.list_started = true; } results = results.replace(/[\x20]+$/,""); for(var s=0; s < this.list_level; s++) { // this handles format characters at the ends of list lines if(results.match(/_FORMAT_SPACE_\s*$/)) { results = results.replace(/_FORMAT_SPACE_\s*$/,"\n"); } results += ' '; } if(this.prev_list_level > 0 && markup['li'] == markup['ol']) { this.prev_list_level = -1; } } if(tag == 'a' && local_image) { this.xcl_markup = true; return; } else if(tag == 'a' && (this.export_code || this.code_snippet)) { return; } else if (tag == 'a' && this.footnote) { tag = 'fn_start'; } else if(tag == 'a' && bottom_note) { HTMLParserTopNotes.push(this.id); } else if(tag == 'a' && this.external_mime) { if(this.in_endnotes) { this.link_class = 'media'; return; } results += markup['img']; if(this.attr) { results += this.attr + '|'; } return; } else if(this.in_font || tag == 'font') { /* <font 18pt:bold/garamond;;color;;background_color> */ if(!font_family) { return; } if(font_color) font_color = font_color.replace(/\s+/g,""); if(font_bgcolor) font_bgcolor = font_bgcolor.replace(/\s+/g,""); if(!font_color) font_color = "#000000"; if(!font_bgcolor) font_bgcolor = "#ffffff"; if(font_color) font_family = font_family + ';;'+ font_color; if(font_bgcolor) { font_family = font_family + ';;'+ font_bgcolor; } var font_tag = '<font ' + font_size + ':'+ font_weight + '/'+font_family+'>'; results += font_tag ; return; } if(this.in_endnotes && tag == 'a') return; if(this.code_type && tag == 'span') tag = 'blank'; results += markup[tag]; if(tag == 'td' || tag == 'th' || (this.last_col_pipes && this.td_align == 'center')) { if(this.is_rowspan) { results += markup['row_span'] + ' | '; this.is_rowspan = false; } if(this.td_align == 'center' || this.td_align == 'right') { results += ' '; } } else if(tag == 'a' && this.attr) { results += this.attr + '|'; } else if(tag == 'img') { var link_type = this.image_link_type; this.image_link_type=""; if(this.link_only) link_type = 'link_only'; if(!link_type){ link_type = 'nolink'; } else if(link_type == 'detail') { link_type = ""; } if(link_type == 'link_only') { img_size='?linkonly'; } else if(link_type) { img_size += link_type + '&'; } if(width && height) { img_size +=width + 'x' + height; } else if(width) { img_size +=width; } else if(!link_type) { img_size=""; } if(img_align && img_align != 'left') { results += ' '; } this.attr += img_size; if(img_align == 'center' || img_align == 'left') { this.attr += ' '; } results += this.attr + '}}'; this.attr = 'src'; } else if(tag == 'plugin' || tag == 'pre' || tag == 'pre_td') { if(this.downloadable_file) this.attr += ' ' + this.downloadable_file; if(!this.attr) this.attr = 'code'; results += this.attr + '>'; this.downloadable_file = ""; this.downloadable_code = false; } } // if markup tag }, end: function( tag ) { if(format_chars[tag] && this.in_font) { results+=' '; return; } if(this.in_endnotes && tag == 'a') return; if(this.link_only){ this.link_only=false; return; } if(!markup[tag]) return; if(tag == 'sup' && this.attr == 'dwfcknote') { return; } if(this.is_smiley) { this.is_smiley = false; if(tag !='li') return; } if(tag == 'span' && this.in_font) { tag = 'font'; this.in_font=false; } if(tag == 'span' && this.curid) { this.curid = false; return; } if(tag == 'dl' && this.downloadable_code) { this.downloadable_code = false; return; } if(useComplexTables && (tag == 'td' || tag == 'th')) { this.current_cell.text = results.substring(this.cell_start); this.current_cell.text = this.current_cell.text.replace(/:::/gm,""); this.current_cell.text = this.current_cell.text.replace(/^[\s\|\^]+/,""); } if(tag == 'a' && (this.export_code || this.code_snippet)) { this.export_code = false; this.code_snippet = false; return; } if(this.code_type && tag == 'span') tag = 'blank'; var current_tag = tag; if(this.footnote) { tag = 'fn_end'; this.footnote = false; } else if(tag == 'a' && this.xcl_markup) { this.xcl_markup = false; return; } else if(tag == 'table') { this.in_table = false; if(useComplexTables ) { results = results.substring(0, this.table_start); insert_table(this.rows); } } if(tag == 'p' && this.in_table) { tag = 'p_insert'; HTMLParser_TABLE=true; } if(this.geshi) { this.geshi = false; return; } if(tag == 'code' && ! this.list_started) { // empty code markup corrupts results if(results.match(/''\s*$/m)) { results = results.replace(/''\s*$/, "\n"); return; } } else if(tag == 'a' && this.attr == 'src') { // if local image without link content, as in <a . . .></a>, delete link markup if(this.backup('\[\[', '\{')) return; } if(tag == 'ol' || tag == 'ul') { this.list_level--; if(!this.list_level) this.format_in_list = false; if(this.prev_li.length) { markup['li']= this.prev_li.pop(); } tag = "\n\n"; } else if(tag == 'a' && this.external_mime) { tag = '}} '; this.external_mime = false; } else if(tag == 'pre') { tag = markup_end[tag]; if(this.code_type) { tag += this.code_type + ">"; } else { var codeinx = results.lastIndexOf('code'); var fileinx = results.lastIndexOf('file'); if(fileinx > codeinx) { this.code_type = 'file'; } else this.code_type = 'code'; tag += this.code_type + ">"; } this.code_type = false; } else if(markup_end[tag]) { tag = markup_end[tag]; } else if(this.attr == 'u' && tag == 'em' ) { tag = 'u'; } else if(tag == 'acronym') { } else { tag = markup[tag]; } if(current_tag == 'tr') { if(this.last_col_pipes) { tag = "\n"; this.last_col_pipes = ""; } if(this.td_rowspan && this.rowspan_col == this.td_no+1) { this.is_rowspan = false; this.last_column = this.td_no; this.td_rowspan --; tag = '|' + markup['row_span'] + "|\n"; } } else if(current_tag == 'td' || current_tag == 'th') { this.last_col_pipes = ""; this.in_td = false; } else if (current_tag.match(/h\d+/)) { this.in_header = false; } if(markup['li']) { if(results.match(/\n$/)) { tag = ""; } } if(this.in_link && format_chars[current_tag] && this.link_formats.length) { return; } results += tag; if(format_chars[current_tag]) { if(this.list_level) { this.format_in_list = true; HTMLFormatInList = true; } results += markup['format_space']; HTMLParser_FORMAT_SPACE = markup['format_space']; } this.last_tag = current_tag; if(this.td_colspan && !useComplexTables) { if(this.td_align == 'center') results += ' '; var _colspan = "|"; if(current_tag == 'th') _colspan = '^'; var colspan = _colspan; for(var i=1; i < this.td_colspan; i++) { colspan += _colspan; } this.last_col_pipes = colspan; results += colspan; this.td_colspan = false; } else if(this.td_align == 'center') { results += ' '; this.td_align = ''; } if(current_tag == 'a' && this.link_formats.length) { var end_str = results.substring(this.link_pos); var start_str = results.substring(0,this.link_pos); var start_format = ""; var end_format = ""; for(var i=0; i < this.link_formats.length; i++) { var fmt = markup[this.link_formats[i]]; var endfmt = markup_end[this.link_formats[i]] ? markup_end[this.link_formats[i]]: fmt; start_format += markup[this.link_formats[i]]; end_format = endfmt + end_format; } start_str += start_format; end_str += end_format; results = start_str + end_str; this.link_formats = new Array(); this.in_link = false; } else if(current_tag == 'a') { this.link_formats = new Array(); this.in_link = false; } else if(current_tag == 'span' ) { this.immutable_plugin = false; } }, chars: function( text ) { if(this.interwiki && results.match(/>\w+\s*\|$/)) { text = text.replace(String.frasl,"\/"); this.interwiki=false; if(this.attr) { results+= text; } else { results=results.replace(/>\w+\s*\|$/,'>'+text); } return; } else if(this.interwiki) { text = text.replace(String.frasl,"\/"); } //adjust spacing on multi-formatted strings results=results.replace(/([\/\*_])_FORMAT_SPACE_([\/\*_]{2})_FORMAT_SPACE_$/,"$1$2"); if(text.match(/^&\w+;/)) { results=results.replace(/_FORMAT_SPACE_\s*$/,""); // remove unwanted space after character entity } if(this.link_only) { if(text) { replacement = '|'+text + '}} '; results = results.replace(/\}\}\s*$/,replacement); } return; } if(!this.code_type) { if(! this.last_col_pipes) { text = text.replace(/\x20{6,}/, " "); text = text.replace(/^( )+/, ''); text = text.replace(/( )+/, ' '); } if(this.immutable_plugin) { text = this.immutable_plugin; text = text.replace(/\/\/<\/\//g,'<'); this.immutable_plugin = false; } if(this.format_tag) { if(!this.list_started || this.in_table) text = text.replace(/^\s+/, '@@_SP_@@'); } else if(this.last_tag=='a') { text=text.replace(/^\s{2,}/," "); } else text = text.replace(/^\s+/, ''); if(text.match(/nowiki>/)) { HTMLParser_NOWIKI=true; } if(this.is_acronym) { this.is_acronym = false; } if(this.format_in_list ) { text = text.replace(/^[\n\s]+$/g, ''); } if(this.in_td && !text) { text = "_FCKG_BLANK_TD_"; this.in_td = false; } } else { text = text.replace(/<\s/g, '<'); text = text.replace(/\s>/g, '>'); } if(this.attr && this.attr == 'dwfcknote') { if(text.match(/fckgL\d+/)) { return; } if(text.match(/^[\-,:;!_]/)) { results += text; } else { results += ' ' + text; } return; } if(this.downloadable_code && (this.export_code || this.code_snippet)) { this.downloadable_file = text; return; } /* remove space between link end markup and following punctuation */ if(this.last_tag == 'a' && text.match(/^[\.,;\:\!]/)) { results=results.replace(/\s$/,""); } if(this.in_header) { text = text.replace(/---/g,'—'); text = text.replace(/--/g,'–'); } if(this.list_started) { results=results.replace(/_LIST_EOFL_\s*L_BR_K\s*$/, '_LIST_EOFL_'); } if(!this.code_type) { // keep special character literals outside of code block // don't touch samba share or Windows path backslashes if(!results.match(/\[\[\\\\.*?\|$/) && !text.match(/\w:(\\(\w?))+/ )) { text = text.replace(/([\*\\])/g, '%%$1%%'); } } if(this.in_endnotes && HTMLParserTopNotes.length) { if(text.match(/\w/) && ! text.match(/^\s*\d\)\s*$/)) { text= text.replace(/\)\s*$/, "_FN_PAREN_C_"); var index = HTMLParserTopNotes.length-1; if(this.bottom_url) { if(this.link_class && this.link_class == 'media') { text = '{{' + this.bottom_url + '|' +text +'}}'; } else text = '[[' + this.bottom_url + '|' +text +']]'; } if(HTMLParserBottomNotes[HTMLParserTopNotes[index]]) { HTMLParserBottomNotes[HTMLParserTopNotes[index]] += ' ' + text; } else { HTMLParserBottomNotes[HTMLParserTopNotes[index]] = text; } } this.bottom_url = false; return; } if(HTMLParser_PLUGIN) { HTMLParser_PLUGIN=false; if(results.match(/>\s*<\/plugin>\s*$/)) { results = results.replace(/\s*<\/plugin>\s*$/, text + '<\/plugin>'); return; } } if(text && text.length) { results += text; } // remove space between formatted character entity and following character string results=results.replace(/(&\w+;)\s*([\*\/_]{2})_FORMAT_SPACE_(\w+)/,"$1$2$3"); if(this.list_level && this.list_level > 1) { results = results.replace(/(\[\[.*?\]\])([ ]+[\*\-].*)$/," $1\n$2"); } try { // in case regex throws error on dynamic regex creation var regex = new RegExp('([\*\/\_]{2,})_FORMAT_SPACE_([\*\/\_]{2,})(' + RegExp.escape(text) + ')$'); if(results.match(regex)) { // remove left-over space inside multiple format sequences results = results.replace(regex,"$1$2$3"); } } catch(ex){} if(!HTMLParserOpenAngleBracket) { if(text.match(/</)) { HTMLParserOpenAngleBracket = true; } } }, comment: function( text ) { // results += "<!--" + text + "-->"; }, dbg: function(text, heading) { <?php if ($this->debug) { ?> if(text.replace) { text = text.replace(/^\s+/g,""); text = text.replace(/^\n$/g,""); if(!text) return; } if(heading) { heading = '<b>'+heading+"</b>\n"; } HTMLParser_DEBUG += heading + text + "\n__________\n"; <?php } ?> } } ); //show_rowspans(CurrentTable); for(var i=0; i < fckgLPluginPatterns.length; i++) { fckgLPluginPatterns[i].pat = fckgLPluginPatterns[i].pat.replace(/\|/g,"\\|"); fckgLPluginPatterns[i].pat = fckgLPluginPatterns[i].pat.replace(/([\(\)\{\}\.\?\[\]])/g, "\\$1"); var pattern = new RegExp(fckgLPluginPatterns[i].pat,"gm"); results = results.replace(pattern, fckgLPluginPatterns[i].orig); } /* we allow escaping of troublesome characters in plugins by enclosing them withinback slashes, as in \*\ the escapes are removed here together with any DW percent escapes */ results = results.replace(/(\[\[\\\\)(.*?)\]\]/gm, function(match,brackets,block) { block=block.replace(/\\/g,"_SMB_"); return brackets+block + ']]'; }); results = results.replace(/%*\\%*([^\w]{1})%*\\%*/g, "$1"); results=results.replace(/_SMB_/g, "\\"); if(id == 'test') { if(!HTMLParser_test_result(results)) return; } if(HTMLParser_FORMAT_SPACE) { if(HTMLParser_COLSPAN) { results =results.replace(/\s*([\|\^]+)((\W\W_FORMAT_SPACE_)+)/gm,function(match,pipes,format) { format = format.replace(/_FORMAT_SPACE_/g,""); return(format + pipes); }); } results = results.replace(/"/g,'"'); var regex = new RegExp(HTMLParser_FORMAT_SPACE + '([\\-]{2,})', "g"); results = results.replace(regex," $1"); var regex = new RegExp("(\\w|\\d)(\\*\\*|\\/\\/|\\'\\'|__|<\/del>)" + HTMLParser_FORMAT_SPACE + '(\\w|\\d)',"g"); results = results.replace(regex,"$1$2$3"); var regex = new RegExp(HTMLParser_FORMAT_SPACE + '@@_SP_@@',"g"); results = results.replace(regex,' '); //spacing around entities with double format characters results=results.replace(/([\*\/_]{2})@@_SP_@@(&\w+;)/g,"$1 $2"); results = results.replace(/\n@@_SP_@@\n/g,''); results = results.replace(/@@_SP_@@\n/g,''); results = results.replace(/@@_SP_@@/g,''); var regex = new RegExp(HTMLParser_FORMAT_SPACE + '([^\\)\\]\\}\\{\\-\\.,;:\\!\?"\x94\x92\u201D\u2019' + "'" + '])',"g"); results = results.replace(regex," $1"); regex = new RegExp(HTMLParser_FORMAT_SPACE,"g"); results = results.replace(regex,''); if(HTMLFormatInList) { /* removes extra newlines from lists */ results = results.replace(/(\s+[\-\*_]\s*)([\*\/_\']{2})(.*?)(\2)([^\n]*)\n+/gm, function(match,list_type,format,text, list_type_close, rest) { return(list_type+format+text+list_type_close+rest +"\n"); }); } } var line_break_final = "\\\\"; if(HTMLParser_LBR) { results = results.replace(/(L_BR_K)+/g,line_break_final); results = results.replace(/L_BR_K/gm, line_break_final) ; results = results.replace(/(\\\\)\s+/gm, "$1 \n"); } if(HTMLParser_PRE) { results = results.replace(/\s+<\/(code|file)>/g, "\n</" + "$1" + ">"); if(HTMLParser_Geshi) { results = results.replace(/\s+;/mg, ";"); results = results.replace(/<\s+/mg, "<"); results = results.replace(/\s+>/mg, ">"); } } if(HTMLParser_TABLE) { results += "\n" + line_break_final + "\n"; var regex = new RegExp(HTMLParserParaInsert,"g"); results = results.replace(regex, ' ' +line_break_final + ' '); // fix for colspans which have had text formatting which cause extra empty cells to be created results = results.replace(/(\||\^)[ ]+(\||\^)\s$/g, "$1\n"); results = results.replace(/(\||\^)[ ]+(\||\^)/g, "$1"); // prevents valid empty td/th cells from being removed above results = results.replace(/_FCKG_BLANK_TD_/g, " "); } if(HTMLParserOpenAngleBracket) { results = results.replace(/\/\/<\/\/\s*/g,'<'); } if(HTMLParserTopNotes.length) { results = results.replace(/\(\(+(\d+)\)\)+/,"(($1))"); for(var i in HTMLParserBottomNotes) { // re-insert DW's bottom notes at text level var matches = i.match(/_(\d+)/); var pattern = new RegExp('(\<sup\>)*[\(]+' + matches[1] + '[\)]+(<\/sup>)*'); results = results.replace(pattern,'((' + HTMLParserBottomNotes[i].replace(/_FN_PAREN_C_/g, ") ") +'))'); } results = results.replace(/<sup><\/sup>/g, ""); } results = results.replace(/(={3,}.*?)(\{\{.*?\}\})(.*?={3,})/g,"$1$3\n\n$2"); // remove any empty footnote markup left after section re-edits results = results.replace(/(<sup>)*\s*\[\[\s*\]\]\s*(<\/sup>)*\n*/g,""); if(HTMLParser_MULTI_LINE_PLUGIN) { results = results.replace(/<\s+/g, '<'); results = results.replace(/<\s+/g, '<'); } if(HTMLParser_NOWIKI) { /* any characters escaped by DW %%<char>%% are replaced by NOWIKI_<char> <char> is restored in save.php */ var nowiki_escapes = '%'; //this technique allows for added chars to attach to NOWIKI_$1_ var regex = new RegExp('([' + nowiki_escapes + '])', "g"); results=results.replace(/(<nowiki>)(.*?)(<\/nowiki>)/mg, function(all,start,mid,close) { mid = mid.replace(/%%(.)%%/mg,"NOWIKI_$1_"); return start + mid.replace(regex,"NOWIKI_$1_") + close; }); } results = results.replace(/SWF(\s*)\[*/g,"{{$1"); results = results.replace(/\|.*?\]*(\s*)FWS/g,"$1}}"); results = results.replace(/(\s*)FWS/g,"$1}}"); results = results.replace(/\n{3,}/g,'\n\n'); results = results.replace(/_LIST_EOFL_/gm, " " + line_break_final + " "); if(embedComplexTableMacro) { if(results.indexOf('~~COMPLEX_TABLES~~') == -1) { results += "\n~~COMPLEX_TABLES~~\n" } } if(id == 'test') { if(HTMLParser_test_result(results)) { alert(results); } return; } var dwform = GetE('dw__editform'); dwform.elements.fck_wikitext.value = results; if(id == 'bakup') { //alert(results); return; } if(id) { var dom = GetE(id); dom.click(); return true; } } <?php if ($this->debug) { ?> function HTMLParser_debug() { HTMLParser_DEBUG = ""; parse_wikitext(""); /* for(var i in oDokuWiki_FCKEditorInstance) { HTMLParser_DEBUG += i + ' = ' + oDokuWiki_FCKEditorInstance[i] + "\n";; } */ var w = window.open(); w.document.write('<pre>' + HTMLParser_DEBUG + '</pre>'); w.document.close(); } <?php } ?> <?php $url = DOKU_URL . 'lib/plugins/fckg/scripts/script-cmpr.js'; echo "var script_url = '{$url}';"; // $safe_url = DOKU_URL . 'lib/plugins/fckg/scripts/safeFN_cmpr.js'; ?> try { if(!HTMLParserInstalled){ LoadScript(script_url); } } catch (ex) { LoadScript(script_url); } if(window.DWikifnEncode && window.DWikifnEncode == 'safe') { LoadScript(DOKU_BASE + 'lib/plugins/fckg/scripts/safeFN_cmpr.js' ); } //]]> </script> </div> <?php } ?> <?php if ($wr) { ?> <div class="summary"> <label for="edit__summary" class="nowrap"><?php echo $lang['summary']; ?> :</label> <input type="text" class="edit" name="summary" id="edit__summary" size="50" value="<?php echo formText($SUM); ?> " tabindex="2" /> <label class="nowrap" for="minoredit"><input type="checkbox" id="minoredit" name="minor" value="1" tabindex="3" /> <span><?php echo $fckg_lang['minor_changes']; ?> </span></label> </div> <?php } ?> </div> </form> <!-- draft messages from DW --> <div id="draft__status"></div> <?php }
foreach (explode(' ', 'basedir userewrite baseurl useslash') as $x) { print '$' . "conf['{$x}'] = '" . $conf[$x] . "';\n"; } foreach (explode(' ', 'DOCUMENT_ROOT HTTP_HOST SCRIPT_FILENAME PHP_SELF ' . 'REQUEST_URI SCRIPT_NAME PATH_INFO PATH_TRANSLATED') as $x) { print '$' . "_SERVER['{$x}'] = '" . $_SERVER[$x] . "';\n"; } print "getID('media'): " . getID('media') . "\n"; print "getID('media',false): " . getID('media', false) . "\n"; print '</pre>'; } $ERROR = false; // check image permissions $AUTH = auth_quickaclcheck($IMG); if ($AUTH >= AUTH_READ) { // check if image exists $SRC = mediaFN($IMG); if (!@file_exists($SRC)) { //doesn't exist! header("HTTP/1.0 404 File not Found"); $ERROR = 'File not found'; } } else { // no auth $ERROR = p_locale_xhtml('denied'); } // this makes some general infos available as well as the info about the // "parent" page $INFO = pageinfo(); //start output and load template header('Content-Type: text/html; charset=utf-8'); include template('detail.php');
/** * Displays a preview of the comment * * @param array $data submitted comment properties */ private function xhtml_comment_preview($data) { $this->entryhelper->load_by_pid($data['pid']); $blogname = $this->entryhelper->get_blog(); ptln('<div id="blogtng__comment_preview">'); ptln(p_locale_xhtml('preview')); ptln('<br />'); $comment = new blogtng_comment(); $comment->init($data); $comment->output($blogname); ptln('</div>'); }