diff options
author | Esther Brunner <esther@kaffeehaus.ch> | 2005-08-16 20:22:01 +0200 |
---|---|---|
committer | Esther Brunner <esther@kaffeehaus.ch> | 2005-08-16 20:22:01 +0200 |
commit | e1f3d9e1aa287c644fee854d1fddcfb5de4e31f5 (patch) | |
tree | 4d5d2428e0be52fa5fcdaecdb04d3aa7d92d6b8c | |
parent | 5667eb6525051fa45d19dfa20281279c306d70fd (diff) | |
download | rpg-e1f3d9e1aa287c644fee854d1fddcfb5de4e31f5.tar.gz rpg-e1f3d9e1aa287c644fee854d1fddcfb5de4e31f5.tar.bz2 |
delete meta files on page deletion
darcs-hash:20050816182201-283c4-75638010c1f75cfb7e905bca5647253084e69323.gz
-rw-r--r-- | inc/common.php | 9 | ||||
-rw-r--r-- | inc/pageutils.php | 21 |
2 files changed, 26 insertions, 4 deletions
diff --git a/inc/common.php b/inc/common.php index 0fdeec63b..6f1948ca5 100644 --- a/inc/common.php +++ b/inc/common.php @@ -687,11 +687,12 @@ function saveWikiText($id,$text,$summary){ $old = saveOldRevision($id); if (empty($text)){ - // remove empty files + // remove empty file @unlink($file); - $mfile=wikiMN($id); - if (file_exists($mfile)) { - @unlink($mfile); + // remove any meta info + $mfiles = metaFiles($id); + foreach ($mfiles as $mfile) { + if (file_exists($mfile)) @unlink($mfile); } $del = true; //autoset summary on deletion diff --git a/inc/pageutils.php b/inc/pageutils.php index e22dc3c86..dea691381 100644 --- a/inc/pageutils.php +++ b/inc/pageutils.php @@ -152,6 +152,27 @@ function metaFN($id,$ext){ } /** + * returns an array of full paths to all metafiles of a given ID + * + * @author Esther Brunner <esther@kaffeehaus.ch> + */ +function metaFiles($id){ + $name = noNS($id); + $dir = metaFN(getNS($id),''); + $files = array(); + + $dh = @opendir($dir); + if(!$dh) return; + while(($file = readdir($dh)) !== false){ + if(strpos($file,$name.'.') == 0 && !is_dir($dir.$file)) + $files[] = $dir.$file; + } + closedir($dh); + + return $files; +} + +/** * returns the full path to the mediafile specified by ID * * The filename is URL encoded to protect Unicode chars |