Changeset 286 for branches/web/UNews.pas


Ignore:
Timestamp:
Sep 8, 2010, 10:08:43 AM (14 years ago)
Author:
george
Message:
  • Odstraněno: Nadále nebude používána sada knihoven powutils.
  • Přidáno: Vlastní třída pro obsluhu a podporu zpracování CGI programů.
  • Upraveno: Korekce názvů sloupců a tabulek databáze.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/web/UNews.pas

    r279 r286  
    5555procedure TNewsItem.LoadFromDbRecord(DbRow: TAssociativeArray);
    5656begin
    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']);
    6464end;
    6565
     
    6969begin
    7070  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));
    7878  Values.Free;
    7979  inherited;
     
    116116  Where := '';
    117117  for I := 0 to High(SelectParts) do
    118     Where := Where + 'OR (category=' + SelectParts[I] + ')';
     118    Where := Where + 'OR (Category=' + SelectParts[I] + ')';
    119119  Where := Copy(Where, 3, Length(Where));
    120120  if Where = '' then Where := '1';
    121121
    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 begin
     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 begin
    123123    NewsItem.LoadFromDbRecord(DbRows[I]);
    124124    NewItem := TRSSChannelItem.Create;
     
    171171  NewCategory: TNewsCategory;
    172172begin
    173   DbRows := Database.Select('news_category', '*');
     173  DbRows := Database.Select('NewsCategory', '*');
    174174  for I := 0 to DbRows.Count - 1 do begin
    175175    NewCategory := TNewsCategory.Create;
     
    184184procedure TNewsCategory.LoadFromDbRecord(DbRow: TAssociativeArray);
    185185begin
    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']);
    189189end;
    190190
     
    194194begin
    195195  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));
    199199  Values.Free;
    200200  inherited;
     
    222222    '<table class="NewsTable" cellspacing="0" cellpadding="0">';
    223223  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));
    225225  for I := 0 to DbRows.Count - 1 do with DbRows[I] do begin
    226     Content := Values['content'];
     226    Content := Values['Content'];
    227227    Content := StringReplace(Content, '<br>', '<br />', [rfReplaceAll]);
    228     Result := Result + '<tr><td  onclick="window.location=''?p=news-item&amp;id=' + Values['id'] + '''" onmouseover="zobraz(''new' + Values['id'] + ''')" class="NewsTableItemTitle">' +
     228    Result := Result + '<tr><td  onclick="window.location=''?p=news-item&amp;id=' + Values['Id'] + '''" onmouseover="zobraz(''new' + Values['id'] + ''')" class="NewsTableItemTitle">' +
    229229      '<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']) + ')' +
    232232      '</td></tr></table>' +
    233       '<div id="new' + Values['id'] + '" class="NewsTableItem">' + Content;
    234 
    235     if Values['enclosure'] <> '' then begin
     233      '<div id="new' + Values['Id'] + '" class="NewsTableItem">' + Content;
     234
     235    if Values['Enclosure'] <> '' then begin
    236236      Result := Result + '<br />Přílohy: ';
    237       Enclosures := Explode(';', Values['enclosure']);
     237      Enclosures := Explode(';', Values['Enclosure']);
    238238            for II := 0 to High(Enclosures) do begin
    239239              // if(file_exists($UploadedFilesFolder.$Enclosure)) echo(' <a href="'.$UploadedFilesFolder.$Enclosure.'">'.$Enclosure.'</a>')
Note: See TracChangeset for help on using the changeset viewer.