3 * HTML output functions
5 * @license GPL 2 (http://www.gnu.org/licenses/gpl.html)
6 * @author Andreas Gohr <andi@splitbrain.org>
9 if(!defined('DOKU_INC')) die('meh.');
10 if(!defined('NL')) define('NL',"\n");
11 if (!defined('SEC_EDIT_PATTERN')) {
12 define('SEC_EDIT_PATTERN', '#<!-- EDIT({.*?}) -->#');
17 * Convenience function to quickly build a wikilink
19 * @author Andreas Gohr <andi@splitbrain.org>
20 * @param string $id id of the target page
21 * @param string $name the name of the link, i.e. the text that is displayed
22 * @param string|array $search search string(s) that shall be highlighted in the target page
23 * @return string the HTML code of the link
25 function html_wikilink($id,$name=null,$search=''){
26 /** @var Doku_Renderer_xhtml $xhtml_renderer */
27 static $xhtml_renderer = null;
28 if(is_null($xhtml_renderer)){
29 $xhtml_renderer = p_get_renderer('xhtml');
32 return $xhtml_renderer->internallink($id,$name,$search,true,'navigation');
38 * @author Andreas Gohr <andi@splitbrain.org>
40 * @param bool $svg Whether to show svg icons in the register and resendpwd links or not
42 function html_login($svg = false){
48 print p_locale_xhtml('login');
49 print '<div class="centeralign">'.NL
;
50 $form = new Doku_Form(array('id' => 'dw__login'));
51 $form->startFieldset($lang['btn_login']);
52 $form->addHidden('id', $ID);
53 $form->addHidden('do', 'login');
54 $form->addElement(form_makeTextField('u', ((!$INPUT->bool('http_credentials')) ?
$INPUT->str('u') : ''), $lang['user'], 'focus__this', 'block'));
55 $form->addElement(form_makePasswordField('p', $lang['pass'], '', 'block'));
56 if($conf['rememberme']) {
57 $form->addElement(form_makeCheckboxField('r', '1', $lang['remember'], 'remember__me', 'simple'));
59 $form->addElement(form_makeButton('submit', '', $lang['btn_login']));
62 if(actionOK('register')){
63 $registerLink = (new \dokuwiki\Menu\Item\
Register())->asHtmlLink('', $svg);
64 $form->addElement('<p>'.$lang['reghere'].': '. $registerLink .'</p>');
67 if (actionOK('resendpwd')) {
68 $resendPwLink = (new \dokuwiki\Menu\Item\
Resendpwd())->asHtmlLink('', $svg);
69 $form->addElement('<p>'.$lang['pwdforget'].': '. $resendPwLink .'</p>');
72 html_form('login', $form);
82 function html_denied() {
83 print p_locale_xhtml('denied');
85 if(empty($_SERVER['REMOTE_USER']) && actionOK('login')){
91 * inserts section edit buttons if wanted or removes the markers
93 * @author Andreas Gohr <andi@splitbrain.org>
96 * @param bool $show show section edit buttons?
99 function html_secedit($text,$show=true){
102 if(!$INFO['writable'] ||
!$show ||
$INFO['rev']){
103 return preg_replace(SEC_EDIT_PATTERN
,'',$text);
106 return preg_replace_callback(SEC_EDIT_PATTERN
,
107 'html_secedit_button', $text);
111 * prepares section edit button data for event triggering
112 * used as a callback in html_secedit
114 * @author Andreas Gohr <andi@splitbrain.org>
116 * @param array $matches matches with regexp
118 * @triggers HTML_SECEDIT_BUTTON
120 function html_secedit_button($matches){
121 $json = htmlspecialchars_decode($matches[1], ENT_QUOTES
);
122 $data = json_decode($json, true);
126 $data ['target'] = strtolower($data['target']);
127 $data ['hid'] = strtolower($data['hid']);
129 return trigger_event('HTML_SECEDIT_BUTTON', $data,
130 'html_secedit_get_button');
134 * prints a section editing button
135 * used as default action form HTML_SECEDIT_BUTTON
137 * @author Adrian Lang <lang@cosmocode.de>
139 * @param array $data name, section id and target
140 * @return string html
142 function html_secedit_get_button($data) {
146 if (!isset($data['name']) ||
$data['name'] === '') return '';
148 $name = $data['name'];
149 unset($data['name']);
151 $secid = $data['secid'];
152 unset($data['secid']);
154 return "<div class='secedit editbutton_" . $data['target'] .
155 " editbutton_" . $secid . "'>" .
156 html_btn('secedit', $ID, '',
157 array_merge(array('do' => 'edit',
158 'rev' => $INFO['lastmod'],
159 'summary' => '['.$name.'] '), $data),
160 'post', $name) . '</div>';
164 * Just the back to top button (in its own form)
166 * @author Andreas Gohr <andi@splitbrain.org>
168 * @return string html
170 function html_topbtn(){
173 $ret = '<a class="nolink" href="#dokuwiki__top"><button class="button" onclick="window.scrollTo(0, 0)" title="'.$lang['btn_top'].'">'.$lang['btn_top'].'</button></a>';
179 * Displays a button (using its own form)
180 * If tooltip exists, the access key tooltip is replaced.
182 * @author Andreas Gohr <andi@splitbrain.org>
184 * @param string $name
186 * @param string $akey access key
187 * @param string[] $params key-value pairs added as hidden inputs
188 * @param string $method
189 * @param string $tooltip
190 * @param bool|string $label label text, false: lookup btn_$name in localization
191 * @param string $svg (optional) svg code, inserted into the button
194 function html_btn($name, $id, $akey, $params, $method='get', $tooltip='', $label=false, $svg=null){
199 $label = $lang['btn_'.$name];
203 //filter id (without urlencoding)
204 $id = idfilter($id,false);
206 //make nice URLs even for buttons
207 if($conf['userewrite'] == 2){
208 $script = DOKU_BASE
.DOKU_SCRIPT
.'/'.$id;
209 }elseif($conf['userewrite']){
210 $script = DOKU_BASE
.$id;
212 $script = DOKU_BASE
.DOKU_SCRIPT
;
216 $ret .= '<form class="button btn_'.$name.'" method="'.$method.'" action="'.$script.'"><div class="no">';
218 if(is_array($params)){
219 foreach($params as $key => $val) {
220 $ret .= '<input type="hidden" name="'.$key.'" ';
221 $ret .= 'value="'.hsc($val).'" />';
226 $tip = hsc($tooltip);
231 $ret .= '<button type="submit" ';
233 $tip .= ' ['.strtoupper($akey).']';
234 $ret .= 'accesskey="'.$akey.'" ';
236 $ret .= 'title="'.$tip.'">';
238 $ret .= '<span>' . hsc($label) . '</span>';
239 $ret .= inlineSVG($svg);
244 $ret .= '</div></form>';
249 * show a revision warning
251 * @author Szymon Olewniczak <dokuwiki@imz.re>
253 function html_showrev() {
254 print p_locale_xhtml('showrev');
260 * @author Andreas Gohr <andi@splitbrain.org>
262 * @param null|string $txt wiki text or null for showing $ID
264 function html_show($txt=null){
270 //disable section editing for old revisions or in preview
279 echo '<br id="scroll__here" />';
280 echo p_locale_xhtml('preview');
281 echo '<div class="preview"><div class="pad">';
282 $html = html_secedit(p_render('xhtml',p_get_instructions($txt),$info),$secedit);
283 if($INFO['prependTOC']) $html = tpl_toc(true).$html;
285 echo '<div class="clearer"></div>';
290 $data = array('rev' => &$REV, 'date_at' => &$DATE_AT);
291 trigger_event('HTML_SHOWREV_OUTPUT', $data, 'html_showrev');
293 $html = p_wiki_xhtml($ID,$REV,true,$DATE_AT);
294 $html = html_secedit($html,$secedit);
295 if($INFO['prependTOC']) $html = tpl_toc(true).$html;
296 $html = html_hilight($html,$HIGH);
302 * ask the user about how to handle an exisiting draft
304 * @author Andreas Gohr <andi@splitbrain.org>
306 function html_draft(){
310 $draft = new \dokuwiki\
Draft($ID, $INFO['client']);
311 $text = $draft->getDraftText();
313 print p_locale_xhtml('draft');
314 html_diff($text, false);
315 $form = new Doku_Form(array('id' => 'dw__editform'));
316 $form->addHidden('id', $ID);
317 $form->addHidden('date', $draft->getDraftDate());
318 $form->addHidden('wikitext', $text);
319 $form->addElement(form_makeOpenTag('div', array('id'=>'draft__status')));
320 $form->addElement($draft->getDraftMessage());
321 $form->addElement(form_makeCloseTag('div'));
322 $form->addElement(form_makeButton('submit', 'recover', $lang['btn_recover'], array('tabindex'=>'1')));
323 $form->addElement(form_makeButton('submit', 'draftdel', $lang['btn_draftdel'], array('tabindex'=>'2')));
324 $form->addElement(form_makeButton('submit', 'show', $lang['btn_cancel'], array('tabindex'=>'3')));
325 html_form('draft', $form);
329 * Highlights searchqueries in HTML code
331 * @author Andreas Gohr <andi@splitbrain.org>
332 * @author Harry Fuecks <hfuecks@gmail.com>
334 * @param string $html
335 * @param array|string $phrases
336 * @return string html
338 function html_hilight($html,$phrases){
339 $phrases = (array) $phrases;
340 $phrases = array_map('preg_quote_cb', $phrases);
341 $phrases = array_map('ft_snippet_re_preprocess', $phrases);
342 $phrases = array_filter($phrases);
343 $regex = join('|',$phrases);
345 if ($regex === '') return $html;
346 if (!utf8_check($regex)) return $html;
347 $html = @preg_replace_callback
("/((<[^>]*)|$regex)/ui",'html_hilight_callback',$html);
352 * Callback used by html_hilight()
354 * @author Harry Fuecks <hfuecks@gmail.com>
356 * @param array $m matches
357 * @return string html
359 function html_hilight_callback($m) {
360 $hlight = unslash($m[0]);
361 if ( !isset($m[2])) {
362 $hlight = '<span class="search_hit">'.$hlight.'</span>';
368 * Display error on locked pages
370 * @author Andreas Gohr <andi@splitbrain.org>
372 function html_locked(){
378 $locktime = filemtime(wikiLockFN($ID));
379 $expire = dformat($locktime +
$conf['locktime']);
380 $min = round(($conf['locktime'] - (time() - $locktime) )/60);
382 print p_locale_xhtml('locked');
384 print '<li><div class="li"><strong>'.$lang['lockedby'].'</strong> '.editorinfo($INFO['locked']).'</div></li>';
385 print '<li><div class="li"><strong>'.$lang['lockexpire'].'</strong> '.$expire.' ('.$min.' min)</div></li>';
392 * @author Andreas Gohr <andi@splitbrain.org>
393 * @author Ben Coburn <btcoburn@silicodon.net>
394 * @author Kate Arzamastseva <pshns@ukr.net>
396 * @param int $first skip the first n changelog lines
397 * @param bool|string $media_id id of media, or false for current page
399 function html_revisions($first=0, $media_id = false){
407 $changelog = new MediaChangeLog($id);
409 $changelog = new PageChangeLog($id);
412 /* we need to get one additional log entry to be able to
413 * decide if this is the last page or is there another one.
417 $revisions = $changelog->getRevisions($first, $conf['recent']+
1);
419 if(count($revisions)==0 && $first!=0){
421 $revisions = $changelog->getRevisions($first, $conf['recent']+
1);
424 if (count($revisions)>$conf['recent']) {
426 array_pop($revisions); // remove extra log entry
429 if (!$media_id) print p_locale_xhtml('revisions');
431 $params = array('id' => 'page__revisions', 'class' => 'changes');
433 $params['action'] = media_managerURL(array('image' => $media_id), '&');
437 $exists = $INFO['exists'];
438 $display_name = useHeading('navigation') ?
hsc(p_get_first_heading($id)) : $id;
443 $exists = file_exists(mediaFN($id));
447 $form = new Doku_Form($params);
448 $form->addElement(form_makeOpenTag('ul'));
450 if($exists && $first == 0) {
453 $date = dformat(@filemtime
(mediaFN($id)));
454 $href = media_managerURL(array('image' => $id, 'tab_details' => 'view'), '&');
456 $changelog->setChunkSize(1024);
457 $revinfo = $changelog->getRevisionInfo(@filemtime
(fullpath(mediaFN($id))));
459 $summary = $revinfo['sum'];
460 if($revinfo['user']) {
461 $editor = $revinfo['user'];
463 $editor = $revinfo['ip'];
465 $sizechange = $revinfo['sizechange'];
467 $date = dformat($INFO['lastmod']);
468 if(isset($INFO['meta']) && isset($INFO['meta']['last_change'])) {
469 if($INFO['meta']['last_change']['type'] === DOKU_CHANGE_TYPE_MINOR_EDIT
) {
472 if(isset($INFO['meta']['last_change']['sizechange'])) {
473 $sizechange = $INFO['meta']['last_change']['sizechange'];
478 $pagelog = new PageChangeLog($ID);
479 $latestrev = $pagelog->getRevisions(-1, 1);
480 $latestrev = array_pop($latestrev);
481 $href = wl($id,"rev=$latestrev",false,'&');
482 $summary = $INFO['sum'];
483 $editor = $INFO['editor'];
486 $form->addElement(form_makeOpenTag('li', array('class' => ($minor ?
'minor' : ''))));
487 $form->addElement(form_makeOpenTag('div', array('class' => 'li')));
488 $form->addElement(form_makeTag('input', array(
489 'type' => 'checkbox',
491 'value' => 'current')));
493 $form->addElement(form_makeOpenTag('span', array('class' => 'date')));
494 $form->addElement($date);
495 $form->addElement(form_makeCloseTag('span'));
497 $form->addElement('<img src="'.DOKU_BASE
.'lib/images/blank.gif" width="15" height="11" alt="" />');
499 $form->addElement(form_makeOpenTag('a', array(
500 'class' => 'wikilink1',
502 $form->addElement($display_name);
503 $form->addElement(form_makeCloseTag('a'));
505 if ($media_id) $form->addElement(form_makeOpenTag('div'));
508 $form->addElement(form_makeOpenTag('span', array('class' => 'sum')));
509 if(!$media_id) $form->addElement(' – ');
510 $form->addElement('<bdi>' . hsc($summary) . '</bdi>');
511 $form->addElement(form_makeCloseTag('span'));
514 $form->addElement(form_makeOpenTag('span', array('class' => 'user')));
515 $form->addElement((empty($editor))?
('('.$lang['external_edit'].')'):'<bdi>'.editorinfo($editor).'</bdi>');
516 $form->addElement(form_makeCloseTag('span'));
518 html_sizechange($sizechange, $form);
520 $form->addElement('('.$lang['current'].')');
522 if ($media_id) $form->addElement(form_makeCloseTag('div'));
524 $form->addElement(form_makeCloseTag('div'));
525 $form->addElement(form_makeCloseTag('li'));
528 foreach($revisions as $rev) {
529 $date = dformat($rev);
530 $info = $changelog->getRevisionInfo($rev);
532 $exists = file_exists(mediaFN($id, $rev));
534 $exists = page_exists($id, $rev);
538 if($info['type'] === DOKU_CHANGE_TYPE_MINOR_EDIT
) {
541 $form->addElement(form_makeOpenTag('li', array('class' => $class)));
542 $form->addElement(form_makeOpenTag('div', array('class' => 'li')));
544 $form->addElement(form_makeTag('input', array(
545 'type' => 'checkbox',
549 $form->addElement('<img src="'.DOKU_BASE
.'lib/images/blank.gif" width="15" height="11" alt="" />');
552 $form->addElement(form_makeOpenTag('span', array('class' => 'date')));
553 $form->addElement($date);
554 $form->addElement(form_makeCloseTag('span'));
558 $href = wl($id,"rev=$rev,do=diff", false, '&');
560 $href = media_managerURL(array('image' => $id, 'rev' => $rev, 'mediado' => 'diff'), '&');
562 $form->addElement(form_makeOpenTag('a', array(
563 'class' => 'diff_link',
565 $form->addElement(form_makeTag('img', array(
566 'src' => DOKU_BASE
.'lib/images/diff.png',
569 'title' => $lang['diff'],
570 'alt' => $lang['diff'])));
571 $form->addElement(form_makeCloseTag('a'));
574 $href = wl($id,"rev=$rev",false,'&');
576 $href = media_managerURL(array('image' => $id, 'tab_details' => 'view', 'rev' => $rev), '&');
578 $form->addElement(form_makeOpenTag('a', array(
579 'class' => 'wikilink1',
581 $form->addElement($display_name);
582 $form->addElement(form_makeCloseTag('a'));
584 $form->addElement('<img src="'.DOKU_BASE
.'lib/images/blank.gif" width="15" height="11" alt="" />');
585 $form->addElement($display_name);
588 if ($media_id) $form->addElement(form_makeOpenTag('div'));
591 $form->addElement(form_makeOpenTag('span', array('class' => 'sum')));
592 if(!$media_id) $form->addElement(' – ');
593 $form->addElement('<bdi>'.hsc($info['sum']).'</bdi>');
594 $form->addElement(form_makeCloseTag('span'));
597 $form->addElement(form_makeOpenTag('span', array('class' => 'user')));
599 $form->addElement('<bdi>'.editorinfo($info['user']).'</bdi>');
600 if(auth_ismanager()){
601 $form->addElement(' <bdo dir="ltr">('.$info['ip'].')</bdo>');
604 $form->addElement('<bdo dir="ltr">'.$info['ip'].'</bdo>');
606 $form->addElement(form_makeCloseTag('span'));
608 html_sizechange($info['sizechange'], $form);
610 if ($media_id) $form->addElement(form_makeCloseTag('div'));
612 $form->addElement(form_makeCloseTag('div'));
613 $form->addElement(form_makeCloseTag('li'));
615 $form->addElement(form_makeCloseTag('ul'));
617 $form->addElement(form_makeButton('submit', 'diff', $lang['diff2']));
619 $form->addHidden('mediado', 'diff');
620 $form->addElement(form_makeButton('submit', '', $lang['diff2']));
622 html_form('revisions', $form);
624 print '<div class="pagenav">';
625 $last = $first +
$conf['recent'];
627 $first -= $conf['recent'];
628 if ($first < 0) $first = 0;
629 print '<div class="pagenav-prev">';
631 print html_btn('newer',$media_id,"p",media_managerURL(array('first' => $first), '&', false, true));
633 print html_btn('newer',$id,"p",array('do' => 'revisions', 'first' => $first));
638 print '<div class="pagenav-next">';
640 print html_btn('older',$media_id,"n",media_managerURL(array('first' => $last), '&', false, true));
642 print html_btn('older',$id,"n",array('do' => 'revisions', 'first' => $last));
651 * display recent changes
653 * @author Andreas Gohr <andi@splitbrain.org>
654 * @author Matthias Grimm <matthiasgrimm@users.sourceforge.net>
655 * @author Ben Coburn <btcoburn@silicodon.net>
656 * @author Kate Arzamastseva <pshns@ukr.net>
659 * @param string $show_changes
661 function html_recent($first = 0, $show_changes = 'both') {
665 /* we need to get one additionally log entry to be able to
666 * decide if this is the last page or is there another one.
667 * This is the cheapest solution to get this information.
670 if($show_changes == 'mediafiles' && $conf['mediarevisions']) {
671 $flags = RECENTS_MEDIA_CHANGES
;
672 } elseif($show_changes == 'pages') {
674 } elseif($conf['mediarevisions']) {
675 $show_changes = 'both';
676 $flags = RECENTS_MEDIA_PAGES_MIXED
;
679 $recents = getRecents($first, $conf['recent'] +
1, getNS($ID), $flags);
680 if(count($recents) == 0 && $first != 0) {
682 $recents = getRecents($first, $conf['recent'] +
1, getNS($ID), $flags);
685 if(count($recents) > $conf['recent']) {
687 array_pop($recents); // remove extra log entry
690 print p_locale_xhtml('recent');
692 if(getNS($ID) != '') {
693 print '<div class="level1"><p>' . sprintf($lang['recent_global'], getNS($ID), wl('', 'do=recent')) . '</p></div>';
696 $form = new Doku_Form(array('id' => 'dw__recent', 'method' => 'GET', 'class' => 'changes'));
697 $form->addHidden('sectok', null);
698 $form->addHidden('do', 'recent');
699 $form->addHidden('id', $ID);
701 if($conf['mediarevisions']) {
702 $form->addElement('<div class="changeType">');
703 $form->addElement(form_makeListboxField(
706 'pages' => $lang['pages_changes'],
707 'mediafiles' => $lang['media_changes'],
708 'both' => $lang['both_changes']
711 $lang['changes_type'],
713 array('class' => 'quickselect')));
715 $form->addElement(form_makeButton('submit', 'recent', $lang['btn_apply']));
716 $form->addElement('</div>');
719 $form->addElement(form_makeOpenTag('ul'));
721 foreach($recents as $recent) {
722 $date = dformat($recent['date']);
725 if($recent['type'] === DOKU_CHANGE_TYPE_MINOR_EDIT
) {
728 $form->addElement(form_makeOpenTag('li', array('class' => $class)));
729 $form->addElement(form_makeOpenTag('div', array('class' => 'li')));
731 if(!empty($recent['media'])) {
732 $form->addElement(media_printicon($recent['id']));
734 $icon = DOKU_BASE
. 'lib/images/fileicons/file.png';
735 $form->addElement('<img src="' . $icon . '" alt="' . $recent['id'] . '" class="icon" />');
738 $form->addElement(form_makeOpenTag('span', array('class' => 'date')));
739 $form->addElement($date);
740 $form->addElement(form_makeCloseTag('span'));
745 if(!empty($recent['media'])) {
746 $changelog = new MediaChangeLog($recent['id']);
747 $revs = $changelog->getRevisions(0, 1);
748 $diff = (count($revs) && file_exists(mediaFN($recent['id'])));
750 $href = media_managerURL(array(
751 'tab_details' => 'history',
753 'image' => $recent['id'],
754 'ns' => getNS($recent['id'])
758 $href = wl($recent['id'], "do=diff", false, '&');
761 if(!empty($recent['media']) && !$diff) {
762 $form->addElement('<img src="' . DOKU_BASE
. 'lib/images/blank.gif" width="15" height="11" alt="" />');
764 $form->addElement(form_makeOpenTag('a', array('class' => 'diff_link', 'href' => $href)));
765 $form->addElement(form_makeTag('img', array(
766 'src' => DOKU_BASE
. 'lib/images/diff.png',
769 'title' => $lang['diff'],
770 'alt' => $lang['diff']
772 $form->addElement(form_makeCloseTag('a'));
775 if(!empty($recent['media'])) {
776 $href = media_managerURL(array('tab_details' => 'history', 'image' => $recent['id'], 'ns' => getNS($recent['id'])), '&');
778 $href = wl($recent['id'], "do=revisions", false, '&');
780 $form->addElement(form_makeOpenTag('a', array(
781 'class' => 'revisions_link',
783 $form->addElement(form_makeTag('img', array(
784 'src' => DOKU_BASE
. 'lib/images/history.png',
787 'title' => $lang['btn_revs'],
788 'alt' => $lang['btn_revs']
790 $form->addElement(form_makeCloseTag('a'));
792 if(!empty($recent['media'])) {
793 $href = media_managerURL(array('tab_details' => 'view', 'image' => $recent['id'], 'ns' => getNS($recent['id'])), '&');
794 $class = file_exists(mediaFN($recent['id'])) ?
'wikilink1' : 'wikilink2';
795 $form->addElement(form_makeOpenTag('a', array(
798 $form->addElement($recent['id']);
799 $form->addElement(form_makeCloseTag('a'));
801 $form->addElement(html_wikilink(':' . $recent['id'], useHeading('navigation') ?
null : $recent['id']));
803 $form->addElement(form_makeOpenTag('span', array('class' => 'sum')));
804 $form->addElement(' – ' . hsc($recent['sum']));
805 $form->addElement(form_makeCloseTag('span'));
807 $form->addElement(form_makeOpenTag('span', array('class' => 'user')));
808 if($recent['user']) {
809 $form->addElement('<bdi>' . editorinfo($recent['user']) . '</bdi>');
810 if(auth_ismanager()) {
811 $form->addElement(' <bdo dir="ltr">(' . $recent['ip'] . ')</bdo>');
814 $form->addElement('<bdo dir="ltr">' . $recent['ip'] . '</bdo>');
816 $form->addElement(form_makeCloseTag('span'));
818 html_sizechange($recent['sizechange'], $form);
820 $form->addElement(form_makeCloseTag('div'));
821 $form->addElement(form_makeCloseTag('li'));
823 $form->addElement(form_makeCloseTag('ul'));
825 $form->addElement(form_makeOpenTag('div', array('class' => 'pagenav')));
826 $last = $first +
$conf['recent'];
828 $first -= $conf['recent'];
829 if($first < 0) $first = 0;
830 $form->addElement(form_makeOpenTag('div', array('class' => 'pagenav-prev')));
831 $form->addElement(form_makeOpenTag('button', array(
833 'name' => 'first[' . $first . ']',
835 'title' => $lang['btn_newer'] . ' [N]',
836 'class' => 'button show'
838 $form->addElement($lang['btn_newer']);
839 $form->addElement(form_makeCloseTag('button'));
840 $form->addElement(form_makeCloseTag('div'));
843 $form->addElement(form_makeOpenTag('div', array('class' => 'pagenav-next')));
844 $form->addElement(form_makeOpenTag('button', array(
846 'name' => 'first[' . $last . ']',
848 'title' => $lang['btn_older'] . ' [P]',
849 'class' => 'button show'
851 $form->addElement($lang['btn_older']);
852 $form->addElement(form_makeCloseTag('button'));
853 $form->addElement(form_makeCloseTag('div'));
855 $form->addElement(form_makeCloseTag('div'));
856 html_form('recent', $form);
862 * @author Andreas Gohr <andi@splitbrain.org>
866 function html_index($ns){
872 if($ns === false) $ns ='';
874 $ns = utf8_encodeFN(str_replace(':','/',$ns));
876 echo p_locale_xhtml('index');
877 echo '<div id="index__tree" class="index__tree">';
880 search($data,$conf['datadir'],'search_index',array('ns' => $ns));
881 echo html_buildlist($data,'idx','html_list_index','html_li_index');
887 * Index item formatter
889 * User function for html_buildlist()
891 * @author Andreas Gohr <andi@splitbrain.org>
896 function html_list_index($item){
899 // prevent searchbots needlessly following links
900 $nofollow = ($ID != $conf['start'] ||
$conf['sitemap']) ?
' rel="nofollow"' : '';
903 $base = ':'.$item['id'];
904 $base = substr($base,strrpos($base,':')+
1);
905 if($item['type']=='d'){
906 // FS#2766, no need for search bots to follow namespace links in the index
907 $ret .= '<a href="'.wl($ID,'idx='.rawurlencode($item['id'])).'" title="' . $item['id'] . '" class="idx_dir"' . $nofollow . '><strong>';
909 $ret .= '</strong></a>';
911 // default is noNSorNS($id), but we want noNS($id) when useheading is off FS#2605
912 $ret .= html_wikilink(':'.$item['id'], useHeading('navigation') ?
null : noNS($item['id']));
920 * This user function is used in html_buildlist to build the
921 * <li> tags for namespaces when displaying the page index
922 * it gives different classes to opened or closed "folders"
924 * @author Andreas Gohr <andi@splitbrain.org>
927 * @return string html
929 function html_li_index($item){
936 if($item['type'] == "f"){
937 // scroll to the current item
938 if($item['id'] == $INFO['id'] && $ACT == 'index') {
939 $id = ' id="scroll__here"';
942 return '<li class="level'.$item['level'].$class.'" '.$id.'>';
943 }elseif($item['open']){
944 return '<li class="open">';
946 return '<li class="closed">';
953 * @author Andreas Gohr <andi@splitbrain.org>
956 * @return string html
958 function html_li_default($item){
959 return '<li class="level'.$item['level'].'">';
963 * Build an unordered list
965 * Build an unordered list from the given $data array
966 * Each item in the array has to have a 'level' property
967 * the item itself gets printed by the given $func user
968 * function. The second and optional function is used to
969 * print the <li> tag. Both user function need to accept
972 * Both user functions can be given as array to point to
973 * a member of an object.
975 * @author Andreas Gohr <andi@splitbrain.org>
977 * @param array $data array with item arrays
978 * @param string $class class of ul wrapper
979 * @param callable $func callback to print an list item
980 * @param callable $lifunc callback to the opening li tag
981 * @param bool $forcewrapper Trigger building a wrapper ul if the first level is
982 * 0 (we have a root object) or 1 (just the root content)
983 * @return string html of an unordered list
985 function html_buildlist($data,$class,$func,$lifunc='html_li_default',$forcewrapper=false){
986 if (count($data) === 0) {
990 $firstElement = reset($data);
991 $start_level = $firstElement['level'];
992 $level = $start_level;
996 foreach ($data as $item){
998 if( $item['level'] > $level ){
1000 for($i=0; $i<($item['level'] - $level); $i++
){
1001 if ($i) $ret .= "<li class=\"clear\">";
1002 $ret .= "\n<ul class=\"$class\">\n";
1005 $level = $item['level'];
1007 }elseif( $item['level'] < $level ){
1010 while( $level > $item['level'] && $open > 0 ){
1011 //close higher lists
1012 $ret .= "</ul>\n</li>\n";
1016 } elseif ($ret !== '') {
1017 //close previous item
1022 $ret .= call_user_func($lifunc,$item);
1023 $ret .= '<div class="li">';
1025 $ret .= call_user_func($func,$item);
1029 //close remaining items and lists
1031 while($open-- > 0) {
1032 $ret .= "</ul></li>\n";
1035 if ($forcewrapper ||
$start_level < 2) {
1036 // Trigger building a wrapper ul if the first level is
1037 // 0 (we have a root object) or 1 (just the root content)
1038 $ret = "\n<ul class=\"$class\">\n".$ret."</ul>\n";
1047 * @author Andreas Gohr <andi@splitbrain.org>
1048 * @author Michael Klier <chi@chimeric.de>
1050 function html_backlinks(){
1054 print p_locale_xhtml('backlinks');
1056 $data = ft_backlinks($ID);
1059 print '<ul class="idx">';
1060 foreach($data as $blink){
1061 print '<li><div class="li">';
1062 print html_wikilink(':'.$blink,useHeading('navigation')?
null:$blink);
1063 print '</div></li>';
1067 print '<div class="level1"><p>' . $lang['nothingfound'] . '</p></div>';
1072 * Get header of diff HTML
1074 * @param string $l_rev Left revisions
1075 * @param string $r_rev Right revision
1076 * @param string $id Page id, if null $ID is used
1077 * @param bool $media If it is for media files
1078 * @param bool $inline Return the header on a single line
1079 * @return string[] HTML snippets for diff header
1081 function html_diff_head($l_rev, $r_rev, $id = null, $media = false, $inline = false) {
1087 $head_separator = $inline ?
' ' : '<br />';
1088 $media_or_wikiFN = $media ?
'mediaFN' : 'wikiFN';
1089 $ml_or_wl = $media ?
'ml' : 'wl';
1090 $l_minor = $r_minor = '';
1093 $changelog = new MediaChangeLog($id);
1095 $changelog = new PageChangeLog($id);
1098 $l_head = '—';
1100 $l_info = $changelog->getRevisionInfo($l_rev);
1101 if($l_info['user']){
1102 $l_user = '<bdi>'.editorinfo($l_info['user']).'</bdi>';
1103 if(auth_ismanager()) $l_user .= ' <bdo dir="ltr">('.$l_info['ip'].')</bdo>';
1105 $l_user = '<bdo dir="ltr">'.$l_info['ip'].'</bdo>';
1107 $l_user = '<span class="user">'.$l_user.'</span>';
1108 $l_sum = ($l_info['sum']) ?
'<span class="sum"><bdi>'.hsc($l_info['sum']).'</bdi></span>' : '';
1109 if ($l_info['type']===DOKU_CHANGE_TYPE_MINOR_EDIT
) $l_minor = 'class="minor"';
1111 $l_head_title = ($media) ?
dformat($l_rev) : $id.' ['.dformat($l_rev).']';
1112 $l_head = '<bdi><a class="wikilink1" href="'.$ml_or_wl($id,"rev=$l_rev").'">'.
1113 $l_head_title.'</a></bdi>'.
1114 $head_separator.$l_user.' '.$l_sum;
1118 $r_info = $changelog->getRevisionInfo($r_rev);
1119 if($r_info['user']){
1120 $r_user = '<bdi>'.editorinfo($r_info['user']).'</bdi>';
1121 if(auth_ismanager()) $r_user .= ' <bdo dir="ltr">('.$r_info['ip'].')</bdo>';
1123 $r_user = '<bdo dir="ltr">'.$r_info['ip'].'</bdo>';
1125 $r_user = '<span class="user">'.$r_user.'</span>';
1126 $r_sum = ($r_info['sum']) ?
'<span class="sum"><bdi>'.hsc($r_info['sum']).'</bdi></span>' : '';
1127 if ($r_info['type']===DOKU_CHANGE_TYPE_MINOR_EDIT
) $r_minor = 'class="minor"';
1129 $r_head_title = ($media) ?
dformat($r_rev) : $id.' ['.dformat($r_rev).']';
1130 $r_head = '<bdi><a class="wikilink1" href="'.$ml_or_wl($id,"rev=$r_rev").'">'.
1131 $r_head_title.'</a></bdi>'.
1132 $head_separator.$r_user.' '.$r_sum;
1133 }elseif($_rev = @filemtime
($media_or_wikiFN($id))){
1134 $_info = $changelog->getRevisionInfo($_rev);
1136 $_user = '<bdi>'.editorinfo($_info['user']).'</bdi>';
1137 if(auth_ismanager()) $_user .= ' <bdo dir="ltr">('.$_info['ip'].')</bdo>';
1139 $_user = '<bdo dir="ltr">'.$_info['ip'].'</bdo>';
1141 $_user = '<span class="user">'.$_user.'</span>';
1142 $_sum = ($_info['sum']) ?
'<span class="sum"><bdi>'.hsc($_info['sum']).'</span></bdi>' : '';
1143 if ($_info['type']===DOKU_CHANGE_TYPE_MINOR_EDIT
) $r_minor = 'class="minor"';
1145 $r_head_title = ($media) ?
dformat($_rev) : $id.' ['.dformat($_rev).']';
1146 $r_head = '<bdi><a class="wikilink1" href="'.$ml_or_wl($id).'">'.
1147 $r_head_title.'</a></bdi> '.
1148 '('.$lang['current'].')'.
1149 $head_separator.$_user.' '.$_sum;
1151 $r_head = '— ('.$lang['current'].')';
1154 return array($l_head, $r_head, $l_minor, $r_minor);
1159 * between current page version and provided $text
1160 * or between the revisions provided via GET or POST
1162 * @author Andreas Gohr <andi@splitbrain.org>
1163 * @param string $text when non-empty: compare with this text with most current version
1164 * @param bool $intro display the intro text
1165 * @param string $type type of the diff (inline or sidebyside)
1167 function html_diff($text = '', $intro = true, $type = null) {
1173 $pagelog = new PageChangeLog($ID);
1176 * Determine diff type
1179 $type = $INPUT->str('difftype');
1181 $type = get_doku_pref('difftype', $type);
1182 if(empty($type) && $INFO['ismobile']) {
1187 if($type != 'inline') $type = 'sidebyside';
1190 * Determine requested revision(s)
1192 // we're trying to be clever here, revisions to compare can be either
1193 // given as rev and rev2 parameters, with rev2 being optional. Or in an
1197 $rev2 = $INPUT->ref('rev2');
1198 if(is_array($rev2)) {
1199 $rev1 = (int) $rev2[0];
1200 $rev2 = (int) $rev2[1];
1207 $rev2 = $INPUT->int('rev2');
1211 * Determine left and right revision, its texts and the header
1216 if($text) { // compare text to the most current revision
1218 $l_text = rawWiki($ID, '');
1219 $l_head = '<a class="wikilink1" href="' . wl($ID) . '">' .
1220 $ID . ' ' . dformat((int) @filemtime
(wikiFN($ID))) . '</a> ' .
1224 $r_text = cleanText($text);
1225 $r_head = $lang['yours'];
1227 if($rev1 && isset($rev2) && $rev2) { // two specific revisions wanted
1228 // make sure order is correct (older on the left)
1236 } elseif($rev1) { // single revision given, compare to current
1239 } else { // no revision was given, compare previous to current
1241 $revs = $pagelog->getRevisions(0, 1);
1243 $REV = $l_rev; // store revision back in $REV
1246 // when both revisions are empty then the page was created just now
1247 if(!$l_rev && !$r_rev) {
1250 $l_text = rawWiki($ID, $l_rev);
1252 $r_text = rawWiki($ID, $r_rev);
1254 list($l_head, $r_head, $l_minor, $r_minor) = html_diff_head($l_rev, $r_rev, null, false, $type == 'inline');
1263 list($l_nav, $r_nav) = html_diff_navigation($pagelog, $type, $l_rev, $r_rev);
1266 * Create diff object and the formatter
1268 $diff = new Diff(explode("\n", $l_text), explode("\n", $r_text));
1270 if($type == 'inline') {
1271 $diffformatter = new InlineDiffFormatter();
1273 $diffformatter = new TableDiffFormatter();
1278 if($intro) print p_locale_xhtml('diff');
1281 * Display type and exact reference
1284 ptln('<div class="diffoptions group">');
1287 $form = new Doku_Form(array('action' => wl()));
1288 $form->addHidden('id', $ID);
1289 $form->addHidden('rev2[0]', $l_rev);
1290 $form->addHidden('rev2[1]', $r_rev);
1291 $form->addHidden('do', 'diff');
1293 form_makeListboxField(
1296 'sidebyside' => $lang['diff_side'],
1297 'inline' => $lang['diff_inline']
1302 array('class' => 'quickselect')
1305 $form->addElement(form_makeButton('submit', 'diff', 'Go'));
1309 // link to exactly this view FS#2835
1310 echo html_diff_navigationlink($type, 'difflink', $l_rev, $r_rev ?
$r_rev : $INFO['currentrev']);
1313 ptln('</div>'); // .diffoptions
1317 * Display diff view table
1321 <table
class="diff diff_<?php echo $type ?>">
1324 //navigation and header
1325 if($type == 'inline') {
1328 <td
class="diff-lineheader">-</td
>
1329 <td
class="diffnav"><?php
echo $l_nav ?
></td
>
1332 <th
class="diff-lineheader">-</th
>
1333 <th
<?php
echo $l_minor ?
>>
1334 <?php
echo $l_head ?
>
1339 <td
class="diff-lineheader">+
</td
>
1340 <td
class="diffnav"><?php
echo $r_nav ?
></td
>
1343 <th
class="diff-lineheader">+
</th
>
1344 <th
<?php
echo $r_minor ?
>>
1345 <?php
echo $r_head ?
>
1351 <td colspan
="2" class="diffnav"><?php
echo $l_nav ?
></td
>
1352 <td colspan
="2" class="diffnav"><?php
echo $r_nav ?
></td
>
1356 <th colspan
="2" <?php
echo $l_minor ?
>>
1357 <?php
echo $l_head ?
>
1359 <th colspan
="2" <?php
echo $r_minor ?
>>
1360 <?php
echo $r_head ?
>
1366 echo html_insert_softbreaks($diffformatter->format($diff)); ?
>
1374 * Create html for revision navigation
1376 * @param PageChangeLog $pagelog changelog object of current page
1377 * @param string $type inline vs sidebyside
1378 * @param int $l_rev left revision timestamp
1379 * @param int $r_rev right revision timestamp
1380 * @return string[] html of left and right navigation elements
1382 function html_diff_navigation($pagelog, $type, $l_rev, $r_rev) {
1385 // last timestamp is not in changelog, retrieve timestamp from metadata
1386 // note: when page is removed, the metadata timestamp is zero
1388 if(isset($INFO['meta']['last_change']['date'])) {
1389 $r_rev = $INFO['meta']['last_change']['date'];
1395 //retrieve revisions with additional info
1396 list($l_revs, $r_revs) = $pagelog->getRevisionsAround($l_rev, $r_rev);
1397 $l_revisions = array();
1399 $l_revisions[0] = array(0, "", false); //no left revision given, add dummy
1401 foreach($l_revs as $rev) {
1402 $info = $pagelog->getRevisionInfo($rev);
1403 $l_revisions[$rev] = array(
1405 dformat($info['date']) . ' ' . editorinfo($info['user'], true) . ' ' . $info['sum'],
1406 $r_rev ?
$rev >= $r_rev : false //disable?
1409 $r_revisions = array();
1411 $r_revisions[0] = array(0, "", false); //no right revision given, add dummy
1413 foreach($r_revs as $rev) {
1414 $info = $pagelog->getRevisionInfo($rev);
1415 $r_revisions[$rev] = array(
1417 dformat($info['date']) . ' ' . editorinfo($info['user'], true) . ' ' . $info['sum'],
1418 $rev <= $l_rev //disable?
1422 //determine previous/next revisions
1423 $l_index = array_search($l_rev, $l_revs);
1424 $l_prev = $l_revs[$l_index +
1];
1425 $l_next = $l_revs[$l_index - 1];
1427 $r_index = array_search($r_rev, $r_revs);
1428 $r_prev = $r_revs[$r_index +
1];
1429 $r_next = $r_revs[$r_index - 1];
1433 $r_prev = $r_revs[0];
1446 $l_nav .= html_diff_navigationlink($type, 'diffbothprevrev', $l_prev, $r_prev);
1447 $l_nav .= html_diff_navigationlink($type, 'diffprevrev', $l_prev, $r_rev);
1450 $form = new Doku_Form(array('action' => wl()));
1451 $form->addHidden('id', $ID);
1452 $form->addHidden('difftype', $type);
1453 $form->addHidden('rev2[1]', $r_rev);
1454 $form->addHidden('do', 'diff');
1456 form_makeListboxField(
1461 array('class' => 'quickselect')
1464 $form->addElement(form_makeButton('submit', 'diff', 'Go'));
1465 $l_nav .= $form->getForm();
1467 if($l_next && ($l_next < $r_rev ||
!$r_rev)) {
1468 $l_nav .= html_diff_navigationlink($type, 'diffnextrev', $l_next, $r_rev);
1476 if($l_rev < $r_prev) {
1477 $r_nav .= html_diff_navigationlink($type, 'diffprevrev', $l_rev, $r_prev);
1480 $form = new Doku_Form(array('action' => wl()));
1481 $form->addHidden('id', $ID);
1482 $form->addHidden('rev2[0]', $l_rev);
1483 $form->addHidden('difftype', $type);
1484 $form->addHidden('do', 'diff');
1486 form_makeListboxField(
1491 array('class' => 'quickselect')
1494 $form->addElement(form_makeButton('submit', 'diff', 'Go'));
1495 $r_nav .= $form->getForm();
1498 if($pagelog->isCurrentRevision($r_next)) {
1499 $r_nav .= html_diff_navigationlink($type, 'difflastrev', $l_rev); //last revision is diff with current page
1501 $r_nav .= html_diff_navigationlink($type, 'diffnextrev', $l_rev, $r_next);
1503 $r_nav .= html_diff_navigationlink($type, 'diffbothnextrev', $l_next, $r_next);
1505 return array($l_nav, $r_nav);
1509 * Create html link to a diff defined by two revisions
1511 * @param string $difftype display type
1512 * @param string $linktype
1513 * @param int $lrev oldest revision
1514 * @param int $rrev newest revision or null for diff with current revision
1515 * @return string html of link to a diff
1517 function html_diff_navigationlink($difftype, $linktype, $lrev, $rrev = null) {
1523 'difftype' => $difftype,
1530 'difftype' => $difftype,
1533 return '<a class="' . $linktype . '" href="' . wl($ID, $urlparam) . '" title="' . $lang[$linktype] . '">' .
1534 '<span>' . $lang[$linktype] . '</span>' .
1539 * Insert soft breaks in diff html
1541 * @param string $diffhtml
1544 function html_insert_softbreaks($diffhtml) {
1545 // search the diff html string for both:
1546 // - html tags, so these can be ignored
1547 // - long strings of characters without breaking characters
1548 return preg_replace_callback('/<[^>]*>|[^<> ]{12,}/','html_softbreak_callback',$diffhtml);
1552 * callback which adds softbreaks
1554 * @param array $match array with first the complete match
1555 * @return string the replacement
1557 function html_softbreak_callback($match){
1558 // if match is an html tag, return it intact
1559 if ($match[0]{0} == '<') return $match[0];
1561 // its a long string without a breaking character,
1562 // make certain characters into breaking characters by inserting a
1563 // breaking character (zero length space, U+200B / #8203) in front them.
1565 (?
(?
= # start a conditional expression with a positive look ahead ...
1566 &\
#?\\w{1,6};) # ... for html entities - we don't want to split them (ok to catch some invalid combinations)
1567 &\
#?\\w{1,6}; # yes pattern - a quicker match for the html entity, since we know we have one
1569 [?
/,&\
#;:] # no pattern - any other group of 'special' characters to insert a breaking character after
1570 )+
# end conditional expression
1573 return preg_replace('<'.$regex.'>xu','\0​',$match[0]);
1577 * show warning on conflict detection
1579 * @author Andreas Gohr <andi@splitbrain.org>
1581 * @param string $text
1582 * @param string $summary
1584 function html_conflict($text,$summary){
1588 print p_locale_xhtml('conflict');
1589 $form = new Doku_Form(array('id' => 'dw__editform'));
1590 $form->addHidden('id', $ID);
1591 $form->addHidden('wikitext', $text);
1592 $form->addHidden('summary', $summary);
1593 $form->addElement(form_makeButton('submit', 'save', $lang['btn_save'], array('accesskey'=>'s')));
1594 $form->addElement(form_makeButton('submit', 'cancel', $lang['btn_cancel']));
1595 html_form('conflict', $form);
1596 print '<br /><br /><br /><br />'.NL
;
1600 * Prints the global message array
1602 * @author Andreas Gohr <andi@splitbrain.org>
1604 function html_msgarea(){
1605 global $MSG, $MSG_shown;
1606 /** @var array $MSG */
1607 // store if the global $MSG has already been shown and thus HTML output has been started
1610 if(!isset($MSG)) return;
1613 foreach($MSG as $msg){
1614 $hash = md5($msg['msg']);
1615 if(isset($shown[$hash])) continue; // skip double messages
1616 if(info_msg_allowed($msg)){
1617 print '<div class="'.$msg['lvl'].'">';
1624 unset($GLOBALS['MSG']);
1628 * Prints the registration form
1630 * @author Andreas Gohr <andi@splitbrain.org>
1632 function html_register(){
1637 $base_attrs = array('size'=>50,'required'=>'required');
1638 $email_attrs = $base_attrs +
array('type'=>'email','class'=>'edit');
1640 print p_locale_xhtml('register');
1641 print '<div class="centeralign">'.NL
;
1642 $form = new Doku_Form(array('id' => 'dw__register'));
1643 $form->startFieldset($lang['btn_register']);
1644 $form->addHidden('do', 'register');
1645 $form->addHidden('save', '1');
1646 $form->addElement(form_makeTextField('login', $INPUT->post
->str('login'), $lang['user'], '', 'block', $base_attrs));
1647 if (!$conf['autopasswd']) {
1648 $form->addElement(form_makePasswordField('pass', $lang['pass'], '', 'block', $base_attrs));
1649 $form->addElement(form_makePasswordField('passchk', $lang['passchk'], '', 'block', $base_attrs));
1651 $form->addElement(form_makeTextField('fullname', $INPUT->post
->str('fullname'), $lang['fullname'], '', 'block', $base_attrs));
1652 $form->addElement(form_makeField('email','email', $INPUT->post
->str('email'), $lang['email'], '', 'block', $email_attrs));
1653 $form->addElement(form_makeButton('submit', '', $lang['btn_register']));
1654 $form->endFieldset();
1655 html_form('register', $form);
1661 * Print the update profile form
1663 * @author Christopher Smith <chris@jalakai.co.uk>
1664 * @author Andreas Gohr <andi@splitbrain.org>
1666 function html_updateprofile(){
1671 /** @var DokuWiki_Auth_Plugin $auth */
1674 print p_locale_xhtml('updateprofile');
1675 print '<div class="centeralign">'.NL
;
1677 $fullname = $INPUT->post
->str('fullname', $INFO['userinfo']['name'], true);
1678 $email = $INPUT->post
->str('email', $INFO['userinfo']['mail'], true);
1679 $form = new Doku_Form(array('id' => 'dw__register'));
1680 $form->startFieldset($lang['profile']);
1681 $form->addHidden('do', 'profile');
1682 $form->addHidden('save', '1');
1683 $form->addElement(form_makeTextField('login', $_SERVER['REMOTE_USER'], $lang['user'], '', 'block', array('size'=>'50', 'disabled'=>'disabled')));
1684 $attr = array('size'=>'50');
1685 if (!$auth->canDo('modName')) $attr['disabled'] = 'disabled';
1686 $form->addElement(form_makeTextField('fullname', $fullname, $lang['fullname'], '', 'block', $attr));
1687 $attr = array('size'=>'50', 'class'=>'edit');
1688 if (!$auth->canDo('modMail')) $attr['disabled'] = 'disabled';
1689 $form->addElement(form_makeField('email','email', $email, $lang['email'], '', 'block', $attr));
1690 $form->addElement(form_makeTag('br'));
1691 if ($auth->canDo('modPass')) {
1692 $form->addElement(form_makePasswordField('newpass', $lang['newpass'], '', 'block', array('size'=>'50')));
1693 $form->addElement(form_makePasswordField('passchk', $lang['passchk'], '', 'block', array('size'=>'50')));
1695 if ($conf['profileconfirm']) {
1696 $form->addElement(form_makeTag('br'));
1697 $form->addElement(form_makePasswordField('oldpass', $lang['oldpass'], '', 'block', array('size'=>'50', 'required' => 'required')));
1699 $form->addElement(form_makeButton('submit', '', $lang['btn_save']));
1700 $form->addElement(form_makeButton('reset', '', $lang['btn_reset']));
1702 $form->endFieldset();
1703 html_form('updateprofile', $form);
1705 if ($auth->canDo('delUser') && actionOK('profile_delete')) {
1706 $form_profiledelete = new Doku_Form(array('id' => 'dw__profiledelete'));
1707 $form_profiledelete->startFieldset($lang['profdeleteuser']);
1708 $form_profiledelete->addHidden('do', 'profile_delete');
1709 $form_profiledelete->addHidden('delete', '1');
1710 $form_profiledelete->addElement(form_makeCheckboxField('confirm_delete', '1', $lang['profconfdelete'],'dw__confirmdelete','', array('required' => 'required')));
1711 if ($conf['profileconfirm']) {
1712 $form_profiledelete->addElement(form_makeTag('br'));
1713 $form_profiledelete->addElement(form_makePasswordField('oldpass', $lang['oldpass'], '', 'block', array('size'=>'50', 'required' => 'required')));
1715 $form_profiledelete->addElement(form_makeButton('submit', '', $lang['btn_deleteuser']));
1716 $form_profiledelete->endFieldset();
1718 html_form('profiledelete', $form_profiledelete);
1725 * Preprocess edit form data
1727 * @author Andreas Gohr <andi@splitbrain.org>
1729 * @triggers HTML_EDITFORM_OUTPUT
1731 function html_edit(){
1744 if ($INPUT->has('changecheck')) {
1745 $check = $INPUT->str('changecheck');
1746 } elseif(!$INFO['exists']){
1747 // $TEXT has been loaded from page template
1750 $check = md5($TEXT);
1752 $mod = md5($TEXT) !== $check;
1754 $wr = $INFO['writable'] && !$INFO['locked'];
1757 if ($REV) $include = 'editrev';
1759 // check pseudo action 'source'
1760 if(!actionOK('source')){
1761 msg('Command disabled: source',-1);
1769 $form = new Doku_Form(array('id' => 'dw__editform'));
1770 $form->addHidden('id', $ID);
1771 $form->addHidden('rev', $REV);
1772 $form->addHidden('date', $DATE);
1773 $form->addHidden('prefix', $PRE . '.');
1774 $form->addHidden('suffix', $SUF);
1775 $form->addHidden('changecheck', $check);
1777 $data = array('form' => $form,
1779 'media_manager' => true,
1780 'target' => ($INPUT->has('target') && $wr) ?
$INPUT->str('target') : 'section',
1781 'intro_locale' => $include);
1783 if ($data['target'] !== 'section') {
1784 // Only emit event if page is writable, section edit data is valid and
1785 // edit target is not section.
1786 trigger_event('HTML_EDIT_FORMSELECTION', $data, 'html_edit_form', true);
1788 html_edit_form($data);
1790 if (isset($data['intro_locale'])) {
1791 echo p_locale_xhtml($data['intro_locale']);
1794 $form->addHidden('target', $data['target']);
1795 if ($INPUT->has('hid')) {
1796 $form->addHidden('hid', $INPUT->str('hid'));
1798 if ($INPUT->has('codeblockOffset')) {
1799 $form->addHidden('codeblockOffset', $INPUT->str('codeblockOffset'));
1801 $form->addElement(form_makeOpenTag('div', array('id'=>'wiki__editbar', 'class'=>'editBar')));
1802 $form->addElement(form_makeOpenTag('div', array('id'=>'size__ctl')));
1803 $form->addElement(form_makeCloseTag('div'));
1805 $form->addElement(form_makeOpenTag('div', array('class'=>'editButtons')));
1806 $form->addElement(form_makeButton('submit', 'save', $lang['btn_save'], array('id'=>'edbtn__save', 'accesskey'=>'s', 'tabindex'=>'4')));
1807 $form->addElement(form_makeButton('submit', 'preview', $lang['btn_preview'], array('id'=>'edbtn__preview', 'accesskey'=>'p', 'tabindex'=>'5')));
1808 $form->addElement(form_makeButton('submit', 'cancel', $lang['btn_cancel'], array('tabindex'=>'6')));
1809 $form->addElement(form_makeCloseTag('div'));
1810 $form->addElement(form_makeOpenTag('div', array('class'=>'summary')));
1811 $form->addElement(form_makeTextField('summary', $SUM, $lang['summary'], 'edit__summary', 'nowrap', array('size'=>'50', 'tabindex'=>'2')));
1812 $elem = html_minoredit();
1813 if ($elem) $form->addElement($elem);
1814 $form->addElement(form_makeCloseTag('div'));
1816 $form->addElement(form_makeCloseTag('div'));
1817 if($wr && $conf['license']){
1818 $form->addElement(form_makeOpenTag('div', array('class'=>'license')));
1819 $out = $lang['licenseok'];
1820 $out .= ' <a href="'.$license[$conf['license']]['url'].'" rel="license" class="urlextern"';
1821 if($conf['target']['extern']) $out .= ' target="'.$conf['target']['extern'].'"';
1822 $out .= '>'.$license[$conf['license']]['name'].'</a>';
1823 $form->addElement($out);
1824 $form->addElement(form_makeCloseTag('div'));
1828 // sets changed to true when previewed
1829 echo '<script type="text/javascript">/*<![CDATA[*/'. NL
;
1830 echo 'textChanged = ' . ($mod ?
'true' : 'false');
1831 echo '/*!]]>*/</script>' . NL
;
1833 <div
class="editBox" role
="application">
1835 <div
class="toolbar group">
1836 <div id
="tool__bar" class="tool__bar"><?php
if ($wr && $data['media_manager']){?
><a href
="<?php echo DOKU_BASE?>lib/exe/mediamanager.php?ns=<?php echo $INFO['namespace']?>"
1837 target
="_blank"><?php
echo $lang['mediaselect'] ?
></a
><?php
}?
></div
>
1839 <div id
="draft__status" class="draft__status">
1841 $draft = new \dokuwiki\
Draft($ID, $INFO['client']);
1842 if ($draft->isDraftAvailable()) {
1843 echo $draft->getDraftMessage();
1849 html_form('edit', $form);
1854 * Display the default edit form
1856 * Is the default action for HTML_EDIT_FORMSELECTION.
1858 * @param mixed[] $param
1860 function html_edit_form($param) {
1863 if ($param['target'] !== 'section') {
1864 msg('No editor for edit target ' . hsc($param['target']) . ' found.', -1);
1867 $attr = array('tabindex'=>'1');
1868 if (!$param['wr']) $attr['readonly'] = 'readonly';
1870 $param['form']->addElement(form_makeWikiText($TEXT, $attr));
1874 * Adds a checkbox for minor edits for logged in users
1876 * @author Andreas Gohr <andi@splitbrain.org>
1878 * @return array|bool
1880 function html_minoredit(){
1884 // minor edits are for logged in users only
1885 if(!$conf['useacl'] ||
!$_SERVER['REMOTE_USER']){
1891 if($INPUT->bool('minor')) $p['checked']='checked';
1892 return form_makeCheckboxField('minor', '1', $lang['minoredit'], 'minoredit', 'nowrap', $p);
1896 * prints some debug info
1898 * @author Andreas Gohr <andi@splitbrain.org>
1900 function html_debug(){
1903 /** @var DokuWiki_Auth_Plugin $auth */
1907 //remove sensitive data
1915 print '<html><body>';
1917 print '<p>When reporting bugs please send all the following ';
1918 print 'output as a mail to andi@splitbrain.org ';
1919 print 'The best way to do this is to save this page in your browser</p>';
1921 print '<b>$INFO:</b><pre>';
1925 print '<b>$_SERVER:</b><pre>';
1929 print '<b>$conf:</b><pre>';
1933 print '<b>DOKU_BASE:</b><pre>';
1937 print '<b>abs DOKU_BASE:</b><pre>';
1941 print '<b>rel DOKU_BASE:</b><pre>';
1942 print dirname($_SERVER['PHP_SELF']).'/';
1945 print '<b>PHP Version:</b><pre>';
1949 print '<b>locale:</b><pre>';
1950 print setlocale(LC_ALL
,0);
1953 print '<b>encoding:</b><pre>';
1954 print $lang['encoding'];
1958 print '<b>Auth backend capabilities:</b><pre>';
1959 foreach ($auth->getCapabilities() as $cando){
1960 print ' '.str_pad($cando,16) . ' => ' . (int)$auth->canDo($cando) . NL
;
1965 print '<b>$_SESSION:</b><pre>';
1969 print '<b>Environment:</b><pre>';
1973 print '<b>PHP settings:</b><pre>';
1974 $inis = ini_get_all();
1978 if (function_exists('apache_get_version')) {
1980 $apache['version'] = apache_get_version();
1982 if (function_exists('apache_get_modules')) {
1983 $apache['modules'] = apache_get_modules();
1985 print '<b>Apache</b><pre>';
1990 print '</body></html>';
1994 * Form to request a new password for an existing account
1996 * @author Benoit Chesneau <benoit@bchesneau.info>
1997 * @author Andreas Gohr <gohr@cosmocode.de>
1999 function html_resendpwd() {
2004 $token = preg_replace('/[^a-f0-9]+/','',$INPUT->str('pwauth'));
2006 if(!$conf['autopasswd'] && $token){
2007 print p_locale_xhtml('resetpwd');
2008 print '<div class="centeralign">'.NL
;
2009 $form = new Doku_Form(array('id' => 'dw__resendpwd'));
2010 $form->startFieldset($lang['btn_resendpwd']);
2011 $form->addHidden('token', $token);
2012 $form->addHidden('do', 'resendpwd');
2014 $form->addElement(form_makePasswordField('pass', $lang['pass'], '', 'block', array('size'=>'50')));
2015 $form->addElement(form_makePasswordField('passchk', $lang['passchk'], '', 'block', array('size'=>'50')));
2017 $form->addElement(form_makeButton('submit', '', $lang['btn_resendpwd']));
2018 $form->endFieldset();
2019 html_form('resendpwd', $form);
2022 print p_locale_xhtml('resendpwd');
2023 print '<div class="centeralign">'.NL
;
2024 $form = new Doku_Form(array('id' => 'dw__resendpwd'));
2025 $form->startFieldset($lang['resendpwd']);
2026 $form->addHidden('do', 'resendpwd');
2027 $form->addHidden('save', '1');
2028 $form->addElement(form_makeTag('br'));
2029 $form->addElement(form_makeTextField('login', $INPUT->post
->str('login'), $lang['user'], '', 'block'));
2030 $form->addElement(form_makeTag('br'));
2031 $form->addElement(form_makeTag('br'));
2032 $form->addElement(form_makeButton('submit', '', $lang['btn_resendpwd']));
2033 $form->endFieldset();
2034 html_form('resendpwd', $form);
2040 * Return the TOC rendered to XHTML
2042 * @author Andreas Gohr <andi@splitbrain.org>
2045 * @return string html
2047 function html_TOC($toc){
2048 if(!count($toc)) return '';
2050 $out = '<!-- TOC START -->'.DOKU_LF
;
2051 $out .= '<div id="dw__toc" class="dw__toc">'.DOKU_LF
;
2052 $out .= '<h3 class="toggle">';
2053 $out .= $lang['toc'];
2054 $out .= '</h3>'.DOKU_LF
;
2055 $out .= '<div>'.DOKU_LF
;
2056 $out .= html_buildlist($toc,'toc','html_list_toc','html_li_default',true);
2057 $out .= '</div>'.DOKU_LF
.'</div>'.DOKU_LF
;
2058 $out .= '<!-- TOC END -->'.DOKU_LF
;
2063 * Callback for html_buildlist
2065 * @param array $item
2066 * @return string html
2068 function html_list_toc($item){
2069 if(isset($item['hid'])){
2070 $link = '#'.$item['hid'];
2072 $link = $item['link'];
2075 return '<a href="'.$link.'">'.hsc($item['title']).'</a>';
2079 * Helper function to build TOC items
2081 * Returns an array ready to be added to a TOC array
2083 * @param string $link - where to link (if $hash set to '#' it's a local anchor)
2084 * @param string $text - what to display in the TOC
2085 * @param int $level - nesting level
2086 * @param string $hash - is prepended to the given $link, set blank if you want full links
2087 * @return array the toc item
2089 function html_mktocitem($link, $text, $level, $hash='#'){
2090 return array( 'link' => $hash.$link,
2097 * Output a Doku_Form object.
2098 * Triggers an event with the form name: HTML_{$name}FORM_OUTPUT
2100 * @author Tom N Harris <tnharris@whoopdedo.org>
2102 * @param string $name The name of the form
2103 * @param Doku_Form $form The form
2105 function html_form($name, &$form) {
2106 // Safety check in case the caller forgets.
2107 $form->endFieldset();
2108 trigger_event('HTML_'.strtoupper($name).'FORM_OUTPUT', $form, 'html_form_output', false);
2112 * Form print function.
2113 * Just calls printForm() on the data object.
2115 * @param Doku_Form $data The form
2117 function html_form_output($data) {
2122 * Embed a flash object in HTML
2124 * This will create the needed HTML to embed a flash movie in a cross browser
2125 * compatble way using valid XHTML
2127 * The parameters $params, $flashvars and $atts need to be associative arrays.
2128 * No escaping needs to be done for them. The alternative content *has* to be
2129 * escaped because it is used as is. If no alternative content is given
2130 * $lang['noflash'] is used.
2132 * @author Andreas Gohr <andi@splitbrain.org>
2133 * @link http://latrine.dgx.cz/how-to-correctly-insert-a-flash-into-xhtml
2135 * @param string $swf - the SWF movie to embed
2136 * @param int $width - width of the flash movie in pixels
2137 * @param int $height - height of the flash movie in pixels
2138 * @param array $params - additional parameters (<param>)
2139 * @param array $flashvars - parameters to be passed in the flashvar parameter
2140 * @param array $atts - additional attributes for the <object> tag
2141 * @param string $alt - alternative content (is NOT automatically escaped!)
2142 * @return string - the XHTML markup
2144 function html_flashobject($swf,$width,$height,$params=null,$flashvars=null,$atts=null,$alt=''){
2149 // prepare the object attributes
2150 if(is_null($atts)) $atts = array();
2151 $atts['width'] = (int) $width;
2152 $atts['height'] = (int) $height;
2153 if(!$atts['width']) $atts['width'] = 425;
2154 if(!$atts['height']) $atts['height'] = 350;
2156 // add object attributes for standard compliant browsers
2158 $std['type'] = 'application/x-shockwave-flash';
2159 $std['data'] = $swf;
2161 // add object attributes for IE
2163 $ie['classid'] = 'clsid:D27CDB6E-AE6D-11cf-96B8-444553540000';
2165 // open object (with conditional comments)
2166 $out .= '<!--[if !IE]> -->'.NL
;
2167 $out .= '<object '.buildAttributes($std).'>'.NL
;
2168 $out .= '<!-- <![endif]-->'.NL
;
2169 $out .= '<!--[if IE]>'.NL
;
2170 $out .= '<object '.buildAttributes($ie).'>'.NL
;
2171 $out .= ' <param name="movie" value="'.hsc($swf).'" />'.NL
;
2172 $out .= '<!--><!-- -->'.NL
;
2175 if(is_array($params)) foreach($params as $key => $val){
2176 $out .= ' <param name="'.hsc($key).'" value="'.hsc($val).'" />'.NL
;
2180 if(is_array($flashvars)){
2181 $out .= ' <param name="FlashVars" value="'.buildURLparams($flashvars).'" />'.NL
;
2184 // alternative content
2188 $out .= $lang['noflash'].NL
;
2192 $out .= '</object>'.NL
;
2193 $out .= '<!-- <![endif]-->'.NL
;
2199 * Prints HTML code for the given tab structure
2201 * @param array $tabs tab structure
2202 * @param string $current_tab the current tab id
2204 function html_tabs($tabs, $current_tab = null) {
2205 echo '<ul class="tabs">'.NL
;
2207 foreach($tabs as $id => $tab) {
2208 html_tab($tab['href'], $tab['caption'], $id === $current_tab);
2215 * Prints a single tab
2217 * @author Kate Arzamastseva <pshns@ukr.net>
2218 * @author Adrian Lang <mail@adrianlang.de>
2220 * @param string $href - tab href
2221 * @param string $caption - tab caption
2222 * @param boolean $selected - is tab selected
2225 function html_tab($href, $caption, $selected=false) {
2230 $tab .= '<a href="' . hsc($href) . '">';
2232 $tab .= hsc($caption)
2233 . '</' . ($selected ?
'strong' : 'a') . '>'
2239 * Display size change
2241 * @param int $sizechange - size of change in Bytes
2242 * @param Doku_Form $form - form to add elements to
2245 function html_sizechange($sizechange, Doku_Form
$form) {
2246 if(isset($sizechange)) {
2247 $class = 'sizechange';
2248 $value = filesize_h(abs($sizechange));
2249 if($sizechange > 0) {
2250 $class .= ' positive';
2251 $value = '+' . $value;
2252 } elseif($sizechange < 0) {
2253 $class .= ' negative';
2254 $value = '-' . $value;
2256 $value = '±' . $value;
2258 $form->addElement(form_makeOpenTag('span', array('class' => $class)));
2259 $form->addElement($value);
2260 $form->addElement(form_makeCloseTag('span'));