Server IP : 103.118.17.23 / Your IP : 216.73.216.169 Web Server : Microsoft-IIS/10.0 System : Windows NT RESELLERPLESK22 10.0 build 20348 (Windows Server 2016) AMD64 User : IWAM_plesk(default) ( 0) PHP Version : 7.4.33 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : E:/Inetpub/vhosts/mesa.org.in/httpdocs/panel/ |
Upload File : |
<%@ CodePage="65001" %> <% Response.Buffer = EW_RESPONSE_BUFFER %> <!--#include file="ewcfg.asp"--> <!--#include file="Homepage_Photosinfo.asp"--> <!--#include file="aspfn.asp"--> <!--#include file="userfn.asp"--> <% Call ew_Header(False, EW_CHARSET, False) %> <% ' Define page object Dim Homepage_Photos_edit Set Homepage_Photos_edit = New cHomepage_Photos_edit Set Page = Homepage_Photos_edit ' Page init processing Call Homepage_Photos_edit.Page_Init ' Page main Call Homepage_Photos_edit.Page_Main ' Global Page Rendering event (in userfn*.asp) Page_Rendering() ' Page Render event Homepage_Photos_edit.Page_Render() %> <!--#include file="header.asp"--> <script type="text/javascript"> // Form object var CurrentPageID = EW_PAGE_ID = "edit"; var CurrentForm = fHomepage_Photosedit = new ew_Form("fHomepage_Photosedit", "edit"); // Validate form fHomepage_Photosedit.Validate = function() { if (!this.ValidateRequired) return true; // Ignore validation var $ = jQuery, fobj = this.GetForm(), $fobj = $(fobj); if ($fobj.find("#a_confirm").val() == "F") return true; var elm, felm, uelm, addcnt = 0; var $k = $fobj.find("#" + this.FormKeyCountName); // Get key_count var rowcnt = ($k[0]) ? parseInt($k.val(), 10) : 1; var startcnt = (rowcnt == 0) ? 0 : 1; // Check rowcnt == 0 => Inline-Add var gridinsert = $fobj.find("#a_list").val() == "gridinsert"; for (var i = startcnt; i <= rowcnt; i++) { var infix = ($k[0]) ? String(i) : ""; $fobj.data("rowindex", infix); elm = this.GetElements("x" + infix + "_Enable"); if (elm && !ew_IsHidden(elm) && !ew_HasValue(elm)) return this.OnError(elm, "<%= ew_JsEncode2(Replace(Homepage_Photos.Enable.ReqErrMsg, "%s", Homepage_Photos.Enable.FldCaption)) %>"); elm = this.GetElements("x" + infix + "_Sequence"); if (elm && !ew_CheckInteger(elm.value)) return this.OnError(elm, "<%= ew_JsEncode2(Homepage_Photos.Sequence.FldErrMsg) %>"); // Fire Form_CustomValidate event if (!this.Form_CustomValidate(fobj)) return false; } // Process detail forms var dfs = $fobj.find("input[name='detailpage']").get(); for (var i = 0; i < dfs.length; i++) { var df = dfs[i], val = df.value; if (val && ewForms[val]) if (!ewForms[val].Validate()) return false; } return true; } // Form_CustomValidate event fHomepage_Photosedit.Form_CustomValidate = function(fobj) { // DO NOT CHANGE THIS LINE! // Your custom validation code here, return false if invalid. return true; } // Use JavaScript validation or not <% If EW_CLIENT_VALIDATE Then %> fHomepage_Photosedit.ValidateRequired = true; // Use JavaScript validation <% Else %> fHomepage_Photosedit.ValidateRequired = false; // No JavaScript validation <% End If %> // Dynamic selection lists fHomepage_Photosedit.Lists["x_Enable"] = {"LinkField":"","Ajax":null,"AutoFill":false,"DisplayFields":["","","",""],"ParentFields":[],"ChildFields":[],"FilterFields":[],"Options":[],"Template":""}; fHomepage_Photosedit.Lists["x_Enable"].Options = <%= ew_ArrayToJson(Homepage_Photos.Enable.Options(False)) %>; <% Set arAS = Nothing %> // Form object for search </script> <script type="text/javascript"> // Write your client script here, no need to add script tags. </script> <% Call Homepage_Photos_edit.ShowPageHeader %> <% Call Homepage_Photos_edit.ShowMessage %> <form name="fHomepage_Photosedit" id="fHomepage_Photosedit" class="<%= Homepage_Photos_edit.FormClassName %>" action="<%= ew_CurrentPage %>" method="post"> <% If Homepage_Photos_edit.CheckToken Then %> <input type="hidden" name="<%= EW_TOKEN_NAME %>" value="<%= Homepage_Photos_edit.Token %>"> <% End If %> <input type="hidden" name="a_table" id="a_table" value="Homepage_Photos"> <input type="hidden" name="a_edit" id="a_edit" value="U"> <input type="hidden" name="modal" value="<%= ew_IIf(Homepage_Photos_edit.IsModal, "1", "0") %>"> <div class="ewEditDiv"><!-- page* --> <% If Homepage_Photos.ID.Visible Then ' ID %> <div id="r_ID" class="form-group"> <label id="elh_Homepage_Photos_ID" class="<%= Homepage_Photos.LeftColumnClass %>"><%= Homepage_Photos.ID.FldCaption %></label> <div class="<%= Homepage_Photos.RightColumnClass %>"><div<%= Homepage_Photos.ID.CellAttributes %>> <span id="el_Homepage_Photos_ID"> <span<%= Homepage_Photos.ID.ViewAttributes %>> <p class="form-control-static"><%= Homepage_Photos.ID.EditValue %></p> </span> </span> <input type="hidden" data-table="Homepage_Photos" data-field="x_ID" name="x_ID" id="x_ID" value="<%= ew_HtmlEncode(Homepage_Photos.ID.CurrentValue&"") %>"> <%= Homepage_Photos.ID.CustomMsg %></div></div> </div> <% End If %> <% If Homepage_Photos.Photos.Visible Then ' Photos %> <div id="r_Photos" class="form-group"> <label id="elh_Homepage_Photos_Photos" class="<%= Homepage_Photos.LeftColumnClass %>"><%= Homepage_Photos.Photos.FldCaption %></label> <div class="<%= Homepage_Photos.RightColumnClass %>"><div<%= Homepage_Photos.Photos.CellAttributes %>> <div id="el_Homepage_Photos_Photos"> <div id="fd_x_Photos"> <span title="<%= ew_IIf(Homepage_Photos.Photos.FldTitle <> "", Homepage_Photos.Photos.FldTitle, Language.Phrase("ChooseFile")) %>" class="btn btn-default btn-sm fileinput-button ewTooltip<% If Homepage_Photos.Photos.ReadOnly Or Homepage_Photos.Photos.Disabled Then Response.Write " hide" %>" data-trigger="hover"> <span><%= Language.Phrase("ChooseFileBtn") %></span> <input type="file" title=" " data-table="Homepage_Photos" data-field="x_Photos" name="x_Photos" id="x_Photos"<%= Homepage_Photos.Photos.EditAttributes %>> </span> <input type="hidden" name="fn_x_Photos" id= "fn_x_Photos" value="<%= Homepage_Photos.Photos.Upload.FileName %>"> <% If Request.Form("fa_x_Photos") & "" = "0" Then %> <input type="hidden" name="fa_x_Photos" id= "fa_x_Photos" value="0"> <% Else %> <input type="hidden" name="fa_x_Photos" id= "fa_x_Photos" value="1"> <% End If %> <input type="hidden" name="fs_x_Photos" id= "fs_x_Photos" value="50"> <input type="hidden" name="fx_x_Photos" id= "fx_x_Photos" value="<%= Homepage_Photos.Photos.UploadAllowedFileExt %>"> <input type="hidden" name="fm_x_Photos" id= "fm_x_Photos" value="<%= Homepage_Photos.Photos.UploadMaxFileSize %>"> </div> <table id="ft_x_Photos" class="table table-condensed pull-left ewUploadTable"><tbody class="files"></tbody></table> </div> <%= Homepage_Photos.Photos.CustomMsg %></div></div> </div> <% End If %> <% If Homepage_Photos.Enable.Visible Then ' Enable %> <div id="r_Enable" class="form-group"> <label id="elh_Homepage_Photos_Enable" class="<%= Homepage_Photos.LeftColumnClass %>"><%= Homepage_Photos.Enable.FldCaption %><%= Language.Phrase("FieldRequiredIndicator") %></label> <div class="<%= Homepage_Photos.RightColumnClass %>"><div<%= Homepage_Photos.Enable.CellAttributes %>> <span id="el_Homepage_Photos_Enable"> <div id="tp_x_Enable" class="ewTemplate"><input type="radio" data-table="Homepage_Photos" data-field="x_Enable" data-value-separator="<%= Homepage_Photos.Enable.DisplayValueSeparatorAttribute %>" name="x_Enable" id="x_Enable" value="{value}"<%= Homepage_Photos.Enable.EditAttributes %>></div> <div id="dsl_x_Enable" data-repeatcolumn="5" class="ewItemList" style="display: none;"><div> <%= Homepage_Photos.Enable.RadioButtonListHtml(False, "x_Enable", -1, Homepage_Photos) %> </div></div> </span> <%= Homepage_Photos.Enable.CustomMsg %></div></div> </div> <% End If %> <% If Homepage_Photos.Title.Visible Then ' Title %> <div id="r_Title" class="form-group"> <label id="elh_Homepage_Photos_Title" for="x_Title" class="<%= Homepage_Photos.LeftColumnClass %>"><%= Homepage_Photos.Title.FldCaption %></label> <div class="<%= Homepage_Photos.RightColumnClass %>"><div<%= Homepage_Photos.Title.CellAttributes %>> <span id="el_Homepage_Photos_Title"> <input type="text" data-table="Homepage_Photos" data-field="x_Title" name="x_Title" id="x_Title" size="30" maxlength="255" placeholder="<%= Homepage_Photos.Title.PlaceHolder %>" value="<%= Homepage_Photos.Title.EditValue %>"<%= Homepage_Photos.Title.EditAttributes %>> </span> <%= Homepage_Photos.Title.CustomMsg %></div></div> </div> <% End If %> <% If Homepage_Photos.Sequence.Visible Then ' Sequence %> <div id="r_Sequence" class="form-group"> <label id="elh_Homepage_Photos_Sequence" for="x_Sequence" class="<%= Homepage_Photos.LeftColumnClass %>"><%= Homepage_Photos.Sequence.FldCaption %></label> <div class="<%= Homepage_Photos.RightColumnClass %>"><div<%= Homepage_Photos.Sequence.CellAttributes %>> <span id="el_Homepage_Photos_Sequence"> <input type="text" data-table="Homepage_Photos" data-field="x_Sequence" name="x_Sequence" id="x_Sequence" size="30" placeholder="<%= Homepage_Photos.Sequence.PlaceHolder %>" value="<%= Homepage_Photos.Sequence.EditValue %>"<%= Homepage_Photos.Sequence.EditAttributes %>> </span> <%= Homepage_Photos.Sequence.CustomMsg %></div></div> </div> <% End If %> </div><!-- /page* --> <% If Not Homepage_Photos_edit.IsModal Then %> <div class="form-group"><!-- buttons .form-group --> <div class="<%= Homepage_Photos.OffsetColumnClass %>"><!-- buttons offset --> <button class="btn btn-primary ewButton" name="btnAction" id="btnAction" type="submit"><%= Language.Phrase("SaveBtn") %></button> <button class="btn btn-default ewButton" name="btnCancel" id="btnCancel" type="button" data-href="<%= Homepage_Photos.ReturnUrl %>"><%= Language.Phrase("CancelBtn") %></button> </div><!-- /buttons offset --> </div><!-- /buttons .form-group --> <% End If %> </form> <script type="text/javascript"> fHomepage_Photosedit.Init(); </script> <% Call Homepage_Photos_edit.ShowPageFooter If EW_DEBUG_ENABLED Then Response.Write ew_DebugMsg() %> <script type="text/javascript"> // Write your table-specific startup script here // document.write("page loaded"); </script> <!--#include file="footer.asp"--> <% ' Clean up and drop page object Call Homepage_Photos_edit.Page_Terminate("") Set Homepage_Photos_edit = Nothing %> <% ' ' Page Class ' Class cHomepage_Photos_edit ' Page ID Public Property Get PageID PageID = "edit" End Property ' Project ID Public Property Get ProjectID ProjectID = "panel" End Property ' Table Name Public Property Get TableName TableName = "Homepage_Photos" End Property ' Page Object Name Public Property Get PageObjName PageObjName = "Homepage_Photos_edit" End Property ' Field (ID) Public Property Get ID Set ID = Homepage_Photos.ID End Property ' Field (Photos) Public Property Get Photos Set Photos = Homepage_Photos.Photos End Property ' Field (Date) Public Property Get zDate Set zDate = Homepage_Photos.zDate End Property ' Field (Enable) Public Property Get Enable Set Enable = Homepage_Photos.Enable End Property ' Field (Title) Public Property Get Title Set Title = Homepage_Photos.Title End Property ' Field (Sequence) Public Property Get Sequence Set Sequence = Homepage_Photos.Sequence End Property ' Get field object dictionary (ASP) Public Property Get Fields Set Fields = Homepage_Photos.Fields End Property ' Get field object by name (alias of Fields) (ASP) Public Function GetField(Name) Set GetField = Fields.Get(Name) End Function ' Get field object by parm (ASP) Public Function GetFieldByParm(Parm) Dim keys, key keys = Fields.Keys() For Each key In keys If Fields.Get(key).FldParm = Parm Then Set GetFieldByParm = Fields.Get(key) Exit Function End If Next Set GetFieldByParm = Nothing End Function ' Export document (ASP) Dim ExportDoc ' Page headings Dim Heading Dim Subheading ' Page heading Function PageHeading() PageHeading = "" If Heading <> "" Then PageHeading = Heading ElseIf ew_NotEmpty(Homepage_Photos) Then PageHeading = Homepage_Photos.TableCaption End If End Function ' Page subheading Function PageSubheading() If Subheading <> "" Then PageSubheading = Subheading Else PageSubheading = "" If TableName <> "" Then PageSubheading = Language.Phrase(PageID) End If End If End Function ' Page Name Public Property Get PageName PageName = ew_CurrentPage() End Property ' Page Url Public Property Get PageUrl PageUrl = ew_CurrentPage() & "?" If Homepage_Photos.UseTokenInUrl Then PageUrl = PageUrl & "t=" & Homepage_Photos.TableVar & "&" ' add page token End Property ' Message Public Property Get Message Message = Session(EW_SESSION_MESSAGE) End Property Public Property Let Message(v) Dim msg msg = Session(EW_SESSION_MESSAGE) Call ew_AddMessage(msg, v) Session(EW_SESSION_MESSAGE) = msg End Property Public Property Get FailureMessage FailureMessage = Session(EW_SESSION_FAILURE_MESSAGE) End Property Public Property Let FailureMessage(v) Dim msg msg = Session(EW_SESSION_FAILURE_MESSAGE) Call ew_AddMessage(msg, v) Session(EW_SESSION_FAILURE_MESSAGE) = msg End Property Public Property Get SuccessMessage SuccessMessage = Session(EW_SESSION_SUCCESS_MESSAGE) End Property Public Property Let SuccessMessage(v) Dim msg msg = Session(EW_SESSION_SUCCESS_MESSAGE) Call ew_AddMessage(msg, v) Session(EW_SESSION_SUCCESS_MESSAGE) = msg End Property Public Property Get WarningMessage WarningMessage = Session(EW_SESSION_WARNING_MESSAGE) End Property Public Property Let WarningMessage(v) Dim msg msg = Session(EW_SESSION_WARNING_MESSAGE) Call ew_AddMessage(msg, v) Session(EW_SESSION_WARNING_MESSAGE) = msg End Property ' Methods to clear message Public Sub ClearMessage() Session(EW_SESSION_MESSAGE) = "" End Sub Public Sub ClearFailureMessage() Session(EW_SESSION_FAILURE_MESSAGE) = "" End Sub Public Sub ClearSuccessMessage() Session(EW_SESSION_SUCCESS_MESSAGE) = "" End Sub Public Sub ClearWarningMessage() Session(EW_SESSION_WARNING_MESSAGE) = "" End Sub Public Sub ClearMessages() Session(EW_SESSION_MESSAGE) = "" Session(EW_SESSION_FAILURE_MESSAGE) = "" Session(EW_SESSION_SUCCESS_MESSAGE) = "" Session(EW_SESSION_WARNING_MESSAGE) = "" End Sub ' Show Message Public Sub ShowMessage() Dim hidden, html, sMessage hidden = False html = "" ' Message sMessage = Message Call Message_Showing(sMessage, "") If sMessage <> "" Then ' Message in Session, display If Not hidden Then sMessage = "<button type=""button"" class=""close"" data-dismiss=""alert"">×</button>" & sMessage html = html & "<div class=""alert alert-info ewInfo"">" & sMessage & "</div>" Session(EW_SESSION_MESSAGE) = "" ' Clear message in Session End If ' Warning message Dim sWarningMessage sWarningMessage = WarningMessage Call Message_Showing(sWarningMessage, "warning") If sWarningMessage <> "" Then ' Message in Session, display If Not hidden Then sWarningMessage = "<button type=""button"" class=""close"" data-dismiss=""alert"">×</button>" & sWarningMessage html = html & "<div class=""alert alert-warning ewWarning"">" & sWarningMessage & "</div>" Session(EW_SESSION_WARNING_MESSAGE) = "" ' Clear message in Session End If ' Success message Dim sSuccessMessage sSuccessMessage = SuccessMessage Call Message_Showing(sSuccessMessage, "success") If sSuccessMessage <> "" Then ' Message in Session, display If Not hidden Then sSuccessMessage = "<button type=""button"" class=""close"" data-dismiss=""alert"">×</button>" & sSuccessMessage html = html & "<div class=""alert alert-success ewSuccess"">" & sSuccessMessage & "</div>" Session(EW_SESSION_SUCCESS_MESSAGE) = "" ' Clear message in Session End If ' Failure message Dim sErrorMessage sErrorMessage = FailureMessage Call Message_Showing(sErrorMessage, "failure") If sErrorMessage <> "" Then ' Message in Session, display If Not hidden Then sErrorMessage = "<button type=""button"" class=""close"" data-dismiss=""alert"">×</button>" & sErrorMessage html = html & "<div class=""alert alert-danger ewError"">" & sErrorMessage & "</div>" Session(EW_SESSION_FAILURE_MESSAGE) = "" ' Clear message in Session End If Response.Write "<div class=""ewMessageDialog""" & ew_IIf(hidden, " style=""display: none;""", "") & ">" & html & "</div>" End Sub Dim PageHeader Dim PageFooter ' Show Page Header Public Sub ShowPageHeader() Dim sHeader sHeader = PageHeader Call Page_DataRendering(sHeader) If sHeader <> "" Then ' Header exists, display Response.Write "<p>" & sHeader & "</p>" End If End Sub ' Show Page Footer Public Sub ShowPageFooter() Dim sFooter sFooter = PageFooter Call Page_DataRendered(sFooter) If sFooter <> "" Then ' Footer exists, display Response.Write "<p>" & sFooter & "</p>" End If End Sub ' ' Validate Page request ' Public Function IsPageRequest() If Homepage_Photos.UseTokenInUrl Then IsPageRequest = False If ew_NotEmpty(ObjForm) Then IsPageRequest = (Homepage_Photos.TableVar = ObjForm.GetValue("t")) End If If Request.QueryString("t").Count > 0 Then IsPageRequest = (Homepage_Photos.TableVar = Request.QueryString("t")) End If Else IsPageRequest = True End If End Function Dim Token Dim CheckToken Dim TokenTimeout ' Valid Post Function ValidPost() If Not CheckToken Or Not ew_IsPost() Then ValidPost = True Exit Function End If If Request.Form(EW_TOKEN_NAME).Count = 0 Then ValidPost = False Exit Function End If ValidPost = ew_CheckToken(Request.Form(EW_TOKEN_NAME),TokenTimeout) End Function ' Create Token Sub CreateToken() If CheckToken And Token = "" Then Token = ew_CreateToken() gsToken = Token ' Save to global variable End If End Sub ' ' Class initialize ' Private Sub Class_Initialize() Session.LCID = 1033 ' Always use US locale id If IsEmpty(StartTimer) Then StartTimer = Timer ' Init start time ' Check Token Token = "" CheckToken = EW_CHECK_TOKEN TokenTimeout = 0 TokenTimeout = ew_SessionTimeoutTime() ' Initialize language object If IsEmpty(Language) Then Set Language = New cLanguage Call Language.LoadPhrases End If ' Initialize table object If IsEmpty(Homepage_Photos) Then Set Homepage_Photos = New cHomepage_Photos Set Table = Homepage_Photos ' Initialize URLs ' Initialize form object Set ObjForm = Nothing ' Get resize object Call ew_GetResizeObj ' Intialize page id (for backward compatibility) EW_PAGE_ID = "edit" ' Initialize table name (for backward compatibility) EW_TABLE_NAME = "Homepage_Photos" ' Debug message Call ew_LoadDebugMsg ' Open connection to the database If IsEmpty(Conn) Then Set Conn = ew_Connect(Homepage_Photos.TableDBID) End If End Sub ' ' Page_Init ' Sub Page_Init() ' Is modal IsModal = (Request.QueryString("modal") = "1" Or Request.Form("modal") = "1") ' User profile Set UserProfile = New cUserProfile ' Security Set Security = New cAdvancedSecurity If Not Security.IsLoggedIn() Then Security.AutoLogin() Call Security.LoadCurrentUserLevel(ProjectID & TableName) If Not Security.CanEdit Then Call Security.SaveLastUrl If Security.CanList Then Call Page_Terminate(ew_GetUrl("Homepage_Photoslist.asp")) Else Call Page_Terminate(ew_GetUrl("login.asp")) End If End If ' Create form object Set ObjForm = New cFormObj Homepage_Photos.CurrentAction = ew_IIf(Request.QueryString("a").Count > 0, Request.QueryString("a") & "", ObjForm.GetValue("a_list") & "") ' Set up current action Call Homepage_Photos.ID.SetVisibility(Homepage_Photos) If Homepage_Photos.IsAdd() Or Homepage_Photos.IsCopy() Or Homepage_Photos.IsGridAdd() Then Homepage_Photos.ID.Visible = False End If Call Homepage_Photos.Photos.SetVisibility(Homepage_Photos) Call Homepage_Photos.zDate.SetVisibility(Homepage_Photos) Call Homepage_Photos.Enable.SetVisibility(Homepage_Photos) Call Homepage_Photos.Title.SetVisibility(Homepage_Photos) Call Homepage_Photos.Sequence.SetVisibility(Homepage_Photos) ' Global page loading event (in userfn*.asp) Call Page_Loading ' Page load event, used in current page Call Page_Load ' Check token If Not ValidPost() Then Response.Write Language.Phrase("InvalidPostRequest") Call Page_Terminate("") Response.End End If ' Process auto fill Dim results If Request.Form("ajax") = "autofill" Then results = Homepage_Photos.GetAutoFill(Request.Form("name"), Request.Form("q")) If results <> "" Then ' Clean output buffer If Response.Buffer Then Response.Clear Response.Write results Call Page_Terminate("") Response.End End If End If ' Create Token Call CreateToken End Sub ' ' Page_Terminate ' Sub Page_Terminate(url) If Request.Form("customexport")&"" = "" Then ' Page unload event, used in current page Call Page_Unload ' Global page unloaded event (in userfn*.asp) Call Page_Unloaded End If ' Export If ew_NotEmpty(Homepage_Photos) Then If Homepage_Photos.Export <> "" And Request.Form("data").Count > 0 Then Dim sContent sContent = Request.Form("data") gsExportFile = Request.Form("filename") If gsExportFile = "" Then gsExportFile = Homepage_Photos.TableVar If Homepage_Photos.Export = "pdf" Then Call ExportPdf(sContent) ElseIf Homepage_Photos.Export = "email" Then Response.Write ExportEmail(sContent) ElseIf Homepage_Photos.Export = "excel" Then Call ExportExcel(sContent) ElseIf Homepage_Photos.Export = "word" Then Call ExportWord(sContent) End If End If End If Dim sRedirectUrl sRedirectUrl = url Call Page_Redirecting(sRedirectUrl) Call ew_CloseConn ' Close Connection Set Security = Nothing Set ObjForm = Nothing Set gResizeObj = Nothing ' Go to URL if specified If gsExport & "" = "" Then If sRedirectUrl <> "" Then If Response.Buffer Then Response.Clear ' Handle modal response If IsModal Then ' Show as modal Dim row, pageName Set row = Dictionary() Call row.Add("url", sRedirectURL) Call row.Add("modal", "1") pageName = ew_GetPageName(sRedirectURL) If pageName <> Homepage_Photos.ListUrl Then ' Not List page Call row.Add("caption", Homepage_Photos.GetModalCaption(pageName)) If pageName = "Homepage_Photosview.asp" Then Call row.Add("view", "1") End If Else 'List page should not be shown as modal => error Call row.Add("error", FailureMessage) Call ClearFailureMessage End If Call ResponseJson Response.Write "[" & row.ToJson() & "]" Set row = Nothing Response.End Else Call ew_SaveDebugMsg Response.Redirect sRedirectUrl End If End If End If Set Homepage_Photos = Nothing Call ew_CleanUp End Sub ' ' Page_Terminate (End) ' Dim DbMasterFilter, DbDetailFilter Dim FormClassName Dim IsModal Dim IsMobileOrModal Dim DisplayRecs Dim StartRec, StopRec, TotalRecs, RecRange Dim AutoHidePager Dim RecCnt Dim Recordset ' ' Page main ' Sub Page_Main() Dim sReturnUrl sReturnUrl = "" ' Check modal If IsModal Then gbSkipHeaderFooter = True IsMobileOrModal = False IsMobileOrModal = ew_IsMobile() Or IsModal FormClassName = "ewForm ewEditForm form-horizontal" Dim loaded, postBack sReturnUrl = "" loaded = False postBack = False ' Set up current action and primary key If ObjForm.GetValue("a_edit")&"" <> "" Then Homepage_Photos.CurrentAction = ObjForm.GetValue("a_edit")&"" ' Get action code If Homepage_Photos.CurrentAction <> "I" Then ' Not reload record, handle as postback postBack = True End If ' Load key from Form If ObjForm.HasValue("x_ID") Then Homepage_Photos.ID.FormValue = ObjForm.GetValue("x_ID") End If Else Homepage_Photos.CurrentAction = "I" ' Default action is display ' Load key from QueryString Dim loadByQuery loadByQuery = False If Request.QueryString("ID").Count > 0 Then Homepage_Photos.ID.QueryStringValue = Request.QueryString("ID") loadByQuery = True Else Homepage_Photos.ID.CurrentValue = Null End If End If ' Load current record loaded = LoadRow() ' Process form if post back If postBack Then Call LoadFormValues ' Get form values End If ' Validate form if post back If postBack Then If Not ValidateForm() Then Homepage_Photos.CurrentAction = "" ' Form error, reset action FailureMessage = gsFormError Homepage_Photos.EventCancelled = True ' Event cancelled LoadRow() ' Restore row Call RestoreFormValues ' Restore form values if validate failed End If End If ' Perform current action Select Case Homepage_Photos.CurrentAction Case "I" ' Get a record to display If Not loaded Then ' Load Record based on key If FailureMessage = "" Then FailureMessage = Language.Phrase("NoRecord") ' No record found Call Page_Terminate("Homepage_Photoslist.asp") ' No matching record, return to list End If Case "U" ' Update sReturnUrl = Homepage_Photos.ReturnUrl If ew_GetPageName(sReturnUrl) = "Homepage_Photoslist.asp" Then sReturnUrl = Homepage_Photos.AddMasterUrl(sReturnUrl) ' List page, return to List page with correct master key if necessary End If Homepage_Photos.SendEmail = True ' Send email on update success If EditRow() Then ' Update Record based on key If SuccessMessage = "" Then SuccessMessage = Language.Phrase("UpdateSuccess") ' Update success End If Call Page_Terminate(sReturnUrl) ' Return to caller ElseIf FailureMessage = Language.Phrase("NoRecord") Then Call Page_Terminate(sReturnUrl) ' Return to caller Else Homepage_Photos.EventCancelled = True ' Event cancelled LoadRow() ' Restore row Call RestoreFormValues ' Restore form values if update failed End If End Select ' Render the record Homepage_Photos.RowType = EW_ROWTYPE_EDIT ' Render as edit ' Set up Breadcrumb Call SetupBreadcrumb ' Render row Call Homepage_Photos.ResetAttrs Call RenderRow End Sub Dim Pager ' ' Set up Starting Record parameters based on Pager Navigation ' Sub SetupStartRec() Dim PageNo ' Exit if DisplayRecs = 0 If DisplayRecs = 0 Then Exit Sub If IsPageRequest Then ' Validate request ' Check for a START parameter If Request.QueryString(EW_TABLE_START_REC).Count > 0 Then StartRec = Request.QueryString(EW_TABLE_START_REC) Homepage_Photos.StartRecordNumber = StartRec ElseIf Request.QueryString(EW_TABLE_PAGE_NO).Count > 0 Then PageNo = Request.QueryString(EW_TABLE_PAGE_NO) If IsNumeric(PageNo) Then StartRec = (PageNo-1)*DisplayRecs+1 If StartRec <= 0 Then StartRec = 1 ElseIf StartRec >= ((TotalRecs-1)\DisplayRecs)*DisplayRecs+1 Then StartRec = ((TotalRecs-1)\DisplayRecs)*DisplayRecs+1 End If Homepage_Photos.StartRecordNumber = StartRec End If End If End If StartRec = Homepage_Photos.StartRecordNumber ' Check if correct start record counter If Not IsNumeric(StartRec) Or StartRec = "" Then ' Avoid invalid start record counter StartRec = 1 ' Reset start record counter Homepage_Photos.StartRecordNumber = StartRec ElseIf CLng(StartRec) > CLng(TotalRecs) Then ' Avoid starting record > total records StartRec = ((TotalRecs-1)\DisplayRecs)*DisplayRecs+1 ' Point to last page first record Homepage_Photos.StartRecordNumber = StartRec ElseIf (StartRec-1) Mod DisplayRecs <> 0 Then StartRec = ((StartRec-1)\DisplayRecs)*DisplayRecs+1 ' Point to page boundary Homepage_Photos.StartRecordNumber = StartRec End If End Sub ' ' Get upload files ' Sub GetUploadFiles() ' Get upload data Homepage_Photos.Photos.Upload.Index = ObjForm.Index Homepage_Photos.Photos.Upload.UploadFile() Homepage_Photos.Photos.CurrentValue = Homepage_Photos.Photos.Upload.FileName End Sub ' ' Load form values ' Sub LoadFormValues() ' Load values from form Call GetUploadFiles ' Get upload files If Not Homepage_Photos.ID.FldIsDetailKey Then Homepage_Photos.ID.FormValue = ObjForm.GetValue("x_ID") If Not Homepage_Photos.zDate.FldIsDetailKey Then Homepage_Photos.zDate.FormValue = ObjForm.GetValue("x_zDate") If Not Homepage_Photos.zDate.FldIsDetailKey Then Homepage_Photos.zDate.CurrentValue = ew_UnFormatDateTime(Homepage_Photos.zDate.CurrentValue, 0) If Not Homepage_Photos.Enable.FldIsDetailKey Then Homepage_Photos.Enable.FormValue = ObjForm.GetValue("x_Enable") If Not Homepage_Photos.Title.FldIsDetailKey Then Homepage_Photos.Title.FormValue = ObjForm.GetValue("x_Title") If Not Homepage_Photos.Sequence.FldIsDetailKey Then Homepage_Photos.Sequence.FormValue = ObjForm.GetValue("x_Sequence") End Sub ' ' Restore form values ' Sub RestoreFormValues() Homepage_Photos.ID.CurrentValue = Homepage_Photos.ID.FormValue Homepage_Photos.zDate.CurrentValue = Homepage_Photos.zDate.FormValue Homepage_Photos.zDate.CurrentValue = ew_UnFormatDateTime(Homepage_Photos.zDate.CurrentValue, 0) Homepage_Photos.Enable.CurrentValue = Homepage_Photos.Enable.FormValue Homepage_Photos.Title.CurrentValue = Homepage_Photos.Title.FormValue Homepage_Photos.Sequence.CurrentValue = Homepage_Photos.Sequence.FormValue End Sub ' ' Load row based on key values ' Function LoadRow() Dim RsRow, sSql, sFilter sFilter = Homepage_Photos.KeyFilter ' Call Row Selecting event Call Homepage_Photos.Row_Selecting(sFilter) ' Load SQL based on filter Homepage_Photos.CurrentFilter = sFilter sSql = Homepage_Photos.SQL Call ew_SetDebugMsg("LoadRow: " & sSql) ' Show SQL for debugging Set RsRow = ew_LoadRowByDbid(sSql, Homepage_Photos.TableDBID) If RsRow.EOF Then LoadRow = False Else LoadRow = True RsRow.MoveFirst Call LoadRowValues(RsRow) ' Load row values End If RsRow.Close Set RsRow = Nothing End Function ' ' Load row values from recordset ' Sub LoadRowValues(RsRow) Dim sDetailFilter If Not EW_DEBUG_ENABLED Then On Error Resume Next If IsNull(RsRow) Then Set RsRow = NewRow() End If ' Call Row Selected event Call Homepage_Photos.Row_Selected(RsRow) If ew_Empty(RsRow) Then Exit Sub If RsRow.EOF Then Exit Sub Homepage_Photos.ID.DbValue = RsRow("ID") Homepage_Photos.Photos.Upload.DbValue = RsRow("Photos") Homepage_Photos.Photos.DbValue = Homepage_Photos.Photos.Upload.DbValue Homepage_Photos.zDate.DbValue = RsRow("Date") Homepage_Photos.Enable.DbValue = RsRow("Enable") Homepage_Photos.Title.DbValue = RsRow("Title") Homepage_Photos.Sequence.DbValue = RsRow("Sequence") End Sub ' Return a row with default values Function NewRow Dim cnn, rs, sSql, sFilter ' Clear any previous errors Err.Clear Set cnn = Homepage_Photos.TableConnection sFilter = Homepage_Photos.CurrentFilter Homepage_Photos.CurrentFilter = "(0 = 1)" sSql = Homepage_Photos.SQL Homepage_Photos.CurrentFilter = sFilter Set rs = Server.CreateObject("ADODB.Recordset") rs.CursorLocation = 3 ' adUseClient Call ew_SetDebugMsg("NewRow: " & sSql) ' Show SQL for debugging rs.Open sSql, cnn, 3, 4 ' adOpenStatic, adLockBatchOptimistic ' Disconnect the Recordset Set rs.ActiveConnection = Nothing ' Add new record rs.AddNew rs("Photos") = Null rs("Date") = Null rs("Enable") = Null rs("Title") = Null rs("Sequence") = Null ' Return the recordset If Err.Number = 0 Then Set NewRow = rs Else Set NewRow = Nothing End If End Function ' Load DbValue from recordset Sub LoadDbValues(Rs) If Not EW_DEBUG_ENABLED Then On Error Resume Next If ew_Empty(Rs) Then Exit Sub If Rs.EOF Then Exit Sub Homepage_Photos.ID.m_DbValue = Rs("ID") Homepage_Photos.Photos.Upload.DbValue = Rs("Photos") Homepage_Photos.zDate.m_DbValue = Rs("Date") Homepage_Photos.Enable.m_DbValue = Rs("Enable") Homepage_Photos.Title.m_DbValue = Rs("Title") Homepage_Photos.Sequence.m_DbValue = Rs("Sequence") End Sub ' Load old record Function LoadOldRecord() ' Load key values from Session Dim bValidKey bValidKey = True If Homepage_Photos.GetKey("ID")&"" <> "" Then Homepage_Photos.ID.CurrentValue = Homepage_Photos.GetKey("ID") ' ID Else bValidKey = False End If ' Load old record OldRecordset = Null If bValidKey Then Homepage_Photos.CurrentFilter = Homepage_Photos.KeyFilter Dim sSql sSql = Homepage_Photos.SQL Set OldRecordset = ew_LoadRecordsetByDbid(sSql, Homepage_Photos.TableDBID) End If Call LoadRowValues(OldRecordset) ' Load row values LoadOldRecord = bValidKey End Function ' ' Render row values based on field settings ' Sub RenderRow() ' Initialize URLs ' Call Row Rendering event Call Homepage_Photos.Row_Rendering ' ' Common render codes for all row types ' ' ID ' Photos ' Date ' Enable ' Title ' Sequence ' ' View Row ' If Homepage_Photos.RowType = EW_ROWTYPE_VIEW Then ' View row ' ID Homepage_Photos.ID.ViewValue = Homepage_Photos.ID.CurrentValue Homepage_Photos.ID.ViewCustomAttributes = "" ' Photos Homepage_Photos.Photos.UploadPath = "../uploads/homepage" If Not ew_Empty(Homepage_Photos.Photos.Upload.DbValue) Then Homepage_Photos.Photos.ViewValue = Homepage_Photos.Photos.Upload.DbValue Homepage_Photos.Photos.ViewValue = Homepage_Photos.Photos.Upload.DbValue Else Homepage_Photos.Photos.ViewValue = "" End If Homepage_Photos.Photos.ViewCustomAttributes = "" ' Date Homepage_Photos.zDate.ViewValue = Homepage_Photos.zDate.CurrentValue Homepage_Photos.zDate.ViewValue = ew_FormatDateTime(Homepage_Photos.zDate.ViewValue, 0) Homepage_Photos.zDate.ViewCustomAttributes = "" ' Enable If Not IsNull(Homepage_Photos.Enable.CurrentValue) Then Homepage_Photos.Enable.ViewValue = Homepage_Photos.Enable.OptionCaption(Homepage_Photos.Enable.CurrentValue) Else Homepage_Photos.Enable.ViewValue = Null End If Homepage_Photos.Enable.ViewCustomAttributes = "" ' Title Homepage_Photos.Title.ViewValue = Homepage_Photos.Title.CurrentValue Homepage_Photos.Title.ViewCustomAttributes = "" ' Sequence Homepage_Photos.Sequence.ViewValue = Homepage_Photos.Sequence.CurrentValue Homepage_Photos.Sequence.ViewCustomAttributes = "" ' View refer script ' ID Homepage_Photos.ID.LinkCustomAttributes = "" Homepage_Photos.ID.HrefValue = "" Homepage_Photos.ID.TooltipValue = "" ' Photos Homepage_Photos.Photos.LinkCustomAttributes = "" Homepage_Photos.Photos.HrefValue = "" Homepage_Photos.Photos.HrefValue2 = Homepage_Photos.Photos.UploadPath & Homepage_Photos.Photos.Upload.DbValue Homepage_Photos.Photos.TooltipValue = "" ' Date Homepage_Photos.zDate.LinkCustomAttributes = "" Homepage_Photos.zDate.HrefValue = "" Homepage_Photos.zDate.TooltipValue = "" ' Enable Homepage_Photos.Enable.LinkCustomAttributes = "" Homepage_Photos.Enable.HrefValue = "" Homepage_Photos.Enable.TooltipValue = "" ' Title Homepage_Photos.Title.LinkCustomAttributes = "" Homepage_Photos.Title.HrefValue = "" Homepage_Photos.Title.TooltipValue = "" ' Sequence Homepage_Photos.Sequence.LinkCustomAttributes = "" Homepage_Photos.Sequence.HrefValue = "" Homepage_Photos.Sequence.TooltipValue = "" ' ' Edit Row ' ElseIf Homepage_Photos.RowType = EW_ROWTYPE_EDIT Then ' Edit row ' ID Call Homepage_Photos.ID.EditAttrs.UpdateAttribute("class", "form-control") Homepage_Photos.ID.EditCustomAttributes = "" Homepage_Photos.ID.EditValue = Homepage_Photos.ID.CurrentValue Homepage_Photos.ID.ViewCustomAttributes = "" ' Photos Call Homepage_Photos.Photos.EditAttrs.UpdateAttribute("class", "form-control") Homepage_Photos.Photos.EditCustomAttributes = "" Homepage_Photos.Photos.UploadPath = "../uploads/homepage" If Not ew_Empty(Homepage_Photos.Photos.Upload.DbValue) Then Homepage_Photos.Photos.EditValue = Homepage_Photos.Photos.Upload.DbValue Homepage_Photos.Photos.EditValue = Homepage_Photos.Photos.Upload.DbValue Else Homepage_Photos.Photos.EditValue = "" End If If Homepage_Photos.CurrentAction = "I" And Not Homepage_Photos.EventCancelled Then Call ew_RenderUploadField(Homepage_Photos.Photos, -1) ' Date ' Enable Homepage_Photos.Enable.EditCustomAttributes = "" Homepage_Photos.Enable.EditValue = Homepage_Photos.Enable.Options(False) ' Title Call Homepage_Photos.Title.EditAttrs.UpdateAttribute("class", "form-control") Homepage_Photos.Title.EditCustomAttributes = "" Homepage_Photos.Title.EditValue = ew_HtmlEncode(Homepage_Photos.Title.CurrentValue) Homepage_Photos.Title.PlaceHolder = ew_HtmlEncode(ew_RemoveHtml(Homepage_Photos.Title.FldCaption)) ' Sequence Call Homepage_Photos.Sequence.EditAttrs.UpdateAttribute("class", "form-control") Homepage_Photos.Sequence.EditCustomAttributes = "" Homepage_Photos.Sequence.EditValue = ew_HtmlEncode(Homepage_Photos.Sequence.CurrentValue) Homepage_Photos.Sequence.PlaceHolder = ew_HtmlEncode(ew_RemoveHtml(Homepage_Photos.Sequence.FldCaption)) ' Edit refer script ' ID Homepage_Photos.ID.LinkCustomAttributes = "" Homepage_Photos.ID.HrefValue = "" ' Photos Homepage_Photos.Photos.LinkCustomAttributes = "" Homepage_Photos.Photos.HrefValue = "" Homepage_Photos.Photos.HrefValue2 = Homepage_Photos.Photos.UploadPath & Homepage_Photos.Photos.Upload.DbValue ' Date Homepage_Photos.zDate.LinkCustomAttributes = "" Homepage_Photos.zDate.HrefValue = "" ' Enable Homepage_Photos.Enable.LinkCustomAttributes = "" Homepage_Photos.Enable.HrefValue = "" ' Title Homepage_Photos.Title.LinkCustomAttributes = "" Homepage_Photos.Title.HrefValue = "" ' Sequence Homepage_Photos.Sequence.LinkCustomAttributes = "" Homepage_Photos.Sequence.HrefValue = "" End If If Homepage_Photos.RowType = EW_ROWTYPE_ADD Or Homepage_Photos.RowType = EW_ROWTYPE_EDIT Or Homepage_Photos.RowType = EW_ROWTYPE_SEARCH Then ' Add/Edit/Search row Call Homepage_Photos.SetupFieldTitles End If ' Call Row Rendered event If Homepage_Photos.RowType <> EW_ROWTYPE_AGGREGATEINIT Then Call Homepage_Photos.Row_Rendered End If End Sub ' ' Validate form ' Function ValidateForm() ' Initialize gsFormError = "" ' Check if validation required If Not EW_SERVER_VALIDATE Then ValidateForm = (gsFormError = "") Exit Function End If If Homepage_Photos.Enable.FormValue&"" = "" Then Call ew_AddMessage(gsFormError, Replace(Homepage_Photos.Enable.ReqErrMsg, "%s", Homepage_Photos.Enable.FldCaption)) End If If Not ew_CheckInteger(Homepage_Photos.Sequence.FormValue) Then Call ew_AddMessage(gsFormError, Homepage_Photos.Sequence.FldErrMsg) End If ' Return validate result ValidateForm = (gsFormError = "") ' Call Form Custom Validate event Dim sFormCustomError sFormCustomError = "" ValidateForm = ValidateForm And Form_CustomValidate(sFormCustomError) If sFormCustomError <> "" Then Call ew_AddMessage(gsFormError, sFormCustomError) End If End Function ' ' Update record based on key values ' Function EditRow() If Not EW_DEBUG_ENABLED Then On Error Resume Next Dim cnn, Rs, sSql, sFilter Dim RsChk, sSqlChk, sFilterChk Dim bUpdateRow Dim RsOld, RsNew Dim sIdxErrMsg ' Clear any previous errors Err.Clear sFilter = Homepage_Photos.KeyFilter Set cnn = Homepage_Photos.TableConnection Homepage_Photos.CurrentFilter = sFilter sSql = Homepage_Photos.UpdateTableSQL Set Rs = Server.CreateObject("ADODB.Recordset") Rs.CursorLocation = Homepage_Photos.TableCursorLocation Call ew_SetDebugMsg("EditRow: " & sSql) ' Show SQL for debugging Rs.Open sSql, cnn, 1, Homepage_Photos.TableRecordsetLockType If Err.Number <> 0 Then Message = Err.Description Rs.Close Set Rs = Nothing EditRow = False Exit Function End If ' Clone old recordset object Set RsOld = ew_CloneRs(Rs) Call LoadDbValues(RsOld) Homepage_Photos.Photos.OldUploadPath = "../uploads/homepage" Homepage_Photos.Photos.UploadPath = Homepage_Photos.Photos.OldUploadPath If Rs.EOF Then FailureMessage = Language.Phrase("NoRecord") ' Set no record message EditRow = False ' Update Failed Else ' Field Photos If Homepage_Photos.Photos.Visible And Not Homepage_Photos.Photos.ReadOnly And Not Homepage_Photos.Photos.Upload.KeepFile Then Homepage_Photos.Photos.Upload.DbValue = Rs("Photos") ' Get original value If Homepage_Photos.Photos.Upload.FileName & "" = "" Then Rs("Photos") = Null Else Rs("Photos") = Homepage_Photos.Photos.Upload.FileName End If End If ' Field Date Call Homepage_Photos.zDate.SetDbValue(Rs, ew_CurrentDate, Null, False) ' Field Enable Call Homepage_Photos.Enable.SetDbValue(Rs, Homepage_Photos.Enable.CurrentValue, Null, Homepage_Photos.Enable.ReadOnly) ' Field Title Call Homepage_Photos.Title.SetDbValue(Rs, Homepage_Photos.Title.CurrentValue, Null, Homepage_Photos.Title.ReadOnly) ' Field Sequence Call Homepage_Photos.Sequence.SetDbValue(Rs, Homepage_Photos.Sequence.CurrentValue, Null, Homepage_Photos.Sequence.ReadOnly) ' Check recordset update error If Err.Number <> 0 Then FailureMessage = Err.Description Rs.Close Set Rs = Nothing EditRow = False Exit Function End If If Homepage_Photos.Photos.Visible And Not Homepage_Photos.Photos.Upload.KeepFile Then Homepage_Photos.Photos.UploadPath = "../uploads/homepage" TmpOldFiles = ew_IIf(ew_Empty(Homepage_Photos.Photos.Upload.DbValue), Array(), Array(Homepage_Photos.Photos.Upload.DbValue)) If Not ew_Empty(Homepage_Photos.Photos.Upload.FileName) Then TmpNewFiles = Array(Homepage_Photos.Photos.Upload.FileName) TmpNewFileCount = UBound(TmpNewFiles) + 1 For i = 0 to TmpNewFileCount - 1 TmpFldVar = ew_IIf(Homepage_Photos.Photos.Upload.Index < 0, Homepage_Photos.Photos.FldVar, Mid(Homepage_Photos.Photos.FldVar, 1, 1) & Homepage_Photos.Photos.Upload.Index & Mid(Homepage_Photos.Photos.FldVar, 2)) If TmpNewFiles(i) <> "" Then If ew_FileExists(ew_UploadTempPath(TmpFldVar, Homepage_Photos.Photos.TblVar), TmpNewFiles(i)) Then TmpFile = TmpNewFiles(i) OldFileFound = False TmpOldFileCount = UBound(TmpOldFiles) + 1 For j = 0 to TmpOldFileCount - 1 If TmpOldFiles(j) = TmpFile Then ' Old file found, no need to delete anymore TmpOldFiles = ew_ArrayDiff(TmpOldFiles, Array(TmpFile)) ' ASP OldFileFound = True Exit For End If Next If Not OldFileFound Then TmpFile1 = ew_UploadFileNameEx(Homepage_Photos.Photos.PhysicalUploadPath, TmpFile) ' Get new file name If TmpFile1 <> TmpFile Then Do While ew_FileExists(ew_UploadTempPath(TmpFldVar, Homepage_Photos.Photos.TblVar), TmpFile1) Or ew_FileExists(Homepage_Photos.Photos.PhysicalUploadPath, TmpFile1) ' Make sure no file name clash TmpFile1 = ew_UniqueFilename(Homepage_Photos.Photos.PhysicalUploadPath, TmpFile1, True) ' Use indexed name Loop Call ew_RenameFile(ew_UploadTempPath(TmpFldVar, Homepage_Photos.Photos.TblVar) & TmpFile, ew_UploadTempPath(TmpFldVar, Homepage_Photos.Photos.TblVar) & TmpFile1) ' Rename temp file TmpNewFiles(i) = TmpFile1 ' Update new file name End If End If End If End If Next If ew_Empty(TmpOldFiles) Then Homepage_Photos.Photos.Upload.DbValue = "" Else Homepage_Photos.Photos.Upload.DbValue = Join(TmpOldFiles, EW_MULTIPLE_UPLOAD_SEPARATOR) End If Homepage_Photos.Photos.Upload.FileName = Join(TmpNewFiles, EW_MULTIPLE_UPLOAD_SEPARATOR) Call Homepage_Photos.Photos.SetDbValue(Rs, Homepage_Photos.Photos.Upload.FileName, Null, Homepage_Photos.Photos.ReadOnly) End If End If ' Call Row Updating event bUpdateRow = Homepage_Photos.Row_Updating(RsOld, Rs) If bUpdateRow Then ' Clone new recordset object Set RsNew = ew_CloneRs(Rs) EditRow = True If EditRow Then Call ew_SetDebugMsg("Update: " & ew_HtmlEncode(ew_RecordToJson(Rs))) ' Show data for debugging Rs.Update End If If Err.Number <> 0 Or Not EditRow Then If Err.Description <> "" Then FailureMessage = Err.Description EditRow = False Else EditRow = True End If If EditRow Then If Homepage_Photos.Photos.Visible And Not Homepage_Photos.Photos.Upload.KeepFile Then TmpOldFiles = ew_IIf(ew_Empty(Homepage_Photos.Photos.Upload.DbValue), Array(), Array(Homepage_Photos.Photos.Upload.DbValue)) If Not ew_Empty(Homepage_Photos.Photos.Upload.FileName) Then TmpNewFiles = Array(Homepage_Photos.Photos.Upload.FileName) TmpNewFiles2 = Array(Rs("Photos")) TmpNewFileCount = UBound(TmpNewFiles) + 1 For i = 0 to TmpNewFileCount - 1 TmpFldVar = ew_IIf(Homepage_Photos.Photos.Upload.Index < 0, Homepage_Photos.Photos.FldVar, Mid(Homepage_Photos.Photos.FldVar, 1, 1) & Homepage_Photos.Photos.Upload.Index & Mid(Homepage_Photos.Photos.FldVar, 2)) If TmpNewFiles(i) <> "" Then If ew_FileExists(ew_UploadTempPath(TmpFldVar, Homepage_Photos.Photos.TblVar), TmpNewFiles(i)) Then TmpFile = ew_UploadTempPath(TmpFldVar, Homepage_Photos.Photos.TblVar) & TmpNewFiles(i) Homepage_Photos.Photos.Upload.Value = ew_LoadBinaryFile(TmpFile) If UBound(TmpNewFiles2) >= i Then If TmpNewFiles2(i) <> "" Then ' Use correct file name TmpNewFiles(i) = TmpNewFiles2(i) End If End If TmpFile = TmpNewFiles(i) If Not Homepage_Photos.Photos.Upload.SaveToFile(TmpFile, True) Then FailureMessage = Language.Phrase("UploadErrMsg7") End If End If End If Next Else TmpNewFiles = Array() End If TmpOldFileCount = UBound(TmpOldFiles) + 1 For i = 0 to TmpOldFileCount - 1 If TmpOldFiles(i) <> "" And Not ew_InArray(TmpOldFiles(i), TmpNewFiles) Then Call ew_DeleteFile(Homepage_Photos.Photos.OldPhysicalUploadPath & TmpOldFiles(i)) End If Next End If End If Else Rs.CancelUpdate ' Set up error message If SuccessMessage <> "" Or FailureMessage <> "" Then ' Use the message, do nothing ElseIf Homepage_Photos.CancelMessage <> "" Then FailureMessage = Homepage_Photos.CancelMessage Homepage_Photos.CancelMessage = "" Else FailureMessage = Language.Phrase("UpdateCancelled") End If EditRow = False End If End If ' Call Row_Updated event If EditRow Then Call Homepage_Photos.Row_Updated(RsOld, RsNew) End If Rs.Close Set Rs = Nothing ' Photos Call ew_CleanUploadTempPath(Homepage_Photos.Photos, Homepage_Photos.Photos.Upload.Index) If ew_NotEmpty(RsOld) Then RsOld.Close Set RsOld = Nothing End If If ew_NotEmpty(RsNew) Then RsNew.Close Set RsNew = Nothing End If End Function ' Set up Breadcrumb Sub SetupBreadcrumb() Dim PageId, url Set Breadcrumb = New cBreadcrumb url = Mid(ew_CurrentUrl(), InStrRev(ew_CurrentUrl(), "/") + 1) Call Breadcrumb.Add("list", Homepage_Photos.TableVar, Homepage_Photos.AddMasterUrl("Homepage_Photoslist.asp"), "", Homepage_Photos.TableVar, True) PageId = "edit" Call Breadcrumb.Add("edit", PageId, url, "", "", False) End Sub ' Setup lookup filters of a field Sub SetupLookupFilters(fld, pageId) pageId = ew_IIf(ew_EmptyStr(pageId), Homepage_Photos_edit.PageID, pageId) Select Case fld.FldVar End Select End Sub ' Setup AutoSuggest filters of a field Sub SetupAutoSuggestFilters(fld, pageId) pageId = ew_IIF(ew_EmptyStr(pageId), Homepage_Photos_edit.PageID, pageId) Select Case fld.FldVar End Select End Sub ' Page Load event Sub Page_Load() 'Response.Write "Page Load" End Sub ' Page Unload event Sub Page_Unload() 'Response.Write "Page Unload" End Sub ' Page Redirecting event Sub Page_Redirecting(url) 'url = newurl End Sub ' Message Showing event ' typ = ""|"success"|"failure"|"warning" Sub Message_Showing(msg, typ) ' Example: 'If typ = "success" Then ' msg = "your success message" 'ElseIf typ = "failure" Then ' msg = "your failure message" 'ElseIf typ = "warning" Then ' msg = "your warning message" 'Else ' msg = "your message" 'End If End Sub ' Page Render event Sub Page_Render() 'Response.Write "Page Render" End Sub ' Page Data Rendering event Sub Page_DataRendering(header) ' Example: 'header = "your header" End Sub ' Page Data Rendered event Sub Page_DataRendered(footer) ' Example: 'footer = "your footer" End Sub ' Form Custom Validate event Function Form_CustomValidate(CustomError) 'Return error message in CustomError Form_CustomValidate = True End Function End Class %>