mirror of
https://git.code.sf.net/p/seeddms/code
synced 2024-11-26 15:32:13 +00:00
52 lines
1.2 KiB
PHP
52 lines
1.2 KiB
PHP
<?php
|
|
/**
|
|
* Implementation of conversion service class
|
|
*
|
|
* @category DMS
|
|
* @package SeedDMS
|
|
* @license GPL 2
|
|
* @version @version@
|
|
* @author Uwe Steinmann <uwe@steinmann.cx>
|
|
* @copyright Copyright (C) 2021 Uwe Steinmann
|
|
* @version Release: @package_version@
|
|
*/
|
|
|
|
require_once("inc/inc.ClassConversionServiceBase.php");
|
|
|
|
/**
|
|
* Implementation of conversion service class for text to text
|
|
*
|
|
* @category DMS
|
|
* @package SeedDMS
|
|
* @author Uwe Steinmann <uwe@steinmann.cx>
|
|
* @copyright Copyright (C) 2021 Uwe Steinmann
|
|
* @version Release: @package_version@
|
|
*/
|
|
class SeedDMS_ConversionServiceHtmlToText extends SeedDMS_ConversionServiceBase {
|
|
public function __construct($from, $to) {
|
|
parent::__construct();
|
|
$this->from = $from;
|
|
$this->to = $to;
|
|
}
|
|
|
|
public function getInfo() {
|
|
return "Strip tags from document contents";
|
|
}
|
|
|
|
public function convert($infile, $target = null, $params = array()) {
|
|
$d = new DOMDocument;
|
|
$d->loadHTMLFile($infile);
|
|
$body = $d->getElementsByTagName('body')->item(0);
|
|
$str = '';
|
|
foreach($body->childNodes as $childNode) {
|
|
$str .= $d->saveHTML($childNode);
|
|
}
|
|
if($target) {
|
|
file_put_contents($target, strip_tags($str));
|
|
return true;
|
|
} else
|
|
return strip_tags($str);
|
|
}
|
|
}
|
|
|