function egOgmcParserOutputApplyValues($out, $parserOutput, $data) { global $wgTitle; $articleId = $wgTitle->getArticleID(); $titleImage = $titleDescription = null; wfRunHooks('OpenGraphMeta:beforeCustomFields', array($articleId, &$titleImage, &$titleDescription)); // Only use ImageServing if no main image is already specified. This lets people override the image with the parser function: [[File:{{#setmainimage:Whatever.png}}]]. if (!isset($out->mMainImage)) { if (is_null($titleImage)) { // Get image from ImageServing // TODO: Make sure we automatically respect these restrictions from Facebook: // "An image URL which should represent your object within the graph. // The image must be at least 50px by 50px and have a maximum aspect ratio of 3:1. // We support PNG, JPEG and GIF formats." $imageServing = F::build('ImageServing', array($articleId)); foreach ($imageServing->getImages(1) as $key => $value) { $titleImage = Title::newFromText($value[0]['name'], NS_FILE); } } // If ImageServing was not able to deliver a good match, fall back to the wiki's wordmark. if (empty($titleImage) && !is_object($titleImage) && F::app()->checkSkin('oasis')) { $themeSettings = new ThemeSettings(); $settings = $themeSettings->getSettings(); if ($settings["wordmark-type"] == "graphic") { $titleImage = Title::newFromText($settings['wordmark-image-name'], NS_FILE); } } // If we have a Title object for an image, convert it to an Image object and store it in mMainImage. if (!empty($titleImage) && is_object($titleImage)) { $mainImage = wfFindFile($titleImage); if ($mainImage !== false) { $parserOutput->setProperty('mainImage', $mainImage); $out->mMainImage = $parserOutput->getProperty('mainImage'); } } else { // Fall back to using a Wikia logo. There aren't any as "File:" pages, so we use a new config var for one that // is being added to skins/common. global $wgBigWikiaLogo; $logoUrl = wfReplaceImageServer($wgBigWikiaLogo); $parserOutput->setProperty('mainImage', $logoUrl); $out->mMainImage = $parserOutput->getProperty('mainImage'); } } // Get description from ArticleService if (is_null($titleDescription)) { $DESC_LENGTH = 100; $articleService = new ArticleService($articleId); $titleDescription = $articleService->getTextSnippet($DESC_LENGTH); } if (!empty($titleDescription)) { $parserOutput->setProperty('description', $titleDescription); $out->mDescription = $parserOutput->getProperty('description'); } if ($page_id = Wikia::getFacebookDomainId()) { $out->addMeta('property:fb:page_id', $page_id); } }
protected function getDailyLikes(array &$stats) { global $fbAccessToken; $result = FALSE; $domain_id = Wikia::getFacebookDomainId(); if (!$domain_id) { return $result; } $this->wf->ProfileIn(__METHOD__); $since = strtotime("-7 day 00:00:00"); $until = strtotime("-0 day 00:00:00"); $url = 'https://graph.facebook.com/' . $domain_id . '/insights/domain_widget_likes/day?access_token=' . $fbAccessToken . '&since=' . $since . '&until=' . $until; $response = json_decode(Http::get($url)); if ($response) { $data = array_pop($response->data); if (isset($data->values)) { $stats['totals']['likes'] = 0; foreach ($data->values as $value) { if (preg_match('/([\\d\\-]*)/', $value->end_time, $matches)) { $day = $matches[1]; $stats[$day]['likes'] = $value->value; $stats['totals']['likes'] += $value->value; } } $result = TRUE; } } $this->wf->ProfileOut(__METHOD__); return $result; }