Ignore:
Timestamp:
Jan 16, 2009, 1:41:07 PM (16 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/UMainPage.pas

    r138 r139  
    1010
    1111uses
    12   USqlDatabase, UCore, UHtmlClasses, SysUtils;
    13 
    14 function ShowNews(Category: Integer): string;
    15 var
    16   DbRows: TDbRows;
    17   Index: Integer;
    18   FontSize: Integer;
    19   I: Integer;
    20   II: Integer;
    21   Enclosures: TArrayOfString;
    22   Content: string;
    23 const
    24   NewsCountPerCategory = 3;
    25 //  UploadedFilesFolder = 'aktuality/uploads/';
    26 begin
    27 //  global $NewsCategoryNames, $NewsCountPerCategory, $UploadedFilesFolder;
    28 
    29   DbRows := Database.Select('news_category', '*', 'id=' + IntToStr(Category));
    30 
    31   Result := '<table class="MainTable"><tr>' +
    32     '<td>' + DbRows[0].Values['caption'] + '</td><td align="right">'+
    33     '<a href="?p=news-list&amp;category=' + IntToStr(Category) + '">Zobrazit všechny aktuality</a>&nbsp;';
    34   if StrToInt(DbRows[0].Values['permission']) = 1 then
    35     Result := Result + '<a href="aktuality/index.php?action=add&amp;category=' + IntToStr(Category) + '">Přidat aktualitu</a>&nbsp;';
    36   Result := Result + '</td></tr><tr><td colspan="2">'+
    37     '<table>';
    38   Index := 0;
    39   FontSize := 12;
    40   DbRows := Database.Select('news', '*', 'category=' + IntToStr(Category) + ' ORDER BY date DESC LIMIT 0,' + IntToStr(NewsCountPerCategory));
    41   for I := 0 to DbRows.Count - 1 do with DbRows[I] do begin
    42     Content := Values['content'];
    43     Content := StringReplace(Content, '<br>', '<br />', [rfReplaceAll]);
    44     Result := Result + '<tr><td onmouseover="zobraz(''new' + IntToStr(Category) + '_' + IntToStr(I) + ''')" style="cursor: pointer; margin: 0px;"><table cellspacing="0" cellpadding="0" style="padding: 0px; margin: 0px; font-size: small; color: red;" width="100%">'+
    45       '<tr><td style="font-size: ' + IntToStr(FontSize) + 'pt"><strong>' + Values['title'] + '</strong></td>'+
    46       '<td align="right" style="font-size: ' + IntToStr(FontSize) + 'pt">' + Values['author'] + ' (' + HumanDate(Values['date']) + ')</td></tr></table>'+
    47       '<div id="new' + IntToStr(Category) + '_' + IntToStr(Index) + '" class="skryty" style="display: none; border-width: 1; border-style: solid; border-color: blue; padding: 3px; font-size: 9pt;">' + Content;
    48 
    49     if Values['enclosure'] <> '' then begin
    50       Result := Result + '<br />Přílohy: ';
    51       Enclosures := Explode(';', Values['enclosure']);
    52             for II := 0 to High(Enclosures) do begin
    53               // if(file_exists($UploadedFilesFolder.$Enclosure)) echo(' <a href="'.$UploadedFilesFolder.$Enclosure.'">'.$Enclosure.'</a>')
    54       end;
    55     end;
    56     Result := Result + '</div></td></tr>';
    57     Index := Index + 1;   
    58     FontSize := FontSize - 2;
    59   end;
    60   Result := Result + '</table></td></tr></table>';
    61 end;
     12  USqlDatabase, UCore, SysUtils, UNews;
    6213
    6314function MainPage: string;
     
    6617  DbRows: TDbRows;
    6718  I: Integer;
     19  News: TNews;
    6820begin
    6921  Output := ShowHeader('<strong>ZděchovNET</strong> - komunitní počítačová síť', 'Rozcestní­k');
     
    13284'<div class="Panel">';
    13385
    134   // Zobrazení seznamu online poèítaèù
     86  // Zobrazení seznamu online počítačů
    13587  Output := Output + '<strong>Online počítače:</strong><br /><span style="font-size: smaller;">';
    13688  DbRows := Database.Select('hosts', 'name', 'online=1 AND show_online=1 ORDER BY name');
     
    169121$Uptime = str_replace('day,','den a',$Uptime);
    170122$Uptime = str_replace('min,','minut',$Uptime);
    171 echo('Server bì¾í '.$Uptime);
     123echo('Server běží '.$Uptime);
    172124*)
    173125  Output := Output + '</div></td><td valign="top">';
     
    183135*)
    184136
    185   Output := Output + '<div onmouseout="skryj(predchozi)">' + ShowNews(5) + ShowNews(3) + ShowNews(1) + ShowNews(2) + ShowNews(4) + ShowNews(6) + ShowNews(8) + ShowNews(9) + ShowNews(10);
     137  News := TNews.Create;
     138  News.LoadFromDb;
     139  with News do
     140    Output := Output + '<div onmouseout="skryj(predchozi)">' + ShowNews(5) + ShowNews(3) + ShowNews(1) + ShowNews(2) + ShowNews(4) + ShowNews(6) + ShowNews(8) + ShowNews(9) + ShowNews(10);
     141  News.Free;
    186142
    187   Output := Output + '<a href="aktuality/subscription.php"><img src="images/rss20.png" alt="Aktuality přes RSS" /></a>  <a href="aktuality/subscription.php">Automatické sledování novinek</a>'+
     143  Output := Output + '<a href="?p=news-selection"><img src="images/rss20.png" alt="Aktuality přes RSS" /></a>  <a href="?p=news-selection">Automatické sledování novinek</a>'+
    188144  '</div></td></tr></table>';
    189145  Output := Output + ShowFooter;
     
    191147end;
    192148
    193 //var
    194 //  MainPage: THtmlPage;
    195149begin
    196   //MainPage := THtmlPage.Create;
    197   RegisterPage('index', @MainPage);   
     150  RegisterPage('index', @MainPage);
    198151end.
Note: See TracChangeset for help on using the changeset viewer.