Your IP : 216.73.217.79


Current Path : /var/www/cesa.co.za/cceadmin/
Upload File :
Current File : /var/www/cesa.co.za/cceadmin/cstArchivedGalleryedit.php

<?php
session_start(); // Initialize Session data
ob_start(); // Turn on output buffering
?>
<?php include "ewcfg7.php" ?>
<?php include "ewmysql7.php" ?>
<?php include "phpfn7.php" ?>
<?php include "cstArchivedGalleryinfo.php" ?>
<?php include "CCEUsersinfo.php" ?>
<?php include "userfn7.php" ?>
<?php
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // Date in the past
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); // Always modified
header("Cache-Control: private, no-store, no-cache, must-revalidate"); // HTTP/1.1 
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache"); // HTTP/1.0
?>
<?php

// Create page object
$cstArchivedGallery_edit = new ccstArchivedGallery_edit();
$Page =& $cstArchivedGallery_edit;

// Page init
$cstArchivedGallery_edit->Page_Init();

// Page main
$cstArchivedGallery_edit->Page_Main();
?>
<?php include "header.php" ?>
<script type="text/javascript">
<!--

// Create page object
var cstArchivedGallery_edit = new ew_Page("cstArchivedGallery_edit");

// page properties
cstArchivedGallery_edit.PageID = "edit"; // page ID
cstArchivedGallery_edit.FormID = "fcstArchivedGalleryedit"; // form ID
var EW_PAGE_ID = cstArchivedGallery_edit.PageID; // for backward compatibility

// extend page with ValidateForm function
cstArchivedGallery_edit.ValidateForm = function(fobj) {
	ew_PostAutoSuggest(fobj);
	if (!this.ValidateRequired)
		return true; // ignore validation
	if (fobj.a_confirm && fobj.a_confirm.value == "F")
		return true;
	var i, elm, aelm, infix;
	var rowcnt = (fobj.key_count) ? Number(fobj.key_count.value) : 1;
	for (i=0; i<rowcnt; i++) {
		infix = (fobj.key_count) ? String(i+1) : "";
		elm = fobj.elements["x" + infix + "_GalleryImage"];
		if (elm && !ew_CheckFileType(elm.value))
			return ew_OnError(this, elm, ewLanguage.Phrase("WrongFileType"));
		elm = fobj.elements["x" + infix + "_ArchiveYear"];
		if (elm && !ew_CheckInteger(elm.value))
			return ew_OnError(this, elm, "<?php echo ew_JsEncode2($cstArchivedGallery->ArchiveYear->FldErrMsg()) ?>");

		// Call Form Custom Validate event
		if (!this.Form_CustomValidate(fobj)) return false;
	}
	return true;
}

// extend page with Form_CustomValidate function
cstArchivedGallery_edit.Form_CustomValidate =  
 function(fobj) { // DO NOT CHANGE THIS LINE!

 	// Your custom validation code here, return false if invalid. 
 	return true;
 }
<?php if (EW_CLIENT_VALIDATE) { ?>
cstArchivedGallery_edit.ValidateRequired = true; // uses JavaScript validation
<?php } else { ?>
cstArchivedGallery_edit.ValidateRequired = false; // no JavaScript validation
<?php } ?>

//-->
</script>
<script type="text/javascript">
<!--
var ew_DHTMLEditors = [];

//-->
</script>
<script language="JavaScript" type="text/javascript">
<!--

// Write your client script here, no need to add script tags.
// To include another .js script, use:
// ew_ClientScriptInclude("my_javascript.js"); 
//-->

</script>
<p><span class="phpmaker"><?php echo $Language->Phrase("Edit") ?>&nbsp;<?php echo $Language->Phrase("TblTypeCUSTOMVIEW") ?><?php echo $cstArchivedGallery->TableCaption() ?><br><br>
<a href="<?php echo $cstArchivedGallery->getReturnUrl() ?>"><?php echo $Language->Phrase("GoBack") ?></a></span></p>
<?php
if (EW_DEBUG_ENABLED)
	echo ew_DebugMsg();
