function testimonial_display($content_to_display) { $pattern_recog = array("left" => array("{", "{"), "right" => array("}", "}"), "center" => array("{", "}")); foreach ($pattern_recog as $float => $direction) { $testimonialPattern = "*" . $direction[0] . "{2}(testimonial:[A-Za-z0-9_ \\-]+)" . $direction[1] . "{2}*"; $testimonialNames = getFilterIds($content_to_display, $testimonialPattern); $testimonials = array(); if (count($testimonialNames) > 0) { foreach ($testimonialNames as $name) { $sploded = explode(":", $name); $testimonials[] = Testimonials::FindByName($sploded[1]); } } foreach ($testimonials as $testimonial) { if (is_object($testimonial)) { $replacement = $testimonial->displayTestimonial($float); $search = "{$direction[0]}{$direction[0]}testimonial:" . $testimonial->slug . "{$direction[1]}{$direction[1]}"; $content_to_display = str_replace($search, $replacement, $content_to_display); } else { $content_to_display = "<span class=\"database_error\">HCd>CMS Warning: Testimonial not found!</span> " . $content_to_display; } } } return $content_to_display; }
function howManyReferencing() { $pagecount = $eventcount = $entrycount = 0; $placement_descriptions = ''; $pages = Pages::FindAll(); if (CALENDAR_INSTALL) { $events = Events::FindAll(); } if (BLOG_INSTALL) { $entries = Blog_Entries::FindAll(); } $pattern_recog = array("left" => array("{", "{"), "right" => array("}", "}"), "reg" => array("{", "}")); foreach ($pattern_recog as $float => $direction) { $imagePattern = "*" . $direction[0] . "{2}(" . $this->name . ")" . $direction[1] . "{2}*"; foreach ($pages as $page) { $imageIds = getFilterIds($page->content, $imagePattern); //print_r($imageIds); if (count($imageIds) >= 1) { $pagecount++; $placement_descriptions .= '<a href="' . get_link('admin/edit_page/' . $page->id) . '">' . $page->display_name . '</a>, '; } } if (CALENDAR_INSTALL) { foreach ($events as $event) { $imageIds = getFilterIds($event->description, $imagePattern); if (count($imageIds) >= 1) { $eventcount++; } } } if (BLOG_INSTALL) { foreach ($entries as $entry) { $imageIds = getFilterIds($entry->content, $imagePattern); if (count($imageIds) >= 1) { $entrycount++; } } } } $message = $pagecount . " Pages"; if (CALENDAR_INSTALL) { $message .= ", " . $eventcount . " Events"; } if (BLOG_INSTALL) { $message .= ", " . $entrycount . " Blog Entries"; } return $message . ' | ' . $placement_descriptions; }
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; }
function scrub_HCd_Tags($content_to_display) { // Looks for all of our patterns and removes the tags... Does not return any one particular tag. // If you want to scrub the content but save an image, the Steel Yard has a good function in blogs.php called "cleanForUpdates" $pattern_recog = array("left" => array("{", "{"), "right" => array("}", "}"), "reg" => array("{", "}")); $types = array("image" => "", "gallery" => "gallery:", "carousel" => "carousel:", "product" => "product:", "documents" => "documents:"); foreach ($pattern_recog as $float => $direction) { foreach ($types as $name => $type) { $pattern = "*" . $direction[0] . "{2}(" . $type . "[A-Za-z0-9_, \\-]+)" . $direction[1] . "{2}*"; $items = getFilterIds($content_to_display, $pattern); foreach ($items as $item) { $search = $direction[0] . $direction[0] . $item . $direction[1] . $direction[1]; $replacement = ""; $content_to_display = str_replace($search, $replacement, $content_to_display); } } } return $content_to_display; }
function mail_image_display($content_to_display) { $pattern_recog = array("left" => array("{", "{"), "right" => array("}", "}"), "reg" => array("{", "}")); foreach ($pattern_recog as $float => $direction) { $imagePattern = "*" . $direction[0] . "{2}([A-Za-z0-9_ \\-]+)" . $direction[1] . "{2}*"; $imageIds = getFilterIds($content_to_display, $imagePattern); $images = array(); foreach ($imageIds as $imageId) { if ($imageId == "random") { $random_image = Images::FindRandom(); $random_image->name = "random"; $images[] = $random_image; } else { if ($imageId == "random_cover") { $random_image = Images::FindRandomCover(); $random_image->name = "random_cover"; $images[] = $random_image; } else { $images[] = Images::FindByName($imageId); } } } foreach ($images as $key => $image) { if (isset($image)) { if (substr($image->description, 0, 7) == "http://") { $replacement = "<span class=\"photo{$float}\"><a href=\"{$image->description}\"><img src=\"http://" . SITE_URL . get_link("/images/view/" . $image->id) . "\" alt=\"" . $image->title . "\" /></a>"; $replacement .= "<br /><a href=\"{$image->description}\">" . $image->title . "</a></span>"; } else { $replacement = "<span class=\"photo{$float}\"><img src=\"http://" . SITE_URL . get_link("/images/view/" . $image->id) . "\" alt=\"" . $image->title . "\" />"; if ($image->description != "") { $replacement .= "<br />" . $image->description; } $replacement .= "</span>"; } $content_to_display = updateContent($content_to_display, "*" . $direction[0] . "{2}{$image->name}" . $direction[1] . "{2}*", $replacement); } } } return $content_to_display; }