Subversion Repositories php-qbpwcf

Rev

Rev 226 | Blame | Compare with Previous | Last modification | View Log | RSS feed

<?php

/*

        QBPWCF, Quick Build PHP website Component base on Fedora Linux.
    Copyright (C) 2014~2026 MIN ZHI, CHEN

    This file is part of QBPWCF.

    QBPWCF is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the 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 of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with QBPWCF.  If not, see <http://www.gnu.org/licenses/>.

*/
namespace qbpwcf;

/*
類別說明:
tab應用相關的類別.
備註:
無.
*/
class tab{

        /*
        #函式說明:
        #當前類別被呼叫的靜態方法不存在時,將會執行該函數,回報該方法不存在.
        #回傳結果:
        #$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

        /*
        #涵式說明:
        #建立給行動版頁面使用的分頁功能
        #回傳結果:
        #$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
        #$result["error"],錯誤訊息陣列.
        #$result["function"],當前執行的函數名稱
        #$result["content"],建立bootstrap樣式分頁的語法
        #必填參數:
        #$conf["liName"],字串陣列,每個分頁標籤的名稱.
        $conf["liName"]=array();
        #$conf["liContent"],字串陣列,每個分頁底下的內容為什麼.
        $conf["liContent"]=array();
        #可省略參數:
        #$conf["liIdHeadStr"],字串,每個分頁的id開頭字串,預設為"mobileTab",若在一分html文件裡面使用多個mobile()則會導致衝突,請務必個別指派不同的數值.
        #$conf["liIdHeadStr"]="";
        */
        function mobile(&$conf){

                #初始化要回傳的結果
                $result=array();

                #初始化語法
                $result["content"]="";

                #取得當前執行的函數名稱
                $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變數須為陣列形態";

                        #如果傳入的參數為 null
                        if($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[$shouldBeCheckedVarName]["varExist"],所檢查的變數是否存在,"false"代表不存在;"true"代表存在
                #$result[$shouldBeCheckedVarName]["varType"],所檢查的變數型態是否正確,"false"代表錯誤;"true"代表正確
                #$result[$shouldBeCheckedVarName]["error"],每個參數設定的錯誤訊息
                #$result["shouldNotBeEmpty"],不應該為空字串或控陣列的變數.
                #$result["argu"],字串陣列,目前輸入的參數名稱陣列.
                #$result["legalVarName"],字串陣列,合法可用的參數名稱陣列.
                #$result["notNeedVar"],字串陣列,多餘的參數名稱.
                #必填寫的參數:
                #$conf["varInput"],陣列變數,要檢查的陣列變數,請在要檢查的參數前面加上&,這樣變動的結果才能被套用。
                $conf["variableCheck::checkArguments"]["varInput"]=&$conf;
                #$conf["mustBeFilledVariableName"],爲必填參數的變數名稱陣列,形態爲陣列變數,元素數量需要跟"mustBeFilledVariableType"參數的元素數量一致,例如: $conf["mustBeFilledVariableName"] = array("id","account","password");
                $conf["variableCheck::checkArguments"]["mustBeFilledVariableName"]=array("liName","liContent");
                #$conf["mustBeFilledVariableType"],爲必填參數的變數陣列應該爲何種變數形態,形態爲陣列,元素數量需要跟"mustBeFilledVariableName"參數的元素數量一致,例如: $conf["mustBeFilledVariableType"] = array("string",integer,"double","resource","object"); , null代表不指定變數形態.
                $conf["variableCheck::checkArguments"]["mustBeFilledVariableType"]=array("array","array");
                #$conf["referenceVarKey"],字串,$conf參數後面的key值,用於移除不要的參考陣列.
                $conf["variableCheck::checkArguments"]["referenceVarKey"]="variableCheck::checkArguments";
                #可以省略的參數:
                #$conf["canBeEmptyString"],字串,必填變數內容如果是空字串就不能算是有設置的話,請設為"false",預設爲"true",可以為空字串.
                $conf["variableCheck::checkArguments"]["canBeEmptyString"]="true";
                #$conf["canNotBeEmpty"],字串陣列,哪些必填參數的內容不得為空字串或空陣列,僅當$conf["canBeEmptyString"]為"true"時會生效.
                $conf["variableCheck::checkArguments"]["canNotBeEmpty"]=array("liName");
                #$conf["canBeEmpty"],字串陣列,哪些必填參數的內容可為空字串或空陣列,僅當$conf["canBeEmptyString"]為"false"時會生效.
                #$conf["canBeEmpty"]=array();
                #$conf["skipableVariableCanNotBeEmpty"],字串陣列,哪些可省略參數不可以為空字串或空陣列.
                #$conf["skipableVariableCanNotBeEmpty"]=array();
                #$conf["skipableVariableName"],陣列字串,爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");
                $conf["variableCheck::checkArguments"]["skipableVariableName"]=array("liIdHeadStr");
                #$conf["skipableVariableType"],陣列字串,爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double");
                $conf["variableCheck::checkArguments"]["skipableVariableType"]=array("string");
                #$conf["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,null與代表不指定,若預設值是參數之一,請將$conf["mustBeFilledVar"]改成"\$conf["\mustBeFilledVar\"]".
                $conf["variableCheck::checkArguments"]["skipableVarDefaultValue"]=array("mobileTab");
                #$conf["arrayCountEqualCheck"],字串陣列,為檢查哪些陣列參數的元素數量要一樣,$conf["arrayCountEqualCheck"][$i]=array()為第$i組key為哪些的變數其元素數量要相等.
                $conf["variableCheck::checkArguments"]["arrayCountEqualCheck"][]=array("liName","liContnet");
                #參考資料來源:
                #array_keys=>http://php.net/manual/en/function.array-keys.php
                $checkArguments=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);
                unset($conf["variableCheck::checkArguments"]);

                #如果檢查參數失敗
                if($checkArguments["status"]=="false"){

                        #設置執行失敗
                        $result["status"]="false";

                        #設置執行錯誤訊息
                        $result["error"]=$checkArguments;

                        #回傳結果
                        return $result;

                        }#if end

                #如果檢查參數不通過
                if($checkArguments["passed"]=="false"){

                        #設置執行失敗
                        $result["status"]="false";

                        #設置執行錯誤訊息
                        $result["error"]=$checkArguments;

                        #回傳結果
                        return $result;

                        }#if end

                #涵式說明:
                #建立給與html標籤使用的style屬性字串.
                #回傳的結果:
                #$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
                #$result["function"],當前執行的函數
                #$result["error"],錯誤訊息陣列
                #$result["content"],css設定內容
                #必填的參數:
                $conf["css::styleStr"]["styleName"]=array("font-size","display","padding-left","padding-right","padding-top","padding-bottom");#為屬性名稱,須為陣列值
                $conf["css::styleStr"]["styleValue"]=array("26px","inline","15px","15px","10px","10px");#為屬性值,須為陣列值
                $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

                #tag標題開始
                $result["content"]=$result["content"]."<div>";

                #上一頁的元素id
                $prePageId=$conf["liIdHeadStr"]."_prePage";

                #上一頁的標籤
                $result["content"]=$result["content"]."<span ".$styleStr["content"]." >";
                $result["content"]=$result["content"]."<span id=\"".$prePageId."\" class=\"btn btn-default\" >上一頁</span>";
                $result["content"]=$result["content"]."</span>";

                #當前標題的標籤
                $result["content"]=$result["content"]."<span ".$styleStr["content"]." >";
                $result["content"]=$result["content"]."<span></span>";
                $result["content"]=$result["content"]."</span>";

                #下一頁的元素id
                $nextPageId=$conf["liIdHeadStr"]."_nextPage";

                #下一頁的標籤
                $result["content"]=$result["content"]."<span ".$styleStr["content"]." >";
                $result["content"]=$result["content"]."<span id=\"".$nextPageId."\" class=\"btn btn-default\" >下一頁</span>";
                $result["content"]=$result["content"]."</span>";

                #tag標題結束
                $result["content"]=$result["content"]."</div>";

                #設置隱藏樣式的css類別名稱
                $hideClass=$conf["liIdHeadStr"]."_hide";

                #建立 $tabIdHeadStr.hide 類別
                #涵式說明:
                #創建 css 樣式,前面會自動加上「.」.
                #回傳的結果:
                #$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
                #$result["css"],css設定內容
                #$result["function"],當前執行的函數
                #$result["error"],涵式錯誤訊息,若爲""則表示沒有錯誤
                #必填的參數:
                $conf["css::createCssStyle"]["cssStyleName"]=$hideClass;#為該 css 樣式的名稱,不能以數字開頭,限定id的css樣式名稱為「樣式名稱.元素名稱」.
                $conf["css::createCssStyle"]["attributes"]=array("display");#為屬性名稱,須為陣列值
                $conf["css::createCssStyle"]["content"]=array("none");#為屬性值,須為陣列值
                $createCssStyle=css::createCssStyle($conf["css::createCssStyle"]);
                unset($conf["css::createCssStyle"]);

                #如果建立 css 樣式失敗
                if($createCssStyle["status"]=="false"){

                        $result["status"]="false";

                        #設置執行錯誤訊息
                        $result["error"]=$createCssStyle;

                        #回傳結果
                        return $result;

                        }#if end

                #串接 css 樣式
                $result["content"]=$result["content"].$createCssStyle["css"];

                #儲存總共有幾個tab
                $tabCount=count($conf["liContent"]);

                #$conf["liContent"]有幾個元素就執行幾次
                for($i=0;$i<$tabCount;$i++){

                        #設置div區塊
                        #涵式說明:
                        #<div>區塊,裡面可以指定css的class樣式,可以指定提示文字.
                        #$result["status"],字串,執行否正常,"true"代表正常,"false"代表不正常.
                        #$result["functin"],字串,當前函數的名稱.
                        #$result["error"],陣列,錯訊訊息.
                        #$result["content"],字串,含有<div>標籤的內容.
                        #必填參數:
                        #$conf["contentArray"],字串陣列,要放入的內容陣列.
                        $conf["css::divSection"]["contentArray"]=array($conf["liContent"][$i]);
                        #可省略參數
                        #$conf["id"],字串,div區塊的id.
                        $conf["css::divSection"]["id"]=$conf["liIdHeadStr"].$i;
                        #$conf["class"],字串,div區段要套用的css樣式.
                        $conf["css::divSection"]["class"]=$hideClass;
                        #$conf["title"],陣列,滑鼠移到上面時要顯示的內容,每個元素代表一列內容
                        #$conf["title"]=array();
                        $divSection=css::divSection($conf["css::divSection"]);
                        unset($conf["css::divSection"]);

                        #如果建立div區塊失敗
                        if($divSection["status"]=="false"){

                                #設置執行失敗
                                $result["status"]="false";

                                #設置執行錯誤訊息
                                $result["error"]=$divSection;

                                #回傳結果
                                return $result;

                                }#if end

                        #串接div的內容
                        $result["content"]=$result["content"].$divSection["content"];

                        }#for end

                #儲存tab名稱變數
                $jsonArray["tabList"]=$conf["liName"];

                #預設要顯示的tab index
                $jsonArray["tabToShow"]=0;

                #轉換成json變數
                $jsonData=json_encode($jsonArray);

                #設置暫存新分頁資訊的webstorage名稱
                $tempWebStorage=$conf["liIdHeadStr"]."_tempWebStorage";

                #設置儲存哪個分頁要顯示以及每個分頁標題的webSorage變數.
                #涵式說明:
                #儲存變數到local storage
                #回傳結果:
                #$result["status"],執行是否正常,"true"為正常,"false"為不正常.
                #$result["error"],錯誤訊息陣列
                #$result["function"],當前執行的函數名稱
                #$result["content"],要執行的javaScript語法
                #必填參數:
                #$conf["key"],字串,要儲存的key為何.
                $conf["javaScript::saveToLocalStorage"]["key"]=$tempWebStorage;
                #$conf["val"],字串,要儲存的val為何.
                $conf["javaScript::saveToLocalStorage"]["val"]=$jsonData;
                #$conf["noScriptTag"],字串,是否不要<script></script>,"true"代表不要,"false"代表不用,預設為"false".
                #$conf["javaScript::saveToLocalStorage"]["noScriptTag"]="false";
                $saveToLocalStorage=javaScript::saveToLocalStorage($conf["javaScript::saveToLocalStorage"]);
                unset($conf["javaScript::saveToLocalStorage"]);

                #如果建立local storage失敗
                if($saveToLocalStorage["status"]==="false"){

                        #設置執行失敗
                        $result["status"]="false";

                        #設置執行錯誤訊息
                        $result["error"]=$saveToLocalStorage;

                        #回傳結果
                        return $result;

                        }#if end

                #串接內容
                $result["content"]=$result["content"].$saveToLocalStorage["content"];

                #設置儲存既有分頁資訊的webstorage名稱
                $webStorage=$conf["liIdHeadStr"]."_webStorage";

                #設置儲存既有分頁資訊的js變數名稱
                $currentTabInfo=$conf["liIdHeadStr"]."currentTabInfo";

                #檢查是否存在既有分頁資訊的 local storage 變數.
                #涵式說明:
                #取得儲存在local storage的變數
                #回傳結果:
                #$result["status"],執行是否正常,"true"為正常,"false"為不正常.
                #$result["error"],錯誤訊息陣列
                #$result["function"],當前執行的函數名稱
                #$result["content"],要執行的javaScript語法
                #必填參數:
                #$conf["key"],字串,要儲存的key為何.
                $conf["javaScript::getLocalStorage"]["key"]=$webStorage;
                #$conf["storeVar"],字串,要儲存到哪個javascript變數裡面.
                $conf["javaScript::getLocalStorage"]["storeVar"]=$currentTabInfo;
                #可省略參數:
                #$conf["noScriptTag"],字串,是否不要<script></script>,"true"代表不要,"false"代表不用,預設為"false".
                $conf["javaScript::getLocalStorage"]["noScriptTag"]="true";
                #$conf["json"],字串要取出的資料是否json,"true"代表是,"false"代表不是,預設為"false".
                $conf["javaScript::getLocalStorage"]["json"]="true";
                $getLocalStorage=javaScript::getLocalStorage($conf["javaScript::getLocalStorage"]);
                unset($conf["javaScript::getLocalStorage"]);

                #如果建立語法失敗
                if($getLocalStorage["status"]==="false"){

                        #設置執行失敗
                        $result["status"]="false";

                        #設置執行錯誤訊息
                        $result["error"]=$getLocalStorage;

                        #回傳結果
                        return $result;

                        }#if end

                #取得儲存在 local storage 中既有的分頁資料
                $script=$getLocalStorage["content"];

                #設置儲存哪個分頁要顯示以及每個分頁標題的webSorage變數.
                #涵式說明:
                #儲存變數到local storage
                #回傳結果:
                #$result["status"],執行是否正常,"true"為正常,"false"為不正常.
                #$result["error"],錯誤訊息陣列
                #$result["function"],當前執行的函數名稱
                #$result["content"],要執行的javaScript語法
                #必填參數:
                #$conf["key"],字串,要儲存的key為何.
                $conf["javaScript::saveToLocalStorage"]["key"]=$webStorage;
                #$conf["val"],字串,要儲存的val為何.
                $conf["javaScript::saveToLocalStorage"]["val"]=$jsonData;
                #可省略參數:
                #$conf["noScriptTag"],字串,是否不要用script tag包住回傳的內容($result["content"]),"true"代表不要用,"false"代表要用,預設為"false".
                $conf["javaScript::saveToLocalStorage"]["noScriptTag"]="true";
                $saveToLocalStorage=javaScript::saveToLocalStorage($conf["javaScript::saveToLocalStorage"]);
                unset($conf["javaScript::saveToLocalStorage"]);

                #如果建立local storage失敗
                if($saveToLocalStorage["status"]==="false"){

                        #設置執行失敗
                        $result["status"]="false";

                        #設置執行錯誤訊息
                        $result["error"]=$saveToLocalStorage;

                        #回傳結果
                        return $result;

                        }#if end

                #涵式說明:
                #移除儲存在local storage的變數
                #回傳結果:
                #$result["status"],執行是否正常,"true"為正常,"false"為不正常.
                #$result["error"],錯誤訊息陣列
                #$result["function"],當前執行的函數名稱
                #$result["content"],要執行的javaScript語法
                #必填參數:
                #$conf["key"],字串,要儲存的key為何.
                $conf["javaScript::rmLocalStorage"]["key"]=$tempWebStorage;
                #可省略參數:
                #$conf["noScriptTag"],字串,是否不要用script tag包住回傳的內容($result["content"]),"true"代表不要用,"false"代表要用,預設為"false".
                $conf["javaScript::rmLocalStorage"]["noScriptTag"]="true";
                $rmLocalStorage=javaScript::rmLocalStorage($conf["javaScript::rmLocalStorage"]);
                unset($conf["javaScript::rmLocalStorage"]);

                #如果建立移除暫存 local storage 變數的語法失敗
                if($rmLocalStorage["status"]=="false"){

                        #設置執行失敗
                        $result["status"]="false";

                        #設置執行錯誤訊息
                        $result["error"]=$rmLocalStorage;

                        #回傳結果
                        return $result;

                        }#if end

                #建立 prePage 的事件
                #涵式說明:
                #建立特定元素的jquery on click事件
                #回傳結果:
                #$result["status"],執行正確與否,"true"代表執行正確,"false"代表執行失敗.
                #$result["error"],錯誤訊息陣列.
                #$result["content"],JavaScript的語法.
                #$result["function"],當前執行的函數名稱.
                #$result["importJS"],匯入js的語法,必定含有<script></script>標籤.
                #必填參數:
                #$conf["trigger"],字串,要設定click事件的目標(selector),可以為ID("#element_id"),class(".trigger"),tag("div"),tag&attr("div[data-action=nextPage]"),combine tag&class("div.flip").
                $conf["jquery::onClick"]["trigger"]="#".$prePageId;
                #$conf["content"],字串,click事件觸發後,要做的事情.
                $conf["jquery::onClick"]["content"]=$getLocalStorage["content"]."
                        //取得當前分頁的索引
                        index=".$currentTabInfo.".tabToShow;

                        //如果是第一個分頁
                        if(index==0)
                        {
                                return false;
                        }
                        //反之
                        else
                        {
                                //隱藏切換前的分頁內容
                                $('#".$conf["liIdHeadStr"]."'+index).addClass('".$hideClass."');

                                //恢復下一頁的功能
                                $('#".$nextPageId."').attr('disabled',false);

                                //分頁索引-1
                                ".$currentTabInfo.".tabToShow=index-1;

                                //如果是一個分頁
                                if(".$currentTabInfo.".tabToShow==0)
                                {
                                        //停止上一頁的功能
                                        $('#".$prePageId."').attr('disabled',true);
                                }

                                //更新儲存到localStorage的變數(目前看的分頁)
                                localStorage.".$webStorage."=JSON.stringify(".$currentTabInfo.");

                                //更新分頁標題
                                $('#".$prePageId."').parent().next().html('<span>'+".$currentTabInfo.".tabList[".$currentTabInfo.".tabToShow]+'</span>');

                                //顯示分頁內容
                                $('#".$conf["liIdHeadStr"]."'+".$currentTabInfo.".tabToShow).removeClass('".$hideClass."');
                        }
                        ";
                #可省略參數:
                #$conf["jqueryPath"],字串,jquery的位置,預設不指定.
                #$conf["jqueryPath"]="";
                #$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑,請與參數"jqueryPath"一起設置,預設為當前檔案的位置.
                #$conf["fileArgu"]=__FILE__;
                #$conf["noScriptTag"],字串,是否不要<script></script>,"true"代表不要,"false"代表不用,預設為"false".
                $conf["jquery::onClick"]["noScriptTag"]="true";
                #參考資料:
                #selector=>https://api.jquery.com/category/selectors/
                $prePageClickEvent=jquery::onClick($conf["jquery::onClick"]);
                unset($conf["jquery::onClick"]);

                #如果建立 on click 事件失敗
                if($prePageClickEvent["status"]=="false"){

                        #設置執行失敗
                        $result["status"]="false";

                        #設置執行錯誤訊息
                        $result["error"]=$prePageClickEvent;

                        #回傳結果
                        return $result;

                        }#if end

                #建立 nextPage 的事件
                #涵式說明:
                #建立特定元素的jquery on click事件
                #回傳結果:
                #$result["status"],執行正確與否,"true"代表執行正確,"false"代表執行失敗.
                #$result["error"],錯誤訊息陣列.
                #$result["content"],JavaScript的語法.
                #$result["function"],當前執行的函數名稱.
                #$result["importJS"],匯入js的語法,必定含有<script></script>標籤.
                #必填參數:
                #$conf["trigger"],字串,要設定click事件的目標(selector),可以為ID("#element_id"),class(".trigger"),tag("div"),tag&attr("div[data-action=nextPage]"),combine tag&class("div.flip").
                $conf["jquery::onClick"]["trigger"]="#".$nextPageId;
                #$conf["content"],字串,click事件觸發後,要做的事情.
                $conf["jquery::onClick"]["content"]=$getLocalStorage["content"]."
                        //取得當前分頁的索引
                        index=".$currentTabInfo.".tabToShow;

                        //如果是最後一個分頁
                        if(index==".$currentTabInfo.".tabList.length-1)
                        {
                                return false;
                        }
                        //反之
                        else
                        {
                                //隱藏切換前的分頁內容
                                $('#".$conf["liIdHeadStr"]."'+index).addClass('".$hideClass."');

                                //恢復上一頁的功能
                                $('#".$prePageId."').attr('disabled',false);

                                //分頁索引+1
                                ".$currentTabInfo.".tabToShow=index+1;

                                //如果是最後一個分頁
                                if(".$currentTabInfo.".tabToShow==".$currentTabInfo.".tabList.length-1)
                                {
                                        //停止下一頁的功能
                                        $('#".$nextPageId."').attr('disabled',true);
                                }

                                //更新儲存到localStorage的變數(目前看的分頁)
                                localStorage.".$webStorage."=JSON.stringify(".$currentTabInfo.");

                                //更新分頁標題
                                $('#".$nextPageId."').parent().prev().html('<span>'+".$currentTabInfo.".tabList[".$currentTabInfo.".tabToShow]+'</span>');

                                //顯示分頁內容
                                $('#".$conf["liIdHeadStr"]."'+".$currentTabInfo.".tabToShow).removeClass('".$hideClass."');
                        }
                        ";
                #可省略參數:
                #$conf["jqueryPath"],字串,jquery的位置,預設不指定.
                #$conf["jqueryPath"]="";
                #$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑,請與參數"jqueryPath"一起設置,預設為當前檔案的位置.
                #$conf["fileArgu"]=__FILE__;
                #$conf["noScriptTag"],字串,是否不要<script></script>,"true"代表不要,"false"代表不用,預設為"false".
                $conf["jquery::onClick"]["noScriptTag"]="true";
                #參考資料:
                #selector=>https://api.jquery.com/category/selectors/
                $nextPageClickEvent=jquery::onClick($conf["jquery::onClick"]);
                unset($conf["jquery::onClick"]);

                #如果建立 on click 事件失敗
                if($nextPageClickEvent["status"]=="false"){

                        #設置執行失敗
                        $result["status"]="false";

                        #設置執行錯誤訊息
                        $result["error"]=$nextPageClickEvent;

                        #回傳結果
                        return $result;

                        }#if end

                #建立初始化當前瀏覽頁面的功能
                $initialTabViewScript="

                        //取得分頁資訊的變數
                        ".$getLocalStorage["content"]."

                        //初始化分頁標題
                        $('#".$nextPageId."').parent().prev().html('<span>'+".$currentTabInfo.".tabList[".$currentTabInfo.".tabToShow]+'</span>');

                        //初始化要顯示的分頁內容
                        $('#".$conf["liIdHeadStr"]."'+".$currentTabInfo.".tabToShow).removeClass('".$hideClass."');

                        //如果是第一個分頁
                        if(".$currentTabInfo.".tabToShow==0)
                        {
                                //停止上一頁的功能
                                $('#".$prePageId."').attr('disabled',true);
                        }

                        //如果是最後一個分頁
                        if(".$currentTabInfo.".tabToShow==".$currentTabInfo.".tabList.length-1)
                        {
                                //停止下一頁的功能
                                $('#".$nextPageId."').attr('disabled',true);
                        }
                        ";

                #建立檢查分頁資訊是否存在且結構正確,再決定使用既有的分頁資訊還是建立新的分頁資訊.
                $script=$script."

                        //如果沒有分頁資訊存在
                        if(window.".$currentTabInfo."==undefined)
                        {
                                //建立新的 tab 資訊
                                ".$saveToLocalStorage["content"]."

                                //將暫存的tab資訊移除
                                ".$rmLocalStorage["content"]."

                                //設定上一頁按鈕的事件
                                ".$prePageClickEvent["content"]."

                                //設定下一頁按鈕的事件
                                ".$nextPageClickEvent["content"]."

                                //初始化要呈現的tab頁面
                                ".$initialTabViewScript."

                        }//if end

                        //反之檢查既有的tab資訊結構是否正確
                        else
                        {
                                //初始化設置結構檢查不通過
                                passed='false';

                                //檢查有無 tabToShow 與 tabList 兩個元素
                                if(".$currentTabInfo.".tabToShow!='undefinded' & ".$currentTabInfo.".tabList!='undefinded')
                                {
                                        //檢查 tabToShow 的數值是否正確 與 tabList 的數量是否正確
                                        if(".$currentTabInfo.".tabToShow<".$tabCount." & ".$currentTabInfo.".tabList.length==.".$tabCount.")
                                        {
                                                //設置結構檢查通過
                                                passed='true';

                                        }//if end

                                }//if end

                                //結構資訊正常
                                if(passed)
                                {
                                        //將暫存的tab資訊移除
                                        ".$rmLocalStorage["content"]."

                                        //設定上一頁按鈕的事件
                                        ".$prePageClickEvent["content"]."

                                        //設定下一頁按鈕的事件
                                        ".$nextPageClickEvent["content"]."

                                        //初始化要呈現的tab頁面
                                        ".$initialTabViewScript."

                                }//if end

                                //結構資訊不正常
                                else
                                {
                                        //建立新的 tab 資訊
                                        ".$saveToLocalStorage["content"]."

                                        //將暫存的tab資訊移除
                                        ".$rmLocalStorage["content"]."

                                }//else end

                        }//else end
                        ";

                #將 建立檢查分頁資訊是否存在且結構正確,再決定使用既有的分頁資訊還是建立新的分頁資訊 的script語法用<script></script>包起來.
                #涵式說明:
                #將要執行的script語法透過該函式執行
                #回傳結果:
                #$result["status"],執行是否正常,"true"為正常,"false"為不正常.
                #$result["error"],錯誤訊息陣列
                #$result["function"],當前執行的函數名稱
                #$result["content"],要執行的javaScript語法
                #必填的參數:
                #$conf["script"],字串,要執行的javaScript語法,標籤「<script></script>」會自動補上.
                $conf["javaScript::toScript"]["script"]=$script;
                $toScript=javaScript::toScript($conf["javaScript::toScript"]);
                unset($conf["javaScript::toScript"]);

                #如果建立
                if($toScript["status"]=="false"){

                        #設置執行失敗
                        $result["status"]="false";

                        #設置執行錯誤訊息
                        $result["error"]=$toScript;

                        #回傳結果
                        return $result;

                        }#if end

                #串接 script 語法
                $result["content"]=$result["content"].$toScript["content"];

                #用<div></div>包起來
                $result["content"]="<div>".$result["content"]."</div>";

                #設置執行正常
                $result["status"]="true";

                #回傳結果
                return $result;

                }#function mobile end

