summaryrefslogtreecommitdiff
path: root/inc/parserutils.php
diff options
context:
space:
mode:
authorchris <chris@jalakai.co.uk>2006-10-04 23:00:30 +0200
committerchris <chris@jalakai.co.uk>2006-10-04 23:00:30 +0200
commit6afe8dca1f7bd2a9ca21fb2dca6fef12ded423e1 (patch)
tree4de8037dd732f90f6bab5eb56ccc5bdb1c52bb59 /inc/parserutils.php
parentb8a111f5605b82b5765cc4bde1826c7e1134c56e (diff)
downloadrpg-6afe8dca1f7bd2a9ca21fb2dca6fef12ded423e1.tar.gz
rpg-6afe8dca1f7bd2a9ca21fb2dca6fef12ded423e1.tar.bz2
update p_get/set_metadata to use $INFO['meta']
This patch updates p_get_metadata() to utilise the in memory copy copy of the current page's metadata ($INFO['meta']) when appropriate. The patch also updates p_set_metadata() to synchronise any changes to the current page's metadata with $INFO['meta']. $INFO hash is updated with two new elements: 'id' darcs-hash:20061004210030-9b6ab-7eab6f933a775fe350a1fb14d1118ea77d2db919.gz
Diffstat (limited to 'inc/parserutils.php')
-rw-r--r--inc/parserutils.php27
1 files changed, 20 insertions, 7 deletions
diff --git a/inc/parserutils.php b/inc/parserutils.php
index 17f1811ae..468ffe5c6 100644
--- a/inc/parserutils.php
+++ b/inc/parserutils.php
@@ -222,15 +222,21 @@ function p_get_instructions($text){
* @author Esther Brunner <esther@kaffeehaus.ch>
*/
function p_get_metadata($id, $key=false, $render=false){
- $file = metaFN($id, '.meta');
+ global $INFO;
- if (@file_exists($file)) $meta = unserialize(io_readFile($file, false));
- else $meta = array();
+ if ($id == $INFO['id'] && !empty($INFO['meta'])) {
+ $meta = $INFO['meta'];
+ } else {
+ $file = metaFN($id, '.meta');
+
+ if (@file_exists($file)) $meta = unserialize(io_readFile($file, false));
+ else $meta = array();
- // metadata has never been rendered before - do it!
- if ($render && !$meta['description']['abstract']){
- $meta = p_render_metadata($id, $meta);
- io_saveFile($file, serialize($meta));
+ // metadata has never been rendered before - do it!
+ if ($render && !$meta['description']['abstract']){
+ $meta = p_render_metadata($id, $meta);
+ io_saveFile($file, serialize($meta));
+ }
}
// filter by $key
@@ -283,6 +289,13 @@ function p_set_metadata($id, $data, $render=false){
// save only if metadata changed
if ($meta == $orig) return true;
+
+ // check if current page metadata has been altered - if so sync the changes
+ global $INFO;
+ if ($id == $INFO['id'] && isset($INFO['meta'])) {
+ $INFO['meta'] = $meta;
+ }
+
return io_saveFile(metaFN($id, '.meta'), serialize($meta));
}