summaryrefslogtreecommitdiff
path: root/www/wiki/extensions/SemanticResultFormats/SemanticResultFormats.utils.php
diff options
context:
space:
mode:
authorYaco <franco@reevo.org>2020-06-04 11:01:00 -0300
committerYaco <franco@reevo.org>2020-06-04 11:01:00 -0300
commitfc7369835258467bf97eb64f184b93691f9a9fd5 (patch)
treedaabd60089d2dd76d9f5fb416b005fbe159c799d /www/wiki/extensions/SemanticResultFormats/SemanticResultFormats.utils.php
first commit
Diffstat (limited to 'www/wiki/extensions/SemanticResultFormats/SemanticResultFormats.utils.php')
-rw-r--r--www/wiki/extensions/SemanticResultFormats/SemanticResultFormats.utils.php74
1 files changed, 74 insertions, 0 deletions
diff --git a/www/wiki/extensions/SemanticResultFormats/SemanticResultFormats.utils.php b/www/wiki/extensions/SemanticResultFormats/SemanticResultFormats.utils.php
new file mode 100644
index 00000000..0093c000
--- /dev/null
+++ b/www/wiki/extensions/SemanticResultFormats/SemanticResultFormats.utils.php
@@ -0,0 +1,74 @@
+<?php
+
+/**
+ * Common libray of independent functions that are shared among different printers
+ * @licence GNU GPL v2 or later
+ *
+ * @since 1.8
+ *
+ * @author mwjames
+ */
+final class SRFUtils {
+
+ /**
+ * Helper function that generates a html element, representing a
+ * processing/loading image as long as jquery is inactive
+ *
+ * @param boolean $isHtml
+ *
+ * @since 1.8
+ */
+ public static function htmlProcessingElement( $isHtml = true ) {
+ SMWOutputs::requireResource( 'ext.srf' );
+
+ return Html::rawElement(
+ 'div',
+ [ 'class' => 'srf-spinner mw-small-spinner' ],
+ Html::element(
+ 'span',
+ [ 'class' => 'srf-processing-text' ],
+ wfMessage( 'srf-module-loading' )->inContentLanguage()->text()
+ )
+ );
+ }
+
+ /**
+ * Add JavaScript variables to the output
+ *
+ * @since 1.8
+ */
+ public static function addGlobalJSVariables(){
+ $options = [
+ 'srfgScriptPath' => $GLOBALS['srfgScriptPath'],
+ 'srfVersion' => SRF_VERSION
+ ];
+
+ $requireHeadItem = [ 'srf.options' => $options ];
+ SMWOutputs::requireHeadItem( 'srf.options', Skin::makeVariablesScript( $requireHeadItem, false ) );
+ }
+
+ /**
+ * @brief Returns semantic search link for the current query
+ *
+ * Generate a link to access the current ask query
+ *
+ * @since 1.8
+ *
+ * @param string $link
+ *
+ * @return $link
+ */
+ public static function htmlQueryResultLink( $link ) {
+ // Get linker instance
+ $linker = class_exists( 'DummyLinker' ) ? new DummyLinker : new Linker;
+
+ // Set caption
+ $link->setCaption( '[+]' );
+
+ // Set parameters
+ $link->setParameter( '' , 'class' );
+ $link->setParameter( '' , 'searchlabel' );
+ return $link->getText( SMW_OUTPUT_HTML, $linker );
+ }
+
+} \ No newline at end of file