Completed
Push — master ( 1acccb...bdff2a )
by Henri
03:25
created
model/sparql/GenericSparql.php 1 patch
Spacing   +23 added lines, -23 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);
@@ -673,7 +673,7 @@  discard block
 block discarded – undo
673 673
         foreach ($graphs as $graph) {
674 674
           $values[] = "<$graph>";
675 675
         }
676
-        return "FILTER (?graph IN (" . implode(',', $values) . "))";
676
+        return "FILTER (?graph IN (".implode(',', $values)."))";
677 677
     }
678 678
 
679 679
     /**
@@ -683,16 +683,16 @@  discard block
 block discarded – undo
683 683
      * @return string sparql query clauses
684 684
      */
685 685
     protected function formatLimitAndOffset($limit, $offset) {
686
-        $limit = ($limit) ? 'LIMIT ' . $limit : '';
687
-        $offset = ($offset) ? 'OFFSET ' . $offset : '';
686
+        $limit = ($limit) ? 'LIMIT '.$limit : '';
687
+        $offset = ($offset) ? 'OFFSET '.$offset : '';
688 688
         // eliminating whitespace and line changes when the conditions aren't needed.
689 689
         $limitandoffset = '';
690 690
         if ($limit && $offset) {
691
-            $limitandoffset = "\n" . $limit . "\n" . $offset;
691
+            $limitandoffset = "\n".$limit."\n".$offset;
692 692
         } elseif ($limit) {
693
-            $limitandoffset = "\n" . $limit;
693
+            $limitandoffset = "\n".$limit;
694 694
         } elseif ($offset) {
695
-            $limitandoffset = "\n" . $offset;
695
+            $limitandoffset = "\n".$offset;
696 696
         }
697 697
 
698 698
         return $limitandoffset;
@@ -712,7 +712,7 @@  discard block
 block discarded – undo
712 712
             }
713 713
         }
714 714
 
715
-        return implode(' UNION ', $typePatterns);;
715
+        return implode(' UNION ', $typePatterns); ;
716 716
     }
717 717
 
