public function search($q) { if (trim($q) == '') { return array(); } $rawProfiles = ProfileNdx_indexer_shared::recoverFromDbNdx('usersProfiles'); $rawProfiles = $this->filterSearchInput($rawProfiles); $xfopt = XenForo_Application::get('options'); $xfopt = $xfopt->searchable; $xfopt = explode(',', $xfopt); $xfo = array(); foreach ($xfopt as $k => $v) { $xfo[$k] = trim($v); } $res = array(); $cfDic = ProfileNdx_indexer_shared::getCustomUserFieldsArray(); foreach ($rawProfiles as $userN => $info) { $match = array(); foreach ($info as $id => $label) { if (in_array($id, $xfo)) { $n = 0; $thisLab = $cfDic[$id]; if (!is_array($label)) { $label = array($label); } $searchable = array(); foreach ($label as $cufChng) { $d = ''; if (array_key_exists($id . '_choice_' . $cufChng, $cfDic)) { $d = $cfDic[$id . '_choice_' . $cufChng]; } else { $d = $cufChng; } $searchable[] = $d; } $n = $this->repeatingTimes($this->plainifyArrayOfStrings($searchable), $q); if ($n == 0) { continue; } $match[$thisLab] = $n; } } $match['Total'] = array_sum($match); if ($match['Total'] > 0) { arsort($match); $res[] = array($match, array($userN, $rawProfiles[$userN]['username'])); } } arsort($res); return $res; }
public function recoverFromDbNdx($id) { return ProfileNdx_indexer_shared::recoverFromDbNdx($id); }