当前位置: 首页>>代码示例>>PHP>>正文


PHP BFCHelper::orderBy方法代码示例

本文整理汇总了PHP中BFCHelper::orderBy方法的典型用法代码示例。如果您正苦于以下问题:PHP BFCHelper::orderBy方法的具体用法?PHP BFCHelper::orderBy怎么用?PHP BFCHelper::orderBy使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在BFCHelper的用法示例。


在下文中一共展示了BFCHelper::orderBy方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: groupResultsByMerchant

 private function groupResultsByMerchant($results, $ordering, $direction)
 {
     if (isset($ordering) && is_array($results)) {
         // 'stay' ordering should take place before grouping
         if (strtolower($ordering) == 'stay') {
             usort($results, function ($a, $b) use($ordering, $direction) {
                 return BFCHelper::orderBy($a, $b, 'TotalPrice', $direction);
             });
         }
     }
     $arr = array();
     foreach ($results as $result) {
         if (!array_key_exists($result->MerchantId, $arr)) {
             $merchant = new stdClass();
             $merchant->MerchantId = $result->MerchantId;
             $merchant->Name = $result->MrcName;
             $merchant->XGooglePos = $result->MrcLat;
             $merchant->YGooglePos = $result->MrcLng;
             $merchant->MerchantTypeId = $result->MerchantTypeId;
             $merchant->Rating = $result->MrcRating;
             $merchant->PaymentType = $result->PaymentType;
             $merchant->Resources = array();
             $merchant->Resources[] = $result;
             $arr[$merchant->MerchantId] = $merchant;
         } else {
             $merchant = $arr[$result->MerchantId];
             $merchant->Resources[] = $result;
         }
     }
     if (isset($ordering)) {
         switch (strtolower($ordering)) {
             case 'rating':
                 usort($arr, function ($a, $b) use($ordering, $direction) {
                     return BFCHelper::orderBy($a, $b, 'Rating', $direction);
                 });
                 break;
             case 'distancefromsea':
                 usort($arr, function ($a, $b) use($ordering, $direction) {
                     return BFCHelper::orderBy($a, $b, 'DistanceFromSea', $direction);
                 });
                 break;
             case 'distancefromcenter':
                 usort($arr, function ($a, $b) use($ordering, $direction) {
                     return BFCHelper::orderBy($a, $b, 'DistanceFromCenter', $direction);
                 });
                 break;
             default:
                 usort($arr, function ($a, $b) use($ordering, $direction) {
                     return BFCHelper::orderBy($a, $b, 'PaymentType', 'desc');
                 });
         }
     }
     return $arr;
 }
开发者ID:Bookingfor,项目名称:joomla-extension,代码行数:54,代码来源:search.php

