Rev 915 | Blame | Compare with Previous | Last modification | View Log | RSS feed
<?php/*QBPWCF, Quick Build PHP website Component base on Fedora Linux.Copyright (C) 2015~2024 Min-Jhin,ChenThis file is part of QBPWCF.QBPWCF is free software: you can redistribute it and/or modifyit under the terms of the GNU General Public License as published bythe Free Software Foundation, either version 3 of the License, or(at your option) any later version.QBPWCF is distributed in the hope that it will be useful,but WITHOUT ANY WARRANTY; without even the implied warranty ofMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See theGNU General Public License for more details.You should have received a copy of the GNU General Public Licensealong with QBPWCF. If not, see <http://www.gnu.org/licenses/>.*/namespace qbpwcf;/*類別說明:frame應用的類別.備註:無.*/class frame{/*#函式說明:#當前類別被呼叫的靜態方法不存在時,將會執行該函數,回報該方法不存在.#回傳結果:#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.#$reuslt["error"],執行不正常結束的錯訊息陣列.#$result["function"],當前執行的函式名稱.#必填參數:#$method,物件,為物件實體或類別名稱,會自動置入該參數.#$arguments,陣列,為呼叫方法時所用的參數.#參考資料:#__call=>http://php.net/manual/en/language.oop5.overloading.php#object.callstatic*/public function __call($method,$arguments){#取得當前執行的函式$result["function"]=__FUNCTION__;#設置執行不正常$result["status"]="false";#設置執行錯誤$result["error"][]=__NAMESPACE__ ."/".$method."() 不存在!";#設置所丟入的參數$result["error"][]=$arguments;#回傳結果return $result;}#function __call end/*#函式說明:#當前類別被呼叫的靜態方法不存在時,將會執行該函數,回報該方法不存在.#回傳結果:#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.#$reuslt["error"],執行不正常結束的錯訊息陣列.#$result["function"],當前執行的函式名稱.#必填參數:#$method,物件,為物件實體或類別名稱,會自動置入該參數.#$arguments,陣列,為呼叫方法時所用的參數.#參考資料:#__call=>http://php.net/manual/en/language.oop5.overloading.php#object.callstatic*/public static function __callStatic($method,$arguments){#取得當前執行的函式$result["function"]=__FUNCTION__;#設置執行不正常$result["status"]="false";#設置執行錯誤$result["error"][]="欲呼叫的". __NAMESPACE__ ."/".$method."() 不存在!";#設置所丟入的參數$result["error"][]=$arguments;#回傳結果return $result;}#function __callStatic end/*#函式說明:#建立一個 iframe 框架#回傳的結果:#$result["status"],執行成功或失敗,成功為"true";"false"為失敗。#$result["functin"],字串,當前函數的名稱.#$result["error"],錯誤訊息提示#$result["content"],iframe的語法#必填參數:#$conf["webPage"],字串,爲放入 iframe 網頁網址.$conf["webPage"]="";#$conf["name"],爲該 iframe 的名稱.$conf["name"]="";#$conf["br"],字串,爲放置完該iframe後是否要換行,"true"爲要換行;"flase"爲不要換行。$conf["br"]="true";#可省略參數:#$conf["class"],字串陣列,爲該 iframe 要套用的css樣式類別名稱.#$conf["class"]=array("");#$conf["scrolling"],字串,是否要取消滾軸功能,"false"代表取消滾軸功能.#$conf["scrolling"]="";#$conf["width"],字串,iframe的寬度.#$conf["width"]="";#$conf["height"],字串,iframe的高度.#$conf["height"]="";#$conf["minWidth"],字串,最小的寬度.#$conf["minWidth"]="";#$conf["maxWidth"],字串,最大寬度.#$conf["maxWidth"]="";#$conf["minHeight"],字串,最小的高度.#$conf["minHeight"]="";#$conf["maxHeight"],字串,最大的高度.#$conf["maxHeight"]="";#$conf["soucreId"],字串,如果要跟該function建立出來的ifame來動態調整高度為用戶看到的高度減去其高度,請給予來源iframe的id,此參數僅在$conf["br"]為"true"時生效.#$conf["soucreId"]="";#$conf["sandbox"],字串,"true"代表要用"sandbox"屬性與搭配的參數來讓iframe的內容儘可能呈現,但不影響_top頁面;預設為"false",不使用"sandbox"參數.#$conf["sandbox"]="";#$conf["extraAttrAndValue"],字串陣列,div或span每個額外的屬性與其對應的數值,key為屬性名稱,value為屬性數值.#$conf["extraAttrAndValue"]=array();#$conf["frameExtraAttrAndValue"],字串陣列,frame每個額外的屬性與其對應的數值,key為屬性名稱,value為屬性數值.#$conf["frameExtraAttrAndValue"]=array();#參考資料:#https://developer.mozilla.org/en-US/docs/Web/HTML/Element/iframe#sandbox#備註:#無.*/public static function createIframe(&$conf){#初始化要回傳的結果$result=array();#取得當前執行的函數名稱$result["function"]=__FUNCTION__;#如果沒有參數if(func_num_args()==0){#設置執行失敗$result["status"]="false";#設置執行錯誤訊息$result["error"]="函數".$result["function"]."需要參數";#回傳結果return $result;}#if end#取得參數$result["argu"]=$conf;#如果 $conf 不為陣列if(gettype($conf)!=="array"){#設置執行失敗$result["status"]="false";#設置執行錯誤訊息$result["error"][]="\$conf變數須為陣列形態";#如果傳入的參數為 nullif($conf===null){#設置執行錯誤訊息$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";}#if end#回傳結果return $result;}#if end#檢查參數#函式說明:#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容。#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.#$reuslt["error"],執行不正常結束的錯訊息陣列.#$result["function"],當前執行的函式名稱.#$result["passed"],識別要檢查的全體變數是否存在以及型態是否正確的變數,"true"代表檢查全部通過;"false"代表檢查不通過#$result[$shouldBtCheckedVarName]["varExist"],所檢查的變數是否存在,"false"代表不存在;"true"代表存在#$result[$shouldBtCheckedVarName]["varType"],所檢查的變數型態是否正確,"false"代表錯誤;"true"代表正確#$result[$shouldBtCheckedVarName]["error"],每個參數設定的錯誤訊息#必填寫的參數:#$conf["varInput"],陣列變數,要檢查的陣列變數,請在要檢查的參數前面加上&,這樣變動的結果才能被套用。$conf["variableCheck::checkArguments"]["varInput"]=&$conf;#$conf["mustBeFilledVariableName"],爲必填參數的變數名稱陣列,形態爲陣列變數,例如: $conf["mustBeFilledVariableName"] = array("id","account","password");$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"]=array("webPage","name","br");#$conf["mustBeFilledVariableType"],爲必填參數的變數陣列應該爲何種變數形態,形態爲陣列 例如: $conf["mustBeFilledVariableType"] = array("string",integer,"double");$conf["variableCheck::checkArguments"]["mustBeFilledVariableType"]=array("string","string","string");#$conf["variableCheck::checkArguments"]["referenceVarKey"],字串,$conf參數後面的key值,用於移除不要的參考陣列.$conf["variableCheck::checkArguments"]["referenceVarKey"]="variableCheck::checkArguments";#可以省略的參數:#$conf["canBeEmptyString"],必填變數內容如果是空字串就不能算是有設置的話,請設為"false",預設爲"true"。#$conf["variableCheck::checkArguments"]["canBeEmptyString"]="true";#$conf["skipableVariableName"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");$conf["variableCheck::checkArguments"]["skipableVariableName"]=array("class","scrolling","width","height","minWidth","maxWidth","minHeight","maxHeight","soucreId","sandbox","extraAttrAndValue","frameExtraAttrAndValue");#$conf["skipableVariableType"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double");$conf["variableCheck::checkArguments"]["skipableVariableType"]=array("array","string","string","string","string","string","string","string","string","string","array","array");#$conf["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,null代表不指定,若預設值是必填參數之一,請將$conf["mustBeFilledVar"]改成"\$conf["\mustBeFilledVar\"]".$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"]=array(null,"true",null,null,null,null,null,null,null,"false",null,null);#$conf["arrayCountEqualCheck"],字串陣列,為檢查哪些陣列參數的元素數量要一樣,$conf["arrayCountEqualCheck"][$i]=array()為第$i組key為哪些的變數其元素數量要相等.#$conf["arrayCountEqualCheck"][]=array();$checkResult=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);unset($conf["variableCheck::checkArguments"]);#如果檢查失敗if($checkResult["status"]=="false"){#設置執行不正常$result["status"]="false";#設置錯誤訊息$result["error"]=$checkResult;#回傳結果return $result;}#if end#如果檢查不通過if($checkResult["passed"]=="false"){#設置執行不正常$result["status"]="false";#設置錯誤訊息$result["error"]=$checkResult;#回傳結果return $result;}#if end#如果$conf["class"]不存在if(!isset($conf["class"])){#不設定要套用的類別樣式$conf["frameCssStyle"]="";}#if end#如果$conf["class"]不爲空,則設定樣式。else{#取得class字串#涵式說明:#建立class屬性字串,亦即套用多個class樣式的設定字串.#回傳結果:#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.#$result["function"],當前執行的函數#$result["error"],錯誤訊息陣列#$result["content"],class屬性字串的內容#必填參數:#$conf["class"],字串陣列,要套用的類別樣式名稱.$conf["css::classStr"]["class"]=$conf["class"];$classStr=css::classStr($conf["css::classStr"]);unset($conf["css::classStr"]);#如果建立class類別字串失敗if($classStr["status"]=="false"){#設置執行不正常$result["status"]="false";#設置錯誤訊息$result["error"]=$classStr;#回傳結果return $result;}#if end#取得類別樣式字串$conf["frameCssStyle"]=$classStr["content"];}#else end#如果 $conf["scrolling"] 有設置if(isset($conf["scrolling"])){#如果 $conf["scrolling"] 等於 "false"if($conf["scrolling"]=="false"){#設定關閉滾軸$conf["scrolling"]=" scrolling=no ";}#if end#反之else{#不做設定$conf["scrolling"]="";}#else end}#if end#反之else{#不做設定$conf["scrolling"]="";}#else end#初始化 style 字串$conf["styleStr"]="";#如果有設定寬度或高度if(isset($conf["width"]) || isset($conf["height"])){#如果有設定寬度if(isset($conf["width"])){#設定寬度$conf["css::styleStr"]["styleName"][]="width";$conf["css::styleStr"]["styleValue"][]=$conf["width"];}#if end#如果有設定高度if(isset($conf["height"])){#設定高度$conf["css::styleStr"]["styleName"][]="height";$conf["css::styleStr"]["styleValue"][]=$conf["height"];}#if end#如果有設定最小寬度if(isset($conf["minWidth"])){#設定寬度$conf["css::styleStr"]["styleName"][]="min-width";$conf["css::styleStr"]["styleValue"][]=$conf["minWidth"];}#if end#如果有設定最大寬度if(isset($conf["maxWidth"])){#設定寬度$conf["css::styleStr"]["styleName"][]="max-width";$conf["css::styleStr"]["styleValue"][]=$conf["maxWidth"];}#if end#如果有設定最小高度if(isset($conf["minHeight"])){#設定寬度$conf["css::styleStr"]["styleName"][]="min-height";$conf["css::styleStr"]["styleValue"][]=$conf["minHeight"];}#if end#如果有設定最大高度if(isset($conf["maxHeight"])){#設定寬度$conf["css::styleStr"]["styleName"][]="max-height";$conf["css::styleStr"]["styleValue"][]=$conf["maxHeight"];}#if end#函式說明:#建立給與html標籤使用的style屬性字串.#回傳的結果:#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.#$result["function"],當前執行的函數#$result["error"],錯誤訊息陣列#$result["content"],css設定內容#必填參數:#$conf["css::styleStr"]["styleName"]=array("");#為屬性名稱,須為陣列值#$conf["css::styleStr"]["styleValue"]=array("");#為屬性值,須為陣列值$styleStr=css::styleStr($conf["css::styleStr"]);unset($conf["css::styleStr"]);#如果建立 style 字串失敗if($styleStr["status"]=="false"){#設置執行不正常$result["status"]="false";#設置錯誤訊息$result["error"]=$styleStr;#回傳結果return $result;}#if end#取得 style 字串$conf["styleStr"]=$styleStr["content"];}#if end#iframe語法,frameborder = 0 可以讓IE9看起來不會有外框#$result["content"]="<iframe src = ".$conf["webPage"]." name = ".$conf["name"].$conf["scrolling"]." id = ".$conf["name"]." frameborder = 0 ".$conf["frameCssStyle"]." ".$conf["styleStr"]." ></iframe>";#初始化儲存div或span其餘的屬性與數值$extraAttrAndValue="";#如果有設置 $conf["extraAttrAndValue"]if(isset($conf["extraAttrAndValue"])){#針對每個屬性與數值foreach($conf["extraAttrAndValue"] as $attr=>$val ){#串接每個屬性與數值$extraAttrAndValue=$extraAttrAndValue." ".$attr."=\"".$val."\"";}#foreach end}#if end#初始化儲存frame其餘的屬性與數值$frameExtraAttrAndValue="";#如果有設置 $conf["frameExtraAttrAndValue"]if(isset($conf["frameExtraAttrAndValue"])){#如果要用 sandbox 參數if($conf["sandbox"]==="true"){#增加 sandbox 參數與屬性$conf["frameExtraAttrAndValue"][]=array("sandbox"=>"allow-popups allow-scripts allow-modals allow-forms allow-downloads");}#if end#針對每個屬性與數值foreach($conf["frameExtraAttrAndValue"] as $attr=>$val ){#串接每個屬性與數值$frameExtraAttrAndValue=$frameExtraAttrAndValue." ".$attr."=\"".$val."\"";}#foreach end}#if end#反之沒有設置 $conf["frameExtraAttrAndValue"]else{#設置 sandbox 參數與屬性$frameExtraAttrAndValue="sandbox=\"allow-popups allow-scripts allow-modals allow-forms allow-downloads\"";}#else end#如果 $conf["br"] 爲 "true"if($conf["br"]==="true"){#用div包起來,寬高的style與class套用在div上面.$result["content"]="<div ".$extraAttrAndValue." ".$conf["frameCssStyle"]." ".$conf["styleStr"].">"."<iframe ".$frameExtraAttrAndValue." style=\"width:100%;height:100%;\" src=\"".$conf["webPage"]."\" name=\"".$conf["name"]."\" ".$conf["scrolling"]." id = \"".$conf["name"]."\" frameborder=0></iframe></div>";#如果存在 $conf["soucreId"]if(isset($conf["soucreId"])){#函式說明:#將要執行的script語法透過該函式執行(會在程式外層用<script></script>包起來).#回傳結果:#$result["status"],執行是否正常,"true"為正常,"false"為不正常.#$result["error"],錯誤訊息陣列#$result["function"],當前執行的函數名稱#$result["content"],要執行的javaScript語法#必填參數:#$conf["script"],字串,要執行的javaScript語法.$conf["javascript::toScript"]["script"]="window.changeFrameEleHeightToFullLessSource.changeSizeFrameId='".$conf["name"]."';window.changeFrameEleHeightToFullLessSource.fixedSizeFrameId='".$conf["soucreId"]."';";#可省略參數:#$conf["onReady"],字串,是否要在網頁完全載入後再執行,"false"為不等載入完就先執行,預設為"true"要等載入完再執行.$conf["javascript::toScript"]["onReady"]="false";#$conf["globalJs"],字串陣列,為要放入<script>標籤的js全域變數.#$conf["globalJs"]=array();#$conf["jsFunciton"],字串陣列,為要放入<script>標籤的js函數.#$conf["jsFunciton"]=array();#參考資料:#http://stackoverflow.com/questions/9899372/pure-javascript-equivalent-to-jquerys-ready-how-to-call-a-function-when-the$toScript=javascript::toScript($conf["javascript::toScript"]);unset($conf["javascript::toScript"]);#如果建立script失敗if($toScript["status"]==="false"){#設置執行不正常$result["status"]="false";#設置錯誤訊息$result["error"]=$toScript;#回傳結果return $result;}#if end#串接語法$result["content"]=$result["content"].$toScript["content"];}#if end}#if end#改用span將iframe包起來else{#用span包起來,寬高的style與class套用在iframe上面.$result["content"]="<span ".$extraAttrAndValue.">"."<iframe ".$frameExtraAttrAndValue." ".$conf["frameCssStyle"]." ".$conf["styleStr"]." src=\"".$conf["webPage"]."\" name=\"".$conf["name"]."\" ".$conf["scrolling"]." id = \"".$conf["name"]."\" frameborder=0></iframe></span>";}#else end#執行到這邊,代表執行成功$result["status"]="true";#回傳結果return $result;}#function createIframe end/*#函式說明:#建立多個 iframe#回傳的結果:#$result["status"],執行成功或失敗,成功為"true";"false"為失敗。#$result["functin"],字串,當前函數的名稱.#$result["error"],錯誤訊息提示#$result["content"],iframe的語法#必填參數:#$conf["webPage"],字串陣列,爲每個要放入 iframe 的網頁網址.$conf["webPage"]=array("");#$conf["name"],字串陣列,爲每個 iframe 的名稱與id.$conf["name"]=array("");#$conf["br"],字串陣列,爲放置完各個iframe後是否要換行,"true"爲要換行;"flase"爲不要換行。$conf["br"]=array("true");#可省略參數:#$conf["class"],字串陣列,爲各個 iframe 要套用的css樣式類別名稱,若不使用請將其元素設為null.#$conf["class"]=array(array(""));#$conf["scrolling"],字串陣列,是否要取消各個iframe的滾軸功能,"false"代表取消滾軸功能,若不使用請將其元素設為null.#$conf["scrolling"]=array("false");#$conf["width"],字串陣列,各個iframe的寬度,若不使用請將其元素設為null.#$conf["width"]=array("");#$conf["height"],字串陣列,各個iframe的高度,若不使用請將其元素設為null.#$conf["height"]=array();#$conf["minWidth"],字串陣列,各個iframe最小的寬度,若不使用請將其元素設為null.#$conf["minWidth"]=array("");#$conf["maxWidth"],字串陣列,各個iframe最大寬度,若不使用請將其元素設為null.#$conf["maxWidth"]=array("");#$conf["minHeight"],字串陣列,各個iframe最小的高度,若不使用請將其元素設為null.#$conf["minHeight"]=array("");#$conf["maxHeight"],字串陣列,各個最大的高度,若不使用請將其元素設為null.#$conf["maxHeight"]=array("");#$conf["soucreId"],字串陣列,各個iframe如果要跟該function建立出來的ifame來動態調整高度為用戶看到的高度減去其高度,請給予來源iframe的id,此參數僅在$conf["br"]為"true"時生效,若不使用請將其元素設為null.#$conf["soucreId"]=array("");#參考資料:#無.#備註:#無.*/public static function createMultiIframe(&$conf){#初始化要回傳的結果$result=array();#取得當前執行的函數名稱$result["function"]=__FUNCTION__;#如果沒有參數if(func_num_args()==0){#設置執行失敗$result["status"]="false";#設置執行錯誤訊息$result["error"]="函數".$result["function"]."需要參數";#回傳結果return $result;}#if end#取得參數$result["argu"]=$conf;#如果 $conf 不為陣列if(gettype($conf)!=="array"){#設置執行失敗$result["status"]="false";#設置執行錯誤訊息$result["error"][]="\$conf變數須為陣列形態";#如果傳入的參數為 nullif($conf===null){#設置執行錯誤訊息$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";}#if end#回傳結果return $result;}#if end#初始化要回傳的語法$result["content"]="";#檢查參數#函式說明:#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容。#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.#$reuslt["error"],執行不正常結束的錯訊息陣列.#$result["function"],當前執行的函式名稱.#$result["passed"],識別要檢查的全體變數是否存在以及型態是否正確的變數,"true"代表檢查全部通過;"false"代表檢查不通過#$result[$shouldBtCheckedVarName]["varExist"],所檢查的變數是否存在,"false"代表不存在;"true"代表存在#$result[$shouldBtCheckedVarName]["varType"],所檢查的變數型態是否正確,"false"代表錯誤;"true"代表正確#$result[$shouldBtCheckedVarName]["error"],每個參數設定的錯誤訊息#必填寫的參數:#$conf["varInput"],陣列變數,要檢查的陣列變數,請在要檢查的參數前面加上&,這樣變動的結果才能被套用。$conf["variableCheck::checkArguments"]["varInput"]=&$conf;#$conf["mustBeFilledVariableName"],爲必填參數的變數名稱陣列,形態爲陣列變數,例如: $conf["mustBeFilledVariableName"] = array("id","account","password");$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"]=array("webPage","name","br");#$conf["mustBeFilledVariableType"],爲必填參數的變數陣列應該爲何種變數形態,形態爲陣列 例如: $conf["mustBeFilledVariableType"] = array("string",integer,"double");$conf["variableCheck::checkArguments"]["mustBeFilledVariableType"]=array("array","array","array");#$conf["variableCheck::checkArguments"]["referenceVarKey"],字串,$conf參數後面的key值,用於移除不要的參考陣列.$conf["variableCheck::checkArguments"]["referenceVarKey"]="variableCheck::checkArguments";#可以省略的參數:#$conf["canBeEmptyString"],必填變數內容如果是空字串就不能算是有設置的話,請設為"false",預設爲"true"。#$conf["variableCheck::checkArguments"]["canBeEmptyString"]="true";#$conf["skipableVariableName"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");$conf["variableCheck::checkArguments"]["skipableVariableName"]=array("class","scrolling","width","height","minWidth","maxWidth","minHeight","maxHeight","soucreId");#$conf["skipableVariableType"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double");$conf["variableCheck::checkArguments"]["skipableVariableType"]=array("array","array","array","array","array","array","array","array","array");#$conf["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,null代表不指定,若預設值是必填參數之一,請將$conf["mustBeFilledVar"]改成"\$conf["\mustBeFilledVar\"]".$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"]=array(null,null,null,null,null,null,null,null,null);#$conf["arrayCountEqualCheck"],字串陣列,為檢查哪些陣列參數的元素數量要一樣,$conf["arrayCountEqualCheck"][$i]=array()為第$i組key為哪些的變數其元素數量要相等.$conf["variableCheck::checkArguments"]["arrayCountEqualCheck"][]=array("webPage","name","br");$conf["variableCheck::checkArguments"]["arrayCountEqualCheck"][]=array("br","class","scrolling","width","height","minWidth","maxWidth","minHeight","maxHeight","soucreId");$checkResult=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);unset($conf["variableCheck::checkArguments"]);#如果檢查失敗if($checkResult["status"]==="false"){#設置執行不正常$result["status"]="false";#設置錯誤訊息$result["error"]=$checkResult;#回傳結果return $result;}#if end#如果檢查不通過if($checkResult["passed"]==="false"){#設置執行不正常$result["status"]="false";#設置錯誤訊息$result["error"]=$checkResult;#回傳結果return $result;}#if end#針對每個 $conf["webPage"]foreach($conf["webPage"] as $index=>$url){#初始化參數$each=array();#取得參數 "webPage"$each["webPage"]=$url;#取得參數 "name"$each["name"]=$conf["name"][$index];#取得參數 "br"$each["br"]=$conf["br"][$index];#如果有設置 $conf["class"][$index] 參數if(isset($conf["class"][$index])){#如果不是 nullif($conf["class"][$index]!==null){#取得 "class" 參數$each["class"]=$conf["class"][$index];}#if end}#if end#如果有設置 $conf["scrolling"] 參數if(isset($conf["scrolling"][$index])){#如果不是 nullif($conf["scrolling"][$index]!==null){#取得 "scrolling" 參數$each["scrolling"]=$conf["scrolling"][$index];}#if end}#if end#如果有設置 $conf["width"] 參數if(isset($conf["width"][$index])){#如果不是 nullif($conf["width"][$index]!==null){#取得 "width" 參數$each["width"]=$conf["width"][$index];}#if end}#if end#如果有設置 $conf["height"] 參數if(isset($conf["height"][$index])){#如果不是 nullif($conf["height"][$index]!==null){#取得 "height" 參數$each["height"]=$conf["height"][$index];}#if end}#if end#如果有設置 $conf["minWidth"] 參數if(isset($conf["minWidth"][$index])){#如果不是 nullif($conf["minWidth"][$index]!==null){#取得 "minWidth" 參數$each["minWidth"]=$conf["minWidth"][$index];}#if end}#if end#如果有設置 $conf["maxWidth"] 參數if(isset($conf["maxWidth"][$index])){#如果不是 nullif($conf["maxWidth"][$index]!==null){#取得 "maxWidth" 參數$each["maxWidth"]=$conf["maxWidth"][$index];}#if end}#if end#如果有設置 $conf["minHeight"] 參數if(isset($conf["minHeight"][$index])){#如果不是 nullif($conf["minHeight"][$index]!==null){#取得 "minHeight" 參數$each["minHeight"]=$conf["minHeight"][$index];}#if end}#if end#如果有設置 $conf["maxHeight"] 參數if(isset($conf["maxHeight"][$index])){#如果不是 nullif($conf["maxHeight"][$index]!==null){#取得 "maxHeight" 參數$each["maxHeight"]=$conf["maxHeight"][$index];}#if end}#if end#如果有設置 $conf["soucreId"] 參數if(isset($conf["soucreId"][$index])){#如果不是 nullif($conf["soucreId"][$index]!==null){#取得 "soucreId" 參數$each["soucreId"]=$conf["soucreId"][$index];}#if end}#if end#函式說明:#建立一個 iframe 框架#回傳的結果:#$result["status"],執行成功或失敗,成功為"true";"false"為失敗。#$result["functin"],字串,當前函數的名稱.#$result["error"],錯誤訊息提示#$result["content"],iframe的語法#必填參數:#$conf["webPage"],字串,爲放入 iframe 網頁網址.$conf["frame::createIframe"]["webPage"]=$each["webPage"];#$conf["name"],爲該 iframe 的名稱.$conf["frame::createIframe"]["name"]=$each["name"];#$conf["br"],字串,爲放置完該iframe後是否要換行,"true"爲要換行;"flase"爲不要換行。$conf["frame::createIframe"]["br"]=$each["br"];#可省略參數:#如果存在 $each["class"]if(isset($each["class"])){#設置參數#$conf["class"],字串陣列,爲該 iframe 要套用的css樣式類別名稱.$conf["frame::createIframe"]["class"]=$each["class"];}#if end#如果存在 $each["scrolling"]if(isset($each["scrolling"])){#設置參數#$conf["scrolling"],字串,是否要取消滾軸功能,"false"代表取消滾軸功能.$conf["frame::createIframe"]["scrolling"]=$each["scrolling"];}#if end#如果存在 $each["width"]if(isset($each["width"])){#設置參數#$conf["width"],字串,iframe的寬度.$conf["frame::createIframe"]["width"]=$each["width"];}#if end#如果存在 $each["height"]if(isset($each["height"])){#設置參數#$conf["height"],字串,iframe的寬度.$conf["frame::createIframe"]["height"]=$each["height"];}#if end#如果存在 $each["minWidth"]if(isset($each["minWidth"])){#$conf["minWidth"],字串,最小的寬度.$conf["frame::createIframe"]["minWidth"]=$each["minWidth"];}#if end#如果存在 $each["maxWidth"]if(isset($each["maxWidth"])){#$conf["maxWidth"],字串,最大寬度.$conf["frame::createIframe"]["maxWidth"]=$each["minWidth"];}#if end#如果存在 $each["maxWidth"]if(isset($each["maxWidth"])){#$conf["minHeight"],字串,最小的高度.$conf["frame::createIframe"]["minHeight"]=$each["minHeight"];}#if end#如果存在 $each["maxHeight"]if(isset($each["maxHeight"])){#$conf["maxHeight"],字串,最大的高度.$conf["frame::createIframe"]["maxHeight"]=$each["maxHeight"];}#if end#如果存在 $each["soucreId"]if(isset($each["soucreId"])){#$conf["soucreId"],字串,如果要跟該function建立出來的ifame來動態調整高度為用戶看到的高度減去其高度,請給予來源iframe的id,此參數僅在$conf["br"]為"true"時生效.$conf["frame::createIframe"]["soucreId"]=$each["soucreId"];}#if end$createIframe=frame::createIframe($conf["frame::createIframe"]);unset($conf["frame::createIframe"]);#如果建立失敗if($createIframe["status"]==="false"){#設置執行不正常$result["status"]="false";#設置錯誤訊息$result["error"]=$checkResult;#回傳結果return $result;}#if end#串接iframe語法$result["content"]=$result["content"].$createIframe["content"];}#foreach end#設置執行正常$result["status"]="true";#回傳結果return $result;}#function createMultiIframe end/*#函式說明:#用div做成的frame.#回傳結果:#$result["status"],執行成功或失敗,成功為"true";"false"為失敗.#$result["functin"],字串,當前函數的名稱.#$result["error"],錯誤訊息提示.#$result["content"],div frame的語法.#必填參數:#$conf["id"],字串,div frame的id.$conf["id"]="";#可省略參數:#$conf["content"],字串陣列,要放入到frame的內容,預設不使用.#$conf["content"]=array();#$conf["oneScreenSize"],字串,是否要為視窗的高度,"true"代表要;"false"代表不要。裡面的div元素也會變成跟視窗一樣高.內部的div要使用line-height:normal樣式來取消效果.#$conf["oneScreenSize"]="";#$conf["height"],字串,frame的高度,若 "oneScreenSize" 設置為 "true",則忽略本參數.#$conf["height"]="";#參考資料:#無.#備註:#無.*/public static function div(&$conf=array()){#初始化要回傳的結果$result=array();#取得當前執行的函數名稱$result["function"]=__FUNCTION__;#如果沒有參數if(func_num_args()==0){#設置執行失敗$result["status"]="false";#設置執行錯誤訊息$result["error"]="函數".$result["function"]."需要參數";#回傳結果return $result;}#if end#取得參數$result["argu"]=$conf;#如果 $conf 不為陣列if(gettype($conf)!=="array"){#設置執行失敗$result["status"]="false";#設置執行錯誤訊息$result["error"][]="\$conf變數須為陣列形態";#如果傳入的參數為 nullif($conf===null){#設置執行錯誤訊息$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";}#if end#回傳結果return $result;}#if end#檢查參數#函式說明:#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容。#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.#$reuslt["error"],執行不正常結束的錯訊息陣列.#$result["function"],當前執行的函式名稱.#$result["passed"],識別要檢查的全體變數是否存在以及型態是否正確的變數,"true"代表檢查全部通過;"false"代表檢查不通過#$result[$shouldBtCheckedVarName]["varExist"],所檢查的變數是否存在,"false"代表不存在;"true"代表存在#$result[$shouldBtCheckedVarName]["varType"],所檢查的變數型態是否正確,"false"代表錯誤;"true"代表正確#$result[$shouldBtCheckedVarName]["error"],每個參數設定的錯誤訊息#必填寫的參數:#$conf["varInput"],陣列變數,要檢查的陣列變數,請在要檢查的參數前面加上&,這樣變動的結果才能被套用。$conf["variableCheck::checkArguments"]["varInput"]=&$conf;#$conf["mustBeFilledVariableName"],爲必填參數的變數名稱陣列,形態爲陣列變數,例如: $conf["mustBeFilledVariableName"] = array("id","account","password");$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"]=array("id");#$conf["mustBeFilledVariableType"],爲必填參數的變數陣列應該爲何種變數形態,形態爲陣列 例如: $conf["mustBeFilledVariableType"] = array("string",integer,"double");$conf["variableCheck::checkArguments"]["mustBeFilledVariableType"]=array("string");#$conf["variableCheck::checkArguments"]["referenceVarKey"],字串,$conf參數後面的key值,用於移除不要的參考陣列.$conf["variableCheck::checkArguments"]["referenceVarKey"]="variableCheck::checkArguments";#可以省略的參數:#$conf["canBeEmptyString"],必填變數內容如果是空字串就不能算是有設置的話,請設為"false",預設爲"true"。#$conf["variableCheck::checkArguments"]["canBeEmptyString"]="true";#$conf["skipableVariableName"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");$conf["variableCheck::checkArguments"]["skipableVariableName"]=array("content","oneScreenSize","height");#$conf["skipableVariableType"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double");$conf["variableCheck::checkArguments"]["skipableVariableType"]=array("array","string","string");#$conf["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,null代表不指定,若預設值是必填參數之一,請將$conf["mustBeFilledVar"]改成"\$conf["\mustBeFilledVar\"]".$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"]=array(array(),"false",null);#$conf["arrayCountEqualCheck"],字串陣列,為檢查哪些陣列參數的元素數量要一樣,$conf["arrayCountEqualCheck"][$i]=array()為第$i組key為哪些的變數其元素數量要相等.#$conf["arrayCountEqualCheck"][]=array();$checkResult=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);unset($conf["variableCheck::checkArguments"]);#如果檢查失敗if($checkResult["status"]=="false"){#設置執行不正常$result["status"]="false";#設置錯誤訊息$result["error"]=$checkResult;#回傳結果return $result;}#if end#如果檢查不通過if($checkResult["passed"]=="false"){#設置執行不正常$result["status"]="false";#設置錯誤訊息$result["error"]=$checkResult;#回傳結果return $result;}#if end#涵式說明:#<div>區塊,裡面可以指定css的class樣式,可以指定提示文字.#$result["status"],字串,執行否正常,"true"代表正常,"false"代表不正常.#$result["functin"],字串,當前函數的名稱.#$result["error"],陣列,錯訊訊息.#$result["content"],字串,含有<div>標籤的內容.#必填參數:#$conf["contentArray"],字串陣列,要放入的內容陣列.$conf["css::divSection"]["contentArray"]=$conf["content"];#可省略參數#$conf["id"],字串,div區塊的id.$conf["css::divSection"]["id"]=$conf["id"];#$conf["styleAttr"],字串陣列,給div區段要套用的style樣式屬性.$conf["css::divSection"]["styleAttr"]=array("overflow-y");#$conf["styleVal"],字串陣列,給div區段要套用的style樣式數值.$conf["css::divSection"]["styleVal"]=array("auto");#如果 "oneScreenSize" 為 "false"if($conf["oneScreenSize"]==="false"){#如果有設置 "height"if(isset($conf["height"])){#設置高度屬性$conf["css::divSection"]["styleAttr"][]="height";#設置高度屬性數值$conf["css::divSection"]["styleVal"][]=$conf["height"];}#if end}#if end#$conf["class"],字串,div區段要套用的css樣式.#$conf["class"]="";#$conf["title"],陣列,滑鼠移到上面時要顯示的內容,每個元素代表一列內容.#$conf["title"]=array();#$conf["oneScreenSize"],字串,div區塊是否要占一個螢幕的大小,預設為"false"不設定,"true"為設定成一個螢幕的大小.$conf["css::divSection"]["oneScreenSize"]=$conf["oneScreenSize"];#$conf["textAlignCenter"],字串,div區塊是否要置中,預設為$conf["oneScreenSize"]的值,"false"為不置中,"true"代表要置中.#$conf["textAlignCenter"]="";$divSection=css::divSection($conf["css::divSection"]);unset($conf["css::divSection"]);#如果建立div frame失敗if($divSection["status"]==="false"){#設置執行失敗$result["status"]="false";#設置執行錯誤訊息$result["error"]=$divSection;#回傳結果return $result;}#if end#設置要回傳的語法$result["content"]=$divSection["content"];#設置執行正常$result["status"]="true";#回傳結果return $result;}#function div end/*#函式說明:#建立多個用div做成的frame.#回傳結果:#$result["status"],執行成功或失敗,成功為"true";"false"為失敗.#$result["functin"],字串,當前函數的名稱.#$result["error"],錯誤訊息提示.#$result["content"],div frame的語法.#必填參數:#$conf["id"],字串陣列,每個div frame的id.$conf["id"]=array("");#可省略參數:#$conf["content"],二維字串陣列,要放入到每個frame的內容,預設不使用,若有個要放有的不要放內容,則不放內容的元素設為null.#$conf["content"]=array(array());#$conf["oneScreenSize"],字串陣列,各個frame是否要為視窗的高度,"true"代表要;"false"代表不要。裡面的div元素也會變成跟視窗一樣高.內部的div要使用line-height:normal樣式來取消效果.#$conf["oneScreenSize"]=array("");#$conf["height"],字串陣列,各個frame的高度,若不設置則請給予null,若 "oneScreenSize" 設置為 "true",則忽略本參數.#$conf["height"]=array("");#$conf["div2heightIsSeeHeightLessDiv1height"],字串,"true"代表第2個 div frame如果要跟第1個 div frame 來動態調整高度為用戶看到的高度減去第1個 div frame高度;預設為"false"代表不使用.若 "content" 的元素數量不等於2則會強制為"false".#$conf["div2heightIsSeeHeightLessDiv1height"]="false";#參考資料:#無.#備註:#無.*/public static function multiDiv(&$conf=array()){#初始化要回傳的結果$result=array();#取得當前執行的函數名稱$result["function"]=__FUNCTION__;#初始化語法$result["content"]="";#如果沒有參數if(func_num_args()==0){#設置執行失敗$result["status"]="false";#設置執行錯誤訊息$result["error"]="函數".$result["function"]."需要參數";#回傳結果return $result;}#if end#取得參數$result["argu"]=$conf;#如果 $conf 不為陣列if(gettype($conf)!=="array"){#設置執行失敗$result["status"]="false";#設置執行錯誤訊息$result["error"][]="\$conf變數須為陣列形態";#如果傳入的參數為 nullif($conf===null){#設置執行錯誤訊息$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";}#if end#回傳結果return $result;}#if end#檢查參數#函式說明:#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容。#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.#$reuslt["error"],執行不正常結束的錯訊息陣列.#$result["function"],當前執行的函式名稱.#$result["passed"],識別要檢查的全體變數是否存在以及型態是否正確的變數,"true"代表檢查全部通過;"false"代表檢查不通過#$result[$shouldBtCheckedVarName]["varExist"],所檢查的變數是否存在,"false"代表不存在;"true"代表存在#$result[$shouldBtCheckedVarName]["varType"],所檢查的變數型態是否正確,"false"代表錯誤;"true"代表正確#$result[$shouldBtCheckedVarName]["error"],每個參數設定的錯誤訊息#必填寫的參數:#$conf["varInput"],陣列變數,要檢查的陣列變數,請在要檢查的參數前面加上&,這樣變動的結果才能被套用。$conf["variableCheck::checkArguments"]["varInput"]=&$conf;#$conf["mustBeFilledVariableName"],爲必填參數的變數名稱陣列,形態爲陣列變數,例如: $conf["mustBeFilledVariableName"] = array("id","account","password");$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"]=array("id");#$conf["mustBeFilledVariableType"],爲必填參數的變數陣列應該爲何種變數形態,形態爲陣列 例如: $conf["mustBeFilledVariableType"] = array("string",integer,"double");$conf["variableCheck::checkArguments"]["mustBeFilledVariableType"]=array("array");#$conf["variableCheck::checkArguments"]["referenceVarKey"],字串,$conf參數後面的key值,用於移除不要的參考陣列.$conf["variableCheck::checkArguments"]["referenceVarKey"]="variableCheck::checkArguments";#可以省略的參數:#$conf["canBeEmptyString"],必填變數內容如果是空字串就不能算是有設置的話,請設為"false",預設爲"true"。#$conf["variableCheck::checkArguments"]["canBeEmptyString"]="true";#$conf["skipableVariableName"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");$conf["variableCheck::checkArguments"]["skipableVariableName"]=array("content","oneScreenSize","height","div2heightIsSeeHeightLessDiv1height");#$conf["skipableVariableType"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double");$conf["variableCheck::checkArguments"]["skipableVariableType"]=array("array","array","array","string");#$conf["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,null代表不指定,若預設值是必填參數之一,請將$conf["mustBeFilledVar"]改成"\$conf["\mustBeFilledVar\"]".$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"]=array(null,null,null,"false");#$conf["arrayCountEqualCheck"],字串陣列,為檢查哪些陣列參數的元素數量要一樣,$conf["arrayCountEqualCheck"][$i]=array()為第$i組key為哪些的變數其元素數量要相等.#$conf["variableCheck::checkArguments"]["arrayCountEqualCheck"][]=array();$checkResult=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);unset($conf["variableCheck::checkArguments"]);#如果檢查失敗if($checkResult["status"]=="false"){#設置執行不正常$result["status"]="false";#設置錯誤訊息$result["error"]=$checkResult;#回傳結果return $result;}#if end#如果檢查不通過if($checkResult["passed"]=="false"){#設置執行不正常$result["status"]="false";#設置錯誤訊息$result["error"]=$checkResult;#回傳結果return $result;}#if end#有幾個 $conf["id"] 就執行幾次for($i=0;$i<count($conf["id"]);$i++){#函式說明:#用div做成的frame.#回傳結果:#$result["status"],執行成功或失敗,成功為"true";"false"為失敗.#$result["functin"],字串,當前函數的名稱.#$result["error"],錯誤訊息提示.#$result["content"],div frame的語法.#必填參數:#$conf["id"],字串,div frame的id.$conf["frame::div"]["id"]=$conf["id"][$i];#可省略參數:#$conf["content"],字串陣列,要放入到frame的內容,預設不使用.#如果存在 "content"if(isset($conf["content"])){#如果存在 ["content"][$i]if(isset($conf["content"][$i])){#如果不為if($conf["content"][$i]!==null){#設置frame的內容$conf["frame::div"]["content"]=$conf["content"][$i];#var_dump($conf["frame::div"]["content"][$i]);}#if end}#if end}#if end#$conf["oneScreenSize"],字串,是否要為視窗的高度,"true"代表要;"false"代表不要。裡面的div元素也會變成跟視窗一樣高.內部的div要使用line-height:normal樣式來取消效果.#如果存在 oneScreenSizeif(isset($conf["oneScreenSize"])){#如果存在 ["oneScreenSize"][$i]if(isset($conf["oneScreenSize"][$i])){#如果不為if($conf["oneScreenSize"][$i]!==null){#設置frame的內容$conf["frame::div"]["oneScreenSize"]=$conf["oneScreenSize"][$i];}#if end}#if end}#if end#$conf["height"],字串,frame的高度,若 "oneScreenSize" 設置為 "true",則忽略本參數.#如果存在 heightif(isset($conf["height"])){#如果存在 ["height"][$i]if(isset($conf["height"][$i])){#如果不為if($conf["height"][$i]!==null){#設置frame的內容$conf["frame::div"]["height"]=$conf["height"][$i];}#if end}#if end}#if end$div=frame::div($conf["frame::div"]);unset($conf["frame::div"]);#如果建立失敗if($div["status"]==="false"){#設置執行不正常$result["status"]="false";#設置錯誤訊息$result["error"]=$div;#回傳結果return $result;}#if end#串接 div frame$result["content"]=$result["content"].$div["content"];}#for end#如果剛好有兩個div frameif(count($conf["id"])===2 && $conf["div2heightIsSeeHeightLessDiv1height"]==="true"){#函式說明:#將要執行的script語法透過該函式執行(會在程式外層用<script></script>包起來).#回傳結果:#$result["status"],執行是否正常,"true"為正常,"false"為不正常.#$result["error"],錯誤訊息陣列#$result["function"],當前執行的函數名稱#$result["content"],要執行的javaScript語法#必填參數:#$conf["script"],字串,要執行的javaScript語法.$conf["javascript::toScript"]["script"]="window.changeDivFrameEleHeightToFullLessSource.changeSizeFrameId='".$conf["id"][0]."';window.changeDivFrameEleHeightToFullLessSource.fixedSizeFrameId='".$conf["id"][1]."';";#可省略參數:#$conf["onReady"],字串,是否要在網頁完全載入後再執行,"false"為不等載入完就先執行,預設為"true"要等載入完再執行.$conf["javascript::toScript"]["onReady"]="false";#$conf["globalJs"],字串陣列,為要放入<script>標籤的js全域變數.#$conf["globalJs"]=array();#$conf["jsFunciton"],字串陣列,為要放入<script>標籤的js函數.#$conf["jsFunciton"]=array();#參考資料:#http://stackoverflow.com/questions/9899372/pure-javascript-equivalent-to-jquerys-ready-how-to-call-a-function-when-the$toScript=javascript::toScript($conf["javascript::toScript"]);unset($conf["javascript::toScript"]);#如果建立script失敗if($toScript["status"]==="false"){#設置執行不正常$result["status"]="false";#設置錯誤訊息$result["error"]=$toScript;#回傳結果return $result;}#if end#串接語法$result["content"]=$result["content"].$toScript["content"];}#if end#設置執行正常$result["status"]="true";#回傳結果return $result;}#function multiDiv end}#class frame end?>