Changeset 893 for trunk/Modules/Wiki/Wiki.php
- Timestamp:
- Jan 4, 2021, 9:55:40 PM (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Modules/Wiki/Wiki.php
r887 r893 15 15 } 16 16 17 function DoInstall(): void 18 { 19 parent::Install(); 20 $this->Database->Query('CREATE TABLE IF NOT EXISTS `WikiPage` ( 21 `Id` int(11) NOT NULL AUTO_INCREMENT, 22 `Name` varchar(255) NOT NULL, 23 `NormalizedName` varchar(255) NOT NULL, 24 `VisibleInMenu` int(11) NOT NULL, 25 PRIMARY KEY (`Id`), 26 UNIQUE KEY `Name` (`Name`), 27 KEY `VisibleInMenu` (`VisibleInMenu`) 28 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1'); 29 $this->Database->Query('CREATE TABLE IF NOT EXISTS `WikiPageContent` ( 30 `Id` int(11) NOT NULL AUTO_INCREMENT, 31 `Page` int(11) NOT NULL, 32 `Time` datetime NOT NULL, 33 `Content` text NOT NULL, 34 `User` int(11) NOT NULL, 35 PRIMARY KEY (`Id`), 36 KEY `User` (`User`), 37 KEY `Page` (`Page`) 38 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1'); 39 $this->Database->Query('ALTER TABLE `WikiPageContent` 40 ADD CONSTRAINT `WikiPageContent_ibfk_2` FOREIGN KEY (`Page`) REFERENCES `WikiPage` (`Id`), 41 ADD CONSTRAINT `WikiPageContent_ibfk_1` FOREIGN KEY (`User`) REFERENCES `User` (`ID`)'); 42 } 43 44 function DoUnInstall(): void 45 { 46 $this->Database->query('DELETE TABLE `WikiPageContent`'); 47 $this->Database->query('DELETE TABLE `WikiPage`;'); 17 function GetModels(): array 18 { 19 return array('WikiPage', 'WikiPageContent'); 48 20 } 49 21 … … 51 23 { 52 24 $this->LoadPages(); 53 }54 55 function DoStop(): void56 {57 25 } 58 26 … … 71 39 ), 2); 72 40 } 41 } 42 } 43 44 class WikiPage extends Model 45 { 46 static function GetDesc(): ModelDesc 47 { 48 $Desc = new ModelDesc('WikiPage'); 49 $Desc->AddString('Name'); 50 $Desc->AddString('NormalizedName'); 51 $Desc->AddBoolean('VisibleInMenu'); 52 return $Desc; 53 } 54 } 55 56 class WikiPageContent extends Model 57 { 58 static function GetDesc(): ModelDesc 59 { 60 $Desc = new ModelDesc('WikiPageContent'); 61 $Desc->AddReference('Page', 'Page'); 62 $Desc->AddDateTime('Time'); 63 $Desc->AddText('Content'); 64 $Desc->AddReference('User', 'User'); 65 return $Desc; 73 66 } 74 67 }
Note:
See TracChangeset
for help on using the changeset viewer.