1 頁 (共 1 頁)

mod_harbour fix 2021.08.21, support PRG/PHP

發表於 : 2021-08-19, 12:51
admin
從 2019 年到現在 2021,mod_harbour 做了相當大的異動,針對新版重新修改程式碼,讓他可以跟一般網頁那樣崁入 php 程式碼方式執行.
From 2019 to 2021, mod_harbour has made a considerable change, re-modifying the code for the new version, so that it can be executed by embedding php code like normal web pages.

範例程式碼,提供給 apache/mod_harbour 執行:
Sample code, provided to apache/mod_harbour to run:

test0.prg

代碼: 選擇全部

<?prg
// #xcommand HTML => #pragma __cstream | AP_RPuts(%s)
// #xcommand ? <cText> => AP_RPuts(<cText>)
// #define CRLF chr(13)+chr(10)
// #define WCRLF "<br>"
local z := 'A'
local j := 100
local cPrg := AP_FileName()
local cFilename := FileName(cPrg)
local cFilePath := FilePath(cPrg)
local cFileext  := FileExt(cPrg)
public cDbf := cFilePath + 'customer.dbf'

?>
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>harbour for apache test!!</title>
<meta name="generator" content="Designed by WenSheng!!">
<link href="ssbbs.css" rel="stylesheet">
<link href="test3.css" rel="stylesheet">
<script src="jquery-1.12.4.min.js"></script>
</head>
<body>
<?prg
USE (cDBF) NEW ALIAS CUT SHARE
?>
<script>
$(document).ready(function(){
  var tbl=document.getElementById('Table1');
  if(! tbl){
    alert("no Table");
    return;
  }
  // alert('Have Table');
<?prg
c:='['
for i:= 1 to 10
    c += if(i<>1, ',', '' )
    c += '["'+CUT->FIRST+'","'+CUT->LAST+'","'+CUT->STREET+'","'+CUT->CITY+'","'+CUT->STATE+'"]'
    SKIP
next i
c+='];'
?? 'var aData='+c+';'+CRLF
?>
  var n=0;
  for(var i=0; i<10; i++){
    n=tbl.rows.length;
    tr=tbl.insertRow(n-1);
    var c='';
    for(var j=0; j<5; j++){
      if(j==4){
        c+='<td class="cell1">'+aData[i][j]+'</td>'; // insert row data
      }else{
        c+='<td class="cell0">'+aData[i][j]+'</td>'; // insert row data
      }
    }
    tr.innerHTML=c;
  }
});
</script>
<table style="position:absolute;left:0px;top:0px;width:774px;height:75px;z-index:0;" id="Table1">
<tr>
<td class="<?prg ?? "cell0" ?>"><span style="<?prg ?? "color:#000000;font-family:Arial;font-size:13px;line-height:15px;" ?>"> </span><span style="color:#000000;font-family:Calibri;font-size:13px;line-height:15px;">ID</span></td>
<td class="cell0"><span style="color:#000000;font-family:微軟正黑體;font-size:13px;line-height:17px;">F</span><span style="color:#000000;font-family:Calibri;font-size:13px;line-height:17px;">IRST</span></td>
<td class="cell0"><span style="color:#000000;font-family:Arial;font-size:13px;line-height:15px;"> </span><span style="color:#000000;font-family:Calibri;font-size:13px;line-height:15px;">LAST</span></td>
<td class="cell0"><span style="color:#000000;font-family:Arial;font-size:13px;line-height:15px;"> </span><span style="color:#000000;font-family:Calibri;font-size:13px;line-height:15px;">STREET</span></td>
<td class="cell1"><span style="color:#000000;font-family:Arial;font-size:13px;line-height:15px;"> </span><span style="color:#000000;font-family:Calibri;font-size:13px;line-height:15px;">CITY</span></td>
</tr>
<tr>
<td colspan="5" class="cell2"><span style="color:#000000;font-family:arial;font-size:13px;line-height:16px;">&nbsp;&nbsp;&nbsp;&nbsp; </span></td>
</tr>
</table>
<?prg
//? "TEST OK!!"
//? j
//? aaa()
CLOSE ALL
?>
</body>
</html><?prg
func aaa()
return 'aaa'
?>
<?prg
Function FileSplit(cFile)
Local   cPath     := '',;
        cFileName := '',;
        cExtName  := ''
        HB_FNameSplit(cFile, @cPath, @cFileName, @cExtName)
