diff options
author | Simon Coffey spc03@doc.ic.ac.uk <andi@splitbrain.org> | 2008-02-13 15:57:34 +0100 |
---|---|---|
committer | Simon Coffey spc03@doc.ic.ac.uk <andi@splitbrain.org> | 2008-02-13 15:57:34 +0100 |
commit | 14f6540fe0436ed2fa56b0b8683d1f071a0c799f (patch) | |
tree | 3380144bf0a937425ee3e63e7ed78c05994e4844 | |
parent | d86d5af08a9eb7b1fa224fd98e1cc7b15032b634 (diff) | |
download | rpg-14f6540fe0436ed2fa56b0b8683d1f071a0c799f.tar.gz rpg-14f6540fe0436ed2fa56b0b8683d1f071a0c799f.tar.bz2 |
Importoldchangelog: Added metadata support
Added function savePerPageMetadata() to populate creator and contributor fields
of metadata array from old-style changes.log.
darcs-hash:20080213145734-31360-226e84e11c5a95d2bcafd8d29abca24f76b25482.gz
-rw-r--r-- | lib/plugins/importoldchangelog/action.php | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/lib/plugins/importoldchangelog/action.php b/lib/plugins/importoldchangelog/action.php index 8effe4ec9..29cea06c1 100644 --- a/lib/plugins/importoldchangelog/action.php +++ b/lib/plugins/importoldchangelog/action.php @@ -116,6 +116,30 @@ class action_plugin_importoldchangelog extends DokuWiki_Action_Plugin { io_saveFile(metaFN($id, '.changes'), implode('', $changes)); } + function savePerPageMetadata($id, &$changes) { + global $auth; + ksort($changes); // order by date + $meta = array(); + // Run through history and populate the metadata array + foreach ($changes as $date => $tmp) { + $user = $tmp['user']; + if ($tmp['type'] === DOKU_CHANGE_TYPE_CREATE) { + $meta['date']['created'] = $tmp['date']; + if ($user) { + $userinfo = $auth->getUserData($user); + $meta['creator'] = $userinfo['name']; + } + } else if ($tmp['type'] === DOKU_CHANGE_TYPE_EDIT) { + $meta['date']['modified'] = $tmp['date']; + if ($user) { + $userinfo = $auth->getUserData($user); + $meta['contributor'][$user] = $userinfo['name']; + } + } + } + p_set_metadata($id, $meta, true); + } + function resetTimer() { // Add 5 minutes to the script execution timer... // This should be much more than needed. @@ -144,6 +168,7 @@ class action_plugin_importoldchangelog extends DokuWiki_Action_Plugin { $this->resetTimer(); $recent = array(); foreach ($log as $id => $page) { + $this->savePerPageMetadata($id, $page); $this->savePerPageChanges($id, $page, $recent); } // save recent changes cache |