Your IP : 216.73.217.117


Current Path : /var/www/cesa.co.za/cceadmin/
Upload File :
Current File : /var/www/cesa.co.za/cceadmin/CCEGalleryedit.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 "CCEGalleryinfo.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
$CCEGallery_edit = new cCCEGallery_edit();
$Page =& $CCEGallery_edit;

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

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

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

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

// extend page with ValidateForm function
CCEGallery_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"));

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

// extend page with Form_CustomValidate function
CCEGallery_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) { ?>
CCEGallery_edit.ValidateRequired = true; // uses JavaScript validation
<?php } else { ?>
CCEGallery_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("TblTypeTABLE") ?><?php echo $CCEGallery->TableCaption() ?><br><br>
<a href="<?php echo $CCEGallery->getReturnUrl() ?>"><?php echo $Language->Phrase("GoBack") ?></a></span></p>
<?php
if (EW_DEBUG_ENABLED)
	echo ew_DebugMsg();
$CCEGallery_edit->ShowMessage();
?>
<form name="fCCEGalleryedit" id="fCCEGalleryedit" action="<?php echo ew_CurrentPage() ?>" method="post" enctype="multipart/form-data" onsubmit="return CCEGallery_edit.ValidateForm(this);">
<p>
<input type="hidden" name="a_table" id="a_table" value="CCEGallery">
<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($CCEGallery->CCEGalleryID->CurrentValue) ?>">
<?php if ($CCEGallery->GalleryImage->Visible) { // GalleryImage ?>
	<tr<?php echo $CCEGallery->GalleryImage->RowAttributes ?>>
		<td class="ewTableHeader"><?php echo $CCEGallery->GalleryImage->FldCaption() ?></td>
		<td<?php echo $CCEGallery->GalleryImage->CellAttributes() ?>><span id="el_GalleryImage">
<div id="old_x_GalleryImage">
<?php if ($CCEGallery->GalleryImage->HrefValue <> "" || $CCEGallery->GalleryImage->TooltipValue <> "") { ?>
<?php if (!empty($CCEGallery->GalleryImage->Upload->DbValue)) { ?>
<img src="ewbv7.php?fn=<?php echo urlencode(ew_IncludeTrailingDelimiter($CCEGallery->GalleryImage->UploadPath, FALSE) . $CCEGallery->GalleryImage->Upload->DbValue) ?>&width=<?php echo $CCEGallery->GalleryImage->ImageWidth ?>&height=<?php echo $CCEGallery->GalleryImage->ImageHeight ?>" border=0<?php echo $CCEGallery->GalleryImage->ViewAttributes() ?>>
<?php } elseif (!in_array($CCEGallery->CurrentAction, array("I", "edit", "gridedit"))) { ?>	
&nbsp;
<?php } ?>
<?php } else { ?>
<?php if (!empty($CCEGallery->GalleryImage->Upload->DbValue)) { ?>
<img src="ewbv7.php?fn=<?php echo urlencode(ew_IncludeTrailingDelimiter($CCEGallery->GalleryImage->UploadPath, FALSE) . $CCEGallery->GalleryImage->Upload->DbValue) ?>&width=<?php echo $CCEGallery->GalleryImage->ImageWidth ?>&height=<?php echo $CCEGallery->GalleryImage->ImageHeight ?>" border=0<?php echo $CCEGallery->GalleryImage->ViewAttributes() ?>>
<?php } elseif (!in_array($CCEGallery->CurrentAction, array("I", "edit", "gridedit"))) { ?>	
&nbsp;
<?php } ?>
<?php } ?>
</div>
<div id="new_x_GalleryImage">
<?php if (!empty($CCEGallery->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 $CCEGallery->GalleryImage->EditAttrs["onchange"] = "this.form.a_GalleryImage[2].checked=true;" . @$CCEGallery->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 $CCEGallery->GalleryImage->FldTitle() ?>" size="30"<?php echo $CCEGallery->GalleryImage->EditAttributes() ?>>
</div>
</span><?php echo $CCEGallery->GalleryImage->CustomMsg ?></td>
	</tr>
<?php } ?>
<?php if ($CCEGallery->ImageCaption->Visible) { // ImageCaption ?>
	<tr<?php echo $CCEGallery->ImageCaption->RowAttributes ?>>
		<td class="ewTableHeader"><?php echo $CCEGallery->ImageCaption->FldCaption() ?></td>
		<td<?php echo $CCEGallery->ImageCaption->CellAttributes() ?>><span id="el_ImageCaption">
<input type="text" name="x_ImageCaption" id="x_ImageCaption" title="<?php echo $CCEGallery->ImageCaption->FldTitle() ?>" size="30" maxlength="255" value="<?php echo $CCEGallery->ImageCaption->EditValue ?>"<?php echo $CCEGallery->ImageCaption->EditAttributes() ?>>
</span><?php echo $CCEGallery->ImageCaption->CustomMsg ?></td>
	</tr>
<?php } ?>
<?php if ($CCEGallery->Archived->Visible) { // Archived ?>
	<tr<?php echo $CCEGallery->Archived->RowAttributes ?>>
		<td class="ewTableHeader"><?php echo $CCEGallery->Archived->FldCaption() ?><?php echo $Language->Phrase("FieldRequiredIndicator") ?></td>
		<td<?php echo $CCEGallery->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 $CCEGallery->Archived->FldTitle() ?>" value="{value}"<?php echo $CCEGallery->Archived->EditAttributes() ?>></label></div>
<div id="dsl_x_Archived" repeatcolumn="5">
<?php
$arwrk = $CCEGallery->Archived->EditValue;
if (is_array($arwrk)) {
	$rowswrk = count($arwrk);
	$emptywrk = TRUE;
	for ($rowcntwrk = 0; $rowcntwrk < $rowswrk; $rowcntwrk++) {
		$selwrk = (strval($CCEGallery->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 $CCEGallery->Archived->FldTitle() ?>" value="<?php echo ew_HtmlEncode($arwrk[$rowcntwrk][0]) ?>"<?php echo $selwrk ?><?php echo $CCEGallery->Archived->EditAttributes() ?>><?php echo $arwrk[$rowcntwrk][1] ?></label>
<?php echo ew_RepeatColumnTable($rowswrk, $rowcntwrk, 5, 2) ?>
<?php
	}
}
?>
</div>
</span><?php echo $CCEGallery->Archived->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
$CCEGallery_edit->Page_Terminate();
?>
<?php

//
// Page class
//
class cCCEGallery_edit {

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

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

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

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

	// Page URL
	function PageUrl() {
		$PageUrl = ew_CurrentPage() . "?";
		global $CCEGallery;
		if ($CCEGallery->UseTokenInUrl) $PageUrl .= "t=" . $CCEGallery->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, $CCEGallery;
		if ($CCEGallery->UseTokenInUrl) {
			if ($objForm)
				return ($CCEGallery->TableVar == $objForm->GetValue("t"));
			if (@$_GET["t"] <> "")
				return ($CCEGallery->TableVar == $_GET["t"]);
		} else {
			return TRUE;
		}
	}

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

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

		// Table object (CCEGallery)
		$GLOBALS["CCEGallery"] = new cCCEGallery();

		// 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", 'CCEGallery', 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 $CCEGallery;

		// 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("CCEGallerylist.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, $CCEGallery;

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

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

		// Check if valid key
		if ($CCEGallery->CCEGalleryID->CurrentValue == "")
			$this->Page_Terminate("CCEGallerylist.php"); // Invalid key, return to list
		switch ($CCEGallery->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("CCEGallerylist.php"); // No matching record, return to list
				}
				break;
			Case "U": // Update
				$CCEGallery->SendEmail = TRUE; // Send email on update success
				if ($this->EditRow()) { // Update record based on key
					$this->setMessage($Language->Phrase("UpdateSuccess")); // Update success
					$sReturnUrl = $CCEGallery->getReturnUrl();
					if (ew_GetPageName($sReturnUrl) == "CCEGalleryview.php")
						$sReturnUrl = $CCEGallery->ViewUrl(); // View paging, return to View page directly
					$this->Page_Terminate($sReturnUrl); // Return to caller
				} else {
					$CCEGallery->EventCancelled = TRUE; // Event cancelled
					$this->RestoreFormValues(); // Restore form values if update failed
				}
		}

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

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

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

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

	// Load form values
	function LoadFormValues() {

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

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

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

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

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

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

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

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

		// Initialize URLs
		// Call Row_Rendering event

		$CCEGallery->Row_Rendering();

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

			// Edit refer script
			// CCEGalleryID

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

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

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

			// Archived
			$CCEGallery->Archived->HrefValue = "";
		}

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

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

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

		// Check if validation required
		if (!EW_SERVER_VALIDATE)
			return ($gsFormError == "");

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

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

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

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

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

		// GalleryImage
		$CCEGallery->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;
	}
}
?>