@@ -171,12 +171,12 @@ discard block |
||
| 171 | 171 | * @param int $limit [optional] |
| 172 | 172 | * @return ArrayData |
| 173 | 173 | */ |
| 174 | - public function search(array $vars, $logSearch=true, $useFacets=true, $start=-1, $limit=-1) { |
|
| 174 | + public function search(array $vars, $logSearch = true, $useFacets = true, $start = -1, $limit = -1) { |
|
| 175 | 175 | $qs_q = $this->config()->get('qs_query'); |
| 176 | 176 | $qs_f = $this->config()->get('qs_filters'); |
| 177 | 177 | $qs_ps = $this->config()->get('qs_parent_search'); |
| 178 | 178 | $qs_t = $this->config()->get('qs_title'); |
| 179 | - $qs_sort= $this->config()->get('qs_sort'); |
|
| 179 | + $qs_sort = $this->config()->get('qs_sort'); |
|
| 180 | 180 | if ($limit < 0) $limit = $this->config()->get('page_size'); |
| 181 | 181 | if ($start < 0) $start = !empty($vars['start']) ? (int)$vars['start'] : 0; // as far as i can see, fulltextsearch hard codes 'start' |
| 182 | 182 | $facets = $useFacets ? $this->config()->get('facets') : array(); |
@@ -187,7 +187,7 @@ discard block |
||
| 187 | 187 | $sortOptions = $this->config()->get('sort_options'); |
| 188 | 188 | $sort = !empty($vars[$qs_sort]) ? $vars[$qs_sort] : ''; |
| 189 | 189 | if (!isset($sortOptions[$sort])) { |
| 190 | - $sort = current(array_keys($sortOptions)); |
|
| 190 | + $sort = current(array_keys($sortOptions)); |
|
| 191 | 191 | } |
| 192 | 192 | |
| 193 | 193 | // figure out and scrub the filters |
@@ -198,7 +198,7 @@ discard block |
||
| 198 | 198 | if ($keywordRegex = $this->config()->get('keyword_filter_regex')) { |
| 199 | 199 | $keywords = preg_replace($keywordRegex, '', $keywords); |
| 200 | 200 | } |
| 201 | - $results = self::adapter()->searchFromVars($keywords, $filters, $facets, $start, $limit, $sort); |
|
| 201 | + $results = self::adapter()->searchFromVars($keywords, $filters, $facets, $start, $limit, $sort); |
|
| 202 | 202 | |
| 203 | 203 | // massage the results a bit |
| 204 | 204 | if (!empty($keywords) && !$results->hasValue('Query')) $results->Query = $keywords; |
@@ -250,7 +250,7 @@ discard block |
||
| 250 | 250 | * @param string $str |
| 251 | 251 | * @return SS_Query |
| 252 | 252 | */ |
| 253 | - public function getSuggestQuery($str='') { |
|
| 253 | + public function getSuggestQuery($str = '') { |
|
| 254 | 254 | $hasResults = 'CASE WHEN max("SearchLog"."NumResults") > 0 THEN 1 ELSE 0 END'; |
| 255 | 255 | $searchCount = 'count(distinct "SearchLog"."ID")'; |
| 256 | 256 | $q = new SQLQuery(); |
@@ -281,7 +281,7 @@ discard block |
||
| 281 | 281 | * @param string $str |
| 282 | 282 | * @return array |
| 283 | 283 | */ |
| 284 | - public function suggest($str='') { |
|
| 284 | + public function suggest($str = '') { |
|
| 285 | 285 | $adapter = self::adapter(); |
| 286 | 286 | if ($adapter->hasMethod('suggest')) { |
| 287 | 287 | return $adapter->suggest($str); |
@@ -327,7 +327,7 @@ discard block |
||
| 327 | 327 | ? $results['products']->getTotalItems() |
| 328 | 328 | : $results['products']->count(); |
| 329 | 329 | |
| 330 | - $products = array(); |
|
| 330 | + $products = array(); |
|
| 331 | 331 | foreach ($results['products'] as $prod) { |
| 332 | 332 | if (!$prod || !$prod->exists()) continue; |
| 333 | 333 | $img = $prod->hasMethod('ProductImage') ? $prod->ProductImage() : $prod->Image(); |
@@ -17,5 +17,5 @@ |
||
| 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 | - function searchFromVars($keywords, array $filters=array(), array $facetSpec=array(), $start=-1, $limit=-1, $sort=''); |
|
| 20 | + function searchFromVars($keywords, array $filters = array(), array $facetSpec = array(), $start = -1, $limit = -1, $sort = ''); |
|
| 21 | 21 | } |
@@ -30,7 +30,7 @@ discard block |
||
| 30 | 30 | // convert the search results into usable json for search-as-you-type |
| 31 | 31 | if (ShopSearch::config()->search_as_you_type_enabled) { |
| 32 | 32 | $searchVars = $req->requestVars(); |
| 33 | - $searchVars[ ShopSearch::config()->qs_query ] = $searchVars['term']; |
|
| 33 | + $searchVars[ShopSearch::config()->qs_query] = $searchVars['term']; |
|
| 34 | 34 | unset($searchVars['term']); |
| 35 | 35 | $results = ShopSearch::inst()->suggestWithResults($searchVars); |
| 36 | 36 | } else { |
@@ -56,7 +56,7 @@ discard block |
||
| 56 | 56 | */ |
| 57 | 57 | public function onAfterInit() { |
| 58 | 58 | $req = $this->owner->getRequest(); |
| 59 | - $src = $req->requestVar( Config::inst()->get('ShopSearch', 'qs_source') ); |
|
| 59 | + $src = $req->requestVar(Config::inst()->get('ShopSearch', 'qs_source')); |
|
| 60 | 60 | if ($src) { |
| 61 | 61 | $qs_q = Config::inst()->get('ShopSearch', 'qs_query'); |
| 62 | 62 | $qs_f = Config::inst()->get('ShopSearch', 'qs_filters'); |
@@ -38,7 +38,7 @@ |
||
| 38 | 38 | |
| 39 | 39 | $emptyString = self::config()->category_empty_string; |
| 40 | 40 | if ($emptyString !== 'NONE') { |
| 41 | - $catField->setEmptyString(_t('ShopSearch.'.$emptyString, $emptyString)); |
|
| 41 | + $catField->setEmptyString(_t('ShopSearch.' . $emptyString, $emptyString)); |
|
| 42 | 42 | } |
| 43 | 43 | |
| 44 | 44 | $fields->push($catField); |
@@ -18,7 +18,7 @@ discard block |
||
| 18 | 18 | * @param string $sort [optional] |
| 19 | 19 | * @return ArrayData |
| 20 | 20 | */ |
| 21 | - function searchFromVars($keywords, array $filters=array(), array $facetSpec=array(), $start=-1, $limit=-1, $sort='') { |
|
| 21 | + function searchFromVars($keywords, array $filters = array(), array $facetSpec = array(), $start = -1, $limit = -1, $sort = '') { |
|
| 22 | 22 | $searchable = ShopSearch::get_searchable_classes(); |
| 23 | 23 | $matches = new ArrayList; |
| 24 | 24 | |
@@ -32,13 +32,13 @@ discard block |
||
| 32 | 32 | $filter = array(); |
| 33 | 33 | |
| 34 | 34 | // Use parametrized query if SilverStripe >= 3.2 |
| 35 | - if(SHOP_SEARCH_IS_SS32){ |
|
| 36 | - foreach($keywordFields as $indexFields){ |
|
| 35 | + if (SHOP_SEARCH_IS_SS32) { |
|
| 36 | + foreach ($keywordFields as $indexFields) { |
|
| 37 | 37 | $filter[] = array("MATCH ($indexFields) AGAINST (?)" => $keywords); |
| 38 | 38 | } |
| 39 | 39 | $list = $list->whereAny($filter); |
| 40 | 40 | } else { |
| 41 | - foreach($keywordFields as $indexFields){ |
|
| 41 | + foreach ($keywordFields as $indexFields) { |
|
| 42 | 42 | $filter[] = sprintf("MATCH ($indexFields) AGAINST ('%s')", Convert::raw2sql($keywords)); |
| 43 | 43 | } |
| 44 | 44 | // join all the filters with an "OR" statement |
@@ -78,7 +78,7 @@ discard block |
||
| 78 | 78 | } |
| 79 | 79 | } |
| 80 | 80 | |
| 81 | - if(count($indexList) === 0){ |
|
| 81 | + if (count($indexList) === 0) { |
|
| 82 | 82 | throw new Exception("Class $className does not appear to have any fulltext indexes"); |
| 83 | 83 | } |
| 84 | 84 | |
@@ -19,7 +19,7 @@ discard block |
||
| 19 | 19 | * @param string $sort [optional] |
| 20 | 20 | * @return ArrayData |
| 21 | 21 | */ |
| 22 | - function searchFromVars($keywords, array $filters=array(), array $facetSpec=array(), $start=-1, $limit=-1, $sort='') { |
|
| 22 | + function searchFromVars($keywords, array $filters = array(), array $facetSpec = array(), $start = -1, $limit = -1, $sort = '') { |
|
| 23 | 23 | $searchable = ShopSearch::get_searchable_classes(); |
| 24 | 24 | $matches = new ArrayList; |
| 25 | 25 | |
@@ -32,7 +32,7 @@ discard block |
||
| 32 | 32 | // convert that list into something we can pass to Datalist::filter |
| 33 | 33 | $keywordFilter = array(); |
| 34 | 34 | if (!empty($keywords)) { |
| 35 | - foreach($keywordFields as $searchField) { |
|
| 35 | + foreach ($keywordFields as $searchField) { |
|
| 36 | 36 | $name = (strpos($searchField, ':') !== FALSE) ? $searchField : "$searchField:PartialMatch"; |
| 37 | 37 | $keywordFilter[$name] = $keywords; |
| 38 | 38 | } |
@@ -63,15 +63,15 @@ discard block |
||
| 63 | 63 | protected function scaffoldSearchFields($dataClass) { |
| 64 | 64 | $obj = singleton($dataClass); |
| 65 | 65 | $fields = null; |
| 66 | - if($fieldSpecs = $obj->searchableFields()) { |
|
| 66 | + if ($fieldSpecs = $obj->searchableFields()) { |
|
| 67 | 67 | $customSearchableFields = $obj->stat('searchable_fields'); |
| 68 | - foreach($fieldSpecs as $name => $spec) { |
|
| 69 | - if(is_array($spec) && array_key_exists('filter', $spec)) { |
|
| 68 | + foreach ($fieldSpecs as $name => $spec) { |
|
| 69 | + if (is_array($spec) && array_key_exists('filter', $spec)) { |
|
| 70 | 70 | // The searchableFields() spec defaults to PartialMatch, |
| 71 | 71 | // so we need to check the original setting. |
| 72 | 72 | // If the field is defined $searchable_fields = array('MyField'), |
| 73 | 73 | // then default to StartsWith filter, which makes more sense in this context. |
| 74 | - if(!$customSearchableFields || array_search($name, $customSearchableFields)) { |
|
| 74 | + if (!$customSearchableFields || array_search($name, $customSearchableFields)) { |
|
| 75 | 75 | $filter = 'PartialMatch'; |
| 76 | 76 | } else { |
| 77 | 77 | $filter = preg_replace('/Filter$/', '', $spec['filter']); |
@@ -234,7 +234,7 @@ discard block |
||
| 234 | 234 | * @param string $sort [optional] |
| 235 | 235 | * @return ArrayData |
| 236 | 236 | */ |
| 237 | - public function searchFromVars($keywords, array $filters=array(), array $facetSpec=array(), $start=-1, $limit=-1, $sort='score desc') { |
|
| 237 | + public function searchFromVars($keywords, array $filters = array(), array $facetSpec = array(), $start = -1, $limit = -1, $sort = 'score desc') { |
|
| 238 | 238 | $query = new SearchQuery(); |
| 239 | 239 | $params = array( |
| 240 | 240 | 'sort' => $sort, |
@@ -349,11 +349,11 @@ discard block |
||
| 349 | 349 | $classq = array(); |
| 350 | 350 | |
| 351 | 351 | foreach ($query->classes as $class) { |
| 352 | - if (!empty($class['includeSubclasses'])) $classq[] = 'ClassHierarchy:'.$class['class']; |
|
| 353 | - else $classq[] = 'ClassName:'.$class['class']; |
|
| 352 | + if (!empty($class['includeSubclasses'])) $classq[] = 'ClassHierarchy:' . $class['class']; |
|
| 353 | + else $classq[] = 'ClassName:' . $class['class']; |
|
| 354 | 354 | } |
| 355 | 355 | |
| 356 | - if ($classq) $fq[] = '+('.implode(' ', $classq).')'; |
|
| 356 | + if ($classq) $fq[] = '+(' . implode(' ', $classq) . ')'; |
|
| 357 | 357 | |
| 358 | 358 | // Filter by filters |
| 359 | 359 | foreach ($query->require as $field => $values) { |
@@ -372,11 +372,11 @@ discard block |
||
| 372 | 372 | $requireq[] = "$field:[$start TO $end]"; |
| 373 | 373 | } |
| 374 | 374 | else { |
| 375 | - $requireq[] = $field.':"'.$value.'"'; |
|
| 375 | + $requireq[] = $field . ':"' . $value . '"'; |
|
| 376 | 376 | } |
| 377 | 377 | } |
| 378 | 378 | |
| 379 | - $fq[] = '+('.implode(' ', $requireq).')'; |
|
| 379 | + $fq[] = '+(' . implode(' ', $requireq) . ')'; |
|
| 380 | 380 | } |
| 381 | 381 | |
| 382 | 382 | foreach ($query->exclude as $field => $values) { |
@@ -396,11 +396,11 @@ discard block |
||
| 396 | 396 | $excludeq[] = "$field:[$start TO $end]"; |
| 397 | 397 | } |
| 398 | 398 | else { |
| 399 | - $excludeq[] = $field.':"'.$value.'"'; |
|
| 399 | + $excludeq[] = $field . ':"' . $value . '"'; |
|
| 400 | 400 | } |
| 401 | 401 | } |
| 402 | 402 | |
| 403 | - $fq[] = ($missing ? "+{$field}:[* TO *] " : '') . '-('.implode(' ', $excludeq).')'; |
|
| 403 | + $fq[] = ($missing ? "+{$field}:[* TO *] " : '') . '-(' . implode(' ', $excludeq) . ')'; |
|
| 404 | 404 | } |
| 405 | 405 | |
| 406 | 406 | // if(!headers_sent()) { |
@@ -419,10 +419,10 @@ discard block |
||
| 419 | 419 | ); |
| 420 | 420 | |
| 421 | 421 | $results = new ArrayList(); |
| 422 | - if($res->getHttpStatus() >= 200 && $res->getHttpStatus() < 300) { |
|
| 422 | + if ($res->getHttpStatus() >= 200 && $res->getHttpStatus() < 300) { |
|
| 423 | 423 | foreach ($res->response->docs as $doc) { |
| 424 | 424 | $result = DataObject::get_by_id($doc->ClassName, $doc->ID); |
| 425 | - if($result) { |
|
| 425 | + if ($result) { |
|
| 426 | 426 | $results->push($result); |
| 427 | 427 | } |
| 428 | 428 | } |
@@ -509,17 +509,17 @@ discard block |
||
| 509 | 509 | |
| 510 | 510 | foreach ($parts[0] as $part) { |
| 511 | 511 | $fields = (isset($search['fields'])) ? $search['fields'] : array(); |
| 512 | - if(isset($search['boost'])) $fields = array_merge($fields, array_keys($search['boost'])); |
|
| 512 | + if (isset($search['boost'])) $fields = array_merge($fields, array_keys($search['boost'])); |
|
| 513 | 513 | if ($fields) { |
| 514 | 514 | $searchq = array(); |
| 515 | 515 | foreach ($fields as $field) { |
| 516 | 516 | $boost = (isset($search['boost'][$field])) ? '^' . $search['boost'][$field] : ''; |
| 517 | - $searchq[] = "{$field}:".$part.$fuzzy.$boost; |
|
| 517 | + $searchq[] = "{$field}:" . $part . $fuzzy . $boost; |
|
| 518 | 518 | } |
| 519 | - $q[] = '+('.implode(' OR ', $searchq).')'; |
|
| 519 | + $q[] = '+(' . implode(' OR ', $searchq) . ')'; |
|
| 520 | 520 | } |
| 521 | 521 | else { |
| 522 | - $q[] = '+'.$part.$fuzzy; |
|
| 522 | + $q[] = '+' . $part . $fuzzy; |
|
| 523 | 523 | } |
| 524 | 524 | } |
| 525 | 525 | } |
@@ -529,11 +529,11 @@ discard block |
||
| 529 | 529 | $classq = array(); |
| 530 | 530 | |
| 531 | 531 | foreach ($query->classes as $class) { |
| 532 | - if (!empty($class['includeSubclasses'])) $classq[] = 'ClassHierarchy:'.$class['class']; |
|
| 533 | - else $classq[] = 'ClassName:'.$class['class']; |
|
| 532 | + if (!empty($class['includeSubclasses'])) $classq[] = 'ClassHierarchy:' . $class['class']; |
|
| 533 | + else $classq[] = 'ClassName:' . $class['class']; |
|
| 534 | 534 | } |
| 535 | 535 | |
| 536 | - if ($classq) $fq[] = '+('.implode(' ', $classq).')'; |
|
| 536 | + if ($classq) $fq[] = '+(' . implode(' ', $classq) . ')'; |
|
| 537 | 537 | |
| 538 | 538 | // Filter by filters |
| 539 | 539 | |
@@ -553,11 +553,11 @@ discard block |
||
| 553 | 553 | $requireq[] = "$field:[$start TO $end]"; |
| 554 | 554 | } |
| 555 | 555 | else { |
| 556 | - $requireq[] = $field.':"'.$value.'"'; |
|
| 556 | + $requireq[] = $field . ':"' . $value . '"'; |
|
| 557 | 557 | } |
| 558 | 558 | } |
| 559 | 559 | |
| 560 | - $fq[] = '+('.implode(' ', $requireq).')'; |
|
| 560 | + $fq[] = '+(' . implode(' ', $requireq) . ')'; |
|
| 561 | 561 | } |
| 562 | 562 | |
| 563 | 563 | foreach ($query->exclude as $field => $values) { |
@@ -577,11 +577,11 @@ discard block |
||
| 577 | 577 | $excludeq[] = "$field:[$start TO $end]"; |
| 578 | 578 | } |
| 579 | 579 | else { |
| 580 | - $excludeq[] = $field.':"'.$value.'"'; |
|
| 580 | + $excludeq[] = $field . ':"' . $value . '"'; |
|
| 581 | 581 | } |
| 582 | 582 | } |
| 583 | 583 | |
| 584 | - $fq[] = ($missing ? "+{$field}:[* TO *] " : '') . '-('.implode(' ', $excludeq).')'; |
|
| 584 | + $fq[] = ($missing ? "+{$field}:[* TO *] " : '') . '-(' . implode(' ', $excludeq) . ')'; |
|
| 585 | 585 | } |
| 586 | 586 | |
| 587 | 587 | // if(!headers_sent()) { |
@@ -605,20 +605,20 @@ discard block |
||
| 605 | 605 | //Debug::dump($res); |
| 606 | 606 | |
| 607 | 607 | $results = new ArrayList(); |
| 608 | - if($res->getHttpStatus() >= 200 && $res->getHttpStatus() < 300) { |
|
| 608 | + if ($res->getHttpStatus() >= 200 && $res->getHttpStatus() < 300) { |
|
| 609 | 609 | foreach ($res->response->docs as $doc) { |
| 610 | 610 | $result = DataObject::get_by_id($doc->ClassName, $doc->ID); |
| 611 | - if($result) { |
|
| 611 | + if ($result) { |
|
| 612 | 612 | $results->push($result); |
| 613 | 613 | |
| 614 | 614 | // Add highlighting (optional) |
| 615 | 615 | $docId = $doc->_documentid; |
| 616 | - if($res->highlighting && $res->highlighting->$docId) { |
|
| 616 | + if ($res->highlighting && $res->highlighting->$docId) { |
|
| 617 | 617 | // TODO Create decorator class for search results rather than adding arbitrary object properties |
| 618 | 618 | // TODO Allow specifying highlighted field, and lazy loading |
| 619 | 619 | // in case the search API needs another query (similar to SphinxSearchable->buildExcerpt()). |
| 620 | 620 | $combinedHighlights = array(); |
| 621 | - foreach($res->highlighting->$docId as $field => $highlights) { |
|
| 621 | + foreach ($res->highlighting->$docId as $field => $highlights) { |
|
| 622 | 622 | $combinedHighlights = array_merge($combinedHighlights, $highlights); |
| 623 | 623 | } |
| 624 | 624 | |
@@ -657,7 +657,7 @@ discard block |
||
| 657 | 657 | } |
| 658 | 658 | |
| 659 | 659 | // Suggestions (requires custom setup, assumes spellcheck.collate=true) |
| 660 | - if(isset($res->spellcheck->suggestions->collation)) { |
|
| 660 | + if (isset($res->spellcheck->suggestions->collation)) { |
|
| 661 | 661 | $ret['Suggestion'] = $res->spellcheck->suggestions->collation; |
| 662 | 662 | } |
| 663 | 663 | |
@@ -18,7 +18,7 @@ discard block |
||
| 18 | 18 | $this->model = $query->applyRelation($this->relation); |
| 19 | 19 | $value = $this->getDbFormattedValue(); |
| 20 | 20 | |
| 21 | - if(is_numeric($value)) $filter = sprintf("%s > %s", $this->getDbName(), Convert::raw2sql($value)); |
|
| 21 | + if (is_numeric($value)) $filter = sprintf("%s > %s", $this->getDbName(), Convert::raw2sql($value)); |
|
| 22 | 22 | else $filter = sprintf("%s > '%s'", $this->getDbName(), Convert::raw2sql($value)); |
| 23 | 23 | |
| 24 | 24 | return $query->where($filter); |
@@ -32,7 +32,7 @@ discard block |
||
| 32 | 32 | $this->model = $query->applyRelation($this->relation); |
| 33 | 33 | $value = $this->getDbFormattedValue(); |
| 34 | 34 | |
| 35 | - if(is_numeric($value)) $filter = sprintf("%s <= %s", $this->getDbName(), Convert::raw2sql($value)); |
|
| 35 | + if (is_numeric($value)) $filter = sprintf("%s <= %s", $this->getDbName(), Convert::raw2sql($value)); |
|
| 36 | 36 | else $filter = sprintf("%s <= '%s'", $this->getDbName(), Convert::raw2sql($value)); |
| 37 | 37 | |
| 38 | 38 | return $query->where($filter); |
@@ -47,15 +47,15 @@ discard block |
||
| 47 | 47 | |
| 48 | 48 | $filters = array(); |
| 49 | 49 | $ops = array('>=', '<='); |
| 50 | - foreach($this->getValue() as $i => $value) { |
|
| 51 | - if(is_numeric($value)) { |
|
| 50 | + foreach ($this->getValue() as $i => $value) { |
|
| 51 | + if (is_numeric($value)) { |
|
| 52 | 52 | $filters[] = sprintf("%s %s %s", $this->getDbName(), $ops[$i], Convert::raw2sql($value)); |
| 53 | 53 | } else { |
| 54 | 54 | $filters[] = sprintf("%s %s '%s'", $this->getDbName(), $ops[$i], Convert::raw2sql($value)); |
| 55 | 55 | } |
| 56 | 56 | } |
| 57 | 57 | |
| 58 | - return $query->where( implode(' AND ', $filters) ); |
|
| 58 | + return $query->where(implode(' AND ', $filters)); |
|
| 59 | 59 | } |
| 60 | 60 | |
| 61 | 61 | /** |
@@ -67,15 +67,15 @@ discard block |
||
| 67 | 67 | |
| 68 | 68 | $filters = array(); |
| 69 | 69 | $ops = array('<', '>'); |
| 70 | - foreach($this->getValue() as $i => $value) { |
|
| 71 | - if(is_numeric($value)) { |
|
| 70 | + foreach ($this->getValue() as $i => $value) { |
|
| 71 | + if (is_numeric($value)) { |
|
| 72 | 72 | $filters[] = sprintf("%s %s %s", $this->getDbName(), $ops[$i], Convert::raw2sql($value)); |
| 73 | 73 | } else { |
| 74 | 74 | $filters[] = sprintf("%s %s '%s'", $this->getDbName(), $ops[$i], Convert::raw2sql($value)); |
| 75 | 75 | } |
| 76 | 76 | } |
| 77 | 77 | |
| 78 | - return $query->where( implode(' OR ', $filters) ); |
|
| 78 | + return $query->where(implode(' OR ', $filters)); |
|
| 79 | 79 | } |
| 80 | 80 | |
| 81 | 81 | /** |
@@ -59,7 +59,7 @@ discard block |
||
| 59 | 59 | * @param DataObject|string $sing - just a singleton object we can get information off of |
| 60 | 60 | * @return DataList |
| 61 | 61 | */ |
| 62 | - public function addFiltersToDataList($list, array $filters, $sing=null) { |
|
| 62 | + public function addFiltersToDataList($list, array $filters, $sing = null) { |
|
| 63 | 63 | if (!$sing) $sing = singleton($list->dataClass()); |
| 64 | 64 | if (is_string($sing)) $sing = singleton($sing); |
| 65 | 65 | |
@@ -148,7 +148,7 @@ discard block |
||
| 148 | 148 | } |
| 149 | 149 | |
| 150 | 150 | if (empty($facets[$field]['Source'])) $facets[$field]['Source'] = $field; |
| 151 | - if (empty($facets[$field]['Type'])) $facets[$field]['Type'] = ShopSearch::FACET_TYPE_LINK; |
|
| 151 | + if (empty($facets[$field]['Type'])) $facets[$field]['Type'] = ShopSearch::FACET_TYPE_LINK; |
|
| 152 | 152 | |
| 153 | 153 | if (empty($facets[$field]['Values'])) { |
| 154 | 154 | $facets[$field]['Values'] = array(); |
@@ -197,7 +197,7 @@ discard block |
||
| 197 | 197 | * @param bool $autoFacetAttributes [optional] |
| 198 | 198 | * @return ArrayList |
| 199 | 199 | */ |
| 200 | - public function buildFacets(SS_List $matches, array $facetSpec, $autoFacetAttributes=false) { |
|
| 200 | + public function buildFacets(SS_List $matches, array $facetSpec, $autoFacetAttributes = false) { |
|
| 201 | 201 | $facets = $this->expandFacetSpec($facetSpec); |
| 202 | 202 | if (!$autoFacetAttributes && (empty($facets) || !$matches || !$matches->count())) return new ArrayList(); |
| 203 | 203 | $fasterMethod = (bool)$this->config()->faster_faceting; |
@@ -340,9 +340,9 @@ discard block |
||
| 340 | 340 | $q = $q->setSelect(array()) |
| 341 | 341 | ->selectField('"ProductAttributeValue"."ID"', 'Value') |
| 342 | 342 | ->selectField('"ProductAttributeValue"."Value"', 'Label') |
| 343 | - ->selectField('count(distinct '.$baseTable.'."ID")', 'Count') |
|
| 343 | + ->selectField('count(distinct ' . $baseTable . '."ID")', 'Count') |
|
| 344 | 344 | ->selectField('"ProductAttributeValue"."Sort"') |
| 345 | - ->addInnerJoin('Product_StaticAttributeValues', $baseTable.'."ID" = "Product_StaticAttributeValues"."ProductID"') |
|
| 345 | + ->addInnerJoin('Product_StaticAttributeValues', $baseTable . '."ID" = "Product_StaticAttributeValues"."ProductID"') |
|
| 346 | 346 | ->addInnerJoin('ProductAttributeValue', '"Product_StaticAttributeValues"."ProductAttributeValueID" = "ProductAttributeValue"."ID"') |
| 347 | 347 | ->addWhere(sprintf("\"ProductAttributeValue\".\"TypeID\" = '%d'", $typeID)) |
| 348 | 348 | ->setOrderBy('"ProductAttributeValue"."Sort"', 'ASC') |
@@ -352,7 +352,7 @@ discard block |
||
| 352 | 352 | |
| 353 | 353 | $facet['Values'] = array(); |
| 354 | 354 | foreach ($q as $row) { |
| 355 | - $facet['Values'][ $row['Value'] ] = new ArrayData($row); |
|
| 355 | + $facet['Values'][$row['Value']] = new ArrayData($row); |
|
| 356 | 356 | } |
| 357 | 357 | } |
| 358 | 358 | |
@@ -374,11 +374,11 @@ discard block |
||
| 374 | 374 | ->selectField('"ProductAttributeType"."Label"', 'TypeLabel') |
| 375 | 375 | ->selectField('"ProductAttributeValue"."ID"', 'Value') |
| 376 | 376 | ->selectField('"ProductAttributeValue"."Value"', 'Label') |
| 377 | - ->selectField('count(distinct '.$baseTable.'."ID")', 'Count') |
|
| 377 | + ->selectField('count(distinct ' . $baseTable . '."ID")', 'Count') |
|
| 378 | 378 | ->selectField('"ProductAttributeValue"."Sort"') |
| 379 | - ->addInnerJoin('Product_StaticAttributeTypes', $baseTable.'."ID" = "Product_StaticAttributeTypes"."ProductID"') |
|
| 379 | + ->addInnerJoin('Product_StaticAttributeTypes', $baseTable . '."ID" = "Product_StaticAttributeTypes"."ProductID"') |
|
| 380 | 380 | ->addInnerJoin('ProductAttributeType', '"Product_StaticAttributeTypes"."ProductAttributeTypeID" = "ProductAttributeType"."ID"') |
| 381 | - ->addInnerJoin('Product_StaticAttributeValues', $baseTable.'."ID" = "Product_StaticAttributeValues"."ProductID"') |
|
| 381 | + ->addInnerJoin('Product_StaticAttributeValues', $baseTable . '."ID" = "Product_StaticAttributeValues"."ProductID"') |
|
| 382 | 382 | ->addInnerJoin('ProductAttributeValue', '"Product_StaticAttributeValues"."ProductAttributeValueID" = "ProductAttributeValue"."ID"' |
| 383 | 383 | . ' AND "ProductAttributeValue"."TypeID" = "ProductAttributeType"."ID"') |
| 384 | 384 | ->setOrderBy(array( |
@@ -395,11 +395,11 @@ discard block |
||
| 395 | 395 | $curFacet = null; |
| 396 | 396 | foreach ($q as $row) { |
| 397 | 397 | if ($curType != $row['TypeID']) { |
| 398 | - if ($curType > 0) $facets['ATT'.$curType] = $curFacet; |
|
| 398 | + if ($curType > 0) $facets['ATT' . $curType] = $curFacet; |
|
| 399 | 399 | $curType = $row['TypeID']; |
| 400 | 400 | $curFacet = array( |
| 401 | 401 | 'Label' => $row['TypeLabel'], |
| 402 | - 'Source' => 'ATT'.$curType, |
|
| 402 | + 'Source' => 'ATT' . $curType, |
|
| 403 | 403 | 'Type' => ShopSearch::FACET_TYPE_LINK, |
| 404 | 404 | 'Values' => array(), |
| 405 | 405 | ); |
@@ -407,10 +407,10 @@ discard block |
||
| 407 | 407 | |
| 408 | 408 | unset($row['TypeID']); |
| 409 | 409 | unset($row['TypeLabel']); |
| 410 | - $curFacet['Values'][ $row['Value'] ] = new ArrayData($row); |
|
| 410 | + $curFacet['Values'][$row['Value']] = new ArrayData($row); |
|
| 411 | 411 | } |
| 412 | 412 | |
| 413 | - if ($curType > 0) $facets['ATT'.$curType] = $curFacet; |
|
| 413 | + if ($curType > 0) $facets['ATT' . $curType] = $curFacet; |
|
| 414 | 414 | return $facets; |
| 415 | 415 | } |
| 416 | 416 | |
@@ -532,7 +532,7 @@ discard block |
||
| 532 | 532 | * @param bool $filterOnlyLeaves [optional] |
| 533 | 533 | * @return bool - true if any of the children are true, false if all children are false |
| 534 | 534 | */ |
| 535 | - protected function updateCheckboxFacetState(ArrayList $values, array $filterVals, $filterOnlyLeaves=false) { |
|
| 535 | + protected function updateCheckboxFacetState(ArrayList $values, array $filterVals, $filterOnlyLeaves = false) { |
|
| 536 | 536 | $out = false; |
| 537 | 537 | |
| 538 | 538 | foreach ($values as $value) { |
@@ -576,14 +576,14 @@ discard block |
||
| 576 | 576 | |
| 577 | 577 | // Look for the most recent parent that matches the beginning of this one |
| 578 | 578 | while (count($parentStack) > 0) { |
| 579 | - $curParent = $parentStack[ count($parentStack)-1 ]; |
|
| 579 | + $curParent = $parentStack[count($parentStack) - 1]; |
|
| 580 | 580 | if (strpos($value->Label, $curParent->FullLabel) === 0) { |
| 581 | 581 | if (!isset($curParent->Children)) $curParent->Children = new ArrayList(); |
| 582 | 582 | |
| 583 | 583 | // Modify the name so we only show the last component |
| 584 | 584 | $value->FullLabel = $value->Label; |
| 585 | 585 | $p = strrpos($value->Label, $facet->HierarchyDivider); |
| 586 | - if ($p > -1) $value->Label = trim( substr($value->Label, $p + 1) ); |
|
| 586 | + if ($p > -1) $value->Label = trim(substr($value->Label, $p + 1)); |
|
| 587 | 587 | |
| 588 | 588 | $curParent->Children->push($value); |
| 589 | 589 | break; |