⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 weboutput.pas

📁 DBDesigner 4 is a database design system that integrates database design, modelling, creation and ma
💻 PAS
📖 第 1 页 / 共 5 页
字号:
        tmp := SearchTemplate[u];



        if (u=gridFilenameIndex) then

          tmp := DMMain.ReplaceText(tmp,GRID_FILENAME_TOKEN,'"'+gridFilename+'"');

        if (u=frameFilenameIndex) then

          tmp := DMMain.ReplaceText(tmp,FRAME_FILENAME_TOKEN,'"'+frameFilename+'"');

        if (u=columnCaptionsIndex) then

          tmp := DMMain.ReplaceText(tmp,COLUMN_CAPTIONS_TOKEN,MakeColumnCaptions(TmpView));

        if (u=columnsOrderIndex) then

          tmp := DMMain.ReplaceText(tmp,COLUMNS_ORDER_TOKEN,MakeGridColumnOrder(TmpView));

        if (u=viewnameIndex) then

          tmp := DMMain.ReplaceText(tmp,VIEWNAME_TOKEN,'"'+TmpView.Name+'"');

        

        Writeln(pFile, tmp);

      end;



      Close(pFile);

    end;

  end;



  SearchTemplate.Free;

end;



function Groupcompare_line(Item1, Item2: Pointer): Integer;

var group1, group2 : TGroup;

begin

  group1 := TGroup(Item1);

  group2 := TGroup(Item2);



  if (group1.showOnLine < group2.showOnLine) then Groupcompare_line:= -1

  else if (group1.showOnLine > group2.showOnLine) then Groupcompare_line:=  +1

  else if (group1.showInColumn < group2.showInColumn) then Groupcompare_line:=  -1

  else if (group1.showInColumn > group2.showInColumn) then Groupcompare_line:=  +1

  else Groupcompare_line:=  0;

end;



function TPHPOutput.MakeMainIndex() :String;

var viewList: String; //a string in the form of a php array : array (viewname1 => linkaddress,...)

    filename, tmp: String;

    currentCol,currentLine,j,maxLine,grpCount: Integer;

    TmpGroup:TGroup;

    TmpView: TView;

    oneGroupAdded: Boolean;

    order: String;

begin

  MakeMainIndex := '';



  tmp:= '';

  GroupList.Sort(GroupCompare_line);

  maxLine := TGroup(GroupList[GroupList.Count-1]).showOnLine;



  grpCount := 0;

  currentLine := 1;

  while (currentLine <= maxLine) do

  begin

    tmp := tmp + '<table border="0"><tr>';

    oneGroupAdded := false;

    currentCol := 1;





    while ((grpCount < GroupList.Count) and (TGroup(GroupList.Items[grpCount]).showOnLine = currentLine)) do       //draw this group

    begin

      TmpGroup := TGroup(GroupList.Items[grpCount]);

      //are we in the right column?

      if (TmpGroup.showInColumn <> currentCol) then

      begin

        tmp := tmp+'<td style="width:100px"></td>';

        currentCol:= currentCol + 1;

        continue;

      end;



      //show the group

      oneGroupAdded := True;

      tmp := tmp + '<td>';



      viewList:= 'array( ';

      //for all views of the group do

      for j:=0 to TmpGroup.Views.Count-1 do

      begin

        TmpView:=TView(TmpGroup.Views[j]);

        order := '';

        if (TmpView.OrderBy <> '') then order:= '&OrderBy=' + TmpView.OrderBy;



        filename:=TmpGroup.Name+'_'+TmpView.Name+'_frame.php';



        if (TmpGroup.FViewsAsPopup) then

          viewList:= viewList + '"'+TmpView.Name+'"' +'=>' + '"javascript: void window.open(' + #39 +

          filename+'?page=0&mode=normal'+order+ ''',' +

            ' '''+DMMain.ReplaceText(TmpView.Name, ' ', '')+''','+

            '''width='+IntToStr(TmpView.FGridPopupWidth)+', '+

            'height='+IntToStr(TmpView.FGridPopupHeight)+', '+

            'left='+IntToStr(TmpView.FGridPopupX)+', '+

            'top='+IntToStr(TmpView.FGridPopupY)+', '+

            'scrollbars=yes, status=no, toolbar=no, resizable=yes, dependent=yes'')",'



        else

          viewList:= viewList + '"'+TmpView.Name+'"' +'=>'+'"'+filename+'?page=0&mode=normal'+order+'",';

      end;

      //delete the last char

      Delete(viewList,Length(viewList),1);



      tmp:= tmp + '<?php displayGroup("'+TmpGroup.Name+'",'+viewList+') ); ?>';

      tmp := tmp + '</td>';



      grpCount := grpCount +1;

      currentCol := currentCol +1;

    end;



    if (NOT oneGroupAdded) then            //just make an empty table, we have to account for the row

    begin

      tmp := tmp + '<td style="height:120px"></td>';

    end;



    tmp := tmp + '</tr></table>';

    currentLine := currentLine+1;

  end;







  MakeMainIndex:= tmp;

