-
Notifications
You must be signed in to change notification settings - Fork 54
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
revision support #131
Open
lisps
wants to merge
5
commits into
dokufreaks:master
Choose a base branch
from
lisps:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
revision support #131
Changes from 2 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -49,6 +49,7 @@ function helper_plugin_include() { | |
$this->defaults['order'] = $this->getConf('order'); | ||
$this->defaults['rsort'] = $this->getConf('rsort'); | ||
$this->defaults['depth'] = $this->getConf('depth'); | ||
$this->defaults['revision'] = $this->getConf('revision'); | ||
} | ||
|
||
/** | ||
|
@@ -68,6 +69,8 @@ function getMethods() { | |
* Overrides standard values for showfooter and firstseconly settings | ||
*/ | ||
function get_flags($setflags) { | ||
global $REV; | ||
global $DATE_AT; | ||
// load defaults | ||
$flags = $this->defaults; | ||
foreach ($setflags as $flag) { | ||
|
@@ -219,6 +222,12 @@ function get_flags($setflags) { | |
// the include_content URL parameter overrides flags | ||
if (isset($_REQUEST['include_content'])) | ||
$flags['linkonly'] = 0; | ||
|
||
//we have to disable some functions | ||
if (($flags['revision'] && $REV) || $DATE_AT) { | ||
$flags['editbtn'] = 0; | ||
} | ||
|
||
return $flags; | ||
} | ||
|
||
|
@@ -237,9 +246,12 @@ function _get_instructions($page, $sect, $mode, $lvl, $flags, $root_id = null, $ | |
global $ID; | ||
$root_id = $ID; | ||
} | ||
|
||
$page_rev = ''; | ||
if(in_array($mode,array('page','section'))) { | ||
$page_rev = $this->_get_revision($page,$flags); | ||
} | ||
if ($flags['linkonly']) { | ||
if (page_exists($page) || $flags['pageexists'] == 0) { | ||
if (page_exists($page,$page_rev) || $flags['pageexists'] == 0) { | ||
$title = ''; | ||
if ($flags['title']) | ||
$title = p_get_first_heading($page); | ||
|
@@ -256,17 +268,22 @@ function _get_instructions($page, $sect, $mode, $lvl, $flags, $root_id = null, $ | |
$ins = array(); | ||
} | ||
} else { | ||
if (page_exists($page)) { | ||
if (page_exists($page,$page_rev)) { | ||
global $ID; | ||
$backupID = $ID; | ||
$ID = $page; // Change the global $ID as otherwise plugins like the discussion plugin will save data for the wrong page | ||
$ins = p_cached_instructions(wikiFN($page), false, $page); | ||
if($page_rev){ | ||
$ins = p_get_instructions(io_readWikiPage(wikiFN($page,$page_rev),$page,$page_rev)); | ||
} else { | ||
$ins = p_cached_instructions(wikiFN($page), false, $page); | ||
} | ||
|
||
$ID = $backupID; | ||
} else { | ||
$ins = array(); | ||
} | ||
|
||
$this->_convert_instructions($ins, $lvl, $page, $sect, $flags, $root_id, $included_pages); | ||
$this->_convert_instructions($ins, $lvl, $page, $sect, $flags, $root_id, $included_pages, $page_rev); | ||
} | ||
return $ins; | ||
} | ||
|
@@ -284,7 +301,7 @@ function _get_instructions($page, $sect, $mode, $lvl, $flags, $root_id = null, $ | |
* | ||
* @author Michael Klier <[email protected]> | ||
*/ | ||
function _convert_instructions(&$ins, $lvl, $page, $sect, $flags, $root_id, $included_pages = array()) { | ||
function _convert_instructions(&$ins, $lvl, $page, $sect, $flags, $root_id, $included_pages = array(), $page_rev = '') { | ||
global $conf; | ||
|
||
// filter instructions if needed | ||
|
@@ -512,7 +529,7 @@ function _convert_instructions(&$ins, $lvl, $page, $sect, $flags, $root_id, $inc | |
|
||
// add footer | ||
if($flags['footer']) { | ||
$ins[] = $this->_footer($page, $sect, $sect_title, $flags, $footer_lvl, $root_id); | ||
$ins[] = $this->_footer($page, $sect, $sect_title, $flags, $footer_lvl, $root_id, $page_rev); | ||
} | ||
|
||
// wrap content at the beginning of the include that is not in a section in a section | ||
|
@@ -552,10 +569,10 @@ function _convert_instructions(&$ins, $lvl, $page, $sect, $flags, $root_id, $inc | |
* | ||
* @author Michael Klier <[email protected]> | ||
*/ | ||
function _footer($page, $sect, $sect_title, $flags, $footer_lvl, $root_id) { | ||
function _footer($page, $sect, $sect_title, $flags, $footer_lvl, $root_id, $page_rev) { | ||
$footer = array(); | ||
$footer[0] = 'plugin'; | ||
$footer[1] = array('include_footer', array($page, $sect, $sect_title, $flags, $root_id, $footer_lvl)); | ||
$footer[1] = array('include_footer', array($page, $sect, $sect_title, $flags, $root_id, $footer_lvl, $page_rev)); | ||
return $footer; | ||
} | ||
|
||
|
@@ -661,6 +678,8 @@ function _get_firstsec(&$ins, $page) { | |
*/ | ||
function _get_included_pages($mode, $page, $sect, $parent_id, $flags) { | ||
global $conf; | ||
global $REV; | ||
global $DATE_AT; | ||
$pages = array(); | ||
switch($mode) { | ||
case 'namespace': | ||
|
@@ -691,7 +710,7 @@ function _get_included_pages($mode, $page, $sect, $parent_id, $flags) { | |
} | ||
break; | ||
default: | ||
$page = $this->_apply_macro($page); | ||
$page = $this->_apply_macro($page,$flags); | ||
resolve_pageid(getNS($parent_id), $page, $exists); // resolve shortcuts and clean ID | ||
if (auth_quickaclcheck($page) >= AUTH_READ) | ||
$pages[] = $page; | ||
|
@@ -743,7 +762,8 @@ function _get_included_pages($mode, $page, $sect, $parent_id, $flags) { | |
|
||
$result = array(); | ||
foreach ($pages as $page) { | ||
$exists = page_exists($page); | ||
$page_rev = $this->_get_revision($page,$flags); | ||
$exists = page_exists($page,$page_rev); | ||
$result[] = array('id' => $page, 'exists' => $exists, 'parent_id' => $parent_id); | ||
} | ||
return $result; | ||
|
@@ -784,7 +804,7 @@ function _get_included_pages_from_meta_instructions($instructions) { | |
/** | ||
* Makes user or date dependent includes possible | ||
*/ | ||
function _apply_macro($id) { | ||
function _apply_macro($id,$flags) { | ||
global $INFO; | ||
global $auth; | ||
|
||
|
@@ -794,32 +814,36 @@ function _apply_macro($id) { | |
$user = $_SERVER['REMOTE_USER']; | ||
$group = $INFO['userinfo']['grps'][0]; | ||
|
||
$time_stamp = time(); | ||
if(($flags['revision'] && $REV) || $DATE_AT) { | ||
$time_stamp = max($REV,$DATE_AT); | ||
} else { | ||
$time_stamp = time(); | ||
} | ||
if(preg_match('/@DATE(\w+)@/',$id,$matches)) { | ||
switch($matches[1]) { | ||
case 'PMONTH': | ||
$time_stamp = strtotime("-1 month"); | ||
$time_stamp = strtotime("-1 month",$time_stamp); | ||
break; | ||
case 'NMONTH': | ||
$time_stamp = strtotime("+1 month"); | ||
$time_stamp = strtotime("+1 month",$time_stamp); | ||
break; | ||
case 'NWEEK': | ||
$time_stamp = strtotime("+1 week"); | ||
$time_stamp = strtotime("+1 week",$time_stamp); | ||
break; | ||
case 'PWEEK': | ||
$time_stamp = strtotime("-1 week"); | ||
$time_stamp = strtotime("-1 week",$time_stamp); | ||
break; | ||
case 'TOMORROW': | ||
$time_stamp = strtotime("+1 day"); | ||
$time_stamp = strtotime("+1 day",$time_stamp); | ||
break; | ||
case 'YESTERDAY': | ||
$time_stamp = strtotime("-1 day"); | ||
$time_stamp = strtotime("-1 day",$time_stamp); | ||
break; | ||
case 'NYEAR': | ||
$time_stamp = strtotime("+1 year"); | ||
$time_stamp = strtotime("+1 year",$time_stamp); | ||
break; | ||
case 'PYEAR': | ||
$time_stamp = strtotime("-1 year"); | ||
$time_stamp = strtotime("-1 year",$time_stamp); | ||
break; | ||
} | ||
$id = preg_replace('/@DATE(\w+)@/','', $id); | ||
|
@@ -833,16 +857,30 @@ function _apply_macro($id) { | |
'@MONTH@' => date('m',$time_stamp), | ||
'@WEEK@' => date('W',$time_stamp), | ||
'@DAY@' => date('d',$time_stamp), | ||
'@YEARPMONTH@' => date('Ym',strtotime("-1 month")), | ||
'@PMONTH@' => date('m',strtotime("-1 month")), | ||
'@NMONTH@' => date('m',strtotime("+1 month")), | ||
'@YEARNMONTH@' => date('Ym',strtotime("+1 month")), | ||
'@YEARPWEEK@' => date('YW',strtotime("-1 week")), | ||
'@PWEEK@' => date('W',strtotime("-1 week")), | ||
'@NWEEK@' => date('W',strtotime("+1 week")), | ||
'@YEARNWEEK@' => date('YW',strtotime("+1 week")), | ||
'@YEARPMONTH@' => date('Ym',strtotime("-1 month",$time_stamp)), | ||
'@PMONTH@' => date('m',strtotime("-1 month",$time_stamp)), | ||
'@NMONTH@' => date('m',strtotime("+1 month",$time_stamp)), | ||
'@YEARNMONTH@' => date('Ym',strtotime("+1 month",$time_stamp)), | ||
'@YEARPWEEK@' => date('YW',strtotime("-1 week",$time_stamp)), | ||
'@PWEEK@' => date('W',strtotime("-1 week",$time_stamp)), | ||
'@NWEEK@' => date('W',strtotime("+1 week",$time_stamp)), | ||
'@YEARNWEEK@' => date('YW',strtotime("+1 week",$time_stamp)), | ||
); | ||
return str_replace(array_keys($replace), array_values($replace), $id); | ||
} | ||
|
||
function _get_revision($page,$flags) { | ||
global $DATE_AT; | ||
global $REV; | ||
$page_rev = ''; | ||
if($DATE_AT) { | ||
$pagelog = new PageChangeLog($page); | ||
$page_rev = $pagelog->getLastRevisionAt($DATE_AT); | ||
} else if($flags['revision'] && $REV) { | ||
$pagelog = new PageChangeLog($page); | ||
$page_rev = $pagelog->getLastRevisionAt($REV); | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This works only with the revisions branch but not with the current master or stable branch. The include plugin should at least support the latest two stable releases. |
||
return $page_rev; | ||
} | ||
} | ||
// vim:ts=4:sw=4:et: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this isn't needed as the edit buttons below the included page are also using the section edit button functionality of DokuWiki which is automatically disabled by DokuWiki when an old revision is rendered.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is true when you don't use the
$DATE_AT
functionality (which is only implemented in my revision branch).But there you need this when you want to see the page at a state after the page was saved and before eventually some media has changed. Because then
$REV
will be set to''
(current) and only$DATE_AT
is set.