function video_display($content_to_display) { $videoPattern = "/{{2}(video:[A-Za-z0-9\\-\\_ \\.\\(\\)'\"]+){{2}/"; $videoIds = getFilterIds($content_to_display, $videoPattern); $videos = array(); foreach ($videoIds as $videoId) { $videoname = end(explode(":", $videoId)); $videos[] = Videos::FindByName($videoname); } foreach ($videos as $thevid) { if (is_object($thevid)) { $replacement = $thevid->embed_video(); $content_to_display = updateContent($content_to_display, "/{{2}video:" . str_replace(")", "\\)", str_replace("(", "\\(", $thevid->slug)) . "{{2}/", $replacement); } else { $content_to_display = "<span class=\"database_error\">HCd>CMS Warning: Video “{$videoname}” not found!</span> " . $content_to_display; } } return $content_to_display; }
function remove_from_content() { // Not Done or Tested yet // A function to cycle through content types and remove references when deleting a video $videoPattern = "/{{2}(video:[A-Za-z0-9\\-\\_ \\.\\(\\)'\"]+){{2}/"; $videoIds = getFilterIds($content_to_display, $videoPattern); $videos = array(); foreach ($videoIds as $videoId) { $videos[] = Videos::FindByName(end(explode(":", $videoId))); } foreach ($videos as $thevid) { if (is_object($thevid)) { $replacement = $thevid->get_embed(); $content_to_display = updateContent($content_to_display, "/{{2}video:" . str_replace(")", "\\)", str_replace("(", "\\(", $thevid->name)) . "{{2}/", $replacement); } else { $content_to_display = "<span class=\"database_error\">HCd>CMS Warning: Video not found!</span> " . $content_to_display; } } return $content_to_display; }