end;



procedure TPhpOutput.CreateIndexFile(IndexTemplateFilename: string);

var IndexTemplate: TStringList;

    i: Integer;

    tmp :String;

    F: TextFile;

begin

  IndexTemplate:= TStringList.Create;

  try  

  //read in the index-template file

  if (NOT (FileExists(IndexTemplateFilename)) ) then

  begin

    raise ETemplateFileException.Create(IndexTemplateFilename+','+TemplateFileError);

  end;

  IndexTemplate.LoadFromFile(IndexTemplateFilename);



  AssignFile(F,saveDir+'index.php');

  Rewrite(F);



  Writeln(F, GeneratedFileHeader);



  for i:=0 to IndexTemplate.Count-1 do

  begin

    tmp := IndexTemplate[i];



    if (AnsiStartsStr('//|', tmp)) then continue; //ignore lines beginning with '//|'

    if AnsiContainsText(tmp,INDEX_TOKEN) then

      tmp:= DMMain.ReplaceText(tmp, INDEX_TOKEN, MakeMainIndex);

    if AnsiContainsText(tmp,HEADING_TOKEN) then

      tmp:= DMMain.ReplaceText(tmp, HEADING_TOKEN, '"'+heading+'"');

    if AnsiContainsText(tmp,IMAGES_TOKEN) then

      tmp:= DMMain.ReplaceText(tmp, IMAGES_TOKEN, MakeImageNames());



    Writeln(F,tmp);

  end;

  finally

    Close(F);

    IndexTemplate.Free;

  end;

end;







procedure TPhpOutput.CreateUpdateFiles(UpdateTemplateFilename :string);

var templateFile, updateFile: TextFile;

    str,tmp, filename: String;

    TemplateLines: TStringList;

    i,j,u : Integer;

    tablenameIndex,datatypesIndex, tablekeyIndex, tabledispcolsIndex :Integer;

    jointablenameIndex, jointablekeyIndex, jointabledispcolsIndex :Integer;

    nmtablenameIndex, nmtableKeyIndex, nmtabledispcolsIndex,connectiontablenameIndex : Integer;

    nmtabledatatypesIndex, keyMappingIndex,nmtabledatatypeparamsIndex: Integer;

    colWidthIndex, colCaptIndex, datatypeparamsIndex, MainNotnullIndex : Integer;

    gridFilenameIndex,columnsOrderIndex : Integer;

    TmpGroup: TGroup;

    TmpView: TView;

