class _HWLDF_WordAccumulator

@todo document @private @subpackage DifferenceEngine

Hierarchy

Expanded class hierarchy of _HWLDF_WordAccumulator

File

drupal/core/lib/Drupal/Component/Diff/DiffEngine.php, line 952
A PHP diff engine for phpwiki. (Taken from phpwiki-1.3.3)

View source
class _HWLDF_WordAccumulator {
  function _HWLDF_WordAccumulator() {
    $this->_lines = array();
    $this->_line = '';
    $this->_group = '';
    $this->_tag = '';
  }
  function _flushGroup($new_tag) {
    if ($this->_group !== '') {
      if ($this->_tag == 'mark') {
        $this->_line .= '<span class="diffchange">' . check_plain($this->_group) . '</span>';
      }
      else {
        $this->_line .= check_plain($this->_group);
      }
    }
    $this->_group = '';
    $this->_tag = $new_tag;
  }
  function _flushLine($new_tag) {
    $this
      ->_flushGroup($new_tag);
    if ($this->_line != '') {
      array_push($this->_lines, $this->_line);
    }
    else {

      // make empty lines visible by inserting an NBSP
      array_push($this->_lines, NBSP);
    }
    $this->_line = '';
  }
  function addWords($words, $tag = '') {
    if ($tag != $this->_tag) {
      $this
        ->_flushGroup($tag);
    }
    foreach ($words as $word) {

      // new-line should only come as first char of word.
      if ($word == '') {
        continue;
      }
      if ($word[0] == "\n") {
        $this
          ->_flushLine($tag);
        $word = drupal_substr($word, 1);
      }
      assert(!strstr($word, "\n"));
      $this->_group .= $word;
    }
  }
  function getLines() {
    $this
      ->_flushLine('~done');
    return $this->_lines;
  }

}

Members