/**
  * Checks the context for whether to load the viewer.
  * @param User $user
  * @return bool
  */
 protected static function shouldHandleClicks($user)
 {
     global $wgMediaViewerIsInBeta, $wgEnableMediaViewerForLoggedInUsersOnly;
     if ($wgMediaViewerIsInBeta && class_exists('BetaFeatures')) {
         return BetaFeatures::isFeatureEnabled($user, 'multimedia-viewer');
     }
     if ($user->getOption('multimediaviewer-enable')) {
         if ($wgEnableMediaViewerForLoggedInUsersOnly) {
             return $user->isLoggedIn();
         } else {
             // Default to enabling for everyone.
             return true;
         }
     }
     return false;
 }
 public static function onBeforePageDisplay(OutputPage &$out, Skin &$skin)
 {
     // Enable only if the user has turned it on in Beta Preferences, or BetaFeatures is not installed.
     // Will only be loaded if PageImages & TextExtracts extensions are installed.
     $registry = ExtensionRegistry::getInstance();
     if (!$registry->isLoaded('TextExtracts') || !class_exists('ApiQueryPageImages')) {
         $logger = LoggerFactory::getInstance('popups');
         $logger->error('Popups requires the PageImages and TextExtracts extensions.');
         return true;
     }
     if (self::getConfig()->get('PopupsBetaFeature') === true) {
         if (!class_exists('BetaFeatures')) {
             $logger = LoggerFactory::getInstance('popups');
             $logger->error('PopupsMode cannot be used as a beta feature unless ' . 'the BetaFeatures extension is present.');
             return true;
         }
         if (!BetaFeatures::isFeatureEnabled($skin->getUser(), 'popups')) {
             return true;
         }
     }
     $out->addModules(array('ext.popups', 'schema.Popups'));
     return true;
 }
 /**
  * GetPreferences hook handler
  * @see https://www.mediawiki.org/wiki/Manual:Hooks/GetPreferences
  *
  * @param User $user
  * @param array $preferences
  *
  * @return bool
  */
 public static function onGetPreferences($user, &$preferences)
 {
     $mfEnableMinervaBetaFeature = MobileContext::singleton()->getMFConfig()->get('MFEnableMinervaBetaFeature');
     $definition = array('type' => 'api', 'default' => '');
     $preferences[SpecialMobileWatchlist::FILTER_OPTION_NAME] = $definition;
     $preferences[SpecialMobileWatchlist::VIEW_OPTION_NAME] = $definition;
     // Remove the Minerva skin from the preferences unless Minerva has been enabled in
     // BetaFeatures.
     if (!class_exists('BetaFeatures') || !BetaFeatures::isFeatureEnabled($user, 'betafeatures-minerva') || !$mfEnableMinervaBetaFeature) {
         // Preference key/values are backwards. The value is the name of the skin. The
         // key is the text+links to display.
         if (!empty($preferences['skin']['options'])) {
             $key = array_search('minerva', $preferences['skin']['options']);
             unset($preferences['skin']['options'][$key]);
         }
     }
     return true;
 }
 /**
  * @param \OutputPage $out
  * @param \Skin $skin
  * @return boolean
  */
 public static function onBeforePageDisplay(\OutputPage &$out, \Skin &$skin)
 {
     global $wgCirrusSearchUseCompletionSuggester;
     if ($wgCirrusSearchUseCompletionSuggester && class_exists('\\BetaFeatures') && \BetaFeatures::isFeatureEnabled($GLOBALS['wgUser'], 'cirrussearch-completionsuggester')) {
         // We use the js extension only for testing the suggest-api
         $out->addModules(array('ext.cirrus'));
     }
     return true;
 }
 /**
  * Hook: EditPage::showEditForm:initial
  */
 public static function newArticleCampaign(EditPage $newPage, OutputPage $out)
 {
     global $wgContentTranslationCampaigns, $wgContentTranslationEventLogging;
     $user = $out->getUser();
     if (!$wgContentTranslationCampaigns['newarticle'] || $out->getRequest()->getCookie('cx_campaign_newarticle_hide', '') || $newPage->mTitle->exists() || !$newPage->mTitle->inNamespace(NS_MAIN) || $user->isAnon() || BetaFeatures::isFeatureEnabled($user, 'cx')) {
         return true;
     }
     // If EventLogging integration is enabled, load the event logging functions module
     // to measure and analyse the usage of this entry point.
     if ($wgContentTranslationEventLogging) {
         $out->addModules('ext.cx.eventlogging');
     }
     $out->addModules('ext.cx.campaigns.newarticle');
 }
<?php

/**
 * Temporary BetaFeature for HHVM.
 *
 * Thiswas sourced from TranslateWiki (https://github.com/wikimedia/translatewiki/blob/0b7ba4665ab3e599516d2c2774e2541495a9d7a4/TranslatewikiSettings.php#L478)
 */
$wgHooks['GetBetaFeaturePreferences'][] = function ($user, &$prefs) {
    $prefs['hhvm-beta'] = array('label-message' => 'hhvm-beta-label', 'desc-message' => 'hhvm-beta-desc', 'info-link' => 'http://www.hhvm.com/', 'discussion-link' => 'https://meta.orain.org/wiki/Forum:HHVM');
};
$wgHooks['BeforePageDisplay'][] = function (OutputPage $out) {
    $req = $out->getRequest();
    $user = $out->getUser();
    $hasCookie = $req->getCookie('hhvm', '');
    $wantsCookie = BetaFeatures::isFeatureEnabled($user, 'hhvm-beta');
    if (!$hasCookie && $wantsCookie) {
        $req->response()->setcookie('hhvm', '1', 0, array('prefix' => ''));
    }
    if ($hasCookie && !$wantsCookie) {
        $req->response()->setcookie('hhvm', '0', -1, array('prefix' => ''));
    }
};
$wgHooks['RecentChange_save'][] = function (RecentChange $rc) {
    if (wfIsHHVM()) {
        ChangeTags::addTags('HHVM', $rc->getAttribute('rc_id'));
    }
    return true;
};
$wgHooks['LocalisationCacheRecache'][] = function ($cache, $code, &$cachedData) {
    if ($code === 'en') {
        $cachedData['messages']['hhvm-beta-label'] = 'HHVM';
 /**
  * Checks the context for whether to load the viewer.
  * @param User $user
  * @return bool
  */
 protected static function shouldHandleClicks($user)
 {
     global $wgMediaViewerIsInBeta, $wgMediaViewerEnableByDefaultForAnonymous;
     if ($wgMediaViewerIsInBeta && class_exists('BetaFeatures')) {
         return BetaFeatures::isFeatureEnabled($user, 'multimedia-viewer');
     }
     if (!$user->isLoggedIn() && isset($wgMediaViewerEnableByDefaultForAnonymous)) {
         return (bool) $wgMediaViewerEnableByDefaultForAnonymous;
     } else {
         return (bool) $user->getOption('multimediaviewer-enable');
     }
 }
 /**
  * Adds the "other projects" section to the sidebar, if enabled project wide or
  * the user has the beta featured enabled.
  *
  * @param Skin $skin
  * @param array &$sidebar
  *
  * @return bool
  */
 public function doSidebarBeforeOutput(Skin $skin, array &$sidebar)
 {
     $outputPage = $skin->getContext()->getOutput();
     $title = $outputPage->getTitle();
     if (!$this->namespaceChecker->isWikibaseEnabled($title->getNamespace()) || !$outputPage->getProperty('wikibase_item')) {
         return true;
     }
     $betaFeatureEnabled = class_exists('\\BetaFeatures') && $this->otherProjectsLinksBeta && \BetaFeatures::isFeatureEnabled($skin->getContext()->getUser(), 'wikibase-otherprojects');
     if ($this->otherProjectsLinksDefault || $betaFeatureEnabled) {
         $otherProjectsSidebar = $outputPage->getProperty('wikibase-otherprojects-sidebar');
         // in case of stuff in cache without the other projects
         if ($otherProjectsSidebar === null) {
             $otherProjectsSidebarGenerator = $this->otherProjectsSidebarGeneratorFactory->getOtherProjectsSidebarGenerator();
             $otherProjectsSidebar = $otherProjectsSidebarGenerator->buildProjectLinkSidebar($title);
         }
         if (!empty($otherProjectsSidebar)) {
             $sidebar['wikibase-otherprojects'] = $otherProjectsSidebar;
         }
     }
     return true;
 }