Completed
Push — master ( 218b13...b87625 )
by Henri
02:22
created
model/ConceptProperty.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -21,7 +21,7 @@  discard block
 block discarded – undo
21 21
      * @param string $prop property type eg. 'rdf:type'.
22 22
      * @param string $label
23 23
      */
24
-    public function __construct($prop, $label, $super=null)
24
+    public function __construct($prop, $label, $super = null)
25 25
     {
26 26
         $this->prop = $prop;
27 27
         $this->label = $label;
@@ -59,7 +59,7 @@  discard block
 block discarded – undo
59 59
      */
60 60
     public function getDescription()
61 61
     {
62
-        $helpprop = $this->prop . "_help";
62
+        $helpprop = $this->prop."_help";
63 63
 
64 64
         return gettext($helpprop); // can't use string constant, it'd be picked up by xgettext
65 65
     }
@@ -78,7 +78,7 @@  discard block
 block discarded – undo
78 78
 
79 79
     public function addValue($value)
80 80
     {
81
-        $this->values[$value->getNotation() . $value->getLabel() . $value->getUri()] = $value;
81
+        $this->values[$value->getNotation().$value->getLabel().$value->getUri()] = $value;
82 82
         $this->is_sorted = false;
83 83
     }
84 84
 
@@ -86,7 +86,7 @@  discard block
 block discarded – undo
86 86
     {
87 87
         if (!empty($this->values)) {
88 88
             uksort($this->values, function($a, $b) {
89
-                return strnatcasecmp($a,$b);
89
+                return strnatcasecmp($a, $b);
90 90
             });
91 91
         }
92 92
         $this->is_sorted = true;
Please login to merge, or discard this patch.
model/sparql/GenericSparql.php 3 patches
Doc Comments   +5 added lines, -3 removed lines patch added patch discarded remove patch
@@ -429,7 +429,7 @@  discard block
 block discarded – undo
429 429
      * Returns information (as a graph) for one or more concept URIs
430 430
      * @param mixed $uris concept URI (string) or array of URIs
431 431
      * @param string|null $arrayClass the URI for thesaurus array class, or null if not used
432
-     * @param \Vocabulary[]|null $vocabs vocabularies to target
432
+     * @param Vocabulary[] $vocabs vocabularies to target
433 433
      * @return \Concept[]
434 434
      */
435 435
     public function queryConceptInfoGraph($uris, $arrayClass = null, $vocabs = array()) {
@@ -649,7 +649,7 @@  discard block
 block discarded – undo
649 649
 
650 650
     /**
651 651
      * Generate a VALUES clause for limiting the targeted graphs.
652
-     * @param Vocabulary[]|null $vocabs array of Vocabulary objects to target
652
+     * @param Vocabulary[] $vocabs array of Vocabulary objects to target
653 653
      * @return string VALUES clause, or "" if not necessary to limit
654 654
      */
655 655
     protected function formatValuesGraph($vocabs) {
@@ -829,6 +829,7 @@  discard block
 block discarded – undo
829 829
      * @param string $searchLang language code used for matching labels (null means any language)
830 830
      * @param string[] $props properties to target e.g. array('skos:prefLabel','skos:altLabel')
831 831
      * @param boolean $unique restrict results to unique concepts (default: false)
832
+     * @param string $filterGraph
832 833
      * @return string sparql query
833 834
      */
834 835
     protected function generateConceptSearchQueryInner($term, $lang, $searchLang, $props, $unique, $filterGraph)
@@ -1094,6 +1095,7 @@  discard block
 block discarded – undo
1094 1095
     /**
1095 1096
      * Generates sparql query clauses used for creating the alphabetical index.
1096 1097
      * @param string $letter the letter (or special class) to search for
1098
+     * @param string $lang
1097 1099
      * @return array of sparql query clause strings
1098 1100
      */
1099 1101
     private function formatFilterConditions($letter, $lang) {
@@ -1406,7 +1408,7 @@  discard block
 block discarded – undo
1406 1408
     /**
1407 1409
      * Query a single transitive property of a concept.
1408 1410
      * @param string $uri
1409
-     * @param string $prop the name of the property eg. 'skos:broader'.
1411
+     * @param string $props the name of the property eg. 'skos:broader'.
1410 1412
      * @param string $lang
1411 1413
      * @param integer $limit
1412 1414
      * @param boolean $anylang if you want a label even when it isn't available in the language you requested.
Please login to merge, or discard this patch.
Braces   +10 added lines, -6 removed lines patch added patch discarded remove patch
@@ -46,12 +46,16 @@  discard block
 block discarded – undo
46 46
         $this->client = new EasyRdf_Sparql_Client($endpoint);
47 47
 
48 48
         // set graphClause so that it can be used by all queries
49
-        if ($this->isDefaultEndpoint()) // default endpoint; query any graph (and catch it in a variable)
49
+        if ($this->isDefaultEndpoint()) {
50
+          // default endpoint; query any graph (and catch it in a variable)
50 51
         {
51 52
             $this->graphClause = "GRAPH $graph";
52
-        } elseif ($graph) // query a specific graph
53
+        }
54
+        } elseif ($graph) {
55
+          // query a specific graph
53 56
         {
54 57
             $this->graphClause = "GRAPH <$graph>";
58
+        }
55 59
         } else // query the default graph
56 60
         {
57 61
             $this->graphClause = "";
@@ -78,8 +82,9 @@  discard block
 block discarded – undo
78 82
             }
79 83
         }
80 84
         foreach ($graphs as $graph) {
81
-            if($graph !== NULL)
82
-                $clause .= "FROM NAMED <$graph> "; 
85
+            if($graph !== NULL) {
86
+                            $clause .= "FROM NAMED <$graph> ";
87
+            }
83 88
         }
84 89
         return $clause;
85 90
     }
@@ -1776,8 +1781,7 @@  discard block
 block discarded – undo
1776 1781
         if (sizeof($ret) > 0) {
1777 1782
             // existing concept, with children
1778 1783
             return $ret;
1779
-        }
1780
-        else {
1784
+        } else {
1781 1785
             // nonexistent concept
1782 1786
             return null;
1783 1787
         }
Please login to merge, or discard this patch.
Spacing   +27 added lines, -27 removed lines patch added patch discarded remove patch
@@ -71,7 +71,7 @@  discard block
 block discarded – undo
71 71
         $starttime = microtime();
72 72
         $result = $this->client->query($query);
73 73
         $elapsed = intval(round((microtime() - $starttime) * 1000));
74
-        if(method_exists($result, 'numRows')) {
74
+        if (method_exists($result, 'numRows')) {
75 75
             $numRows = $result->numRows();
76 76
             $logger->info("[qid $queryId] result: $numRows rows returned in $elapsed ms");
77 77
         } else { // graph result
@@ -87,20 +87,20 @@  discard block
 block discarded – undo
87 87
      * @param Vocabulary[]|null $vocabs
88 88
      * @return string
89 89
      */
90
-    protected function generateFromClause($vocabs=null) {
90
+    protected function generateFromClause($vocabs = null) {
91 91
         $graphs = array();
92 92
         $clause = '';
93 93
         if (!$vocabs) {
94 94
             return $this->graph !== '?graph' && $this->graph !== NULL ? "FROM <$this->graph>" : '';
95 95
         }
96
-        foreach($vocabs as $vocab) {
96
+        foreach ($vocabs as $vocab) {
97 97
             $graph = $vocab->getGraph();
98 98
             if (!in_array($graph, $graphs)) {
99 99
                 array_push($graphs, $graph);
100 100
             }
101 101
         }
102 102
         foreach ($graphs as $graph) {
103
-            if($graph !== NULL)
103
+            if ($graph !== NULL)
104 104
                 $clause .= "FROM NAMED <$graph> "; 
105 105
         }
106 106
         return $clause;
@@ -697,7 +697,7 @@  discard block
 block discarded – undo
697 697
         foreach ($graphs as $graph) {
698 698
           $values[] = "<$graph>";
699 699
         }
700
-        return "FILTER (?graph IN (" . implode(',', $values) . "))";
700
+        return "FILTER (?graph IN (".implode(',', $values)."))";
701 701
     }
702 702
 
703 703
     /**
@@ -707,16 +707,16 @@  discard block
 block discarded – undo
707 707
      * @return string sparql query clauses
708 708
      */
709 709
     protected function formatLimitAndOffset($limit, $offset) {
710
-        $limit = ($limit) ? 'LIMIT ' . $limit : '';
711
-        $offset = ($offset) ? 'OFFSET ' . $offset : '';
710
+        $limit = ($limit) ? 'LIMIT '.$limit : '';
711
+        $offset = ($offset) ? 'OFFSET '.$offset : '';
712 712
         // eliminating whitespace and line changes when the conditions aren't needed.
713 713
         $limitandoffset = '';
714 714
         if ($limit && $offset) {
715
-            $limitandoffset = "\n" . $limit . "\n" . $offset;
715
+            $limitandoffset = "\n".$limit."\n".$offset;
716 716
         } elseif ($limit) {
717
-            $limitandoffset = "\n" . $limit;
717
+            $limitandoffset = "\n".$limit;
718 718
         } elseif ($offset) {
719
-            $limitandoffset = "\n" . $offset;
719
+            $limitandoffset = "\n".$offset;
720 720
         }
721 721
 
722 722
         return $limitandoffset;
@@ -736,7 +736,7 @@  discard block
 block discarded – undo
736 736
             }
737 737
         }
738 738
 
739
-        return implode(' UNION ', $typePatterns);;
739
+        return implode(' UNION ', $typePatterns); ;
740 740
     }
741 741
 
742 742
     /**
@@ -868,14 +868,14 @@  discard block
 block discarded – undo
868 868
         // if search language and UI/display language differ, must also consider case where there is no prefLabel in
869 869
         // the display language; in that case, should use the label with the same language as the matched label
870 870
         $labelcondFallback = ($searchLang != $lang) ?
871
-          "OPTIONAL { # in case previous OPTIONAL block gives no labels\n" .
871
+          "OPTIONAL { # in case previous OPTIONAL block gives no labels\n".
872 872
           "?s skos:prefLabel ?label . FILTER (LANGMATCHES(LANG(?label), LANG(?match))) }" : "";
873 873
           
874 874
         //  Including the labels if there is no query term given.
875 875
         if ($rawterm === '') {
876 876
           $labelClause = "?s skos:prefLabel ?label .";
877
-          $labelClause = ($lang) ? $labelClause . " FILTER (LANGMATCHES(LANG(?label), '$lang'))" : $labelClause . "";
878
-          return $labelClause . " BIND(?label AS ?match)";
877
+          $labelClause = ($lang) ? $labelClause." FILTER (LANGMATCHES(LANG(?label), '$lang'))" : $labelClause."";
878
+          return $labelClause." BIND(?label AS ?match)";
879 879
         }
880 880
 
881 881
         /*
@@ -936,15 +936,15 @@  discard block
 block discarded – undo
936 936
 
937 937
         $schemecond = '';
938 938
         if (!empty($schemes)) {
939
-            foreach($schemes as $scheme) {
939
+            foreach ($schemes as $scheme) {
940 940
                 $schemecond .= "?s skos:inScheme <$scheme> . ";
941 941
             }
942 942
         }
943 943
 
944 944
         // extra conditions for parent and group, if specified
945
-        $parentcond = ($params->getParentLimit()) ? "?s skos:broader+ <" . $params->getParentLimit() . "> ." : "";
946
-        $groupcond = ($params->getGroupLimit()) ? "<" . $params->getGroupLimit() . "> skos:member ?s ." : "";
947
-        $pgcond = $parentcond . $groupcond;
945
+        $parentcond = ($params->getParentLimit()) ? "?s skos:broader+ <".$params->getParentLimit()."> ." : "";
946
+        $groupcond = ($params->getGroupLimit()) ? "<".$params->getGroupLimit()."> skos:member ?s ." : "";
947
+        $pgcond = $parentcond.$groupcond;
948 948
 
949 949
         $orderextra = $this->isDefaultEndpoint() ? $this->graph : '';
950 950
 
@@ -1018,9 +1018,9 @@  discard block
 block discarded – undo
1018 1018
             $hit['type'][] = $this->shortenUri($typeuri);
1019 1019
         }
1020 1020
 
1021
-        if(!empty($fields)) {
1021
+        if (!empty($fields)) {
1022 1022
             foreach ($fields as $prop) {
1023
-                $propname = $prop . 's';
1023
+                $propname = $prop.'s';
1024 1024
                 if (isset($row->$propname)) {
1025 1025
                     foreach (explode("\n", $row->$propname->getValue()) as $line) {
1026 1026
                         $rdata = str_getcsv($line, ',', '"', '"');
@@ -1035,7 +1035,7 @@  discard block
 block discarded – undo
1035 1035
                             $propvals = $rdata[2];
1036 1036
                         }
1037 1037
 
1038
-                        $hit['skos:' . $prop][] = $propvals;
1038
+                        $hit['skos:'.$prop][] = $propvals;
1039 1039
                     }
1040 1040
                 }
1041 1041
             }
@@ -1494,7 +1494,7 @@  discard block
 block discarded – undo
1494 1494
                 if (!isset($row->label) || $row->label->getLang() === $lang) {
1495 1495
                     $ret[$row->object->getUri()] = $val;
1496 1496
                 } elseif ($row->label->getLang() === $fallbacklang) {
1497
-                    $val['label'] .= ' (' . $row->label->getLang() . ')';
1497
+                    $val['label'] .= ' ('.$row->label->getLang().')';
1498 1498
                     $ret[$row->object->getUri()] = $val;
1499 1499
                 }
1500 1500
             }
@@ -1593,7 +1593,7 @@  discard block
 block discarded – undo
1593 1593
                 if ($row->label->getLang() == $lang) {
1594 1594
                     $label = $row->label->getValue();
1595 1595
                 } else {
1596
-                    $label = $row->label->getValue() . " (" . $row->label->getLang() . ")";
1596
+                    $label = $row->label->getValue()." (".$row->label->getLang().")";
1597 1597
                 }
1598 1598
 
1599 1599
             }
@@ -1758,7 +1758,7 @@  discard block
 block discarded – undo
1758 1758
                 if (isset($row->childlabel)) {
1759 1759
                     $label = $row->childlabel->getValue();
1760 1760
                     if ($row->childlabel->getLang() !== $lang) {
1761
-                        $label .= " (" . $row->childlabel->getLang() . ")";
1761
+                        $label .= " (".$row->childlabel->getLang().")";
1762 1762
                     }
1763 1763
 
1764 1764
                 }
@@ -1780,7 +1780,7 @@  discard block
 block discarded – undo
1780 1780
             if (isset($row->label)) {
1781 1781
                 $preflabel = $row->label->getValue();
1782 1782
                 if ($row->label->getLang() && $row->label->getLang() !== $lang && strpos($row->label->getLang(), $lang) !== 0) {
1783
-                    $preflabel .= ' (' . $row->label->getLang() . ')';
1783
+                    $preflabel .= ' ('.$row->label->getLang().')';
1784 1784
                 }
1785 1785
 
1786 1786
                 $ret[$uri]['prefLabel'] = $preflabel;
@@ -1940,7 +1940,7 @@  discard block
 block discarded – undo
1940 1940
                     if ($row->label->getLang() == $lang) {
1941 1941
                         $values[$row->conc->getURI()]['prefLabel'] = $row->label->getValue();
1942 1942
                     } else {
1943
-                        $values[$row->conc->getURI()]['prefLabel'] = $row->label->getValue() . " (" . $row->label->getLang() . ")";
1943
+                        $values[$row->conc->getURI()]['prefLabel'] = $row->label->getValue()." (".$row->label->getLang().")";
1944 1944
                     }
1945 1945
 
1946 1946
                 }
@@ -1981,7 +1981,7 @@  discard block
 block discarded – undo
1981 1981
      */
1982 1982
     private function generateChangeListQuery($lang, $offset, $prop) {
1983 1983
         $fcl = $this->generateFromClause();
1984
-        $offset = ($offset) ? 'OFFSET ' . $offset : '';
1984
+        $offset = ($offset) ? 'OFFSET '.$offset : '';
1985 1985
 
1986 1986
         $query = <<<EOQ
1987 1987
 SELECT DISTINCT ?concept ?date ?label $fcl
Please login to merge, or discard this patch.