示例2: groupResultsByMerchant

 private function groupResultsByMerchant($results, $ordering, $direction)
 {
     $catValues = array();
     foreach ($results as $key => $row) {
         $catValues[$key] = $row->IsCatalog;
     }
     if (isset($ordering) && is_array($results)) {
         // 'stay' ordering should take place before grouping
         if (strtolower($ordering) == 'stay') {
             $pricesValues = array();
             foreach ($results as $key => $row) {
                 $pricesValues[$key] = $row->TotalPrice;
             }
             array_multisort($catValues, SORT_ASC, $pricesValues, $direction == 'desc' ? SORT_DESC : SORT_ASC, $results);
             //				usort($results, function($a,$b) use ( $ordering, $direction) {
             //					return BFCHelper::orderBy($a, $b, 'TotalPrice', $direction);
             //				});
         }
         if (strtolower($ordering) == 'offer') {
             $pricesValues = array();
             foreach ($results as $key => $row) {
                 $pricesValues[$key] = $row->PercentVariation;
             }
             array_multisort($catValues, SORT_ASC, $pricesValues, $direction == 'desc' ? SORT_DESC : SORT_ASC, $results);
             //				usort($results, function($a,$b) use ( $ordering, $direction) {
             //					return BFCHelper::orderBy($a, $b, 'PercentVariation', $direction);
             ////					return BFCHelper::orderBySingleDiscount($a, $b, $direction);
             //				});
         }
     }
     $arr = array();
     foreach ($results as $result) {
         if (!array_key_exists($result->MerchantId, $arr)) {
             $merchant = new stdClass();
             $merchant->MerchantId = $result->MerchantId;
             $merchant->MrcCategoryName = $result->DefaultLangMrcCategoryName;
             $merchant->Name = $result->MrcName;
             $merchant->XGooglePos = $result->MrcLat;
             $merchant->YGooglePos = $result->MrcLng;
             $merchant->MerchantTypeId = $result->MerchantTypeId;
             $merchant->Rating = $result->MrcRating;
             $merchant->RatingsContext = $result->RatingsContext;
             $merchant->RatingsType = $result->RatingsType;
             $merchant->PaymentType = $result->PaymentType;
             $merchant->reviewValue = $result->MrcAVG;
             $merchant->reviewCount = $result->MrcAVGCount;
             $merchant->LogoUrl = $result->LogoUrl;
             $merchant->Weight = $result->MrcWeight;
             $merchant->MrcTagsIdList = $result->MrcTagsIdList;
             $merchant->ImageUrl = $result->MrcImageUrl;
             $merchant->Resources = array();
             $merchant->Resources[] = $result;
             $arr[$merchant->MerchantId] = $merchant;
         } else {
             $merchant = $arr[$result->MerchantId];
             $merchant->Resources[] = $result;
         }
     }
     if (!empty($ordering)) {
         switch (strtolower($ordering)) {
             case 'stay':
                 usort($arr, function ($a, $b) use($ordering, $direction) {
                     return BFCHelper::orderByStay($a, $b, $direction);
                 });
                 break;
             case 'rating':
                 usort($arr, function ($a, $b) use($ordering, $direction) {
                     return BFCHelper::orderBy($a, $b, 'Rating', $direction);
                 });
                 break;
             case 'reviewvalue':
                 usort($arr, function ($a, $b) use($ordering, $direction) {
                     return BFCHelper::orderBy($a, $b, 'reviewValue', $direction);
                 });
                 break;
             case 'offer':
                 usort($arr, function ($a, $b) use($ordering, $direction) {
                     return BFCHelper::orderBy($a->Resources[0], $b->Resources[0], 'PercentVariation', $direction);
                     //						return BFCHelper::orderByDiscount($a, $b, $direction);
                 });
                 break;
             default:
                 $mrcCatalog = array();
                 $mrcIndexes = array();
                 foreach ($arr as $key => $row) {
                     /*
                     usort($row->Resources, function($a,$b) use ( $ordering, $direction) {
                     	return BFCHelper::orderBy($a, $b, 'ResWeight', 'asc');
                     });
                     */
                     $totalResources = count($row->Resources);
                     $catRes = count(array_filter($row->Resources, function ($rs) {
                         return $rs->IsCatalog;
                     }));
                     $mrcCatalog[$key] = $catRes * 100 / $totalResources;
                     $mrcIndexes[$key] = $key;
                 }
                 array_multisort($mrcCatalog, SORT_ASC, $mrcIndexes, SORT_ASC, $arr);
                 //				usort($arr, function($a,$b) use ( $ordering, $direction) {
                 //					return BFCHelper::orderBy($a, $b, 'PaymentType', 'desc');
//.........这里部分代码省略.........
开发者ID:Bookingfor,项目名称:joomla-extension-v-2,代码行数:101,代码来源:search.php

示例3: groupResultsByMerchant

 private function groupResultsByMerchant($results, $ordering, $direction)
 {
     if (isset($ordering) && is_array($results)) {
         // 'stay' ordering should take place before grouping
         if (strtolower($ordering) == 'stay') {
             usort($results, function ($a, $b) use($ordering, $direction) {
                 return BFCHelper::orderBy($a, $b, 'TotalPrice', $direction);
             });
         }
         if (strtolower($ordering) == 'offer') {
             usort($results, function ($a, $b) use($ordering, $direction) {
                 return BFCHelper::orderBy($a, $b, 'PercentVariation', $direction);
                 //					return BFCHelper::orderBySingleDiscount($a, $b, $direction);
             });
         }
     }
     $arr = array();
     foreach ($results as $result) {
         if (!array_key_exists($result->MerchantId, $arr)) {
             $merchant = new stdClass();
             $merchant->MerchantId = $result->MerchantId;
             $merchant->Name = $result->MrcName;
             $merchant->XGooglePos = $result->MrcLat;
             $merchant->YGooglePos = $result->MrcLng;
             $merchant->MerchantTypeId = $result->MerchantTypeId;
             $merchant->Rating = $result->MrcRating;
             $merchant->RatingsContext = $result->RatingsContext;
             $merchant->PaymentType = $result->PaymentType;
             $merchant->reviewValue = $result->MrcAVG;
             $merchant->reviewCount = $result->MrcAVGCount;
             $merchant->LogoUrl = $result->LogoUrl;
             $merchant->Weight = $result->MrcWeight;
             $merchant->MrcTagsIdList = $result->MrcTagsIdList;
             $merchant->ImageUrl = $result->MrcImageUrl;
             $merchant->Resources = array();
             $merchant->Resources[] = $result;
             $arr[$merchant->MerchantId] = $merchant;
         } else {
             $merchant = $arr[$result->MerchantId];
             $merchant->Resources[] = $result;
         }
     }
     if (isset($ordering)) {
         switch (strtolower($ordering)) {
             case 'stay':
                 usort($arr, function ($a, $b) use($ordering, $direction) {
                     return BFCHelper::orderByStay($a, $b, $direction);
                 });
                 break;
             case 'rating':
                 usort($arr, function ($a, $b) use($ordering, $direction) {
                     return BFCHelper::orderBy($a, $b, 'Rating', $direction);
                 });
                 break;
             case 'reviewvalue':
                 usort($arr, function ($a, $b) use($ordering, $direction) {
                     return BFCHelper::orderBy($a, $b, 'reviewValue', $direction);
                 });
                 break;
             case 'offer':
                 usort($arr, function ($a, $b) use($ordering, $direction) {
                     return BFCHelper::orderBy($a->Resources[0], $b->Resources[0], 'PercentVariation', $direction);
                     //						return BFCHelper::orderByDiscount($a, $b, $direction);
                 });
                 break;
             default:
                 usort($arr, function ($a, $b) use($ordering, $direction) {
                     return BFCHelper::orderBy($a, $b, 'PaymentType', 'desc');
                 });
         }
     } else {
         usort($arr, function ($a, $b) use($ordering, $direction) {
             return BFCHelper::orderBy($a, $b, 'Weight', 'asc');
         });
         usort($arr->Resources[], function ($a, $b) use($ordering, $direction) {
             return BFCHelper::orderBy($a, $b, 'ResWeight', 'asc');
         });
     }
     return $arr;
 }
开发者ID:Bookingfor,项目名称:joomla-extension-v-2,代码行数:80,代码来源:tag.php


注:本文中的BFCHelper::orderBy方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。