This repository has been archived on 2022-07-28. You can view files and clone it, but cannot push or open issues or pull requests.
md-cms/inc/mdEmbeds.php

44 lines
853 B
PHP
Raw Normal View History

<?PHP
/**
* For embedding from museum-digital functions.
*
* @file
*
* @author Joshua Ramon Enslin <joshua@jrenslin.de>
*/
/**
* Function for checking a text for the existence of pseudocode
* for embedding from museum-digital.
*
* @param string $text Input string.
*
* @return string
*/
function checkForEmbeds(string $text):string {
$embedOptions = [
"eventCalendar"
];
foreach ($embedOptions as $option) {
if (strpos($text, $option) === false) continue;
$position = strpos($text, $option) - 1;
$nextTag = strpos($text, "<", $position);
$nextWhitespace = strpos($text, " ", $position);
$end = min($nextTag, $nextWhitespace, strlen($text));
$pseudocode = substr($text, $position, $position + $end);
echo $pseudocode;
}
return $text;
}
?>