/**
  * Transforms content to be mobile friendly version.
  * Filters out various elements and runs the MobileFormatter.
  * @param OutputPage $out
  * @param string $mode mobile mode, i.e. stable or beta
  *
  * @return string
  */
 public static function DOMParse(OutputPage $out, $text = null, $isBeta = false)
 {
     $html = $text ? $text : $out->getHTML();
     $context = MobileContext::singleton();
     $formatter = MobileFormatter::newFromContext($context, $html);
     Hooks::run('MobileFrontendBeforeDOM', array($context, $formatter));
     $title = $out->getTitle();
     $isSpecialPage = $title->isSpecialPage();
     $formatter->enableExpandableSections($out->canUseWikiPage() && $out->getWikiPage()->getContentModel() == CONTENT_MODEL_WIKITEXT && array_search($title->getNamespace(), $context->getMFConfig()->get('MFNamespacesWithoutCollapsibleSections')) === false && $context->getRequest()->getText('action', 'view') == 'view');
     if ($context->getContentTransformations()) {
         // Remove images if they're disabled from special pages, but don't transform otherwise
         $formatter->filterContent(!$isSpecialPage);
     }
     $contentHtml = $formatter->getText();
     // If the page is a user page which has not been created, then let the
     // user know about it with pretty graphics and different texts depending
     // on whether the user is the owner of the page or not.
     if ($isBeta && $title->inNamespace(NS_USER) && !$title->isSubpage()) {
         $pageUserId = User::idFromName($title->getText());
         if ($pageUserId && !$title->exists()) {
             $pageUser = User::newFromId($pageUserId);
             $contentHtml = ExtMobileFrontend::getUserPageContent($out, $pageUser);
         }
     }
     return $contentHtml;
 }
 /**
  * Transforms content to be mobile friendly version.
  * Filters out various elements and runs the MobileFormatter.
  * @param OutputPage $out
  *
  * @return string
  */
 public static function DOMParse(OutputPage $out)
 {
     $html = $out->getHTML();
     $context = MobileContext::singleton();
     $formatter = MobileFormatter::newFromContext($context, $html);
     Hooks::run('MobileFrontendBeforeDOM', array($context, $formatter));
     $title = $out->getTitle();
     $isSpecialPage = $title->isSpecialPage();
     $formatter->enableExpandableSections($out->canUseWikiPage() && $out->getWikiPage()->getContentModel() == CONTENT_MODEL_WIKITEXT && array_search($title->getNamespace(), $context->getMFConfig()->get('MFNamespacesWithoutCollapsibleSections')) === false && $context->getRequest()->getText('action', 'view') == 'view');
     if ($context->getContentTransformations()) {
         // Remove images if they're disabled from special pages, but don't transform otherwise
         $formatter->filterContent(!$isSpecialPage);
     }
     $contentHtml = $formatter->getText();
     return $contentHtml;
 }