$cstArchivedGallery_edit->ShowMessage();
?>
<form name="fcstArchivedGalleryedit" id="fcstArchivedGalleryedit" action="<?php echo ew_CurrentPage() ?>" method="post" enctype="multipart/form-data" onsubmit="return cstArchivedGallery_edit.ValidateForm(this);">
<p>
<input type="hidden" name="a_table" id="a_table" value="cstArchivedGallery">
<input type="hidden" name="a_edit" id="a_edit" value="U">
<table cellspacing="0" class="ewGrid"><tr><td class="ewGridContent">
<div class="ewGridMiddlePanel">
<table cellspacing="0" class="ewTable">
<input type="hidden" name="x_CCEGalleryID" id="x_CCEGalleryID" value="<?php echo ew_HtmlEncode($cstArchivedGallery->CCEGalleryID->CurrentValue) ?>">
<?php if ($cstArchivedGallery->GalleryImage->Visible) { // GalleryImage ?>
	<tr<?php echo $cstArchivedGallery->GalleryImage->RowAttributes ?>>
		<td class="ewTableHeader"><?php echo $cstArchivedGallery->GalleryImage->FldCaption() ?></td>
		<td<?php echo $cstArchivedGallery->GalleryImage->CellAttributes() ?>><span id="el_GalleryImage">
<div id="old_x_GalleryImage">
<?php if ($cstArchivedGallery->GalleryImage->HrefValue <> "" || $cstArchivedGallery->GalleryImage->TooltipValue <> "") { ?>
<?php if (!empty($cstArchivedGallery->GalleryImage->Upload->DbValue)) { ?>
<img src="ewbv7.php?fn=<?php echo urlencode(ew_IncludeTrailingDelimiter($cstArchivedGallery->GalleryImage->UploadPath, FALSE) . $cstArchivedGallery->GalleryImage->Upload->DbValue) ?>&width=<?php echo $cstArchivedGallery->GalleryImage->ImageWidth ?>&height=<?php echo $cstArchivedGallery->GalleryImage->ImageHeight ?>" border=0<?php echo $cstArchivedGallery->GalleryImage->ViewAttributes() ?>>
<?php } elseif (!in_array($cstArchivedGallery->CurrentAction, array("I", "edit", "gridedit"))) { ?>	
&nbsp;
<?php } ?>
<?php } else { ?>
<?php if (!empty($cstArchivedGallery->GalleryImage->Upload->DbValue)) { ?>
<img src="ewbv7.php?fn=<?php echo urlencode(ew_IncludeTrailingDelimiter($cstArchivedGallery->GalleryImage->UploadPath, FALSE) . $cstArchivedGallery->GalleryImage->Upload->DbValue) ?>&width=<?php echo $cstArchivedGallery->GalleryImage->ImageWidth ?>&height=<?php echo $cstArchivedGallery->GalleryImage->ImageHeight ?>" border=0<?php echo $cstArchivedGallery->GalleryImage->ViewAttributes() ?>>
<?php } elseif (!in_array($cstArchivedGallery->CurrentAction, array("I", "edit", "gridedit"))) { ?>	
&nbsp;
<?php } ?>
<?php } ?>
</div>
<div id="new_x_GalleryImage">
<?php if (!empty($cstArchivedGallery->GalleryImage->Upload->DbValue)) { ?>
<label><input type="radio" name="a_GalleryImage" id="a_GalleryImage" value="1" checked="checked"><?php echo $Language->Phrase("Keep") ?></label>&nbsp;
<label><input type="radio" name="a_GalleryImage" id="a_GalleryImage" value="2"><?php echo $Language->Phrase("Remove") ?></label>&nbsp;
<label><input type="radio" name="a_GalleryImage" id="a_GalleryImage" value="3"><?php echo $Language->Phrase("Replace") ?><br></label>
<?php $cstArchivedGallery->GalleryImage->EditAttrs["onchange"] = "this.form.a_GalleryImage[2].checked=true;" . @$cstArchivedGallery->GalleryImage->EditAttrs["onchange"]; ?>
<?php } else { ?>
<input type="hidden" name="a_GalleryImage" id="a_GalleryImage" value="3">
<?php } ?>
<input type="file" name="x_GalleryImage" id="x_GalleryImage" title="<?php echo $cstArchivedGallery->GalleryImage->FldTitle() ?>" size="30"<?php echo $cstArchivedGallery->GalleryImage->EditAttributes() ?>>
</div>
</span><?php echo $cstArchivedGallery->GalleryImage->CustomMsg ?></td>
	</tr>
<?php } ?>
<?php if ($cstArchivedGallery->ImageCaption->Visible) { // ImageCaption ?>
	<tr<?php echo $cstArchivedGallery->ImageCaption->RowAttributes ?>>
		<td class="ewTableHeader"><?php echo $cstArchivedGallery->ImageCaption->FldCaption() ?></td>
		<td<?php echo $cstArchivedGallery->ImageCaption->CellAttributes() ?>><span id="el_ImageCaption">
<input type="text" name="x_ImageCaption" id="x_ImageCaption" title="<?php echo $cstArchivedGallery->ImageCaption->FldTitle() ?>" size="30" maxlength="255" value="<?php echo $cstArchivedGallery->ImageCaption->EditValue ?>"<?php echo $cstArchivedGallery->ImageCaption->EditAttributes() ?>>
</span><?php echo $cstArchivedGallery->ImageCaption->CustomMsg ?></td>
	</tr>
<?php } ?>
<?php if ($cstArchivedGallery->Archived->Visible) { // Archived ?>
	<tr<?php echo $cstArchivedGallery->Archived->RowAttributes ?>>
		<td class="ewTableHeader"><?php echo $cstArchivedGallery->Archived->FldCaption() ?><?php echo $Language->Phrase("FieldRequiredIndicator") ?></td>
		<td<?php echo $cstArchivedGallery->Archived->CellAttributes() ?>><span id="el_Archived">
<div id="tp_x_Archived" class="<?php echo EW_ITEM_TEMPLATE_CLASSNAME ?>"><label><input type="radio" name="x_Archived" id="x_Archived" title="<?php echo $cstArchivedGallery->Archived->FldTitle() ?>" value="{value}"<?php echo $cstArchivedGallery->Archived->EditAttributes() ?>></label></div>
<div id="dsl_x_Archived" repeatcolumn="5">
<?php
$arwrk = $cstArchivedGallery->Archived->EditValue;
if (is_array($arwrk)) {
	$rowswrk = count($arwrk);
	$emptywrk = TRUE;
	for ($rowcntwrk = 0; $rowcntwrk < $rowswrk; $rowcntwrk++) {
		$selwrk = (strval($cstArchivedGallery->Archived->CurrentValue) == strval($arwrk[$rowcntwrk][0])) ? " checked=\"checked\"" : "";
		if ($selwrk <> "") $emptywrk = FALSE;

		// Note: No spacing within the LABEL tag
?>
<?php echo ew_RepeatColumnTable($rowswrk, $rowcntwrk, 5, 1) ?>
<label><input type="radio" name="x_Archived" id="x_Archived" title="<?php echo $cstArchivedGallery->Archived->FldTitle() ?>" value="<?php echo ew_HtmlEncode($arwrk[$rowcntwrk][0]) ?>"<?php echo $selwrk ?><?php echo $cstArchivedGallery->Archived->EditAttributes() ?>><?php echo $arwrk[$rowcntwrk][1] ?></label>
<?php echo ew_RepeatColumnTable($rowswrk, $rowcntwrk, 5, 2) ?>
<?php
	}
}
?>
</div>
</span><?php echo $cstArchivedGallery->Archived->CustomMsg ?></td>
	</tr>
<?php } ?>
<?php if ($cstArchivedGallery->ArchiveYear->Visible) { // ArchiveYear ?>
	<tr<?php echo $cstArchivedGallery->ArchiveYear->RowAttributes ?>>
		<td class="ewTableHeader"><?php echo $cstArchivedGallery->ArchiveYear->FldCaption() ?></td>
		<td<?php echo $cstArchivedGallery->ArchiveYear->CellAttributes() ?>><span id="el_ArchiveYear">
<input type="text" name="x_ArchiveYear" id="x_ArchiveYear" title="<?php echo $cstArchivedGallery->ArchiveYear->FldTitle() ?>" size="30" value="<?php echo $cstArchivedGallery->ArchiveYear->EditValue ?>"<?php echo $cstArchivedGallery->ArchiveYear->EditAttributes() ?>>
</span><?php echo $cstArchivedGallery->ArchiveYear->CustomMsg ?></td>
	</tr>
<?php } ?>
</table>
</div>
</td></tr></table>
<p>
<input type="submit" name="btnAction" id="btnAction" value="<?php echo ew_BtnCaption($Language->Phrase("EditBtn")) ?>">
</form>
<script language="JavaScript" type="text/javascript">
<!--

