/**
  * Trim outer and inner HTML for CSV files
  *
  * @return string
  */
 public function render()
 {
     $string = $this->renderChildren();
     $string = $this->removeDuplicatedWhitespace($string);
     $string = StringUtility::br2nl($string);
     $string = $this->removeWhiteSpaceForEveryLine($string);
     $string = $this->removeCsvWhitespace($string);
     return $string;
 }
예제 #2
0
 /**
  * Function makePlain() removes html tags and add linebreaks
  *        Easy generate a plain email bodytext from a html bodytext
  *
  * @param string $content HTML Mail bodytext
  * @return string $content
  */
 protected function makePlain($content)
 {
     $tags2LineBreaks = ['</p>', '</tr>', '<ul>', '</li>', '</h1>', '</h2>', '</h3>', '</h4>', '</h5>', '</h6>', '</div>', '</legend>', '</fieldset>', '</dd>', '</dt>'];
     // 1. remove complete head element
     $content = preg_replace('/<head>(.*?)<\\/head>/i', '', $content);
     // 2. remove linebreaks, tabs
     $content = trim(str_replace(["\n", "\r", "\t"], '', $content));
     // 3. add linebreaks on some parts (</p> => </p><br />)
     $content = str_replace($tags2LineBreaks, '</p><br />', $content);
     // 4. insert space for table cells
     $content = str_replace(['</td>', '</th>'], '</td> ', $content);
     // 5. replace links <a href="xyz">LINK</a> -> LINK [xyz]
     $content = preg_replace('/<a[^>]+href\\s*=\\s*["\']([^"\']+)["\'][^>]*>(.*?)<\\/a>/misu', '$2 [$1]', $content);
     // 6. remove all tags (<b>bla</b><br /> => bla<br />)
     $content = strip_tags($content, '<br><address>');
     // 7. <br /> to \n
     $content = StringUtility::br2nl($content);
     return trim($content);
 }
예제 #3
0
 /**
  * cleanFileNameReturnBool Test
  *
  * @param string $content
  * @param string $expectedResult
  * @dataProvider br2nlReturnStringDataProvider
  * @return void
  * @test
  */
 public function br2nlReturnString($content, $expectedResult)
 {
     $this->assertSame($expectedResult, StringUtility::br2nl($content));
 }