public static function getInstance() { if (!isset(self::$libraryInstance)) { self::$libraryInstance = new OpenGraphLibrary(); } return self::$libraryInstance; }
function __construct(&$subject, $config) { $this->pluginName = $config['name']; $this->extensionName = $config['name']; // Should be overridden by the plugin itself. if (class_exists('JFBConnectFacebookLibrary')) { JModelLegacy::addIncludePath(JPATH_SITE . '/components/com_jfbconnect/models'); $this->jfbcOgActionModel = JModelLegacy::getInstance('OpenGraphAction', 'JFBConnectModel'); $this->jfbcOgObjectModel = JModelLegacy::getInstance('OpenGraphObject', 'JFBConnectModel'); $this->jfbcLibrary = JFBCFactory::provider('facebook'); } if (class_exists('OpenGraphLibrary')) { $this->openGraphLibrary = OpenGraphLibrary::getInstance(); } $this->hasDefaultTags = false; $this->db = JFactory::getDBO(); parent::__construct($subject, $config); $this->init(); }
public function html() { $openGraphLibrary = OpenGraphLibrary::getInstance(); $ogGroups = array("Inserted", "Skipped", "Removed"); $html = ' <div id="social-meta" style="position:fixed; bottom:45px; display:none;">'; foreach ($ogGroups as $group) { $groupName = 'tags' . $group; $tags = $this->getOGTagList("Inserted", $openGraphLibrary->{$groupName}, true); $html .= <<<EOT <h3>{$group}</h3> <div> <p> {$tags} </p> </div> EOT; } $html .= "</div>"; return $html; }
private function replaceGraphTags() { $placeholder = '<SCOpenGraphPlaceholder />'; $regex1 = '/\\{SCOpenGraph\\s+(.*?)\\}/i'; $regex2 = '/\\{JFBCGraph\\s+(.*?)\\}/i'; $newGraphTags1 = array(); $newGraphTags2 = array(); $contents = JResponse::getBody(); $this->getGraphContents($regex1, $contents, $newGraphTags1); $this->getGraphContents($regex2, $contents, $newGraphTags2); $newGraphTags = array_merge($newGraphTags1, $newGraphTags2); //Replace Placeholder with new Head tags $defaultGraphFields = JFBCFactory::config()->getSetting('social_graph_fields'); $skipGraphFields = JFBCFactory::config()->getSetting('social_graph_skip_fields'); $locale = JFBCFactory::provider('facebook')->getLocale(); $openGraphLibrary = OpenGraphLibrary::getInstance(); $openGraphLibrary->addBlockedTags($skipGraphFields); $openGraphLibrary->addOpenGraphEasyTags($newGraphTags); $openGraphLibrary->addDefaultSettingsTags($defaultGraphFields); $openGraphLibrary->addAutoGeneratedTags($locale); $graphTags = $openGraphLibrary->buildCompleteOpenGraphList(); $contents = $openGraphLibrary->removeOverlappingTags($contents); $search = '/' . preg_quote($placeholder, '/') . '/'; $graphTags = str_replace('$', '\\$', $graphTags); $contents = preg_replace($search, $graphTags, $contents, 1); $contents = str_replace($placeholder, '', $contents); //If JLinked attempts to insert, ignore JResponse::setBody($contents); }