/** * Register function. */ function Xml2Wiki_Hooker() { Xml2Wiki::Instance(); }
/** * @todo doc * @param $params @todo doc * @return @todo doc */ public static function AjaxParser($params) { $out = ''; global $wgXML2WikiConfig; Xml2Wiki::Instance(); $params = explode($wgXML2WikiConfig['ajaxseparator'], $params); $xml = $params[0]; $value = $params[1]; $oldValue = $params[2]; $position = $params[3]; $articleID = $params[4]; $debug = $params[5]; $out = $oldValue; if ($value != $oldValue) { $conf = array('file' => $xml, 'debug' => $debug); /* * - class * - file * - translator * - style * - showattrs * - class * - debug */ $x2wParser = new X2WParser(); $x2wParser->setLastError(); $x2wParser->loadFromList($conf); if ($x2wParser->getLastError()) { if ($x2wParser->debugEnabled()) { $out = $x2wParser->getLastError() . '<br/>' . $oldValue; } else { $out = $oldValue; } } else { $conf['full_path'] = $x2wParser->getFilePath($xml); $x2wParser->loadXMLData(); /* * Analysing XML structure and items. * @{ */ $aux = explode("_", $position); $xyPosition = array('x' => $aux[2], 'y' => $aux[3]); $xmlSt = buildXMLStruct($x2wParser->_xmlData, $xyPosition, $value, false); if (!$x2wParser->_xmlData->asXML($conf['full_path'])) { $out = $x2wParser->formatErrorMessage(wfMsg('forbbideneditfile', $conf['file'])) . '<br/>' . $oldValue; } else { /* * GhostBuster's Code: This piece of code * avoids some unpleasant results when * cache is enabled. * @{ */ $title = Title::newFromID($articleID, GAID_FOR_UPDATE); $title->invalidateCache(); /* @} */ $out = $value; } } } return $out; }
/** * @todo doc * @return @todo doc */ public static function Instance() { if (!Xml2Wiki::$_Instance) { Xml2Wiki::$_Instance = new Xml2Wiki(); } return Xml2Wiki::$_Instance; }