function RenderChemForm($input, $argv) { # add messages $link = false; $wikilink = false; $showthis = $input; $searchfor = $input; if (isset($argv["link"])) { $link = $argv["link"]; } if (isset($argv["wikilink"])) { $wikilink = $argv["wikilink"]; } if (isset($argv["query"])) { $searchfor = $argv["query"]; } if (!$showthis) { $showthis = $searchfor; } $showthis = htmlentities(Sanitizer::StripAllTags($showthis)); # tagstripping $showthis = preg_replace("/[0-9]+/", "<sub>\$0</sub>", $showthis); # All numbers down $showthis = preg_replace("/[\\+\\-]/", "<sup>\$0</sup>", $showthis); # + and - up $showthis = preg_replace("/<\\/sub><sup>/", "", $showthis); # </sub><sup> should not occur $showthis = preg_replace("/<sub>([0-9\\+\\-]+)<\\/sup>/", "<sup>\$1</sup>", $showthis); # and <sub>whatever</sup> to <sup>..</sup> $searchfor = htmlentities(Sanitizer::StripAllTags($searchfor)); if (!($showthis . $searchfor)) { return wfMsg('chemFunctions_ChemFormInputError'); } if ($link) { $title = SpecialPage::getTitleFor('Chemicalsources'); $output = "<a href=\"" . $title->getFullUrl() . "?Formula=" . $searchfor . "\">" . $showthis . "</a>"; } elseif ($wikilink) { $title = Title::makeTitleSafe(NS_MAIN, $searchfor); if ($title) { $revision = Revision::newFromTitle($title); if ($revision) { $output = "<a href=\"" . $title->getFullUrl() . "\">" . $showthis . "</a>"; } else { $output = "<a href=\"" . $title->getFullUrl() . "?action=edit\" class=\"new\">" . $showthis . "</a>"; } } else { $output = wfMsg('chemFunctions_ChemFormInputError'); } } else { $output = $showthis; } return $output; }
public function getNextResults() { $this->wf->ProfileIn(__METHOD__); $this->response->setVal('status', true); $query = $this->request->getVal('query', $this->request->getVal('search')); $query = htmlentities(Sanitizer::StripAllTags($query), ENT_COMPAT, 'UTF-8'); $page = $this->request->getVal('page', 1); $rank = $this->request->getVal('rank', 'default'); $crossWikia = $this->request->getBool('crossWikia'); $hub = false; $isCorporateWiki = !empty($this->wg->EnableWikiaHomePageExt); $isInterWiki = $crossWikia ? true : $isCorporateWiki; $cityId = $isInterWiki ? 0 : $this->wg->CityId; $params = array('page' => $page, 'length' => self::RESULTS_PER_PAGE, 'cityId' => $cityId, 'groupResults' => $isInterWiki, 'rank' => $rank, 'hub' => $hub, 'query' => $query); $searchConfig = F::build('WikiaSearchConfig', array($params)); $results = $this->wikiaSearch->doSearch($searchConfig); $text = $this->app->getView('WikiaSearch', 'WikiaMobileResultList', array('currentPage' => $page, 'isInterWiki' => $isInterWiki, 'relevancyFunctionId' => WikiaSearch::RELEVANCY_FUNCTION_ID, 'results' => $results, 'resultsPerPage' => self::RESULTS_PER_PAGE, 'query' => $query))->render(); $this->response->setVal('text', $text); $this->wf->ProfileOut(__METHOD__); }
/** * Used to store the query from the request as passed by the controller. * We remove any namespaces prefixes, but store the original query under the originalQuery param. * @see WikiaSearchConfigTest::testQueryAndNamespaceMethods * @param string $query * @return WikiaSearchConfig provides fluent interface */ public function setQuery($query) { $query = html_entity_decode(Sanitizer::StripAllTags($query), ENT_COMPAT, 'UTF-8'); $this->params['originalQuery'] = $query; $mwNamespace = F::build('MWNamespace'); $queryNamespace = $mwNamespace->getCanonicalIndex(preg_replace('/^(.*):.*$/', '$1', strtolower($query))); if ($queryNamespace) { $namespaces = $this->getNamespaces(); if (empty($namespaces) || !in_array($queryNamespace, $namespaces)) { $this->params['queryNamespace'] = $queryNamespace; } $query = implode(':', array_slice(explode(':', $query), 1)); } $this->params['query'] = $query; return $this; }