Init(); $adminMenu->Init($adminPage->aModules); $arResult = array( "CATEGORIES"=>array( "global_menu_content"=>array("ITEMS"=>array(), "TITLE"=>GetMessage('admin_lib_menu_content')), "global_menu_services"=>array("ITEMS"=>array(), "TITLE"=>GetMessage('admin_lib_menu_services')), "global_menu_store"=>array("ITEMS"=>array(), "TITLE"=>GetMessage('admin_lib_menu_store')), "global_menu_statistics"=>array("ITEMS"=>array(), "TITLE"=>GetMessage('admin_lib_menu_stat')), "global_menu_settings"=>array("ITEMS"=>array(), "TITLE"=>GetMessage('admin_lib_menu_settings')), ) ); $arStemFunc = stemming_init(LANGUAGE_ID); $arPhrase = stemming_split($query, LANGUAGE_ID); $preg_template = "/(^|[^".$arStemFunc["pcre_letters"]."])(".str_replace("/", "\\/", implode("|", array_map('preg_quote', array_keys($arPhrase)))).")/i".BX_UTF_PCRE_MODIFIER; $bFound = false; function GetStrings(&$item, $key, $p) { global $arStemFunc, $arPhrase, $preg_template, $arResult, $bFound; $category = $p[0]; $icon = $p[1]; $arRes = null; if($item["url"] <> '') { $searchstring = ''; if($item["text"]) { if(preg_match_all($preg_template, mb_strtoupper($item["text"]), $arMatches, PREG_OFFSET_CAPTURE)) { $c = count($arMatches[2]); if(defined("BX_UTF")) { for($j = $c-1; $j >= 0; $j--) { $prefix = mb_substr($item["text"], 0, $arMatches[2][$j][1], 'latin1'); $instr = mb_substr($item["text"], $arMatches[2][$j][1], mb_strlen($arMatches[2][$j][0], 'latin1'), 'latin1'); $suffix = mb_substr($item["text"], $arMatches[2][$j][1] + mb_strlen($arMatches[2][$j][0], 'latin1'), mb_strlen($item["text"], 'latin1'), 'latin1'); $item["text"] = $prefix."".$instr."".$suffix; } } else { for($j = $c-1; $j >= 0; $j--) { $prefix = mb_substr($item["text"], 0, $arMatches[2][$j][1]); $instr = mb_substr($item["text"], $arMatches[2][$j][1], mb_strlen($arMatches[2][$j][0])); $suffix = mb_substr($item["text"], $arMatches[2][$j][1] + mb_strlen($arMatches[2][$j][0])); $item["text"] = $prefix."".$instr."".$suffix; } } } $searchstring .= $item["text"]; } if($item["title"]) $searchstring .= " ".$item["title"]; if($item["keywords"]) $searchstring .= " ".$item["keywords"]; if($item["icon"]=='') $item["icon"] = $icon; if(preg_match_all($preg_template, mb_strtoupper($searchstring), $arMatches, PREG_OFFSET_CAPTURE)) { $ar = Array(); foreach($arMatches[0] as $m) $ar[] = trim($m[0], " ,;>"); if(count(array_unique($ar)) == count($arPhrase)) { $arRes = array("NAME"=>$item["text"], "URL"=>$item["url"], "TITLE"=>$item["title"], "ICON"=>$item['icon']); } } } if(is_array($arRes)) { if($item['category'] == '') $item['category'] = $category; if(!is_array($arResult["CATEGORIES"][$item['category']])) { $arResult["CATEGORIES"][$item['category']] = Array('TITLE'=>'', 'ITEMS'=>Array()); if($item['category_name']!='') $arResult["CATEGORIES"][$item['category']]['TITLE'] = $item['category_name']; } $arResult["CATEGORIES"][$item['category']]["ITEMS"][] = $arRes; $bFound = true; } if(is_array($item["items"])) array_walk($item['items'], 'GetStrings', array($category, $item["icon"])); } foreach($adminMenu->aGlobalMenu as $menu_id => $menu) array_walk($menu['items'], 'GetStrings', array($menu_id, '')); if($bFound) { ?> $arCategory): if(empty($arCategory["ITEMS"])) continue; ?> $arItem): if($i>9) break; ?>