Completed
Push — master ( 686b54...ec5bd5 )
by Mark
06:38
created
code/ShopSearchAdapter.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -17,5 +17,5 @@
 block discarded – undo
17 17
      * @param string $sort [optional]
18 18
      * @return ArrayData - must contain at least 'Matches' with an list of data objects that match the search
19 19
      */
20
-    public function searchFromVars($keywords, array $filters=array(), array $facetSpec=array(), $start=-1, $limit=-1, $sort='');
20
+    public function searchFromVars($keywords, array $filters = array(), array $facetSpec = array(), $start = -1, $limit = -1, $sort = '');
21 21
 }
Please login to merge, or discard this patch.
code/helpers/FacetedCategory.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -73,7 +73,7 @@  discard block
 block discarded – undo
73 73
      */
74 74
     protected function getFilters()
75 75
     {
76
-        $qs_f       = Config::inst()->get('ShopSearch', 'qs_filters');
76
+        $qs_f = Config::inst()->get('ShopSearch', 'qs_filters');
77 77
         if (!$qs_f) {
78 78
             return array();
79 79
         }
@@ -90,7 +90,7 @@  discard block
 block discarded – undo
90 90
      * @param bool $recursive
91 91
      * @return mixed
92 92
      */
93
-    public function FilteredProducts($recursive=true)
93
+    public function FilteredProducts($recursive = true)
94 94
     {
95 95
         if (!isset($this->_filteredProducts)) {
96 96
             $fn = Config::inst()->get('FacetedCategory', 'products_method');
@@ -124,7 +124,7 @@  discard block
 block discarded – undo
124 124
      */
125 125
     public function Facets()
126 126
     {
127
-        $spec       = $this->getFacetSpec();
127
+        $spec = $this->getFacetSpec();
128 128
         if (empty($spec)) {
129 129
             return new ArrayList;
130 130
         }
Please login to merge, or discard this patch.
code/helpers/ProductCategoryHelperMethods.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -16,7 +16,7 @@
 block discarded – undo
16 16
      * @param bool $recursive [optional] - include the parents of the categories as well? - default: true
17 17
      * @return array - array of productCategory records
18 18
      */
19
-    protected function buildParentCategoriesArray($recursive=true)
19
+    protected function buildParentCategoriesArray($recursive = true)
20 20
     {
21 21
         $out = array();
22 22
 
Please login to merge, or discard this patch.
code/adapters/ShopSearchMysql.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -19,7 +19,7 @@
 block discarded – undo
19 19
      * @param string $sort [optional]
20 20
      * @return ArrayData
21 21
      */
22
-    public function searchFromVars($keywords, array $filters=array(), array $facetSpec=array(), $start=-1, $limit=-1, $sort='')
22
+    public function searchFromVars($keywords, array $filters = array(), array $facetSpec = array(), $start = -1, $limit = -1, $sort = '')
23 23
     {
24 24
         $searchable = ShopSearch::get_searchable_classes();
25 25
         $matches = new ArrayList;
Please login to merge, or discard this patch.
code/ShopSearchForm.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -55,13 +55,13 @@  discard block
 block discarded – undo
55 55
             $this->addExtraClass($c);
56 56
         }
57 57
 
58
-        Requirements::css(SHOP_SEARCH_FOLDER . '/css/ShopSearch.css');
58
+        Requirements::css(SHOP_SEARCH_FOLDER.'/css/ShopSearch.css');
59 59
 
60 60
         if (Config::inst()->get('ShopSearch', 'suggest_enabled')) {
61
-            Requirements::javascript(THIRDPARTY_DIR . '/jquery-ui/jquery-ui.js');
62
-            Requirements::css(THIRDPARTY_DIR . '/jquery-ui-themes/smoothness/jquery-ui.css');
63
-            Requirements::javascript(SHOP_SEARCH_FOLDER . '/javascript/search.suggest.js');
64
-            Requirements::javascript(SHOP_SEARCH_FOLDER . '/javascript/search.js');
61
+            Requirements::javascript(THIRDPARTY_DIR.'/jquery-ui/jquery-ui.js');
62
+            Requirements::css(THIRDPARTY_DIR.'/jquery-ui-themes/smoothness/jquery-ui.css');
63
+            Requirements::javascript(SHOP_SEARCH_FOLDER.'/javascript/search.suggest.js');
64
+            Requirements::javascript(SHOP_SEARCH_FOLDER.'/javascript/search.js');
65 65
         }
66 66
     }
67 67
 
@@ -124,7 +124,7 @@  discard block
 block discarded – undo
124 124
         $sortParams = array_merge($data, array($qs_sort => 'NEWSORTVALUE'));
125 125
         unset($sortParams['url']);
126 126
         $results->SortControl = DropdownField::create($qs_sort, ShopSearch::config()->sort_label, $options, $results->Sort)
127
-            ->setAttribute('data-url', $baseLink . '?' . http_build_query($sortParams));
127
+            ->setAttribute('data-url', $baseLink.'?'.http_build_query($sortParams));
128 128
 
129 129
         // a little more output management
130 130
         $results->Title = "Search Results";
Please login to merge, or discard this patch.
code/ShopSearch.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -135,9 +135,9 @@  discard block
 block discarded – undo
135 135
         }
136 136
 
137 137
         foreach ($cats as $cat) {
138
-            $out[$cat->ID] = $prefix . $cat->Title;
138
+            $out[$cat->ID] = $prefix.$cat->Title;
139 139
             if ($maxDepth > 1) {
140
-                $out += self::get_category_hierarchy($cat->ID, $prefix . $cat->Title . ' > ', $maxDepth - 1);
140
+                $out += self::get_category_hierarchy($cat->ID, $prefix.$cat->Title.' > ', $maxDepth - 1);
141 141
             }
142 142
         }
143 143
 
@@ -175,13 +175,13 @@  discard block
 block discarded – undo
175 175
      * @param int $limit [optional]
176 176
      * @return ArrayData
177 177
      */
178
-    public function search(array $vars, $logSearch=true, $useFacets=true, $start=-1, $limit=-1)
178
+    public function search(array $vars, $logSearch = true, $useFacets = true, $start = -1, $limit = -1)
179 179
     {
180 180
         $qs_q   = $this->config()->get('qs_query');
181 181
         $qs_f   = $this->config()->get('qs_filters');
182 182
         $qs_ps  = $this->config()->get('qs_parent_search');
183 183
         $qs_t   = $this->config()->get('qs_title');
184
-        $qs_sort= $this->config()->get('qs_sort');
184
+        $qs_sort = $this->config()->get('qs_sort');
185 185
         if ($limit < 0) {
186 186
             $limit  = $this->config()->get('page_size');
187 187
         }
@@ -211,7 +211,7 @@  discard block
 block discarded – undo
211 211
         if ($keywordRegex = $this->config()->get('keyword_filter_regex')) {
212 212
             $keywords = preg_replace($keywordRegex, '', $keywords);
213 213
         }
214
-        $results  = self::adapter()->searchFromVars($keywords, $filters, $facets, $start, $limit, $sort);
214
+        $results = self::adapter()->searchFromVars($keywords, $filters, $facets, $start, $limit, $sort);
215 215
 
216 216
         // massage the results a bit
217 217
         if (!empty($keywords) && !$results->hasValue('Query')) {
@@ -269,7 +269,7 @@  discard block
 block discarded – undo
269 269
      * @param string $str
270 270
      * @return SS_Query
271 271
      */
272
-    public function getSuggestQuery($str='')
272
+    public function getSuggestQuery($str = '')
273 273
     {
274 274
         $hasResults = 'CASE WHEN max("SearchLog"."NumResults") > 0 THEN 1 ELSE 0 END';
275 275
         $searchCount = 'count(distinct "SearchLog"."ID")';
@@ -301,7 +301,7 @@  discard block
 block discarded – undo
301 301
      * @param string $str
302 302
      * @return array
303 303
      */
304
-    public function suggest($str='')
304
+    public function suggest($str = '')
305 305
     {
306 306
         $adapter = self::adapter();
307 307
         if ($adapter->hasMethod('suggest')) {
@@ -349,7 +349,7 @@  discard block
 block discarded – undo
349 349
                 ? $results['products']->getTotalItems()
350 350
                 : $results['products']->count();
351 351
 
352
-            $products   = array();
352
+            $products = array();
353 353
             foreach ($results['products'] as $prod) {
354 354
                 if (!$prod || !$prod->exists()) {
355 355
                     continue;
@@ -358,7 +358,7 @@  discard block
 block discarded – undo
358 358
                 $thumb = ($img && $img->exists()) ? $img->getThumbnail() : null;
359 359
 
360 360
                 $json = array(
361
-                    'link'  => $prod->Link() . '?' . ShopSearch::config()->qs_source . '=' . urlencode(base64_encode(json_encode($searchVars))),
361
+                    'link'  => $prod->Link().'?'.ShopSearch::config()->qs_source.'='.urlencode(base64_encode(json_encode($searchVars))),
362 362
                     'title' => $prod->Title,
363 363
                     'desc'  => $prod->obj('Content')->Summary(),
364 364
                     'thumb' => $thumb ? $thumb->Link() : '',
Please login to merge, or discard this patch.
code/helpers/VirtualFieldIndexQueuedJob.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -50,7 +50,7 @@
 block discarded – undo
50 50
     public function getTitle()
51 51
     {
52 52
         $obj = $this->getObject();
53
-        return "Update Virtual Field Indexes: " . ($obj ? $obj->getTitle() : '???');
53
+        return "Update Virtual Field Indexes: ".($obj ? $obj->getTitle() : '???');
54 54
     }
55 55
 
56 56
 
Please login to merge, or discard this patch.
code/helpers/FacetHelper.php 1 patch
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -67,7 +67,7 @@  discard block
 block discarded – undo
67 67
      * @param DataObject|string $sing - just a singleton object we can get information off of
68 68
      * @return DataList
69 69
      */
70
-    public function addFiltersToDataList($list, array $filters, $sing=null)
70
+    public function addFiltersToDataList($list, array $filters, $sing = null)
71 71
     {
72 72
         if (!$sing) {
73 73
             $sing = singleton($list->dataClass());
@@ -117,14 +117,14 @@  discard block
 block discarded – undo
117 117
         if ($rec->hasExtension('VirtualFieldIndex') && ($spec = $rec->getVFISpec($filterField))) {
118 118
             if ($spec['Type'] == VirtualFieldIndex::TYPE_LIST) {
119 119
                 // Lists have to be handled a little differently
120
-                $f = $rec->getVFIFieldName($filterField) . ':PartialMatch';
120
+                $f = $rec->getVFIFieldName($filterField).':PartialMatch';
121 121
                 if (is_array($filterVal)) {
122 122
                     foreach ($filterVal as &$val) {
123
-                        $val = '|' . $val . '|';
123
+                        $val = '|'.$val.'|';
124 124
                     }
125 125
                     return array($f => $filterVal);
126 126
                 } else {
127
-                    return array($f => '|' . $filterVal . '|');
127
+                    return array($f => '|'.$filterVal.'|');
128 128
                 }
129 129
             } else {
130 130
                 // Simples are simple
@@ -170,7 +170,7 @@  discard block
 block discarded – undo
170 170
                 $facets[$field]['Source'] = $field;
171 171
             }
172 172
             if (empty($facets[$field]['Type'])) {
173
-                $facets[$field]['Type']  = ShopSearch::FACET_TYPE_LINK;
173
+                $facets[$field]['Type'] = ShopSearch::FACET_TYPE_LINK;
174 174
             }
175 175
 
176 176
             if (empty($facets[$field]['Values'])) {
@@ -178,7 +178,7 @@  discard block
 block discarded – undo
178 178
             } else {
179 179
                 $vals = $facets[$field]['Values'];
180 180
                 if (is_string($vals)) {
181
-                    $vals = eval('return ' . $vals . ';');
181
+                    $vals = eval('return '.$vals.';');
182 182
                 }
183 183
                 $facets[$field]['Values'] = array();
184 184
                 foreach ($vals as $val => $lbl) {
@@ -222,7 +222,7 @@  discard block
 block discarded – undo
222 222
      * @param bool $autoFacetAttributes [optional]
223 223
      * @return ArrayList
224 224
      */
225
-    public function buildFacets(SS_List $matches, array $facetSpec, $autoFacetAttributes=false)
225
+    public function buildFacets(SS_List $matches, array $facetSpec, $autoFacetAttributes = false)
226 226
     {
227 227
         $facets = $this->expandFacetSpec($facetSpec);
228 228
         if (!$autoFacetAttributes && (empty($facets) || !$matches || !$matches->count())) {
@@ -401,7 +401,7 @@  discard block
 block discarded – undo
401 401
 
402 402
         $facet['Values'] = array();
403 403
         foreach ($q as $row) {
404
-            $facet['Values'][ $row['Value'] ] = new ArrayData($row);
404
+            $facet['Values'][$row['Value']] = new ArrayData($row);
405 405
         }
406 406
     }
407 407
 
@@ -461,7 +461,7 @@  discard block
 block discarded – undo
461 461
 
462 462
             unset($row['TypeID']);
463 463
             unset($row['TypeLabel']);
464
-            $curFacet['Values'][ $row['Value'] ] = new ArrayData($row);
464
+            $curFacet['Values'][$row['Value']] = new ArrayData($row);
465 465
         }
466 466
 
467 467
         if ($curType > 0) {
@@ -493,8 +493,8 @@  discard block
 block discarded – undo
493 493
                         $params[$qs_f] = array();
494 494
                     }
495 495
                     $params[$qs_f][$facet->Source] = 'RANGEFACETVALUE';
496
-                    $params[$qs_t] = $facet->Label . ': RANGEFACETLABEL';
497
-                    $facet->Link = $baseLink . '?' . http_build_query($params);
496
+                    $params[$qs_t] = $facet->Label.': RANGEFACETLABEL';
497
+                    $facet->Link = $baseLink.'?'.http_build_query($params);
498 498
                 break;
499 499
 
500 500
                 case ShopSearch::FACET_TYPE_CHECKBOX;
@@ -517,14 +517,14 @@  discard block
 block discarded – undo
517 517
                         }
518 518
                         if ($facet->Type == ShopSearch::FACET_TYPE_CHECKBOX) {
519 519
                             unset($params[$qs_f][$facet->Source]); // this will be figured out via javascript
520
-                            $params[$qs_t] = ($value->Active ? 'Remove ' : '') . $facet->Label . ': ' . $value->Label;
520
+                            $params[$qs_t] = ($value->Active ? 'Remove ' : '').$facet->Label.': '.$value->Label;
521 521
                         } else {
522 522
                             $params[$qs_f][$facet->Source] = $value->Value;
523
-                            $params[$qs_t] = $facet->Label . ': ' . $value->Label;
523
+                            $params[$qs_t] = $facet->Label.': '.$value->Label;
524 524
                         }
525 525
 
526 526
                         // build a new link
527
-                        $value->Link = $baseLink . '?' . http_build_query($params);
527
+                        $value->Link = $baseLink.'?'.http_build_query($params);
528 528
                     }
529 529
             }
530 530
         }
@@ -599,7 +599,7 @@  discard block
 block discarded – undo
599 599
      * @param bool      $filterOnlyLeaves [optional]
600 600
      * @return bool - true if any of the children are true, false if all children are false
601 601
      */
602
-    protected function updateCheckboxFacetState(ArrayList $values, array $filterVals, $filterOnlyLeaves=false)
602
+    protected function updateCheckboxFacetState(ArrayList $values, array $filterVals, $filterOnlyLeaves = false)
603 603
     {
604 604
         $out = false;
605 605
 
@@ -651,7 +651,7 @@  discard block
 block discarded – undo
651 651
 
652 652
                     // Look for the most recent parent that matches the beginning of this one
653 653
                     while (count($parentStack) > 0) {
654
-                        $curParent = $parentStack[ count($parentStack)-1 ];
654
+                        $curParent = $parentStack[count($parentStack) - 1];
655 655
                         if (strpos($value->Label, $curParent->FullLabel) === 0) {
656 656
                             if (!isset($curParent->Children)) {
657 657
                                 $curParent->Children = new ArrayList();
Please login to merge, or discard this patch.
code/helpers/VirtualFieldIndex.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -89,7 +89,7 @@  discard block
 block discarded – undo
89 89
         );
90 90
 
91 91
         foreach ($vfi_def as $field => $spec) {
92
-            $fn = 'VFI_' . $field;
92
+            $fn = 'VFI_'.$field;
93 93
             $out['db'][$fn] = isset($spec['DBField']) ? $spec['DBField'] : 'Varchar(255)';
94 94
             $out['indexes'][$fn] = true;
95 95
         }
@@ -158,7 +158,7 @@  discard block
 block discarded – undo
158 158
      *
159 159
      * @param string $class [optional] - if not given all indexes will be rebuilt
160 160
      */
161
-    public static function build($class='')
161
+    public static function build($class = '')
162 162
     {
163 163
         if ($class) {
164 164
             $list   = DataObject::get($class);
@@ -248,7 +248,7 @@  discard block
 block discarded – undo
248 248
      */
249 249
     public function getVFIFieldName($name)
250 250
     {
251
-        return 'VFI_' . $name;
251
+        return 'VFI_'.$name;
252 252
     }
253 253
 
254 254
 
@@ -273,7 +273,7 @@  discard block
 block discarded – undo
273 273
      * @param bool   $forceIDs [optional] - if true, it will return an ID even if the norm is to return a DataObject
274 274
      * @return string|array|SS_List
275 275
      */
276
-    public function getVFI($field, $fromSource=false, $forceIDs=false)
276
+    public function getVFI($field, $fromSource = false, $forceIDs = false)
277 277
     {
278 278
         $spec = $this->getVFISpec($field);
279 279
         if (!$spec) {
@@ -330,9 +330,9 @@  discard block
 block discarded – undo
330 330
             foreach ($list as $rec) {
331 331
                 $ids[] = $rec->ID;
332 332
             }
333
-            $val = '>' . $list[0]->ClassName . '|' . implode('|', $ids) . '|';
333
+            $val = '>'.$list[0]->ClassName.'|'.implode('|', $ids).'|';
334 334
         } else {
335
-            $val = '|' . implode('|', $list) . '|';
335
+            $val = '|'.implode('|', $list).'|';
336 336
         }
337 337
 
338 338
         return $val;
@@ -344,14 +344,14 @@  discard block
 block discarded – undo
344 344
      * @param bool   $forceIDs [optional] - if true encoded objects will not be returned as objects but as id's
345 345
      * @return array
346 346
      */
347
-    protected static function decode_list($val, $forceIDs=false)
347
+    protected static function decode_list($val, $forceIDs = false)
348 348
     {
349 349
         if ($val[0] == '>') {
350 350
             $firstBar = strpos($val, '|');
351 351
             if ($firstBar < 3) {
352 352
                 return array();
353 353
             }
354
-            $className = substr($val, 1, $firstBar-1);
354
+            $className = substr($val, 1, $firstBar - 1);
355 355
             $ids = explode('|', trim(substr($val, $firstBar), '|'));
356 356
             return $forceIDs ? $ids : DataObject::get($className)->filter('ID', $ids)->toArray();
357 357
         } else {
Please login to merge, or discard this patch.