/**
* @param simple_html_dom_node $child
* @param string $tmpBuffer
* @return string
*/
function elementHandler($child, $tmpBuffer, $depth = 0, $break = true)
{
//foreach ($childsHtml->children as $child) {
/** @var simple_html_dom_node $child */
if ($child->tag == 'ul') {
foreach ($child->children as $grandchild) {
$tmpBuffer = elementHandler($grandchild, $tmpBuffer, $depth + 1);
}
return $tmpBuffer;
}
$inner = $child->innertext();
$break2 = true;
if ($child->tag == 'li') {
//$tmpBuffer.='*';
for ($i = 0; $i < $depth; $i++) {
$tmpBuffer .= '*';
}
if ($inner == '') {
$break2 = false;
} else {
$tmpBuffer .= $inner;
}
} else {
if ($child->tag == 'p') {
$inner = str_replace("\t", '', $inner);
$inner = str_replace("\n", ' ', $inner);
//$tmpBuffer .= $inner;
$tmpBuffer = depthTest($inner, $child, $tmpBuffer);
} else {
if ($child->tag == 'b') {
$tmpBuffer .= '===';
$tmpBuffer = depthTest($inner, $child, $tmpBuffer);
//$tmpBuffer .= $inner;
$tmpBuffer .= "===";
} else {
if ($child->tag == 'u') {
$tmpBuffer .= '<u>';
$tmpBuffer = depthTest($inner, $child, $tmpBuffer);
//$tmpBuffer .= $inner;
$tmpBuffer .= '</u>';
} else {
if ($child->tag == 'i') {
$tmpBuffer .= '\'\'';
$tmpBuffer = depthTest($inner, $child, $tmpBuffer);
//$tmpBuffer .= $inner;
$tmpBuffer .= '\'\'';
} else {
if ($child->tag == 'text') {
$tmpBuffer .= $inner;
} else {
if ($child->tag == 'font') {
$tmpBuffer .= $inner;
}
}
}
}
}
}
}
if ($break && $break2) {
$tmpBuffer .= "\n";
}
//}
return $tmpBuffer;
}