$( "#tags" ).autocomplete({ source: 'source.php' }); }); </script> </head> <body> <?php if (isset($_POST['CARI'])) { $kunci = $_POST['KUNCI']; $db2 = new searching(); $db2->cari($kunci); } ?> <form method="post" action="index.php"> <div class="ui-widget"> <input type ='text' name = 'KUNCI' placeholder="Inputkan Nama Disini" id="tags"> </div><!--end of ui widget--> <input type ='submit' name = 'CARI' value='CARI'> </form> </body>
public function execute(\FrameResponseObject $frameResponseObject) { //DEFINITION OF IGNORED USERS AND GROUPS $ignoredUser = array(0 => "postman", 1 => "root", 2 => "guest"); $ignoredGroups = array(0 => "sTeam", 1 => "admin"); $steam = $GLOBALS["STEAM"]; $action = isset($_POST["action"]) ? $_POST["action"] : ""; $searchString = isset($_POST["searchString"]) ? $_POST["searchString"] : ""; $searchType = isset($_POST["searchType"]) ? $_POST["searchType"] : "searchUser"; $steamUser = \lms_steam::get_current_user(); $searchResult = array(); $min_search_string_count = 4; if ($action != "") { $searchString = trim($searchString); if (strlen($searchString) < $min_search_string_count) { //$frameResponseObject->setProblemDescription(gettext("Search string too short")); $frameResponseObject->setProblemDescription("Länge der Suchanfrage zu klein! Eine Suchanfrage muss aus mindestens 4 Zeichen bestehen."); } else { /* prepare search string */ $modSearchString = $searchString; if ($modSearchString[0] != "%") { $modSearchString = "%" . $modSearchString; } if ($modSearchString[strlen($modSearchString) - 1] != "%") { $modSearchString = $modSearchString . "%"; } $searchModule = $steam->get_module("searching"); $searchobject = new \searching($searchModule); $search = new \search_define(); if ($searchType == "searchUser") { $search->extendAttr("OBJ_NAME", \search_define::like($modSearchString)); $resultItems = $searchobject->search($search, CLASS_USER); foreach ($resultItems as $r) { $id = $r->get_id(); $resultItemName[$id] = $r->get_name(1); } } elseif ($searchType == "searchGroup") { $search->extendAttr("GROUP_NAME", \search_define::like($modSearchString)); $resultItems = $searchobject->search($search, CLASS_GROUP); foreach ($resultItems as $r) { $id = $r->get_id(); $resultItemName[$id] = $r->get_groupname(1); } } elseif ($searchType == "searchUserFullname") { $cache = get_cache_function($steamUser->get_name(), 60); $resultUser = $cache->call("lms_steam::search_user", $searchString, "name"); $resultItems = array(); for ($i = 0; $i < count($resultUser); $i++) { $resultItems[$i] = \steam_factory::get_object($steam->get_id(), $resultUser[$i]["OBJ_ID"]); } foreach ($resultItems as $r) { $id = $r->get_id(); $resultItemName[$id] = $r->get_name(); } } if ($searchType != "searchUserFullname") { $result = $steam->buffer_flush(); } else { $result = array(); $counter = 0; foreach ($resultItems as $r) { $result[$r->get_name()] = $r->get_id(); $counter++; } } $helper = array(); foreach ($resultItems as $r) { $id = $r->get_id(); if ($r instanceof \steam_user) { $helper[$r->get_name()] = $id; } else { $helper[$r->get_groupname()] = $id; } $resultItemName[$id] = $result[$resultItemName[$id]]; $searchResult[] = $resultItemName[$id]; } } } // sort favourites natcasesort($searchResult); $content = \Favorite::getInstance()->loadTemplate("fav_search.html"); //$content->setVariable("TITLE", gettext("Search for favorites")); $content->setVariable("TITLE", "Favoritensuche"); //$content->setVariable("SEARCH",gettext("Search")); $content->setVariable("SEARCH", "Suche"); //$content->setVariable("BUTTON_LABEL", gettext("Search")); $content->setVariable("BUTTON_LABEL", "Suchen"); //$content->setVariable("GROUPS",gettext("Groups")); //$content->setVariable("USER_LOGIN",gettext("User (login)")); //$content->setVariable("USER_FULLNAME", gettext("User (fullname)")); $content->setVariable("GROUPS", "Gruppen"); $content->setVariable("USER_LOGIN", "Benutzer (Login)"); $content->setVariable("USER_FULLNAME", "Benutzer (Namen)"); if ($action != "") { //$content->setVariable("SEARCH_RESULTS", gettext("Search results")); $loopCount = 0; if ($searchType == "searchUser" || $searchType == "searchUserFullname") { $category = "user"; } else { $category = "group"; } foreach ($searchResult as $resultEntry) { $content->setVariable("SEARCH_RESULTS", "Suchergebnisse"); $b = false; if ($searchType != "searchUserFullname") { $urlId = $helper[$resultEntry]; } else { $urlId = $resultEntry; } if ($category == "user") { foreach ($ignoredUser as $ignore) { if ($ignore == $resultEntry) { $b = true; } } } if ($category == "group") { foreach ($ignoredGroups as $ignore) { if ($ignore == $resultEntry) { $b = true; } } } if (!$b) { if ($category == "user") { $content->setCurrentBlock("BLOCK_SEARCH_RESULTS"); $content->setVariable("BUDDY_NAME", PATH_URL . "profile/index/" . $resultEntry . "/"); //$content->setVariable("BUDDY_NAME1",$resultEntry); $resultUser = \steam_factory::get_object($GLOBALS["STEAM"]->get_id(), $urlId); $fullname = $resultUser->get_full_name(); $content->setVariable("BUDDY_NAME1", $fullname); $picId = $resultUser->get_attribute("OBJ_ICON")->get_id(); $content->setVariable("BUDDY_PIC_LINK", PATH_URL . "download/image/" . $picId . "/60/40/"); if ($steamUser->get_id() == $resultUser->get_id()) { //$content->setVariable("ALREADY_BUDDY",gettext("Your profile")); $content->setVariable("ALREADY_BUDDY", "Das bist Du!"); } elseif (!$steamUser->is_buddy($resultUser)) { //$content->setVariable("ADD_FAVORITE_BUDDY", gettext("Add favorite")); $content->setVariable("ADD_FAVORITE_BUDDY", "Favorit hinzufügen"); $content->setVariable("FAVORITE_BUDDY_LINK", PATH_URL . "favorite/add/" . $urlId . "/" . $category . "/"); } else { //$content->setVariable("ALREADY_BUDDY", gettext("Already your favorite")); $content->setVariable("ALREADY_BUDDY", "Bereits Teil der Favoritenliste"); } $content->parse("BLOCK_SEARCH_RESULTS"); $loopCount++; } else { if ($category == "group") { $content->setCurrentBlock("BLOCK_GROUP_LIST"); $content->setVariable("GROUP_NAME", $resultEntry); $resultGroup = \steam_factory::get_object($GLOBALS["STEAM"]->get_id(), $urlId); $groupDesc = $resultGroup->get_attribute("OBJ_DESC"); $content->setVariable("GROUP_DESC", $groupDesc); if (!$steamUser->is_buddy($resultGroup)) { $content->setVariable("ADD_FAVORITE_GROUP", "Favorit hinzufügen"); //$content->setVariable("ALREADY_BUDDY", "Bereits Teil der Favoritenliste"); $content->setVariable("FAVORITE_GROUP_LINK", PATH_URL . "favorite/add/" . $urlId . "/" . $category . "/"); } else { $content->setVariable("ALREADY_GROUP", "Bereits Teil der Favoritenliste"); } $content->parse("BLOCK_GROUP_LIST"); $loopCount++; } } } } if ($loopCount == 0 || count($searchResult) == 0) { $content->setVariable("NO_RESULT", "Suchanfrage ergab keinen Treffer"); } } $headline = new \Widgets\Breadcrumb(); //$headline->setData(array(array("name"=>gettext("Profile"), "link"=>PATH_URL."profile/index/"),array("name"=>" / ".gettext("Favorites"), "link"=>PATH_URL."favorite/index/"),array("name"=>" / ".gettext("Favorite search")))); $headline->setData(array(array("name" => "Profil", "link" => PATH_URL . "profile/index/"), array("name" => "Favoriten", "link" => PATH_URL . "favorite/index/"), array("name" => "Favoritensuche"))); $rawHtml = new \Widgets\RawHtml(); $rawHtml->setHtml($content->get()); $frameResponseObject->addWidget($headline); $frameResponseObject->addWidget($rawHtml); return $frameResponseObject; }