/** * Fill the internal arrays with the set of articles to be displayed (possibly plus one additional * article that indicates further results). */ protected function doQuery() { global $wgContLang; // ask for the list of articles that use the web service $options = new SMWRequestOptions(); $options->limit = $this->limit + 1; $options->sort = true; $reverse = false; if ($this->mFromArticle != '') { $options->boundary = $this->mFromArticle; $options->ascending = true; $options->include_boundary = true; } elseif ($this->mUntilArticle != '') { $options->boundary = $this->mUntilArticle; $options->ascending = false; $options->include_boundary = false; $reverse = true; } $articleIDs = WSStorage::getDatabase()->getWSArticles($this->getTitle()->getArticleID(), $options); foreach ($articleIDs as $articleId) { $this->mArticles[] = Title::newFromID($articleId); } if ($reverse) { $this->mArticles = array_reverse($this->mArticles); } foreach ($this->mArticles as $title) { $this->articles_start_char[] = $wgContLang->convert($wgContLang->firstChar($title->getText())); } }
/** * Returns the single instance of this class. * * @return WSStorage * The single instance of this class. */ public static function getInstance() { if (!isset(self::$mInstance)) { $c = __CLASS__; self::$mInstance = new $c(); } return self::$mInstance; }
/** * method for confirming a new webservice * * @param string $wsId * */ function smwf_ws_confirmWWSD($wsId) { global $smwgDIIP; require_once $smwgDIIP . '/specials/WebServices/SMW_WSStorage.php'; global $wgUser; $allowed = false; $user = $wgUser; if ($user != null) { $groupsOfUser = $user->getGroups(); foreach ($groupsOfUser as $key => $group) { if ($group == 'sysop') { $allowed = true; } } } if ($allowed) { WSStorage::getDatabase()->setWWSDConfirmationStatus($wsId, "true"); return $wsId; } return 0; }
/** * This method updates cache entries that are used in properties * that are outdated for a single webservice * */ private function updateWSResults($ws) { $log = SGAGardeningIssuesAccess::getGardeningIssuesAccess(); echo "updating " . $ws->getName() . "\n"; $parameterSets = WSStorage::getDatabase()->getWSUsages($ws->getArticleID()); $updatedEntries = 0; $affectedArticles = array(); foreach ($parameterSets as $parameterSet) { echo "\t updating paramater set " . $parameterSet["paramSetId"] . "\n"; $cacheResult = WSStorage::getDatabase()->getResultFromCache($ws->getArticleID(), $parameterSet["paramSetId"]); $refresh = false; if (count($cacheResult) < 1) { $refresh = true; } if (!$refresh) { if ($ws->getQueryPolicy() > 0) { if (wfTime() - wfTimestamp(TS_UNIX, $cacheResult["lastUpdate"]) > $ws->getQueryPolicy() * 60) { $refresh = true; } } } if ($refresh) { echo "\t\t update necessary\n"; if ($updatedEntries > 0) { sleep($ws->getUpdateDelay()); echo "\t\t sleeping " . $ws->getUpdateDelay() . "\n"; } $parameters = WSStorage::getDatabase()->getParameters($parameterSet["paramSetId"]); $parameters = $ws->initializeCallParameters($parameters); $response = $ws->getWSClient()->call($ws->getMethod(), $parameters); $goon = true; if (is_string($response)) { $log->addGardeningIssueAboutValue($this->id, SMW_GARDISSUE_ERROR_WSCACHE_ENTRIES, Title::newFromText($ws->getName()), 0); $goon = false; } if ($goon) { WSStorage::getDatabase()->storeCacheEntry($ws->getArticleID(), $parameterSet["paramSetId"], serialize($response), wfTimeStamp(TS_MW, wfTime()), wfTimeStamp(TS_MW, wfTime())); echo "\t\t update was successfully\n"; //get articles which have to be refreshed } } $tempAffectedArticles = WSStorage::getDatabase()->getUsedWSParameterSetPairs($ws->getArticleID(), $parameterSet["paramSetId"]); if ($ws->getQueryPolicy() > 0) { if ($refresh || count($tempAffectedArticles) > 1) { $affectedArticles = array_merge($affectedArticles, $tempAffectedArticles); } $updatedEntries += 1; } } return $affectedArticles; }
/** * this function deletes all cache entries related * to a wwsd that longer exists.. * * @param string $webServiceId */ public static function removeWS($webServiceId) { WSStorage::getDatabase()->removeWSFromCache($webServiceId); }
/** * Intializes Data Import Extension. * Called from SMW during initialization. */ function smwfDISetupExtension() { global $wgHooks, $wgExtensionCredits, $wgAutoloadClasses, $wgSpecialPages; global $smwgDIIP, $wgSpecialPageGroups, $wgRequest, $smwgEnableDataImportExtension, $wgContLang; if (defined('DO_MAINTENANCE')) { require_once $smwgDIIP . '/specials/WebServices/SMW_WSStorage.php'; if (!WSStorage::getDatabase()->isInitialized()) { return true; } } global $smwgQuerySources; $smwgQuerySources['webservice'] = 'SMWWSSMWStore'; require_once $smwgDIIP . '/specials/WebServices/smwstoragelayer/SMW_WSSMWStore.php'; //so that other extensions like the gardening framework know about //the Data Import Extension $smwgEnableDataImportExtension = true; require_once $smwgDIIP . '/specials/WebServices/SMW_WebServiceManager.php'; require_once $smwgDIIP . '/specials/TermImport/SMW_TermImportManager.php'; global $wgParser; $wgParser->setFunctionHook('webServiceUsage', 'wsuf_Render'); $spns_text = $wgContLang->getNsText(NS_SPECIAL); // register AddHTMLHeader functions for special pages // to include javascript and css files (only on special page requests). if (stripos($wgRequest->getRequestURL(), $spns_text . ":") !== false || stripos($wgRequest->getRequestURL(), $spns_text . "%3A") !== false) { $wgHooks['BeforePageDisplay'][] = 'smwDITIAddHTMLHeader'; $wgHooks['BeforePageDisplay'][] = 'smwDIWSAddHTMLHeader'; } $wgHooks['BeforePageDisplay'][] = 'smwDITBAddHTMLHeader'; global $enableMaterialization; if (isset($enableMaterialization) && $enableMaterialization) { $wgHooks['BeforePageDisplay'][] = 'smwDIMAAddHTMLHeader'; } $wgHooks['smwhACNamespaceMappings'][] = 'difRegisterAutocompletionIcons'; smwfDIInitMessages(); WebServiceManager::initWikiWebServiceExtension(); TermImportManager::initTermImportFramework(); // add some AJAX calls $action = $wgRequest->getVal('action'); if ($action == 'ajax') { $method_prefix = smwfDIGetAjaxMethodPrefix(); // decide according to ajax method prefix which script(s) to import switch ($method_prefix) { case '_ti_': require_once $smwgDIIP . '/specials/TermImport/SMW_CL.php'; break; case '_wsu_': require_once $smwgDIIP . '/specials/WebServices/SMW_UseWebServiceAjaxAccess.php'; break; case '_ws_': require_once $smwgDIIP . '/specials/WebServices/SMW_WebServiceRepositoryAjaxAccess.php'; require_once $smwgDIIP . '/specials/WebServices/SMW_DefineWebServiceAjaxAccess.php'; break; } } else { // otherwise register special pages $wgAutoloadClasses['SMWTermImportSpecial'] = $smwgDIIP . '/specials/TermImport/SMW_TermImportSpecial.php'; $wgSpecialPages['TermImport'] = array('SMWTermImportSpecial'); $wgSpecialPageGroups['TermImport'] = 'di_group'; $wgAutoloadClasses['SMWWebServiceRepositorySpecial'] = $smwgDIIP . '/specials/WebServices/SMW_WebServiceRepositorySpecial.php'; $wgSpecialPages['DataImportRepository'] = array('SMWWebServiceRepositorySpecial'); $wgSpecialPageGroups['DataImportRepository'] = 'di_group'; $wgAutoloadClasses['SMWDefineWebServiceSpecial'] = $smwgDIIP . '/specials/WebServices/SMW_DefineWebServiceSpecial.php'; $wgSpecialPages['DefineWebService'] = array('SMWDefineWebServiceSpecial'); $wgSpecialPageGroups['DefineWebService'] = 'di_group'; $wgAutoloadClasses['SMWUseWebServiceSpecial'] = $smwgDIIP . '/specials/WebServices/SMW_UseWebServiceSpecial.php'; $wgSpecialPages['UseWebService'] = array('SMWUseWebServiceSpecial'); $wgSpecialPageGroups['UseWebService'] = 'di_group'; // Register Credits $wgExtensionCredits['parserhook'][] = array('name' => 'Data Import Extension', 'version' => SMW_DI_VERSION, 'author' => "Thomas Schweitzer, Ingo Steinbauer, Sascha Wagner and Daniel Hansch. Owned by [http://www.ontoprise.de ontoprise GmbH].", 'url' => 'http://smwforum.ontoprise.com/smwforum/index.php/Help:Data_Import_Extension', 'description' => 'Allows to import data from a lot of different sources.'); } //load the Gardening Bots require_once "{$smwgDIIP}/specials/TermImport/SMW_TermImportBot.php"; require_once "{$smwgDIIP}/specials/TermImport/SMW_TermImportUpdateBot.php"; require_once "{$smwgDIIP}/specials/WebServices/SMW_WSCacheBot.php"; require_once "{$smwgDIIP}/specials/WebServices/SMW_WSUpdateBot.php"; $wgSpecialPages['Ask'] = array('SMWWSSMWAskPage'); return true; }
/** * This method constructs the special page for defining webservices * */ public function execute($par) { global $wgRequest, $wgOut, $smwgDIIP; require_once $smwgDIIP . '/specials/WebServices/SMW_WSStorage.php'; $webServices = WSStorage::getDatabase()->getWebServices(); ksort($webServices); $ws = ""; //todo:use language file $wgOut->setPageTitle("Use Web Service"); if (count($webServices) == 0) { $url = Title::makeTitleSafe(NS_SPECIAL, "DefineWebService")->getInternalURL() . "?wwsdId=" . $this->getTitle()->getArticleID(); $url = Title::makeTitleSafe(NS_SPECIAL, "DefineWebService")->getInternalURL(); $html = "No Wiki Web Service Definitions are available yet. Please go to the special page <a href=\"" . $url . "\">Special:DefineWebService</a> and define some first."; $wgOut->addHTML($html); return; } $first = true; $firstTriplifyable = ' style="display: none" '; $step5BCLabel = str_replace("6.", "5.", wfMsg('smw_wwsu_menue-s5')); foreach ($webServices as $w) { if (strlen($w->getTriplificationSubject()) > 0 && defined('LOD_LINKEDDATA_VERSION')) { $triplifyable = ' class="triplifyable" '; if ($first) { $firstTriplifyable = ''; $step5BCLabel = str_replace("5.", "6.", wfMsg('smw_wwsu_menue-s5')); } } else { $triplifyable = ' class="not triplifyable" '; } $first = false; $ws .= "<option " . $triplifyable . " value=\"" . substr($w->getName(), 11, strlen($w->getName())) . "\">" . substr($w->getName(), 11, strlen($w->getName())) . "</option>"; } global $smwgDIIP, $smwgDIScriptPath; $html = ""; $html .= "<div id=\"menue\" class=\"BreadCrumpContainer\">"; $html .= "<span id=\"menue-step1\" class=\"ActualMenueStep\">" . wfMsg('smw_wwsu_menue-s1') . "</span><span class=\"HeadlineDelimiter\"></span>"; $html .= "<span id=\"menue-step2\" class=\"TodoMenueStep\">" . wfMsg('smw_wwsu_menue-s2') . "</span><span class=\"HeadlineDelimiter\"></span>"; $html .= "<span id=\"menue-step3\" class=\"TodoMenueStep\">" . wfMsg('smw_wwsu_menue-s3') . "</span><span class=\"HeadlineDelimiter\"></span>"; $html .= "<span id=\"menue-step4\" class=\"TodoMenueStep\">" . wfMsg('smw_wwsu_menue-s4') . "</span><span class=\"HeadlineDelimiter\"></span>"; if (defined('LOD_LINKEDDATA_VERSION')) { $html .= "<span id=\"menue-step6\" " . $firstTriplifyable . " class=\"TodoMenueStep\">" . wfMsg('smw_wwsu_menue-s6') . "</span><span class=\"HeadlineDelimiter\"></span>"; $html .= "<span id=\"menue-step5\" class=\"TodoMenueStep\">" . $step5BCLabel . "</span>"; } else { $html .= "<span id=\"menue-step5\" class=\"TodoMenueStep\">" . str_replace("6.", "5.", wfMsg('smw_wwsu_menue-s5')) . "</span>"; } $html .= "</div>"; // 1. Choose web service $html .= "<br>"; $html .= "<div id=\"step1\" class=\"StepDiv\" style=\"display: block\">"; $html .= "<p id=\"step1-head\" class=\"step-headline\">" . wfMsg('smw_wwsu_menue-s1'); $html .= "<img id=\"step1-help-img\" class=\"help-image\" title=\"" . wfMsg("smw_wws_help-button-tooltip") . "\" onclick=\"useWSSpecial.displayHelp(1)\" src=\"" . $smwgDIScriptPath . "/skins/webservices/help.gif\"></img>"; $html .= "</p>"; $html .= "<p>" . wfMsg('smw_wwsu_availablews'); $html .= "<select id=\"step1-webservice\" size=\"1\" onchange=\"useWSSpecial.displayTriplificationOptions()\">"; $html .= $ws . "</select>"; $html .= "</p>"; $html .= "<div id=\"step1-help\" class=\"WSHLPMSG\" style=\"display:none\">" . wfMsg("smw_wsuse_s1-help") . "</div>"; $html .= "<br/>"; $html .= "<span id=\"step1-go\" class=\"OKButton\">"; $html .= "<input type=\"button\" class=\"OKButton\" id=\"step1-go-img\" value=\"" . wfMsg("smw_wsgui_nextbutton") . "\" onclick=\"useWSSpecial.processStep1()\">"; $html .= "</span>"; $html .= "</div>"; //2. Define parameters $html .= "<div id=\"step2\" class=\"StepDiv\" style=\"display: none\">"; $html .= "<p class=\"step-headline\">" . wfMsg('smw_wwsu_menue-s2'); $html .= "<img id=\"step2-help-img\" class=\"help-image\" title=\"" . wfMsg("smw_wws_help-button-tooltip") . "\" onclick=\"useWSSpecial.displayHelp(2)\" src=\"" . $smwgDIScriptPath . "/skins/webservices/help.gif\"></img>"; $html .= "</p>"; $html .= "<table id=\"step2-parameters\"><tr><th>" . wfMsg('smw_wwsu_alias') . "</th><th id=\"step2-use-label\" style=\"visibility: hidden\">" . wfMsg('smw_wwsu_use') . "<span onclick=\"useWSSpecial.useParameters()\"><input title=\"" . wfMsg("smw_wws_selectall-tooltip") . "\" type=\"checkbox\" style=\"text-align: right\" id=\"step2-use\"/></span></th><th>" . wfMsg('smw_wwsu_value') . "</th><th>" . wfMsg('smw_wwsu_defaultvalue') . "</th></tr></table>"; $html .= "<div id=\"step2-noparameters\">" . wfMsg("smw_wwsu_noparameters") . "</div>"; $html .= "<div id=\"step2-help\" class=\"WSHLPMSG\" style=\"display:none\">" . wfMsg("smw_wsuse_s2-help") . "</div>"; $html .= "<br/>"; $html .= "<span id=\"step2-go\" class=\"OKButton\">"; $html .= "<input type=\"button\" class=\"OKButton\" id=\"step2-go-img\" value=\"" . wfMsg("smw_wsgui_nextbutton") . "\" onclick=\"useWSSpecial.processStep2()\">"; $html .= "</span>"; $html .= "</div>"; //3. Choose result parts $html .= "<div id=\"step3\" class=\"StepDiv\" style=\"display: none\">"; $html .= "<p class=\"step-headline\">" . wfMsg('smw_wwsu_menue-s3'); $html .= "<img id=\"step3-help-img\" class=\"help-image\" title=\"" . wfMsg("smw_wws_help-button-tooltip") . "\" onclick=\"useWSSpecial.displayHelp(3)\" src=\"" . $smwgDIScriptPath . "/skins/webservices/help.gif\"></img>"; $html .= "</p>"; $html .= "<table id=\"step3-results\"><tr><th>" . wfMsg('smw_wwsu_alias') . "</th><th>" . wfMsg('smw_wwsu_use') . "<span onclick=\"useWSSpecial.useResults()\"><input title=\"" . wfMsg("smw_wws_selectall-tooltip") . "\" type=\"checkbox\" style=\"text-align: right\" id=\"step3-use\"/></span></th><th>" . wfMsg('smw_wwsu_label') . "</th</tr></table>"; $html .= "<div id=\"step3-noresults\">" . wfMsg('smw_wwsu_noresults') . "</div>"; $html .= "<div id=\"step3-help\" class=\"WSHLPMSG\" style=\"display:none\">" . wfMsg("smw_wsuse_s3-help") . "</div>"; $html .= "<br/>"; $html .= "<span id=\"step3-go\" class=\"OKButton\">"; $html .= "<input type=\"button\" class=\"OKButton\" id=\"step3-go-img\" value=\"" . wfMsg("smw_wsgui_nextbutton") . "\" onclick=\"useWSSpecial.processStep3()\">"; $html .= "</span>"; $html .= "</div>"; // 4. Choose output format $html .= "<br>"; $html .= "<div id=\"step4\" class=\"StepDiv\" style=\"display: none\">"; $html .= "<p class=\"step-headline\">" . wfMsg('smw_wwsu_menue-s4'); $html .= "<img id=\"step4-help-img\" title=\"" . wfMsg("smw_wws_help-button-tooltip") . "\" class=\"help-image\" onclick=\"useWSSpecial.displayHelp(4)\" src=\"" . $smwgDIScriptPath . "/skins/webservices/help.gif\"></img>"; $html .= "</p>"; // format selector $html .= "<p>" . wfMsg('smw_wwsu_availableformats'); $html .= "<select id=\"step4-format\" size=\"1\" onchange=\"useWSSpecial.updateStep4Widgets()\">"; $html .= "<option value=\"list\">list</option>"; $html .= "<option value=\"ol\">ol</option>"; $html .= "<option value=\"ul\">ul</option>"; $html .= "<option value=\"table\">table</option>"; $html .= "<option value=\"broadtable\">broadtable</option>"; $html .= "<option value=\"count\">count</option>"; $html .= "<option value=\"ofc-pie\">ofc-pie</option>"; $html .= "<option value=\"ofc-bar\">ofc-bar</option>"; $html .= "<option value=\"ofc-bar-3d\">ofc-bar-3d</option>"; $html .= "<option value=\"ofc-line\">ofc-line</option>"; $html .= "<option value=\"sum\">sum</option>"; $html .= "<option value=\"average\">average</option>"; $html .= "<option value=\"min\">min</option>"; $html .= "<option value=\"max\">max</option>"; $html .= "<option value=\"simpletable\">simpletable</option>"; $html .= "<option value=\"template\">template</option>"; $html .= "<option value=\"tixml\">tixml</option>"; $html .= "<option value=\"transposed\">transposed</option>"; $html .= "<option value=\"csv\">csv</option>"; $html .= "</select>"; $html .= "</p>"; //sorting $html .= '<p>' . wfMsg('smw_wwsu_sort'); $html .= '<input id="step4-sort-checkbox" type="checkbox" onchange="useWSSpecial.displaySortDetails()"/>'; $html .= '<span id="step4-sort-details" style="display: none">'; $html .= '<span class="step4-format-labels">' . wfMsg('smw_wwsu_sort_by') . '</span>'; $html .= '<select id="step4-sort-column"></select>'; $html .= '<span class="step4-format-labels">' . wfMsg('smw_wwsu_sort_order') . '</span>'; $html .= '<select id="step4-sort-order">'; $html .= "<option value=\"" . wfMsg('smw_wwsu_sort_order_asc') . "\">" . wfMsg('smw_wwsu_sort_order_asc') . "</option>"; $html .= "<option value=\"" . wfMsg('smw_wwsu_sort_order_desc') . "\">" . wfMsg('smw_wwsu_sort_order_desc') . "</option>"; $html .= '</select>'; $html .= "</sption>"; $html .= '</p>'; //template $html .= "<p id=\"step4-template-container\">Template: "; $html .= "<input class=\"wickEnabled\" constraints = \"namespace: " . NS_TEMPLATE . "\" id=\"step4-template\"></input> "; $html .= "</p>"; //limit global $smwgQMaxInlineLimit; $html .= '<p>' . wfMsg('smw_wwsu_limit'); $html .= '<input id="step4-limit" value="' . $smwgQMaxInlineLimit . '" size="3"/>'; $html .= '<span class="step4-format-labels">' . wfMsg('smw_wwsu_offset') . '</span>'; $html .= '<input id="step4-offset" value="0" size="3"/>'; $html .= '</p>'; $html .= "<div id=\"step4-help\" class=\"WSHLPMSG\" style=\"display:none\">" . wfMsg("smw_wsuse_s4-help") . "</div>"; $html .= "<br/>"; $html .= "<span id=\"step4-go\" class=\"OKButton\">"; if (defined('LOD_LINKEDDATA_VERSION')) { $s4OnClick = 'useWSSpecial.processStep6()'; } else { $s4OnClick = 'useWSSpecial.processStep4()'; } $html .= "<input type=\"button\" class=\"OKButton\" id=\"step4-go-img\" value=\"" . wfMsg("smw_wsgui_nextbutton") . "\" onclick=\"" . $s4OnClick . "\">"; $html .= "</span>"; $html .= "</div>"; //step 4.5 aka 6 Triplification if (defined('LOD_LINKEDDATA_VERSION')) { $html .= "<div id=\"step6\" class=\"StepDiv\" style=\"display: none\">"; $html .= "<br>"; $html .= "<p class=\"step-headline\">" . wfMsg('smw_wwsu_menue-s6'); $html .= "<img id=\"step6-help-img\" title=\"" . wfMsg("smw_wws_help-button-tooltip") . "\" class=\"help-image\" onclick=\"useWSSpecial.displayHelp(6)\" src=\"" . $smwgDIScriptPath . "/skins/webservices/help.gif\"></img>"; $html .= "</p>"; //$html .= '<p id="step6-missing-subjects">'.wfMsg('smw_wwsu_triplify_impossible').'</p>'; $html .= '<span id="step6-triplification-container">'; $html .= "<p>" . wfMsg('smw_wwsu_triplify'); $html .= "<input type=\"checkbox\" id=\"step6-triplify\" selected=\"false\"/>"; $html .= "</p>"; $html .= "<p>" . wfMsg('smw_wwsu_triplify_subject_display'); $html .= "<input type=\"checkbox\" id=\"step6-display-subjects\" selected=\"false\" onchange=\"useWSSpecial.displayTriplificationSubjectAlias()\"/>"; $html .= '<span id="step6-subject-alias-container" style="display: none">'; $html .= '<span>' . wfMsg('smw_wwsu_triplify_subject_alias') . '</span>'; $html .= "<input id=\"step6-subject-alias\" value=\"" . wfMsg('smw_wwsu_triplify_subject_alias_value') . "\"></input> "; $html .= "</span>"; $html .= "</p>"; $html .= "</span>"; $html .= "<div id=\"step6-help\" class=\"WSHLPMSG\" style=\"display:none\">" . wfMsg("smw_wsuse_s6-help") . "</div>"; $html .= "<br/>"; $html .= "<span id=\"step6-go\" class=\"OKButton\">"; $html .= "<input type=\"button\" class=\"OKButton\" id=\"step6-go-img\" value=\"" . wfMsg("smw_wsgui_nextbutton") . "\" onclick=\"useWSSpecial.processStep4()\">"; $html .= "</span>"; $html .= "</div>"; } //step 5 $html .= "<br>"; $html .= "<div id=\"step5\" class=\"StepDiv\" style=\"display: none\">"; $html .= "<p class=\"step-headline\">" . wfMsg('smw_wwsu_menue-s5'); $html .= "<img id=\"step5-help-img\" class=\"help-image\" onclick=\"useWSSpecial.displayHelp(5)\" title=\"" . wfMsg("smw_wws_help-button-tooltip") . "\" src=\"" . $smwgDIScriptPath . "/skins/webservices/help.gif\"></img>"; $html .= "</p>"; $html .= "<p>"; $html .= "<span id=\"step5-preview-button\"><input type=\"button\" onclick=\"useWSSpecial.getPreview()\" value=\"" . wfMsg('smw_wwsu_displaypreview') . "\" id=\"step5-preview-button-img\"></input></span>"; $html .= "<input id=\"displayWSButton\" type=\"button\" onclick=\"useWSSpecial.displayWSSyntax()\" value=\"" . wfMsg('smw_wwsu_displaywssyntax') . "\"></input>"; $html .= "<input id=\"copyWSButton\" type=\"button\" onclick=\"useWSSpecial.copyToClipBoard()\" value=\"" . wfMsg('smw_wwsu_copytoclipboard') . "\"></input>"; $html .= "<input type=\"button\" onclick=\"useWSSpecial.addToArticle()\" value=\"" . wfMsg('smw_wwsu_addcall') . "\" id=\"step5-add\" style=\"display: none\"></input>"; $html .= "</p>"; $html .= "<div id=\"step5-help\" class=\"WSHLPMSG\" style=\"display:none\">" . wfMsg("smw_wsuse_s5-help") . "</div>"; $html .= "<div id=\"step5-preview\" style=\"display: none; border-width: 2px; border-style: solid; border-color: #5d5d5d\"></div>"; $html .= "</div>"; $wgOut->addHTML($html); }
/** * this methods constructs the special page webservice repository * */ public function execute($par) { global $wgRequest, $wgOut; $wgOut->setPageTitle("Data Import Repository"); $webTestDebug = $wgRequest->getVal('webTestDebug'); if (!is_null($webTestDebug)) { $webTestDebug = true; } global $wgCookiePrefix; global $wgArticlePath; $gardeningURL = Title::makeTitleSafe(NS_SPECIAL, "Gardening")->getFullURL(); $allowed = false; global $wgUser; $user = $wgUser; if ($user != null) { $groupsOfUser = $user->getGroups(); foreach ($groupsOfUser as $key => $group) { if ($group == SMW_WS_SYSOP) { $allowed = true; } } } $html = ""; $html .= "<table id=\"menue\" class=\"TabContainer\"><tr>"; $html .= "<td id=\"web-service-tab\" class=\"ActiveTab\" onclick=\"webServiceRepSpecial.displayWebServiceTab()\">Web Service definitions</td>"; $html .= "<td></td>"; $html .= "<td id=\"term-import-tab\" class=\"InactiveTab\" onclick=\"webServiceRepSpecial.displayTermImportTab()\" onmouseover=\"webServiceRepSpecial.highlightTab(event)\">Term Import definitions</td>"; $html .= "<td></td></tr></table>"; global $smwgDIIP; // handle web service repository require_once $smwgDIIP . '/specials/WebServices/SMW_WSStorage.php'; $webServices = WSStorage::getDatabase()->getWebServices(); ksort($webServices); $html .= "<span id=\"web-service-tab-content\">"; $html .= "<h2><span class=\"mw-headline\">" . wfMsg('smw_wwsr_intro') . "</span></h2>"; $html .= "<p>" . wfMsg('smw_wwsr_rep_intro') . "</p>"; $html .= '<p><a href="' . Title::makeTitleSafe(NS_SPECIAL, "DefineWebService")->getFullURL() . '">' . wfMsg('smw_wwsr_rep_create_link') . '</a></p>'; if ($allowed) { $html .= "<table id=\"webservicetable\" class=\"smwtable\"><tr><th>" . wfMsg('smw_wwsr_name') . "</th><th>" . wfMsg('smw_wwsr_lastupdate') . "</th><th style=\"text-align: center\">" . wfMsg('smw_wwsr_update_manual') . "</th><th style=\"text-align: center\">" . wfMsg('smw_wwsr_rep_edit') . "</th><th style=\"text-align: center\">" . wfMsg('smw_wwsr_delete') . "</th><th style=\"text-align: center\">" . wfMsg('smw_wwsr_confirm') . "</th></tr>"; } else { $html .= "<table id=\"webservicetable\" class=\"smwtable\"><tr><th>" . wfMsg('smw_wwsr_name') . "</th><th>" . wfMsg('smw_wwsr_lastupdate') . "</th><th style=\"text-align: center\">" . wfMsg('smw_wwsr_rep_edit') . "</th></tr>"; } foreach ($webServices as $ws) { $title = Title::newFromID($ws->getArticleID()); if (!is_null($title)) { $wsUrl = $title->getFullURL(); $wsName = substr($ws->getName(), 11, strlen($ws->getName())); $html .= "<tr id=\"ws-row-" . $ws->getArticleID() . "\"><td><a href=\"" . $wsUrl . "\">" . $wsName . "</a></td>"; $cacheResults = WSStorage::getDatabase()->getResultsFromCache($ws->getArticleID()); $oldestUpdate = ""; if (count($cacheResults) > 0) { $oldestUpdate = $cacheResults[0]["lastUpdate"]; if (strlen($oldestUpdate) > 0) { $oldestUpdate = wfTimestamp(TS_DB, $oldestUpdate); } } $latestUpdate = ""; if (sizeof($cacheResults) > 1) { $latestUpdate = $cacheResults[sizeof($cacheResults) - 1]["lastUpdate"]; if (strlen($latestUpdate) > 0) { $latestUpdate = wfTimestamp(TS_DB, $cacheResults[sizeof($cacheResults) - 1]["lastUpdate"]); if (strlen($oldestUpdate) > 0) { $latestUpdate = " - " . $latestUpdate; } } } $html .= "<td>" . $oldestUpdate . $latestUpdate . "</td>"; if ($allowed) { $wsUpdateBot = new WSUpdateBot(); $html .= "<td style=\"text-align: center\"><button id=\"update" . $ws->getArticleID() . "\" type=\"button\" name=\"update\" onclick=\"webServiceRepSpecial.updateCache('" . $wsUpdateBot->getBotID() . "', 'WS_WSID=" . $ws->getArticleID() . "')\" alt=\"" . wfMsg('smw_wwsr_update') . "\" title=\"" . wfMsg('smw_wwsr_update_tooltip') . "\">" . wfMsg('smw_wwsr_update') . "</button>"; $html .= "<div id=\"updating" . $ws->getArticleID() . "\" style=\"display: none; text-align: center\"><a href=\"" . $gardeningURL . "\">" . wfMsg('smw_wwsr_updating') . "</a></div></td>"; } global $wgArticlePath; if (strpos($wgArticlePath, "?") > 0) { $url = Title::makeTitleSafe(NS_SPECIAL, "DefineWebService")->getFullURL() . "&wwsdId=" . $ws->getArticleID(); } else { $url = Title::makeTitleSafe(NS_SPECIAL, "DefineWebService")->getFullURL() . "?wwsdId=" . $ws->getArticleID(); } $html .= "<td style=\"text-align: center\"><button id=\"edit" . $ws->getArticleID() . "\" type=\"button\" name=\"edit\" onclick=\"window.location.href = '" . $url . "';\" alt=\"" . wfMsg('smw_wwsr_rep_edit') . "\" title=\"" . wfMsg('smw_wwsr_rep_edit_tooltip') . "\">" . wfMsg('smw_wwsr_rep_edit') . "</button>"; if ($allowed) { $html .= "<td style=\"text-align: center\"> <button type=\"button\" onclick=\"webServiceRepSpecial.deleteWWSD(" . $ws->getArticleID() . ")\" alt=\"" . wfMsg('smw_wwsr_delete') . "\" title=\"" . wfMsg('smw_wwsr_delete_tooltip') . "\">" . wfMsg('smw_wwsr_delete') . "</button></td>"; } if ($allowed) { if ($ws->getConfirmationStatus() != "true") { $html .= "<td style=\"text-align: center\" id=\"confirmText" . $ws->getArticleID() . "\"> <button type=\"button\" id=\"confirmButton" . $ws->getArticleID() . "\" onclick=\"webServiceRepSpecial.confirmWWSD(" . $ws->getArticleID() . ")\" alt=\"" . wfMsg('smw_wwsr_confirm') . "\" title=\"" . wfMsg('smw_wwsr_confirm_tooltip') . "\">" . wfMsg('smw_wwsr_confirm') . "</button></td></tr>"; } else { $html .= "<td style=\"text-align: center\" alt=\"" . wfMsg('smw_wwsr_confirm') . "\" title=\"" . wfMsg('smw_wwsr_confirm_tooltip') . "\">" . wfMsg('smw_wwsr_confirmed') . "</td></tr>"; } } else { $html .= "</tr>"; } } } $html .= "</table>"; $html .= "</span>"; //Term Import definition tab $html .= "<span id=\"term-import-tab-content\" style=\"display: none\">"; $html .= "<h2><span class=\"mw-headline\">" . wfMsg('smw_tir_intro') . "</span></h2>"; $html .= "<p>" . wfMsg('smw_tir_rep_intro') . "</p>"; $html .= '<p><a href="' . Title::makeTitleSafe(NS_SPECIAL, "TermImport")->getFullURL() . '">' . wfMsg('smw_tir_rep_create_link') . '</a></p>'; if ($allowed) { $html .= "<table id=\"termimporttable\" width=\"100%\" class=\"smwtable\"><tr><th>" . wfMsg('smw_wwsr_name') . "</th><th>" . wfMsg('smw_wwsr_lastupdate') . "</th><th style=\"text-align: center\">" . wfMsg('smw_wwsr_update_manual') . "</th><th style=\"text-align: center\">" . wfMsg('smw_wwsr_rep_edit') . "</th><th style=\"text-align: center\">" . wfMsg('smw_wwsr_delete') . "</th></tr>"; } else { $html .= "<table id=\"termimporttable\" width=\"100%\" class=\"smwtable\"><tr><th>" . wfMsg('smw_wwsr_name') . "</th><th>" . wfMsg('smw_wwsr_lastupdate') . "</th></tr>"; } $log = SGAGardeningIssuesAccess::getGardeningIssuesAccess(); SMWQueryProcessor::processFunctionParams(array("[[Category:TermImport]]"), $querystring, $params, $printouts); $queryResult = explode("|", SMWQueryProcessor::getResultFromQueryString($querystring, $params, $printouts, SMW_OUTPUT_WIKI)); unset($queryResult[0]); foreach ($queryResult as $tiArticleName) { $tiArticleName = substr($tiArticleName, 0, strpos($tiArticleName, "]]")); $html .= "<tr id=\"ti-row-" . $tiArticleName . "\">"; $tiUrl = Title::newFromText("TermImport:" . $tiArticleName)->getFullURL(); $html .= "<td><a href=\"" . $tiUrl . "\">" . $tiArticleName . "</a></td>"; SMWQueryProcessor::processFunctionParams(array("[[belongsToTermImport::TermImport:" . $tiArticleName . "]]", "?hasImportDate", "limit=1", "sort=hasImportDate", "order=descending", "format=list", "mainlabel=-"), $querystring, $params, $printouts); $queryResult = SMWQueryProcessor::getResultFromQueryString($querystring, $params, $printouts, SMW_OUTPUT_WIKI); // timestamp creation depends on property type (page or date) $queryResult = trim(substr($queryResult, strpos($queryResult, "]]") + 2)); if (strpos($queryResult, "[[:") === 0) { //type page $queryResult = trim(substr($queryResult, strpos($queryResult, "|") + 1)); $queryResult = trim(substr($queryResult, 0, strpos($queryResult, "]"))); } else { //type date $queryResult = trim(substr($queryResult, 0, strpos($queryResult, "["))); } $html .= "<td>" . $queryResult . "</td>"; if ($allowed) { $tiUpdateBot = new TermImportUpdateBot(); $html .= "<td style=\"text-align: center\"><button id=\"update-ti-" . $tiArticleName . "\" \r\n\t\t\t\t\ttype=\"button\" name=\"update-ti\" \r\n\t\t\t\t\tonclick=\"webServiceRepSpecial.updateTermImport('" . $tiArticleName . "')\" alt=\"" . wfMsg('smw_wwsr_update') . "\" title=\"" . wfMsg('smw_wwsr_update_tooltip_ti') . "\">" . wfMsg('smw_wwsr_update') . "</button>"; $html .= "<div id=\"updating-ti-" . $tiArticleName . "\" style=\"display: none; text-align: center\"><a href=\"" . $gardeningURL . "\">" . wfMsg('smw_wwsr_updating') . "</a></div></td>"; global $wgArticlePath; if (strpos($wgArticlePath, "?") > 0) { $url = Title::makeTitleSafe(NS_SPECIAL, "TermImport")->getFullURL() . "&tiname=" . $tiArticleName; } else { $url = Title::makeTitleSafe(NS_SPECIAL, "TermImport")->getFullURL() . "?tiname=" . $tiArticleName; } $html .= "<td style=\"text-align: center\"><button id=\"edit" . $tiArticleName . "\" type=\"button\" name=\"edit\" onclick=\"window.location.href = '" . $url . "';\" alt=\"" . wfMsg('smw_wwsr_rep_edit') . "\" title=\"" . wfMsg('smw_wwsr_rep_edit_tooltip_ti') . "\">" . wfMsg('smw_wwsr_rep_edit') . "</button></td>"; $html .= "<td style=\"text-align: center\"><button type=\"button\" name=\"delete\" onclick=\"webServiceRepSpecial.deleteTermImport('" . $tiArticleName . "')\" alt=\"" . wfMsg('smw_wwsr_delete') . "\" title=\"" . wfMsg('smw_wwsr_rep_delete_tooltip_ti') . "\">" . wfMsg('smw_wwsr_delete') . "</button></td>"; } $html .= "</tr>"; } $html .= "</table>"; $html .= "</span>"; $wgOut->addHTML($html); }
/** * remove this ws from the database * */ public function removeFromDB() { WSStorage::getDatabase()->removeWS($this->getArticleID()); }
/** * this function detects parameter sets that are no longer referred and * web services that are no longer used in this article * * @param string $articleId * * @return boolean true */ public static function detectRemovedWebServiceUsages($articleId) { global $wgsmwRememberedWSUsages, $purgePage; $purgePage = false; $rememberedWSUsages = $wgsmwRememberedWSUsages; if ($rememberedWSUsages != null) { foreach ($rememberedWSUsages as $rememberedWSUsage) { WSStorage::getDatabase()->addWSArticle($rememberedWSUsage[0], $rememberedWSUsage[1], $articleId); } } $oldWSUsages = WSStorage::getDatabase()->getWSsUsedInArticle($articleId); foreach ($oldWSUsages as $oldWSUsage) { $remove = true; if ($rememberedWSUsages != null) { foreach ($rememberedWSUsages as $rememberedWSUsage) { if ($rememberedWSUsage[0] == $oldWSUsage[0] && $rememberedWSUsage[1] == $oldWSUsage[1]) { $remove = false; } } } if ($remove) { WSStorage::getDatabase()->removeWSArticle($oldWSUsage[0], $oldWSUsage[1], $articleId); WebServiceCache::removeWSParameterPair($oldWSUsage[0], $oldWSUsage[1]); $parameterSetIds = WSStorage::getDatabase()->getUsedParameterSetIds($oldWSUsage[1]); if (sizeof($parameterSetIds) == 0) { WSStorage::getDatabase()->removeParameterSet($oldWSUsage[1]); } } } $wgsmwRememberedWSUsages = array(); //deal with triplifying global $wgsmwRememberedWSTriplifications; if (!is_array($wgsmwRememberedWSTriplifications)) { $wgsmwRememberedWSTriplifications = array(); } foreach ($oldWSUsages as $oldWSUsage) { if (!array_key_exists($oldWSUsage[0], $wgsmwRememberedWSTriplifications)) { WSTriplifier::getInstance()->removeWSUsage($oldWSUsage[0], $articleId); } } $wgsmwRememberedWSTriplifications = array(); //eof deal with triplification return true; }
/** * Setup database for Data Import extension. * * @author: Ingo Steinbauer * * Created on: 17.07.2009 */ if (array_key_exists('SERVER_NAME', $_SERVER) && $_SERVER['SERVER_NAME'] != NULL) { echo "Invalid access! A maintenance script MUST NOT accessed from remote."; return; } $mediaWikiLocation = dirname(__FILE__) . '/../../..'; require_once "{$mediaWikiLocation}/maintenance/commandLine.inc"; global $smwgDIIP; $smwgDIIP = "{$mediaWikiLocation}/extensions/DataImport"; $help = array_key_exists("h", $options); $delete = array_key_exists("delete", $options) || array_key_exists("d", $options); if ($help) { echo "\nUsage: php DI_setup.php --h | --d \n"; echo "Started with no parameters installs the database tables."; die; } require_once $smwgDIIP . "/specials/WebServices/SMW_WSStorage.php"; require_once $smwgDIIP . "/specials/Materialization/SMW_MaterializationStorageAccess.php"; if ($delete) { WSStorage::getDatabase()->deleteDatabaseTables(); SMWMaterializationStorageAccess::getDatabase()->deleteDatabaseTables(); } else { WSStorage::getDatabase()->initDatabaseTables(); SMWMaterializationStorageAccess::getDatabase()->setup(true); }
/** * Creates the database tables that are used by the web service extension. * */ public static function initDatabaseTables() { global $smwgDIIP; require_once "{$smwgDIIP}/specials/WebServices/SMW_WSStorage.php"; WSStorage::getDatabase()->initDatabaseTables(); }
/** * this method checks for each cache entry of * a webservice if it has to be deleted * * @param webservice $ws */ private function cleanWSCacheEntries($ws) { $log = SGAGardeningIssuesAccess::getGardeningIssuesAccess(); if ($ws->getSpanOfLife() != "0") { $cacheResults = WSStorage::getDatabase()->getResultsFromCache($ws->getArticleID()); $this->addSubTask(sizeof($cacheResults) + 1); //echo($ws->getArticleID()); $deletedCacheEntries = 0; foreach ($cacheResults as $cacheResult) { if ($ws->doesExpireAfterUpdate() == "false") { if ($cacheResult["lastAccess"]) { if (wfTimestamp(TS_UNIX, $cacheResult["lastAccess"]) < wfTimestamp(TS_UNIX, $cacheResult["lastUpdate"])) { $compareTS = $cacheResult["lastUpdate"]; } else { $compareTS = $cacheResult["lastAccess"]; } } else { $compareTS = $cacheResult["lastUpdate"]; } } else { $compareTS = $cacheResult["lastUpdate"]; } //todo: change to days again if (wfTime() - wfTimestamp(TS_UNIX, $compareTS) > $ws->getSpanOfLife() * 24 * 60 * 60) { WSStorage::getDatabase()->removeWSEntryFromCache($ws->getArticleID(), $cacheResult["paramSetId"]); $deletedCacheEntries += 1; } $this->worked(1); } // echo($ws->getName()."-".$deletedCacheEntries); if ($deletedCacheEntries > 0) { $log->addGardeningIssueAboutValue($this->id, SMW_GARDISSUE__REMOVED_WSCACHE_ENTRIES, Title::newFromText($ws->getName()), $deletedCacheEntries); } } else { $this->addSubTask(1); $this->worked(1); } }