// Write your table-specific startup script here
// document.write("page loaded");
//-->

</script>
<?php include "footer.php" ?>
<?php
$cstArchivedGallery_edit->Page_Terminate();
?>
<?php

//
// Page class
//
class ccstArchivedGallery_edit {

	// Page ID
	var $PageID = 'edit';

	// Table name
	var $TableName = 'cstArchivedGallery';

	// Page object name
	var $PageObjName = 'cstArchivedGallery_edit';

	// Page name
	function PageName() {
		return ew_CurrentPage();
	}

	// Page URL
	function PageUrl() {
		$PageUrl = ew_CurrentPage() . "?";
		global $cstArchivedGallery;
		if ($cstArchivedGallery->UseTokenInUrl) $PageUrl .= "t=" . $cstArchivedGallery->TableVar . "&"; // Add page token
		return $PageUrl;
	}

	// Page URLs
	var $AddUrl;
	var $EditUrl;
	var $CopyUrl;
	var $DeleteUrl;
	var $ViewUrl;
	var $ListUrl;

	// Export URLs
	var $ExportPrintUrl;
	var $ExportHtmlUrl;
	var $ExportExcelUrl;
	var $ExportWordUrl;
	var $ExportXmlUrl;
	var $ExportCsvUrl;

	// Update URLs
	var $InlineAddUrl;
	var $InlineCopyUrl;
	var $InlineEditUrl;
	var $GridAddUrl;
	var $GridEditUrl;
	var $MultiDeleteUrl;
	var $MultiUpdateUrl;

	// Message
	function getMessage() {
		return @$_SESSION[EW_SESSION_MESSAGE];
	}

