From a4a2d4cf66dd68b9dc9ce51064fae2db8385d81d Mon Sep 17 00:00:00 2001
From: Andreas Gohr <andi@splitbrain.org>
Date: Sun, 7 May 2006 17:31:13 +0200
Subject: [PATCH] metadata hnalding updates, header fixes

This removes the meta instruction again in favour of the new meta renderer.
Most tests work now again, a few tweaks were done on the header handler
to render certain headers as it did in earlier versions.

darcs-hash:20060507153113-7ad00-bd299fbe1762482c72d109f9bca776f12bcea7c8.gz
---
 _test/runtests.php      |  4 ++++
 doku.php                |  2 +-
 inc/parser/handler.php  | 12 ++++--------
 inc/parser/metadata.php |  9 ++-------
 inc/parser/xhtml.php    |  6 ------
 lib/exe/indexer.php     |  4 +++-
 6 files changed, 14 insertions(+), 23 deletions(-)

diff --git a/_test/runtests.php b/_test/runtests.php
index e41454f8b..e3489b4cf 100755
--- a/_test/runtests.php
+++ b/_test/runtests.php
@@ -2,6 +2,10 @@
 <?php
 ini_set('memory_limit','128M');
 if(!defined('DOKU_INC')) define('DOKU_INC',realpath(dirname(__FILE__).'/../').'/');
+
+require_once(DOKU_INC.'inc/init.php');
+require_once(DOKU_INC.'inc/events.php');
+
 define('TEST_ROOT', dirname(__FILE__));
 define('TMPL_FILESCHEME_PATH', TEST_ROOT . '/filescheme/');
 error_reporting(E_ALL ^ E_NOTICE);
diff --git a/doku.php b/doku.php
index 04154df6f..7b53def43 100644
--- a/doku.php
+++ b/doku.php
@@ -11,7 +11,7 @@
   if(!defined('DOKU_INC')) define('DOKU_INC',realpath(dirname(__FILE__)).'/');
   require_once(DOKU_INC.'inc/init.php');
   require_once(DOKU_INC.'inc/common.php');
-	require_once(DOKU_INC.'inc/events.php');
+  require_once(DOKU_INC.'inc/events.php');
   require_once(DOKU_INC.'inc/pageutils.php');
   require_once(DOKU_INC.'inc/html.php');
   require_once(DOKU_INC.'inc/auth.php');
diff --git a/inc/parser/handler.php b/inc/parser/handler.php
index 702bcce55..fde538515 100644
--- a/inc/parser/handler.php
+++ b/inc/parser/handler.php
@@ -9,10 +9,6 @@ class Doku_Handler {
 
     var $calls = array();
 
-    var $meta = array(
-        'first_heading' => '',
-    );
-
     var $status = array(
         'section' => FALSE,
     );
@@ -43,7 +39,6 @@ class Doku_Handler {
         trigger_event('PARSER_HANDLER_DONE',$this);
 
         array_unshift($this->calls,array('document_start',array(),0));
-        array_unshift($this->calls,array('meta',array($this->meta),0));
         $last_call = end($this->calls);
         array_push($this->calls,array('document_end',array(),$last_call[2]));
     }
@@ -87,9 +82,11 @@ class Doku_Handler {
 
     function header($match, $state, $pos) {
         // get level and title
-        $level = 7 - strspn($match,'=');
+        $title = trim($match);
+        $level = 7 - strspn($title,'=');
         if($level < 1) $level = 1;
-        $title = trim($match,'= ');
+        $title = trim($title,'=');
+        $title = trim($title);
 
         if ($this->status['section']) $this->_addCall('section_close',array(),$pos);
 
@@ -97,7 +94,6 @@ class Doku_Handler {
 
         $this->_addCall('section_open',array($level),$pos);
         $this->status['section'] = TRUE;
-        if (!$this->meta['first_heading']) $this->meta['first_heading'] = $title;
         return TRUE;
     }
 
diff --git a/inc/parser/metadata.php b/inc/parser/metadata.php
index e7173dda6..59b791fae 100644
--- a/inc/parser/metadata.php
+++ b/inc/parser/metadata.php
@@ -31,13 +31,6 @@ class Doku_Renderer_metadata extends Doku_Renderer {
   var $capture = true;
   var $store   = '';
 
-  function meta($data) {
-    if (is_array($data)){
-      $this->meta = $data;
-      if (!$this->meta['title']) $this->meta['title'] = $data['first_heading'];
-    }
-  }
-
   function document_start(){
     //reset some variables
     $this->meta['description']['abstract'] = '';
@@ -60,6 +53,8 @@ class Doku_Renderer_metadata extends Doku_Renderer {
   function header($text, $level, $pos) {
     global $conf;
 
+    if (!$this->meta['title']) $this->meta['title'] = $text;
+
     // create a unique header id
     $hid = $this->_headerToLink($text,'true');
 
diff --git a/inc/parser/xhtml.php b/inc/parser/xhtml.php
index 682551169..dc28423f9 100644
--- a/inc/parser/xhtml.php
+++ b/inc/parser/xhtml.php
@@ -45,12 +45,6 @@ class Doku_Renderer_xhtml extends Doku_Renderer {
 
     var $store = '';
 
-    var $meta = array();
-
-    function meta($data) {
-      if (is_array($data)) $this->meta = $data;
-    }
-
     function document_start() {
         //reset some internals
         $this->toc     = array();
diff --git a/lib/exe/indexer.php b/lib/exe/indexer.php
index d37fb9c9a..05bcb5827 100644
--- a/lib/exe/indexer.php
+++ b/lib/exe/indexer.php
@@ -8,6 +8,7 @@
 if(!defined('DOKU_INC')) define('DOKU_INC',realpath(dirname(__FILE__).'/../../').'/');
 require_once(DOKU_INC.'inc/init.php');
 require_once(DOKU_INC.'inc/auth.php');
+require_once(DOKU_INC.'inc/events.php');
 session_write_close();  //close session
 if(!defined('NL')) define('NL',"\n");
 
@@ -86,6 +87,7 @@ function metaUpdate(){
     $ID = cleanID($_REQUEST['id']);
     if(!$ID) return false;
     $file = metaFN($ID, '.meta');
+    echo "meta file: $file".NL;
 
     // rendering needed?
     if (@file_exists($file)) return false;
@@ -96,7 +98,7 @@ function metaUpdate(){
     $meta = p_render_metadata($ID, $meta);
     io_saveFile($file, serialize($meta));
 
-    print "metaUpdate(): finished".NL;
+    echo "metaUpdate(): finished".NL;
     return true;
 }
 
-- 
GitLab