aboutsummaryrefslogtreecommitdiff
path: root/mod/dokuwiki/vendors/dokuwiki/inc/parser/xhtmlsummary.php
diff options
context:
space:
mode:
authorSem <sembrestels@riseup.net>2013-11-09 16:13:46 +0100
committerSem <sembrestels@riseup.net>2013-11-09 16:13:46 +0100
commite2a2fbdccaf0f48878903f448428cab5852d0870 (patch)
tree9cbe6b74c8e2e191ec65fba78d7435af35506f82 /mod/dokuwiki/vendors/dokuwiki/inc/parser/xhtmlsummary.php
parent59448d8a9864573c05477a63a6dda404c455fdb6 (diff)
parentb603da53e13005c67d05efac67b70023dfffc450 (diff)
downloadelgg-e2a2fbdccaf0f48878903f448428cab5852d0870.tar.gz
elgg-e2a2fbdccaf0f48878903f448428cab5852d0870.tar.bz2
Add 'mod/dokuwiki/' from commit 'b603da53e13005c67d05efac67b70023dfffc450'
git-subtree-dir: mod/dokuwiki git-subtree-mainline: 59448d8a9864573c05477a63a6dda404c455fdb6 git-subtree-split: b603da53e13005c67d05efac67b70023dfffc450
Diffstat (limited to 'mod/dokuwiki/vendors/dokuwiki/inc/parser/xhtmlsummary.php')
-rw-r--r--mod/dokuwiki/vendors/dokuwiki/inc/parser/xhtmlsummary.php90
1 files changed, 90 insertions, 0 deletions
diff --git a/mod/dokuwiki/vendors/dokuwiki/inc/parser/xhtmlsummary.php b/mod/dokuwiki/vendors/dokuwiki/inc/parser/xhtmlsummary.php
new file mode 100644
index 000000000..b187fef01
--- /dev/null
+++ b/mod/dokuwiki/vendors/dokuwiki/inc/parser/xhtmlsummary.php
@@ -0,0 +1,90 @@
+<?php
+if(!defined('DOKU_INC')) die('meh.');
+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.
+ *
+ *
+ * @author Harry Fuecks <hfuecks@gmail.com>
+ * @todo Is this currently used anywhere? Should it?
+ */
+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;
+ }
+
+ // FIXME not supported anymore
+ function toc_open() {
+ $this->sum_summary .= $this->doc;
+ }
+
+ // FIXME not supported anymore
+ 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 :