[ Index ]

PHP Cross Reference of vtigercrm-6.1.0

title

Body

[close]

/libraries/htmlpurifier/library/HTMLPurifier/Injector/ -> RemoveEmpty.php (source)

   1  <?php
   2  
   3  class HTMLPurifier_Injector_RemoveEmpty extends HTMLPurifier_Injector
   4  {
   5  
   6      private $context, $config;
   7  
   8      public function prepare($config, $context) {
   9          parent::prepare($config, $context);
  10          $this->config = $config;
  11          $this->context = $context;
  12          $this->attrValidator = new HTMLPurifier_AttrValidator();
  13      }
  14  
  15      public function handleElement(&$token) {
  16          if (!$token instanceof HTMLPurifier_Token_Start) return;
  17          $next = false;
  18          for ($i = $this->inputIndex + 1, $c = count($this->inputTokens); $i < $c; $i++) {
  19              $next = $this->inputTokens[$i];
  20              if ($next instanceof HTMLPurifier_Token_Text && $next->is_whitespace) continue;
  21              break;
  22          }
  23          if (!$next || ($next instanceof HTMLPurifier_Token_End && $next->name == $token->name)) {
  24              if ($token->name == 'colgroup') return;
  25              $this->attrValidator->validateToken($token, $this->config, $this->context);
  26              $token->armor['ValidateAttributes'] = true;
  27              if (isset($token->attr['id']) || isset($token->attr['name'])) return;
  28              $token = $i - $this->inputIndex + 1;
  29              for ($b = $this->inputIndex - 1; $b > 0; $b--) {
  30                  $prev = $this->inputTokens[$b];
  31                  if ($prev instanceof HTMLPurifier_Token_Text && $prev->is_whitespace) continue;
  32                  break;
  33              }
  34              // This is safe because we removed the token that triggered this.
  35              $this->rewind($b - 1);
  36              return;
  37          }
  38      }
  39  
  40  }
  41  
  42  // vim: et sw=4 sts=4


Generated: Fri Nov 28 20:08:37 2014 Cross-referenced by PHPXref 0.7.1