コード例 #1
0
ファイル: Search.php プロジェクト: kingboard/kingboard
 public function nameAlliance(array $params)
 {
     $id = 0;
     if (!empty($params['alliancename'])) {
         foreach (\Kingboard\Model\MapReduce\NameSearch::search($params['alliancename'], 1) as $result) {
             $id = $result->value['id'];
         }
         $this->redirect("/details/alliance/{$id}/");
         return;
     }
     return $this->error("unknown alliance");
 }
コード例 #2
0
ファイル: AutoCompleter.php プロジェクト: kingboard/kingboard
 public function search(array $search)
 {
     $result = array();
     $find = $search["text"];
     if (strlen($find) < 4) {
         echo json_encode(array());
         return;
     }
     foreach (\Kingboard\Model\MapReduce\NameSearch::search($find, 6) as $searchresult) {
         $result[] = $searchresult->_id;
     }
     echo json_encode($result);
     return;
 }
コード例 #3
0
ファイル: Kill.php プロジェクト: kingboard/kingboard
 public static function getFactionIdFromName($name)
 {
     $id = 0;
     foreach (\Kingboard\Model\MapReduce\NameSearch::search($name, 1) as $result) {
         $id = $result->value['id'];
     }
     if ($id > 0) {
         return $id;
     } else {
         // find a random kill with characterID $id
         $kill = parent::doFindOne(__CLASS__, array('$or' => array(array('victim.factionName' => $name), array('attackers.factionName' => $name))), array('victim.factionName' => 1, 'attackers.factionName' => 1, 'victim.factionID' => 1, 'attackers.factionID' => 1));
         if ($kill['victim']['factionName'] == $name) {
             return $kill['victim']['factionID'];
         } else {
             foreach ($kill['attackers'] as $attacker) {
                 if ($attacker['factionName'] == $name) {
                     return $attacker['factionID'];
                 }
             }
         }
         return false;
     }
 }