public function execute() { global $smwgDIIP, $wgOut, $wgRequest, $wgScriptPath, $smwgDIScriptPath; require_once $smwgDIIP . '/specials/TermImport/SMW_WIL.php'; $wil = new WIL(); $tlModules = $wil->getTLModules(); $html = "<div id=\"menue\">"; $html .= "<div id=\"breadcrumb-menue\" class=\"BreadCrumpContainer\">"; $html .= "<span id=\"menue-step1\" class=\"ActualMenueStep\">" . wfMsg('smw_ti_menuestep1') . "</span><span class=\"HeadlineDelimiter\"></span>"; $html .= "<span id=\"menue-step2\" class=\"TodoMenueStep\">" . wfMsg('smw_ti_menuestep2') . "</span>"; $html .= "</div></div>"; $html .= "<div id=\"summary\"></div>" . "<div id=\"top-container\">" . "<div><div id=\"tl-content\"><b>" . wfMsg('smw_ti_tl-heading') . "</b>" . "<div id=\"tlid\">" . $this->getTLIDs($tlModules) . "</div>" . "<div id=\"tldesc\">" . "</div></div>" . "<div class=\"arrow\"><img src=\"{$wgScriptPath}/extensions/DataImport/skins/TermImport/images/arrow.png\"/></div>" . "</div>"; $html .= "<div><div id=\"dal-content\"><b>" . wfMsg('smw_ti_dam-heading') . "</b>" . "<div id=\"dalid\">" . "<div class=\"myinfo\"><i>" . wfMsg('smw_ti_firstselectTLM') . "</i></div>" . "</div>" . "<div id=\"daldesc\">" . "</div></div>" . "<div class=\"arrow\"><img src=\"{$wgScriptPath}/extensions/DataImport/skins/TermImport/images/arrow.png\"/></div>" . "</div>"; $html .= "<div id=\"source-spec\"><b>" . wfMsg('smw_ti_module-data-heading') . "</b>" . "<table height=\"200px\"><tr><td valign=\"top\"><i>" . wfMsg('smw_ti_selectDAM') . "</i></td></tr></table>" . "</div>"; $html .= "</div>"; //top-container $html .= "<div style=\"display: none\" id=\"loading-container\">"; $html .= "<br/><br/>"; $html .= "<b>Loading... </b>"; $html .= "<img src=\"" . $smwgDIScriptPath . "/skins/TermImport/images/ajax-loader.gif\"/>"; $html .= "</div>"; $html .= "<div id=\"bottom-container\">" . "<div id=\"extras\">" . "<div id=\"extras-left\">" . "<div id=\"importset\"><div class=\"input-field-heading\">" . wfMsg('smw_ti_selectImport-heading') . "<img id=\"help-img1\" title=\"" . wfMsg("smw_wws_help-button-tooltip") . "\" class=\"help-image\" onclick=\"termImportPage.displayHelp(1)\" src=\"" . $smwgDIScriptPath . "/skins/webservices/help.gif\"></img>" . "</div>" . "<div id=\"help1\" class=\"TIHelpMessage\" style=\"display: none\">" . "<span>" . wfMsg('smw_ti_help') . "</span> " . wfMsg('smw_ti_selectImport-help') . "</div>" . wfMsg('smw_ti_selectImport-label') . "<select name=\"importset\" id=\"importset-input-field\" size=\"1\" onchange=\"termImportPage.importSetChanged(event, this)\"></select>" . "<br><br>" . "</div>" . "<br/><br/><div id=\"policy\">" . "<div id=\"policy-input\">" . "<div class=\"input-field-heading\">" . wfMsg('smw_ti_inputpolicy-heading') . "<img id=\"help-img2\" title=\"" . wfMsg("smw_wws_help-button-tooltip") . "\" class=\"help-image\" onclick=\"termImportPage.displayHelp(2)\" src=\"" . $smwgDIScriptPath . "/skins/webservices/help.gif\"></img>" . "</div>" . "<div id=\"help2\" class=\"TIHelpMessage\" style=\"display: none\">" . "<span>" . wfMsg('smw_ti_help') . "</span> " . wfMsg('smw_ti_inputpolicy-help') . "</div>" . "<span>" . wfMsg('smw_ti_inputpolicy-label') . "</span>" . "<input type=\"radio\" name=\"policy_type\" value=\"regex\" checked><span>RegEx</span><input type=\"radio\" name=\"policy_type\" value=\"term\">Term</span>" . " <input name=\"policy\" id=\"policy-input-field\" type=\"text\" size=\"20\">" . " <img onclick=\"termImportPage.getPolicy(event, this)\" src=\"{$wgScriptPath}/extensions/DataImport/skins/TermImport/images/Add.png\" />" . "<br/><br/><div>" . wfMsg('smw_ti_inputpolicy-defined') . "<img onclick=\"termImportPage.deletePolicy(event, this)\" src=\"{$wgScriptPath}/extensions/DataImport/skins/TermImport/images/Delete-silk.png\" /></div>" . "</div>" . "<select id=\"policy-textarea\" name=\"policy-out\" size=\"3\" multiple>" . "</select><div id=\"hidden_pol_type\"></div>" . "</div>" . "<div id=\"mapping\">" . "<br/><br/><div class=\"input-field-heading\">" . wfMsg('smw_ti_mappingPage-heading') . "<img id=\"help-img3\" title=\"" . wfMsg("smw_wws_help-button-tooltip") . "\" class=\"help-image\" onclick=\"termImportPage.displayHelp(3)\" src=\"" . $smwgDIScriptPath . "/skins/webservices/help.gif\"></img>" . "</div>" . "<div id=\"help3\" class=\"TIHelpMessage\" style=\"display: none\">" . "<span >" . wfMsg('smw_ti_help') . "</span> " . wfMsg('smw_ti_mappingPage-help') . "</div>" . wfMsg('smw_ti_mappingPage-label') . "<input name=\"mapping\" id=\"mapping-input-field\" type=\"text\"\r\n\t\t\t\t\t\t\t\t\tclass=\"wickEnabled\" typeHint=\"0\" \r\n\t\t\t\t\t\t\t\t\tsize=\"20\" onKeyPress=\"termImportPage.changeBackground(event, this)\"/>  \r\n\t\t\t\t\t\t\t\t\t\t<a onClick=\"termImportPage.viewMappingArticle(event,this)\">" . wfMsg('smw_ti_viewMappingPage') . "</a>  \r\n\t\t\t\t\t\t\t\t\t\t<a onClick=\"termImportPage.editMappingArticle(event,this)\">" . wfMsg('smw_ti_editMappingPage') . "</a>" . "</div>" . "<div id=\"conflict\">" . "<br/><br/><div class=\"input-field-heading\">" . wfMsg('smw_ti_conflictpolicy-heading') . "<img id=\"help-img4\" title=\"" . wfMsg("smw_wws_help-button-tooltip") . "\" class=\"help-image\" onclick=\"termImportPage.displayHelp(4)\" src=\"" . $smwgDIScriptPath . "/skins/webservices/help.gif\"></img>" . "</div>" . "<div id=\"help4\" class=\"TIHelpMessage\" style=\"display: none\">" . "<span>" . wfMsg('smw_ti_help') . "</span> " . wfMsg('smw_ti_conflictpolicy-help') . "</div>" . wfMsg('smw_ti_conflictpolicy-label') . "<select name=\"conflict\" id=\"conflict-input-field\">" . "<option>overwrite</option>" . "<option>preserve current versions</option>" . "</select>" . "</div>" . "<div id=\"ti-update-policy\">" . "<br/><br/><div class=\"input-field-heading\">" . wfMsg('smw_ti_update_policy-heading') . " " . "<img id=\"help-img5\" title=\"" . wfMsg("smw_wws_help-button-tooltip") . "\" class=\"help-image\" onclick=\"termImportPage.displayHelp(5)\" src=\"" . $smwgDIScriptPath . "/skins/webservices/help.gif\"></img>" . "</div>" . "<div id=\"help5\" class=\"TIHelpMessage\" style=\"display: none\">" . "<span>" . wfMsg('smw_ti_help') . "</span> " . wfMsg('smw_ti_update_policy-help') . "</div>" . "<input type=\"radio\" name=\"update_policy_type\" value=\"once\" checked><span>Once</span>" . "<input id=\"update-policy-checkbox\" type=\"radio\" name=\"update_policy_type\" value=\"maxage\">Max age:</span>" . " <input id=\"ti-update-policy-input-field\" onKeyPress=\"termImportPage.changeBackground(event, this)\" size=\"10\"/> in minutes" . "</div>" . "<div id=\"ti-name\">" . "<br><br><div class=\"input-field-heading\">" . wfMsg('smw_ti_ti_name-heading') . " " . "<img id=\"help-img6\" title=\"" . wfMsg("smw_wws_help-button-tooltip") . "\" class=\"help-image\" onclick=\"termImportPage.displayHelp(6)\" src=\"" . $smwgDIScriptPath . "/skins/webservices/help.gif\"></img>" . "</div>" . "<div id=\"help6\" class=\"TIHelpMessage\" style=\"display: none\">" . "<span>" . wfMsg('smw_ti_help') . "</span> " . wfMsg('smw_ti_ti_name-help') . "</div>" . wfMsg('smw_ti_ti_name-label') . "<input id=\"ti-name-input-field\" onKeyPress=\"termImportPage.changeBackground(event, this)\"/>" . "</div>" . "</div>" . "<div id=\"extras-right\">" . "<div class=\"input-field-heading\">" . wfMsg('smw_ti_properties-heading') . "<img id=\"help-img7\" title=\"" . wfMsg("smw_wws_help-button-tooltip") . "\" class=\"help-image\" onclick=\"termImportPage.displayHelp(7)\" src=\"" . $smwgDIScriptPath . "/skins/webservices/help.gif\"></img>" . "</div>" . "<div id=\"help7\" class=\"TIHelpMessage\" style=\"display: none\">" . "<span>" . wfMsg('smw_ti_help') . "</span> " . wfMsg('smw_ti_properties-help') . "</div>" . wfMsg('smw_ti_properties-label') . "<div id=\"attrib-articles\">" . "<div id=\"attrib\"></div>" . "<div id=\"articles\">" . "<div class=\"input-field-heading\">" . wfMsg('smw_ti_articles-heading') . " " . "<img id=\"help-img8\" title=\"" . wfMsg("smw_wws_help-button-tooltip") . "\" class=\"help-image\" onclick=\"termImportPage.displayHelp(8)\" src=\"" . $smwgDIScriptPath . "/skins/webservices/help.gif\"></img>" . "</div>" . "<div id=\"help8\" class=\"TIHelpMessage\" style=\"display: none\">" . "<span>" . wfMsg('smw_ti_help') . "</span> " . wfMsg('smw_ti_articles-help') . "</div>" . wfMsg('smw_ti_articles-label1') . "<span id=\"article-count\"></span>" . wfMsg('smw_ti_articles-label2') . "<div id=\"article_table\" class=\"scrolling\"></div></div>" . "</div>" . "</div>" . "</div>" . "<div id=\"extras-bottom\" align=\"left\"></div>" . "<div style=\"display: none\" id=\"loading-bottom-container\">" . "<b>Loading... </b>" . "<img src=\"" . $smwgDIScriptPath . "/skins/TermImport/images/ajax-loader.gif\"/><br/><br/>" . "</div>"; $html .= "</div>"; //bottom-container $termImportName = $wgRequest->getVal('tiname'); if ($termImportName != null) { $html .= $this->embedEditTermImportData($termImportName); } $wgOut->addHTML($html); }
/** * This function sets up the modules of the import framework according to the * settings, reads the terms and creates articles for them. * * @param string $settings * This XML string contains the modules (Transport Layer, Data Access Layer), * the data source, the import sets and the input, mapping and conflict * policy. * * @return mixed (boolean, string) * <true>, if all terms were successfully imported or an * error message, otherwise. * */ public function importTerms($settings, $termImportName) { echo "Starting to import terms...\n"; echo "\n" . $settings; global $smwgDIIP; require_once $smwgDIIP . '/specials/TermImport/SMW_XMLParser.php'; $parser = new XMLParser($settings); $result = $parser->parse(); if ($result !== TRUE) { return $result; } $tlModule = $parser->getValuesOfElement(array('TLModules', 'Module', 'id')); if (count($tlModule) == 0) { return "Error: Transport layer module was not defined."; //todo: language } $dalModule = $parser->getValuesOfElement(array('DALModules', 'Module', 'id')); if (count($dalModule) == 0) { return "Error: Data access layer module was not defined."; //todo: language } global $smwgDIIP; require_once $smwgDIIP . '/specials/TermImport/SMW_WIL.php'; $wil = new WIL(); $tlModules = $wil->getTLModules(); echo "\n WIL connected"; $res = $wil->connectTL($tlModule[0], $tlModules); if (stripos($res, '<value>true</value>') === false) { return "Connecting the transport layer module {$tlModule['0']} failed."; //todo: language } $dalModules = $wil->getDALModules(); $res = $wil->connectDAL($dalModule[0], $dalModules); if (stripos($res, '<value>true</value>') === false) { return "Connecting the data access layer module {$dalModule['0']} failed."; //todo: language } $source = $parser->serializeElement(array('DataSource')); $importSets = $parser->serializeElement(array('ImportSets')); $inputPolicy = $parser->serializeElement(array('InputPolicy')); $conflictPolicy = $parser->serializeElement(array('ConflictPolicy')); echo "\nGet Terms"; $terms = $wil->getTerms($source, $importSets, $inputPolicy, $conflictPolicy); echo "\nTerms in place"; $mappingPolicy = $parser->serializeElement(array('MappingPolicy')); try { $result = $this->createArticles($terms, $mappingPolicy, $conflictPolicy, $wil, $termImportName); echo "Bot finished!\n"; if ($result === true) { $result = wfMsg('smw_ti_import_successful'); } } catch (Exception $e) { $result = "Something bad happened during the Term Import: " . $e; } return $result; }