Your IP : 216.73.217.79


Current Path : /var/www/cesa.co.za/cceadmin/
Upload File :
Current File : /var/www/cesa.co.za/cceadmin/CCEGalleryadd.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_add = new cCCEGallery_add();
$Page =& $CCEGallery_add;

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

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

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

// page properties
CCEGallery_add.PageID = "add"; // page ID
CCEGallery_add.FormID = "fCCEGalleryadd"; // form ID
var EW_PAGE_ID = CCEGallery_add.PageID; // for backward compatibility

// extend page with ValidateForm function
CCEGallery_add.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_add.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_add.ValidateRequired = true; // uses JavaScript validation
<?php } else { ?>
CCEGallery_add.ValidateRequired = false; // no JavaScript validation
<?php } ?>

//-->
</script>
<link rel="stylesheet" type="text/css" media="all" href="calendar/calendar-win2k-cold-1.css" title="win2k-1">
<script type="text/javascript" src="calendar/calendar.js"></script>
<script type="text/javascript" src="calendar/lang/calendar-en.js"></script>
<script type="text/javascript" src="calendar/calendar-setup.js"></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("Add") ?>&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_add->ShowMessage();
?>
<form name="fCCEGalleryadd" id="fCCEGalleryadd" action="<?php echo ew_CurrentPage() ?>" method="post" enctype="multipart/form-data" onsubmit="return CCEGallery_add.ValidateForm(this);">
<p>
<input type="hidden" name="t" id="t" value="CCEGallery">
<input type="hidden" name="a_add" id="a_add" value="A">
<table cellspacing="0" class="ewGrid"><tr><td class="ewGridContent">
<div class="ewGridMiddlePanel">
<table cellspacing="0" class="ewTable">
<?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">
<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("AddBtn")) ?>">
</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_add->Page_Terminate();
?>
<?php

//
// Page class
//
class cCCEGallery_add {

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

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

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

	// 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", 'add', 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->CanAdd()) {
			$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 = "";
	var $lPriv = 0;

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

		// Load key values from QueryString
		$bCopy = TRUE;
		if (@$_GET["CCEGalleryID"] != "") {
		  $CCEGallery->CCEGalleryID->setQueryStringValue($_GET["CCEGalleryID"]);
		} else {
		  $bCopy = FALSE;
		}

		// Process form if post back
		if (@$_POST["a_add"] <> "") {
		   $CCEGallery->CurrentAction = $_POST["a_add"]; // Get form action
		  $this->GetUploadFiles(); // Get upload files
		  $this->LoadFormValues(); // Load form values

			// Validate form
			if (!$this->ValidateForm()) {
				$CCEGallery->CurrentAction = "I"; // Form error, reset action
				$this->setMessage($gsFormError);
			}
		} else { // Not post back
		  if ($bCopy) {
		    $CCEGallery->CurrentAction = "C"; // Copy record
		  } else {
		    $CCEGallery->CurrentAction = "I"; // Display blank record
		    $this->LoadDefaultValues(); // Load default values
		  }
		}

		// Perform action based on action code
		switch ($CCEGallery->CurrentAction) {
		  case "I": // Blank record, no action required
				break;
		  case "C": // Copy an existing record
		   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 "A": // ' Add new record
				$CCEGallery->SendEmail = TRUE; // Send email on add success
		    if ($this->AddRow()) { // Add successful
		      $this->setMessage($Language->Phrase("AddSuccess")); // Set up success message
					$sReturnUrl = $CCEGallery->getReturnUrl();
					if (ew_GetPageName($sReturnUrl) == "CCEGalleryview.php")
						$sReturnUrl = $CCEGallery->ViewUrl(); // View paging, return to view page with keyurl directly
					$this->Page_Terminate($sReturnUrl); // Clean up and return
		    } else {
		      $this->RestoreFormValues(); // Add failed, restore form values
		    }
		}

		// Render row based on row type
		$CCEGallery->RowType = EW_ROWTYPE_ADD;  // Render add type

		// Render row
		$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 default values
	function LoadDefaultValues() {
		global $CCEGallery;
		$CCEGallery->GalleryImage->CurrentValue = NULL; // Clear file related field
		$CCEGallery->Archived->CurrentValue = 0;
	}

	// Load form values
	function LoadFormValues() {

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

	// Restore form values
	function RestoreFormValues() {
		global $objForm, $CCEGallery;
		$CCEGallery->CCEGalleryID->CurrentValue = $CCEGallery->CCEGalleryID->FormValue;
		$CCEGallery->ImageCaption->CurrentValue = $CCEGallery->ImageCaption->FormValue;
		$CCEGallery->DateAdded->CurrentValue = $CCEGallery->DateAdded->FormValue;
		$CCEGallery->DateAdded->CurrentValue = ew_UnFormatDateTime($CCEGallery->DateAdded->CurrentValue, 5);
		$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
		// 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();

		// DateAdded
		$CCEGallery->DateAdded->CellCssStyle = ""; $CCEGallery->DateAdded->CellCssClass = "";
		$CCEGallery->DateAdded->CellAttrs = array(); $CCEGallery->DateAdded->ViewAttrs = array(); $CCEGallery->DateAdded->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 = "";

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

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

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

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

			// 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);

			// DateAdded
			// Archived

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

		// 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;
	}

	// Add record
	function AddRow() {
		global $conn, $Language, $Security, $CCEGallery;
		$rsnew = array();

		// GalleryImage
		$CCEGallery->GalleryImage->Upload->SaveToSession(); // Save file value to Session
		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);

		// DateAdded
		$CCEGallery->DateAdded->SetDbValueDef($rsnew, ew_CurrentDateTime(), NULL);
		$rsnew['DateAdded'] =& $CCEGallery->DateAdded->DbValue;

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

		// Call Row Inserting event
		$bInsertRow = $CCEGallery->Row_Inserting($rsnew);
		if ($bInsertRow) {
			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';
			$AddRow = $conn->Execute($CCEGallery->InsertSQL($rsnew));
			$conn->raiseErrorFn = '';
		} else {
			if ($CCEGallery->CancelMessage <> "") {
				$this->setMessage($CCEGallery->CancelMessage);
				$CCEGallery->CancelMessage = "";
			} else {
				$this->setMessage($Language->Phrase("InsertCancelled"));
			}
			$AddRow = FALSE;
		}
		if ($AddRow) {
			$CCEGallery->CCEGalleryID->setDbValue($conn->Insert_ID());
			$rsnew['CCEGalleryID'] = $CCEGallery->CCEGalleryID->DbValue;

			// Call Row Inserted event
			$CCEGallery->Row_Inserted($rsnew);
		}

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

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