RETURN  {cPath, cFileName, cExtName}

// 取得檔名
Func    FileName(cFile)
Return  FileSplit(cFile)[2]

// 取得目錄(inc '\')
Func    FilePath(cFile)
Return  FileSplit(cFile)[1]

// 取得附加檔名
Func    FileExt(cFile)
Return  FileSplit(cFile)[3]
?>
下載範例檔:
download:
https://app.box.com/s/v58m099kbd8g80422ky2kahndxjc0rb9

apache 專用檔:(mod_harbour.so、libharbour.dll)
apache special files: (mod_harbour.so, libharbour.dll)
https://app.box.com/s/4s7fypzg9srb2mz61gblqq07qfb4yuf6

請參考 mod_harbour 的說明書,將 mod_harbour.so、libharbour.dll 放入適當目錄下,並修改 httpd.conf 檔案執行!
Please refer to the manual of mod_harbour, put mod_harbour.so, libharbour.dll into the appropriate directory, and modify the httpd.conf file to execute!

執行結果:
The results:
圖檔

檢視網頁原始碼:
View the source code of the webpage:

代碼: 選擇全部

<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>harbour for apache test!!</title>
<meta name="generator" content="Designed by WenSheng!!">
<link href="ssbbs.css" rel="stylesheet">
<link href="test3.css" rel="stylesheet">
<script src="jquery-1.12.4.min.js"></script>
</head>
<body>
 
<script>
$(document).ready(function(){
  var tbl=document.getElementById('Table1');
  if(! tbl){
    alert("no Table");
    return;
  }
  // alert('Have Table');
 var aData=[["Homer               ","Simpson             ","32179 Maiden Lane             ","Springfield                   ","IL"],["Ceci                ","Gibbard             ","9540 Raynes Park Road         ","Miami                         ","MA"],["Reg                 ","Kaczocha            ","30522 Park Ten Place          ","Scottsdale                    ","WY"],["David               ","Jochum              ","8211 Carnegie Center          ","Hingham                       ","IL"],["Simpson             ","Cafee               ","32736 Meadowbrook Drive       ","Nedlands                      ","ID"],["Tom                 ","Logan               ","6180 Roselle Street           ","West Covina                   ","CT"],["Gary                ","Brock               ","3893 Canandaigua Road         ","Senford                       ","WV"],["Frank               ","Fonseca             ","18712 Sherman Way             ","Ashby                         ","RI"],["Rick                ","Sencovici           ","13802 South University        ","Arcadia                       ","HI"],["Hugh                ","Lupton              ","16472 S. LaSalle Street       ","Tarzana                       ","AK"]];;
 
  var n=0;
  for(var i=0; i<10; i++){
    n=tbl.rows.length;
    tr=tbl.insertRow(n-1);
    var c='';
    for(var j=0; j<5; j++){
      if(j==4){
        c+='<td class="cell1">'+aData[i][j]+'</td>'; // insert row data
      }else{
        c+='<td class="cell0">'+aData[i][j]+'</td>'; // insert row data
      }
    }
    tr.innerHTML=c;
  }
});
</script>
<table style="position:absolute;left:0px;top:0px;width:774px;height:75px;z-index:0;" id="Table1">
<tr>
<td class="
 cell0 "><span style="
 color:#000000;font-family:Arial;font-size:13px;line-height:15px; "> </span><span style="color:#000000;font-family:Calibri;font-size:13px;line-height:15px;">ID</span></td>
