/** * Sort ranking data by search terms * @param array $results - input data * @param array $res_data_array - output array * @param string $data_count - index postfix * @author Ruslan Ushakov */ private function getRankingResults($results, &$res_data_array, $data_count = '') { foreach ($results as $item) { $item->title = strip_slashes($item->title); //remove slashes from term title like "That\'s My Ticket" $res_data_array[$item->title]['total_results' . $data_count] = $item->total_results; if (!isset($res_data_array[$item->title]['brand_results' . $data_count]) || isset($res_data_array[$item->title]['brand_results' . $data_count]) && $item->brand_results > $res_data_array[$item->title]['brand_results' . $data_count]) { $res_data_array[$item->title]['brand_results' . $data_count] = $item->brand_results; } if (!isset($res_data_array[$item->title]['number_in_results' . $data_count])) { $res_data_array[$item->title]['number_in_results' . $data_count] = array(); } if (!isset($res_data_array[$item->title]['on_first_page' . $data_count]) || !empty($res_data_array[$item->title]['on_first_page' . $data_count]) && $item->on_first_page > $res_data_array[$item->title]['on_first_page' . $data_count]) { $res_data_array[$item->title]['on_first_page' . $data_count] = $item->on_first_page; } $res_data_array[$item->title]['number_in_results' . $data_count][$item->number_in_results] = array('num' => $item->number_in_results, 'url' => $item->url); } foreach ($res_data_array as &$dt) { if (empty($dt['on_first_page' . $data_count])) { $dt['on_first_page' . $data_count] = '0/16'; } if (!empty($dt['number_in_results' . $data_count])) { $dt['number_in_results' . $data_count] = $this->ranking_model->sortRankingNumbers($dt['number_in_results' . $data_count]); } else { $dt['tmp_number_in_results' . $data_count] = array(); } } }