* @license MIT */ class MMNotify{ /** * Occurs after a new article has been created. * @see http://www.mediawiki.org/wiki/Manual:Hooks/ArticleInsertComplete */ static function onPageContentInsertComplete(WikiPage $wikiPage, $user, $text, $summary, $isminor, $iswatch, $section, $flags, $revision){ if (stripos($wikiPage->getTitle()->getText(), 'FSPlenum') === false) return; $post = wfMessage('mmmotify-onPageContentInsertComplete')->plain().'\n'.$wikiPage->getTitle()->getFullURL().'\n\n----\n'; $text = ContentHandler::getContentText($wikiPage->getRevision()->getContent( Revision::RAW)); preg_match_all('/^={1,2}[^=].*$/m', $text, $out); foreach ($out[0] as $heading) { $post .= $heading.'\n'; } self::send_curl_request('{"text": "'.str_replace('"', '\"', $post).'"}'); return true; } private static function send_curl_request($postData) { global $MMIncomingWebhookUrl; $h = curl_init(); curl_setopt($h, CURLOPT_URL, $MMIncomingWebhookUrl); curl_setopt($h, CURLOPT_POST, 1); curl_setopt($h, CURLOPT_POSTFIELDS, $postData); curl_setopt($h, CURLOPT_HTTPHEADER, array('Content-Type: application/json', 'Content-Length: '.strlen($postData))); curl_setopt($h, CURLOPT_RETURNTRANSFER, true); $curl_output = curl_exec($h); curl_close($h); } }