begin

  tablenameIndex:= 0; datatypesIndex := 0;tablekeyIndex:=0; tabledispcolsIndex:= 0;

  jointablenameIndex:=0; jointablekeyIndex:=0; jointabledispcolsIndex:= 0;

  nmtablenameIndex:= 0; nmtableKeyIndex:=0; nmtabledispcolsIndex:=0;connectiontablenameIndex:=0;

  nmtabledatatypesIndex := 0;keyMappingIndex := 0; datatypeparamsIndex :=0;

  colWidthIndex := 0; colCaptIndex := 0; nmtabledatatypeparamsIndex := 0;

  MainNotNullIndex := 0;  gridFilenameIndex :=0;   columnsOrderIndex:=0;



  TemplateLines:= TStringList.Create;



  try

  //read in the template

  if (NOT (FileExists(UpdateTemplateFilename)) ) then

  begin

    raise ETemplateFileException.Create(UpdateTemplateFilename+','+TemplateFileError);

  end;

  AssignFile(templateFile,UpdateTemplateFilename);

  Reset(templateFile);

  while not eof(templateFile) do

  begin

    ReadLn(templateFile, str);

    if (AnsiContainsText(str,INCLUDE_TOKEN) )then

      str:= DMMain.ReplaceText(str, INCLUDE_TOKEN, 'include "db_open.php"');



    if (AnsiStartsStr('//|', str)) then continue; //ignore lines beginning with '//|'

    i := templateLines.Add(str);



    if (AnsiContainsText(str,COLUMNS_ORDER_TOKEN) ) then columnsOrderIndex:= i;

    if (AnsiContainsText(str,GRID_FILENAME_TOKEN) ) then gridFilenameIndex := i;

    if (AnsiContainsText(str,TABLENAME_TOKEN) ) then tablenameIndex := i;

    if (AnsiContainsText(str,DATATYPES_TOKEN) ) then datatypesIndex := i;

    if (AnsiContainsText(str,DATATYPE_PARAMS_TOKEN) ) then datatypeparamsIndex := i;

    if (AnsiContainsText(str,TABLEKEY_TOKEN) ) then tablekeyIndex := i;

    if (AnsiContainsText(str,TABLEDISPCOLS_TOKEN) ) then tabledispcolsIndex := i;

    if (AnsiContainsText(str,MAIN_NOT_NULL_TOKEN) ) then MainNotNullIndex := i;



    if (AnsiContainsText(str,JOINTABLEDISPCOLS_TOKEN) ) then jointabledispcolsIndex := i;

    if (AnsiContainsText(str,JOINTABLENAME_TOKEN) ) then jointablenameIndex := i;

    if (AnsiContainsText(str,JOINTABLEKEY_TOKEN) ) then jointablekeyIndex := i;



    if (AnsiContainsText(str,NMTABLEDISPCOLS_TOKEN) ) then nmtabledispcolsIndex := i;

    if (AnsiContainsText(str,NMTABLENAME_TOKEN) ) then nmtablenameIndex := i;

    if (AnsiContainsText(str,NMTABLEDATATYPES_TOKEN) ) then nmtabledatatypesIndex := i;

    if (AnsiContainsText(str,NMTABLEDATATYPE_PARAMS_TOKEN) ) then nmtabledatatypeparamsIndex := i;

    if (AnsiContainsText(str,NMTABLEKEY_TOKEN) ) then nmtablekeyIndex := i;

    if (AnsiContainsText(str,CONNECTIONTABLENAME_TOKEN) ) then connectiontablenameIndex := i;



    if (AnsiContainsText(str,KEY_MAPPING_TOKEN) ) then keyMappingIndex := i;

    if (AnsiContainsText(str,COLUMN_WIDTHS_TOKEN) ) then colWidthIndex := i;

    if (AnsiContainsText(str,COLUMN_CAPTIONS_TOKEN) ) then colCaptIndex := i;

  end;

  finally

    Close(templateFile);

  end;



  //for all groups

  for i:=0 to GroupList.Count-1 do

  begin

    TmpGroup:=TGroup(GroupList[i]);



    //for all views of the group do

    for j:=0 to TmpGroup.Views.Count-1 do

    begin

      TmpView:=TView(TmpGroup.Views[j]);

      filename:=TmpGroup.Name+'_'+TmpView.Name+'_update.php';



      try

        //create the update-file for each view

        AssignFile(updateFile,saveDir+filename);

        Rewrite(updateFile);



        Writeln(updateFile, GeneratedFileHeader);



        for u:=0 to TemplateLines.Count-1 do

        begin

          tmp := TemplateLines[u];



          if (u= columnsOrderIndex) then

            tmp := DMMain.ReplaceText(tmp, COLUMNS_ORDER_TOKEN, MakeColumnOrder(TmpView));

          if (u= gridFilenameIndex) then

            tmp := DMMain.ReplaceText(tmp, GRID_FILENAME_TOKEN, '"'+TmpGroup.Name+'_'+TmpView.Name+'.php"');

          if (u=tablenameIndex) then

            tmp := DMMain.ReplaceText(tmp,TABLENAME_TOKEN,'"'+TmpView.Table.Name+'"');

          if (u=datatypesIndex) then

            tmp := DMMain.ReplaceText(tmp,DATATYPES_TOKEN, MakeDataTypes(TmpView.Table));

          if (u=datatypeparamsIndex) then

            tmp := DMMain.ReplaceText(tmp,DATATYPE_PARAMS_TOKEN, MakeDataTypeParams(TmpView.Table));

          if (u=tablekeyIndex) then

            tmp := DMMain.ReplaceText(tmp,TABLEKEY_TOKEN,MakeKey(TmpView.Table));

          if (u=tabledispcolsIndex) then

            tmp := DMMain.ReplaceText(tmp,TABLEDISPCOLS_TOKEN, MakeDispCols(TmpView.Table, 1));

          if (u=mainNotNullIndex) then

            tmp := DMMain.ReplaceText(tmp,MAIN_NOT_NULL_TOKEN, MakeNotNull(TmpView.Table));



          if (u=keyMappingIndex) then

            tmp:= DMMain.ReplaceText(tmp, KEY_MAPPING_TOKEN, MakeKeyMapping(TmpView));

          if (u=colCaptIndex) then

            tmp:= DMMain.ReplaceText(tmp, COLUMN_CAPTIONS_TOKEN, MakeFormColumnCaptions(TmpView));

          if (u=colWidthIndex) then

            tmp:= DMMain.ReplaceText(tmp, COLUMN_WIDTHS_TOKEN, MakeFormColumnWidths(TmpView));



          if (Tmpview.JoinTables.Count <> 0) then

          begin

            if (u=jointablenameIndex) then

              tmp := DMMain.ReplaceText(tmp,JOINTABLENAME_TOKEN, MakeTableNames(TmpView.JoinTables) );

            if (u=jointablekeyIndex) then

              tmp := DMMain.ReplaceText(tmp,JOINTABLEKEY_TOKEN,MakeKey(TmpView.JoinTables));

            if (u=jointabledispcolsIndex) then

              tmp := DMMain.ReplaceText(tmp,JOINTABLEDISPCOLS_TOKEN, MakeDispCols(TmpView.JoinTables, 1) );

          end

          else

          begin

            if (u=jointablenameIndex) then

              tmp := DMMain.ReplaceText(tmp,JOINTABLENAME_TOKEN, 'array ()');

            if (u=jointablekeyIndex) then

              tmp := DMMain.ReplaceText(tmp,JOINTABLEKEY_TOKEN,'array ()');

            if (u=jointabledispcolsIndex) then

              tmp := DMMain.ReplaceText(tmp,JOINTABLEDISPCOLS_TOKEN, 'array ()');

          end;



          if (TmpView.NMTables.Count <> 0) then

          begin

            if (u=nmtablenameIndex) then

              tmp := DMMain.ReplaceText(tmp,NMTABLENAME_TOKEN, MakeTableNames(TmpView.NMTables) );

            if (u=nmtablekeyIndex) then

              tmp := DMMain.ReplaceText(tmp,NMTABLEKEY_TOKEN,MakeKey(TmpView.NMTables));

            if (u=nmtabledatatypesIndex) then

              tmp := DMMain.ReplaceText(tmp,NMTABLEDATATYPES_TOKEN, MakeDataTypes(TmpView.NMTables) );

            if (u=nmtabledatatypeparamsIndex) then

              tmp := DMMain.ReplaceText(tmp,NMTABLEDATATYPE_PARAMS_TOKEN, MakeDataTypeParams(TmpView.NMTables) );

            if (u=nmtabledispcolsIndex) then

              tmp := DMMain.ReplaceText(tmp,NMTABLEDISPCOLS_TOKEN, MakeDispCols(TmpView.NMTables, 1) );

            if (u=connectiontablenameIndex) then

              tmp := DMMain.ReplaceText(tmp,CONNECTIONTABLENAME_TOKEN, MakeConnectionTables(TmpView.Table,TmpView.NMTables) );

          end

          else

          begin

            if (u=nmtablenameIndex) then

              tmp := DMMain.ReplaceText(tmp,NMTABLENAME_TOKEN, 'array ()');

            if (u=nmtablekeyIndex) then

              tmp := DMMain.ReplaceText(tmp,NMTABLEKEY_TOKEN,'array ()');

            if (u=nmtabledatatypesIndex) then

              tmp := DMMain.ReplaceText(tmp,NMTABLEDATATYPES_TOKEN, 'array ()');

            if (u=nmtabledatatypeparamsIndex) then

              tmp := DMMain.ReplaceText(tmp,NMTABLEDATATYPE_PARAMS_TOKEN, 'array ()');

            if (u=nmtabledispcolsIndex) then

              tmp := DMMain.ReplaceText(tmp,NMTABLEDISPCOLS_TOKEN, 'array ()');

            if (u=connectiontablenameIndex) then

              tmp := DMMain.ReplaceText(tmp,CONNECTIONTABLENAME_TOKEN, 'array ()');

          end;



          Writeln(updateFile,tmp);

        end;

      finally

        Close(updateFile);

      end;

    end;

  end;

  

  TemplateLines.Free;

