Changeset 103 for trunk/Modules/Portal/UModulePortal.pas
- Timestamp:
- Oct 8, 2012, 8:48:16 AM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Modules/Portal/UModulePortal.pas
r102 r103 6 6 7 7 uses 8 Classes, SysUtils, UModularSystem, SpecializedDictionary, USqlDatabase; 8 Classes, SysUtils, UModularSystem, SpecializedDictionary, USqlDatabase, 9 UUtils, UWebSession, SpecializedList, UUser; 9 10 10 11 type … … 14 15 TModulePortal = class(TModule) 15 16 private 17 Time: TDateTime; 18 function ShowFooter(Session: TWebSession): string; 19 function ShowHeader(Session: TWebSession): string; 16 20 public 17 21 constructor Create(Owner: TComponent); override; … … 40 44 License := 'GNU/LGPL v3'; 41 45 Author := 'Chronosoft'; 46 Dependencies.Add('User'); 42 47 end; 43 48 … … 69 74 70 75 Core.CommonDatabase.Query(DbRows, 71 'CREATE TABLE IF NOT EXISTS `User` (' + 72 ' `Id` int(11) NOT NULL AUTO_INCREMENT,' + 73 ' `Name` varchar(255) NOT NULL,' + 74 ' `FullName` varchar(255) NOT NULL,' + 75 ' `Password` varchar(255) NOT NULL,' + 76 ' `Salt` varchar(255) NOT NULL,' + 77 ' `Email` varchar(255) NOT NULL,' + 78 ' `RegistrationTime` datetime NOT NULL,' + 76 'CREATE TABLE IF NOT EXISTS `Panel` (' + 77 ' `Id` int(11) NOT NULL AUTO_INCREMENT,' + 78 ' `Module` varchar(255) COLLATE utf8_czech_ci NOT NULL,' + 79 ' `Parameters` varchar(255) COLLATE utf8_czech_ci NOT NULL,' + 80 ' `Order` int(11) NOT NULL,' + 81 ' `PanelColumn` int(11) NOT NULL,' + 82 ' PRIMARY KEY (`Id`),' + 83 ' KEY `PanelColumn` (`PanelColumn`)' + 84 ') ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_czech_ci AUTO_INCREMENT=1 ;'); 85 86 Core.CommonDatabase.Query(DbRows, 87 'CREATE TABLE IF NOT EXISTS `PanelColumn` (' + 88 ' `Id` int(11) NOT NULL AUTO_INCREMENT,' + 89 ' `Width` varchar(255) COLLATE utf8_czech_ci NOT NULL,' + 79 90 ' PRIMARY KEY (`Id`)' + 80 ') ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;'); 81 82 Data.Add('Id', '1'); 83 Data.Add('Name', 'anonymous'); 84 Data.Add('FullName', 'Anonymous'); 85 Data.Add('RegistrationTime', 'NOW()'); 86 Data.Add('Password', ''); 87 Data.Add('Salt', ''); 88 Data.Add('Email', ''); 89 Core.CommonDatabase.Insert('User', Data); 90 91 Core.CommonDatabase.Query(DbRows, 92 'CREATE TABLE IF NOT EXISTS `UserOnline` (' + 93 ' `Id` int(11) NOT NULL AUTO_INCREMENT,' + 94 ' `User` int(11) NOT NULL DEFAULT ''0'',' + 95 ' `ActivityTime` datetime NOT NULL DEFAULT ''0000-00-00 00:00:00'',' + 96 ' `LoginTime` datetime NOT NULL DEFAULT ''0000-00-00 00:00:00'',' + 97 ' `SessionId` varchar(255) COLLATE utf8_czech_ci NOT NULL DEFAULT '''',' + 98 ' `IpAddress` varchar(16) COLLATE utf8_czech_ci NOT NULL DEFAULT '''',' + 99 ' `HostName` varchar(255) COLLATE utf8_czech_ci NOT NULL DEFAULT '''',' + 100 ' `ScriptName` varchar(255) COLLATE utf8_czech_ci NOT NULL,' + 91 ') ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_czech_ci AUTO_INCREMENT=1 ;'); 92 93 Core.CommonDatabase.Query(DbRows, 94 'ALTER TABLE `Panel`' + 95 ' ADD CONSTRAINT `Panel_ibfk_1` FOREIGN KEY (`PanelColumn`) REFERENCES `panelcolumn` (`Id`);'); 96 97 Core.CommonDatabase.Query(DbRows, 98 'CREATE TABLE IF NOT EXISTS `HyperlinkGroup` (' + 99 ' `Id` int(11) NOT NULL AUTO_INCREMENT,' + 100 ' `Name` varchar(255) COLLATE utf8_czech_ci NOT NULL,' + 101 ' PRIMARY KEY (`Id`)' + 102 ') ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_czech_ci AUTO_INCREMENT=1 ;'); 103 104 Core.CommonDatabase.Query(DbRows, 105 'CREATE TABLE IF NOT EXISTS `Hyperlink` (' + 106 ' `Id` int(11) NOT NULL AUTO_INCREMENT,' + 107 ' `Name` varchar(255) COLLATE utf8_czech_ci NOT NULL,' + 108 ' `URL` varchar(255) COLLATE utf8_czech_ci NOT NULL,' + 109 ' `Group` int(11) NOT NULL,' + 110 ' `IconFile` varchar(255) COLLATE utf8_czech_ci NOT NULL,' + 111 ' `PermissionModule` varchar(255) COLLATE utf8_czech_ci NOT NULL,' + 112 ' `PermissionOperation` varchar(255) COLLATE utf8_czech_ci NOT NULL,' + 113 ' `Enable` int(11) NOT NULL DEFAULT "1",' + 101 114 ' PRIMARY KEY (`Id`),' + 102 ' KEY `User` (`User`)' + 103 ') ENGINE=MEMORY DEFAULT CHARSET=utf8 COLLATE=utf8_czech_ci AUTO_INCREMENT=1 ;'); 115 ' KEY `Group` (`Group`),' + 116 ' KEY `Enable` (`Enable`)' + 117 ') ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_czech_ci AUTO_INCREMENT=1 ;'); 118 119 Core.CommonDatabase.Query(DbRows, 120 'ALTER TABLE `Hyperlink`' + 121 ' ADD CONSTRAINT `Hyperlink_ibfk_1` FOREIGN KEY (`Group`) REFERENCES `hyperlinkgroup` (`Id`);'); 122 104 123 finally 105 124 Data.Free; … … 116 135 try 117 136 DbRows := TDbRows.Create; 118 Core.CommonDatabase.Query(DbRows, 'DROP TABLE IF EXISTS `User`'); 119 Core.CommonDatabase.Query(DbRows, 'DROP TABLE IF EXISTS `UserOnline`'); 137 Core.CommonDatabase.Query(DbRows, 'DROP TABLE IF EXISTS `Panel`'); 138 Core.CommonDatabase.Query(DbRows, 'DROP TABLE IF EXISTS `PanelColumn`'); 139 Core.CommonDatabase.Query(DbRows, 'DROP TABLE IF EXISTS `Hyperlink`'); 140 Core.CommonDatabase.Query(DbRows, 'DROP TABLE IF EXISTS `HyperlinkGroup`'); 120 141 finally 121 142 DbRows.Free; … … 128 149 end; 129 150 151 function TModulePortal.ShowHeader(Session: TWebSession): string; 152 var 153 ScriptName: string; 154 PathTreePath: string; 155 Navigation: string; 156 ScriptNameParts: TListString; 157 ScriptNamePart: string; 158 I: Integer; 159 BodyParam: string; 160 Path: string; 161 Output: string; 162 begin 163 try 164 ScriptNameParts := TListString.Create; 165 166 //ScriptName := $_SERVER['SCRIPT_NAME']; 167 while Pos('//', ScriptName) > 0 do 168 ScriptName := StringReplace('//', '/', ScriptName, [rfReplaceAll]); 169 PathTreePath := '/'; 170 //PathTreeItem := PathTree; 171 //Navigation := '<a href="' + NavigationLink(PathTreePath) + '">' + PathTreeItem[0] + '</a> > '; 172 ScriptName := Copy(ScriptName, Length(Core.BaseURL), Length(ScriptName)); 173 ScriptNameParts.Explode(ScriptName, '/', StrToStr); 174 ScriptNameParts.Delete(0); 175 (* 176 for I := 0 to ScriptNameParts.Count - 1 do begin 177 ScriptNamePart := ScriptNameParts[I]; 178 //echo($ScriptNamePart.'<br />'); 179 if array_key_exists($ScriptNamePart, $PathTreeItem) then begin 180 if is_array($PathTreeItem[$ScriptNamePart]) then begin 181 182 PathTreeItem = $PathTreeItem[$ScriptNamePart]; 183 PathTreePath .= $ScriptNamePart.'/'; 184 if PathTreeItem[0] != '' then 185 Navigation := Navigation + '<a href="' + $this->System->Config['Web']['RootFolder'] + PathTreePath + '">' + PathTreeItem[0] + '</a> > '; 186 end else begin 187 if(PathTreeItem[ScriptNamePart] != '') 188 Navigation := Navigation + '<a href="' + $this->System->Config['Web']['RootFolder'].$PathTreePath.$ScriptNamePart.'">'.$PathTreeItem[$ScriptNamePart].'</a> > '; 189 end; 190 end; 191 end; *) 192 Navigation := Copy(Navigation, 1, Length(Navigation) - 6); 193 194 BodyParam := ''; 195 //if(isset($this->Load)) BodyParam := BodyParam + ' onload="'.$this->Load.'"'; 196 //if(isset($this->Unload)) BodyParam := BodyParam + ' onunload="'.$this->Unload.'"'; 197 Output := '<?xml version="1.0" encoding="' + Core.Charset + '"?>' + LineEnding + 198 '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">' + 199 '<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="cs" lang="cs">' + 200 '<head><link rel="stylesheet" href="' + NavigationLink('/style/' + Core.Style + '/style.css') + '" type="text/css" media="all" />' + 201 '<meta http-equiv="content-type" content="application/xhtml+xml; charset=' + Core.Charset + '" />' + 202 '<script type="text/javascript" src="' + Core.BaseURL + '/style/' + Core.Style + '/global.js"></script>' + 203 '<title>' + Session.GlobalTitle + ' - ' + Path + '</title>' + 204 '</head><body' + BodyParam + '>' + 205 '<div id="Title">' + Title + '</div>' + 206 '<div class="Navigation"><span class="MenuItem"><strong>Navigace :: </strong> '; 207 Output := Output + Navigation + '</span><div class="MenuItem2">'; 208 if Session.User.Id = UnknownUser then 209 Output := Output + '<a href="' + MakeLink('Přihlášení', 210 NavigationLink('/?Action=LoginForm')) + ' ' + 211 MakeLink('Registrace', NavigationLink('/?Action=UserRegister')) 212 else Output := Output + Session.User.Name + ' ' + MakeLink('Odhlásit', 213 NavigationLink('/?Action=Logout')); 214 // <a href="'.$this->System->Config['Web']['RootFolder'].'/?Action=UserOptions">Nastavení</a>'; 215 Output := Output + '</div></div>'; 216 Result := Output; 217 finally 218 ScriptNameParts.Free; 219 end; 220 end; 221 222 function TModulePortal.ShowFooter(Session: TWebSession): string; 223 begin 224 //Time := Round(Now - $ScriptTimeStart, 2); 225 Result := Result + '<div id="Footer">' + 226 '<i>| Správa webu: ' + Core.Admin + ' | e-mail: ' + Core.AdminEmail + ' |'; 227 // if Core.ShowRuntimeInfo then Output := Output + ' Doba generování: ' + 228 // Time + ' s / ' + ini_get('max_execution_time') + ' s | Použitá paměť: ' + 229 // HumanSize(memory_get_peak_usage(FALSE)) + ' / ' + ini_get('memory_limit') + 'B |'; 230 Result := Result + '</i></div></body></html>'; 231 end; 232 130 233 end. 131 234
Note:
See TracChangeset
for help on using the changeset viewer.