Changeset 887 for trunk/Modules/Search/Search.php
- Timestamp:
- Nov 20, 2020, 12:08:12 AM (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Modules/Search/Search.php
r874 r887 3 3 class PageSearch extends Page 4 4 { 5 function __construct( $System)5 function __construct(System $System) 6 6 { 7 7 parent::__construct($System); … … 11 11 } 12 12 13 function Show() 13 function Show(): string 14 14 { 15 15 $Output = ''; … … 21 21 '</form>'; 22 22 if ($Text != '') 23 foreach ( $this->System->ModuleManager->Modules['Search']->Items as $Item)23 foreach (ModuleSearch::Cast($this->System->GetModule('Search'))->Items as $Item) 24 24 { 25 25 $Columns = ''; … … 33 33 $Condition = substr($Condition, 3); 34 34 $DbResult = $this->Database->Select($Item['Table'], $Columns, $Condition.' LIMIT '. 35 $this->System->ModuleManager->Modules['Search']->MaxItemCount);35 ModuleSearch::Cast($this->System->GetModule('Search'))->MaxItemCount); 36 36 if ($DbResult->num_rows > 0) $Output .= '<strong>'.$Item['Name'].'</strong><br/>'; 37 37 while ($Row = $DbResult->fetch_assoc()) … … 49 49 class ModuleSearch extends AppModule 50 50 { 51 var$Items;52 var$MaxItemCount;51 public array $Items; 52 public int $MaxItemCount; 53 53 54 function __construct( $System)54 function __construct(System $System) 55 55 { 56 56 parent::__construct($System); … … 65 65 } 66 66 67 function DoStart() 67 function DoStart(): void 68 68 { 69 69 $this->System->Pages['search'] = 'PageSearch'; 70 70 } 71 71 72 function DoInstall() 72 function DoInstall(): void 73 73 { 74 74 } 75 75 76 function DoUnInstall() 76 function DoUnInstall(): void 77 77 { 78 78 } 79 79 80 function RegisterSearch( $Title, $TableName, $Columns)80 function RegisterSearch(string $Title, string $TableName, array $Columns): void 81 81 { 82 82 $this->Items[] = array('Name' => $Title, 'Table' => $TableName, 'Columns' => $Columns); 83 83 } 84 85 static function Cast(AppModule $AppModule): ModuleSearch 86 { 87 if ($AppModule instanceof ModuleSearch) 88 { 89 return $AppModule; 90 } 91 throw new Exception('Expected ModuleSearch type but got '.gettype($AppModule)); 92 } 84 93 }
Note:
See TracChangeset
for help on using the changeset viewer.