end;







procedure TPhpOutput.CreateInsertFiles(InsertTemplateFilename :string);

var templateFile, insertFile: TextFile;

    str,tmp, filename: String;

    TemplateLines: TStringList;

    i,j,u : Integer;

    tablenameIndex,datatypesIndex, tablekeyIndex, tabledispcolsIndex :Integer;

    jointablenameIndex, jointablekeyIndex, jointabledispcolsIndex :Integer;

    nmtablenameIndex, nmtableKeyIndex, nmtabledispcolsIndex,connectiontablenameIndex : Integer;

    nmtabledatatypesIndex, keyMappingIndex,nmtabledatatypeparamsIndex : Integer;

    colWidthIndex, colCaptIndex,datatypeparamsIndex,columnsOrderIndex : Integer;

    mainDefaultValueIndex, mainNotNullIndex,gridFilenameIndex : Integer;

    TmpGroup: TGroup;

    TmpView: TView;

begin

  tablenameIndex:= 0; datatypesIndex := 0;tablekeyIndex:=0; tabledispcolsIndex:= 0;

  jointablenameIndex:=0; jointablekeyIndex:=0; jointabledispcolsIndex:= 0;

  nmtablenameIndex:= 0; nmtableKeyIndex:=0; nmtabledispcolsIndex:=0;connectiontablenameIndex:=0;

  nmtabledatatypesIndex := 0;keyMappingIndex := 0;  datatypeparamsIndex := 0;

  colWidthIndex := 0; colCaptIndex := 0;   nmtabledatatypeparamsIndex := 0;

  mainDefaultValueIndex := 0; mainNotNullIndex := 0;  gridFilenameIndex :=0;

  columnsOrderIndex:=0;



  TemplateLines:= TStringList.Create;



  //read in the template

  if (NOT (FileExists(InsertTemplateFilename)) ) then

  begin

    raise ETemplateFileException.Create(InsertTemplateFilename+','+TemplateFileError);

  end;

  AssignFile(templateFile,InsertTemplateFilename);

  Reset(templateFile);

  while not eof(templateFile) do

  begin

    ReadLn(templateFile, str);

    if (AnsiContainsText(str,INCLUDE_TOKEN) )then

      str:= DMMain.ReplaceText(str, INCLUDE_TOKEN, 'include "db_open.php"');



    if (AnsiStartsStr('//|', str)) then continue; //ignore lines beginning with '//|'

    i := templateLines.Add(str);



    if (AnsiContainsText(str,COLUMNS_ORDER_TOKEN) ) then columnsOrderIndex:= i;

    if (AnsiContainsText(str,GRID_FILENAME_TOKEN) ) then gridFilenameIndex:= i;

    if (AnsiContainsText(str,TABLENAME_TOKEN) ) then tablenameIndex := i;

    if (AnsiContainsText(str,DATATYPES_TOKEN) ) then datatypesIndex := i;

    if (AnsiContainsText(str,DATATYPE_PARAMS_TOKEN) ) then datatypeparamsIndex := i;

    if (AnsiContainsText(str,TABLEKEY_TOKEN) ) then tablekeyIndex := i;

    if (AnsiContainsText(str,TABLEDISPCOLS_TOKEN) ) then tabledispcolsIndex := i;

    if (AnsiContainsText(str,MAIN_DEFAULT_VALUE_TOKEN) ) then mainDefaultValueIndex := i

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -