/** * ResourceLoaderGetConfigVars hook handler * This should be used for variables which vary with the html * and for variables this should work cross skin including anonymous users * @see https://www.mediawiki.org/wiki/Manual:Hooks/ResourceLoaderGetConfigVars * * @param array $vars * @return boolean */ public static function onResourceLoaderGetConfigVars(&$vars) { $context = MobileContext::singleton(); $config = $context->getMFConfig(); $pageProps = $config->get('MFQueryPropModules'); $searchParams = $config->get('MFSearchAPIParams'); // Avoid API warnings and allow integration with optional extensions. if (defined('PAGE_IMAGES_INSTALLED')) { $pageProps[] = 'pageimages'; $searchParams = array_merge_recursive($searchParams, array('piprop' => 'thumbnail', 'pithumbsize' => MobilePage::SMALL_IMAGE_WIDTH, 'pilimit' => 50)); } // We need to check that first descriptions are enabled (the server admin has installed // Wikidata) and then secondly that it is okay to display them prominently in the UI // For instance a server admin may want to make them available in the page via JS for gadgets // but not build them into their experience. $displayDescriptions = $config->get('MFDisplayWikibaseDescription'); $useDescriptions = $config->get('MFUseWikibaseDescription'); if ($context->isBetaGroupMember()) { $displayDescriptions = true; } // When set turn on Wikidata descriptions // https://phabricator.wikimedia.org/T101719 if ($useDescriptions && $displayDescriptions) { if (!in_array('pageterms', $pageProps)) { $pageProps[] = 'pageterms'; } $searchParams = array_merge_recursive($searchParams, array('wbptterms' => 'description')); } // Get the licensing agreement that is displayed in the uploading interface. $wgMFUploadLicense = MobileFrontendSkinHooks::getLicense('upload'); $vars += array('wgMFSearchAPIParams' => $searchParams, 'wgMFQueryPropModules' => $pageProps, 'wgMFSearchGenerator' => $config->get('MFSearchGenerator'), 'wgMFNearbyEndpoint' => $config->get('MFNearbyEndpoint'), 'wgMFThumbnailSizes' => array('tiny' => MobilePage::TINY_IMAGE_WIDTH, 'small' => MobilePage::SMALL_IMAGE_WIDTH), 'wgMFContentNamespace' => $config->get('MFContentNamespace'), 'wgMFEditorOptions' => $config->get('MFEditorOptions'), 'wgMFLicense' => MobileFrontendSkinHooks::getLicense('editor'), 'wgMFUploadLicenseLink' => $wgMFUploadLicense['link']); if ($context->shouldDisplayMobileView()) { $vars['wgImagesDisabled'] = $context->imagesDisabled(); } // add CodeMirror specific things, if it is installed (for CodeMirror editor) if (class_exists('CodeMirrorHooks')) { $vars += CodeMirrorHooks::getGlobalVariables(MobileContext::singleton()); $vars['wgMFCodeMirror'] = true; } return true; }
/** * ResourceLoaderGetConfigVars hook handler * This should be used for variables which vary with the html * and for variables this should work cross skin including anonymous users * @see https://www.mediawiki.org/wiki/Manual:Hooks/ResourceLoaderGetConfigVars * * @param array $vars * @return boolean */ public static function onResourceLoaderGetConfigVars(&$vars) { $context = MobileContext::singleton(); $config = $context->getMFConfig(); // Get the licensing agreement that is displayed in the uploading interface. $wgMFUploadLicense = SkinMinerva::getLicense('upload'); $vars += array('wgMFExperiments' => $config->get('MFExperiments'), 'wgMFNearbyEndpoint' => $config->get('MFNearbyEndpoint'), 'wgMFThumbnailSizes' => array('tiny' => MobilePage::TINY_IMAGE_WIDTH, 'small' => MobilePage::SMALL_IMAGE_WIDTH), 'wgMFContentNamespace' => $config->get('MFContentNamespace'), 'wgMFEditorOptions' => $config->get('MFEditorOptions'), 'wgMFLicense' => SkinMinerva::getLicense('editor'), 'wgMFUploadLicenseLink' => $wgMFUploadLicense['link']); // add CodeMirror specific things, if it is installed (for CodeMirror editor) if (class_exists('CodeMirrorHooks')) { $vars += CodeMirrorHooks::getGlobalVariables(MobileContext::singleton()); $vars['wgMFCodeMirror'] = true; } return true; }