示例#1
0
 /**
  * @param $listingSID
  */
 public static function setMetaOpenGraph($listingSID)
 {
     if (!empty($listingSID)) {
         $listing = SJB_ListingManager::getObjectBySID($listingSID);
         $listingStructure = SJB_ListingManager::createTemplateStructureForListing($listing);
         $siteUrl = SJB_System::getSystemSettings("SITE_URL");
         $location = SJB_LocationManager::locationFormat(array("location" => $listingStructure['Location']));
         $locationFormatted = !empty($location) ? " (" . $location . ")" : '';
         $title = htmlspecialchars(strip_tags(trim($listingStructure['Title']))) . $locationFormatted;
         $logoImage = !empty($listingStructure['user']['Logo']['file_url']) ? $listingStructure['user']['Logo']['file_url'] : '';
         $description = self::getListingDescriptionPreparedForSharer($listingStructure);
         $listingUrl = SJB_ListingManager::getListingUrlBySID($listingSID);
         $openGraphMetaBlock = "<meta property=\"og:type\" content=\"website\" />\n\t" . "<meta property=\"og:url\" content=\"{$listingUrl}\" />\n\t" . "<meta property=\"og:title\" content=\"{$title}\" />\n\t" . "<meta property=\"og:description\" content=\"{$description}\" />\n\t" . "<meta property=\"og:site_name\" content=\"{$siteUrl}\" />\n\t" . "<meta property=\"og:image\" content=\"{$logoImage}\" />";
         $head = SJB_System::getPageHead();
         SJB_System::setPageHead($head . ' ' . $openGraphMetaBlock);
     }
 }