Feedback in V3
This commit is contained in:
parent
765d6a2f6b
commit
6e0c7e8706
19 changed files with 1141 additions and 491 deletions
|
|
@ -172,6 +172,70 @@ class HTMLHelper
|
|||
return "alle Wochentage";
|
||||
}
|
||||
|
||||
public static function getParentBy($obj = NULL, $options, $empty=true){
|
||||
|
||||
$ret = "";
|
||||
$setId = 0;
|
||||
if($obj){
|
||||
$setId = $obj->id;
|
||||
}
|
||||
if($empty){
|
||||
$ret .= '<option value="">Non-Parent</option>\n';
|
||||
}
|
||||
foreach ($options as $id => $name){
|
||||
$attr = ($id === $setId) ? 'selected="selected"' : '';
|
||||
$ret .= '<option value="'.$id.'" '.$attr.'>'.$name.'</option>\n';
|
||||
}
|
||||
return $ret;
|
||||
}
|
||||
|
||||
|
||||
public static function filterHTML($html, $arg = [], $save = false){
|
||||
|
||||
$dom = new \DOMDocument('1.0', 'UTF-8');
|
||||
//@$dom->loadHTML();
|
||||
|
||||
@$dom->loadHTML( mb_convert_encoding($html, 'HTML-ENTITIES', 'UTF-8'));
|
||||
|
||||
if(isset($arg['src'])){
|
||||
|
||||
if(in_array('addHost', $arg['src'])){
|
||||
$images = $dom->getElementsByTagName('img');
|
||||
foreach ($images as $image) {
|
||||
|
||||
$src = $image->getAttribute('src');
|
||||
$host = config('app.url_stern');
|
||||
if(strpos($src, $host) === false){
|
||||
$src = $host."/".ltrim($src, '/');
|
||||
}
|
||||
$image->setAttribute('src', $src);
|
||||
}
|
||||
}
|
||||
|
||||
if(in_array('removeHost', $arg['src'])){
|
||||
$images = $dom->getElementsByTagName('img');
|
||||
foreach ($images as $image) {
|
||||
$src = $image->getAttribute('src');
|
||||
$host = config('app.url_stern');
|
||||
if(strpos($src, $host) !== false){
|
||||
$src = str_replace($host, '', $src);
|
||||
}
|
||||
$image->setAttribute('src', $src);
|
||||
}
|
||||
}
|
||||
}
|
||||
$html = $dom->saveHTML();
|
||||
|
||||
$html = preg_replace('~<(?:!DOCTYPE|/?(?:html|head|body))[^>]*>\s*~i', '', $html);
|
||||
|
||||
if($save){
|
||||
return mb_convert_encoding($html, "UTF-8", "HTML-ENTITIES");
|
||||
}
|
||||
|
||||
|
||||
return $html;
|
||||
}
|
||||
|
||||
/*
|
||||
public static function getIndustrySectorsWithoutParents($id = false, $sameId = false, $all = true){
|
||||
$values = IndustrySector::where('parent_id', null)->get();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue