[ Index ]
 

Code source de DokuWiki 2006-11-06

Accédez au Source d'autres logiciels libresSoutenez Angelica Josefina !

title

Body

[fermer]

/inc/parser/ -> xhtmlsummary.php (source)

   1  <?php
   2  if(!defined('DOKU_INC')) define('DOKU_INC',realpath(dirname(__FILE__).'/../../').'/');
   3  
   4  require_once  DOKU_INC . 'inc/parser/xhtml.php';
   5  
   6  /**
   7   * The summary XHTML form selects either up to the first two paragraphs
   8   * it find in a page or the first section (whichever comes first)
   9   * It strips out the table of contents if one exists
  10   * Section divs are not used - everything should be nested in a single
  11   * div with CSS class "page"
  12   * Headings have their a name link removed and section editing links
  13   * removed
  14   * It also attempts to capture the first heading in a page for
  15   * use as the title of the page.
  16   *
  17   *
  18   * @author Harry Fuecks <hfuecks@gmail.com>
  19   * @todo   Is this currently used anywhere? Should it?
  20   */
  21  class Doku_Renderer_xhtmlsummary extends Doku_Renderer_xhtml {
  22  
  23      // Namespace these variables to
  24      // avoid clashes with parent classes
  25      var $sum_paragraphs = 0;
  26      var $sum_capture = TRUE;
  27      var $sum_inSection = FALSE;
  28      var $sum_summary = '';
  29      var $sum_pageTitle = FALSE;
  30  
  31      function document_start() {
  32          $this->doc .= DOKU_LF.'<div>'.DOKU_LF;
  33      }
  34  
  35      function document_end() {
  36          $this->doc = $this->sum_summary;
  37          $this->doc .= DOKU_LF.'</div>'.DOKU_LF;
  38      }
  39  
  40      // FIXME not supported anymore
  41      function toc_open() {
  42          $this->sum_summary .= $this->doc;
  43      }
  44  
  45      // FIXME not supported anymore
  46      function toc_close() {
  47          $this->doc = '';
  48      }
  49  
  50      function header($text, $level, $pos) {
  51          if ( !$this->sum_pageTitle ) {
  52              $this->info['sum_pagetitle'] = $text;
  53              $this->sum_pageTitle = TRUE;
  54          }
  55          $this->doc .= DOKU_LF.'<h'.$level.'>';
  56          $this->doc .= $this->_xmlEntities($text);
  57          $this->doc .= "</h$level>".DOKU_LF;
  58      }
  59  
  60      function section_open($level) {
  61          if ( $this->sum_capture ) {
  62              $this->sum_inSection = TRUE;
  63          }
  64      }
  65  
  66      function section_close() {
  67          if ( $this->sum_capture && $this->sum_inSection ) {
  68              $this->sum_summary .= $this->doc;
  69              $this->sum_capture = FALSE;
  70          }
  71      }
  72  
  73      function p_open() {
  74          if ( $this->sum_capture && $this->sum_paragraphs < 2 ) {
  75              $this->sum_paragraphs++;
  76          }
  77          parent :: p_open();
  78      }
  79  
  80      function p_close() {
  81          parent :: p_close();
  82          if ( $this->sum_capture && $this->sum_paragraphs >= 2 ) {
  83              $this->sum_summary .= $this->doc;
  84              $this->sum_capture = FALSE;
  85          }
  86      }
  87  
  88  }
  89  
  90  
  91  //Setup VIM: ex: et ts=2 enc=utf-8 :


Généré le : Tue Apr 3 20:47:31 2007 par Balluche grâce à PHPXref 0.7