Changeset 393 for trunk/includes/global_function.php
- Timestamp:
- Mar 17, 2010, 1:21:49 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/includes/global_function.php
r382 r393 462 462 } 463 463 464 function GetIDbyName($Table) 465 { 466 global $TranslationTree; 467 468 foreach($TranslationTree as $TableID => $Value) 469 { 470 //echo $Value['TablePrefix'].'='.$Table.'<br>'; 471 if ($Value['TablePrefix'] == $Table) return $TableID; 472 } 473 } 474 475 476 function GetTranslatNames($Text,$mode,$TablesColumn) 477 { 478 global $Database; 479 480 /* $TablesID = array('gameobject' => 5, 481 'creature' => 6, 482 'item' => 4, 483 'transports' => 'Name', 484 'areatrigger_teleport' => 'Name', 485 'areatrigger_tavern' => 'Name',); */ 486 $buff = array(); 487 488 foreach($TablesColumn as $Table => $Column) 489 { 490 $sql = 'SELECT `ID`,`'.$Column.'`, (SELECT `'.$Column.'` FROM `'.$Table.'` AS `T` WHERE `O`.`Entry` = `T`.`Entry` AND `Language` <> 0 LIMIT 1) AS `Tran` FROM `'.$Table.'` AS `O` WHERE '; 491 $groupby = ' GROUP BY `'.$Column.'`'; 492 493 $ArrStr = explode(' ', $Text); 494 $where = '`Language` = 0 '; 495 if ($mode == 1) $where .= ' AND EXISTS(SELECT 1 FROM `'.$Table.'` AS `Sub` WHERE (`Sub`.`Language` <> 0) AND (`Sub`.`Entry` = `O`.`Entry`))'; 496 if ($mode == 2) $where .= ' AND NOT EXISTS(SELECT 1 FROM `'.$Table.'` AS `Sub` WHERE (`Sub`.`Language` <> 0) AND (`Sub`.`Entry` = `O`.`Entry`))'; 497 $where .= ' AND ('; 498 499 for($i = 0; $i < count($ArrStr); $i++) 500 { 501 if (strpos($ArrStr[$i],"'s") > 0) 502 $ArrStr[$i] = substr($ArrStr[$i],0,strlen($ArrStr[$i])-2); 503 if (strpos($ArrStr[$i],',') > 0) $ArrStr[$i] = substr($ArrStr[$i],0,strlen($ArrStr[$i])-1); 504 if (strpos($ArrStr[$i],'.') > 0) $ArrStr[$i] = substr($ArrStr[$i],0,strlen($ArrStr[$i])-1); 505 if (strpos($ArrStr[$i],'!') > 0) $ArrStr[$i] = substr($ArrStr[$i],0,strlen($ArrStr[$i])-1); 506 if (strpos($ArrStr[$i],'?') > 0) $ArrStr[$i] = substr($ArrStr[$i],0,strlen($ArrStr[$i])-1); 507 508 if (strlen($ArrStr[$i]) > 5) 509 $where .= '(`O`.`'.$Column.'` LIKE "%'.addslashes($ArrStr[$i]).'%") OR '; 510 } 511 $where = substr($where,0,strlen($where)-4); 512 $where .= ')'; 513 514 $ID = $Database->SQLCommand($sql.$where.$groupby); 515 //echo ($sql.$where.$groupby); 516 while($Line = mysql_fetch_assoc($ID)) 517 { 518 // if (($mode != 0) or (($mode == 0) and (strpos(strtolower($Text), strtolower($Line[2])) > 0) ) ) 519 $buff[] = array($Line['ID'],GetIDbyName($Table),$Line[$Column],$Line['Tran']); 520 } 521 } 522 return $buff; 523 } 464 524 ?>
Note:
See TracChangeset
for help on using the changeset viewer.