Changeset 626 for trunk/Modules/Search/Search.php
- Timestamp:
- Dec 4, 2013, 9:50:16 PM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Modules/Search/Search.php
r595 r626 14 14 $this->Description = 'Allow test search in other modules content.'; 15 15 $this->Dependencies = array(); 16 $this->SearchItems = array(); 16 17 } 17 18 … … 21 22 } 22 23 23 function Register Content($Name, $Columns, $Query)24 function RegisterSearch($Name, $Title, $Columns, $Query, $Link) 24 25 { 25 $this->SearchItems[$Name] = array('Columns' => $Columns, 'Query' => $Query); 26 // Query can be table name or subselect query 27 $this->SearchItems[$Name] = array('Name' => $Title, 'Columns' => $Columns, 28 'Query' => $Query, 'Link' => $Link); 26 29 } 27 30 28 function Unregister Content($Name)31 function UnregisterSearch($Name) 29 32 { 30 33 unset($this->SearchItems[$Name]); … … 36 39 function Show() 37 40 { 38 global $TranslationTree;39 40 41 if(array_key_exists('text', $_GET)) $Search = $_GET['text']; 41 42 else if(array_key_exists('text', $_POST)) $Search = $_POST['text']; 42 43 else $Search = ''; 43 44 $SearchHTML = htmlentities($Search); 44 45 $Output = '<table class="BaseTable"><tr><th> Skupina</th><th>Výsledků</th></tr>';46 foreach($ TranslationTree as $Group)45 46 $Output = '<table class="BaseTable"><tr><th>'.T('Section').'</th><th>'.T('Found count').'</th></tr>'; 47 foreach($this->System->ModuleManager->Modules['Search']->SearchItems as $SearchItem) 47 48 { 48 $Table = $Group['TablePrefix']; 49 50 $sql = 'SELECT COUNT(*) FROM `'.$Table.'` WHERE '. 51 ' (`ID` LIKE "%'.$Search.'%")'. 52 ' OR (`Entry` LIKE "%'.$Search.'%")'; 53 foreach($Group['Items'] as $Item) 49 $ColumnQuery = array(); 50 foreach($SearchItem['Columns'] as $Column) 54 51 { 55 if($Item['Column'] != '') $sql .= ' OR (`'.$Item['Column'].'` LIKE "%'.$Search.'%")'; 56 } 57 $DbResult = $this->Database->query($sql); 58 $Line = $DbResult->fetch_row(); 59 if ($Line[0] <> '0') 60 $Output .= '<tr><td><a href="'.$this->System->Link('/TranslationList.php?group='. 61 $Group['Id'].'&user=0&state=0&text='.$SearchHTML.'&entry=').'">'. 62 $Group['Name'].'</a></td><td>'.$Line[0].'</td></tr>'; 52 $ColumnQuery[] = '(`'.$Column.'` LIKE "%'.$Search.'%")'; 53 } 54 $ColumnQuery = implode(' OR ', $ColumnQuery); 55 if($SearchItem['Query'] != '') 56 { 57 $DbResult = $this->Database->query('SELECT COUNT(*) FROM '.$SearchItem['Query'].' WHERE '.$ColumnQuery); 58 $Line = $DbResult->fetch_row(); 59 $Line = $Line[0]; 60 } else $Line = ''; 61 $Output .= '<tr><td><a href="'.$SearchItem['Link'].$SearchHTML.'">'.$SearchItem['Name'].'</a></td><td>'.$Line.'</td></tr>'; 63 62 } 64 65 $DbResult = $this->Database->query('SELECT count(*) FROM `User` WHERE `Name` LIKE "%'.$Search.'%"'); 66 $Line = $DbResult->fetch_row(); 67 $Output .= '<tr><td><a href="'.$this->System->Link('/userlist.php?search='.$SearchHTML).'">Uživatelé</a></td><td>'.$Line[0].'</td></tr>'; 68 69 $DbResult = $this->Database->query('SELECT count(*) FROM `Team` WHERE `Name` LIKE "%'.$Search.'%" OR `Description` LIKE "%'.$Search.'%"'); 70 $Line = $DbResult->fetch_row(); 71 $Output .= '<tr><td><a href="'.$this->System->Link('/team/?search='.$SearchHTML).'">Týmy</a></td><td>'.$Line[0].'</td></tr>'; 72 73 $DbResult = $this->Database->query('SELECT count(*) FROM `CzWoWPackageVersion` WHERE `Text` LIKE "%'.$Search.'%"'); 74 $Line = $DbResult->fetch_row(); 75 $Output .= '<tr><td><a href="'.$this->System->Link('/download.php?addon').'">Čeština pro klienta</a></td><td>'.$Line[0].'</td></tr>'; 76 $Output .= '<tr><td><a href="'.$this->System->Link('/aowow/?search='.$SearchHTML).'">Vyhledávací databáze AoWoW</a></td></tr>'; 77 78 $DbResult = $this->Database->query('SELECT count(*) FROM `Dictionary` WHERE '. 79 '(`Text` LIKE "%'.$Search.'%" OR `Description` LIKE "%'.$Search.'%") AND `Language` = '.$this->System->Config['OriginalLanguage']); 80 $Line = $DbResult->fetch_row(); 81 $Output .= '<tr><td><a href="'.$this->System->Link('/dictionary/?search='.$SearchHTML). 82 '">Slovníček</a></td><td>'.$Line[0].'</td></tr>'; 83 84 $Output .= '</table>'; 63 64 $Output .= '</table>'; 85 65 return($Output); 86 66 }
Note:
See TracChangeset
for help on using the changeset viewer.