From 39a89382d5e693e2b9c9f4e10d73081d1311aeee Mon Sep 17 00:00:00 2001 From: Esther Brunner Date: Sat, 15 Apr 2006 12:46:27 +0200 Subject: new metadata renderer; functions p_get_metadata() and p_set_metadata() darcs-hash:20060415104627-283c4-c7d35620fc9dbc21b8a47089692b76d35a9f9ca8.gz --- inc/common.php | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'inc/common.php') diff --git a/inc/common.php b/inc/common.php index a073ebeaa..75c3e8574 100644 --- a/inc/common.php +++ b/inc/common.php @@ -1005,6 +1005,7 @@ function saveWikiText($id,$text,$summary,$minor=false){ }else{ // save file (datadir is created in io_saveFile) io_saveFile($file,$text); + saveMetadata($id, $file, $minor); $del = false; } @@ -1019,6 +1020,27 @@ function saveWikiText($id,$text,$summary,$minor=false){ } } +/** + * saves the metadata for a page + * + * @author Esther Brunner + */ +function saveMetadata($id, $file, $minor){ + global $INFO; + + $user = $_SERVER['REMOTE_USER']; + + $meta = array(); + if (!$INFO['exists']){ // newly created + $meta['date']['created'] = @filectime($file); + if ($user) $meta['creator'] = $INFO['userinfo']['name']; + } elseif (!$minor) { // non-minor modification + $meta['date']['modified'] = @filemtime($file); + if ($user) $meta['contributor'][$user] = $INFO['userinfo']['name']; + } + p_set_metadata($id, $meta, true); +} + /** * moves the current version to the attic and returns its * revision date -- cgit v1.2.3