Пример #1
0
 public function run($paramArray, $isAsync, $delay)
 {
     echo "bot started\n";
     if (array_key_exists("WS_WSID", $paramArray) && $paramArray["WS_WSID"] != null) {
         $log = SGAGardeningIssuesAccess::getGardeningIssuesAccess();
         $ws = WebService::newFromID($paramArray["WS_WSID"]);
         $affectedArticles = $this->updateWSResults($ws);
         $this->setNumberOfTasks(2);
     } else {
         $affectedArticles = $this->updateAllWSResults();
     }
     ksort($affectedArticles);
     $affectedArticles = array_flip($affectedArticles);
     echo "\nRefreshing articles: \n";
     foreach ($affectedArticles as $articleId => $dontCare) {
         echo "\t refreshing articleId: " . $articleId . "\n";
         $title = Title::newFromID($articleId);
         $updatejob = new SMWUpdateJob($title);
         $updatejob->run();
     }
     echo "\nbot finished";
     global $smwgDefaultStore;
     if ($smwgDefaultStore == 'SMWTripleStore' || $smwgDefaultStore == 'SMWTripleStoreQuad') {
         define('SMWH_FORCE_TS_UPDATE', 'TRUE');
         smwfGetStore()->initialize(true);
     }
     return '';
 }
Пример #2
0
 /**
  * Generates the headline for the page list and the HTML encoded list of pages which
  * shall be shown.
  */
 protected function getPages()
 {
     wfProfileIn(__METHOD__ . ' (SMW)');
     $r = '';
     global $wgArticlePath;
     $ws = WebService::newFromID($this->getTitle()->getArticleID());
     if ($ws != null) {
         if (strpos($wgArticlePath, "?") > 0) {
             $url = Title::makeTitleSafe(NS_SPECIAL, "DefineWebService")->getFullURL() . "&wwsdId=" . $this->getTitle()->getArticleID();
         } else {
             $url = Title::makeTitleSafe(NS_SPECIAL, "DefineWebService")->getFullURL() . "?wwsdId=" . $this->getTitle()->getArticleID();
         }
         $r .= '<h4><span class="mw-headline"><a href="' . $url . '">' . wfMsg('smw_wws_edit_in_gui') . '</a></span></h4>';
     }
     $ti = htmlspecialchars($this->mTitle->getText());
     // list articles
     $nav = $this->myGetNavigationLinks('WWSArticleResults', $this->mArticles, $this->mFromArticle, $this->mUntilArticle, 'fromarticle', 'untilarticle');
     $r .= '<a name="WWSArticleResults"></a>' . "<div id=\"mw-pages\">\n";
     $r .= '<h4><span class="mw-headline">' . wfMsg('smw_wws_articles_header', $ti) . "</h4>\n";
     $r .= wfMsg('smw_wws_articlecount', min($this->limit, count($this->mArticles))) . "\n";
     $r .= $nav;
     $r .= $this->myShortList($this->mArticles, $this->articles_start_char, $this->mUntilArticle) . "\n</div>";
     $r .= $nav;
     wfProfileOut(__METHOD__ . ' (SMW)');
     return $r;
 }
