@@ -76,9 +76,9 @@ discard block |
||
| 76 | 76 | $this->runFrom($_GET['class'], $_GET['start'], $_GET['field']); |
| 77 | 77 | } |
| 78 | 78 | else { |
| 79 | - foreach(array('framework','sapphire') as $dirname) { |
|
| 79 | + foreach (array('framework', 'sapphire') as $dirname) { |
|
| 80 | 80 | $script = sprintf("%s%s$dirname%scli-script.php", BASE_PATH, DIRECTORY_SEPARATOR, DIRECTORY_SEPARATOR); |
| 81 | - if(file_exists($script)) { |
|
| 81 | + if (file_exists($script)) { |
|
| 82 | 82 | break; |
| 83 | 83 | } |
| 84 | 84 | } |
@@ -90,7 +90,7 @@ discard block |
||
| 90 | 90 | $query = $singleton->get($class); |
| 91 | 91 | $dtaQuery = $query->dataQuery(); |
| 92 | 92 | $sqlQuery = $dtaQuery->getFinalisedQuery(); |
| 93 | - $singleton->extend('augmentSQL',$sqlQuery,$dtaQuery); |
|
| 93 | + $singleton->extend('augmentSQL', $sqlQuery, $dtaQuery); |
|
| 94 | 94 | $total = $query->count(); |
| 95 | 95 | $startFrom = isset($_GET['startfrom']) ? $_GET['startfrom'] : 0; |
| 96 | 96 | $field = isset($_GET['field']) ? $_GET['field'] : ''; |
@@ -100,9 +100,9 @@ discard block |
||
| 100 | 100 | for ($offset = $startFrom; $offset < $total; $offset += $this->stat('recordsPerRequest')) { |
| 101 | 101 | echo "$offset.."; |
| 102 | 102 | $cmd = "php $script dev/tasks/$self class=$class start=$offset field=$field"; |
| 103 | - if($verbose) echo "\n Running '$cmd'\n"; |
|
| 103 | + if ($verbose) echo "\n Running '$cmd'\n"; |
|
| 104 | 104 | $res = $verbose ? passthru($cmd) : `$cmd`; |
| 105 | - if($verbose) echo " ".preg_replace('/\r\n|\n/', '$0 ', $res)."\n"; |
|
| 105 | + if ($verbose) echo " " . preg_replace('/\r\n|\n/', '$0 ', $res) . "\n"; |
|
| 106 | 106 | } |
| 107 | 107 | } |
| 108 | 108 | } |
@@ -175,13 +175,13 @@ discard block |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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; |
@@ -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 | - 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 | } |
@@ -32,7 +32,7 @@ |
||
| 32 | 32 | // convert the search results into usable json for search-as-you-type |
| 33 | 33 | if (ShopSearch::config()->search_as_you_type_enabled) { |
| 34 | 34 | $searchVars = $req->requestVars(); |
| 35 | - $searchVars[ ShopSearch::config()->qs_query ] = $searchVars['term']; |
|
| 35 | + $searchVars[ShopSearch::config()->qs_query] = $searchVars['term']; |
|
| 36 | 36 | unset($searchVars['term']); |
| 37 | 37 | $results = ShopSearch::inst()->suggestWithResults($searchVars); |
| 38 | 38 | } else { |
@@ -41,7 +41,7 @@ |
||
| 41 | 41 | |
| 42 | 42 | $emptyString = self::config()->category_empty_string; |
| 43 | 43 | if ($emptyString !== 'NONE') { |
| 44 | - $catField->setEmptyString(_t('ShopSearch.'.$emptyString, $emptyString)); |
|
| 44 | + $catField->setEmptyString(_t('ShopSearch.' . $emptyString, $emptyString)); |
|
| 45 | 45 | } |
| 46 | 46 | |
| 47 | 47 | $fields->push($catField); |
@@ -19,7 +19,7 @@ |
||
| 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; |
@@ -251,7 +251,7 @@ discard block |
||
| 251 | 251 | * @param string $sort [optional] |
| 252 | 252 | * @return ArrayData |
| 253 | 253 | */ |
| 254 | - public function searchFromVars($keywords, array $filters=array(), array $facetSpec=array(), $start=-1, $limit=-1, $sort='score desc') |
|
| 254 | + public function searchFromVars($keywords, array $filters = array(), array $facetSpec = array(), $start = -1, $limit = -1, $sort = 'score desc') |
|
| 255 | 255 | { |
| 256 | 256 | $query = new SearchQuery(); |
| 257 | 257 | $params = array( |
@@ -371,14 +371,14 @@ discard block |
||
| 371 | 371 | |
| 372 | 372 | foreach ($query->classes as $class) { |
| 373 | 373 | if (!empty($class['includeSubclasses'])) { |
| 374 | - $classq[] = 'ClassHierarchy:'.$class['class']; |
|
| 374 | + $classq[] = 'ClassHierarchy:' . $class['class']; |
|
| 375 | 375 | } else { |
| 376 | - $classq[] = 'ClassName:'.$class['class']; |
|
| 376 | + $classq[] = 'ClassName:' . $class['class']; |
|
| 377 | 377 | } |
| 378 | 378 | } |
| 379 | 379 | |
| 380 | 380 | if ($classq) { |
| 381 | - $fq[] = '+('.implode(' ', $classq).')'; |
|
| 381 | + $fq[] = '+(' . implode(' ', $classq) . ')'; |
|
| 382 | 382 | } |
| 383 | 383 | |
| 384 | 384 | // Filter by filters |
@@ -401,11 +401,11 @@ discard block |
||
| 401 | 401 | } |
| 402 | 402 | $requireq[] = "$field:[$start TO $end]"; |
| 403 | 403 | } else { |
| 404 | - $requireq[] = $field.':"'.$value.'"'; |
|
| 404 | + $requireq[] = $field . ':"' . $value . '"'; |
|
| 405 | 405 | } |
| 406 | 406 | } |
| 407 | 407 | |
| 408 | - $fq[] = '+('.implode(' ', $requireq).')'; |
|
| 408 | + $fq[] = '+(' . implode(' ', $requireq) . ')'; |
|
| 409 | 409 | } |
| 410 | 410 | |
| 411 | 411 | foreach ($query->exclude as $field => $values) { |
@@ -428,11 +428,11 @@ discard block |
||
| 428 | 428 | } |
| 429 | 429 | $excludeq[] = "$field:[$start TO $end]"; |
| 430 | 430 | } else { |
| 431 | - $excludeq[] = $field.':"'.$value.'"'; |
|
| 431 | + $excludeq[] = $field . ':"' . $value . '"'; |
|
| 432 | 432 | } |
| 433 | 433 | } |
| 434 | 434 | |
| 435 | - $fq[] = ($missing ? "+{$field}:[* TO *] " : '') . '-('.implode(' ', $excludeq).')'; |
|
| 435 | + $fq[] = ($missing ? "+{$field}:[* TO *] " : '') . '-(' . implode(' ', $excludeq) . ')'; |
|
| 436 | 436 | } |
| 437 | 437 | |
| 438 | 438 | // if(!headers_sent()) { |
@@ -550,11 +550,11 @@ discard block |
||
| 550 | 550 | $searchq = array(); |
| 551 | 551 | foreach ($fields as $field) { |
| 552 | 552 | $boost = (isset($search['boost'][$field])) ? '^' . $search['boost'][$field] : ''; |
| 553 | - $searchq[] = "{$field}:".$part.$fuzzy.$boost; |
|
| 553 | + $searchq[] = "{$field}:" . $part . $fuzzy . $boost; |
|
| 554 | 554 | } |
| 555 | - $q[] = '+('.implode(' OR ', $searchq).')'; |
|
| 555 | + $q[] = '+(' . implode(' OR ', $searchq) . ')'; |
|
| 556 | 556 | } else { |
| 557 | - $q[] = '+'.$part.$fuzzy; |
|
| 557 | + $q[] = '+' . $part . $fuzzy; |
|
| 558 | 558 | } |
| 559 | 559 | } |
| 560 | 560 | } |
@@ -565,14 +565,14 @@ discard block |
||
| 565 | 565 | |
| 566 | 566 | foreach ($query->classes as $class) { |
| 567 | 567 | if (!empty($class['includeSubclasses'])) { |
| 568 | - $classq[] = 'ClassHierarchy:'.$class['class']; |
|
| 568 | + $classq[] = 'ClassHierarchy:' . $class['class']; |
|
| 569 | 569 | } else { |
| 570 | - $classq[] = 'ClassName:'.$class['class']; |
|
| 570 | + $classq[] = 'ClassName:' . $class['class']; |
|
| 571 | 571 | } |
| 572 | 572 | } |
| 573 | 573 | |
| 574 | 574 | if ($classq) { |
| 575 | - $fq[] = '+('.implode(' ', $classq).')'; |
|
| 575 | + $fq[] = '+(' . implode(' ', $classq) . ')'; |
|
| 576 | 576 | } |
| 577 | 577 | |
| 578 | 578 | // Filter by filters |
@@ -596,11 +596,11 @@ discard block |
||
| 596 | 596 | } |
| 597 | 597 | $requireq[] = "$field:[$start TO $end]"; |
| 598 | 598 | } else { |
| 599 | - $requireq[] = $field.':"'.$value.'"'; |
|
| 599 | + $requireq[] = $field . ':"' . $value . '"'; |
|
| 600 | 600 | } |
| 601 | 601 | } |
| 602 | 602 | |
| 603 | - $fq[] = '+('.implode(' ', $requireq).')'; |
|
| 603 | + $fq[] = '+(' . implode(' ', $requireq) . ')'; |
|
| 604 | 604 | } |
| 605 | 605 | |
| 606 | 606 | foreach ($query->exclude as $field => $values) { |
@@ -623,11 +623,11 @@ discard block |
||
| 623 | 623 | } |
| 624 | 624 | $excludeq[] = "$field:[$start TO $end]"; |
| 625 | 625 | } else { |
| 626 | - $excludeq[] = $field.':"'.$value.'"'; |
|
| 626 | + $excludeq[] = $field . ':"' . $value . '"'; |
|
| 627 | 627 | } |
| 628 | 628 | } |
| 629 | 629 | |
| 630 | - $fq[] = ($missing ? "+{$field}:[* TO *] " : '') . '-('.implode(' ', $excludeq).')'; |
|
| 630 | + $fq[] = ($missing ? "+{$field}:[* TO *] " : '') . '-(' . implode(' ', $excludeq) . ')'; |
|
| 631 | 631 | } |
| 632 | 632 | |
| 633 | 633 | // if(!headers_sent()) { |
@@ -67,7 +67,7 @@ discard block |
||
| 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()); |
@@ -170,7 +170,7 @@ discard block |
||
| 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'])) { |
@@ -222,7 +222,7 @@ discard block |
||
| 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())) { |
@@ -389,9 +389,9 @@ discard block |
||
| 389 | 389 | $q = $q->setSelect(array()) |
| 390 | 390 | ->selectField('"ProductAttributeValue"."ID"', 'Value') |
| 391 | 391 | ->selectField('"ProductAttributeValue"."Value"', 'Label') |
| 392 | - ->selectField('count(distinct '.$baseTable.'."ID")', 'Count') |
|
| 392 | + ->selectField('count(distinct ' . $baseTable . '."ID")', 'Count') |
|
| 393 | 393 | ->selectField('"ProductAttributeValue"."Sort"') |
| 394 | - ->addInnerJoin('Product_StaticAttributeValues', $baseTable.'."ID" = "Product_StaticAttributeValues"."ProductID"') |
|
| 394 | + ->addInnerJoin('Product_StaticAttributeValues', $baseTable . '."ID" = "Product_StaticAttributeValues"."ProductID"') |
|
| 395 | 395 | ->addInnerJoin('ProductAttributeValue', '"Product_StaticAttributeValues"."ProductAttributeValueID" = "ProductAttributeValue"."ID"') |
| 396 | 396 | ->addWhere(sprintf("\"ProductAttributeValue\".\"TypeID\" = '%d'", $typeID)) |
| 397 | 397 | ->setOrderBy('"ProductAttributeValue"."Sort"', 'ASC') |
@@ -401,7 +401,7 @@ discard block |
||
| 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 | |
@@ -426,11 +426,11 @@ discard block |
||
| 426 | 426 | ->selectField('"ProductAttributeType"."Label"', 'TypeLabel') |
| 427 | 427 | ->selectField('"ProductAttributeValue"."ID"', 'Value') |
| 428 | 428 | ->selectField('"ProductAttributeValue"."Value"', 'Label') |
| 429 | - ->selectField('count(distinct '.$baseTable.'."ID")', 'Count') |
|
| 429 | + ->selectField('count(distinct ' . $baseTable . '."ID")', 'Count') |
|
| 430 | 430 | ->selectField('"ProductAttributeValue"."Sort"') |
| 431 | - ->addInnerJoin('Product_StaticAttributeTypes', $baseTable.'."ID" = "Product_StaticAttributeTypes"."ProductID"') |
|
| 431 | + ->addInnerJoin('Product_StaticAttributeTypes', $baseTable . '."ID" = "Product_StaticAttributeTypes"."ProductID"') |
|
| 432 | 432 | ->addInnerJoin('ProductAttributeType', '"Product_StaticAttributeTypes"."ProductAttributeTypeID" = "ProductAttributeType"."ID"') |
| 433 | - ->addInnerJoin('Product_StaticAttributeValues', $baseTable.'."ID" = "Product_StaticAttributeValues"."ProductID"') |
|
| 433 | + ->addInnerJoin('Product_StaticAttributeValues', $baseTable . '."ID" = "Product_StaticAttributeValues"."ProductID"') |
|
| 434 | 434 | ->addInnerJoin('ProductAttributeValue', '"Product_StaticAttributeValues"."ProductAttributeValueID" = "ProductAttributeValue"."ID"' |
| 435 | 435 | . ' AND "ProductAttributeValue"."TypeID" = "ProductAttributeType"."ID"') |
| 436 | 436 | ->setOrderBy(array( |
@@ -448,12 +448,12 @@ discard block |
||
| 448 | 448 | foreach ($q as $row) { |
| 449 | 449 | if ($curType != $row['TypeID']) { |
| 450 | 450 | if ($curType > 0) { |
| 451 | - $facets['ATT'.$curType] = $curFacet; |
|
| 451 | + $facets['ATT' . $curType] = $curFacet; |
|
| 452 | 452 | } |
| 453 | 453 | $curType = $row['TypeID']; |
| 454 | 454 | $curFacet = array( |
| 455 | 455 | 'Label' => $row['TypeLabel'], |
| 456 | - 'Source' => 'ATT'.$curType, |
|
| 456 | + 'Source' => 'ATT' . $curType, |
|
| 457 | 457 | 'Type' => ShopSearch::FACET_TYPE_LINK, |
| 458 | 458 | 'Values' => array(), |
| 459 | 459 | ); |
@@ -461,11 +461,11 @@ discard block |
||
| 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) { |
| 468 | - $facets['ATT'.$curType] = $curFacet; |
|
| 468 | + $facets['ATT' . $curType] = $curFacet; |
|
| 469 | 469 | } |
| 470 | 470 | return $facets; |
| 471 | 471 | } |
@@ -599,7 +599,7 @@ discard block |
||
| 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 |
||
| 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(); |
@@ -73,7 +73,7 @@ discard block |
||
| 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 |
||
| 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 |
||
| 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 | } |