/** * @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 * @param $parser @todo doc * @param $frame @todo doc * @param $args @todo doc * @return @todo doc */ protected function cmdLoad(&$parser, $frame, array $args) { $out = ''; $id = trim(strtolower(isset($args[1]) ? $frame->expand($args[1]) : '')); $xml = trim(isset($args[2]) ? $frame->expand($args[2]) : ''); $trans = trim(isset($args[3]) ? $frame->expand($args[3]) : ''); $out .= $this->formatDebugMessage("Loading XML: id = '{$id}'"); $out .= $this->formatDebugMessage("Loading XML: file = '{$xml}'"); if (!isset($this->_xmls[$id])) { $conf = array('file' => $xml); /* * - class * - file * - translator * - style * - showattrs * - class * - debug * - editable */ $this->setLastError(); $aux = new X2WParser(); $out .= $aux->loadFromList($conf); if (!$this->getLastError()) { $this->_xmls[$id] = $aux; $out .= $this->formatDebugMessage("XML with ID '{$id}' added"); } } else { $out .= $this->setLastError($this->formatErrorMessage(wfMsg('x2w-load-duplicated-id', $id))); } return $out; }