$result .= $res; } } $main = IOStruct::GetFile(PATH_TEMPLATES . "kb_result_main.tpl"); $main = str_replace("<!--show_cats-->", $catcount > 1 ? "''" : "none", $main); $main = str_replace("<!--categories-->", $catcount > 1 ? $navcats : "", $main); $main = str_replace("<!--content-->", $result, $main); } if (!empty($result) && !empty($main)) { $externalUser->AddFunctionCall("lz_chat_search_result('" . base64_encode(Server::Replace($main, true, false, false, false)) . "',0);", false); } else { $externalUser->AddFunctionCall("lz_chat_search_result('" . base64_encode("<div><br><br>" . LocalizationManager::$TranslationStrings["client_kb_no_entries"] . "</div>" . $result) . "',0);", false); } } else { if (strlen($query) >= 3) { $matches = KnowledgeBase::GetMatches($query, Visitor::$BrowserLanguage); if (count($matches) > 0) { foreach ($matches as $match) { $result .= $match->GetHTML($color); } $res = IOStruct::GetFile(PATH_TEMPLATES . "kb_result_category.tpl"); $res = str_replace("<!--title-->", "\"" . cutString($query, 50, true) . "\"", $res); $res = str_replace("<!--entries-->", $result, $res); $res = str_replace("<!--search-->", "true", $res); $res = str_replace("<!--id-->", "sr", $res); $externalUser->AddFunctionCall("lz_chat_search_result('" . base64_encode("<div><b>" . str_replace("<!--count-->", count($matches), LocalizationManager::$TranslationStrings["client_kb_results_found"]) . " </b><br><br>" . $res) . "'," . count($matches) . ");", false); } else { $externalUser->AddFunctionCall("lz_chat_search_result('" . base64_encode("<div><br><br>" . LocalizationManager::$TranslationStrings["client_search_no_result"] . "</div>" . $result . "") . "',0);", false); } } else { $externalUser->AddFunctionCall("lz_chat_search_result('" . base64_encode("<div><br><br>" . LocalizationManager::$TranslationStrings["client_search_no_result"] . "</div>" . $result . "") . "',0);", false);
function KnowledgebaseSearch() { global $USER; if (!empty($_GET["skb"])) { $c = count(KnowledgeBase::GetMatches(Communication::ReadParameter("skb", ""), Visitor::$BrowserLanguage)); $USER->AddFunctionCall("lz_chat_search_result(" . $c . ");", false); } }
function GetAutoReplies($_question, $_chat) { $_question = str_replace(array("!", ",", ".", "?", "=", ")", "(", "-", "_", ":", "#", "~", "�"), "", strtolower($_question)); $merged = array_merge($this->AutoReplies, Server::$Groups[$_chat->DesiredChatGroup]->AutoReplies); if ($this->IsBot) { $kbresults = KnowledgeBase::GetMatches($_question, Visitor::$BrowserLanguage, true); $merged = array_merge($merged, $kbresults); } $answers = ChatAutoReply::GetMatches($merged, $_question, Visitor::$BrowserLanguage, $_chat, $this); if ($this->IsBot) { return $this->FormatBotAutoReplies($_chat, $answers); } else { return $this->FormatHumanAutoReplies($answers, $_chat); } }