function GetCurPageParams() { $PageId = ToolMethod::Instance()->GetPageId(); $sql = "select PageId,ParamsId,ParamsType,ParamsName,FieldsId,FieldsName\n\t\t\tfrom config_page_param\n\t\t\twhere PageId='" . $PageId . "'"; $tmp = DB::Instance()->GetFirstRow($sql); $ParamsId = explode(",", $tmp["ParamsId"]); // , 隔开 $ParamsType = explode(",", $tmp["ParamsType"]); $ParamsName = explode(",", $tmp["ParamsName"]); $FieldsId = explode(",", $tmp["FieldsId"]); $FieldsName = explode(",", $tmp["FieldsName"]); if (count($ParamsId) == count($ParamsType) && count($ParamsId) == count($ParamsName) && count($ParamsType) == count($ParamsName) && count($FieldsId) == count($FieldsName)) { $sql = "select tb2.BtnId,tb2.BtnClass,tb2.BtnName,tb2.BtnIcon\n\t\t\t\tfrom(\n\t\t\t\t select * from config_page_btn\n\t\t\t\t where IsActive=1 and PageId='" . $PageId . "'\n\t\t\t\t order by Seq\n\t\t\t\t) as tb1\n\t\t\t\tinner join(\n\t\t\t\t select * from config_btn\n\t\t\t\t where IsActive=1\n\t\t\t\t) as tb2\n\t\t\t\ton tb1.BtnId=tb2.BtnId"; $tmp_Btn = DB::Instance()->GetJson($sql); $tmp_Params = ""; for ($i = 0; $i < count($ParamsId); $i++) { if ($ParamsId[$i] != "" && $ParamsType[$i] != "" && $ParamsName[$i] != "") { $tmp_Params .= '{' . '"id":' . json_encode($ParamsId[$i]) . ',' . '"type":' . json_encode($ParamsType[$i]) . ',' . '"name":' . json_encode($ParamsName[$i]) . '' . '},'; } } $tmp_Params = rtrim($tmp_Params, ","); $tmp_Fields = ""; for ($i = 0; $i < count($FieldsId); $i++) { if ($FieldsId[$i] != "" && $FieldsName[$i] != "") { $tmp_Fields .= '{' . '"id":' . json_encode($FieldsId[$i]) . ',' . '"name":' . json_encode($FieldsName[$i]) . '' . '},'; } } $tmp_Fields = rtrim($tmp_Fields, ","); echo '{' . '"PageId":' . json_encode($PageId) . ',' . '"Params":[' . $tmp_Params . '],' . '"Fields":[' . $tmp_Fields . '],' . '"Btns":' . $tmp_Btn . '' . '}'; } else { throw new Exception("Params Error"); //配置失败 } }
public function GetModifySql($tb) { $Params = self::GetPageParamForSql(); //获取数据库的页面配置数据 $ParamsId = explode(",", $Params["ParamsId"]); $QuerysType = explode(",", $Params["QuerysType"]); $str = ""; $sql_where = ""; for ($i = 0; $i < count($ParamsId); $i++) { $tmp1 = $QuerysType[$i]; $tmp2 = $ParamsId[$i]; $tmp3 = ToolMethod::Instance()->GetUrlParam("old_" . $tmp2); if ($tmp3 == "") { $tmp3 = ToolMethod::Instance()->GetPostParam("old_" . $tmp2); } if ($tmp1 == "like" && $tmp3 != "") { $sql_where .= " and " . $tmp2 . " " . $tmp1 . " '%" . $tmp3 . "%'"; } elseif ($tmp1 == "=" && $tmp3 != "") { $sql_where .= " and " . $tmp2 . " " . $tmp1 . " '" . $tmp3 . "'"; } $tmp3 = ToolMethod::Instance()->GetUrlParam($tmp2); if ($tmp3 == "") { $tmp3 = ToolMethod::Instance()->GetPostParam($tmp2); } $str .= $tmp2 . "='" . $tmp3 . "',"; } return "update " . $tb . " set " . rtrim($str, ",") . " where " . ltrim($sql_where, " and"); }
function GetUserToken() { return ToolMethod::Instance()->GetCookies(Config::Instance()->LoginUser["UserToken"]); }