private function getTag() { $dbname = F::app()->wg->DBname; $t = F::app()->wg->Title; $title = $t->getText(); if ($dbname == 'dehauptseite') { if (Wikia::isMainPage()) { return 'RC_WIKIA_HOME'; } if (strpos($title, 'Mobil') === 0) { return 'RC_WIKIA_MOBIL'; } if (in_array($title, array('Videospiele', 'Entertainment', 'Lifestyle'))) { return 'RC_WIKIA_START'; } if (WikiaPageType::getPageType() == 'search') { return 'RC_WIKIA_SEARCH'; } return 'RC_WIKIA_SVCE'; } if ($dbname == 'de') { if ($t->getNamespace() == NS_FORUM) { return 'RC_WIKIA_PIN'; } return 'RC_WIKIA_COMMUNITY'; } if (HubService::getComscoreCategory(F::app()->wg->CityId)->cat_name == 'Entertainment') { return 'RC_WIKIA_UGCENT'; } return 'RC_WIKIA_UGC'; }
/** * Add global JS variables * * @param array $vars global variables list * @return boolean return true */ public static function onMakeGlobalVariablesScript(array &$vars) { $vars['wgOasisResponsive'] = BodyController::isResponsiveLayoutEnabled(); $vars['wgOasisBreakpoints'] = BodyController::isOasisBreakpoints(); $vars['verticalName'] = HubService::getCurrentWikiaVerticalName(); return true; }
public function onWikiaAssetsPackages(&$out, &$jsPackages, &$scssPackages) { if (HubService::isCurrentPageAWikiaHub()) { $jsPackages[] = 'wikia/WikiaHubs/js/WikiaHubs.js'; $jsPackages[] = 'wikia/ImageLightbox/ImageLightbox.js'; $scssPackages[] = 'wikia/WikiaHubs/css/WikiaHubs.scss'; } return true; }
private function getC7Value() { global $wgCityId; $verticalName = HubService::getVerticalNameForComscore($wgCityId); if (!$verticalName) { \Wikia\Logger\WikiaLogger::instance()->error('Vertical not set for comscore', ['cityId' => $wgCityId, 'exception' => new Exception()]); return false; } else { return 'wikiacsid_' . $verticalName; } }
/** * Get wiki vertical * * @return string - wiki vertical */ protected function initCategories() { $name = ''; $categoryId = \WikiFactoryHub::getInstance()->getCategoryId($this->wg->CityId); if (!empty($categoryId)) { // get vertical id $verticalId = \HubService::getCanonicalCategoryId($categoryId); if (array_key_exists($verticalId, self::$pageCategories)) { $name = self::$pageCategories[$verticalId]; } } $this->categories = $name; }
public function getContext(Title $title, $skinName) { $wrapper = new GlobalStateWrapper(['wgTitle' => $title]); $wg = F::app()->wg; return $wrapper->wrap(function () use($title, $wg, $skinName) { $wikiFactoryHub = WikiFactoryHub::getInstance(); $hubService = new HubService(); $adPageTypeService = new AdEngine2PageTypeService(); $wikiaPageType = new WikiaPageType(); $sevenOneMediaCombinedUrl = null; if (!empty($wg->AdDriverUseSevenOneMedia)) { // TODO: implicitly gets the skin from the context! $sevenOneMediaCombinedUrl = ResourceLoader::makeCustomURL($wg->Out, ['wikia.ext.adengine.sevenonemedia'], 'scripts'); } $monetizationServiceAds = null; if (!empty($wg->AdDriverUseMonetizationService) && !empty($wg->EnableMonetizationModuleExt)) { $monetizationServiceAds = F::app()->sendRequest('MonetizationModule', 'index')->getData()['data']; } $langCode = $title->getPageLanguage()->getCode(); return ['opts' => $this->filterOutEmptyItems(['adsInContent' => $wg->EnableAdsInContent, 'delayBtf' => $wg->AdDriverDelayBelowTheFold, 'enableAdsInMaps' => $wg->AdDriverEnableAdsInMaps, 'pageType' => $adPageTypeService->getPageType(), 'paidAssetDropConfig' => $wg->PaidAssetDropConfig, 'showAds' => $adPageTypeService->areAdsShowableOnPage(), 'trackSlotState' => $wg->AdDriverTrackState, 'usePostScribe' => $wg->Request->getBool('usepostscribe', false)]), 'targeting' => $this->filterOutEmptyItems(['enablePageCategories' => array_search($langCode, $wg->AdPageLevelCategoryLangs) !== false, 'pageArticleId' => $title->getArticleId(), 'pageIsArticle' => !!$title->getArticleId(), 'pageIsHub' => $wikiaPageType->isWikiaHub(), 'pageName' => $title->getPrefixedDBKey(), 'pageType' => $wikiaPageType->getPageType(), 'sevenOneMediaSub2Site' => $wg->AdDriverSevenOneMediaOverrideSub2Site, 'skin' => $skinName, 'wikiCategory' => $wikiFactoryHub->getCategoryShort($wg->CityId), 'wikiCustomKeyValues' => $wg->DartCustomKeyValues, 'wikiDbName' => $wg->DBname, 'wikiDirectedAtChildren' => $wg->WikiDirectedAtChildrenByFounder || $wg->WikiDirectedAtChildrenByStaff, 'wikiIsCorporate' => $wikiaPageType->isCorporatePage(), 'wikiIsTop1000' => $wg->AdDriverWikiIsTop1000, 'wikiLanguage' => $langCode, 'wikiVertical' => $hubService->getCategoryInfoForCity($wg->CityId)->cat_name]), 'providers' => $this->filterOutEmptyItems(['monetizationService' => $wg->AdDriverUseMonetizationService, 'monetizationServiceAds' => $monetizationServiceAds, 'sevenOneMedia' => $wg->AdDriverUseSevenOneMedia, 'sevenOneMediaCombinedUrl' => $sevenOneMediaCombinedUrl, 'taboola' => $wg->AdDriverUseTaboola]), 'slots' => $this->filterOutEmptyItems(['exitstitial' => $wg->EnableOutboundScreenExt, 'exitstitialRedirectDelay' => $wg->OutboundScreenRedirectDelay, 'invisibleHighImpact' => $wg->AdDriverEnableInvisibleHighImpactSlot]), 'forcedProvider' => $wg->AdDriverForcedProvider]; }); }
private function getHub() { wfProfileIn( __METHOD__ ); global $wgCityId; $catInfo = HubService::getComscoreCategory($wgCityId); //i18n if (!empty($catInfo)) { $catInfo->cat_link = wfMsg('oasis-corporatefooter-hub-'. $catInfo->cat_name .'-link'); $catInfo->cat_name = wfMsg('hub-'. $catInfo->cat_name); } wfProfileOut( __METHOD__ ); return $catInfo; }
/** * @desc Contents for Weebo * @param Array $params request params */ public function anon() { wfProfileIn(__METHOD__); $params = $this->request->getParams(); $lang = !empty($params['lang']) ? $params['lang'] : WikiaBarModel::WIKIA_BAR_DEFAULT_LANG_CODE; $vertical = !empty($params['vertical']) ? $params['vertical'] : HubService::getCategoryInfoForCity($this->wg->cityId)->cat_id; /** @var $model WikiaBarModel */ $model = new WikiaBarModel(); $vertical = $model->mapVerticalToMain($vertical); $model->setLang($lang); $model->setVertical($vertical); $barContents = $model->getBarContents(); $this->barContents = $barContents['data']; $this->status = $barContents['status']; wfProfileOut(__METHOD__); }
function wfAdEngineSetupTopVars(&$vars) { global $wgCityId, $wgEnableKruxTargeting, $wgNoExternals; wfProfileIn(__METHOD__); // generic type of page: forum/search/article/home/... $vars['wikiaPageType'] = WikiaPageType::getPageType(); // category/hub $catInfo = HubService::getComscoreCategory($wgCityId); $vars['cscoreCat'] = $catInfo->cat_name; // Krux $cat = AdEngine::getCachedCategory(); if (!empty($wgEnableKruxTargeting) && empty($wgNoExternals)) { $vars['wgEnableKruxTargeting'] = $wgEnableKruxTargeting; $vars['wgKruxCategoryId'] = WikiFactoryHub::getInstance()->getKruxId($cat['id']); } wfProfileOut(__METHOD__); return true; }
private function getTag() { $dbname = F::app()->wg->DBname; $t = F::app()->wg->Title; $title = $t->getText(); if (WikiaPageType::isWikiaHub()) { return 'RC_WIKIA_START'; } if ($dbname == 'dehauptseite') { if (Wikia::isMainPage()) { return 'RC_WIKIA_HOME'; } if (strpos($title, 'Mobil') === 0) { return 'RC_WIKIA_MOBIL'; } if (WikiaPageType::getPageType() == 'search') { return 'RC_WIKIA_SEARCH'; } return 'RC_WIKIA_SVCE'; } if ($dbname == 'de') { if ($t->getNamespace() == NS_FORUM) { return 'RC_WIKIA_PIN'; } return 'RC_WIKIA_COMMUNITY'; } if (strpos(F::app()->wg->DartCustomKeyValues, 'anime') !== false) { return 'RC_WIKIA_UGCANIME'; } $cat_name = HubService::getCategoryInfoForCurrentPage()->cat_name; if ($cat_name == 'Entertainment') { return 'RC_WIKIA_UGCENT'; } if ($cat_name == 'Gaming') { return 'RC_WIKIA_UGCGAMES'; } if ($cat_name == 'Lifestyle') { return 'RC_WIKIA_UGCLIFESTYLE'; } return 'RC_WIKIA_UGC'; }
/** * Get meta description tag * @return string $description */ public function getMetaTagDescription() { $catInfo = HubService::getCategoryInfoForCity($this->wg->CityId); $descriptionKey = 'specialvideos-meta-description'; switch ($catInfo->cat_id) { case WikiFactoryHub::CATEGORY_ID_GAMING: $descriptionKey .= '-gaming'; break; case WikiFactoryHub::CATEGORY_ID_ENTERTAINMENT: $descriptionKey .= '-entertainment'; break; case WikiFactoryHub::CATEGORY_ID_LIFESTYLE: $descriptionKey .= '-lifestyle'; break; case WikiFactoryHub::CATEGORY_ID_CORPORATE: $descriptionKey .= '-corporate'; break; } $description = wfMessage($descriptionKey, $this->wg->Sitename)->escaped(); return $description; }
public function loadDataAndUpdateDatabase() { global $wgCityId; wfProfileIn(__METHOD__); if( !$this->options->overwrittenLang ) { $wikisVisualizationLangCode = WikiFactory::getVarValueByName('wgLanguageCode', $wgCityId); } else { $wikisVisualizationLangCode = $this->options->overwrittenLang; } echo "\n"; echo 'Uploading wikis for "'.$wikisVisualizationLangCode.'" visualization: '; echo "\n"; foreach( $this->options->csvContent as $line ) { $element = str_getcsv($line, ',', '"'); if( $this->areAllRequiredWikiDataForDatabaseSet($element) ) { $wikiDomain = trim( str_replace('http://', '', $element[2]), '/'); $wikiId = WikiFactory::DomainToID($wikiDomain); $spreadSheetImageName = basename($element[4]); $wikiMainImageUrl = $element[4]; $wikiMainImageName = $this->getCorpDestImageName($wikiDomain, $spreadSheetImageName); $sliderImages = $this->getSliderImages( array_slice($element, self::SPREADSHEET_FIRST_ADD_IMG_IDX, self::SPREADSHEET_LAST_ADD_IMG_IDX) ); $wikiHeadline = !empty($element[1]) ? $element[1] : ''; $wikiDesc = !empty($element[5]) ? $element[5] : wfMsg( 'wikiahome-import-script-no-description' ); if( !$this->options->skipUpload ) { //upload main image $this->uploadImage($wikiMainImageUrl, $wikiMainImageName, $wikiId); //upload slider images $sliderUploadedImages = $this->uploadSliderImages($wikiDomain, $sliderImages, $wikiId); } if( $wikiId > 0 ) { $wikiCityVertical = HubService::getComscoreCategory($wikiId); $sliderUploadedImages = (!empty($sliderUploadedImages)) ? json_encode($sliderUploadedImages) : null; $this->addToVisualizationTable( array( 'city_id' => $wikiId, 'city_lang_code' => $wikisVisualizationLangCode, 'city_vertical' => $wikiCityVertical, 'city_headline' => $wikiHeadline, 'city_description' => $wikiDesc, 'city_main_image' => $wikiMainImageName, 'city_images' => $sliderUploadedImages, ) ); } else { $this->wikisNotAdded[] = $wikiDomain.' ('.$wikiId.') '; } } } $this->uploadImagesOnWikis(); $this->displayStatus(); wfProfileOut(__METHOD__); }
public static function onWikiDataUpdated($cityId) { $app = F::app(); $mdb = wfGetDB(DB_MASTER, array(), $app->wg->ExternalSharedDB); $category = HubService::getCategoryInfoForCity($cityId); $table = self::CITY_VISUALIZATION_TABLE_NAME; $data = array('city_vertical' => $category->cat_id); $cond = array('city_id' => $cityId); $mdb->update($table, $data, $cond, __METHOD__); return true; }
protected function initVertical() { global $wgCityId; $this->verticalId = HubService::getCanonicalCategoryId(WikiFactory::getCategory($wgCityId)->cat_id); $this->cityId = $wgCityId; $this->verticalName = $this->getContext()->getTitle()->getText(); $this->canonicalVerticalName = str_replace(' ', '', $this->model->getCanonicalVerticalNameById($this->cityId)); $this->wg->out->setPageTitle($this->verticalName); // For the main page, overwrite the <title> element with the contents of 'pagetitle-view-mainpage'. if ($this->getContext()->getTitle()->isMainPage()) { $msg = wfMessage('pagetitle-view-mainpage')->inContentLanguage(); if (!$msg->isDisabled()) { $this->wg->out->setHTMLTitle($msg->title($this->getContext()->getTitle())); } } }
private function getC7Value() { global $wgCityId; $catInfo = HubService::getComscoreCategory($wgCityId); return 'wikiacsid_' . strtolower($catInfo->cat_name); }
<?php // This file receives HTTP requests from SNS, that's why it's open to the world, but the requests from SNS // contain a signature and a certificate that are verified by the notificationHandler->readNotification(...), so only // genuine messages are processed. require_once "../../../wp-load.php"; require_once 'vendor/autoload.php'; require_once 'content-hub-client-service.php'; use Hub\NotificationHandler; $hubService = new HubService(); $hubUrl = $hubService->get_property("hub.url"); $signingKeyId = $hubService->get_property("signing.key.id"); $signingKeyValue = $hubService->get_property("signing.key.value"); $acceptRawDelivery = $hubService->get_property("accept.raw.delivery") == "true"; $notificationHandler = new NotificationHandler($signingKeyId, $signingKeyValue, $hubUrl); $data = $notificationHandler->readNotification($acceptRawDelivery, true); $messageType = $data["Type"]; if ("Notification" == $messageType) { $hubService->save_notification_and_post($data["MessageId"], $data["TopicArn"], $data["MessageAttributes"]["originTopicName"]["Value"], $data["MessageAttributes"]["Content-Type"]["Value"], $data["Message"], $data["Timestamp"], $data["UnsubscribeURL"]); echo "Notification received"; } else { if ("SubscriptionConfirmation" == $messageType) { $hubService->save_subscription($data["TopicArn"]); echo "message content: " . $data["Message"] . " \n"; echo "subscription confirmed"; } else { if ("UnsubscribeConfirmation" == $messageType) { $hubService->remove_subscription($data["TopicArn"]); echo "message content: " . $data["Message"] . " \n"; echo "subscription removed"; }
public function footer() { $this->response->addAsset('extensions/wikia/WikiaHomePage/js/CorporateFooterTracker.js'); $this->interlang = HubService::isCorporatePage($this->wg->cityId); }
/** * Check if page is Wikia hub page, for example http://www.wikia.com/Video_games * * @return bool */ public static function isWikiaHub() { return HubService::isCurrentPageAWikiaHub(); }
public function getWikisForStaffTool($opt) { //todo: implement memc and purge it once admin changes data or main image is approved //todo: add sql join and instead of headline provide wiki name $db = $this->wf->GetDB(DB_SLAVE, array(), $this->wg->ExternalSharedDB); $table = array('city_visualization', 'city_list'); $fields = array('city_visualization.city_id', 'city_visualization.city_vertical', 'city_list.city_title', 'city_visualization.city_flags'); $conds = $this->getConditionsForStaffTool($opt); $options = $this->getOptionsForStaffTool($opt); $joinConds = array('city_list' => array('join', 'city_list.city_id = city_visualization.city_id')); $results = $db->select($table, $fields, $conds, __METHOD__, $options, $joinConds); $wikis = array(); while ($row = $db->fetchObject($results)) { $category = HubService::getComscoreCategory($row->city_id); $row->city_vertical = $category->cat_name; $wikis[] = $row; } return $wikis; }