Ignore:
Timestamp:
Sep 8, 2010, 4:17:21 PM (14 years ago)
Author:
george
Message:
  • Přidáno: Z PHP kódů převedeno zobrazení stránek a hlavního menu. Pro generování kostry použity třídy HTMLClasses a XMLClasses.
  • Přidáno: Styly a obrázky.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/lazarus/UCore.pas

    r23 r24  
    66
    77uses
    8   USqlDatabase;
     8  USqlDatabase, Classes, SysUtils, StrUtils;
    99 
    1010type
     
    1212  TPageProducer = function: string;
    1313
     14function MakeLink(Text, URL: string): string;
     15function NavigationMakeLink(Module, Page: string): string;
    1416function InsertIcon(FileName: string): string;
     17function IconedLink(Link, Text: string): string;
    1518function HtmlLink(Text, Target: string): string;
    1619function ShowHeader(Title, Path: string): string;
     
    1821function Explode(Separator: Char; Data: string): TArrayOfString;
    1922function HumanDate(Date: string): string;
    20 procedure RegisterPage(Name: string; Producer: TPageProducer);
    2123function PagesList(URL: string; Page, TotalCount, CountPerPage: Integer): string;
    2224function StrRepeat(Data: string; Count: Integer): string;
    23 
    24 type
    25   TRegistredPage = record
    26     Name: string;
    27         Producer: TPageProducer;
    28   end;
    29  
    30 var
    31   Pages: array of TRegistredPage;
    32   Database: TSqlDatabase;
    3325
    3426implementation
    3527
    3628uses 
    37   SysUtils, UConfig;
    38 
    39 procedure RegisterPage(Name: string; Producer: TPageProducer);
    40 begin
    41   SetLength(Pages, Length(Pages) + 1);
    42   Pages[High(Pages)].Name := Name;
    43   Pages[High(Pages)].Producer := Producer;
    44 end;
     29  UConfig;
    4530
    4631function HtmlLink(Text, Target: string): string;
     
    11095end;
    11196
    112 procedure Init;
    113 var
    114   DbRows: TDbRows;
     97function LastPos(const SubStr: String; const S: String): Integer;
    11598begin
    116   Database := TSqlDatabase.Create;
    117   with Database do begin
    118     Hostname := DatabaseHostName;
    119     Database := DatabaseDatabase;
    120     UserName := DatabaseUserName;
    121     Password := DatabasePassword;
    122     Connect;
    123   end;
    124   DbRows := Database.Query('SET NAMES utf8');
    125   DbRows.Free;
     99  Result := Pos(ReverseString(SubStr), ReverseString(S));
     100
     101  if (Result <> 0) then
     102    Result := ((Length(S) - Length(SubStr)) + 1) - Result + 1;
    126103end;
    127104
    128 procedure Done;
     105function IconedLink(Link, Text: string): string;
     106var
     107  Extension: string;
     108  Icon: string;
    129109begin
    130   Database.Free;
     110  Extension := Copy(Link, LastPos(Link, '.') + 1, Length(Link));
     111  Icon := '<img src="images/icons/' + Extension + '.gif" alt="' + Extension + '"> ';
     112  Result := Icon + '<a href="' + Link + '">' + Text + '</a>';
     113end;
     114
     115function MakeLink(Text, URL: string): string;
     116begin
     117  Result := '<a href="' + URL + '">' + Text + '</a>';
     118end;
     119
     120function NavigationMakeLink(Module, Page: string): string;
     121begin
     122  Result := '?m=' + Module + '&amp;p=' + Page;
    131123end;
    132124
     
    179171initialization
    180172
    181 Init;
    182 
    183173finalization
    184174
    185 Done;
    186175end.
Note: See TracChangeset for help on using the changeset viewer.