	function setMessage($v) {
		if (@$_SESSION[EW_SESSION_MESSAGE] <> "") { // Append
			$_SESSION[EW_SESSION_MESSAGE] .= "<br>" . $v;
		} else {
			$_SESSION[EW_SESSION_MESSAGE] = $v;
		}
	}

	// Show message
	function ShowMessage() {
		$sMessage = $this->getMessage();
		$this->Message_Showing($sMessage);
		if ($sMessage <> "") { // Message in Session, display
			echo "<p><span class=\"ewMessage\">" . $sMessage . "</span></p>";
			$_SESSION[EW_SESSION_MESSAGE] = ""; // Clear message in Session
		}
	}

	// Validate page request
	function IsPageRequest() {
		global $objForm, $cstArchivedGallery;
		if ($cstArchivedGallery->UseTokenInUrl) {
			if ($objForm)
				return ($cstArchivedGallery->TableVar == $objForm->GetValue("t"));
			if (@$_GET["t"] <> "")
				return ($cstArchivedGallery->TableVar == $_GET["t"]);
		} else {
			return TRUE;
		}
	}

	//
	// Page class constructor
	//
	function __construct() {
		global $conn, $Language;

		// Language object
		$Language = new cLanguage();

		// Table object (cstArchivedGallery)
		$GLOBALS["cstArchivedGallery"] = new ccstArchivedGallery();

		// Table object (CCEUsers)
		$GLOBALS['CCEUsers'] = new cCCEUsers();

		// Page ID
		if (!defined("EW_PAGE_ID"))
			define("EW_PAGE_ID", 'edit', TRUE);

		// Table name (for backward compatibility)
		if (!defined("EW_TABLE_NAME"))
			define("EW_TABLE_NAME", 'cstArchivedGallery', TRUE);

		// Start timer
		$GLOBALS["gsTimer"] = new cTimer();

		// Open connection
		$conn = ew_Connect();
	}

	// 
	//  Page_Init
	//
	function Page_Init() {
		global $gsExport, $gsExportFile, $UserProfile, $Language, $Security, $objForm;
		global $cstArchivedGallery;

		// Security
		$Security = new cAdvancedSecurity();
		if (!$Security->IsLoggedIn()) $Security->AutoLogin();
		if (!$Security->IsLoggedIn()) {
			$Security->SaveLastUrl();
			$this->Page_Terminate("login.php");
		}
		$Security->TablePermission_Loading();
		$Security->LoadCurrentUserLevel($this->TableName);
		$Security->TablePermission_Loaded();
		if (!$Security->IsLoggedIn()) {
			$Security->SaveLastUrl();
			$this->Page_Terminate("login.php");
		}
		if (!$Security->CanEdit()) {
			$Security->SaveLastUrl();
			$this->Page_Terminate("cstArchivedGallerylist.php");
		}

		// Create form object
		$objForm = new cFormObj();

		// Global Page Loading event (in userfn*.php)
		Page_Loading();

		// Page Load event
		$this->Page_Load();
	}

	//
	// Page_Terminate
	//
	function Page_Terminate($url = "") {
		global $conn;

		// Page Unload event
		$this->Page_Unload();

		// Global Page Unloaded event (in userfn*.php)
		Page_Unloaded();

		 // Close connection
		$conn->Close();

		// Go to URL if specified
		$this->Page_Redirecting($url);
		if ($url <> "") {
			if (!EW_DEBUG_ENABLED && ob_get_length())
				ob_end_clean();
			header("Location: " . $url);
		}
		exit();
	}
	var $sDbMasterFilter;
	var $sDbDetailFilter;

	// 
	// Page main
	//
	function Page_Main() {
		global $objForm, $Language, $gsFormError, $cstArchivedGallery;

		// Load key from QueryString
		if (@$_GET["CCEGalleryID"] <> "")
			$cstArchivedGallery->CCEGalleryID->setQueryStringValue($_GET["CCEGalleryID"]);
		if (@$_POST["a_edit"] <> "") {
			$cstArchivedGallery->CurrentAction = $_POST["a_edit"]; // Get action code
			$this->GetUploadFiles(); // Get upload files
			$this->LoadFormValues(); // Get form values

			// Validate form
			if (!$this->ValidateForm()) {
				$cstArchivedGallery->CurrentAction = ""; // Form error, reset action
				$this->setMessage($gsFormError);
				$cstArchivedGallery->EventCancelled = TRUE; // Event cancelled
				$this->RestoreFormValues();
			}
		} else {
			$cstArchivedGallery->CurrentAction = "I"; // Default action is display
		}

		// Check if valid key
		if ($cstArchivedGallery->CCEGalleryID->CurrentValue == "")
			$this->Page_Terminate("cstArchivedGallerylist.php"); // Invalid key, return to list
		switch ($cstArchivedGallery->CurrentAction) {
			case "I": // Get a record to display
				if (!$this->LoadRow()) { // Load record based on key
					$this->setMessage($Language->Phrase("NoRecord")); // No record found
					$this->Page_Terminate("cstArchivedGallerylist.php"); // No matching record, return to list
				}
				break;
			Case "U": // Update
				$cstArchivedGallery->SendEmail = TRUE; // Send email on update success
				if ($this->EditRow()) { // Update record based on key
					$this->setMessage($Language->Phrase("UpdateSuccess")); // Update success
					$sReturnUrl = $cstArchivedGallery->getReturnUrl();
					if (ew_GetPageName($sReturnUrl) == "cstArchivedGalleryview.php")
						$sReturnUrl = $cstArchivedGallery->ViewUrl(); // View paging, return to View page directly
					$this->Page_Terminate($sReturnUrl); // Return to caller
				} else {
					$cstArchivedGallery->EventCancelled = TRUE; // Event cancelled
					$this->RestoreFormValues(); // Restore form values if update failed
				}
		}

		// Render the record
		$cstArchivedGallery->RowType = EW_ROWTYPE_EDIT; // Render as Edit
		$this->RenderRow();
	}

	// Get upload files
	function GetUploadFiles() {
		global $objForm, $cstArchivedGallery;

		// Get upload data
			if ($cstArchivedGallery->GalleryImage->Upload->UploadFile()) {

				// No action required
			} else {
				echo $cstArchivedGallery->GalleryImage->Upload->Message;
				$this->Page_Terminate();
				exit();
			}
	}

	// Load form values
	function LoadFormValues() {

		// Load from form
		global $objForm, $cstArchivedGallery;
		$cstArchivedGallery->CCEGalleryID->setFormValue($objForm->GetValue("x_CCEGalleryID"));
		$cstArchivedGallery->ImageCaption->setFormValue($objForm->GetValue("x_ImageCaption"));
		$cstArchivedGallery->Archived->setFormValue($objForm->GetValue("x_Archived"));
		$cstArchivedGallery->ArchiveYear->setFormValue($objForm->GetValue("x_ArchiveYear"));
	}

	// Restore form values
	function RestoreFormValues() {
		global $objForm, $cstArchivedGallery;
		$this->LoadRow();
		$cstArchivedGallery->CCEGalleryID->CurrentValue = $cstArchivedGallery->CCEGalleryID->FormValue;
		$cstArchivedGallery->ImageCaption->CurrentValue = $cstArchivedGallery->ImageCaption->FormValue;
		$cstArchivedGallery->Archived->CurrentValue = $cstArchivedGallery->Archived->FormValue;
		$cstArchivedGallery->ArchiveYear->CurrentValue = $cstArchivedGallery->ArchiveYear->FormValue;
	}

	// Load row based on key values
	function LoadRow() {
		global $conn, $Security, $cstArchivedGallery;
		$sFilter = $cstArchivedGallery->KeyFilter();

		// Call Row Selecting event
		$cstArchivedGallery->Row_Selecting($sFilter);

		// Load SQL based on filter
		$cstArchivedGallery->CurrentFilter = $sFilter;
		$sSql = $cstArchivedGallery->SQL();
		$res = FALSE;
		$rs = ew_LoadRecordset($sSql);
		if ($rs && !$rs->EOF) {
			$res = TRUE;
			$this->LoadRowValues($rs); // Load row values

			// Call Row Selected event
			$cstArchivedGallery->Row_Selected($rs);
			$rs->Close();
		}
		return $res;
	}

	// Load row values from recordset
	function LoadRowValues(&$rs) {
		global $conn, $cstArchivedGallery;
		$cstArchivedGallery->CCEGalleryID->setDbValue($rs->fields('CCEGalleryID'));
		$cstArchivedGallery->GalleryImage->Upload->DbValue = $rs->fields('GalleryImage');
		$cstArchivedGallery->ImageCaption->setDbValue($rs->fields('ImageCaption'));
		$cstArchivedGallery->DateAdded->setDbValue($rs->fields('DateAdded'));
		$cstArchivedGallery->Archived->setDbValue($rs->fields('Archived'));
		$cstArchivedGallery->ArchiveYear->setDbValue($rs->fields('ArchiveYear'));
	}

	// Render row values based on field settings
	function RenderRow() {
		global $conn, $Security, $Language, $cstArchivedGallery;

		// Initialize URLs
		// Call Row_Rendering event

		$cstArchivedGallery->Row_Rendering();

		// Common render codes for all row types
		// CCEGalleryID

		$cstArchivedGallery->CCEGalleryID->CellCssStyle = ""; $cstArchivedGallery->CCEGalleryID->CellCssClass = "";
		$cstArchivedGallery->CCEGalleryID->CellAttrs = array(); $cstArchivedGallery->CCEGalleryID->ViewAttrs = array(); $cstArchivedGallery->CCEGalleryID->EditAttrs = array();

		// GalleryImage
		$cstArchivedGallery->GalleryImage->CellCssStyle = ""; $cstArchivedGallery->GalleryImage->CellCssClass = "";
		$cstArchivedGallery->GalleryImage->CellAttrs = array(); $cstArchivedGallery->GalleryImage->ViewAttrs = array(); $cstArchivedGallery->GalleryImage->EditAttrs = array();

		// ImageCaption
		$cstArchivedGallery->ImageCaption->CellCssStyle = ""; $cstArchivedGallery->ImageCaption->CellCssClass = "";
		$cstArchivedGallery->ImageCaption->CellAttrs = array(); $cstArchivedGallery->ImageCaption->ViewAttrs = array(); $cstArchivedGallery->ImageCaption->EditAttrs = array();

		// Archived
		$cstArchivedGallery->Archived->CellCssStyle = ""; $cstArchivedGallery->Archived->CellCssClass = "";
		$cstArchivedGallery->Archived->CellAttrs = array(); $cstArchivedGallery->Archived->ViewAttrs = array(); $cstArchivedGallery->Archived->EditAttrs = array();

		// ArchiveYear
		$cstArchivedGallery->ArchiveYear->CellCssStyle = ""; $cstArchivedGallery->ArchiveYear->CellCssClass = "";
		$cstArchivedGallery->ArchiveYear->CellAttrs = array(); $cstArchivedGallery->ArchiveYear->ViewAttrs = array(); $cstArchivedGallery->ArchiveYear->EditAttrs = array();
		if ($cstArchivedGallery->RowType == EW_ROWTYPE_VIEW) { // View row

			// CCEGalleryID
			$cstArchivedGallery->CCEGalleryID->ViewValue = $cstArchivedGallery->CCEGalleryID->CurrentValue;
			$cstArchivedGallery->CCEGalleryID->CssStyle = "";
			$cstArchivedGallery->CCEGalleryID->CssClass = "";
			$cstArchivedGallery->CCEGalleryID->ViewCustomAttributes = "";

			// GalleryImage
			if (!ew_Empty($cstArchivedGallery->GalleryImage->Upload->DbValue)) {
				$cstArchivedGallery->GalleryImage->ViewValue = $cstArchivedGallery->GalleryImage->Upload->DbValue;
				$cstArchivedGallery->GalleryImage->ImageWidth = 200;
				$cstArchivedGallery->GalleryImage->ImageHeight = 0;
				$cstArchivedGallery->GalleryImage->ImageAlt = $cstArchivedGallery->GalleryImage->FldAlt();
			} else {
				$cstArchivedGallery->GalleryImage->ViewValue = "";
			}
			$cstArchivedGallery->GalleryImage->CssStyle = "";
			$cstArchivedGallery->GalleryImage->CssClass = "";
			$cstArchivedGallery->GalleryImage->ViewCustomAttributes = "";

			// ImageCaption
			$cstArchivedGallery->ImageCaption->ViewValue = $cstArchivedGallery->ImageCaption->CurrentValue;
			$cstArchivedGallery->ImageCaption->CssStyle = "";
			$cstArchivedGallery->ImageCaption->CssClass = "";
			$cstArchivedGallery->ImageCaption->ViewCustomAttributes = "";

			// DateAdded
			$cstArchivedGallery->DateAdded->ViewValue = $cstArchivedGallery->DateAdded->CurrentValue;
			$cstArchivedGallery->DateAdded->ViewValue = ew_FormatDateTime($cstArchivedGallery->DateAdded->ViewValue, 5);
			$cstArchivedGallery->DateAdded->CssStyle = "";
			$cstArchivedGallery->DateAdded->CssClass = "";
			$cstArchivedGallery->DateAdded->ViewCustomAttributes = "";

			// Archived
			if (strval($cstArchivedGallery->Archived->CurrentValue) <> "") {
				switch ($cstArchivedGallery->Archived->CurrentValue) {
					case "1":
						$cstArchivedGallery->Archived->ViewValue = "Yes";
						break;
					case "0":
						$cstArchivedGallery->Archived->ViewValue = "No";
						break;
					default:
						$cstArchivedGallery->Archived->ViewValue = $cstArchivedGallery->Archived->CurrentValue;
				}
			} else {
				$cstArchivedGallery->Archived->ViewValue = NULL;
			}
			$cstArchivedGallery->Archived->CssStyle = "";
			$cstArchivedGallery->Archived->CssClass = "";
			$cstArchivedGallery->Archived->ViewCustomAttributes = "";

			// ArchiveYear
			$cstArchivedGallery->ArchiveYear->ViewValue = $cstArchivedGallery->ArchiveYear->CurrentValue;
			$cstArchivedGallery->ArchiveYear->CssStyle = "";
			$cstArchivedGallery->ArchiveYear->CssClass = "";
			$cstArchivedGallery->ArchiveYear->ViewCustomAttributes = "";

			// CCEGalleryID
			$cstArchivedGallery->CCEGalleryID->HrefValue = "";
			$cstArchivedGallery->CCEGalleryID->TooltipValue = "";

			// GalleryImage
			$cstArchivedGallery->GalleryImage->HrefValue = "";
			$cstArchivedGallery->GalleryImage->TooltipValue = "";

			// ImageCaption
			$cstArchivedGallery->ImageCaption->HrefValue = "";
			$cstArchivedGallery->ImageCaption->TooltipValue = "";

			// Archived
			$cstArchivedGallery->Archived->HrefValue = "";
			$cstArchivedGallery->Archived->TooltipValue = "";

			// ArchiveYear
			$cstArchivedGallery->ArchiveYear->HrefValue = "";
			$cstArchivedGallery->ArchiveYear->TooltipValue = "";
		} elseif ($cstArchivedGallery->RowType == EW_ROWTYPE_EDIT) { // Edit row

			// CCEGalleryID
			$cstArchivedGallery->CCEGalleryID->EditCustomAttributes = "";

			// GalleryImage
			$cstArchivedGallery->GalleryImage->EditCustomAttributes = "";
			if (!ew_Empty($cstArchivedGallery->GalleryImage->Upload->DbValue)) {
				$cstArchivedGallery->GalleryImage->EditValue = $cstArchivedGallery->GalleryImage->Upload->DbValue;
				$cstArchivedGallery->GalleryImage->ImageWidth = 200;
				$cstArchivedGallery->GalleryImage->ImageHeight = 0;
				$cstArchivedGallery->GalleryImage->ImageAlt = $cstArchivedGallery->GalleryImage->FldAlt();
			} else {
				$cstArchivedGallery->GalleryImage->EditValue = "";
			}

			// ImageCaption
			$cstArchivedGallery->ImageCaption->EditCustomAttributes = "";
			$cstArchivedGallery->ImageCaption->EditValue = ew_HtmlEncode($cstArchivedGallery->ImageCaption->CurrentValue);

			// Archived
			$cstArchivedGallery->Archived->EditCustomAttributes = "";
			$arwrk = array();
			$arwrk[] = array("1", "Yes");
			$arwrk[] = array("0", "No");
			$cstArchivedGallery->Archived->EditValue = $arwrk;

			// ArchiveYear
			$cstArchivedGallery->ArchiveYear->EditCustomAttributes = "";
			$cstArchivedGallery->ArchiveYear->EditValue = ew_HtmlEncode($cstArchivedGallery->ArchiveYear->CurrentValue);

			// Edit refer script
			// CCEGalleryID

			$cstArchivedGallery->CCEGalleryID->HrefValue = "";

			// GalleryImage
			$cstArchivedGallery->GalleryImage->HrefValue = "";

			// ImageCaption
			$cstArchivedGallery->ImageCaption->HrefValue = "";

			// Archived
			$cstArchivedGallery->Archived->HrefValue = "";

			// ArchiveYear
			$cstArchivedGallery->ArchiveYear->HrefValue = "";
		}

		// Call Row Rendered event
		if ($cstArchivedGallery->RowType <> EW_ROWTYPE_AGGREGATEINIT)
			$cstArchivedGallery->Row_Rendered();
	}

