Netbrain has submitted this change and it was merged.

Change subject: Re-added some lost functionality after previous refactor. fixed 
i18n
......................................................................


Re-added some lost functionality after previous refactor.
fixed i18n

Change-Id: I4c6812a272d4aefda0cfd90f90834894e368d79a
---
M SemanticSifter.i18n.php
M src/main/parserfunction/Sift.php
2 files changed, 41 insertions(+), 9 deletions(-)

Approvals:
  Netbrain: Verified; Looks good to me, approved



diff --git a/SemanticSifter.i18n.php b/SemanticSifter.i18n.php
index 8da4f06..0717833 100644
--- a/SemanticSifter.i18n.php
+++ b/SemanticSifter.i18n.php
@@ -26,6 +26,9 @@
        'semanticsifter-button-apply-filter' => 'Button which applies filter.
 {{Identical|Apply filter}}',
        'semanticsifter-message-siftlink-params-error' => 'Message displayed  
when error occurs in parameter handling of #siftlink parser function',
+       'semanticsifter-param-query' => 'The main smw query, default parameter, 
should not be referenced by name',
+       'semanticsifter-param-filterwidth' => 'Parameter that controls the 
filter input box width.',
+       'semanticsifter-param-display' => 'Controls which components to show. 
both, filter or result. both is default',
 );
 
 /** German (Deutsch)
diff --git a/src/main/parserfunction/Sift.php b/src/main/parserfunction/Sift.php
index da5f1b9..6149620 100644
--- a/src/main/parserfunction/Sift.php
+++ b/src/main/parserfunction/Sift.php
@@ -33,6 +33,12 @@
        protected $properties = array();
 
        /**
+        * Array of filterable smw properties
+        * @var array
+        */
+       protected $filterProperties = array();
+
+       /**
         * HTTP Query storage system for filter selection
         * @var FilterStorageHTTPQuery
         */
@@ -148,7 +154,7 @@
        {
                $smwStore = StoreFactory::getStore();
                $output = '<form class="ss-filteringform">';
-               foreach ($this->properties as $p => $v) {
+               foreach ($this->filterProperties as $p => $v) {
                        $displayValue = is_null($v) ? $p : $v;
                        $property = \SMWDIProperty::newFromUserLabel($p);
                        $pValues = $this->getPropertyValue($smwStore, 
$property);
@@ -177,9 +183,14 @@
                foreach ($parameters as $key => &$arg) {
                        $arg = trim($arg);
                        list($property, $value) = array_pad(explode('=', $arg, 
2), 2, null);
+
                        switch (substr($arg, 0, 1)) {
+                               case '!':
+                                       //Extract smw property into filter array
+                                       
$this->filterProperties[substr($property, 1)] = $value;
+                                       unset($parameters[$key]);
+                                       break;
                                case '?':
-                                       //case '!': //FIXME why is this here?
                                        //Extract smw property into its own 
array
                                        $this->properties[substr($property, 1)] 
= $value;
                                        unset($parameters[$key]);
@@ -201,6 +212,13 @@
                                        break;
                        }
 
+               }
+
+               /**
+                * If the list of filterable properties is zero, add all smw 
properties to the array.
+                */
+               if(count($this->filterProperties) === 0){
+                       $this->filterProperties = $this->properties;
                }
 
                $defaultParams = array(
@@ -228,8 +246,20 @@
         */
        private function getOutput()
        {
-               $queryOutput = $this->createSMWQueryComponent();
-               $filteringComponent = 
$this->parameters['showfilter']->getValue() ?  
$this->createFilteringComponent() : '';
+               $queryOutput =  $filteringComponent = '';
+               switch($this->parameters['display']->getValue()){
+                       case 'filter':
+                               $filteringComponent = 
$this->createFilteringComponent();
+                               break;
+                       case 'result':
+                               $queryOutput = $this->createSMWQueryComponent();
+                               break;
+                       case 'both':
+                       default:
+                               $queryOutput = $this->createSMWQueryComponent();
+                               $filteringComponent = 
$this->createFilteringComponent();
+                               break;
+               }
 
                //create final html output
                $id = uniqid();
@@ -296,11 +326,10 @@
                                'message' => 'semanticsifter-param-filterwidth'
                        ),
                        array(
-                               'name' => 'showfilter',
-                               'default' => true,
-                               'type' => 'boolean',
-                               'message' => 'semanticsifter-param-showfilter'
-                       ),
+                               'name' => 'display',
+                               'default' => 'both',
+                               'message' => 'semanticsifter-param-display'
+                       )
                );
        }
 } 
\ No newline at end of file

-- 
To view, visit https://gerrit.wikimedia.org/r/121004
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I4c6812a272d4aefda0cfd90f90834894e368d79a
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/SemanticSifter
Gerrit-Branch: master
Gerrit-Owner: Netbrain <[email protected]>
Gerrit-Reviewer: Netbrain <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to