summaryrefslogtreecommitdiff
path: root/www/wiki/extensions/SemanticMediaWiki/src/MediaWiki/Specials/SpecialPropertyLabelSimilarity.php
diff options
context:
space:
mode:
Diffstat (limited to 'www/wiki/extensions/SemanticMediaWiki/src/MediaWiki/Specials/SpecialPropertyLabelSimilarity.php')
-rw-r--r--www/wiki/extensions/SemanticMediaWiki/src/MediaWiki/Specials/SpecialPropertyLabelSimilarity.php86
1 files changed, 86 insertions, 0 deletions
diff --git a/www/wiki/extensions/SemanticMediaWiki/src/MediaWiki/Specials/SpecialPropertyLabelSimilarity.php b/www/wiki/extensions/SemanticMediaWiki/src/MediaWiki/Specials/SpecialPropertyLabelSimilarity.php
new file mode 100644
index 00000000..870eccec
--- /dev/null
+++ b/www/wiki/extensions/SemanticMediaWiki/src/MediaWiki/Specials/SpecialPropertyLabelSimilarity.php
@@ -0,0 +1,86 @@
+<?php
+
+namespace SMW\MediaWiki\Specials;
+
+use SMW\ApplicationFactory;
+use SMW\MediaWiki\Specials\PropertyLabelSimilarity\ContentsBuilder;
+use SMW\SQLStore\Lookup\PropertyLabelSimilarityLookup;
+use SpecialPage;
+
+/**
+ * @license GNU GPL v2+
+ * @since 2.5
+ *
+ * @author mwjames
+ */
+class SpecialPropertyLabelSimilarity extends SpecialPage {
+
+ /**
+ * @codeCoverageIgnore
+ */
+ public function __construct() {
+ parent::__construct( 'PropertyLabelSimilarity' );
+ }
+
+ /**
+ * @see SpecialPage::execute
+ */
+ public function execute( $query ) {
+
+ $this->setHeaders();
+ $output = $this->getOutput();
+ $webRequest = $this->getRequest();
+
+ $applicationFactory = ApplicationFactory::getInstance();
+ $store = $applicationFactory->getStore( '\SMW\SQLStore\SQLStore' );
+
+ $propertyLabelSimilarityLookup = new PropertyLabelSimilarityLookup(
+ $store
+ );
+
+ $propertyLabelSimilarityLookup->setExemptionProperty(
+ $applicationFactory->getSettings()->get( 'smwgSimilarityLookupExemptionProperty' )
+ );
+
+ $htmlFormRenderer = $applicationFactory->newMwCollaboratorFactory()->newHtmlFormRenderer(
+ $this->getContext()->getTitle(),
+ $this->getLanguage()
+ );
+
+ $contentsBuilder = new ContentsBuilder(
+ $propertyLabelSimilarityLookup,
+ $htmlFormRenderer
+ );
+
+ $threshold = (int)$webRequest->getText( 'threshold', 90 );
+ $type = $webRequest->getText( 'type', false );
+
+ $offset = (int)$webRequest->getText( 'offset', 0 );
+ $limit = (int)$webRequest->getText( 'limit', 50 );
+
+ $requestOptions = $applicationFactory->getQueryFactory()->newRequestOptions();
+ $requestOptions->setLimit( $limit );
+ $requestOptions->setOffset( $offset );
+
+ $requestOptions->addExtraCondition(
+ [
+ 'type' => $type,
+ 'threshold' => $threshold
+ ]
+ );
+
+ $output->addHtml(
+ $contentsBuilder->getHtml( $requestOptions )
+ );
+
+ return true;
+ }
+
+ /**
+ * @see SpecialPage::getGroupName
+ */
+ protected function getGroupName() {
+ return 'smw_group';
+ }
+
+}