Completed
Push — master ( 1b8c1a...c8fd0a )
by Henri
03:22
created
model/sparql/GenericSparql.php 1 patch
Spacing   +25 added lines, -25 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,14 +845,14 @@  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
-          $labelClause = ($lang) ? $labelClause . " FILTER (LANGMATCHES(LANG(?label), '$lang'))" : $labelClause . "";
855
-          return $labelClause . " BIND(?label AS ?match)";
854
+          $labelClause = ($lang) ? $labelClause." FILTER (LANGMATCHES(LANG(?label), '$lang'))" : $labelClause."";
855
+          return $labelClause." BIND(?label AS ?match)";
856 856
         }
857 857
 
858 858
         /*
@@ -912,15 +912,15 @@  discard block
 block discarded – undo
912 912
 
913 913
         $schemecond = '';
914 914
         if (!empty($schemes)) {
915
-            foreach($schemes as $scheme) {
915
+            foreach ($schemes as $scheme) {
916 916
                 $schemecond .= "?s skos:inScheme <$scheme> . ";
917 917
             }
918 918
         }
919 919
 
920 920
         // extra conditions for parent and group, if specified
921
-        $parentcond = ($params->getParentLimit()) ? "?s skos:broader+ <" . $params->getParentLimit() . "> ." : "";
922
-        $groupcond = ($params->getGroupLimit()) ? "<" . $params->getGroupLimit() . "> skos:member ?s ." : "";
923
-        $pgcond = $parentcond . $groupcond;
921
+        $parentcond = ($params->getParentLimit()) ? "?s skos:broader+ <".$params->getParentLimit()."> ." : "";
922
+        $groupcond = ($params->getGroupLimit()) ? "<".$params->getGroupLimit()."> skos:member ?s ." : "";
923
+        $pgcond = $parentcond.$groupcond;
924 924
 
925 925
         $orderextra = $this->isDefaultEndpoint() ? $this->graph : '';
926 926
 
@@ -994,9 +994,9 @@  discard block
 block discarded – undo
994 994
             $hit['type'][] = $this->shortenUri($typeuri);
995 995
         }
996 996
 
997
-        if(!empty($fields)) {
997
+        if (!empty($fields)) {
998 998
             foreach ($fields as $prop) {
999
-                $propname = $prop . 's';
999
+                $propname = $prop.'s';
1000 1000
                 if (isset($row->$propname)) {
1001 1001
                     foreach (explode("\n", $row->$propname->getValue()) as $line) {
1002 1002
                         $rdata = str_getcsv($line, ',', '"', '"');
@@ -1011,7 +1011,7 @@  discard block
 block discarded – undo
1011 1011
                             $propvals = $rdata[2];
1012 1012
                         }
1013 1013
 
1014
-                        $hit['skos:' . $prop][] = $propvals;
1014
+                        $hit['skos:'.$prop][] = $propvals;
1015 1015
                     }
1016 1016
                 }
1017 1017
             }
@@ -1472,7 +1472,7 @@  discard block
 block discarded – undo
1472 1472
                 if (!isset($row->label) || $row->label->getLang() === $lang) {
1473 1473
                     $ret[$row->object->getUri()] = $val;
1474 1474
                 } elseif ($row->label->getLang() === $fallbacklang) {
1475
-                    $val['label'] .= ' (' . $row->label->getLang() . ')';
1475
+                    $val['label'] .= ' ('.$row->label->getLang().')';
1476 1476
                     $ret[$row->object->getUri()] = $val;
1477 1477
                 }
1478 1478
             }
@@ -1571,7 +1571,7 @@  discard block
 block discarded – undo
1571 1571
                 if ($row->label->getLang() == $lang) {
1572 1572
                     $label = $row->label->getValue();
1573 1573
                 } else {
1574
-                    $label = $row->label->getValue() . " (" . $row->label->getLang() . ")";
1574
+                    $label = $row->label->getValue()." (".$row->label->getLang().")";
1575 1575
                 }
1576 1576
 
1577 1577
             }
@@ -1736,7 +1736,7 @@  discard block
 block discarded – undo
1736 1736
                 if (isset($row->childlabel)) {
1737 1737
                     $label = $row->childlabel->getValue();
1738 1738
                     if ($row->childlabel->getLang() !== $lang) {
1739
-                        $label .= " (" . $row->childlabel->getLang() . ")";
1739
+                        $label .= " (".$row->childlabel->getLang().")";
1740 1740
                     }
1741 1741
 
1742 1742
                 }
@@ -1758,7 +1758,7 @@  discard block
 block discarded – undo
1758 1758
             if (isset($row->label)) {
1759 1759
                 $preflabel = $row->label->getValue();
1760 1760
                 if ($row->label->getLang() !== $lang && strpos($row->label->getLang(), $lang) !== 0) {
1761
-                    $preflabel .= ' (' . $row->label->getLang() . ')';
1761
+                    $preflabel .= ' ('.$row->label->getLang().')';
1762 1762
                 }
1763 1763
 
1764 1764
                 $ret[$uri]['prefLabel'] = $preflabel;
@@ -1918,7 +1918,7 @@  discard block
 block discarded – undo
1918 1918
                     if ($row->label->getLang() == $lang) {
1919 1919
                         $values[$row->conc->getURI()]['prefLabel'] = $row->label->getValue();
1920 1920
                     } else {
1921
-                        $values[$row->conc->getURI()]['prefLabel'] = $row->label->getValue() . " (" . $row->label->getLang() . ")";
1921
+                        $values[$row->conc->getURI()]['prefLabel'] = $row->label->getValue()." (".$row->label->getLang().")";
1922 1922
                     }
1923 1923
 
1924 1924
                 }
@@ -1959,7 +1959,7 @@  discard block
 block discarded – undo
1959 1959
      */
1960 1960
     private function generateChangeListQuery($lang, $offset, $prop) {
1961 1961
         $fcl = $this->generateFromClause();
1962
-        $offset = ($offset) ? 'OFFSET ' . $offset : '';
1962
+        $offset = ($offset) ? 'OFFSET '.$offset : '';
1963 1963
 
1964 1964
         $query = <<<EOQ
1965 1965
 SELECT DISTINCT ?concept ?date ?label $fcl
Please login to merge, or discard this patch.