for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
/******************************************************************************
* Wikipedia Account Creation Assistance tool *
* *
* All code in this file is released into the public domain by the ACC *
* Development Team. Please see team.json for a list of contributors. *
******************************************************************************/
namespace Waca\Helpers;
use Waca\SiteConfiguration;
class WikiTextHelper
{
/**
* @var SiteConfiguration
*/
private $configuration;
* @var HttpHelper
private $http;
* WikiTextHelper constructor.
*
* @param SiteConfiguration $configuration
* @param HttpHelper $http
public function __construct(SiteConfiguration $configuration, HttpHelper $http)
$this->configuration = $configuration;
$this->http = $http;
}
* Gets the HTML for the provided wiki-markup from the MediaWiki service endpoint
* @param string $wikiText
* @return string
public function getHtmlForWikiText($wikiText)
$endpoint = $this->configuration->getMediawikiWebServiceEndpoint();
$parameters = array(
'action' => 'parse',
'pst' => true,
'contentmodel' => 'wikitext',
'disablelimitreport' => true,
'disabletoc' => true,
'disableeditsection' => true,
'format' => 'php',
'text' => $wikiText,
);
$apiResult = $this->http->get($endpoint, $parameters);
$parseResult = unserialize($apiResult);
return $parseResult['parse']['text']['*'];