public virtual XVar preparePage() { dynamic fields = XVar.Array(), i = null, keylink = null, tKeys = XVar.Array(); if ((XVar)(!(XVar)(this.masterRecordData)) || (XVar)(!(XVar)(MVCFunctions.count(this.masterRecordData)))) { return(null); } this.xt.assign(new XVar("pagetitlelabel"), (XVar)(getPageTitle((XVar)(this.pageType), (XVar)(MVCFunctions.GoodFieldName((XVar)(this.tName))), (XVar)(this.masterRecordData)))); tKeys = XVar.Clone(this.pSet.getTableKeys()); keylink = new XVar(""); i = new XVar(0); for (; i < MVCFunctions.count(tKeys); i++) { keylink = MVCFunctions.Concat(keylink, "&key", i + 1, "=", MVCFunctions.runner_htmlspecialchars((XVar)(MVCFunctions.RawUrlEncode((XVar)(this.masterRecordData[tKeys[i]]))))); } fields = XVar.Clone(this.pSet.getMasterListFields()); fields = XVar.Clone(MVCFunctions.array_merge((XVar)(fields), (XVar)(tKeys))); foreach (KeyValuePair <XVar, dynamic> f in fields.GetEnumerator()) { dynamic fieldClassStr = null; fieldClassStr = XVar.Clone(fieldClass((XVar)(f.Value))); this.xt.assign((XVar)(MVCFunctions.Concat(MVCFunctions.GoodFieldName((XVar)(f.Value)), "_mastervalue")), (XVar)(MVCFunctions.Concat("<span class='", fieldClassStr, "'>", showDBValue((XVar)(f.Value), (XVar)(this.masterRecordData), (XVar)(keylink)), "</span>"))); this.xt.assign((XVar)(MVCFunctions.Concat(MVCFunctions.GoodFieldName((XVar)(f.Value)), "_class")), (XVar)(fieldClassStr)); } if (XVar.Pack(this.pageLayout)) { this.xt.assign(new XVar("pageattrs"), (XVar)(MVCFunctions.Concat("class=\"", this.pageLayout.style, " page-", this.pageLayout.name, "\""))); } this.xt.load_template((XVar)(MVCFunctions.GetTemplateName((XVar)(this.shortTableName), (XVar)(MVCFunctions.Concat("master", this.masterPageType))))); return(null); }
public virtual XVar process() { setReferer(); if (XVar.Pack(GlobalVars.globalEvents.exists(new XVar("BeforeProcessChangePwd")))) { GlobalVars.globalEvents.BeforeProcessChangePwd(this); } if (this.action == "Change") { this.changedSuccess = XVar.Clone(changePassword()); } if (XVar.Pack(!(XVar)(this.changedSuccess))) { prepareEditControls(); } else { this.pageName = XVar.Clone(this.pSet.getDefaultPage((XVar)(successPageType()))); this.pSet = XVar.UnPackProjectSettings(new ProjectSettings((XVar)(this.tName), (XVar)(successPageType()), (XVar)(this.pageName), (XVar)(this.pageTable))); this.pageData.InitAndSetArrayItem(MVCFunctions.array_merge((XVar)(this.pageData["buttons"]), (XVar)(this.pSet.buttons())), "buttons"); foreach (KeyValuePair <XVar, dynamic> b in this.pSet.buttons().GetEnumerator()) { AddJSFile((XVar)(MVCFunctions.Concat("include/button_", b.Value, ".js"))); } } addCommonJs(); fillSetCntrlMaps(); addButtonHandlers(); doCommonAssignments(); showPage(); return(null); }
public virtual XVar preparePage() { dynamic fields = XVar.Array(), i = null, keylink = null, pageTypeTitle = null, tKeys = XVar.Array(); if ((XVar)(!(XVar)(this.masterRecordData)) || (XVar)(!(XVar)(MVCFunctions.count(this.masterRecordData)))) { return(null); } pageTypeTitle = XVar.Clone(this.pageType); if (this.masterPageType == "report") { pageTypeTitle = new XVar("masterprint"); } this.xt.assign(new XVar("pagetitlelabel"), (XVar)(getPageTitle((XVar)(pageTypeTitle), (XVar)(MVCFunctions.GoodFieldName((XVar)(this.tName))), (XVar)(this.masterRecordData)))); tKeys = XVar.Clone(this.pSet.getTableKeys()); keylink = new XVar(""); i = new XVar(0); for (; i < MVCFunctions.count(tKeys); i++) { keylink = MVCFunctions.Concat(keylink, "&key", i + 1, "=", MVCFunctions.runner_htmlspecialchars((XVar)(MVCFunctions.RawUrlEncode((XVar)(this.masterRecordData[tKeys[i]]))))); } fields = XVar.Clone(this.pSet.getPageFields()); fields = XVar.Clone(MVCFunctions.array_merge((XVar)(fields), (XVar)(tKeys))); foreach (KeyValuePair <XVar, dynamic> f in fields.GetEnumerator()) { dynamic fieldClassStr = null, value = null; this.xt.assign((XVar)(MVCFunctions.Concat(MVCFunctions.GoodFieldName((XVar)(f.Value)), "_fieldheader")), new XVar(true)); fieldClassStr = XVar.Clone(fieldClass((XVar)(f.Value))); value = XVar.Clone(showDBValue((XVar)(f.Value), (XVar)(this.masterRecordData), (XVar)(keylink))); if (XVar.Pack(pdfJsonMode())) { this.xt.assign((XVar)(MVCFunctions.Concat(MVCFunctions.GoodFieldName((XVar)(f.Value)), "_pdfvalue")), (XVar)(value)); } else { dynamic wrappedValue = null; wrappedValue = XVar.Clone(MVCFunctions.Concat("<span class='", fieldClassStr, "'>", value, "</span>")); this.xt.assign((XVar)(MVCFunctions.Concat(MVCFunctions.GoodFieldName((XVar)(f.Value)), "_mastervalue")), (XVar)(wrappedValue)); this.xt.assign((XVar)(MVCFunctions.Concat(MVCFunctions.GoodFieldName((XVar)(f.Value)), "_value")), (XVar)(wrappedValue)); } this.xt.assign((XVar)(MVCFunctions.Concat(MVCFunctions.GoodFieldName((XVar)(f.Value)), "_class")), (XVar)(fieldClassStr)); this.xt.assign((XVar)(MVCFunctions.Concat(MVCFunctions.GoodFieldName((XVar)(f.Value)), "_fieldcolumn")), new XVar(true)); this.xt.assign((XVar)(MVCFunctions.Concat(MVCFunctions.GoodFieldName((XVar)(f.Value)), "_fieldheadercolumn")), new XVar(true)); } this.xt.assign(new XVar("grid_header"), new XVar(true)); this.xt.assign(new XVar("grid_row"), new XVar(true)); this.xt.assign(new XVar("grid_record"), new XVar(true)); this.xt.assign(new XVar("grid_vrecord"), new XVar(true)); if (XVar.Pack(this.pageLayout)) { this.xt.assign(new XVar("pageattrs"), (XVar)(MVCFunctions.Concat("class=\"", this.pageLayout.style, " page-", this.pageLayout.name, "\""))); } if (XVar.Pack(!(XVar)(pdfJsonMode()))) { this.xt.load_template((XVar)(MVCFunctions.GetTemplateName((XVar)(this.shortTableName), (XVar)(this.pageType)))); } return(null); }
public virtual XVar addControlsJSAndCSS() { dynamic appearOnPageFunc = null, fields = XVar.Array(), getEditFieldsFunc = null, pageTypeStr = null, pageTypes = null, searchFields = null, searchPanelActivated = null; pageTypes = XVar.Clone(XVar.Array()); switch (((XVar)this.pageType).ToString()) { case Constants.PAGE_ADD: pageTypeStr = new XVar("Add"); break; case Constants.PAGE_EDIT: pageTypeStr = new XVar("Edit"); break; case Constants.PAGE_VIEW: case Constants.PAGE_LIST: case Constants.PAGE_SEARCH: pageTypeStr = new XVar("List"); break; case Constants.PAGE_REGISTER: pageTypeStr = new XVar("RegisterOrSearch"); break; default: pageTypeStr = new XVar(""); break; } searchPanelActivated = XVar.Clone(isSearchPanelActivated()); if ((XVar)(pageTypeStr == XVar.Pack("")) && (XVar)(!(XVar)(searchPanelActivated))) { return(null); } if ((XVar)(pageTypeStr != XVar.Pack("")) && (XVar)(this.pageType != Constants.PAGE_SEARCH)) { getEditFieldsFunc = XVar.Clone(MVCFunctions.Concat("get", (XVar.Pack((XVar)(this.pageAddLikeInline) || (XVar)(this.pageEditLikeInline)) ? XVar.Pack("Inline") : XVar.Pack("")), pageTypeStr, "Fields")); if ((XVar)(this.pageAddLikeInline) || (XVar)(this.pageEditLikeInline)) { appearOnPageFunc = XVar.Clone(MVCFunctions.Concat("appearOnInline", pageTypeStr)); } else { appearOnPageFunc = XVar.Clone(MVCFunctions.Concat("appearOn", pageTypeStr, "Page")); } } switch (((XVar)this.pageType).ToString()) { case Constants.PAGE_REGISTER: fields = XVar.Clone(this.pSetEdit.getPageFields()); break; case Constants.PAGE_SEARCH: fields = XVar.Clone(this.pSetEdit.getAdvSearchFields()); break; default: fields = XVar.Clone(XVar.Array()); if (XVar.Pack(getEditFieldsFunc)) { fields = XVar.Clone(this.pSetEdit.Invoke(getEditFieldsFunc)); } break; } searchFields = XVar.Clone(XVar.Array()); if (XVar.Pack(searchPanelActivated)) { searchFields = XVar.Clone(this.pSetEdit.getPanelSearchFields()); searchFields = XVar.Clone(MVCFunctions.array_merge((XVar)(searchFields), (XVar)(this.pSetEdit.getAllSearchFields()))); searchFields = XVar.Clone(MVCFunctions.array_unique((XVar)(searchFields))); fields = XVar.Clone(MVCFunctions.array_merge((XVar)(searchFields), (XVar)(fields))); fields = XVar.Clone(MVCFunctions.array_unique((XVar)(fields))); } foreach (KeyValuePair <XVar, dynamic> f in fields.GetEnumerator()) { dynamic appear = null; appear = new XVar(false); if ((XVar)((XVar)(this.pageType == Constants.PAGE_REGISTER) || (XVar)(this.pageType == Constants.PAGE_SEARCH)) || (XVar)(MVCFunctions.in_array((XVar)(f.Value), (XVar)(searchFields)))) { appear = new XVar(true); } else { if (XVar.Pack(appearOnPageFunc)) { appear = XVar.Clone(this.pSetEdit.Invoke(appearOnPageFunc, (XVar)(f.Value))); } } if (XVar.Pack(appear)) { getControl((XVar)(f.Value)).addJSFiles(); getControl((XVar)(f.Value)).addCSSFiles(); } } return(null); }
public virtual XVar getOrderFields() { dynamic columns = XVar.Array(), groupByRet = XVar.Array(), ret = XVar.Array(), saved = XVar.Array(); ProjectSettings pSet; if (!XVar.Equals(XVar.Pack(this._cachedFields), XVar.Pack(null))) { return(this._cachedFields); } ret = XVar.Clone(XVar.Array()); columns = XVar.Clone(XVar.Array()); pSet = XVar.UnPackProjectSettings(this.pSet); saved = XVar.Clone(XSession.Session[MVCFunctions.Concat(this.sessionPrefix, "_orderby")]); if (0 != MVCFunctions.strlen((XVar)(saved["orderby"]))) { dynamic fields = XVar.Array(); fields = XVar.Clone(MVCFunctions.explode(new XVar(";"), (XVar)(saved["orderby"]))); foreach (KeyValuePair <XVar, dynamic> f in fields.GetEnumerator()) { dynamic dir = null, fieldName = null, goodField = null, index = null; dir = XVar.Clone(MVCFunctions.substr((XVar)(f.Value), new XVar(0), new XVar(1))); if ((XVar)(dir != "a") && (XVar)(dir != "d")) { continue; } goodField = XVar.Clone(MVCFunctions.substr((XVar)(f.Value), new XVar(1))); fieldName = XVar.Clone(pSet.getFieldByGoodFieldName((XVar)(goodField))); index = XVar.Clone(pSet.getFieldIndex((XVar)(fieldName))); if (XVar.Pack(!(XVar)(index))) { continue; } ret.InitAndSetArrayItem(new XVar("column", fieldName, "index", index, "expr", RunnerPage._getFieldSQLDecrypt((XVar)(fieldName), (XVar)(this.connection), (XVar)(this.pSet), (XVar)(this.cipherer)), "dir", (XVar.Pack(dir == "a") ? XVar.Pack("ASC") : XVar.Pack("DESC"))), null); columns.InitAndSetArrayItem(true, fieldName); } } else { if (0 != MVCFunctions.strlen((XVar)(saved["sortby"]))) { dynamic sortbySettings = XVar.Array(), var_option = XVar.Array(); sortbySettings = getSortBySettings(); var_option = XVar.Clone(sortbySettings[saved["sortby"] - 1]); if (XVar.Pack(var_option)) { foreach (KeyValuePair <XVar, dynamic> f in var_option["fields"].GetEnumerator()) { ret.InitAndSetArrayItem(new XVar("column", f.Value["field"], "index", pSet.getFieldIndex((XVar)(f.Value["field"])), "expr", RunnerPage._getFieldSQLDecrypt((XVar)(f.Value["field"]), (XVar)(this.connection), (XVar)(this.pSet), (XVar)(this.cipherer)), "dir", (XVar.Pack(f.Value["desc"]) ? XVar.Pack("DESC") : XVar.Pack("ASC"))), null); columns.InitAndSetArrayItem(true, f.Value["field"]); } } } else { dynamic orderInfo = XVar.Array(); orderInfo = XVar.Clone(pSet.getOrderIndexes()); foreach (KeyValuePair <XVar, dynamic> o in orderInfo.GetEnumerator()) { dynamic field = null; field = XVar.Clone(pSet.GetFieldByIndex((XVar)(o.Value[0]))); ret.InitAndSetArrayItem(new XVar("column", field, "index", o.Value[0], "expr", o.Value[2], "dir", o.Value[1]), null); columns.InitAndSetArrayItem(true, field); } } } foreach (KeyValuePair <XVar, dynamic> k in pSet.getTableKeys().GetEnumerator()) { if (XVar.Pack(columns.KeyExists(k.Value))) { continue; } ret.InitAndSetArrayItem(new XVar("column", k.Value, "index", pSet.getFieldIndex((XVar)(k.Value)), "expr", RunnerPage._getFieldSQLDecrypt((XVar)(k.Value), (XVar)(this.connection), (XVar)(this.pSet), (XVar)(this.cipherer)), "dir", "ASC", "hidden", true), null); } groupByRet = XVar.Clone(XVar.Array()); foreach (KeyValuePair <XVar, dynamic> grField in pSet.getGroupFields().GetEnumerator()) { dynamic grFieldPos = null; grFieldPos = XVar.Clone(-1); foreach (KeyValuePair <XVar, dynamic> of in ret.GetEnumerator()) { if (of.Value["column"] == grField.Value) { grFieldPos = XVar.Clone(of.Key); break; } } if (grFieldPos != -1) { groupByRet.InitAndSetArrayItem(ret[grFieldPos], null); ret.Remove(grFieldPos); } else { groupByRet.InitAndSetArrayItem(new XVar("column", grField.Value, "index", pSet.getFieldIndex((XVar)(grField.Value)), "expr", RunnerPage._getFieldSQLDecrypt((XVar)(grField.Value), (XVar)(this.connection), (XVar)(this.pSet), (XVar)(this.cipherer)), "dir", "ASC", "hidden", true), null); } } this._cachedFields = XVar.Clone(MVCFunctions.array_merge((XVar)(groupByRet), (XVar)(ret))); return(this._cachedFields); }