Ignore:
Timestamp:
Jan 16, 2009, 1:41:07 PM (15 years ago)
Author:
george
Message:
  • Opraveno: Zobrazní aktualit na hlavní stránce.
  • Přidáno: Nástřel databázové objektové vrstvy.
Location:
devel/web
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • devel/web

    • Property svn:ignore
      •  

        old new  
        77
        88index.compiled
         9
         10UConfig.pas
  • devel/web/UNewsPage.pas

    r138 r139  
    1212
    1313uses
    14   USqlDatabase, UCore, SysUtils, pwmain, UNews;
     14  USqlDatabase, UCore, SysUtils, pwmain, UNews, UConfig;
     15
     16function NewsChannelBuild: string;
     17var
     18  URL: string;
     19  I: Integer;
     20  Count: Integer;
     21  Index: string;
     22begin
     23  Result := ShowHeader('<strong>ZděchovNET</strong> - komunitní počítačová síť', 'Aktuality');
     24  URL := '';
     25  Count := CountCgiVars;
     26  for I := 0 to Count - 1 do begin
     27    Index := FetchCgiVarName(I);
     28    if Copy(Index, 1, 8) = 'category' then URL := URL + '-' + Copy(Index, 9, Length(Index));
     29  end;
     30  URL := WebServerAddress + '?p=news-rss&amp;select=' + Copy(URL, 2, Length(URL));
     31  Result := Result + 'Výsledný RSS kanál: <a href="' + URL + '">' + URL + '</a>';
     32  Result := Result + ShowFooter;
     33end;
    1534
    1635function NewsChannelSelection: string;
     36var
     37  DbRows: TDbRows;
     38  I: Integer;
    1739begin
    1840  Result := ShowHeader('<strong>ZděchovNET</strong> - komunitní počítačová síť', 'Aktuality');
     41  Result := Result + 'Vytvořte si vlastní RSS kanál, díky kterému budete moci automaticky sledovat novinky pomocí vaší RSS čtečky. ' +
     42  'Informace o technologii RSS a programech pro čtení kanálů najdete např. <a href="http://www.lupa.cz/clanky/prehled-rss-ctecek/">zde</a><br />' +
     43  '<br />Kategorie:<br />';
     44  Result := Result + '<form action="?p=news-build" method="post">';
     45  DbRows := Database.Select('news_category', '*', '1 ORDER BY caption');
     46  for I := 0 to DbRows.Count - 1 do
     47    Result := Result + '<input type="checkbox" name="category' + DbRows[I].Values['id'] + '">' +
     48      DbRows[I].Values['caption']+ '<br />';
     49  Result := Result + '<input type="submit" value="Sestavit ">' +
     50    '</form>';
    1951  Result := Result + ShowFooter;
    2052end;
     
    3668  Result := ShowHeader('<strong>ZděchovNET</strong> - komunitní počítačová síť', 'Aktuality');
    3769  if GetCgiVar('id') = '' then Id := 1 else Id := StrToInt(GetCgiVar('id')); 
    38   DbRows := Database.Query('SELECT `news`.*, `User`.`Name` FROM `news` LEFT JOIN `User` ON `User`.`Id`=`news`.`User` WHERE  `news`.`id`=' + IntToStr(Id));
     70  DbRows := Database.Query('SELECT `news`.*, UNIX_TIMESTAMP(`news`.date) as time, `User`.`Name` FROM `news` LEFT JOIN `User` ON `User`.`Id`=`news`.`User` WHERE  `news`.`id`=' + IntToStr(Id));
    3971  if DbRows.Count > 0 then begin
    4072    NewsItem.LoadFromDbRecord(DbRows[0]);
     
    89121  Result := Result + PagesList('?p=news-list&amp;category=' + IntToStr(Category) + '&amp;page=', Page, PageMax, PerPage);
    90122
    91   DbRows := Database.Query('SELECT `news`.*, `User`.`Name` FROM `news` LEFT JOIN `User` ON `User`.`Id`=`news`.`User` WHERE `category`=' + IntToStr(Category) + ' ORDER BY `news`.`id` DESC LIMIT ' + IntToStr(Page * PerPage) + ',' + IntToStr(PerPage));
     123  DbRows := Database.Query('SELECT `news`.*, UNIX_TIMESTAMP(`news`.date) as time, `User`.`Name` FROM `news` LEFT JOIN `User` ON `User`.`Id`=`news`.`User` WHERE `category`=' + IntToStr(Category) + ' ORDER BY `news`.`id` DESC LIMIT ' + IntToStr(Page * PerPage) + ',' + IntToStr(PerPage));
    92124  for I := 0 to DbRows.Count - 1 do begin
    93125    NewsItem.LoadFromDbRecord(DbRows[I]);
     
    128160RegisterPage('news-rss', @RSSChannel);
    129161RegisterPage('news-selection', @NewsChannelSelection);
     162RegisterPage('news-build', @NewsChannelBuild);
    130163
    131164end.
Note: See TracChangeset for help on using the changeset viewer.