/** * Add the Open Graph meta tags to the current page. * * This hook is used instead of BeforePageDisplay, (I quote from mediawiki.org,) * "to make it easier on parser caching." */ public static function ParserAfterTidy(&$parser, &$text) { global $wgFbOpenGraph, $wgOut; if (!empty($wgFbOpenGraph)) { $parser->disableCache(); $object = FacebookOpenGraph::newObjectFromTitle($parser->getTitle()); if ($object) { if ($object instanceof OpenGraphArticleObject && $object->needsDescription()) { $object->setDescriptionFromText($text); } foreach ($object->getProperties() as $property => $content) { $parser->mOutput->addHeadItem("<meta property=\"{$property}\" content=\"{$content}\" />\n", $property); } } } return true; }
/** * Remove the watch action from the user's Timeline when they unwatch an * article. */ public static function UnwatchArticleComplete(&$user, &$article) { global $facebook; if (self::getAction('watch')) { $fbUser = new FacebookUser(); if ($fbUser->getMWUser()->getId() == $user->getId()) { $object = FacebookOpenGraph::newObjectFromTitle($article->getTitle()); try { self::removeAction('watch', $object); } catch (FacebookApiException $e) { // echo $e->getType() . ": " . $e->getMessage() . "<br/>\n"; } } } return true; }