Passed
Pull Request — master (#64)
by
unknown
06:06
created
Classes/Controller/AbstractSearchController.php 3 patches
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -67,21 +67,21 @@  discard block
 block discarded – undo
67 67
      * build array for elasticsearch
68 68
      * @return array Elasticsearch query array
69 69
      */
70
-    public function extendedSearch($searchArray = array())
70
+    public function extendedSearch($searchArray = array ())
71 71
     {
72 72
 
73
-        $query  = array();
74
-        $filter = array();
73
+        $query  = array ();
74
+        $filter = array ();
75 75
         foreach ($searchArray as $key => $qry) {
76 76
             $qry = trim($qry);
77 77
 
78 78
             if (!empty($qry) && in_array($key, self::$matches)) {
79 79
 
80
-                $query['body']['query']['bool']['must'][] = array('match' => array($key => $qry));
80
+                $query['body']['query']['bool']['must'][] = array ('match' => array ($key => $qry));
81 81
 
82 82
             } elseif (!empty($qry) && in_array($key, self::$terms)) {
83 83
 
84
-                $query['body']['query']['bool']['must'][] = array('term' => array($key => $qry));
84
+                $query['body']['query']['bool']['must'][] = array ('term' => array ($key => $qry));
85 85
 
86 86
             } elseif (!empty($qry) && $key == 'from') {
87 87
 
@@ -98,7 +98,7 @@  discard block
 block discarded – undo
98 98
 
99 99
         if (isset($filter['gte']) || isset($filter['lte'])) {
100 100
 
101
-            $query['body']['query']['bool']['must'][] = array('range' => array('distribution_date' => $filter));
101
+            $query['body']['query']['bool']['must'][] = array ('range' => array ('distribution_date' => $filter));
102 102
 
103 103
         }
104 104
 
@@ -116,19 +116,19 @@  discard block
 block discarded – undo
116 116
     public function resultsFilter($query, $showDeleted = false)
117 117
     {
118 118
 
119
-        $queryFilter = array();
119
+        $queryFilter = array ();
120 120
 
121 121
         // Frontend only
122 122
         $searchResultsFilter = $this->settings['searchResultsFilter'];
123
-        if(!empty($searchResultsFilter)) {
123
+        if (!empty($searchResultsFilter)) {
124 124
 
125 125
             // add doctypes
126
-            if($searchResultsFilter['doctype']) {
126
+            if ($searchResultsFilter['doctype']) {
127 127
 
128 128
                 $uids = \TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode(',', $searchResultsFilter['doctype']);
129 129
                 $documentTypeRepository = $this->documentTypeRepository;
130
-                $documentTypes = array();
131
-                foreach($uids as $uid) {
130
+                $documentTypes = array ();
131
+                foreach ($uids as $uid) {
132 132
                     $documentType = $documentTypeRepository->findByUid($uid);
133 133
                     $documentTypes[] = $documentType->getName();
134 134
                 };
@@ -136,7 +136,7 @@  discard block
 block discarded – undo
136 136
             }
137 137
 
138 138
             // add date filter
139
-            $dateFilter = array();
139
+            $dateFilter = array ();
140 140
             if ($searchResultsFilter['from']) {
141 141
 
142 142
                 $from     = date('d.m.Y', $searchResultsFilter['from']);
@@ -148,7 +148,7 @@  discard block
 block discarded – undo
148 148
 
149 149
             if ($searchResultsFilter['till']) {
150 150
 
151
-                $till          = date('d.m.Y', $searchResultsFilter['till']);
151
+                $till = date('d.m.Y', $searchResultsFilter['till']);
152 152
                 $dateTime = $this->convertFormDate($till, true);
153 153
                 $dateFilter['lte'] = $dateTime->format('Y-m-d');
154 154
                 unset($searchResultsFilter['till']);
@@ -157,14 +157,14 @@  discard block
 block discarded – undo
157 157
 
158 158
             if (isset($dateFilter['gte']) || isset($dateFilter['lte'])) {
159 159
 
160
-                $queryFilter['body']['query']['bool']['must'][] = array('range' => array('distribution_date' => $dateFilter));
160
+                $queryFilter['body']['query']['bool']['must'][] = array ('range' => array ('distribution_date' => $dateFilter));
161 161
 
162 162
             }
163 163
 
164 164
             foreach ($searchResultsFilter as $key => $qry) {
165 165
 
166
-                if(!empty($qry)) {
167
-                    $queryFilter['body']['query']['bool']['must'][] = array('match' => array($key => $qry));
166
+                if (!empty($qry)) {
167
+                    $queryFilter['body']['query']['bool']['must'][] = array ('match' => array ($key => $qry));
168 168
                 }
169 169
 
170 170
             }
@@ -172,7 +172,7 @@  discard block
 block discarded – undo
172 172
         }
173 173
 
174 174
         // document must be active
175
-        if($showDeleted == false) {
175
+        if ($showDeleted == false) {
176 176
 
177 177
             $queryFilter['body']['query']['bool']['must'][]['term']['STATE'] = 'A';
178 178
 
@@ -212,7 +212,7 @@  discard block
 block discarded – undo
212 212
         $luceneReservedCharacters = preg_quote('+-&|!(){}[]^"~?:\\');
213 213
         $string                   = preg_replace_callback(
214 214
             '/([' . $luceneReservedCharacters . '])/',
215
-            function ($matches) {
215
+            function($matches) {
216 216
                 return '\\' . $matches[0];
217 217
             },
218 218
             $string
Please login to merge, or discard this patch.
Braces   +8 added lines, -16 removed lines patch added patch discarded remove patch
@@ -16,8 +16,7 @@  discard block
 block discarded – undo
16 16
 
17 17
 use TYPO3\CMS\Core\Utility\GeneralUtility;
18 18
 
19
-abstract class AbstractSearchController extends \EWW\Dpf\Controller\AbstractController
20
-{
19
+abstract class AbstractSearchController extends \EWW\Dpf\Controller\AbstractController {
21 20
     // search terms
22 21
     private static $terms   = ['_id', 'OWNER_ID', 'submitter', 'project'];
23 22
 
@@ -29,8 +28,7 @@  discard block
 block discarded – undo
29 28
      * @param  array $query elasticsearch search query
30 29
      * @return array        results
31 30
      */
32
-    public function getResultList($query, $type)
33
-    {
31
+    public function getResultList($query, $type) {
34 32
 
35 33
         $elasticSearch = new \EWW\Dpf\Services\ElasticSearch();
36 34
         $results = $elasticSearch->search($query, $type);
@@ -43,8 +41,7 @@  discard block
 block discarded – undo
43 41
      * @param  string $searchString
44 42
      * @return array query
45 43
      */
46
-    public function searchFulltext($searchString)
47
-    {
44
+    public function searchFulltext($searchString) {
48 45
         // don't return query if searchString is empty
49 46
         if (empty($searchString)) {
50 47
             return null;
@@ -67,8 +64,7 @@  discard block
 block discarded – undo
67 64
      * build array for elasticsearch
68 65
      * @return array Elasticsearch query array
69 66
      */
70
-    public function extendedSearch($searchArray = array())
71
-    {
67
+    public function extendedSearch($searchArray = array()) {
72 68
 
73 69
         $query  = array();
74 70
         $filter = array();
@@ -115,8 +111,7 @@  discard block
 block discarded – undo
115 111
      * @param array Elasticsearch query array
116 112
      * @return array Elasticsearch queryFilter array
117 113
      */
118
-    public function resultsFilter($query, $showDeleted = false)
119
-    {
114
+    public function resultsFilter($query, $showDeleted = false) {
120 115
 
121 116
         $queryFilter = array();
122 117
 
@@ -200,8 +195,7 @@  discard block
 block discarded – undo
200 195
      * @param  bool      $intervalEnd Fills missing values with the maximum possible date if true
201 196
      * @return DateTime               Determined date
202 197
      */
203
-    public function convertFormDate($dateString, $intervalEnd = false)
204
-    {
198
+    public function convertFormDate($dateString, $intervalEnd = false) {
205 199
         try {
206 200
             if (strlen($dateString) == 4) {
207 201
                 // assuming year
@@ -222,8 +216,7 @@  discard block
 block discarded – undo
222 216
      * @param $string
223 217
      * @return mixed
224 218
      */
225
-    private function escapeQuery($string)
226
-    {
219
+    private function escapeQuery($string) {
227 220
         $luceneReservedCharacters = preg_quote('+-&|!(){}[]^"~?:\\');
228 221
         $string                   = preg_replace_callback(
229 222
             '/([' . $luceneReservedCharacters . '])/',
@@ -241,8 +234,7 @@  discard block
 block discarded – undo
241 234
      * @param $date
242 235
      * @return string
243 236
      */
244
-    public function formatDate($date)
245
-    {
237
+    public function formatDate($date) {
246 238
         // convert date from dd.mm.yyy to yyyy-dd-mm
247 239
         $date = explode(".", $date);
248 240
         return $date[2] . '-' . $date[1] . '-' . $date[0];
Please login to merge, or discard this patch.
Upper-Lower-Casing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -47,7 +47,7 @@  discard block
 block discarded – undo
47 47
     {
48 48
         // don't return query if searchString is empty
49 49
         if (empty($searchString)) {
50
-            return null;
50
+            return NULL;
51 51
         }
52 52
 
53 53
         $searchString = $this->escapeQuery(trim($searchString));
@@ -57,7 +57,7 @@  discard block
 block discarded – undo
57 57
         $query['body']['query']['bool']['minimum_should_match'] = "1"; // 1
58 58
         $query['body']['query']['bool']['should'][1]['has_child']['child_type'] = "datastream"; // 1
59 59
 
60
-        $query = $this->resultsFilter($query, false);
60
+        $query = $this->resultsFilter($query, FALSE);
61 61
 
62 62
         return $query;
63 63
 
@@ -85,13 +85,13 @@  discard block
 block discarded – undo
85 85
 
86 86
             } elseif (!empty($qry) && $key == 'from') {
87 87
 
88
-                if ($dateTime = $this->convertFormDate($qry, false)) {
88
+                if ($dateTime = $this->convertFormDate($qry, FALSE)) {
89 89
                     $filter['gte'] = $dateTime->format('Y-m-d');
90 90
                 }
91 91
 
92 92
             } elseif (!empty($qry) && $key == 'till') {
93 93
 
94
-                if ($dateTime = $this->convertFormDate($qry, true)) {
94
+                if ($dateTime = $this->convertFormDate($qry, TRUE)) {
95 95
                     $filter['lte'] = $dateTime->format('Y-m-d');
96 96
                 }
97 97
 
@@ -104,7 +104,7 @@  discard block
 block discarded – undo
104 104
 
105 105
         }
106 106
 
107
-        $showDeleted = ($searchArray['showDeleted'] == 'true') ? true : false;
107
+        $showDeleted = ($searchArray['showDeleted'] == 'true') ? TRUE : FALSE;
108 108
         $query = $this->resultsFilter($query, $showDeleted);
109 109
         return $query;
110 110
 
@@ -115,7 +115,7 @@  discard block
 block discarded – undo
115 115
      * @param array Elasticsearch query array
116 116
      * @return array Elasticsearch queryFilter array
117 117
      */
118
-    public function resultsFilter($query, $showDeleted = false)
118
+    public function resultsFilter($query, $showDeleted = FALSE)
119 119
     {
120 120
 
121 121
         $queryFilter = array();
@@ -142,7 +142,7 @@  discard block
 block discarded – undo
142 142
             if ($searchResultsFilter['from']) {
143 143
 
144 144
                 $from     = date('d.m.Y', $searchResultsFilter['from']);
145
-                $dateTime = $this->convertFormDate($from, false);
145
+                $dateTime = $this->convertFormDate($from, FALSE);
146 146
                 $dateFilter['gte'] = $dateTime->format('Y-m-d');
147 147
                 unset($searchResultsFilter['from']);
148 148
 
@@ -151,7 +151,7 @@  discard block
 block discarded – undo
151 151
             if ($searchResultsFilter['till']) {
152 152
 
153 153
                 $till          = date('d.m.Y', $searchResultsFilter['till']);
154
-                $dateTime = $this->convertFormDate($till, true);
154
+                $dateTime = $this->convertFormDate($till, TRUE);
155 155
                 $dateFilter['lte'] = $dateTime->format('Y-m-d');
156 156
                 unset($searchResultsFilter['till']);
157 157
 
@@ -174,7 +174,7 @@  discard block
 block discarded – undo
174 174
         }
175 175
 
176 176
         // document must be active
177
-        if($showDeleted == false) {
177
+        if($showDeleted == FALSE) {
178 178
 
179 179
             $queryFilter['body']['query']['bool']['must'][]['term']['STATE'] = 'A';
180 180
 
@@ -200,7 +200,7 @@  discard block
 block discarded – undo
200 200
      * @param  bool      $intervalEnd Fills missing values with the maximum possible date if true
201 201
      * @return DateTime               Determined date
202 202
      */
203
-    public function convertFormDate($dateString, $intervalEnd = false)
203
+    public function convertFormDate($dateString, $intervalEnd = FALSE)
204 204
     {
205 205
         try {
206 206
             if (strlen($dateString) == 4) {
@@ -213,7 +213,7 @@  discard block
 block discarded – undo
213 213
                 return new \DateTime($dateString);
214 214
             }
215 215
         } catch (Exception $_) {
216
-            return false;
216
+            return FALSE;
217 217
         }
218 218
     }
219 219
 
Please login to merge, or discard this patch.