/**
  * Creates and returns a MobileFormatter
  *
  * @param MobileContext $context
  * @param string $html
  *
  * @return MobileFormatter
  */
 public static function newFromContext(MobileContext $context, $html)
 {
     $mfSpecialCaseMainPage = $context->getMFConfig()->get('MFSpecialCaseMainPage');
     $title = $context->getTitle();
     $isMainPage = $title->isMainPage() && $mfSpecialCaseMainPage;
     $isFilePage = $title->inNamespace(NS_FILE);
     $isSpecialPage = $title->isSpecialPage();
     $html = self::wrapHTML($html);
     $formatter = new MobileFormatter($html, $title);
     $formatter->enableExpandableSections(!$isMainPage && !$isSpecialPage);
     $formatter->setIsMainPage($isMainPage);
     if ($context->getContentTransformations() && !$isFilePage) {
         $formatter->setRemoveMedia($context->imagesDisabled());
     }
     return $formatter;
 }
Пример #2
0
 /**
  * Returns array of config variables that should be added only to this skin
  * for use in JavaScript.
  * @return array
  */
 public function getSkinConfigVariables()
 {
     $title = $this->getTitle();
     $user = $this->getUser();
     $config = $this->getMFConfig();
     $vars = array('wgMFEnableJSConsoleRecruitment' => $config->get('MFEnableJSConsoleRecruitment'), 'wgMFWikiDataEndpoint' => $config->get('MFWikiDataEndpoint'), 'wgMFUseCentralAuthToken' => $config->get('MFUseCentralAuthToken'), 'wgMFPhotoUploadAppendToDesc' => $config->get('MFPhotoUploadAppendToDesc'), 'wgMFLeadPhotoUploadCssSelector' => $config->get('MFLeadPhotoUploadCssSelector'), 'wgMFPhotoUploadEndpoint' => $config->get('MFPhotoUploadEndpoint') ? $config->get('MFPhotoUploadEndpoint') : '', 'wgPreferredVariant' => $title->getPageLanguage()->getPreferredVariant(), 'wgMFDeviceWidthTablet' => $config->get('MFDeviceWidthTablet'), 'wgMFMode' => $this->getMode(), 'wgMFCollapseSectionsByDefault' => $config->get('MFCollapseSectionsByDefault'), 'wgMFTocEnabled' => $this->getOutput()->getProperty('MinervaTOC'), 'wgMFPageSections' => $this->isMobileMode);
     if ($this->isAuthenticatedUser()) {
         $vars['wgMFIsLoggedInUserBlockedFromPage'] = $user->isBlockedFrom($title, true);
         $vars['wgMFExperiments'] = $config->get('MFExperiments');
     }
     $vars['wgMFShowRedLinks'] = $user->isLoggedIn() ? $config->get('MFShowRedLinks') : $config->get('MFShowRedLinksAnon');
     // Get variables that are only needed in mobile mode
     if ($this->isMobileMode) {
         $vars['wgImagesDisabled'] = $this->mobileContext->imagesDisabled();
         $vars['wgUserCanUpload'] = $this->mobileContext->userCanUpload();
     }
     return $vars;
 }
 /**
  * Returns array of config variables that should be added only to this skin
  * for use in JavaScript.
  * @return array
  */
 public function getSkinConfigVariables()
 {
     $title = $this->getTitle();
     $user = $this->getUser();
     $config = $this->getMFConfig();
     $out = $this->getOutput();
     $vars = array('wgMFMenuData' => $this->getMenuData(), 'wgMFEnableJSConsoleRecruitment' => $config->get('MFEnableJSConsoleRecruitment'), 'wgMFWikiDataEndpoint' => $config->get('MFWikiDataEndpoint'), 'wgMFUseCentralAuthToken' => $config->get('MFUseCentralAuthToken'), 'wgMFPhotoUploadAppendToDesc' => $config->get('MFPhotoUploadAppendToDesc'), 'wgMFLeadPhotoUploadCssSelector' => $config->get('MFLeadPhotoUploadCssSelector'), 'wgMFPhotoUploadEndpoint' => $config->get('MFPhotoUploadEndpoint') ? $config->get('MFPhotoUploadEndpoint') : '', 'wgPreferredVariant' => $title->getPageLanguage()->getPreferredVariant(), 'wgMFDeviceWidthTablet' => $config->get('MFDeviceWidthTablet'), 'wgMFMode' => $this->getMode(), 'wgMFCollapseSectionsByDefault' => $config->get('MFCollapseSectionsByDefault'), 'wgMFTocEnabled' => $this->getOutput()->getProperty('MinervaTOC'));
     if ($this->isAuthenticatedUser()) {
         $blockInfo = false;
         if ($user->isBlockedFrom($title, true)) {
             $block = $user->getBlock();
             $blockReason = $block->mReason ? $out->parseinline($block->mReason) : $this->msg('blockednoreason')->text();
             $blockInfo = array('blockedBy' => $block->getByName(), 'blockReason' => $blockReason);
         }
         $vars['wgMFUserBlockInfo'] = $blockInfo;
     }
     // Get variables that are only needed in mobile mode
     if ($this->isMobileMode) {
         $vars['wgImagesDisabled'] = $this->mobileContext->imagesDisabled();
     }
     return $vars;
 }