        /*
        #函數說明:
        #使用bootstrap樣式建立的分頁功能
        #回傳結果:
        #$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
        #$result["error"],錯誤訊息陣列.
        #$result["function"],當前執行的函數名稱
        #$result["content"],建立bootstrap樣式分頁的語法
        #必填參數:
        #$conf["liName"],字串陣列,有幾個分頁標籤.
        $conf["liName"]=array();
        #$conf["liContent"],字串陣列,每個分頁底下的內容為什麼.
        $conf["liContent"]=array();
        #可省略參數:
        #$conf["liId"],陣列,$conf["liContent"]中每個元素的id,用來給$conf["liName"]呼叫要顯示的頁面,預設為$conf["liName"].
        #$conf["liId"]=array();
        #參考資料:
        #http://www.w3schools.com/bootstrap/bootstrap_tabs_pills.asp
        */
        function bootstrap(&$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變數須為陣列形態";

                        #如果傳入的參數為 null
                        if($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[$shouldBeCheckedVarName]["varExist"],所檢查的變數是否存在,"false"代表不存在;"true"代表存在
                #$result[$shouldBeCheckedVarName]["varType"],所檢查的變數型態是否正確,"false"代表錯誤;"true"代表正確
                #$result[$shouldBeCheckedVarName]["error"],每個參數設定的錯誤訊息
                #$result["shouldNotBeEmpty"],不應該為空字串或控陣列的變數.
                #$result["argu"],字串陣列,目前輸入的參數名稱陣列.
                #$result["legalVarName"],字串陣列,合法可用的參數名稱陣列.
                #$result["notNeedVar"],字串陣列,多餘的參數名稱.
                #必填寫的參數:
                #$conf["varInput"],陣列變數,要檢查的陣列變數,請在要檢查的參數前面加上&,這樣變動的結果才能被套用。
                $conf["variableCheck::checkArguments"]["varInput"]=&$conf;
                #$conf["mustBeFilledVariableName"],爲必填參數的變數名稱陣列,形態爲陣列變數,元素數量需要跟"mustBeFilledVariableType"參數的元素數量一致,例如: $conf["mustBeFilledVariableName"] = array("id","account","password");
                $conf["variableCheck::checkArguments"]["mustBeFilledVariableName"]=array("liName","liContent");
                #$conf["mustBeFilledVariableType"],爲必填參數的變數陣列應該爲何種變數形態,形態爲陣列,元素數量需要跟"mustBeFilledVariableName"參數的元素數量一致,例如: $conf["mustBeFilledVariableType"] = array("string",integer,"double","resource","object"); , null代表不指定變數形態.
                $conf["variableCheck::checkArguments"]["mustBeFilledVariableType"]=array("array","array");
                #$conf["referenceVarKey"],字串,$conf參數後面的key值,用於移除不要的參考陣列.
                $conf["variableCheck::checkArguments"]["referenceVarKey"]="variableCheck::checkArguments";
                #可以省略的參數:
                #$conf["canBeEmptyString"],字串,必填變數內容如果是空字串就不能算是有設置的話,請設為"false",預設爲"true",可以為空字串.
                $conf["variableCheck::checkArguments"]["canBeEmptyString"]="true";
                #$conf["canNotBeEmpty"],字串陣列,哪些必填參數的內容不得為空字串或空陣列,僅當$conf["canBeEmptyString"]為"true"時會生效.
                $conf["variableCheck::checkArguments"]["canNotBeEmpty"]=array("liName");
                #$conf["canBeEmpty"],字串陣列,哪些必填參數的內容可為空字串或空陣列,僅當$conf["canBeEmptyString"]為"false"時會生效.
                #$conf["canBeEmpty"]=array();
                #$conf["skipableVariableCanNotBeEmpty"],字串陣列,哪些可省略參數不可以為空字串或空陣列.
                #$conf["skipableVariableCanNotBeEmpty"]=array();
                #$conf["skipableVariableName"],陣列字串,爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");
                $conf["variableCheck::checkArguments"]["skipableVariableName"]=array("liId");
                #$conf["skipableVariableType"],陣列字串,爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double");
                $conf["variableCheck::checkArguments"]["skipableVariableType"]=array("array");
                #$conf["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,null與代表不指定,若預設值是參數之一,請將$conf["mustBeFilledVar"]改成"\$conf["\mustBeFilledVar\"]".
                $conf["variableCheck::checkArguments"]["skipableVarDefaultValue"]=array("\$conf[\"liName\"]");
                #$conf["arrayCountEqualCheck"],字串陣列,為檢查哪些陣列參數的元素數量要一樣,$conf["arrayCountEqualCheck"][$i]=array()為第$i組key為哪些的變數其元素數量要相等.
                $conf["variableCheck::checkArguments"]["arrayCountEqualCheck"][]=array("liName","liContnet","liId");
                #參考資料來源:
                #array_keys=>http://php.net/manual/en/function.array-keys.php
                $checkArguments=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);
                unset($conf["variableCheck::checkArguments"]);

                #如果檢查參數失敗
                if($checkArguments["status"]=="false"){

                        #設置執行失敗
                        $result["status"]="false";

                        #設置執行錯誤訊息
                        $result["error"]=$checkArguments;

                        #回傳結果
                        return $result;

                        }#if end

                #如果檢查參數不通過
                if($checkArguments["passed"]=="false"){

                        #設置執行失敗
                        $result["status"]="false";

                        #設置執行錯誤訊息
                        $result["error"]=$checkArguments;

                        #回傳結果
                        return $result;

                        }#if end

                #ul開始
                $ul="<ul class=\"nav nav-tabs\">";

                #初始化tab的內容
                $tab="<div class=\"tab-content\">";

                #$conf["liName"] 有幾個就執行幾次
                for($i=0;$i<count($conf["liName"]);$i++){

                        #串接 li
                        $ul=$ul."<li>";
                        $ul=$ul."<a data-toggle=\"tab\" href=\"#".$conf["liId"][$i]."\" >".$conf["liName"][$i]."</a>";
                        $ul=$ul."</li>";

                        #如果是第一筆
                        if($i===0){

                                #串接 tab 的內容
                                $tab=$tab."<div class=\"tab-pane fade in active \" id=\"".$conf["liId"][$i]."\">".$conf["liContent"][$i]."</div>";

                                }#if end

                        #反之不是第一筆
                        else{

                                #串接 tab 的內容
                                $tab=$tab."<div class=\"tab-pane fade\" id=\"".$conf["liId"][$i]."\">".$conf["liContent"][$i]."</div>";

                                }#else end

                        }#for end

                #ul結束
                $ul=$ul."</ul>";

                #tab content 結束
                $tab=$tab."</div>";

                #取得分頁的內容
                $result["content"]=$ul.$tab;

                #設置執行正常
                $result["status"]="true";

                #回傳結果
                return $result;

                }#function botostrap

        }#class tab end

?>