Ejemplo n.º 1
0
function smwf_ti_createTIArticle($moduleConfig, $sourceConfig, $mappingConfig, $conflictConfig, $inputConfig, $importSetConfig, $termImportName, $updatePolicy, $edit)
{
    $title = Title::newFromText("TermImport:" . $termImportName);
    if ($title->exists() && $edit == "false") {
        return '<?xml version="1.0"?>
	 			<ReturnValue xmlns="http://www.ontoprise.de/smwplus#">
	 		    <value>falseTIN</value>
	 		    <message>' . wfMsg('smw_ti_def_allready_exists') . '</message>
	 			</ReturnValue >';
    }
    $moduleConfig = str_replace('<?xml version="1.0"?>', "", $moduleConfig);
    $moduleConfig = str_replace(' xmlns="http://www.ontoprise.de/smwplus#"', "", $moduleConfig);
    $moduleConfig = trim($moduleConfig);
    $sourceConfig = str_replace('<?xml version="1.0"?>', "", $sourceConfig);
    $sourceConfig = str_replace(' xmlns="http://www.ontoprise.de/smwplus#"', "", $sourceConfig);
    $sourceConfig = trim($sourceConfig);
    $mappingConfig = str_replace('<?xml version="1.0"?>', "", $mappingConfig);
    $mappingConfig = str_replace(' xmlns="http://www.ontoprise.de/smwplus#"', "", $mappingConfig);
    $mappingConfig = trim($mappingConfig);
    $conflictConfig = str_replace('<?xml version="1.0"?>', "", $conflictConfig);
    $conflictConfig = str_replace(' xmlns="http://www.ontoprise.de/smwplus#"', "", $conflictConfig);
    $conflictConfig = trim($conflictConfig);
    $inputConfig = str_replace('<?xml version="1.0"?>', "", $inputConfig);
    $inputConfig = str_replace(' xmlns="http://www.ontoprise.de/smwplus#"', "", $inputConfig);
    $inputConfig = trim($inputConfig);
    $updatePolicy = str_replace('<?xml version="1.0"?>', "", $updatePolicy);
    $updatePolicy = str_replace(' xmlns="http://www.ontoprise.de/smwplus#"', "", $updatePolicy);
    $updatePolicy = trim($updatePolicy);
    $importSetConfig = str_replace('<?xml version="1.0"?>', "", $importSetConfig);
    $importSetConfig = str_replace(' XMLNS="http://www.ontoprise.de/smwplus#"', "", $importSetConfig);
    $importSetConfig = str_replace('IMPORTSETS>', "ImportSets>", $importSetConfig);
    $importSetConfig = str_replace('IMPORTSET>', "ImportSet>", $importSetConfig);
    $importSetConfig = str_replace('NAME>', "Name>", $importSetConfig);
    $importSetConfig = trim($importSetConfig);
    $tiConfig = "<ImportSettings>" . $moduleConfig . $sourceConfig . $mappingConfig . $conflictConfig . $inputConfig . $importSetConfig . $updatePolicy . "</ImportSettings>";
    //pretty print
    $xml = explode("\n", preg_replace('/>\\s*</', ">\n<", $tiConfig));
    $tiConfig = implode("\n", $xml);
    $articleContent = $tiConfig;
    $articleContent .= "\n==== Last runs of this Term Import ====\n";
    $articleContent .= "{{#ask: [[belongsToTermImportWithLabel::" . $termImportName . "]]" . "\n| format=ul | limit=10 | sort=hasImportDate | order=descending}}";
    $articleContent .= "\n[[Category:TermImport]]";
    $result = smwf_om_EditArticle('TermImport:' . $termImportName, 'TermImportBot', $articleContent, '');
    $temp = $result;
    $result = explode(",", $result);
    $result = trim($result[0]);
    if ($result !== "true") {
        return '<?xml version="1.0"?>
	 			<ReturnValue xmlns="http://www.ontoprise.de/smwplus#">
	 		    <value>falseTIN</value>
	 		    <message>' . wfMsg('smw_ti_def_not_creatable') . '</message>
	 			</ReturnValue >';
    }
    smwf_om_TouchArticle("TermImport:" . $termImportName);
    return true;
}
Ejemplo n.º 2
0
 private function createTermImportResultContentPreview($termImportName)
 {
     $result = "__NOTOC__\n";
     $result .= "==== Import summary ====";
     $result .= "\nTerm Import definition: [[belongsToTermImport::TermImport:" . $termImportName . "|" . $termImportName . "]]" . " [[belongsToTermImportWithLabel::" . $termImportName . "| ]]";
     $result .= "\nImport date: [[hasImportDate::";
     $result .= $this->getDateString() . "]]";
     $result .= "\nResult: Some errors occured.[[wasImportedSuccessfully::false| ]] (Check [[Special:Gardening]] if Term Import is finished.)";
     $result .= "\n==== Added terms ====\n";
     $result .= "{{#ask: [[WasAddedDuringTermImport::TermImport:" . $termImportName . "/" . $this->getDateString() . "]]| format=ul}}";
     $result .= "\n==== Updated terms ====\n";
     $result .= "{{#ask: [[WasUpdatedDuringTermImport::TermImport:" . $termImportName . "/" . $this->getDateString() . "]]| format=ul}}";
     $result .= "\n==== Ignored terms ====\n";
     $result .= "{{#ask: [[IgnoredDuringTermImport::TermImport:" . $termImportName . "/" . $this->getDateString() . "]]| format=ul}}";
     $result .= "\n[[Category:TermImportRun]]";
     $timeInTitle = $this->getDateString();
     smwf_om_EditArticle("TermImport:" . $termImportName . "/" . $timeInTitle, 'TermImportBot', $result, '');
     //smwf_om_TouchArticle("TermImport:".$termImportName."/".$timeInTitle);
     smwf_om_TouchArticle("TermImport:" . $termImportName);
 }
/**
 * this method is called after step 3 (specify ws-name)
 *
 * @param string $name name of the webservice
 * @param string $wwsd the wwsd which was created
 * @return string error/ok signals if the wwsd could be validated
 */
function smwf_ws_processStep6($name, $wwsd, $user, $wsSyntax)
{
    global $wgHooks;
    $wgHooks['ArticleSaveComplete'][] = 'WebServiceManager::articleSavedHook';
    //$editResult = explode(",", smwf_om_EditArticle("webservice:".$name, $user, $wwsd.$wsSyntax, ""));
    $editResult = explode(",", smwf_om_EditArticle("webservice:" . $name, $user, $wwsd, ""));
    if ($editResult[0]) {
        $ws = WebService::newFromWWSD($name, $wwsd);
        if (is_array($ws)) {
            return "isa " . implode(";", $ws);
        } else {
            //$res = $ws->validateWWSD();
            // $res = $ws->store();
            // if(!$res){
            //	return "error";
            //}
            return smwf_om_TouchArticle("webservice:" . $name);
        }
    } else {
        return "false done";
    }
}