	// Validate form
	function ValidateForm() {
		global $Language, $gsFormError, $cstArchivedGallery;

		// Initialize form error message
		$gsFormError = "";
		if (!ew_CheckFileType($cstArchivedGallery->GalleryImage->Upload->FileName)) {
			$gsFormError .= ($gsFormError <> "") ? "<br>" : "";
			$gsFormError .= $Language->Phrase("WrongFileType");
		}
		if ($cstArchivedGallery->GalleryImage->Upload->FileSize > 0 && EW_MAX_FILE_SIZE > 0 && $cstArchivedGallery->GalleryImage->Upload->FileSize > EW_MAX_FILE_SIZE) {
			$gsFormError .= ($gsFormError <> "") ? "<br>" : "";
			$gsFormError .= str_replace("%s", EW_MAX_FILE_SIZE, $Language->Phrase("MaxFileSize"));
		}
		if (in_array($cstArchivedGallery->GalleryImage->Upload->Error, array(1, 2, 3, 6, 7, 8))) {
			$gsFormError .= ($gsFormError <> "") ? "<br>" : "";
			$gsFormError .= $Language->Phrase("PhpUploadErr" . $cstArchivedGallery->GalleryImage->Upload->Error);
		}

		// Check if validation required
		if (!EW_SERVER_VALIDATE)
			return ($gsFormError == "");
		if (!ew_CheckInteger($cstArchivedGallery->ArchiveYear->FormValue)) {
			if ($gsFormError <> "") $gsFormError .= "<br>";
			$gsFormError .= $cstArchivedGallery->ArchiveYear->FldErrMsg();
		}

		// Return validate result
		$ValidateForm = ($gsFormError == "");

		// Call Form_CustomValidate event
		$sFormCustomError = "";
		$ValidateForm = $ValidateForm && $this->Form_CustomValidate($sFormCustomError);
		if ($sFormCustomError <> "") {
			$gsFormError .= ($gsFormError <> "") ? "<br>" : "";
			$gsFormError .= $sFormCustomError;
		}
		return $ValidateForm;
	}