Пример #3
0
 /**
  * Parses the {{ ws: }} syntax and returns the resulting wikitext
  *
  * @param $parser : a parser object if called by mediawiki or
  * 					a string if called by the preview function
  * @param $preview : boolean
  * @return string
  * 		the rendered wikitext
  */
 public static function processCall(&$parser, $parameters, $preview = false, $smwQueryMode = false, $rawResults = false)
 {
     global $wgsmwRememberedWSUsages, $purgePage, $wgsmwRememberedWSTriplifications;
     $purgePage = true;
     //parse web service call parameters
     list($wsParameters, $wsReturnValues, $configArgs) = self::parseWSCallParameters($parameters);
     $configArgs['webservice'] = trim($parameters[1]);
     $wsTriplify = array_key_exists('triplify', $configArgs) ? true : false;
     $displayTripleSubjects = array_key_exists('displaytriplesubjects', $configArgs) ? $configArgs['displaytriplesubjects'] : false;
     // the name of the ws must be the first parameter of the parser function
     $wsName = trim($parameters[1]);
     $ws = WebService::newFromName($wsName);
     if (!$ws) {
         $errorMSG = wfMsg('smw_wsuse_wwsd_not_existing', $wsName);
         return self::formatWSResult($errorMSG, $configArgs, $wsParameters, $wsReturnValues, $smwQueryMode);
     }
     $wsId = $ws->getArticleID();
     //get article id
     if (!$preview && !$smwQueryMode) {
         $articleId = $parser->getTitle()->getArticleID();
     } else {
         $articleId = 0;
         if (strlen($parser) > 0) {
             $t = Title::makeTitleSafe(0, $parser);
             $articleId = $t->getArticleID();
         }
     }
     $allAliases = WebService::newFromID($wsId)->getAllResultPartAliases();
     //process triplification instructions
     if ($wsTriplify || $displayTripleSubjects) {
         if (!defined('LOD_LINKEDDATA_VERSION') && $wsTriplify) {
             //ld extension not installed
             $errorMSG = wfMsg('smw_wsuse_missing_ld_extension');
             return self::formatWSResult($errorMSG, $configArgs, $wsParameters, $wsReturnValues, $smwQueryMode);
         }
         //get subject creation pattern from wwsd if necessary
         $triplificationSubject = $ws->getTriplificationSubject();
         if (strlen($triplificationSubject) == 0) {
             //no subject creation pattern defind
             $errorMSG = wfMsg('smw_wsuse_missing_triplification_subject');
             return self::formatWSResult($errorMSG, $configArgs, $wsParameters, $wsReturnValues, $smwQueryMode);
         }
         //add triplification subject aliases to result parts if necessary and
         //remember those special result parts
         $subjectCreationPatternParts = array();
         foreach ($allAliases as $alias => $dc) {
             if (strpos(strtolower($triplificationSubject), "?" . $alias . "?") !== false) {
                 $alias = explode('.', $alias);
                 if (!array_key_exists($alias[0] . "." . $alias[1], $wsReturnValues) && !array_key_exists($alias[0], $wsReturnValues)) {
                     $wsReturnValues[$alias[0] . "." . $alias[1]] = "";
                     $subjectCreationPatternParts[] = $alias[1];
                 }
             }
         }
     }
     //validate ws call parameters
     list($messages, $wsParameters) = self::validateWSUsage($wsId, $wsReturnValues, $wsParameters);
     if (sizeof($messages) > 0) {
         $errorMSG = implode(' ', $messages);
         return self::formatWSResult($errorMSG, $configArgs, $wsParameters, $wsReturnValues, $smwQueryMode);
     }
     $parameterSetId = WSStorage::getDatabase()->storeParameterset($wsParameters);
     //check if parameter set id must be removed
     //afterwards if preview or smwquerymode
     $removeParameterSetForRemove = true;
     if (strpos($parameterSetId, "#") === 0) {
         $parameterSetId = substr($parameterSetId, 1);
         $removeParameterSetForRemove = false;
     }
     $wsResults = self::getWSResultsFromCache($ws, $wsReturnValues, $parameterSetId);
     if (is_string($wsResults)) {
         //todo: remove parameter sets and so on
         $wsResults = self::formatWSResult($wsResults, $configArgs, $wsParameters, $wsReturnValues, $smwQueryMode);
     } else {
         if ($rawResults) {
             return $wsResults;
         }
         //process triplification instructions
         if (($wsTriplify || $displayTripleSubjects) && !is_string($wsResults)) {
             $wsResultsForTriplification = $wsResults;
             foreach ($subjectCreationPatternParts as $p) {
                 if (array_key_exists(strtolower($p), $wsResults)) {
                     unset($wsResults[strtolower($p)]);
                     unset($wsReturnValues['result.' . $p]);
                 }
             }
             //only triplify if this is not for the preview
             if (!$preview && !$smwQueryMode || $displayTripleSubjects) {
                 if (!is_array($wgsmwRememberedWSTriplifications)) {
                     $wgsmwRememberedWSTriplifications = array();
                 }
                 $dropGraph = false;
                 if (!array_key_exists($wsId, $wgsmwRememberedWSTriplifications)) {
                     $wgsmwRememberedWSTriplifications[$wsId] = null;
                     $dropGraph = true;
                 }
                 $tmp = $wsResultsForTriplification;
                 $wsResultsForTriplification = array();
                 foreach ($allAliases as $alias => $dontCare) {
                     $alias = substr($alias, strpos($alias, '.') + 1);
                     if (array_key_exists(strtolower($alias), $tmp)) {
                         $results = $tmp[strtolower(strtolower($alias))];
                         $wsResultsForTriplification[$alias] = $results;
                     }
                 }
                 $subjects[$displayTripleSubjects] = WSTriplifier::getInstance()->triplify($wsResultsForTriplification, $triplificationSubject, $wsId, $wsTriplify && !$preview && !$smwQueryMode, $articleId, $dropGraph, $subjectCreationPatternParts, $parser);
             }
         }
         if ($displayTripleSubjects) {
             $wsResults = array_merge($subjects, $wsResults);
             $wsReturnValues = array_merge(array('result.' . $displayTripleSubjects => ''), $wsReturnValues);
         }
         foreach ($allAliases as $alias => $dontCare) {
             if (array_key_exists(strtolower($alias), $wsReturnValues) && strlen($wsReturnValues[strtolower($alias)]) == 0) {
                 $wsReturnValues[strtolower($alias)] = substr($alias, strpos($alias, '.') + 1);
             }
         }
         $wsResults = self::formatWSResult($wsResults, $configArgs, $wsParameters, $wsReturnValues, $smwQueryMode);
     }
     //handle cache issues for previews
     if (!$preview && !$smwQueryMode) {
         $tmp = array_keys($wsReturnValues);
         $wgsmwRememberedWSUsages[] = array($wsId, $parameterSetId, "", array_pop($tmp));
     } else {
         WebServiceCache::removeWSParameterPair($wsId, $parameterSetId);
         if ($removeParameterSetForRemove) {
             WSStorage::getDatabase()->removeParameterSet($parameterSetId);
         }
     }
     if ($preview) {
         global $wgParser;
         $t = Title::makeTitleSafe(0, $parser);
         $parser = $wgParser;
         $popts = new ParserOptions();
         $parser->startExternalParse($t, $popts, Parser::OT_HTML);
         $wsResults = $parser->internalParse($wsResults);
         $wsResults = $parser->doBlockLevels($wsResults, true);
         return $wsResults;
     }
     if (!$smwQueryMode) {
         //todo: Is this still necessary?
         $wsResults = $parser->replaceVariables($wsResults);
     }
     return $wsResults;
 }
 /**
  * This method constructs the special page for defining webservices
  *
  */
 public function execute($par)
 {
     global $wgRequest, $wgOut;
     $wgOut->setPageTitle(wfMsg("definewebservice"));
     global $smwgDIIP, $smwgDIScriptPath;
     $wwsdId = $wgRequest->getVal('wwsdId');
     $editwwsd = false;
     if (!is_null($wwsdId)) {
         $editwwsd = true;
         $wwsd = WebService::newFromID($wwsdId);
     }
     $html = "";
     //ac needs to know property ns id
     $html .= '<span style="display: none" id="di_ns_id">' . SMW_NS_PROPERTY . '</span>';
     //0. menue
     $html .= "<div id=\"menue\">";
     $fClass = " class=\"ActualMenueStep\" ";
     $rClass = " class=\"TodoMenueStep\" ";
     if ($editwwsd) {
         $fClass = " class=\"DoneMenueStep\" ";
         $rClass = " class=\"DoneMenueStep\" ";
     }
     $html .= "<div id=\"breadcrumb-menue\" class=\"BreadCrumpContainer\">";
     $html .= "<span id=\"menue-step1\" " . $fClass . ">" . wfMsg("smw_wws_s1-menue") . "</span><span class=\"HeadlineDelimiter\"></span>";
     $html .= "<span id=\"menue-step2\" " . $rClass . ">" . wfMsg("smw_wws_s2-menue") . "</span><span class=\"HeadlineDelimiter\" id=\"menue-step2-delimiter\"></span>";
     $html .= "<span id=\"menue-step3\" " . $rClass . ">" . wfMsg("smw_wws_s3-menue") . "</span><span class=\"HeadlineDelimiter\" id=\"menue-step3-delimiter\"></span>";
     $html .= "<span id=\"menue-step4\"" . $rClass . ">" . wfMsg("smw_wws_s4-menue") . "</span><span class=\"HeadlineDelimiter\"></span>";
     $html .= "<span id=\"menue-step5\"" . $rClass . ">" . wfMsg("smw_wws_s5-menue") . "</span><span class=\"HeadlineDelimiter\"></span>";
     $html .= "<span id=\"menue-step6\"" . $rClass . ">" . wfMsg("smw_wws_s6-menue") . "</span>";
     $html .= "</div></div>";
     $visible = "display:none";
     $showButton = "";
     $soap = "";
     $rest = " checked=\"true\" ";
     $ld = "";
     $uri = "";
     $authVisibility = " display:none ";
     $auth = "";
     $noauth = " checked=\"true\" ";
     $username = "";
     $password = "";
     $method = "";
     $subjectCreationPattern = "";
     $subjectCreationPatternVisibility = "none";
     $subjectCreationCheckboxChecked = '';
     $displayOnce = "checked=\"true\"";
     $displayMax = "";
     $displayMinutes = "";
     $queryOnce = "checked=\"true\"";
     $queryMax = "";
     $queryMinutes = "";
     $delayValue = "";
     $spanOfLife = "";
     $expires = "";
     $expiresno = " checked=\"true\" ";
     $name = "";
     if ($editwwsd) {
         $visible = "";
         $showButton = "display: none";
         if (strtolower($wwsd->getProtocol()) == "soap") {
             $soap = " checked=\"true\" ";
             $rest = "";
         } else {
             if (strtolower($wwsd->getProtocol()) == "linkeddata") {
                 $ld = " checked=\"true\" ";
                 $rest = "";
             }
         }
         $uri = $wwsd->getURI();
         $username = $wwsd->getAuthenticationLogin();
         if (strlen($username) > 0) {
             $auth = " checked=\"true\" ";
             $noauth = "";
             $authVisibility = "";
         }
         $password = $wwsd->getAuthenticationPassword();
         $method = "<option>" . $wwsd->getMethod() . "</option>";
         $ts = $wwsd->getTriplificationSubject();
         if (strlen($ts) > 0) {
             $subjectCreationPattern = $ts;
             $subjectCreationPatternVisibility = "";
             $subjectCreationCheckboxChecked = ' checked="true" ';
         }
         if ($wwsd->getDisplayPolicy() > 0) {
             $displayOnce = "";
             $displayMax = "checked=\"true\"";
             $displayMinutes = " value=\"" . $wwsd->getDisplayPolicy() . "\"";
         }
         if ($wwsd->getQueryPolicy() > 0) {
             $queryOnce = "";
             $queryMax = "checked=\"true\"";
             $queryMinutes = " value=\"" . $wwsd->getQueryPolicy() . "\"";
         }
         if ($wwsd->getUpdateDelay() > 0) {
             $delayValue = " value=\"" . $wwsd->getUpdateDelay() . "\"";
         }
         if ($wwsd->getSpanOfLife() > 0) {
             $spanOfLife = "value=\"" . $wwsd->getSpanOfLife() . "\"";
         }
         if ($wwsd->doesExpireAfterUpdate()) {
             $expires = " checked=\"true\" ";
             $expiresno = "";
         }
         $name = "value=\"" . substr($wwsd->getName(), 11) . "\"";
     }
     // 1. Specify URI
     $html .= "<br>";
     $html .= "<div id=\"step1\" class=\"StepDiv\" style=\"display: block\">";
     $html .= "<p id=\"step1-head\" class=\"step-headline\">" . wfMsg("smw_wws_s1-intro");
     $html .= "<img id=\"step1-help-img\" title=\"" . wfMsg("smw_wws_help-button-tooltip") . "\" class=\"help-image\" onclick=\"webServiceSpecial.displayHelp(1)\" src=\"" . $smwgDIScriptPath . "/skins/webservices/help.gif\"></img>";
     $html .= "</p>";
     $html .= "<div>" . wfMsg("smw_wws_spec_protocol");
     $html .= "<input id=\"step1-protocol-rest\" " . $rest . " type=\"radio\" name=\"step1-protocol\" value=\"rest\" onclick=\"webServiceSpecial.updateBreadCrump(event)\">REST</input>";
     $html .= "<input id=\"step1-protocol-ld\" " . $ld . " type=\"radio\" name=\"step1-protocol\" value=\"ld\" onclick=\"webServiceSpecial.updateBreadCrump(event)\">LinkedData</input>";
     $html .= "<input id=\"step1-protocol-soap\" " . $soap . "type=\"radio\" name=\"step1-protocol\" value=\"soap\" onclick=\"webServiceSpecial.updateBreadCrump(event)\">SOAP</input></div>";
     $html .= "<div>" . wfMsg("smw_wws_s1-uri");
     $html .= "<input id=\"step1-uri\" type=\"text\" onkeypress=\"webServiceSpecial.checkEnterKey(event, 'step1')\" size=\"100\" maxlength=\"500\" value=\"" . $uri . "\"/></div>";
     $html .= "<div>" . wfMsg('smw_wws_spec_auth');
     $html .= "<input id=\"step1-auth-yes\" " . $auth . " onfocus=\"webServiceSpecial.showAuthenticationBox('Yes')\" type=\"radio\" name=\"step1-auth\" value=\"yes\">" . wfMsg('smw_wws_yes') . "</input>";
     $html .= "<input id=\"step1-auth-no\" " . $noauth . " onfocus=\"webServiceSpecial.showAuthenticationBox('no')\" type=\"radio\" name=\"step1-auth\" value=\"no\">" . wfMsg('smw_wws_no') . "</input></div>";
     $html .= "<span id=\"step1-auth-box\" style=\"" . $authVisibility . "\">";
     $html .= wfMsg('smw_wws_username');
     $html .= "<input id=\"step1-username\" type=\"text\" size=\"30\" maxlength=\"100\" value=\"" . $username . "\"/>";
     $html .= wfMsg('smw_wws_password');
     $html .= "<input id=\"step1-password\" type=\"password\" size=\"30\" maxlength=\"100\" value=\"" . $password . "\"/>";
     $html .= "</span>";
     $html .= "<div style=\"display:none\" class=\"WSHLPMSG\" id=\"step1-help\" >" . wfMsg("smw_wws_s1-help") . "</div>";
     $html .= "<div id=\"step1-go\" class=\"OKButton\">";
     $html .= "<input type=\"button\" class=\"OKButton\" id=\"step1-go-img\" value=\"" . wfMsg("smw_wsgui_nextbutton") . "\" onclick=\"webServiceSpecial.processStep1()\" style=\"" . $showButton . "\">";
     $html .= "</div>";
     $html .= "</div>";
     //2. Specify method
     $html .= "<div id=\"step2\" class=\"StepDiv\" style=\"" . $visible . "\">";
     $html .= "<p class=\"step-headline\">" . wfMsg("smw_wws_s2-intro");
     $html .= "<img id=\"step2-help-img\" title=\"" . wfMsg("smw_wws_help-button-tooltip") . "\" class=\"help-image\" onclick=\"webServiceSpecial.displayHelp(2)\" src=\"" . $smwgDIScriptPath . "/skins/webservices/help.gif\"></img>";
     $html .= "</p>";
     $html .= "<div>" . wfMsg("smw_wws_s2-method");
     $html .= "<select id=\"step2-methods\" size=\"1\">";
     $html .= $method;
     $html .= "</select></div>";
     $html .= "<div id=\"step2-help\" class=\"WSHLPMSG\" style=\"display:none\">" . wfMsg("smw_wws_s2-help") . "</div>";
     $html .= "<div id=\"step2-rest-help\" style=\"display:none\">" . wfMsg("smw_wws_s2-REST-help") . "</div>";
     $html .= "<div id=\"step2-go\" class=\"OKButton\">";
     $html .= "<input type=\"button\" class=\"OKButton\" id=\"step2-go-img\" value=\"" . wfMsg("smw_wsgui_nextbutton") . "\" style=\"" . $showButton . "\" onclick=\"webServiceSpecial.processStep2()\">";
     $html .= "</div>";
     $html .= "</div>";
     //3. Define Parameters
     $html .= "<div id=\"step3\" class=\"StepDiv\" style=\"" . $visible . "\">";
     $html .= "<p class=\"step-headline\">" . wfMsg("smw_wws_s3-intro");
     $html .= "<img id=\"step3-help-img\" title=\"" . wfMsg("smw_wws_help-button-tooltip") . "\" class=\"help-image\" onclick=\"webServiceSpecial.displayHelp(3)\" src=\"" . $smwgDIScriptPath . "/skins/webservices/help.gif\"></img>";
     $html .= "</p>";
     $html .= "<div id=\"step3-duplicates\" style=\"display:none\"><img src=\"" . $smwgDIScriptPath . "/skins/webservices/warning.png\"></img>";
     $html .= wfMsg("smw_wws_duplicate");
     $html .= "</div>";
     $html .= "<div id=\"step3-rest-intro\" style=\"display:none\"></div>";
     $html .= "<table id=\"step3-parameters\"><tr><th>" . wfMsg('smw_wws_path') . "</th><th>" . wfMsg('smw_wws_use') . "<span><input title=\"" . wfMsg("smw_wws_selectall-tooltip") . "\" type=\"checkbox\" id=\"step3-use\"/></span></th><th>" . wfMsg('smw_wws_alias') . "<span class=\"alias-generate\"><img title=\"" . wfMsg("smw_wws_autogenerate-alias-tooltip-parameter") . "\" id=\"step-3-alias-generate-button\" src=\"" . $smwgDIScriptPath . "/skins/webservices/Pencil_grey.png\"></img></span></th><th>" . wfMsg('smw_wws_optional') . "</th><th>" . wfMsg('smw_wws_defaultvalue') . "</th><th></th></tr></table>";
     $html .= '<a id="step3-add-rest-parameter" style="display: none" href="javascript:webServiceSpecial.appendRESTParameter()">' . wfMsg('smw_wws_s3_add_another_parameter') . '</a>';
     $html .= "<div id=\"step3-help\" class=\"WSHLPMSG\" style=\"display:none\">" . wfMsg("smw_wws_s3-help", $smwgDIScriptPath . "/skins/webservices/Pencil_go.png") . "</div>";
     $html .= "<div id=\"step3-rest-help\" class=\"WSHLPMSG\" style=\"display:none\">" . wfMsg("smw_wws_s3-REST-help") . "</div>";
     $html .= "<div id=\"step3-go\" class=\"OKButton\">";
     $html .= "<input type=\"button\" class=\"OKButton\" id=\"step3-go-img\" style=\"" . $showButton . "\" value=\"" . wfMsg("smw_wsgui_nextbutton") . "\" onclick=\"webServiceSpecial.processStep3()\">";
     $html .= "</div>";
     $html .= "</div>";
     // 4. Define Results
     $html .= "<div id=\"step4\" class=\"StepDiv\" style=\"" . $visible . "\">";
     $html .= "<p class=\"step-headline\">" . wfMsg("smw_wws_s4-intro");
     $html .= "<img id=\"step4-help-img\" title=\"" . wfMsg("smw_wws_help-button-tooltip") . "\" class=\"help-image\" onclick=\"webServiceSpecial.displayHelp(4)\" src=\"" . $smwgDIScriptPath . "/skins/webservices/help.gif\"></img>";
     $html .= "</p>";
     $html .= "<div id=\"step4-duplicates\" style=\"display:none\">";
     $html .= wfMsg("smw_wws_duplicate");
     $html .= "</div>";
     $html .= "<div id=\"step4-rest-intro\" style=\"display:none\"></div>";
     $html .= "<table id=\"step4-results\"><tr><th>" . wfMsg('smw_wws_path') . "</th><th>" . wfMsg('smw_wws_use') . "<span onclick=\"webServiceSpecial.useResults()\"><input title=\"" . wfMsg("smw_wws_selectall-tooltip") . "\" type=\"checkbox\" id=\"step4-use\"/></span></th><th>" . wfMsg('smw_wws_alias') . "<span class=\"alias-generate\" onclick=\"webServiceSpecial.generateResultAliases(true)\"><img id=\"step-4-alias-generate-button\" title=\"" . wfMsg("smw_wws_autogenerate-alias-tooltip-resultpart") . "\" src=\"" . $smwgDIScriptPath . "/skins/webservices/Pencil_grey.png\"></img></span></th><th>" . wfMsg('smw_wws_format') . "</th><th>" . wfMsg('smw_wws_path') . "</th><th></th></tr></table>";
     $html .= '<a id="step4-add-rest-result-part" style="display: none" href="javascript:webServiceSpecial.appendRESTResultPart()">' . wfMsg('smw_wws_s4_add_rest_result_part') . '</a>';
     //Add button for displaying the namespace prefix table
     $html .= '<div id="step4-nss-header" style="display: none; cursor: pointer">';
     $html .= '<img id="step4-display-nss" src="' . $smwgDIScriptPath . '/skins/webservices/right.png"></img>';
     $html .= '<span>' . wfMsg('smw_wws_add_prefixes') . '</span>';
     $html .= '</div>';
     //Add table for defining namespace prefixes
     $html .= "<table id=\"step4-nss\" style=\"padding-top:20px; display: none\"><tr><th>" . wfMsg('smw_wws_nss_prefix') . "</th><th>" . wfMsg('smw_wws_nss_url') . "</th><th></th></tr></table>";
     $html .= '<a id="step4-add-nsp" style="display: none" href="javascript:webServiceSpecial.appendNSPrefix()">' . wfMsg('smw_wws_s4_add_ns_prefix') . '</a>';
     //for triplification
     $displayTriplificationContainer = ' style="display: none" ';
     if (defined('LOD_LINKEDDATA_VERSION')) {
         $displayTriplificationContainer = '';
     }
     $html .= '<table id="step4-enable-triplification" ' . $displayTriplificationContainer . '>';
     $html .= '<tr>';
     $html .= '<td onclick="webServiceSpecial.displaySubjectCreationPattern()"><input id="step4-enable-triplification-checkbox" type="checkbox" ' . $subjectCreationCheckboxChecked . '/></td>';
     $html .= '<td><span>' . wfMsg('smw_wws_enable_triplification') . '</span></td>';
     $html .= '<td></td>';
     $html .= "</tr>";
     $triplificationDetailsVisible = strpos($subjectCreationCheckboxChecked, 'true') ? '' : ' style="display: none" ';
     $html .= '<tr id="step4-enable-triplification-details" ' . $triplificationDetailsVisible . '>';
     $html .= '<td/>';
     $html .= '<td id="step4-enable-triplification-scp-label"><span>' . wfMsg('smw_wws_enable_triplification-intro') . '</span></td>';
     $html .= '<td>';
     $html .= '<textarea id="step4-enable-triplification-input" rows="3" cols="64" onblur="webServiceSpecial.setSubjectCreationPatternCursorPos()" value="' . $subjectCreationPattern . '">' . $subjectCreationPattern . '</textarea><br/>';
     $html .= '<a id="step4-add-alias-to-input" href="javascript:void(0)" onclick="webServiceSpecial.initSubjectCreationPatternAliasClick()">' . wfMsg('smw_wws_enable_triplification-scp-add') . '</a><br/>';
     $html .= '<span id="step4-add-alias-to-input-stop-text" style="display: none">' . wfMsg('smw_wws_enable_triplification-scp-stop-add') . '</span>';
     $html .= '<span id="step4-add-alias-to-input-note" style="display:none">' . wfMsg('smw_wws_enable_triplification-scp-add-note') . '</span>';
     $html .= '</td>';
     $html .= "</tr>";
     $html .= '</table>';
     $triplificationHelp = "";
     if (defined('LOD_LINKEDDATA_VERSION')) {
         $triplificationHelp = wfMsg("smw_wws_s4-help-triplification");
     }
     $html .= "<div id=\"step4-help\" class=\"WSHLPMSG\" style=\"display:none\">" . wfMsg("smw_wws_s4-help") . $triplificationHelp . "</div>";
     $html .= "<div id=\"step4-rest-help\" class=\"WSHLPMSG\" style=\"display:none\">" . wfMsg("smw_wws_s4-REST-help") . $triplificationHelp . "</div>";
     $html .= "<div id=\"step4-ld-help\" class=\"WSHLPMSG\" style=\"display:none\">" . wfMsg("smw_wws_s4-LD-help") . $triplificationHelp . "</div>";
     $html .= "<div id=\"step4-go\" class=\"OKButton\">";
     $html .= "<input type=\"button\" class=\"OKButton\" id=\"step4-go-img\" style=\"" . $showButton . "\" value=\"" . wfMsg("smw_wsgui_nextbutton") . "\" onclick=\"webServiceSpecial.processStep4()\">";
     $html .= "</div>";
     $html .= "</div>";
     // 5. Define updatae policy
     $html .= "<div id=\"step5\" class=\"StepDiv\" style=\"" . $visible . "\" >";
     $html .= "<p class=\"step-headline\">" . wfMsg("smw_wws_s5-intro");
     $html .= "<img id=\"step5-help-img\" title=\"" . wfMsg("smw_wws_help-button-tooltip") . "\" class=\"help-image\" onclick=\"webServiceSpecial.displayHelp(5)\" src=\"" . $smwgDIScriptPath . "/skins/webservices/help.gif\"></img>";
     $html .= "</p>";
     $html .= "<table id=\"step5-policies\">";
     $html .= "<tr><td><span>Display policy: </span></td>";
     $html .= "<td><input id=\"step5-display-once\" " . $displayOnce . " onfocus=\"webServiceSpecial.selectRadioOnce('step5-display-once')\" type=\"radio\" name=\"step5-display\" value=\"once\">Once</input>";
     $html .= "<span><input id=\"step5-display-max\" " . $displayMax . " type=\"radio\" name=\"step5-display\" value=\"\">Max age</input></span></td>";
     $html .= "<td><input type=\"text\" id=\"step5-display-days\" onfocus=\"webServiceSpecial.selectRadio('step5-display-max')\" size=\"7\" maxlength=\"10\" />";
     $html .= "<span>" . wfMsg('smw_wws_days') . "</span>";
     $html .= "<input type=\"text\" id=\"step5-display-hours\" onfocus=\"webServiceSpecial.selectRadio('step5-display-max')\" size=\"7\" maxlength=\"10\" />";
     $html .= "<span>" . wfMsg('smw_wws_hours') . "</span>";
     $html .= "<input type=\"text\" id=\"step5-display-minutes\" onfocus=\"webServiceSpecial.selectRadio('step5-display-max')\" size=\"7\" maxlength=\"10\" " . $displayMinutes . "/>";
     $html .= "<span>" . wfMsg('smw_wws_minutes') . "</span>";
     $html .= "</td></tr>";
     $html .= "<tr><td><span>Query policy: </span></td>";
     $html .= "<td><input id=\"step5-query-once\" " . $queryOnce . " onfocus=\"webServiceSpecial.selectRadioOnce('step5-query-once')\" type=\"radio\" name=\"step5-query\" value=\"once\">Once</input>";
     $html .= "<span><input id=\"step5-query-max\" " . $queryMax . " type=\"radio\" name=\"step5-query\" value=\"\">Max age</input></span></td>";
     $html .= "<td><input type=\"text\" id=\"step5-query-days\" onfocus=\"webServiceSpecial.selectRadio('step5-query-max')\" size=\"7\" maxlength=\"10\" />";
     $html .= "<span>" . wfMsg('smw_wws_days') . "</span>";
     $html .= "<input type=\"text\" id=\"step5-query-hours\" size=\"7\" onfocus=\"webServiceSpecial.selectRadio('step5-query-max')\" maxlength=\"10\" />";
     $html .= "<span>" . wfMsg('smw_wws_hours') . "</span>";
     $html .= "<input type=\"text\" id=\"step5-query-minutes\" size=\"7\" onfocus=\"webServiceSpecial.selectRadio('step5-query-max')\" maxlength=\"10\" " . $queryMinutes . "/>";
     $html .= "<span>" . wfMsg('smw_wws_minutes') . "</span>";
     $html .= "</td></tr>";
     $html .= "<tr><td></td>";
     $html .= "<td><span> Delay value (" . wfMsg('smw_wws_inseconds') . "): </span></td>";
     $html .= "<td><input type=\"text\" id=\"step5-delay\" size=\"7\" maxlength=\"10\" " . $delayValue . "/>";
     $html .= "</td></tr>";
     $html .= "<tr></tr>";
     $html .= "<tr><td><span> Span of life (" . wfMsg('smw_wws_indays') . "): </span></td>";
     $html .= "<td><input type=\"text\" id=\"step5-spanoflife\" size=\"7\" maxlength=\"10\" " . $spanOfLife . "/></td>";
     $html .= "<td><span> Expires after update: </span>";
     $html .= "<input id=\"step5-expires-yes\" " . $expires . " type=\"radio\" name=\"step5-expires\" value=\"once\">" . wfMsg('smw_wws_yes') . "</input>";
     $html .= "<input id=\"step5-expires-no\" " . $expiresno . " type=\"radio\" name=\"step5-expires\" value=\"\">" . wfMsg('smw_wws_no') . "</input>";
     $html .= "</td></tr></table>";
     $html .= "<div id=\"step5-help\" class=\"WSHLPMSG\" style=\"display:none\">" . wfMsg("smw_wws_s5-help") . "</div>";
     $html .= "<div id=\"step5-go\" class=\"OKButton\">";
     $html .= "<input type=\"button\" class=\"OKButton\" id=\"step5-go-img\" style=\"" . $showButton . "\" value=\"" . wfMsg("smw_wsgui_nextbutton") . "\" onclick=\"webServiceSpecial.processStep5()\">";
     $html .= "</div>";
     $html .= "</div>";
     // 6. Specify name
     $html .= "<div id=\"step6\" class=\"StepDiv\" style=\"" . $visible . "\">";
     $html .= "<p class=\"step-headline\">" . wfMsg("smw_wws_s6-intro");
     $html .= "<img id=\"step6-help-img\" title=\"" . wfMsg("smw_wws_help-button-tooltip") . "\" class=\"help-image\" onclick=\"webServiceSpecial.displayHelp(6)\" src=\"" . $smwgDIScriptPath . "/skins/webservices/help.gif\"></img>";
     $html .= "</p>";
     $html .= wfMsg("smw_wws_s6-name");
     $html .= "<input id=\"step6-name\" type=\"text\" onkeypress=\"webServiceSpecial.checkEnterKey(event, 'step6')\" size=\"50\" maxlength=\"300\" " . $name . "/>";
     $html .= "<div id=\"step6-help\" class=\"WSHLPMSG\" style=\"display:none\">" . wfMsg("smw_wws_s6-help") . "</div>";
     $html .= "<div id=\"step6-go\" class=\"OKButton\">";
     $html .= "<input type=\"button\" class=\"OKButton\" id=\"step6-go-img\" value=\"" . wfMsg("smw_wsgui_savebutton") . "\" onclick=\"webServiceSpecial.processStep6()\">";
     $html .= "</div>";
     $html .= "</div>";
     //7. show #ws-usage
     $html .= "<div id=\"step7\" style=\"display: none\">";
     $html .= "<span>" . wfMsg('smw_wws_yourws') . "\"";
     $html .= "<span id=\"step7-name\"></span>";
     $html .= "\"" . wfMsg('smw_wws_succ_created');
     $url = Title::makeTitleSafe(NS_SPECIAL, "dataimportrepository")->getInternalURL();
     //$html .= "<div id=\"step7-container\"></div>";
     $html .= "<a href=\"" . $url . "\">" . wfMsg('smw_wws_succ_created-3') . "</a>" . wfMsg('smw_wws_succ_created-4') . "</span>";
     //$html .= "<img onclick=\"webServiceSpecial.processStep7()\" src=\"".$smwgDIScriptPath."/skins/webservices/Control_play.png\" class=\"OKButton\"></img>";
     $html .= "<br/><input type=\"button\" class=\"OKButton\" id=\"step7-go-img\" value=\"" . wfMsg('smw_wws_new') . "\" onclick=\"webServiceSpecial.processStep7()\"/>";
     $html .= "</div>";
     //errors
     $html .= "<div id=\"errors\" class=\"StepDiv\" style=\"display: none;\">";
     $html .= "<h2>" . wfMsg('smw_wws_error_headline') . "</h2>";
     $html .= "<div id=\"step1-error\" style=\"display: none\">" . wfMsg("smw_wws_s1-error") . "</div>";
     $html .= "<div id=\"step2a-error\" style=\"display: none\">" . wfMsg("smw_wws_s2a-error") . "</div>";
     $html .= "<div id=\"step2b-error\" style=\"display: none\">" . wfMsg("smw_wws_s2b-error") . "</div>";
     $html .= "<div id=\"step3-error\" style=\"display: none\">" . wfMsg("smw_wws_s3-error") . "</div>";
     $html .= "<div id=\"step4-error\" style=\"display: none\">" . wfMsg("smw_wws_s4-error") . "</div>";
     $html .= "<div id=\"step5-error\" style=\"display: none\">" . wfMsg("smw_wws_s5-error") . "</div>";
     $html .= "<div id=\"step6-error\" style=\"display: none\">" . wfMsg("smw_wws_s6-error") . "</div>";
     $html .= "<div id=\"step6b-error\" style=\"display: none\">" . wfMsg("smw_wws_s6-error2") . "</div>";
     $html .= "<div id=\"step6c-error\" style=\"display: none\">" . wfMsg("smw_wws_s6-error3") . "</div>";
     $html .= "</div>";
     if ($editwwsd) {
         if (strtolower($wwsd->getProtocol()) == "soap") {
             $html .= $this->getMergedParameters($wwsd, false);
             $html .= $this->getMergedParameters($wwsd, true);
         } else {
             if (strtolower($wwsd->getProtocol()) == "rest") {
                 $html .= $this->getRESTMergedParameters($wwsd, false, "rest");
                 $html .= $this->getRESTMergedParameters($wwsd, true, "rest");
             } else {
                 if (strtolower($wwsd->getProtocol()) == "linkeddata") {
                     $html .= $this->getRESTMergedParameters($wwsd, false, "ld");
                     $html .= $this->getRESTMergedParameters($wwsd, true, "ld");
                 }
             }
         }
     }
     $wgOut->addHTML($html);
 }