<td class="cell0"><span style="color:#000000;font-family:微軟正黑體;font-size:13px;line-height:17px;">F</span><span style="color:#000000;font-family:Calibri;font-size:13px;line-height:17px;">IRST</span></td>
<td class="cell0"><span style="color:#000000;font-family:Arial;font-size:13px;line-height:15px;"> </span><span style="color:#000000;font-family:Calibri;font-size:13px;line-height:15px;">LAST</span></td>
<td class="cell0"><span style="color:#000000;font-family:Arial;font-size:13px;line-height:15px;"> </span><span style="color:#000000;font-family:Calibri;font-size:13px;line-height:15px;">STREET</span></td>
<td class="cell1"><span style="color:#000000;font-family:Arial;font-size:13px;line-height:15px;"> </span><span style="color:#000000;font-family:Calibri;font-size:13px;line-height:15px;">CITY</span></td>
</tr>
<tr>
<td colspan="5" class="cell2"><span style="color:#000000;font-family:arial;font-size:13px;line-height:16px;">&nbsp;&nbsp;&nbsp;&nbsp; </span></td>
</tr>
</table>
 
</body>
</html>
 
瞧! 沒有任何 harbour 語法!
Look! There is no harbour syntax!

然後,可以使用: WYSIWYG Web Builder 設計畫面、崁入程式碼,就像 php 方式一樣!!
Then, you can use: WYSIWYG Web Builder to design the screen and embed the code, just like the php way!!
圖檔

Re: mod_harbour fix 2021.08.21

發表於 : 2021-08-21, 12:51
admin
*2021.08.21: fix
1. 修正: 如果整個網頁都沒有 '<?prg' 與 '?>' 造成失敗錯誤訊息.
1. Fix: If there is no'<?prg' and '?>' in the entire webpage, it will cause a failure error message.

2. 新增: HTML 中可以同時執行 <?php ... ?> 與 <?prg ... ?>.
說明: 執行順序: 先執行 PHP 程式碼,再執行 PRG 程式碼.
這項功能在副檔名為 .hrb 時無法正確執行,因為 .hrb 是預先編譯,無法重新呼叫 PHP 重新編譯!
須設定可以呼叫得到 php 於路徑下( SET PATH=...).
或是設定環境變數: 'PHP_PATH'

2. New addition: <?php ... ?> and <?prg ... ?> can be executed simultaneously in HTML.
Description: The execution order: first execute PHP code before execution PRG code.
This function cannot be executed correctly when the extension is .hrb, because .hrb is pre-compiled and cannot be called again to recompile PHP!
It must be set to call to get php under the path (SET PATH=...).
Or to set environment variables: 'PHP_PATH'

執行結果 & 部分程式碼:
Execution result & part of the code:
圖檔

下載(download):
https://app.box.com/s/drqig3vt4c9m8ghp0ol037624gsghbmh

Re: mod_harbour fix 2021.08.21, support PRG/PHP

發表於 : 2021-09-07, 10:11
admin
好消息!!
WYSIWYG Web Builder 16.4.3 經在下建議,開始支援 harbour 語法 <?prg ... ?>
也就是說,我們可以開始使用 WYSIWYG Web Builder 搭配 harbour 設計網頁了!!

good news!!
WYSIWYG Web Builder 16.4.3 has been suggested below and started to support harbour syntax <?prg ... ?>
In other words, we can start using WYSIWYG Web Builder with harbour to design web pages!!

https://www.wysiwygwebbuilder.com/forum ... =1&t=92886

代碼: 選擇全部

What's new?
- Improved: Added support for file links to Button and Themeable Button.
- Improved: Optimized the generated HTML of the Responsive Menu for Google's Lighthouse.
- Improved: Added (experimental) support for Harbour programming language in HTML formatting engine (beautify/minify)
- Improved: Simplified HTML attribute encoding for Unicode text to improve SEO.
- Improved: Re-adding hidden columns in Layout grid will restore previous alignment/order.
- Fixed: Incorrect column alignment in layout grids and custom overflow with flexbox.
- Fixed: Issue with captcha width in layout grids (full width = false).
- Improved: Added (experimental) support for Harbour programming language in HTML formatting engine (beautify/minify)