Completed
Push — master ( eb3b50...e1e7fd )
by Henri
03:00
created
model/sparql/GenericSparql.php 1 patch
Spacing   +24 added lines, -24 removed lines patch added patch discarded remove patch
@@ -65,13 +65,13 @@  discard block
 block discarded – undo
65 65
      * @param Vocabulary[]|null $vocabs
66 66
      * @return string
67 67
      */
68
-    protected function generateFromClause($vocabs=null) {
68
+    protected function generateFromClause($vocabs = null) {
69 69
         $graphs = array();
70 70
         $clause = '';
71 71
         if (!$vocabs) {
72 72
             return $this->graph !== '?graph' ? "FROM <$this->graph>" : '';
73 73
         }
74
-        foreach($vocabs as $vocab) {
74
+        foreach ($vocabs as $vocab) {
75 75
             $graph = $vocab->getGraph();
76 76
             if (!in_array($graph, $graphs)) {
77 77
                 array_push($graphs, $graph);
@@ -674,7 +674,7 @@  discard block
 block discarded – undo
674 674
         foreach ($graphs as $graph) {
675 675
           $values[] = "<$graph>";
676 676
         }
677
-        return "FILTER (?graph IN (" . implode(',', $values) . "))";
677
+        return "FILTER (?graph IN (".implode(',', $values)."))";
678 678
     }
679 679
 
680 680
     /**
@@ -684,16 +684,16 @@  discard block
 block discarded – undo
684 684
      * @return string sparql query clauses
685 685
      */
686 686
     protected function formatLimitAndOffset($limit, $offset) {
687
-        $limit = ($limit) ? 'LIMIT ' . $limit : '';
688
-        $offset = ($offset) ? 'OFFSET ' . $offset : '';
687
+        $limit = ($limit) ? 'LIMIT '.$limit : '';
688
+        $offset = ($offset) ? 'OFFSET '.$offset : '';
689 689
         // eliminating whitespace and line changes when the conditions aren't needed.
690 690
         $limitandoffset = '';
691 691
         if ($limit && $offset) {
692
-            $limitandoffset = "\n" . $limit . "\n" . $offset;
692
+            $limitandoffset = "\n".$limit."\n".$offset;
693 693
         } elseif ($limit) {
694
-            $limitandoffset = "\n" . $limit;
694
+            $limitandoffset = "\n".$limit;
695 695
         } elseif ($offset) {
696
-            $limitandoffset = "\n" . $offset;
696
+            $limitandoffset = "\n".$offset;
697 697
         }
698 698
 
699 699
         return $limitandoffset;
@@ -713,7 +713,7 @@  discard block
 block discarded – undo
713 713
             }
714 714
         }
715 715
 
716
-        return implode(' UNION ', $typePatterns);;
716
+        return implode(' UNION ', $typePatterns); ;
717 717
     }
718 718
 
719 719
     /**
@@ -845,13 +845,13 @@  discard block
 block discarded – undo
845 845
         // if search language and UI/display language differ, must also consider case where there is no prefLabel in
846 846
         // the display language; in that case, should use the label with the same language as the matched label
847 847
         $labelcondFallback = ($searchLang != $lang) ?
848
-          "OPTIONAL { # in case previous OPTIONAL block gives no labels\n" .
848
+          "OPTIONAL { # in case previous OPTIONAL block gives no labels\n".
849 849
           "?s skos:prefLabel ?label . FILTER (LANGMATCHES(LANG(?label), LANG(?match))) }" : "";
850 850
           
851 851
         //  Including the labels if there is no query term given.
852 852
         if ($rawterm === '') {
853 853
           $labelClause = "?s skos:prefLabel ?label .";
854
-          return ($lang) ? $labelClause . " FILTER (LANGMATCHES(LANG(?label), '$lang'))" : $labelClause . "";
854
+          return ($lang) ? $labelClause." FILTER (LANGMATCHES(LANG(?label), '$lang'))" : $labelClause."";
855 855
         }
856 856
 
857 857
         /*
@@ -911,15 +911,15 @@  discard block
 block discarded – undo
911 911
 
912 912
         $schemecond = '';
913 913
         if (!empty($schemes)) {
914
-            foreach($schemes as $scheme) {
914
+            foreach ($schemes as $scheme) {
915 915
                 $schemecond .= "?s skos:inScheme <$scheme> . ";
916 916
             }
917 917
         }
918 918
 
919 919
         // extra conditions for parent and group, if specified
920
-        $parentcond = ($params->getParentLimit()) ? "?s skos:broader+ <" . $params->getParentLimit() . "> ." : "";
921
-        $groupcond = ($params->getGroupLimit()) ? "<" . $params->getGroupLimit() . "> skos:member ?s ." : "";
922
-        $pgcond = $parentcond . $groupcond;
920
+        $parentcond = ($params->getParentLimit()) ? "?s skos:broader+ <".$params->getParentLimit()."> ." : "";
921
+        $groupcond = ($params->getGroupLimit()) ? "<".$params->getGroupLimit()."> skos:member ?s ." : "";
922
+        $pgcond = $parentcond.$groupcond;
923 923
 
924 924
         $orderextra = $this->isDefaultEndpoint() ? $this->graph : '';
925 925
 
@@ -993,9 +993,9 @@  discard block
 block discarded – undo
993 993
             $hit['type'][] = $this->shortenUri($typeuri);
994 994
         }
995 995
 
996
-        if(!empty($fields)) {
996
+        if (!empty($fields)) {
997 997
             foreach ($fields as $prop) {
998
-                $propname = $prop . 's';
998
+                $propname = $prop.'s';
999 999
                 if (isset($row->$propname)) {
1000 1000
                     foreach (explode("\n", $row->$propname->getValue()) as $line) {
1001 1001
                         $rdata = str_getcsv($line, ',', '"', '"');
@@ -1010,7 +1010,7 @@  discard block
 block discarded – undo
1010 1010
                             $propvals = $rdata[2];
1011 1011
                         }
1012 1012
 
1013
-                        $hit['skos:' . $prop][] = $propvals;
1013
+                        $hit['skos:'.$prop][] = $propvals;
1014 1014
                     }
1015 1015
                 }
1016 1016
             }
@@ -1471,7 +1471,7 @@  discard block
 block discarded – undo
1471 1471
                 if (!isset($row->label) || $row->label->getLang() === $lang) {
1472 1472
                     $ret[$row->object->getUri()] = $val;
1473 1473
                 } elseif ($row->label->getLang() === $fallbacklang) {
1474
-                    $val['label'] .= ' (' . $row->label->getLang() . ')';
1474
+                    $val['label'] .= ' ('.$row->label->getLang().')';
1475 1475
                     $ret[$row->object->getUri()] = $val;
1476 1476
                 }
1477 1477
             }
@@ -1570,7 +1570,7 @@  discard block
 block discarded – undo
1570 1570
                 if ($row->label->getLang() == $lang) {
1571 1571
                     $label = $row->label->getValue();
1572 1572
                 } else {
1573
-                    $label = $row->label->getValue() . " (" . $row->label->getLang() . ")";
1573
+                    $label = $row->label->getValue()." (".$row->label->getLang().")";
1574 1574
                 }
1575 1575
 
1576 1576
             }
@@ -1735,7 +1735,7 @@  discard block
 block discarded – undo
1735 1735
                 if (isset($row->childlabel)) {
1736 1736
                     $label = $row->childlabel->getValue();
1737 1737
                     if ($row->childlabel->getLang() !== $lang) {
1738
-                        $label .= " (" . $row->childlabel->getLang() . ")";
1738
+                        $label .= " (".$row->childlabel->getLang().")";
1739 1739
                     }
1740 1740
 
1741 1741
                 }
@@ -1757,7 +1757,7 @@  discard block
 block discarded – undo
1757 1757
             if (isset($row->label)) {
1758 1758
                 $preflabel = $row->label->getValue();
1759 1759
                 if ($row->label->getLang() !== $lang && strpos($row->label->getLang(), $lang) !== 0) {
1760
-                    $preflabel .= ' (' . $row->label->getLang() . ')';
1760
+                    $preflabel .= ' ('.$row->label->getLang().')';
1761 1761
                 }
1762 1762
 
1763 1763
                 $ret[$uri]['prefLabel'] = $preflabel;
@@ -1917,7 +1917,7 @@  discard block
 block discarded – undo
1917 1917
                     if ($row->label->getLang() == $lang) {
1918 1918
                         $values[$row->conc->getURI()]['prefLabel'] = $row->label->getValue();
1919 1919
                     } else {
1920
-                        $values[$row->conc->getURI()]['prefLabel'] = $row->label->getValue() . " (" . $row->label->getLang() . ")";
1920
+                        $values[$row->conc->getURI()]['prefLabel'] = $row->label->getValue()." (".$row->label->getLang().")";
1921 1921
                     }
1922 1922
 
1923 1923
                 }
@@ -1958,7 +1958,7 @@  discard block
 block discarded – undo
1958 1958
      */
1959 1959
     private function generateChangeListQuery($lang, $offset, $prop) {
1960 1960
         $fcl = $this->generateFromClause();
1961
-        $offset = ($offset) ? 'OFFSET ' . $offset : '';
1961
+        $offset = ($offset) ? 'OFFSET '.$offset : '';
1962 1962
 
1963 1963
         $query = <<<EOQ
1964 1964
 SELECT DISTINCT ?concept ?date ?label $fcl
Please login to merge, or discard this patch.