getbody($art);
var_dump($body);
$parsebody = $this->parser($art, $body);
echo $parsebody;
return $parsebody;
}
public function getbody(Art2 $art)
{
$body = '';
foreach (self::TEXT_ELEMENTS as $element) {
if (array_key_exists($element, $art->template('array'))) {
$tempalteart = $this->get($art->template('array')[$element]);
$text = $tempalteart->$element() . PHP_EOL . $art->$element();
} else {
$text = $art->$element();
}
$body .= PHP_EOL . '<' . $element . '>' . PHP_EOL . $this->markdown($text) . PHP_EOL . '' . $element . '>' . PHP_EOL;
}
return $body;
}
public function elementsrender(Art2 $art)
{
foreach ($this->getelements($art) as $element => $text) {
if (in_array($element, self::TEXT_ELEMENTS)) {
$elements[$element] = $this->markdown($text);
}
}
return $elements;
}
public function parser(Art2 $art, string $text)
{
$text = str_replace('%TITLE%', $art->title(), $text);
$text = str_replace('%DESCRIPTION%', $art->description(), $text);
$text = str_replace(self::SUMMARY, $this->sumparser($text), $text);
$text = str_replace('href="=', 'href="?id=', $text);
$text = $this->tooltip($art->linkfrom('array'), $text);
$text = str_replace('href="http', ' class="external" target="_blank" href="http', $text);
$text = str_replace('autourl($text);
return $text;
}
public function autourl($text)
{
$text = preg_replace('#( |\R|>)(https?:\/\/((\S+)\.([^< ]+)))#', '$1$3', $text);
return $text;
}
public function markdown($text)
{
//use Michelf\MarkdownExtra;
$fortin = new Michelf\MarkdownExtra;
// id in headers
$fortin->header_id_func = function ($header) {
return preg_replace('/[^\w]/', '', strtolower($header));
};
$text = $fortin->transform($text);
return $text;
}
public function tooltip(array $linkfrom, string $text)
{
$descriptions = [];
$artlist = $this->getlisterid($linkfrom);
foreach ($artlist as $art) {
$descriptions[$art->id()] = $art->description();
}
foreach ($linkfrom as $id) {
if (isset($descriptions[$id])) {
$title = $descriptions[$id];
}
$linkfrom = 'href="?id=' . $id . '"';
$titlelinkfrom = ' title="' . $title . '" ' . $linkfrom;
$text = str_replace($linkfrom, $titlelinkfrom, $text);
}
return $text;
}
function sumparser($text)
{
preg_match_all('#