summaryrefslogtreecommitdiff
path: root/inc/html.php
diff options
context:
space:
mode:
authorghi <dokuwiki@imz.re>2015-02-17 11:08:15 +0100
committerghi <dokuwiki@imz.re>2015-02-17 11:08:15 +0100
commit7d0b7e5ed7aa0f9c56def8f6c9866aa4fc8315b8 (patch)
tree08330b0a548a402caeb02ee7a185e745386ad45d /inc/html.php
parentd6dc28be40fb3202a3df69458db164e20999ac2b (diff)
parentf8803275a58a05b29e4029cc539a6f8c60ad2ea5 (diff)
downloadrpg-7d0b7e5ed7aa0f9c56def8f6c9866aa4fc8315b8.tar.gz
rpg-7d0b7e5ed7aa0f9c56def8f6c9866aa4fc8315b8.tar.bz2
Merge https://github.com/splitbrain/dokuwiki into html_showrev_output
Diffstat (limited to 'inc/html.php')
-rw-r--r--inc/html.php612
1 files changed, 481 insertions, 131 deletions
diff --git a/inc/html.php b/inc/html.php
index 7f473cdb6..3a93a6604 100644
--- a/inc/html.php
+++ b/inc/html.php
@@ -19,6 +19,7 @@ if(!defined('NL')) define('NL',"\n");
* @return string the HTML code of the link
*/
function html_wikilink($id,$name=null,$search=''){
+ /** @var Doku_Renderer_xhtml $xhtml_renderer */
static $xhtml_renderer = null;
if(is_null($xhtml_renderer)){
$xhtml_renderer = p_get_renderer('xhtml');
@@ -64,10 +65,28 @@ function html_login(){
print '</div>'.NL;
}
+
+/**
+ * Denied page content
+ *
+ * @return string html
+ */
+function html_denied() {
+ print p_locale_xhtml('denied');
+
+ if(!$_SERVER['REMOTE_USER']){
+ html_login();
+ }
+}
+
/**
* inserts section edit buttons if wanted or removes the markers
*
* @author Andreas Gohr <andi@splitbrain.org>
+ *
+ * @param string $text
+ * @param bool $show show section edit buttons?
+ * @return string
*/
function html_secedit($text,$show=true){
global $INFO;
@@ -86,8 +105,11 @@ function html_secedit($text,$show=true){
* prepares section edit button data for event triggering
* used as a callback in html_secedit
*
- * @triggers HTML_SECEDIT_BUTTON
* @author Andreas Gohr <andi@splitbrain.org>
+ *
+ * @param array $matches matches with regexp
+ * @return string
+ * @triggers HTML_SECEDIT_BUTTON
*/
function html_secedit_button($matches){
$data = array('secid' => $matches[1],
@@ -106,6 +128,9 @@ function html_secedit_button($matches){
* used as default action form HTML_SECEDIT_BUTTON
*
* @author Adrian Lang <lang@cosmocode.de>
+ *
+ * @param array $data name, section id and target
+ * @return string html
*/
function html_secedit_get_button($data) {
global $ID;
@@ -132,6 +157,8 @@ function html_secedit_get_button($data) {
* Just the back to top button (in its own form)
*
* @author Andreas Gohr <andi@splitbrain.org>
+ *
+ * @return string html
*/
function html_topbtn(){
global $lang;
@@ -146,6 +173,15 @@ function html_topbtn(){
* If tooltip exists, the access key tooltip is replaced.
*
* @author Andreas Gohr <andi@splitbrain.org>
+ *
+ * @param string $name
+ * @param string $id
+ * @param string $akey access key
+ * @param string[] $params key-value pairs added as hidden inputs
+ * @param string $method
+ * @param string $tooltip
+ * @param bool|string $label label text, false: lookup btn_$name in localization
+ * @return string
*/
function html_btn($name,$id,$akey,$params,$method='get',$tooltip='',$label=false){
global $conf;
@@ -198,15 +234,18 @@ function html_btn($name,$id,$akey,$params,$method='get',$tooltip='',$label=false
}
/**
- * show a wiki page
+ * Show a wiki page
*
* @author Andreas Gohr <andi@splitbrain.org>
+ *
+ * @param null|string $txt wiki text or null for showing $ID
*/
function html_show($txt=null){
global $ID;
global $REV;
global $HIGH;
global $INFO;
+ global $DATE_AT;
//disable section editing for old revisions or in preview
if($txt || $REV){
$secedit = false;
@@ -226,8 +265,8 @@ function html_show($txt=null){
echo '</div></div>';
}else{
- if ($REV) print p_locale_xhtml('showrev');
- $html = p_wiki_xhtml($ID,$REV,true);
+ if ($REV||$DATE_AT) print p_locale_xhtml('showrev');
+ $html = p_wiki_xhtml($ID,$REV,true,$DATE_AT);
$html = html_secedit($html,$secedit);
if($INFO['prependTOC']) $html = tpl_toc(true).$html;
$html = html_hilight($html,$HIGH);
@@ -266,6 +305,10 @@ function html_draft(){
*
* @author Andreas Gohr <andi@splitbrain.org>
* @author Harry Fuecks <hfuecks@gmail.com>
+ *
+ * @param string $html
+ * @param array|string $phrases
+ * @return string html
*/
function html_hilight($html,$phrases){
$phrases = (array) $phrases;
@@ -284,6 +327,9 @@ function html_hilight($html,$phrases){
* Callback used by html_hilight()
*
* @author Harry Fuecks <hfuecks@gmail.com>
+ *
+ * @param array $m matches
+ * @return string html
*/
function html_hilight_callback($m) {
$hlight = unslash($m[0]);
@@ -299,15 +345,17 @@ function html_hilight_callback($m) {
* @author Andreas Gohr <andi@splitbrain.org>
*/
function html_search(){
- global $QUERY;
+ global $QUERY, $ID;
global $lang;
$intro = p_locale_xhtml('searchpage');
// allow use of placeholder in search intro
+ $pagecreateinfo = (auth_quickaclcheck($ID) >= AUTH_CREATE) ? $lang['searchcreatepage'] : '';
$intro = str_replace(
- array('@QUERY@','@SEARCH@'),
- array(hsc(rawurlencode($QUERY)),hsc($QUERY)),
- $intro);
+ array('@QUERY@', '@SEARCH@', '@CREATEPAGEINFO@'),
+ array(hsc(rawurlencode($QUERY)), hsc($QUERY), $pagecreateinfo),
+ $intro
+ );
echo $intro;
flush();
@@ -396,8 +444,8 @@ function html_locked(){
print p_locale_xhtml('locked');
print '<ul>';
- print '<li><div class="li"><strong>'.$lang['lockedby'].':</strong> '.editorinfo($INFO['locked']).'</div></li>';
- print '<li><div class="li"><strong>'.$lang['lockexpire'].':</strong> '.$expire.' ('.$min.' min)</div></li>';
+ print '<li><div class="li"><strong>'.$lang['lockedby'].'</strong> '.editorinfo($INFO['locked']).'</div></li>';
+ print '<li><div class="li"><strong>'.$lang['lockexpire'].'</strong> '.$expire.' ('.$min.' min)</div></li>';
print '</ul>';
}
@@ -407,6 +455,9 @@ function html_locked(){
* @author Andreas Gohr <andi@splitbrain.org>
* @author Ben Coburn <btcoburn@silicodon.net>
* @author Kate Arzamastseva <pshns@ukr.net>
+ *
+ * @param int $first skip the first n changelog lines
+ * @param bool|string $media_id id of media, or false for current page
*/
function html_revisions($first=0, $media_id = false){
global $ID;
@@ -414,20 +465,23 @@ function html_revisions($first=0, $media_id = false){
global $conf;
global $lang;
$id = $ID;
+ if ($media_id) {
+ $id = $media_id;
+ $changelog = new MediaChangeLog($id);
+ } else {
+ $changelog = new PageChangeLog($id);
+ }
+
/* we need to get one additional log entry to be able to
* decide if this is the last page or is there another one.
* see html_recent()
*/
- if (!$media_id) $revisions = getRevisions($ID, $first, $conf['recent']+1);
- else {
- $revisions = getRevisions($media_id, $first, $conf['recent']+1, 8192, true);
- $id = $media_id;
- }
+
+ $revisions = $changelog->getRevisions($first, $conf['recent']+1);
if(count($revisions)==0 && $first!=0){
$first=0;
- if (!$media_id) $revisions = getRevisions($ID, $first, $conf['recent']+1);
- else $revisions = getRevisions($media_id, $first, $conf['recent']+1, 8192, true);
+ $revisions = $changelog->getRevisions($first, $conf['recent']+1);
}
$hasNext = false;
if (count($revisions)>$conf['recent']) {
@@ -447,7 +501,7 @@ function html_revisions($first=0, $media_id = false){
$form->addElement(form_makeOpenTag('ul'));
if (!$media_id) $exists = $INFO['exists'];
- else $exists = @file_exists(mediaFN($id));
+ else $exists = file_exists(mediaFN($id));
$display_name = (!$media_id && useHeading('navigation')) ? hsc(p_get_first_heading($id)) : $id;
if (!$display_name) $display_name = $id;
@@ -486,15 +540,18 @@ function html_revisions($first=0, $media_id = false){
$form->addElement(form_makeCloseTag('span'));
}
+ $changelog->setChunkSize(1024);
+
$form->addElement(form_makeOpenTag('span', array('class' => 'user')));
- if (!$media_id) $editor = $INFO['editor'];
- else {
- $revinfo = getRevisionInfo($id, @filemtime(fullpath(mediaFN($id))), 1024, true);
- if($revinfo['user']){
+ if($media_id) {
+ $revinfo = $changelog->getRevisionInfo(@filemtime(fullpath(mediaFN($id))));
+ if($revinfo['user']) {
$editor = $revinfo['user'];
- }else{
+ } else {
$editor = $revinfo['ip'];
}
+ } else {
+ $editor = $INFO['editor'];
}
$form->addElement((empty($editor))?('('.$lang['external_edit'].')'):editorinfo($editor));
$form->addElement(form_makeCloseTag('span'));
@@ -509,12 +566,11 @@ function html_revisions($first=0, $media_id = false){
foreach($revisions as $rev){
$date = dformat($rev);
- if (!$media_id) {
- $info = getRevisionInfo($id,$rev,true);
- $exists = page_exists($id,$rev);
- } else {
- $info = getRevisionInfo($id,$rev,true,true);
- $exists = @file_exists(mediaFN($id,$rev));
+ $info = $changelog->getRevisionInfo($rev);
+ if($media_id) {
+ $exists = file_exists(mediaFN($id, $rev));
+ } else {
+ $exists = page_exists($id, $rev);
}
if ($info['type']===DOKU_CHANGE_TYPE_MINOR_EDIT)
@@ -623,6 +679,9 @@ function html_revisions($first=0, $media_id = false){
* @author Matthias Grimm <matthiasgrimm@users.sourceforge.net>
* @author Ben Coburn <btcoburn@silicodon.net>
* @author Kate Arzamastseva <pshns@ukr.net>
+ *
+ * @param int $first
+ * @param string $show_changes
*/
function html_recent($first=0, $show_changes='both'){
global $conf;
@@ -691,7 +750,7 @@ function html_recent($first=0, $show_changes='both'){
$form->addElement(form_makeOpenTag('div', array('class' => 'li')));
- if ($recent['media']) {
+ if (!empty($recent['media'])) {
$form->addElement(media_printicon($recent['id']));
} else {
$icon = DOKU_BASE.'lib/images/fileicons/file.png';
@@ -705,8 +764,8 @@ function html_recent($first=0, $show_changes='both'){
$diff = false;
$href = '';
- if ($recent['media']) {
- $diff = (count(getRevisions($recent['id'], 0, 1, 8192, true)) && @file_exists(mediaFN($recent['id'])));
+ if (!empty($recent['media'])) {
+ $diff = (count(getRevisions($recent['id'], 0, 1, 8192, true)) && file_exists(mediaFN($recent['id'])));
if ($diff) {
$href = media_managerURL(array('tab_details' => 'history',
'mediado' => 'diff', 'image' => $recent['id'], 'ns' => getNS($recent['id'])), '&');
@@ -715,7 +774,7 @@ function html_recent($first=0, $show_changes='both'){
$href = wl($recent['id'],"do=diff", false, '&');
}
- if ($recent['media'] && !$diff) {
+ if (!empty($recent['media']) && !$diff) {
$form->addElement('<img src="'.DOKU_BASE.'lib/images/blank.gif" width="15" height="11" alt="" />');
} else {
$form->addElement(form_makeOpenTag('a', array('class' => 'diff_link', 'href' => $href)));
@@ -729,7 +788,7 @@ function html_recent($first=0, $show_changes='both'){
$form->addElement(form_makeCloseTag('a'));
}
- if ($recent['media']) {
+ if (!empty($recent['media'])) {
$href = media_managerURL(array('tab_details' => 'history',
'image' => $recent['id'], 'ns' => getNS($recent['id'])), '&');
} else {
@@ -745,7 +804,7 @@ function html_recent($first=0, $show_changes='both'){
)));
$form->addElement(form_makeCloseTag('a'));
- if ($recent['media']) {
+ if (!empty($recent['media'])) {
$href = media_managerURL(array('tab_details' => 'view', 'image' => $recent['id'], 'ns' => getNS($recent['id'])), '&');
$class = (file_exists(mediaFN($recent['id']))) ? 'wikilink1' : $class = 'wikilink2';
$form->addElement(form_makeOpenTag('a', array('class' => $class, 'href' => $href)));
@@ -810,6 +869,8 @@ function html_recent($first=0, $show_changes='both'){
* Display page index
*
* @author Andreas Gohr <andi@splitbrain.org>
+ *
+ * @param string $ns
*/
function html_index($ns){
global $conf;
@@ -838,6 +899,9 @@ function html_index($ns){
* User function for html_buildlist()
*
* @author Andreas Gohr <andi@splitbrain.org>
+ *
+ * @param array $item
+ * @return string
*/
function html_list_index($item){
global $ID, $conf;
@@ -868,10 +932,23 @@ function html_list_index($item){
* it gives different classes to opened or closed "folders"
*
* @author Andreas Gohr <andi@splitbrain.org>
+ *
+ * @param array $item
+ * @return string html
*/
function html_li_index($item){
+ global $INFO;
+
+ $class = '';
+ $id = '';
+
if($item['type'] == "f"){
- return '<li class="level'.$item['level'].'">';
+ // scroll to the current item
+ if($item['id'] == $INFO['id']) {
+ $id = ' id="scroll__here"';
+ $class = ' bounce';
+ }
+ return '<li class="level'.$item['level'].$class.'" '.$id.'>';
}elseif($item['open']){
return '<li class="open">';
}else{
@@ -883,6 +960,9 @@ function html_li_index($item){
* Default List item
*
* @author Andreas Gohr <andi@splitbrain.org>
+ *
+ * @param array $item
+ * @return string html
*/
function html_li_default($item){
return '<li class="level'.$item['level'].'">';
@@ -902,6 +982,14 @@ function html_li_default($item){
* a member of an object.
*
* @author Andreas Gohr <andi@splitbrain.org>
+ *
+ * @param array $data array with item arrays
+ * @param string $class class of ul wrapper
+ * @param callable $func callback to print an list item
+ * @param callable $lifunc callback to the opening li tag
+ * @param bool $forcewrapper Trigger building a wrapper ul if the first level is
+ 0 (we have a root object) or 1 (just the root content)
+ * @return string html of an unordered list
*/
function html_buildlist($data,$class,$func,$lifunc='html_li_default',$forcewrapper=false){
if (count($data) === 0) {
@@ -990,12 +1078,13 @@ function html_backlinks(){
/**
* Get header of diff HTML
+ *
* @param string $l_rev Left revisions
* @param string $r_rev Right revision
* @param string $id Page id, if null $ID is used
* @param bool $media If it is for media files
* @param bool $inline Return the header on a single line
- * @return array HTML snippets for diff header
+ * @return string[] HTML snippets for diff header
*/
function html_diff_head($l_rev, $r_rev, $id = null, $media = false, $inline = false) {
global $lang;
@@ -1008,10 +1097,15 @@ function html_diff_head($l_rev, $r_rev, $id = null, $media = false, $inline = fa
$ml_or_wl = $media ? 'ml' : 'wl';
$l_minor = $r_minor = '';
+ if($media) {
+ $changelog = new MediaChangeLog($id);
+ } else {
+ $changelog = new PageChangeLog($id);
+ }
if(!$l_rev){
$l_head = '&mdash;';
}else{
- $l_info = getRevisionInfo($id,$l_rev,true, $media);
+ $l_info = $changelog->getRevisionInfo($l_rev);
if($l_info['user']){
$l_user = '<bdi>'.editorinfo($l_info['user']).'</bdi>';
if(auth_ismanager()) $l_user .= ' <bdo dir="ltr">('.$l_info['ip'].')</bdo>';
@@ -1029,7 +1123,7 @@ function html_diff_head($l_rev, $r_rev, $id = null, $media = false, $inline = fa
}
if($r_rev){
- $r_info = getRevisionInfo($id,$r_rev,true, $media);
+ $r_info = $changelog->getRevisionInfo($r_rev);
if($r_info['user']){
$r_user = '<bdi>'.editorinfo($r_info['user']).'</bdi>';
if(auth_ismanager()) $r_user .= ' <bdo dir="ltr">('.$r_info['ip'].')</bdo>';
@@ -1045,7 +1139,7 @@ function html_diff_head($l_rev, $r_rev, $id = null, $media = false, $inline = fa
$r_head_title.'</a></bdi>'.
$head_separator.$r_user.' '.$r_sum;
}elseif($_rev = @filemtime($media_or_wikiFN($id))){
- $_info = getRevisionInfo($id,$_rev,true, $media);
+ $_info = $changelog->getRevisionInfo($_rev);
if($_info['user']){
$_user = '<bdi>'.editorinfo($_info['user']).'</bdi>';
if(auth_ismanager()) $_user .= ' <bdo dir="ltr">('.$_info['ip'].')</bdo>';
@@ -1069,162 +1163,386 @@ function html_diff_head($l_rev, $r_rev, $id = null, $media = false, $inline = fa
}
/**
- * show diff
+ * Show diff
+ * between current page version and provided $text
+ * or between the revisions provided via GET or POST
*
* @author Andreas Gohr <andi@splitbrain.org>
- * @param string $text - 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)
+ * @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 html_diff($text='',$intro=true,$type=null){
+function 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)) {
+ if(empty($type)) {
$type = get_doku_pref('difftype', $type);
- if (empty($type) && $INFO['ismobile']) {
+ if(empty($type) && $INFO['ismobile']) {
$type = 'inline';
}
}
}
if($type != 'inline') $type = 'sidebyside';
+ /*
+ * 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)){
+ if(is_array($rev2)) {
$rev1 = (int) $rev2[0];
$rev2 = (int) $rev2[1];
- if(!$rev1){
+ if(!$rev1) {
$rev1 = $rev2;
unset($rev2);
}
- }else{
+ } 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> '.
+ 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
+ $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){
+ if($rev1 < $rev2) {
$l_rev = $rev1;
$r_rev = $rev2;
- }else{
+ } else {
$l_rev = $rev2;
$r_rev = $rev1;
}
- }elseif($rev1){ // single revision given, compare to current
+ } elseif($rev1) { // single revision given, compare to current
$r_rev = '';
$l_rev = $rev1;
- }else{ // no revision was given, compare previous to current
+ } else { // no revision was given, compare previous to current
$r_rev = '';
- $revs = getRevisions($ID, 0, 1);
+ $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){
+ if(!$l_rev && !$r_rev) {
$l_text = '';
- }else{
- $l_text = rawWiki($ID,$l_rev);
+ } else {
+ $l_text = rawWiki($ID, $l_rev);
}
- $r_text = rawWiki($ID,$r_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');
}
- $df = new Diff(explode("\n",$l_text),explode("\n",$r_text));
+ /*
+ * 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'){
- $tdf = new InlineDiffFormatter();
+ if($type == 'inline') {
+ $diffformatter = new InlineDiffFormatter();
} else {
- $tdf = new TableDiffFormatter();
+ $diffformatter = new TableDiffFormatter();
}
-
+ /*
+ * Display intro
+ */
if($intro) print p_locale_xhtml('diff');
- if (!$text) {
- ptln('<div class="diffoptions">');
-
- $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(
- 'sidebyside' => $lang['diff_side'],
- 'inline' => $lang['diff_inline']),
- $type,
- $lang['diff_type'],
- '','',
- array('class'=>'quickselect')));
- $form->addElement(form_makeButton('submit', 'diff','Go'));
+ /*
+ * 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(
+ 'sidebyside' => $lang['diff_side'],
+ 'inline' => $lang['diff_inline']
+ ),
+ $type,
+ $lang['diff_type'],
+ '', '',
+ array('class' => 'quickselect')
+ )
+ );
+ $form->addElement(form_makeButton('submit', 'diff', 'Go'));
$form->printForm();
- $diffurl = wl($ID, array(
- 'do' => 'diff',
- 'rev2[0]' => $l_rev,
- 'rev2[1]' => $r_rev,
- 'difftype' => $type,
- ));
- ptln('<p><a class="wikilink1" href="'.$diffurl.'">'.$lang['difflink'].'</a></p>');
- ptln('</div>');
+ 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 if ($type == 'inline') { ?>
- <tr>
- <th class="diff-lineheader">-</th><th <?php echo $l_minor?>>
- <?php echo $l_head?>
- </th>
- </tr>
- <tr>
- <th class="diff-lineheader">+</th><th <?php echo $r_minor?>>
- <?php echo $r_head?>
- </th>
- </tr>
- <?php } else { ?>
- <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 }
- echo html_insert_softbreaks($tdf->format($df)); ?>
+ <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
+<?php
+}
+
+/**
+ * Create html for revision navigation
+ *
+ * @param PageChangeLog $pagelog changelog object of current page
+ * @param string $type inline vs sidebyside
+ * @param int $l_rev left revision timestamp
+ * @param int $r_rev right revision timestamp
+ * @return string[] html of left and right navigation elements
+ */
+function html_diff_navigation($pagelog, $type, $l_rev, $r_rev) {
+ global $INFO, $ID;
+
+ // last timestamp is not in changelog, retrieve timestamp from metadata
+ // note: when page is removed, the metadata timestamp is zero
+ $r_rev = $r_rev ? $r_rev : $INFO['meta']['last_change']['date'];
+
+ //retrieve revisions with additional info
+ list($l_revs, $r_revs) = $pagelog->getRevisionsAround($l_rev, $r_rev);
+ $l_revisions = array();
+ if(!$l_rev) {
+ $l_revisions[0] = array(0, "", false); //no left revision given, add dummy
+ }
+ foreach($l_revs as $rev) {
+ $info = $pagelog->getRevisionInfo($rev);
+ $l_revisions[$rev] = array(
+ $rev,
+ dformat($info['date']) . ' ' . editorinfo($info['user'], true) . ' ' . $info['sum'],
+ $r_rev ? $rev >= $r_rev : false //disable?
+ );
+ }
+ $r_revisions = array();
+ if(!$r_rev) {
+ $r_revisions[0] = array(0, "", false); //no right revision given, add dummy
+ }
+ foreach($r_revs as $rev) {
+ $info = $pagelog->getRevisionInfo($rev);
+ $r_revisions[$rev] = array(
+ $rev,
+ dformat($info['date']) . ' ' . editorinfo($info['user'], true) . ' ' . $info['sum'],
+ $rev <= $l_rev //disable?
+ );
+ }
+
+ //determine previous/next revisions
+ $l_index = array_search($l_rev, $l_revs);
+ $l_prev = $l_revs[$l_index + 1];
+ $l_next = $l_revs[$l_index - 1];
+ if($r_rev) {
+ $r_index = array_search($r_rev, $r_revs);
+ $r_prev = $r_revs[$r_index + 1];
+ $r_next = $r_revs[$r_index - 1];
+ } else {
+ //removed page
+ if($l_next) {
+ $r_prev = $r_revs[0];
+ } else {
+ $r_prev = null;
+ }
+ $r_next = null;
+ }
+
+ /*
+ * Left side:
+ */
+ $l_nav = '';
+ //move back
+ if($l_prev) {
+ $l_nav .= html_diff_navigationlink($type, 'diffbothprevrev', $l_prev, $r_prev);
+ $l_nav .= html_diff_navigationlink($type, 'diffprevrev', $l_prev, $r_rev);
+ }
+ //dropdown
+ $form = new Doku_Form(array('action' => wl()));
+ $form->addHidden('id', $ID);
+ $form->addHidden('difftype', $type);
+ $form->addHidden('rev2[1]', $r_rev);
+ $form->addHidden('do', 'diff');
+ $form->addElement(
+ form_makeListboxField(
+ 'rev2[0]',
+ $l_revisions,
+ $l_rev,
+ '', '', '',
+ array('class' => 'quickselect')
+ )
+ );
+ $form->addElement(form_makeButton('submit', 'diff', 'Go'));
+ $l_nav .= $form->getForm();
+ //move forward
+ if($l_next && ($l_next < $r_rev || !$r_rev)) {
+ $l_nav .= html_diff_navigationlink($type, 'diffnextrev', $l_next, $r_rev);
+ }
+
+ /*
+ * Right side:
+ */
+ $r_nav = '';
+ //move back
+ if($l_rev < $r_prev) {
+ $r_nav .= html_diff_navigationlink($type, 'diffprevrev', $l_rev, $r_prev);
+ }
+ //dropdown
+ $form = new Doku_Form(array('action' => wl()));
+ $form->addHidden('id', $ID);
+ $form->addHidden('rev2[0]', $l_rev);
+ $form->addHidden('difftype', $type);
+ $form->addHidden('do', 'diff');
+ $form->addElement(
+ form_makeListboxField(
+ 'rev2[1]',
+ $r_revisions,
+ $r_rev,
+ '', '', '',
+ array('class' => 'quickselect')
+ )
+ );
+ $form->addElement(form_makeButton('submit', 'diff', 'Go'));
+ $r_nav .= $form->getForm();
+ //move forward
+ if($r_next) {
+ if($pagelog->isCurrentRevision($r_next)) {
+ $r_nav .= html_diff_navigationlink($type, 'difflastrev', $l_rev); //last revision is diff with current page
+ } else {
+ $r_nav .= html_diff_navigationlink($type, 'diffnextrev', $l_rev, $r_next);
+ }
+ $r_nav .= html_diff_navigationlink($type, 'diffbothnextrev', $l_next, $r_next);
+ }
+ return array($l_nav, $r_nav);
+}
+
+/**
+ * Create html link to a diff defined by two revisions
+ *
+ * @param string $difftype display type
+ * @param string $linktype
+ * @param int $lrev oldest revision
+ * @param int $rrev newest revision or null for diff with current revision
+ * @return string html of link to a diff
+ */
+function html_diff_navigationlink($difftype, $linktype, $lrev, $rrev = null) {
+ global $ID, $lang;
+ if(!$rrev) {
+ $urlparam = array(
+ 'do' => 'diff',
+ 'rev' => $lrev,
+ 'difftype' => $difftype,
+ );
+ } else {
+ $urlparam = array(
+ 'do' => 'diff',
+ 'rev2[0]' => $lrev,
+ 'rev2[1]' => $rrev,
+ 'difftype' => $difftype,
+ );
+ }
+ return '<a class="' . $linktype . '" href="' . wl($ID, $urlparam) . '" title="' . $lang[$linktype] . '">' .
+ '<span>' . $lang[$linktype] . '</span>' .
+ '</a>' . "\n";
}
+/**
+ * Insert soft breaks in diff html
+ *
+ * @param string $diffhtml
+ * @return string
+ */
function html_insert_softbreaks($diffhtml) {
// search the diff html string for both:
// - html tags, so these can be ignored
@@ -1232,6 +1550,12 @@ function html_insert_softbreaks($diffhtml) {
return preg_replace_callback('/<[^>]*>|[^<> ]{12,}/','html_softbreak_callback',$diffhtml);
}
+/**
+ * callback which adds softbreaks
+ *
+ * @param array $match array with first the complete match
+ * @return string the replacement
+ */
function html_softbreak_callback($match){
// if match is an html tag, return it intact
if ($match[0]{0} == '<') return $match[0];
@@ -1255,6 +1579,9 @@ REGEX;
* show warning on conflict detection
*
* @author Andreas Gohr <andi@splitbrain.org>
+ *
+ * @param string $text
+ * @param string $summary
*/
function html_conflict($text,$summary){
global $ID;
@@ -1343,7 +1670,7 @@ function html_updateprofile(){
global $conf;
global $INPUT;
global $INFO;
- /** @var auth_basic $auth */
+ /** @var DokuWiki_Auth_Plugin $auth */
global $auth;
print p_locale_xhtml('updateprofile');
@@ -1415,7 +1742,6 @@ function html_edit(){
global $lang;
global $conf;
global $TEXT;
- global $RANGE;
if ($INPUT->has('changecheck')) {
$check = $INPUT->str('changecheck');
@@ -1517,6 +1843,8 @@ function html_edit(){
* Display the default edit form
*
* Is the default action for HTML_EDIT_FORMSELECTION.
+ *
+ * @param mixed[] $param
*/
function html_edit_form($param) {
global $TEXT;
@@ -1535,6 +1863,8 @@ function html_edit_form($param) {
* Adds a checkbox for minor edits for logged in users
*
* @author Andreas Gohr <andi@splitbrain.org>
+ *
+ * @return array|bool
*/
function html_minoredit(){
global $conf;
@@ -1559,7 +1889,7 @@ function html_minoredit(){
function html_debug(){
global $conf;
global $lang;
- /** @var auth_basic $auth */
+ /** @var DokuWiki_Auth_Plugin $auth */
global $auth;
global $INFO;
@@ -1634,6 +1964,18 @@ function html_debug(){
print_r($inis);
print '</pre>';
+ if (function_exists('apache_get_version')) {
+ $apache = array();
+ $apache['version'] = apache_get_version();
+
+ if (function_exists('apache_get_modules')) {
+ $apache['modules'] = apache_get_modules();
+ }
+ print '<b>Apache</b><pre>';
+ print_r($apache);
+ print '</pre>';
+ }
+
print '</body></html>';
}
@@ -1698,12 +2040,12 @@ function html_admin(){
}
unset($menu['acl']);
- if($menu['plugin']){
+ if($menu['extension']){
ptln(' <li class="admin_plugin"><div class="li">'.
- '<a href="'.wl($ID, array('do' => 'admin','page' => 'plugin')).'">'.
- $menu['plugin']['prompt'].'</a></div></li>');
+ '<a href="'.wl($ID, array('do' => 'admin','page' => 'extension')).'">'.
+ $menu['extension']['prompt'].'</a></div></li>');
}
- unset($menu['plugin']);
+ unset($menu['extension']);
if($menu['config']){
ptln(' <li class="admin_config"><div class="li">'.
@@ -1802,6 +2144,9 @@ function html_resendpwd() {
* Return the TOC rendered to XHTML
*
* @author Andreas Gohr <andi@splitbrain.org>
+ *
+ * @param array $toc
+ * @return string html
*/
function html_TOC($toc){
if(!count($toc)) return '';
@@ -1820,6 +2165,9 @@ function html_TOC($toc){
/**
* Callback for html_buildlist
+ *
+ * @param array $item
+ * @return string html
*/
function html_list_toc($item){
if(isset($item['hid'])){
@@ -1854,6 +2202,7 @@ function html_mktocitem($link, $text, $level, $hash='#'){
* Triggers an event with the form name: HTML_{$name}FORM_OUTPUT
*
* @author Tom N Harris <tnharris@whoopdedo.org>
+ *
* @param string $name The name of the form
* @param Doku_Form $form The form
*/
@@ -1866,6 +2215,7 @@ function html_form($name, &$form) {
/**
* Form print function.
* Just calls printForm() on the data object.
+ *
* @param Doku_Form $data The form
*/
function html_form_output($data) {