/** * Returns a list of available revisions of a given wiki page * * @author Michael Klier <*****@*****.**> */ function pageVersions($id, $first) { $id = $this->resolvePageId($id); if (auth_quickaclcheck($id) < AUTH_READ) { throw new RemoteAccessDeniedException('You are not allowed to read this page', 111); } global $conf; $versions = array(); if (empty($id)) { throw new RemoteException('Empty page ID', 131); } $revisions = getRevisions($id, $first, $conf['recent'] + 1); if (count($revisions) == 0 && $first != 0) { $first = 0; $revisions = getRevisions($id, $first, $conf['recent'] + 1); } if (count($revisions) > 0 && $first == 0) { array_unshift($revisions, ''); // include current revision array_pop($revisions); // remove extra log entry } if (count($revisions) > $conf['recent']) { array_pop($revisions); // remove extra log entry } if (!empty($revisions)) { foreach ($revisions as $rev) { $file = wikiFN($id, $rev); $time = @filemtime($file); // we check if the page actually exists, if this is not the // case this can lead to less pages being returned than // specified via $conf['recent'] if ($time) { $info = getRevisionInfo($id, $time, 1024); if (!empty($info)) { $data['user'] = $info['user']; $data['ip'] = $info['ip']; $data['type'] = $info['type']; $data['sum'] = $info['sum']; $data['modified'] = $this->api->toDate($info['date']); $data['version'] = $info['date']; array_push($versions, $data); } } } return $versions; } else { return array(); } }
function html_diff_head($l_rev, $r_rev, $id = null, $media = false) { global $lang; if ($id === null) { global $ID; $id = $ID; } $media_or_wikiFN = $media ? 'mediaFN' : 'wikiFN'; $ml_or_wl = $media ? 'ml' : 'wl'; $l_minor = $r_minor = ''; if (!$l_rev) { $l_head = '—'; } else { $l_info = getRevisionInfo($id, $l_rev, true, $media); if ($l_info['user']) { $l_user = editorinfo($l_info['user']); if (auth_ismanager()) { $l_user .= ' (' . $l_info['ip'] . ')'; } } else { $l_user = $l_info['ip']; } $l_user = '******' . $l_user . '</span>'; $l_sum = $l_info['sum'] ? '<span class="sum">' . hsc($l_info['sum']) . '</span>' : ''; if ($l_info['type'] === DOKU_CHANGE_TYPE_MINOR_EDIT) { $l_minor = 'class="minor"'; } $l_head_title = $media ? dformat($l_rev) : $id . ' [' . dformat($l_rev) . ']'; $l_head = '<a class="wikilink1" href="' . $ml_or_wl($id, "rev={$l_rev}") . '">' . $l_head_title . '</a>' . '<br />' . $l_user . ' ' . $l_sum; } if ($r_rev) { $r_info = getRevisionInfo($id, $r_rev, true, $media); if ($r_info['user']) { $r_user = editorinfo($r_info['user']); if (auth_ismanager()) { $r_user .= ' (' . $r_info['ip'] . ')'; } } else { $r_user = $r_info['ip']; } $r_user = '******' . $r_user . '</span>'; $r_sum = $r_info['sum'] ? '<span class="sum">' . hsc($r_info['sum']) . '</span>' : ''; if ($r_info['type'] === DOKU_CHANGE_TYPE_MINOR_EDIT) { $r_minor = 'class="minor"'; } $r_head_title = $media ? dformat($r_rev) : $id . ' [' . dformat($r_rev) . ']'; $r_head = '<a class="wikilink1" href="' . $ml_or_wl($id, "rev={$r_rev}") . '">' . $r_head_title . '</a>' . '<br />' . $r_user . ' ' . $r_sum; } elseif ($_rev = @filemtime($media_or_wikiFN($id))) { $_info = getRevisionInfo($id, $_rev, true, $media); if ($_info['user']) { $_user = editorinfo($_info['user']); if (auth_ismanager()) { $_user .= ' (' . $_info['ip'] . ')'; } } else { $_user = $_info['ip']; } $_user = '******' . $_user . '</span>'; $_sum = $_info['sum'] ? '<span class="sum">' . hsc($_info['sum']) . '</span>' : ''; if ($_info['type'] === DOKU_CHANGE_TYPE_MINOR_EDIT) { $r_minor = 'class="minor"'; } $r_head_title = $media ? dformat($_rev) : $id . ' [' . dformat($_rev) . ']'; $r_head = '<a class="wikilink1" href="' . $ml_or_wl($id) . '">' . $r_head_title . '</a> ' . '(' . $lang['current'] . ')' . '<br />' . $_user . ' ' . $_sum; } else { $r_head = '— (' . $lang['current'] . ')'; } return array($l_head, $r_head, $l_minor, $r_minor); }
/** * Return info about the current document as associative * array. * * @author Andreas Gohr <*****@*****.**> */ function pageinfo() { global $ID; global $REV; global $USERINFO; global $conf; // include ID & REV not redundant, as some parts of DokuWiki may temporarily change $ID, e.g. p_wiki_xhtml // FIXME ... perhaps it would be better to ensure the temporary changes weren't necessary $info['id'] = $ID; $info['rev'] = $REV; if ($_SERVER['REMOTE_USER']) { $info['userinfo'] = $USERINFO; $info['perm'] = auth_quickaclcheck($ID); $info['subscribed'] = is_subscribed($ID, $_SERVER['REMOTE_USER']); $info['client'] = $_SERVER['REMOTE_USER']; // if some outside auth were used only REMOTE_USER is set if (!$info['userinfo']['name']) { $info['userinfo']['name'] = $_SERVER['REMOTE_USER']; } } else { $info['perm'] = auth_aclcheck($ID, '', null); $info['subscribed'] = false; $info['client'] = clientIP(true); } $info['namespace'] = getNS($ID); $info['locked'] = checklock($ID); $info['filepath'] = realpath(wikiFN($ID)); $info['exists'] = @file_exists($info['filepath']); if ($REV) { //check if current revision was meant if ($info['exists'] && @filemtime($info['filepath']) == $REV) { $REV = ''; } else { //really use old revision $info['filepath'] = realpath(wikiFN($ID, $REV)); $info['exists'] = @file_exists($info['filepath']); } } $info['rev'] = $REV; if ($info['exists']) { $info['writable'] = is_writable($info['filepath']) && $info['perm'] >= AUTH_EDIT; } else { $info['writable'] = $info['perm'] >= AUTH_CREATE; } $info['editable'] = $info['writable'] && empty($info['lock']); $info['lastmod'] = @filemtime($info['filepath']); //load page meta data $info['meta'] = p_get_metadata($ID); //who's the editor if ($REV) { $revinfo = getRevisionInfo($ID, $REV, 1024); } else { $revinfo = isset($info['meta']['last_change']) ? $info['meta']['last_change'] : getRevisionInfo($ID, $info['lastmod'], 1024); } $info['ip'] = $revinfo['ip']; $info['user'] = $revinfo['user']; $info['sum'] = $revinfo['sum']; // See also $INFO['meta']['last_change'] which is the most recent log line for page $ID. // Use $INFO['meta']['last_change']['type']==='e' in place of $info['minor']. if ($revinfo['user']) { $info['editor'] = $revinfo['user']; } else { $info['editor'] = $revinfo['ip']; } // draft $draft = getCacheName($info['client'] . $ID, '.draft'); if (@file_exists($draft)) { if (@filemtime($draft) < @filemtime(wikiFN($ID))) { // remove stale draft @unlink($draft); } else { $info['draft'] = $draft; } } return $info; }
/** * Return info about the current document as associative * array. * * @author Andreas Gohr <*****@*****.**> */ function pageinfo() { global $ID; global $REV; global $RANGE; global $USERINFO; global $lang; // include ID & REV not redundant, as some parts of DokuWiki may temporarily change $ID, e.g. p_wiki_xhtml // FIXME ... perhaps it would be better to ensure the temporary changes weren't necessary $info['id'] = $ID; $info['rev'] = $REV; // set info about manager/admin status. $info['isadmin'] = false; $info['ismanager'] = false; if (isset($_SERVER['REMOTE_USER'])) { $info['userinfo'] = $USERINFO; $info['perm'] = auth_quickaclcheck($ID); $info['subscribed'] = get_info_subscribed(); $info['client'] = $_SERVER['REMOTE_USER']; if ($info['perm'] == AUTH_ADMIN) { $info['isadmin'] = true; $info['ismanager'] = true; } elseif (auth_ismanager()) { $info['ismanager'] = true; } // if some outside auth were used only REMOTE_USER is set if (!$info['userinfo']['name']) { $info['userinfo']['name'] = $_SERVER['REMOTE_USER']; } } else { $info['perm'] = auth_aclcheck($ID, '', null); $info['subscribed'] = false; $info['client'] = clientIP(true); } $info['namespace'] = getNS($ID); $info['locked'] = checklock($ID); $info['filepath'] = fullpath(wikiFN($ID)); $info['exists'] = @file_exists($info['filepath']); if ($REV) { //check if current revision was meant if ($info['exists'] && @filemtime($info['filepath']) == $REV) { $REV = ''; } elseif ($RANGE) { //section editing does not work with old revisions! $REV = ''; $RANGE = ''; msg($lang['nosecedit'], 0); } else { //really use old revision $info['filepath'] = fullpath(wikiFN($ID, $REV)); $info['exists'] = @file_exists($info['filepath']); } } $info['rev'] = $REV; if ($info['exists']) { $info['writable'] = is_writable($info['filepath']) && $info['perm'] >= AUTH_EDIT; } else { $info['writable'] = $info['perm'] >= AUTH_CREATE; } $info['editable'] = $info['writable'] && empty($info['locked']); $info['lastmod'] = @filemtime($info['filepath']); //load page meta data $info['meta'] = p_get_metadata($ID); //who's the editor if ($REV) { $revinfo = getRevisionInfo($ID, $REV, 1024); } else { if (is_array($info['meta']['last_change'])) { $revinfo = $info['meta']['last_change']; } else { $revinfo = getRevisionInfo($ID, $info['lastmod'], 1024); // cache most recent changelog line in metadata if missing and still valid if ($revinfo !== false) { $info['meta']['last_change'] = $revinfo; p_set_metadata($ID, array('last_change' => $revinfo)); } } } //and check for an external edit if ($revinfo !== false && $revinfo['date'] != $info['lastmod']) { // cached changelog line no longer valid $revinfo = false; $info['meta']['last_change'] = $revinfo; p_set_metadata($ID, array('last_change' => $revinfo)); } $info['ip'] = $revinfo['ip']; $info['user'] = $revinfo['user']; $info['sum'] = $revinfo['sum']; // See also $INFO['meta']['last_change'] which is the most recent log line for page $ID. // Use $INFO['meta']['last_change']['type']===DOKU_CHANGE_TYPE_MINOR_EDIT in place of $info['minor']. if ($revinfo['user']) { $info['editor'] = $revinfo['user']; } else { $info['editor'] = $revinfo['ip']; } // draft $draft = getCacheName($info['client'] . $ID, '.draft'); if (@file_exists($draft)) { if (@filemtime($draft) < @filemtime(wikiFN($ID))) { // remove stale draft @unlink($draft); } else { $info['draft'] = $draft; } } // mobile detection $info['ismobile'] = clientismobile(); return $info; }
/** * show diff * * @author Andreas Gohr <*****@*****.**> */ function html_diff($text = '', $intro = true) { require_once DOKU_INC . 'inc/DifferenceEngine.php'; global $ID; global $REV; global $lang; global $conf; // 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; if (is_array($_REQUEST['rev2'])) { $rev1 = (int) $_REQUEST['rev2'][0]; $rev2 = (int) $_REQUEST['rev2'][1]; if (!$rev1) { $rev1 = $rev2; unset($rev2); } } else { $rev2 = (int) $_REQUEST['rev2']; } if ($text) { // compare text to the most current revision $l_rev = ''; $l_text = rawWiki($ID, ''); $l_head = '<a class="wikilink1" href="' . wl($ID) . '">' . $ID . ' ' . strftime($conf['dformat'], @filemtime(wikiFN($ID))) . '</a> ' . $lang['current']; $r_rev = ''; $r_text = cleanText($text); $r_head = $lang['yours']; } else { if ($rev1 && $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 = getRevisions($ID, 0, 1); $l_rev = $revs[0]; } // 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); if (!$l_rev) { $l_head = '—'; } else { $l_info = getRevisionInfo($ID, $l_rev, true); if ($l_info['user']) { $l_user = editorinfo($l_info['user']); if (auth_ismanager()) { $l_user .= ' (' . $l_info['ip'] . ')'; } } else { $l_user = $l_info['ip']; } $l_user = '******' . $l_user . '</span>'; $l_sum = $l_info['sum'] ? '<span class="sum">' . hsc($l_info['sum']) . '</span>' : ''; if ($l_info['type'] === DOKU_CHANGE_TYPE_MINOR_EDIT) { $l_minor = 'class="minor"'; } $l_head = '<a class="wikilink1" href="' . wl($ID, "rev={$l_rev}") . '">' . $ID . ' [' . strftime($conf['dformat'], $l_rev) . ']</a>' . '<br />' . $l_user . ' ' . $l_sum; } if ($r_rev) { $r_info = getRevisionInfo($ID, $r_rev, true); if ($r_info['user']) { $r_user = editorinfo($r_info['user']); if (auth_ismanager()) { $r_user .= ' (' . $r_info['ip'] . ')'; } } else { $r_user = $r_info['ip']; } $r_user = '******' . $r_user . '</span>'; $r_sum = $r_info['sum'] ? '<span class="sum">' . hsc($r_info['sum']) . '</span>' : ''; if ($r_info['type'] === DOKU_CHANGE_TYPE_MINOR_EDIT) { $r_minor = 'class="minor"'; } $r_head = '<a class="wikilink1" href="' . wl($ID, "rev={$r_rev}") . '">' . $ID . ' [' . strftime($conf['dformat'], $r_rev) . ']</a>' . '<br />' . $r_user . ' ' . $r_sum; } elseif ($_rev = @filemtime(wikiFN($ID))) { $_info = getRevisionInfo($ID, $_rev, true); if ($_info['user']) { $_user = editorinfo($_info['user']); if (auth_ismanager()) { $_user .= ' (' . $_info['ip'] . ')'; } } else { $_user = $_info['ip']; } $_user = '******' . $_user . '</span>'; $_sum = $_info['sum'] ? '<span class="sum">' . hsc($_info['sum']) . '</span>' : ''; if ($_info['type'] === DOKU_CHANGE_TYPE_MINOR_EDIT) { $r_minor = 'class="minor"'; } $r_head = '<a class="wikilink1" href="' . wl($ID) . '">' . $ID . ' [' . strftime($conf['dformat'], $_rev) . ']</a> ' . '(' . $lang['current'] . ')' . '<br />' . $_user . ' ' . $_sum; } else { $r_head = '— (' . $lang['current'] . ')'; } } $df = new Diff(explode("\n", htmlspecialchars($l_text)), explode("\n", htmlspecialchars($r_text))); $tdf = new TableDiffFormatter(); if ($intro) { print p_locale_xhtml('diff'); } ?> <table class="diff"> <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 $tdf->format($df); ?> </table> <?php }
/** * Returns a list of available revisions of a given wiki page * * @author Michael Klier <*****@*****.**> */ function pageVersions($id, $first) { global $conf; $versions = array(); if (empty($id)) { return new IXR_Error(1, 'Empty page ID'); } require_once DOKU_INC . 'inc/changelog.php'; $revisions = getRevisions($id, $first, $conf['recent'] + 1); if (count($revisions) == 0 && $first != 0) { $first = 0; $revisions = getRevisions($id, $first, $conf['recent'] + 1); } if (count($revisions) > 0 && $first == 0) { array_unshift($revisions, ''); // include current revision array_pop($revisions); // remove extra log entry } $hasNext = false; if (count($revisions) > $conf['recent']) { $hasNext = true; array_pop($revisions); // remove extra log entry } if (!empty($revisions)) { foreach ($revisions as $rev) { $file = wikiFN($id, $rev); $time = @filemtime($file); // we check if the page actually exists, if this is not the // case this can lead to less pages being returned than // specified via $conf['recent'] if ($time) { $info = getRevisionInfo($id, $time, 1024); if (!empty($info)) { $data['user'] = $info['user']; $data['ip'] = $info['ip']; $data['type'] = $info['type']; $data['sum'] = $info['sum']; $data['modified'] = new IXR_Date($info['date']); $data['version'] = $info['date']; array_push($versions, $data); } } } return $versions; } else { return array(); } }
/** * Pull the user that modified the page from metadata * * @param string $page_id The page ID * @param string $revision_id The revision ID, or "" if current revision * * @return string The name of the user responsible for the revision, or "" if the user * could not be determined */ function getPageUser($page_id, $revision_id) { if ($revision_id == "") { // Try to pull the user from the last_change metadata $metadata = p_get_metadata($page_id); if (array_key_exists("last_change", $metadata)) { return $metadata["last_change"]["user"]; } // There's no data as to who updated this, return empty user return ""; } else { // Return user associated with revision return getRevisionInfo($page_id, $revision_id)["user"]; } }
/** * Moves the current version of media file to the media_attic * directory * * @author Kate Arzamastseva <*****@*****.**> * @param string $id * @return int - revision date */ function media_saveOldRevision($id) { global $conf, $lang; $oldf = mediaFN($id); if (!@file_exists($oldf)) { return ''; } $date = filemtime($oldf); if (!$conf['mediarevisions']) { return $date; } if (!getRevisionInfo($id, $date, 8192, true)) { // there was an external edit, // there is no log entry for current version of file if (!@file_exists(mediaMetaFN($id, '.changes'))) { addMediaLogEntry($date, $id, DOKU_CHANGE_TYPE_CREATE, $lang['created']); } else { addMediaLogEntry($date, $id, DOKU_CHANGE_TYPE_EDIT); } } $newf = mediaFN($id, $date); io_makeFileDir($newf); if (copy($oldf, $newf)) { // Set the correct permission here. // Always chmod media because they may be saved with different permissions than expected from the php umask. // (Should normally chmod to $conf['fperm'] only if $conf['fperm'] is set.) chmod($newf, $conf['fmode']); } return $date; }
/** * list old revisions * * @author Andreas Gohr <*****@*****.**> * @author Ben Coburn <*****@*****.**> */ function html_revisions($first = 0) { global $ID; global $INFO; global $conf; global $lang; /* we need to get one additionally log entry to be able to * decide if this is the last page or is there another one. * see html_recent() */ $revisions = getRevisions($ID, $first, $conf['recent'] + 1); if (count($revisions) == 0 && $first != 0) { $first = 0; $revisions = getRevisions($ID, $first, $conf['recent'] + 1); } $hasNext = false; if (count($revisions) > $conf['recent']) { $hasNext = true; array_pop($revisions); // remove extra log entry } $date = @date($conf['dformat'], $INFO['lastmod']); print p_locale_xhtml('revisions'); print '<ul>'; if ($INFO['exists'] && $first == 0) { print isset($INFO['meta']) && isset($INFO['meta']['last_change']) && $INFO['meta']['last_change']['type'] === 'e' ? '<li class="minor">' : '<li>'; print '<div class="li">'; print $date; print ' <img src="' . DOKU_BASE . 'lib/images/blank.gif" width="15" height="11" alt="" /> '; print '<a class="wikilink1" href="' . wl($ID) . '">' . $ID . '</a> '; print ' – '; print $INFO['sum']; print ' <span class="user">'; print $INFO['editor']; print '</span> '; print '(' . $lang['current'] . ')'; print '</div>'; print '</li>'; } foreach ($revisions as $rev) { $date = date($conf['dformat'], $rev); $info = getRevisionInfo($ID, $rev, true); print $info['type'] === 'e' ? '<li class="minor">' : '<li>'; print '<div class="li">'; print $date; if (@file_exists(wikiFN($ID, $rev))) { print ' <a href="' . wl($ID, "rev={$rev},do=diff") . '">'; $p = array(); $p['src'] = DOKU_BASE . 'lib/images/diff.png'; $p['width'] = 15; $p['height'] = 11; $p['title'] = $lang['diff']; $p['alt'] = $lang['diff']; $att = buildAttributes($p); print "<img {$att} />"; print '</a> '; print '<a class="wikilink1" href="' . wl($ID, "rev={$rev}") . '">' . $ID . '</a>'; } else { print ' <img src="' . DOKU_BASE . 'lib/images/blank.gif" width="15" height="11" alt="" /> '; print $ID; } print ' – '; print htmlspecialchars($info['sum']); print ' <span class="user">'; if ($info['user']) { print $info['user']; } else { print $info['ip']; } print '</span>'; print '</div>'; print '</li>'; } print '</ul>'; print '<div class="pagenav">'; $last = $first + $conf['recent']; if ($first > 0) { $first -= $conf['recent']; if ($first < 0) { $first = 0; } print '<div class="pagenav-prev">'; print html_btn('newer', $ID, "p", array('do' => 'revisions', 'first' => $first)); print '</div>'; } if ($hasNext) { print '<div class="pagenav-next">'; print html_btn('older', $ID, "n", array('do' => 'revisions', 'first' => $last)); print '</div>'; } print '</div>'; }
/** * show diff * * @author Andreas Gohr <*****@*****.**> * @param string $text - compare with this text with most current version * @param bool $intr - display the intro text */ function html_diff($text = '', $intro = true, $type = null) { global $ID; global $REV; global $lang; global $conf; if (!$type) { $type = $_REQUEST['difftype']; } if ($type != 'inline') { $type = 'sidebyside'; } // 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; if (is_array($_REQUEST['rev2'])) { $rev1 = (int) $_REQUEST['rev2'][0]; $rev2 = (int) $_REQUEST['rev2'][1]; if (!$rev1) { $rev1 = $rev2; unset($rev2); } } else { $rev2 = (int) $_REQUEST['rev2']; } $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 && $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 = getRevisions($ID, 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); if (!$l_rev) { $l_head = '—'; } else { $l_info = getRevisionInfo($ID, $l_rev, true); if ($l_info['user']) { $l_user = editorinfo($l_info['user']); if (auth_ismanager()) { $l_user .= ' (' . $l_info['ip'] . ')'; } } else { $l_user = $l_info['ip']; } $l_user = '******' . $l_user . '</span>'; $l_sum = $l_info['sum'] ? '<span class="sum">' . hsc($l_info['sum']) . '</span>' : ''; if ($l_info['type'] === DOKU_CHANGE_TYPE_MINOR_EDIT) { $l_minor = 'class="minor"'; } $l_head = '<a class="wikilink1" href="' . wl($ID, "rev={$l_rev}") . '">' . $ID . ' [' . dformat($l_rev) . ']</a>' . '<br />' . $l_user . ' ' . $l_sum; } if ($r_rev) { $r_info = getRevisionInfo($ID, $r_rev, true); if ($r_info['user']) { $r_user = editorinfo($r_info['user']); if (auth_ismanager()) { $r_user .= ' (' . $r_info['ip'] . ')'; } } else { $r_user = $r_info['ip']; } $r_user = '******' . $r_user . '</span>'; $r_sum = $r_info['sum'] ? '<span class="sum">' . hsc($r_info['sum']) . '</span>' : ''; if ($r_info['type'] === DOKU_CHANGE_TYPE_MINOR_EDIT) { $r_minor = 'class="minor"'; } $r_head = '<a class="wikilink1" href="' . wl($ID, "rev={$r_rev}") . '">' . $ID . ' [' . dformat($r_rev) . ']</a>' . '<br />' . $r_user . ' ' . $r_sum; } elseif ($_rev = @filemtime(wikiFN($ID))) { $_info = getRevisionInfo($ID, $_rev, true); if ($_info['user']) { $_user = editorinfo($_info['user']); if (auth_ismanager()) { $_user .= ' (' . $_info['ip'] . ')'; } } else { $_user = $_info['ip']; } $_user = '******' . $_user . '</span>'; $_sum = $_info['sum'] ? '<span class="sum">' . hsc($_info['sum']) . '</span>' : ''; if ($_info['type'] === DOKU_CHANGE_TYPE_MINOR_EDIT) { $r_minor = 'class="minor"'; } $r_head = '<a class="wikilink1" href="' . wl($ID) . '">' . $ID . ' [' . dformat($_rev) . ']</a> ' . '(' . $lang['current'] . ')' . '<br />' . $_user . ' ' . $_sum; } else { $r_head = '— (' . $lang['current'] . ')'; } } $df = new Diff(explode("\n", htmlspecialchars($l_text)), explode("\n", htmlspecialchars($r_text))); if ($type == 'inline') { $tdf = new InlineDiffFormatter(); } else { $tdf = new TableDiffFormatter(); } if ($intro) { print p_locale_xhtml('diff'); } if (!$text) { ptln('<p class="difflink">'); $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('<br /><a class="wikilink1" href="' . $diffurl . '">' . $lang['difflink'] . '</a>'); ptln('</p>'); } ?> <table class="diff diff_<?php echo $type; ?> "> <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 $tdf->format($df); ?> </table> <?php }
/** * sometimes chuncksize is set to true */ function test_chuncksizetrue() { $rev = 1362525899; $infoexpected = parseChangelogLine($this->logline); $info = getRevisionInfo($this->pageid, $rev, true); $this->assertEquals($infoexpected, $info); }