예제 #1
0
파일: ApiHelp.php 프로젝트: paladox/2
 public function execute()
 {
     $params = $this->extractRequestParams();
     $modules = array();
     foreach ($params['modules'] as $path) {
         $modules[] = $this->getModuleFromPath($path);
     }
     // Get the help
     $context = new DerivativeContext($this->getMain()->getContext());
     $context->setSkin(SkinFactory::getDefaultInstance()->makeSkin('apioutput'));
     $context->setLanguage($this->getMain()->getLanguage());
     $context->setTitle(SpecialPage::getTitleFor('ApiHelp'));
     $out = new OutputPage($context);
     $out->setCopyrightUrl('https://www.mediawiki.org/wiki/Special:MyLanguage/Copyright');
     $context->setOutput($out);
     self::getHelp($context, $modules, $params);
     // Grab the output from the skin
     ob_start();
     $context->getOutput()->output();
     $html = ob_get_clean();
     $result = $this->getResult();
     if ($params['wrap']) {
         $data = array('mime' => 'text/html', 'help' => $html);
         ApiResult::setSubelementsList($data, 'help');
         $result->addValue(null, $this->getModuleName(), $data);
     } else {
         $result->reset();
         $result->addValue(null, 'text', $html, ApiResult::NO_SIZE_CHECK);
         $result->addValue(null, 'mime', 'text/html', ApiResult::NO_SIZE_CHECK);
     }
 }
예제 #2
0
 /**
  * @param WebRequest|null $request
  * @param Language|string|null $language
  * @param User|null $user
  *
  * @return DerivativeContext
  */
 private function newContext(WebRequest $request = null, $language = null, User $user = null)
 {
     $context = new DerivativeContext(RequestContext::getMain());
     $context->setRequest($request ?: new FauxRequest());
     if ($language !== null) {
         $context->setLanguage($language);
     }
     if ($user !== null) {
         $context->setUser($user);
     }
     $this->setEditTokenFromUser($context);
     return $context;
 }
예제 #3
0
 /**
  * Flatten an array, using the content language for any messages.
  *
  * @param array $vals Array of values
  * @param string $type Type of array (either lang, ul, ol).
  *   lang = language assoc array with keys being the lang code
  *   ul = unordered list, ol = ordered list
  *   type can also come from the '_type' member of $vals.
  * @param bool $noHtml If to avoid returning anything resembling HTML.
  *   (Ugly hack for backwards compatibility with old MediaWiki).
  * @param bool|IContextSource $context
  * @return string Single value (in wiki-syntax).
  * @since 1.23
  */
 public static function flattenArrayContentLang($vals, $type = 'ul', $noHtml = false, $context = false)
 {
     global $wgContLang;
     $obj = new FormatMetadata();
     if ($context) {
         $obj->setContext($context);
     }
     $context = new DerivativeContext($obj->getContext());
     $context->setLanguage($wgContLang);
     $obj->setContext($context);
     return $obj->flattenArrayReal($vals, $type, $noHtml);
 }