summaryrefslogtreecommitdiff
path: root/inc/parser/xhtmlsummary.php
diff options
context:
space:
mode:
authorhfuecks <hfuecks@gmail.com>2005-11-07 01:05:54 +0100
committerhfuecks <hfuecks@gmail.com>2005-11-07 01:05:54 +0100
commit6b7b33dca364d6167321792ffb4459a604fbab82 (patch)
treebc8224db7d82546e2784647fae04c574d5512077 /inc/parser/xhtmlsummary.php
parent9b9cbe5440fe18eb5932e3d42eb079af83117f23 (diff)
downloadrpg-6b7b33dca364d6167321792ffb4459a604fbab82.tar.gz
rpg-6b7b33dca364d6167321792ffb4459a604fbab82.tar.bz2
xhtmlsummary_patch
darcs-hash:20051107000554-e96b6-1a7ae7a9d5e820d3c52629570ff33f8e75bc4a46.gz
Diffstat (limited to 'inc/parser/xhtmlsummary.php')
-rw-r--r--inc/parser/xhtmlsummary.php85
1 files changed, 85 insertions, 0 deletions
diff --git a/inc/parser/xhtmlsummary.php b/inc/parser/xhtmlsummary.php
new file mode 100644
index 000000000..eeb684e57
--- /dev/null
+++ b/inc/parser/xhtmlsummary.php
@@ -0,0 +1,85 @@
+<?php
+if(!defined('DOKU_INC')) define('DOKU_INC',realpath(dirname(__FILE__).'/../../').'/');
+
+require_once DOKU_INC . 'inc/parser/xhtml.php';
+
+/**
+* The summary XHTML form selects either up to the first two paragraphs
+* it find in a page or the first section (whichever comes first)
+* It strips out the table of contents if one exists
+* Section divs are not used - everything should be nested in a single
+* div with CSS class "page"
+* Headings have their a name link removed and section editing links
+* removed
+* It also attempts to capture the first heading in a page for
+* use as the title of the page.
+*/
+class Doku_Renderer_xhtmlsummary extends Doku_Renderer_xhtml {
+
+ // Namespace these variables to
+ // avoid clashes with parent classes
+ var $sum_paragraphs = 0;
+ var $sum_capture = TRUE;
+ var $sum_inSection = FALSE;
+ var $sum_summary = '';
+ var $sum_pageTitle = FALSE;
+
+ function document_start() {
+ $this->doc .= DOKU_LF.'<div>'.DOKU_LF;
+ }
+
+ function document_end() {
+ $this->doc = $this->sum_summary;
+ $this->doc .= DOKU_LF.'</div>'.DOKU_LF;
+ }
+
+ function toc_open() {
+ $this->sum_summary .= $this->doc;
+ }
+
+ function toc_close() {
+ $this->doc = '';
+ }
+
+ function header($text, $level, $pos) {
+ if ( !$this->sum_pageTitle ) {
+ $this->info['sum_pagetitle'] = $text;
+ $this->sum_pageTitle = TRUE;
+ }
+ $this->doc .= DOKU_LF.'<h'.$level.'>';
+ $this->doc .= $this->_xmlEntities($text);
+ $this->doc .= "</h$level>".DOKU_LF;
+ }
+
+ function section_open($level) {
+ if ( $this->sum_capture ) {
+ $this->sum_inSection = TRUE;
+ }
+ }
+
+ function section_close() {
+ if ( $this->sum_capture && $this->sum_inSection ) {
+ $this->sum_summary .= $this->doc;
+ $this->sum_capture = FALSE;
+ }
+ }
+
+ function p_open() {
+ if ( $this->sum_capture && $this->sum_paragraphs < 2 ) {
+ $this->sum_paragraphs++;
+ }
+ parent :: p_open();
+ }
+
+ function p_close() {
+ parent :: p_close();
+ if ( $this->sum_capture && $this->sum_paragraphs >= 2 ) {
+ $this->sum_summary .= $this->doc;
+ $this->sum_capture = FALSE;
+ }
+ }
+
+}
+
+
+//Setup VIM: ex: et ts=2 enc=utf-8 :