[ Index ]
 

Code source de SPIP 1.9.2c

Accédez au Source d'autres logiciels libres

title

Body

[fermer]

/ecrire/safehtml/classes/HTMLSax3/ -> Decorators.php (source)

   1  <?php
   2  class XML_HTMLSax3_Trim {
   3   var $orig_obj;
   4   var $orig_method;
   5   function XML_HTMLSax3_Trim(&$orig_obj, $orig_method) {
   6    $this->orig_obj =& $orig_obj;
   7    $this->orig_method = $orig_method;
   8   }
   9   function trimData(&$parser, $data) {
  10    $data = trim($data);
  11    if ($data != '') {
  12     $this->orig_obj->{$this->orig_method}($parser, $data);
  13    }
  14   }
  15  }
  16  class XML_HTMLSax3_CaseFolding {
  17   var $orig_obj;
  18   var $orig_open_method;
  19   var $orig_close_method;
  20   function XML_HTMLSax3_CaseFolding(&$orig_obj, $orig_open_method, $orig_close_method) {
  21    $this->orig_obj =& $orig_obj;
  22    $this->orig_open_method = $orig_open_method;
  23    $this->orig_close_method = $orig_close_method;
  24   }
  25   function foldOpen(&$parser, $tag, $attrs=array(), $empty = FALSE) {
  26    $this->orig_obj->{$this->orig_open_method}($parser, strtoupper($tag), $attrs, $empty);
  27   }
  28   function foldClose(&$parser, $tag, $empty = FALSE) {
  29    $this->orig_obj->{$this->orig_close_method}($parser, strtoupper($tag), $empty);
  30   }
  31  }
  32  class XML_HTMLSax3_Linefeed {
  33   var $orig_obj;
  34   var $orig_method;
  35   function XML_HTMLSax3_LineFeed(&$orig_obj, $orig_method) {
  36    $this->orig_obj =& $orig_obj;
  37    $this->orig_method = $orig_method;
  38   }
  39   function breakData(&$parser, $data) {
  40    $data = explode("\n",$data);
  41    foreach ( $data as $chunk ) {
  42     $this->orig_obj->{$this->orig_method}($parser, $chunk);
  43    }
  44   }
  45  }
  46  class XML_HTMLSax3_Tab {
  47   var $orig_obj;
  48   var $orig_method;
  49   function XML_HTMLSax3_Tab(&$orig_obj, $orig_method) {
  50    $this->orig_obj =& $orig_obj;
  51    $this->orig_method = $orig_method;
  52   }
  53   function breakData(&$parser, $data) {
  54    $data = explode("\t",$data);
  55    foreach ( $data as $chunk ) {
  56     $this->orig_obj->{$this->orig_method}($this, $chunk);
  57    }
  58   }
  59  }
  60  class XML_HTMLSax3_Entities_Parsed {
  61   var $orig_obj;
  62   var $orig_method;
  63   function XML_HTMLSax3_Entities_Parsed(&$orig_obj, $orig_method) {
  64    $this->orig_obj =& $orig_obj;
  65    $this->orig_method = $orig_method;
  66   }
  67   function breakData(&$parser, $data) {
  68    $data = preg_split('/(&.+?;)/',$data,-1,PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY);
  69    foreach ( $data as $chunk ) {
  70     $chunk = html_entity_decode($chunk,ENT_NOQUOTES);
  71     $this->orig_obj->{$this->orig_method}($this, $chunk);
  72    }
  73   }
  74  }
  75  if (version_compare(phpversion(), '4.3', '<') && !function_exists('html_entity_decode') ) {
  76   function html_entity_decode($str, $style=ENT_NOQUOTES) {
  77    return strtr($str,
  78     array_flip(get_html_translation_table(HTML_ENTITIES,$style)));
  79   }
  80  }
  81  class XML_HTMLSax3_Entities_Unparsed {
  82   var $orig_obj;
  83   var $orig_method;
  84   function XML_HTMLSax3_Entities_Unparsed(&$orig_obj, $orig_method) {
  85    $this->orig_obj =& $orig_obj;
  86    $this->orig_method = $orig_method;
  87   }
  88   function breakData(&$parser, $data) {
  89    $data = preg_split('/(&.+?;)/',$data,-1,PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY);
  90    foreach ( $data as $chunk ) {
  91     $this->orig_obj->{$this->orig_method}($this, $chunk);
  92    }
  93   }
  94  }
  95  
  96  class XML_HTMLSax3_Escape_Stripper {
  97   var $orig_obj;
  98   var $orig_method;
  99   function XML_HTMLSax3_Escape_Stripper(&$orig_obj, $orig_method) {
 100    $this->orig_obj =& $orig_obj;
 101    $this->orig_method = $orig_method;
 102   }
 103   function strip(&$parser, $data) {
 104    if ( substr($data,0,2) == '--' ) {
 105     $patterns = array(
 106      '/^\-\-/',    // Opening comment: --
 107      '/\-\-$/',    // Closing comment: --
 108     );
 109     $data = preg_replace($patterns,'',$data);
 110  
 111    } else if ( substr($data,0,1) == '[' ) {
 112     $patterns = array(
 113      '/^\[.*CDATA.*\[/s', // Opening CDATA
 114      '/\].*\]$/s',    // Closing CDATA
 115      );
 116     $data = preg_replace($patterns,'',$data);
 117    }
 118  
 119    $this->orig_obj->{$this->orig_method}($this, $data);
 120   }
 121  }
 122  ?>


Généré le : Wed Nov 21 10:20:27 2007 par Balluche grâce à PHPXref 0.7
  Clicky Web Analytics