	// Update record based on key values
	function EditRow() {
		global $conn, $Security, $Language, $cstArchivedGallery;
		$sFilter = $cstArchivedGallery->KeyFilter();
		$cstArchivedGallery->CurrentFilter = $sFilter;
		$sSql = $cstArchivedGallery->SQL();
		$conn->raiseErrorFn = 'ew_ErrorFn';
		$rs = $conn->Execute($sSql);
		$conn->raiseErrorFn = '';
		if ($rs === FALSE)
			return FALSE;
		if ($rs->EOF) {
			$EditRow = FALSE; // Update Failed
		} else {

			// Save old values
			$rsold =& $rs->fields;
			$rsnew = array();

			// GalleryImage
			$cstArchivedGallery->GalleryImage->Upload->SaveToSession(); // Save file value to Session
						if ($cstArchivedGallery->GalleryImage->Upload->Action == "2" || $cstArchivedGallery->GalleryImage->Upload->Action == "3") { // Update/Remove
			$cstArchivedGallery->GalleryImage->Upload->DbValue = $rs->fields('GalleryImage'); // Get original value
			if (is_null($cstArchivedGallery->GalleryImage->Upload->Value)) {
				$rsnew['GalleryImage'] = NULL;
			} else {
				$rsnew['GalleryImage'] = ew_UploadFileNameEx(ew_UploadPathEx(TRUE, $cstArchivedGallery->GalleryImage->UploadPath), $cstArchivedGallery->GalleryImage->Upload->FileName);
			}
			$cstArchivedGallery->GalleryImage->ImageWidth = 700; // Resize width
			$cstArchivedGallery->GalleryImage->ImageHeight = 0; // Resize height
			}

			// ImageCaption
			$cstArchivedGallery->ImageCaption->SetDbValueDef($rsnew, $cstArchivedGallery->ImageCaption->CurrentValue, NULL, FALSE);

			// Archived
			$cstArchivedGallery->Archived->SetDbValueDef($rsnew, $cstArchivedGallery->Archived->CurrentValue, 0, FALSE);

			// ArchiveYear
			$cstArchivedGallery->ArchiveYear->SetDbValueDef($rsnew, $cstArchivedGallery->ArchiveYear->CurrentValue, NULL, FALSE);

			// Call Row Updating event
			$bUpdateRow = $cstArchivedGallery->Row_Updating($rsold, $rsnew);
			if ($bUpdateRow) {
			if (!ew_Empty($cstArchivedGallery->GalleryImage->Upload->Value)) {
				$cstArchivedGallery->GalleryImage->Upload->RestoreFromSession(); // Restore original value
				$cstArchivedGallery->GalleryImage->Upload->Resize($cstArchivedGallery->GalleryImage->ImageWidth, $cstArchivedGallery->GalleryImage->ImageHeight, 75);
			}
			$cstArchivedGallery->GalleryImage->ImageWidth = 0; // Reset image width
			$cstArchivedGallery->GalleryImage->ImageHeight = 0; // Reset image height
			if (!ew_Empty($cstArchivedGallery->GalleryImage->Upload->Value)) {
				$cstArchivedGallery->GalleryImage->Upload->SaveToFile($cstArchivedGallery->GalleryImage->UploadPath, $rsnew['GalleryImage'], FALSE);
			}
				$conn->raiseErrorFn = 'ew_ErrorFn';
				$EditRow = $conn->Execute($cstArchivedGallery->UpdateSQL($rsnew));
				$conn->raiseErrorFn = '';
			} else {
				if ($cstArchivedGallery->CancelMessage <> "") {
					$this->setMessage($cstArchivedGallery->CancelMessage);
					$cstArchivedGallery->CancelMessage = "";
				} else {
					$this->setMessage($Language->Phrase("UpdateCancelled"));
				}
				$EditRow = FALSE;
			}
		}

		// Call Row_Updated event
		if ($EditRow)
			$cstArchivedGallery->Row_Updated($rsold, $rsnew);
		$rs->Close();

		// GalleryImage
		$cstArchivedGallery->GalleryImage->Upload->RemoveFromSession(); // Remove file value from Session
		return $EditRow;
	}

	// Page Load event
	function Page_Load() {

		//echo "Page Load";
	}

	// Page Unload event
	function Page_Unload() {

		//echo "Page Unload";
	}

	// Page Redirecting event
	function Page_Redirecting(&$url) {

		// Example:
		//$url = "your URL";

	}

	// Message Showing event
	function Message_Showing(&$msg) {

		// Example:
		//$msg = "your new message";

	}

	// Form Custom Validate event
	function Form_CustomValidate(&$CustomError) {

		// Return error message in CustomError
		return TRUE;
	}
}
?>