Changeset 286 for branches/web/UNews.pas
- Timestamp:
- Sep 8, 2010, 10:08:43 AM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/web/UNews.pas
r279 r286 55 55 procedure TNewsItem.LoadFromDbRecord(DbRow: TAssociativeArray); 56 56 begin 57 Id := StrToInt(DbRow.Values[' id']);58 Title := DbRow.Values[' title'];59 Content := DbRow.Values[' content'];60 Time := UnixToDateTime(StrToInt(DbRow.Values[' time']));61 Author := DbRow.Values[' author'];62 IPAddress := DbRow.Values[' ip'];63 Category := StrToInt(DbRow.Values[' category']);57 Id := StrToInt(DbRow.Values['Id']); 58 Title := DbRow.Values['Title']; 59 Content := DbRow.Values['Content']; 60 Time := UnixToDateTime(StrToInt(DbRow.Values['Time'])); 61 Author := DbRow.Values['Author']; 62 IPAddress := DbRow.Values['IP']; 63 Category := StrToInt(DbRow.Values['Category']); 64 64 end; 65 65 … … 69 69 begin 70 70 Values := TAssociativeArray.Create; 71 Values.AddKeyValue(' content', Content);72 Values.AddKeyValue(' title', Title);73 Values.AddKeyValue(' author', Author);74 Values.AddKeyValue(' ip', IPAddress);75 Values.AddKeyValue(' time', IntToStr(DateTimeToUnix(Time)));76 Values.AddKeyValue(' category', IntToStr(Category));77 Database.Update(' news', Values, 'id=' + IntToStr(Id));71 Values.AddKeyValue('Content', Content); 72 Values.AddKeyValue('Title', Title); 73 Values.AddKeyValue('Author', Author); 74 Values.AddKeyValue('IP', IPAddress); 75 Values.AddKeyValue('Time', IntToStr(DateTimeToUnix(Time))); 76 Values.AddKeyValue('Category', IntToStr(Category)); 77 Database.Update('News', Values, 'Id=' + IntToStr(Id)); 78 78 Values.Free; 79 79 inherited; … … 116 116 Where := ''; 117 117 for I := 0 to High(SelectParts) do 118 Where := Where + 'OR ( category=' + SelectParts[I] + ')';118 Where := Where + 'OR (Category=' + SelectParts[I] + ')'; 119 119 Where := Copy(Where, 3, Length(Where)); 120 120 if Where = '' then Where := '1'; 121 121 122 DbRows := Database.Query('SELECT *,UNIX_TIMESTAMP( date) as time FROM news WHERE ' + Where + ' ORDER BY date DESC LIMIT 0,' + IntToStr(MaxNewsItemCount)); for I := 0 to DbRows.Count - 1 do begin122 DbRows := Database.Query('SELECT *,UNIX_TIMESTAMP(Date) AS Time FROM News WHERE ' + Where + ' ORDER BY Date DESC LIMIT 0,' + IntToStr(MaxNewsItemCount)); for I := 0 to DbRows.Count - 1 do begin 123 123 NewsItem.LoadFromDbRecord(DbRows[I]); 124 124 NewItem := TRSSChannelItem.Create; … … 171 171 NewCategory: TNewsCategory; 172 172 begin 173 DbRows := Database.Select(' news_category', '*');173 DbRows := Database.Select('NewsCategory', '*'); 174 174 for I := 0 to DbRows.Count - 1 do begin 175 175 NewCategory := TNewsCategory.Create; … … 184 184 procedure TNewsCategory.LoadFromDbRecord(DbRow: TAssociativeArray); 185 185 begin 186 Id := StrToInt(DbRow.Values[' id']);187 Title := DbRow.Values[' caption'];188 Permission := StrToInt(DbRow.Values[' permission']);186 Id := StrToInt(DbRow.Values['Id']); 187 Title := DbRow.Values['Caption']; 188 Permission := StrToInt(DbRow.Values['Permission']); 189 189 end; 190 190 … … 194 194 begin 195 195 Values := TAssociativeArray.Create; 196 Values.AddKeyValue(' permission', IntToStr(Permission));197 Values.AddKeyValue(' title', Title);198 Database.Update(' news_category', Values, 'id=' + IntToStr(Id));196 Values.AddKeyValue('Permission', IntToStr(Permission)); 197 Values.AddKeyValue('Title', Title); 198 Database.Update('NewsCategory', Values, 'Id=' + IntToStr(Id)); 199 199 Values.Free; 200 200 inherited; … … 222 222 '<table class="NewsTable" cellspacing="0" cellpadding="0">'; 223 223 FontSize := 12; 224 DbRows := Database.Select(' news', '*', 'category=' + IntToStr(Category) + ' ORDER BY date DESC LIMIT 0,' + IntToStr(NewsCountPerCategory));224 DbRows := Database.Select('News', '*', 'Category=' + IntToStr(Category) + ' ORDER BY Date DESC LIMIT 0,' + IntToStr(NewsCountPerCategory)); 225 225 for I := 0 to DbRows.Count - 1 do with DbRows[I] do begin 226 Content := Values[' content'];226 Content := Values['Content']; 227 227 Content := StringReplace(Content, '<br>', '<br />', [rfReplaceAll]); 228 Result := Result + '<tr><td onclick="window.location=''?p=news-item&id=' + Values[' id'] + '''" onmouseover="zobraz(''new' + Values['id'] + ''')" class="NewsTableItemTitle">' +228 Result := Result + '<tr><td onclick="window.location=''?p=news-item&id=' + Values['Id'] + '''" onmouseover="zobraz(''new' + Values['id'] + ''')" class="NewsTableItemTitle">' + 229 229 '<table class="NewsTableItemTitle">' + 230 '<tr><td style="font-size: ' + IntToStr(FontSize) + 'pt"><strong>' + Values[' title'] + '</strong></td>'+231 '<td align="right" style="font-size: ' + IntToStr(FontSize) + 'pt">' + Values[' author'] + ' (' + HumanDate(Values['date']) + ')' +230 '<tr><td style="font-size: ' + IntToStr(FontSize) + 'pt"><strong>' + Values['Title'] + '</strong></td>'+ 231 '<td align="right" style="font-size: ' + IntToStr(FontSize) + 'pt">' + Values['Author'] + ' (' + HumanDate(Values['date']) + ')' + 232 232 '</td></tr></table>' + 233 '<div id="new' + Values[' id'] + '" class="NewsTableItem">' + Content;234 235 if Values[' enclosure'] <> '' then begin233 '<div id="new' + Values['Id'] + '" class="NewsTableItem">' + Content; 234 235 if Values['Enclosure'] <> '' then begin 236 236 Result := Result + '<br />Přílohy: '; 237 Enclosures := Explode(';', Values[' enclosure']);237 Enclosures := Explode(';', Values['Enclosure']); 238 238 for II := 0 to High(Enclosures) do begin 239 239 // if(file_exists($UploadedFilesFolder.$Enclosure)) echo(' <a href="'.$UploadedFilesFolder.$Enclosure.'">'.$Enclosure.'</a>')
Note:
See TracChangeset
for help on using the changeset viewer.