Пример #5
0
 public static function articleDeleteHook(&$article, &$user, $reason)
 {
     if ($article->getTitle()->getNamespace() != SMW_NS_WEB_SERVICE) {
         return true;
     }
     $ws = WebService::newFromID($article->getID());
     if ($ws) {
         //triplification processing
         global $smwgDIIP;
         require_once $smwgDIIP . "/specials/WebServices/SMW_WSTriplifier.php";
         //deal with triplification
         $articles = WSStorage::getDatabase()->getWSArticles($article->getID(), new SMWRequestOptions());
         WSTriplifier::getInstance()->removeWS($article->getID(), $articles);
         WebServiceCache::removeWS($ws->getArticleID());
         $options = new SMWRequestOptions();
         $pageIds = WSStorage::getDatabase()->getWSArticles($ws->getArticleID(), $options);
         foreach ($pageIds as $articleId) {
             $usedWSs = WSStorage::getDatabase()->getWSsUsedInArticle($articleId);
             foreach ($usedWSs as $usedWS) {
                 if ($usedWS[0] == $ws->getArticleID()) {
                     WSStorage::getDatabase()->removeWSArticle($ws->getArticleID(), $usedWS[1], $articleId);
                     $parameterSetIds = WSStorage::getDatabase()->getUsedParameterSetIds($usedWS[1]);
                     if (sizeof($parameterSetIds) == 0) {
                         WSStorage::getDatabase()->removeParameterSet($usedWS[1]);
                     }
                 }
             }
         }
         $ws->removeFromDB();
     }
     self::$mNewWebService = null;
     self::$mOldWebservice = null;
     return true;
 }