openrat-cms

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs

commit 4392c3d298b64aac4400fc0b0d7ab858fa5ffbc7
parent e180c2a71d6c343b1e2148fd1d1c6187d4404870
Author: dankert <devnull@localhost>
Date:   Sat, 24 Nov 2007 02:10:43 +0100

Fu?notenelement einbinden.

Diffstat:
textClasses/DocumentElement.class.php | 49+++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 49 insertions(+), 0 deletions(-)

diff --git a/textClasses/DocumentElement.class.php b/textClasses/DocumentElement.class.php @@ -13,6 +13,13 @@ class DocumentElement extends AbstractElement { var $linkedObjectIds = array(); + + /** + * Fußnoten. + * + * @var Array + */ + var $footnotes = array(); @@ -669,6 +676,10 @@ class DocumentElement extends AbstractElement return $elements; } + $erg = $this->parseSimpleElement( $text,$text_markup['footnote-begin'],$text_markup['footnote-end'],'FootnoteElement' ); + if ( is_array($erg) ) + return $erg; + $erg = $this->parseSimpleElement( $text,$text_markup['strong-begin'],$text_markup['strong-end'],'StrongElement' ); if ( is_array($erg) ) return $erg; @@ -756,6 +767,40 @@ class DocumentElement extends AbstractElement break; + case 'footnoteelement': + $tag = 'a'; + $attr['href'] = '#footnote'; + + $title = ''; + foreach( $child->children as $c ) + $title .= $this->renderElement($c); + $attr['title'] = strip_tags($title); + + $nr = 1; + foreach( $this->footnotes as $fn ) + if ( strtolower(get_class($fn))=='linebreakelement') + $nr++; + + $val = '<sup><small>'.$nr.'</small></sup>'; + + if ( $nr == 1 ) + { + $this->footnotes[] = new TextElement('&mdash;'); + $le = new LinkElement(); + $le->name = "footnote"; + $this->footnotes[] = $le; + $this->footnotes[] = new TextElement('&mdash;'); + } + $this->footnotes[] = new LineBreakElement(); + $this->footnotes[] = new TextElement($val); + $this->footnotes[] = new TextElement(' '); + foreach( $child->children as $c ) + $this->footnotes[] = $c; + + $child->children = array(); + + break; + case 'codeelement': if ( empty($child->language) ) @@ -1034,9 +1079,13 @@ class DocumentElement extends AbstractElement $this->type = 'text/html'; $this->renderedText = ''; + $this->footnotes = array(); foreach( $this->children as $child ) $this->renderedText .= $this->renderElement( $child ); + + foreach( $this->footnotes as $child ) + $this->renderedText .= $this->renderElement( $child ); return $this->renderedText; }