建立模板標簽系統應用程序 建立模板標簽系統應用程序只需幾個步驟. 注意:以下步驟假設使用了新的SleeK例子應用程序(這個例子可以在www.phpmvc.net上找到). 修改應用程序的boot.ini文件 應用程序的boot.ini文件包含需要得到PHP.MVC框架的信息.boot.ini文件通常位于應用程序的"WEB-INF"目錄下.為了設置應用程序使用模板標簽類,我們需要在boot.ini文件中定義一些屬性. TagActionDispatcher類 TagActionDispatcher是ActionDispatcher類的標準實現.為了讓框架能讀取TagActionDispatcher類,我們為變量$appServerRootDir設置值為'TagActionDispatcher': // Setup the application specific ActionDispatcher (RequestDispatcher) $actionDispatcher = 'TagActionDispatcher'; 模板標簽系統庫根目錄 我們也需要設置路徑指向我們的PHP.MVC庫(需要文件系統的絕對路徑): // Set php.MVC library root directory (no trailing slash). $appServerRootDir = 'C:\WWW\phpmvc-base'; 可選設置 應用程序定時器可以使用$timerRun屬性來設置開或關: // Timer reporting. 1=on, 0=off $timerRun = 1; 還可以指導框架總是(強制)編譯應用程序phpmvc-config.xml配置類(最好用在開發階段,因為會比較慢),我們使用: // The application XML configuration data set: $appXmlCfgs = array(); $appXmlCfgs['config'] = array('name'=>'phpmvc-config.xml', 'fc'=>True); 或者僅在phpmvc-config.xml文件被修改的時候重新編譯應用程序配置文件(在開發完成后使用此項設置,速度快),我們使用: // The application XML configuration data set: $appXmlCfgs = array(); $appXmlCfgs['config'] = array('name'=>'phpmvc-config.xml', 'fc'=>False); 設置應用程序模板目錄 當為模板標簽應用程序設置模板目錄時,我們需要去創建一個目錄(和子目錄),放置我們的應用程序模板文件.這個目錄必須被命名為在View資源配置類的$tplDir屬性所定義的值,默認是'./WEB-INF/tpl'.比如:例子應用程序有一個模板目錄結構設置像這樣: - PhpMVC-Tags Index.html Main.php WEB-INF tpl pageFooter.ssp pageHeader.ssp salePageBody.ssp sale pageContent.ssp 我們也需要去創建目錄放置編譯的頁面.這個目錄必須被命名為在View資源配置類的$tplDirC屬性所定義的值.默認是'./WEB-INF/tpl_C'.例子應用程序有一個模板目錄結構設置像這樣: PhpMVC-Tags Index.html Main.php WEB-INF tpl ... sale ... tpl_C pageFooter.sspC pageHeader.sspC salePageBody.sspC sale pageContent.sspC 注意我們也需要在'./WEB-INF/tpl_C'下創建sale目錄. 設置PHP.MVC庫的路徑和包含 檢查以下路徑設置已經被定義在GlobalPaths.php和globalPrepend.php文件在你的框架安裝目錄下的"/WEB-INF"目錄下: GlobalPaths.php ------------------------------------------------ $appDirs[] = 'WEB-INF/lib/phpmvc_tags'; globalPrepend.php ------------------------------------------------ include_once 'PhpMVC_Tags.php'; 如果他們沒有在添加到路徑里,那么就定義這些變量. 安裝PHP.MVC庫 下載最新版的PHP.MVC庫:http://www.phpmvc.net/download/cvsIdx.php?doc=cvs-snaps 解壓庫文檔到一個目錄.修改上面所描述過的路徑設置和包含設置. 運行例子應用程序 下載例子應用程序.完整的例子代碼文件和這個向導都能在這里下載:http://www.phpmvc.net/download/rel/phpmvc-tags-v1.0.zip 解壓到web服務器目錄中.可能像這樣:C:/WWW/PhpMVC-Tags 修改應用程序和框架設置. 為了測試例子程序,需要瀏覽器例子程序的首頁:http://localhost/PhpMVC-Tags/Index.html 附錄A:ViewResources配置類
ViewResourcesConfig類表現了<view-resource>元素的配置信息. 下表列出了ViewResourcesConfig類的屬性,條目描述和默認值:
Name | Description | Default Value | $appTitle | The application title | 'My Web Application' | $appVersion | The application version | '1.0' | $copyright | The copyright notice | 'Copyright C YYYY My Name. All rights reserved.' | $contactInfo | The contact information | 'webmaster@myhost.com' | $processTags | Do we run the template engine processor (boolean) | False | $compileAll | Force compile pages (boolean) | False | $tagL | The left tag identifier | '<@' | $tagR | The right tag identifier | '@>' | $tplDir | The view resource templates directory | './WEB-INF/tpl' | $tplDirC | The compiled templates directory | './WEB-INF/tpl_C' | $extC | The compiled file notation. Eg: "pageContent.ssp[C]" | 'C' | $maxFileLength | The maximum size of the template files allowed, in bytes (integer) | 250000 | $tagFlagStr | Indicates tag template file(s) to be pre-processed. Eg: "myPage.ssp" | '.ssp' | $tagFlagCnt | The number of trailing filename characters to sample (".ssp" = -4) | -4 |
|