-
-
Save supersonictw/e3915cfc4443b0f656a09d5fe8033c70 to your computer and use it in GitHub Desktop.
Revisions
-
supersonictw renamed this gist
Aug 26, 2020 . 1 changed file with 16 additions and 16 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,8 +1,8 @@ # PHP 註解規範 ## 通用註解寫法 ### 一、文件的註解通用樣例(普通程式文件,類文件,函數文件,變量定義文件) ```php /** @@ -11,34 +11,34 @@ * 功能1: xxx * 功能2: xxx * * @file $Source: /home/doc/php開發註解規範.md $ * @package core * @author Joy <anzhengchao@gmail.com> * @version $Id: php開發註解規範.txt,v 1.1 2014/03/04 20:37:46 Joy Exp $ * @link http://www.joychao.cc */ ``` - `@file` 行在提交了svn之後,會自動被補充為如下樣式: ```php * @file $Source: /home/doc/php開發註解規範.md $ ``` - `@version` 行在提交了svn之後,會自動被補充為如下樣式: ```php * @version $Id: php開發註解規範.txt,v 1.1 2014/03/04 20:37:46 Joy Exp $ ``` - `@package` 是團隊事先定義好的,在phpdocumentor里同一package的文件可以給出跟蹤的鏈接。項目開發前需要對其定義。 - `@link` 行後面接的地址是程式開發文檔的地址,因為我們目前沒有在線的程式開發文檔庫,所以可不加。 注意註解的排版,左端保持對齊。 > 說明:以上自動更新版本及文件名需要設定SVN,具體請自行搜尋 *'SVN自動版本號'* ### 二、類的註解,使用如下幾個tag ```php /** @@ -82,7 +82,7 @@ public class DemoClass { ``` ### 四、普通函數和類中的函數註解 ```php /** @@ -104,9 +104,9 @@ function getAvatarUrl($imageName, $size = 80) 順序按照author、param、return來放,**區塊間空行**。 ### 五、程式段落註解 段落註解和邏輯註解使用如下方式 ```php /** @@ -141,9 +141,9 @@ if($_GET['do'] == 'list') ## PHPdoc規範 文檔註解,無非“//”和“/**/”兩種 ,自己寫程式碼,就那麽點,適當寫幾句就好了;但是一個人總有融入團隊的一天,團隊的交流不是那幾句註解和一張嘴能解決的,還需要通用的註解標準。 PHPDoc是PHP文檔註解的一個標準,可以幫助我們在註解文檔時有規範,查看別人的程式碼時更方便。下面的表格是我翻譯的WIKI上的PHPDoc,個人英文水平有限,可以參照原文。 文檔翻譯自:[http://en.wikipedia.org/wiki/Phpdoc](http://en.wikipedia.org/wiki/Phpdoc) @@ -164,7 +164,7 @@ PHPDoc是PHP文檔注釋的一個標準,可以幫助我們在注釋文檔時 @name|變量別名|為某個變量指定別名 @magic| |phpdoc.de compatibility @package|封裝包的名稱|一組相關類、函數封裝的包名稱 @param|如 $username 用戶名|變量含義註解 @return|如 返回bool|函數返回結果描述,一般不用在void(空返回結果的)的函數中 @see|如 Class Login()|文件關聯的任何元素(全局變量,包括,頁面,類,函數,定義,方法,變量)。 @since|version|記錄什麽時候對文檔的哪些部分進行了更改 @@ -176,7 +176,7 @@ PHPDoc是PHP文檔注釋的一個標準,可以幫助我們在注釋文檔時 @var|type|文檔中的變量及其類型 @version| |文檔、類、函數的版本信息 PHPDoc註解實例: ```php <?php -
supersonictw renamed this gist
Aug 26, 2020 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
supersonictw revised this gist
Aug 25, 2020 . 1 changed file with 50 additions and 53 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -2,75 +2,76 @@ ## 通用注釋寫法 ### 一、文件的注釋通用樣例(普通程式文件,類文件,函數文件,變量定義文件) ```php /** * XXXXX的文件 * * 功能1: xxx * 功能2: xxx * * @file $Source: /home/doc/php開發注釋規範.md $ * @package core * @author Joy <anzhengchao@gmail.com> * @version $Id: php開發注釋規範.txt,v 1.1 2014/03/04 20:37:46 Joy Exp $ * @link http://www.joychao.cc */ ``` - `@file` 行在提交了svn之後,會自動被補充為如下樣式: ```php * @file $Source: /home/doc/php開發注釋規範.md $ ``` - `@version` 行在提交了svn之後,會自動被補充為如下樣式: ```php * @version $Id: php開發注釋規範.txt,v 1.1 2014/03/04 20:37:46 Joy Exp $ ``` - `@package` 是團隊事先定義好的,在phpdocumentor里同一package的文件可以給出跟蹤的鏈接。項目開發前需要對其定義。 - `@link` 行後面接的地址是程式開發文檔的地址,因為我們目前沒有在線的程式開發文檔庫,所以可不加。 注意注釋的排版,左端保持對齊。 > 說明:以上自動更新版本及文件名需要設定SVN,具體請自行搜尋 *'SVN自動版本號'* ### 二、類的注釋,使用如下幾個tag ```php /** * xxxxx類 * * 功能1:完成xxxx * 功能2:完成xxxxx * * @author Joy <anzhengchao@gmail.com> * @access public * @abstract */ public class DemoClass { //code... } ``` - `@access` (`public`|`private`) 標記類是私有的還是公用的。 - `@abstract`標記該類是個抽象類 雖然我們使用的是php5,但目前程式類的編寫仍然沿用的php4,因此`@access`和`@abstract`兩項可加可不加。 ### 三、類的屬性定義 ```php public class DemoClass { /** * 當前頁碼 * * @var integer */ public $currentPageNumber; /** * 私有變量使用下劃線開頭 * @@ -83,14 +84,14 @@ public class DemoClass { ### 四、普通函數和類中的函數注釋 ```php /** * 獲得頭貼地址 * * @author Joy <anzhengchao@gmail.com> * * @param string $imageName 圖片檔案名 * @param integer $size 檔案大小 * * @return string */ @@ -103,10 +104,11 @@ function getAvatarUrl($imageName, $size = 80) 順序按照author、param、return來放,**區塊間空行**。 ### 五、程式段落注釋 段落注釋和邏輯注釋使用如下方式 ```php /** * 1 如果$_GET['do']等於buy,則購買條碼 */ @@ -115,10 +117,9 @@ if($_GET['do'] == 'buy') // 1.1 驗證用戶提交變量是否合法 if($_POST['strCodeNum']) { } // 1.2 驗證用戶提交的碼是否可以購買 // 1.3 .................. } // end if @@ -130,23 +131,22 @@ if($_GET['do'] == 'list') // 2.1 驗證用戶提交變量是否合法 if($_POST['strCodeNum']) { } // 2.2 驗證用戶提交的碼是否可以購買 // 2.3 .................. } // end if ``` ## PHPdoc規範 文檔注釋,無非“//”和“/**/”兩種 ,自己寫程式碼,就那麽點,適當寫幾句就好了;但是一個人總有融入團隊的一天,團隊的交流不是那幾句注釋和一張嘴能解決的,還需要通用的注釋標準。 PHPDoc是PHP文檔注釋的一個標準,可以幫助我們在注釋文檔時有規範,查看別人的程式碼時更方便。下面的表格是我翻譯的WIKI上的PHPDoc,個人英文水平有限,可以參照原文。 文檔翻譯自:[http://en.wikipedia.org/wiki/Phpdoc](http://en.wikipedia.org/wiki/Phpdoc) 標記|用途|描述 -|-|- @abstract| |抽象類的變量和方法 @@ -159,7 +159,7 @@ PHPDoc是PHP文檔注釋的一個標準,可以幫助我們在注釋文檔時 @exception| |文檔中方法拋出的異常,也可參照 @throws. @global|類型:$globalvarname|文檔中的全局變量及有關的方法和函數 @ignore| |忽略文檔中指定的關鍵字 @internal| |開發團隊內部信息 @link|URL|類似於license 但還可以通過link找到文檔中的更多個詳細的信息 @name|變量別名|為某個變量指定別名 @magic| |phpdoc.de compatibility @@ -176,12 +176,10 @@ PHPDoc是PHP文檔注釋的一個標準,可以幫助我們在注釋文檔時 @var|type|文檔中的變量及其類型 @version| |文檔、類、函數的版本信息 PHPDoc注釋實例: ```php <?php /** * start page for webaccess * @@ -214,28 +212,28 @@ PHPDoc注釋實例: * @var String */ private $_language; /** * configured template * * @var String */ private $_template; /** * all available templates * * @var Array */ private $_templates = array(); /** * all available languages * * @var Array */ private $_languages = array(); /** * check for all extensions that are needed, initialize needed vars and read config.php */ @@ -245,7 +243,7 @@ PHPDoc注釋實例: $this->_getTemplateList(); $this->_getLanguageList(); } /** * checking config.php setting for template, if not supportet set phpsysinfo.css as default * checking config.php setting for language, if not supported set en as default @@ -258,13 +256,13 @@ PHPDoc注釋實例: if (!file_exists(APP_ROOT.'/templates/'.$this->_template.".css")) { $this->_template = 'phpsysinfo'; } $this->_language = trim(PSI_DEFAULT_LANG); if (!file_exists(APP_ROOT.'/language/'.$this->_language.".xml")) { $this->_language = 'en'; } } /** * get all available tamplates and store them in internal array * @@ -282,7 +280,7 @@ PHPDoc注釋實例: } } } /** * get all available translations and store them in internal array * @@ -300,7 +298,7 @@ PHPDoc注釋實例: } } } /** * render the page * @@ -309,16 +307,15 @@ PHPDoc注釋實例: public function run() { $this->_checkTemplateLanguage(); $tpl = new Template("/templates/html/index_dynamic.html"); $tpl->set("template", $this->_template); $tpl->set("templates", $this->_templates); $tpl->set("language", $this->_language); $tpl->set("languages", $this->_languages); echo $tpl->fetch(); } } ``` -
supersonictw revised this gist
Aug 25, 2020 . No changes.There are no files selected for viewing
-
supersonictw revised this gist
Aug 25, 2020 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -148,7 +148,7 @@ PHPDoc是PHP文檔注釋的一個標準,可以幫助我們在注釋文檔時 標記|用途|描述 -|-|- @abstract| |抽象類的變量和方法 @access|public, private or protected|文檔的訪問、使用權限. @access private 表明這個文檔是被保護的。 @author|張三 <zhangsan@163.com>|文檔作者 -
supersonictw renamed this gist
Aug 25, 2020 . 1 changed file with 61 additions and 61 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,8 +1,8 @@ # PHP注釋規範 ## 通用注釋寫法 ### 一、文件的注釋通用樣例(普通程序文件,類文件,函數文件,變量定義文件) ``` /** @@ -11,38 +11,38 @@ * 功能1: xxx * 功能2: xxx * * @file $Source: /home/doc/php開发注釋規範.md $ * @package core * @author Joy <anzhengchao@gmail.com> * @version $Id: php開发注釋規範.txt,v 1.1 2014/03/04 20:37:46 Joy Exp $ * @link http://www.joychao.cc */ ``` - `@file` 行在提交了svn之後,會自動被補充為如下樣式: ``` * @file $Source: /home/doc/php開发注釋規範.md $ ``` - `@version` 行在提交了svn之後,會自動被補充為如下樣式: ``` * @version $Id: php開发注釋規範.txt,v 1.1 2014/03/04 20:37:46 Joy Exp $ ``` - `@package` 是團隊事先定義好的,在phpdocumentor里同一package的文件可以給出跟蹤的鏈接。項目開发前需要對其定義。 - `@link` 行後面接的地址是程序開发文檔的地址,因為我們目前沒有在線的程序開发文檔庫,所以可不加。 注意注釋的排版,左端保持對齊。 ##### 說明:以上自動更新版本及文件名需要配置svn,具體請自行google *'SVN自動版本號'* ### 二、類的注釋,使用如下幾個tag ``` /** * xxxxx類 * * 功能1:完成xxxx * 功能2:完成xxxxx @@ -55,24 +55,24 @@ public class DemoClass { //code... } ``` - `@access` (`public`|`private`) 標記類是私有的還是公用的。 - `@abstract`標記該類是個抽象類 雖然我們使用的是php5,但目前程序類的編寫仍然沿用的php4,因此`@access`和`@abstract`兩項可加可不加。 ### 三、類的屬性定義 ``` public class DemoClass { /** * 當前頁碼 * * @var integer */ public $currentPageNumber; /** * 私有變量使用下劃線開頭 * * @var string */ @@ -81,15 +81,15 @@ public class DemoClass { ``` ### 四、普通函數和類中的函數注釋 ``` /** * 獲取頭像地址 * * @author Joy <anzhengchao@gmail.com> * * @param string $imageName 圖片文件名 * @param integer $size 大小 * * @return string @@ -101,84 +101,84 @@ function getAvatarUrl($imageName, $size = 80) ``` 順序按照author、param、return來放,**區塊間空行**。 ### 五、程序段落注釋 段落注釋和邏輯注釋使用如下方式 ``` /** * 1 如果$_GET['do']等於buy,則購買條碼 */ if($_GET['do'] == 'buy') { // 1.1 驗證用戶提交變量是否合法 if($_POST['strCodeNum']) { } // 1.2 驗證用戶提交的碼是否可以購買 // 1.3 .................. } // end if /** * 2 如果$_GET['do']等於list,顯示用戶選擇的條碼 */ if($_GET['do'] == 'list') { // 2.1 驗證用戶提交變量是否合法 if($_POST['strCodeNum']) { } // 2.2 驗證用戶提交的碼是否可以購買 // 2.3 .................. } // end if ``` ## PHPdoc規範 文檔注釋,無非“//”和“/**/”兩種 ,自己寫代碼,就那麽點,適當寫幾句就好了;但是一個人總有融入團隊的一天,團隊的交流不是那幾句注釋和一張嘴能解決的,還需要通用的注釋標準。 PHPDoc是PHP文檔注釋的一個標準,可以幫助我們在注釋文檔時有規範,查看別人的代碼時更方便。下面的表格是我翻譯的WIKI上的PHPDoc,個人英文水平有限,可以參照原文。 文檔翻譯自:[http://en.wikipedia.org/wiki/Phpdoc](http://en.wikipedia.org/wiki/Phpdoc) 標記|用途|描述 -|- @abstract| |抽象類的變量和方法 @access|public, private or protected|文檔的訪問、使用權限. @access private 表明這個文檔是被保護的。 @author|張三 <zhangsan@163.com>|文檔作者 @copyright|名稱 時間|文檔版權信息 @deprecated|version|文檔中被廢除的方法 @deprec| |同 @deprecated @example|/path/to/example|文檔的外部保存的示例文件的位置。 @exception| |文檔中方法拋出的異常,也可參照 @throws. @global|類型:$globalvarname|文檔中的全局變量及有關的方法和函數 @ignore| |忽略文檔中指定的關鍵字 @internal| |開发團隊內部信息 @link|URL|類似於license 但還可以通過link找到文檔中的更多個詳細的信息 @name|變量別名|為某個變量指定別名 @magic| |phpdoc.de compatibility @package|封裝包的名稱|一組相關類、函數封裝的包名稱 @param|如 $username 用戶名|變量含義注釋 @return|如 返回bool|函數返回結果描述,一般不用在void(空返回結果的)的函數中 @see|如 Class Login()|文件關聯的任何元素(全局變量,包括,頁面,類,函數,定義,方法,變量)。 @since|version|記錄什麽時候對文檔的哪些部分進行了更改 @static| |記錄靜態類、方法 @staticvar| |在類、函數中使用的靜態變量 @subpackage| |子版本 @throws| |某一方法拋出的異常 @todo| |表示文件未完成或者要完善的地方 @var|type|文檔中的變量及其類型 @version| |文檔、類、函數的版本信息 PHPDoc注釋實例: ``` <?php -
supersonictw revised this gist
Aug 25, 2020 . 1 changed file with 9 additions and 9 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,8 +1,8 @@ # PHP注释规范 ## 通用注释写法 ### 一、文件的注释通用样例(普通程序文件,类文件,函数文件,变量定义文件) ``` /** @@ -36,9 +36,9 @@ - `@link` 行后面接的地址是程序开发文档的地址,因为我们目前没有在线的程序开发文档库,所以可不加。 注意注释的排版,左端保持对齐。 ##### 说明:以上自动更新版本及文件名需要配置svn,具体请自行google *'SVN自动版本号'* ### 二、类的注释,使用如下几个tag ``` /** @@ -59,7 +59,7 @@ public class DemoClass { - `@abstract`标记该类是个抽象类 虽然我们使用的是php5,但目前程序类的编写仍然沿用的php4,因此`@access`和`@abstract`两项可加可不加。 ### 三、类的属性定义 ``` public class DemoClass { @@ -81,7 +81,7 @@ public class DemoClass { ``` ### 四、普通函数和类中的函数注释 ``` /** @@ -103,7 +103,7 @@ function getAvatarUrl($imageName, $size = 80) 顺序按照author、param、return来放,**区块间空行**。 ### 五、程序段落注释 段落注释和逻辑注释使用如下方式 ``` @@ -138,7 +138,7 @@ if($_GET['do'] == 'list') } // end if ``` ## PHPdoc规范 文档注释,无非“//”和“/**/”两种 ,自己写代码,就那么点,适当写几句就好了;但是一个人总有融入团队的一天,团队的交流不是那几句注释和一张嘴能解决的,还需要通用的注释标准。 -
supersonictw renamed this gist
Aug 25, 2020 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
yboker revised this gist
Apr 20, 2016 . No changes.There are no files selected for viewing
-
yboker created this gist
Apr 20, 2016 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,324 @@ #PHP注释规范 ##通用注释写法 ###一、文件的注释通用样例(普通程序文件,类文件,函数文件,变量定义文件) ``` /** * XXXXX的文件 * * 功能1: xxx * 功能2: xxx * * @file $Source: /home/doc/php开发注释规范.md $ * @package core * @author Joy <anzhengchao@gmail.com> * @version $Id: php开发注释规范.txt,v 1.1 2014/03/04 20:37:46 Joy Exp $ * @link http://www.joychao.cc */ ``` - `@file` 行在提交了svn之后,会自动被补充为如下样式: ``` * @file $Source: /home/doc/php开发注释规范.md $ ``` - `@version` 行在提交了svn之后,会自动被补充为如下样式: ``` * @version $Id: php开发注释规范.txt,v 1.1 2014/03/04 20:37:46 Joy Exp $ ``` - `@package` 是团队事先定义好的,在phpdocumentor里同一package的文件可以给出跟踪的链接。项目开发前需要对其定义。 - `@link` 行后面接的地址是程序开发文档的地址,因为我们目前没有在线的程序开发文档库,所以可不加。 注意注释的排版,左端保持对齐。 #####说明:以上自动更新版本及文件名需要配置svn,具体请自行google *'SVN自动版本号'* ###二、类的注释,使用如下几个tag ``` /** * xxxxx类 * * 功能1:完成xxxx * 功能2:完成xxxxx * * @author Joy <anzhengchao@gmail.com> * @access public * @abstract */ public class DemoClass { //code... } ``` - `@access` (`public`|`private`) 标记类是私有的还是公用的。 - `@abstract`标记该类是个抽象类 虽然我们使用的是php5,但目前程序类的编写仍然沿用的php4,因此`@access`和`@abstract`两项可加可不加。 ###三、类的属性定义 ``` public class DemoClass { /** * 当前页码 * * @var integer */ public $currentPageNumber; /** * 私有变量使用下划线开头 * * @var string */ private $_instance; } ``` ###四、普通函数和类中的函数注释 ``` /** * 获取头像地址 * * @author Joy <anzhengchao@gmail.com> * * @param string $imageName 图片文件名 * @param integer $size 大小 * * @return string */ function getAvatarUrl($imageName, $size = 80) { return sprintf(SITE_URL . '/service/images/cropped_%s/'.$imageName, $size); } ``` 顺序按照author、param、return来放,**区块间空行**。 ###五、程序段落注释 段落注释和逻辑注释使用如下方式 ``` /** * 1 如果$_GET['do']等于buy,则购买条码 */ if($_GET['do'] == 'buy') { // 1.1 验证用户提交变量是否合法 if($_POST['strCodeNum']) { } // 1.2 验证用户提交的码是否可以购买 // 1.3 .................. } // end if /** * 2 如果$_GET['do']等于list,显示用户选择的条码 */ if($_GET['do'] == 'list') { // 2.1 验证用户提交变量是否合法 if($_POST['strCodeNum']) { } // 2.2 验证用户提交的码是否可以购买 // 2.3 .................. } // end if ``` ##PHPdoc规范 文档注释,无非“//”和“/**/”两种 ,自己写代码,就那么点,适当写几句就好了;但是一个人总有融入团队的一天,团队的交流不是那几句注释和一张嘴能解决的,还需要通用的注释标准。 PHPDoc是PHP文档注释的一个标准,可以帮助我们在注释文档时有规范,查看别人的代码时更方便。下面的表格是我翻译的WIKI上的PHPDoc,个人英文水平有限,可以参照原文。 文档翻译自:[http://en.wikipedia.org/wiki/Phpdoc](http://en.wikipedia.org/wiki/Phpdoc) 标记|用途|描述 -|- @abstract| |抽象类的变量和方法 @access|public, private or protected|文档的访问、使用权限. @access private 表明这个文档是被保护的。 @author|张三 <zhangsan@163.com>|文档作者 @copyright|名称 时间|文档版权信息 @deprecated|version|文档中被废除的方法 @deprec| |同 @deprecated @example|/path/to/example|文档的外部保存的示例文件的位置。 @exception| |文档中方法抛出的异常,也可参照 @throws. @global|类型:$globalvarname|文档中的全局变量及有关的方法和函数 @ignore| |忽略文档中指定的关键字 @internal| |开发团队内部信息 @link|URL|类似于license 但还可以通过link找到文档中的更多个详细的信息 @name|变量别名|为某个变量指定别名 @magic| |phpdoc.de compatibility @package|封装包的名称|一组相关类、函数封装的包名称 @param|如 $username 用户名|变量含义注释 @return|如 返回bool|函数返回结果描述,一般不用在void(空返回结果的)的函数中 @see|如 Class Login()|文件关联的任何元素(全局变量,包括,页面,类,函数,定义,方法,变量)。 @since|version|记录什么时候对文档的哪些部分进行了更改 @static| |记录静态类、方法 @staticvar| |在类、函数中使用的静态变量 @subpackage| |子版本 @throws| |某一方法抛出的异常 @todo| |表示文件未完成或者要完善的地方 @var|type|文档中的变量及其类型 @version| |文档、类、函数的版本信息 PHPDoc注释实例: ``` <?php /** * start page for webaccess * * PHP version 5 * * @category PHP * @package PSI_Web * @author Michael Cramer <BigMichi1@users.sourceforge.net> * @copyright 2009 phpSysInfo * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License * @version SVN: $Id: class.Webpage.inc.php 412 2010-12-29 09:45:53Z Jacky672 $ * @link http://phpsysinfo.sourceforge.net */ /** * generate the dynamic webpage * * @category PHP * @package PSI_Web * @author Michael Cramer <BigMichi1@users.sourceforge.net> * @copyright 2009 phpSysInfo * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License * @version Release: 3.0 * @link http://phpsysinfo.sourceforge.net */ class Webpage extends Output implements PSI_Interface_Output { /** * configured language * * @var String */ private $_language; /** * configured template * * @var String */ private $_template; /** * all available templates * * @var Array */ private $_templates = array(); /** * all available languages * * @var Array */ private $_languages = array(); /** * check for all extensions that are needed, initialize needed vars and read config.php */ public function __construct() { parent::__construct(); $this->_getTemplateList(); $this->_getLanguageList(); } /** * checking config.php setting for template, if not supportet set phpsysinfo.css as default * checking config.php setting for language, if not supported set en as default * * @return void */ private function _checkTemplateLanguage() { $this->_template = trim(PSI_DEFAULT_TEMPLATE); if (!file_exists(APP_ROOT.'/templates/'.$this->_template.".css")) { $this->_template = 'phpsysinfo'; } $this->_language = trim(PSI_DEFAULT_LANG); if (!file_exists(APP_ROOT.'/language/'.$this->_language.".xml")) { $this->_language = 'en'; } } /** * get all available tamplates and store them in internal array * * @return void */ private function _getTemplateList() { $dirlist = CommonFunctions::gdc(APP_ROOT.'/templates/'); sort($dirlist); foreach ($dirlist as $file) { $tpl_ext = substr($file, strlen($file) - 4); $tpl_name = substr($file, 0, strlen($file) - 4); if ($tpl_ext === ".css") { array_push($this->_templates, $tpl_name); } } } /** * get all available translations and store them in internal array * * @return void */ private function _getLanguageList() { $dirlist = CommonFunctions::gdc(APP_ROOT.'/language/'); sort($dirlist); foreach ($dirlist as $file) { $lang_ext = substr($file, strlen($file) - 4); $lang_name = substr($file, 0, strlen($file) - 4); if ($lang_ext == ".xml") { array_push($this->_languages, $lang_name); } } } /** * render the page * * @return void */ public function run() { $this->_checkTemplateLanguage(); $tpl = new Template("/templates/html/index_dynamic.html"); $tpl->set("template", $this->_template); $tpl->set("templates", $this->_templates); $tpl->set("language", $this->_language); $tpl->set("languages", $this->_languages); echo $tpl->fetch(); } } ```