718 718
     /**
@@ -844,7 +844,7 @@  discard block
 block discarded – undo
844 844
         // if search language and UI/display language differ, must also consider case where there is no prefLabel in
845 845
         // the display language; in that case, should use the label with the same language as the matched label
846 846
         $labelcondFallback = ($searchLang != $lang) ?
847
-          "OPTIONAL { # in case previous OPTIONAL block gives no labels\n" .
847
+          "OPTIONAL { # in case previous OPTIONAL block gives no labels\n".
848 848
           "?s skos:prefLabel ?label . FILTER (LANGMATCHES(LANG(?label), LANG(?match))) }" : "";
849 849
 
850 850
         /*
@@ -902,15 +902,15 @@  discard block
 block discarded – undo
902 902
 
903 903
         $schemecond = '';
904 904
         if (!empty($schemes)) {
905
-            foreach($schemes as $scheme) {
905
+            foreach ($schemes as $scheme) {
906 906
                 $schemecond .= "?s skos:inScheme <$scheme> . ";
907 907
             }
908 908
         }
909 909
 
910 910
         // extra conditions for parent and group, if specified
911
-        $parentcond = ($params->getParentLimit()) ? "?s skos:broader+ <" . $params->getParentLimit() . "> ." : "";
912
-        $groupcond = ($params->getGroupLimit()) ? "<" . $params->getGroupLimit() . "> skos:member ?s ." : "";
913
-        $pgcond = $parentcond . $groupcond;
911
+        $parentcond = ($params->getParentLimit()) ? "?s skos:broader+ <".$params->getParentLimit()."> ." : "";
912
+        $groupcond = ($params->getGroupLimit()) ? "<".$params->getGroupLimit()."> skos:member ?s ." : "";
913
+        $pgcond = $parentcond.$groupcond;
914 914
 
915 915
         $orderextra = $this->isDefaultEndpoint() ? $this->graph : '';
916 916
 
@@ -978,9 +978,9 @@  discard block
 block discarded – undo
978 978
             $hit['type'][] = $this->shortenUri($typeuri);
979 979
         }
980 980
 
981
-        if(!empty($fields)) {
981
+        if (!empty($fields)) {
982 982
             foreach ($fields as $prop) {
983
-                $propname = $prop . 's';
983
+                $propname = $prop.'s';
984 984
                 if (isset($row->$propname)) {
985 985
                     foreach (explode("\n", $row->$propname->getValue()) as $line) {
986 986
                         $rdata = str_getcsv($line, ',', '"', '"');
@@ -995,7 +995,7 @@  discard block
 block discarded – undo
995 995
                             $propvals = $rdata[2];
996 996
                         }
997 997
 
998
-                        $hit['skos:' . $prop][] = $propvals;
998
+                        $hit['skos:'.$prop][] = $propvals;
999 999
                     }
1000 1000
                 }
1001 1001
             }
@@ -1456,7 +1456,7 @@  discard block
 block discarded – undo
1456 1456
                 if (!isset($row->label) || $row->label->getLang() === $lang) {
1457 1457
                     $ret[$row->object->getUri()] = $val;
1458 1458
                 } elseif ($row->label->getLang() === $fallbacklang) {
1459
-                    $val['label'] .= ' (' . $row->label->getLang() . ')';
1459
+                    $val['label'] .= ' ('.$row->label->getLang().')';
1460 1460
                     $ret[$row->object->getUri()] = $val;
1461 1461
                 }
1462 1462
             }
@@ -1555,7 +1555,7 @@  discard block
 block discarded – undo
1555 1555
                 if ($row->label->getLang() == $lang) {
1556 1556
                     $label = $row->label->getValue();
1557 1557
                 } else {
1558
-                    $label = $row->label->getValue() . " (" . $row->label->getLang() . ")";
1558
+                    $label = $row->label->getValue()." (".$row->label->getLang().")";
1559 1559
                 }
1560 1560
 
1561 1561
             }
@@ -1720,7 +1720,7 @@  discard block
 block discarded – undo
1720 1720
                 if (isset($row->childlabel)) {
1721 1721
                     $label = $row->childlabel->getValue();
1722 1722
                     if ($row->childlabel->getLang() !== $lang) {
1723
-                        $label .= " (" . $row->childlabel->getLang() . ")";
1723
+                        $label .= " (".$row->childlabel->getLang().")";
1724 1724
                     }
1725 1725
 
1726 1726
                 }
@@ -1742,7 +1742,7 @@  discard block
 block discarded – undo
1742 1742
             if (isset($row->label)) {
1743 1743
                 $preflabel = $row->label->getValue();
1744 1744
                 if ($row->label->getLang() !== $lang && strpos($row->label->getLang(), $lang) !== 0) {
1745
-                    $preflabel .= ' (' . $row->label->getLang() . ')';
1745
+                    $preflabel .= ' ('.$row->label->getLang().')';
1746 1746
                 }
1747 1747
 
1748 1748
                 $ret[$uri]['prefLabel'] = $preflabel;
@@ -1902,7 +1902,7 @@  discard block
 block discarded – undo
1902 1902
                     if ($row->label->getLang() == $lang) {
1903 1903
                         $values[$row->conc->getURI()]['prefLabel'] = $row->label->getValue();
1904 1904
                     } else {
1905
-                        $values[$row->conc->getURI()]['prefLabel'] = $row->label->getValue() . " (" . $row->label->getLang() . ")";
1905
+                        $values[$row->conc->getURI()]['prefLabel'] = $row->label->getValue()." (".$row->label->getLang().")";
1906 1906
                     }
1907 1907
 
1908 1908
                 }
@@ -1943,7 +1943,7 @@  discard block
 block discarded – undo
1943 1943
      */
1944 1944
     private function generateChangeListQuery($lang, $offset, $prop) {
1945 1945
         $fcl = $this->generateFromClause();
1946
-        $offset = ($offset) ? 'OFFSET ' . $offset : '';
1946
+        $offset = ($offset) ? 'OFFSET '.$offset : '';
1947 1947
 
1948 1948
         $query = <<<EOQ
1949 1949
 SELECT DISTINCT ?concept ?date ?label $fcl
Please login to merge, or discard this patch.