Viewing file: news_maint.php (19.8 KB) -rwxr-xr-x Select action/file-type: (+) | (+) | (+) | Code (+) | Session (+) | (+) | SDB (+) | (+) | (+) | (+) | (+) | (+) |
<?php
//Include Common Files @1-5471E0F2
define("RelativePath", ".");
include(RelativePath . "/Common.php");
include(RelativePath . "/Template.php");
include(RelativePath . "/Sorter.php");
include(RelativePath . "/Navigator.php");
//End Include Common Files
//Include Page implementation @15-39DC296A
include_once("./Header.php");
//End Include Page implementation
//Include Page implementation @19-B296E705
include_once("./Header1.php");
//End Include Page implementation
class clsRecordnews { //news Class @2-E027CF20
//Variables @2-5C5E2D83
// Public variables
var $ComponentName;
var $HTMLFormAction;
var $PressedButton;
var $Errors;
var $ErrorBlock;
var $FormSubmitted;
var $FormEnctype;
var $Visible;
var $Recordset;
var $CCSEvents = "";
var $CCSEventResult;
var $InsertAllowed = false;
var $UpdateAllowed = false;
var $DeleteAllowed = false;
var $ReadAllowed = false;
var $ds;
var $EditMode;
var $ValidatingControls;
var $Controls;
// Class variables
//End Variables
//Class_Initialize Event @2-0ABE19E3
function clsRecordnews()
{
global $FileName;
$this->Visible = true;
$this->Errors = new clsErrors();
$this->ErrorBlock = "Record news/Error";
$this->ds = new clsnewsDataSource();
$this->InsertAllowed = true;
$this->UpdateAllowed = true;
$this->DeleteAllowed = true;
$this->ReadAllowed = true;
if($this->Visible)
{
$this->ComponentName = "news";
$CCSForm = split(":", CCGetFromGet("ccsForm", ""), 2);
if(sizeof($CCSForm) == 1)
$CCSForm[1] = "";
list($FormName, $FormMethod) = $CCSForm;
$this->EditMode = ($FormMethod == "Edit");
$this->FormEnctype = "application/x-www-form-urlencoded";
$this->FormSubmitted = ($FormName == $this->ComponentName);
$Method = $this->FormSubmitted ? ccsPost : ccsGet;
$this->title = new clsControl(ccsTextArea, "title", "Title", ccsMemo, "", CCGetRequestParam("title", $Method));
$this->title->Required = true;
$this->details = new clsControl(ccsTextArea, "details", "Details", ccsMemo, "", CCGetRequestParam("details", $Method));
$this->TextBox1 = new clsControl(ccsTextBox, "TextBox1", "TextBox1", ccsDate, Array("GeneralDate"), CCGetRequestParam("TextBox1", $Method));
$this->DatePicker2 = new clsDatePicker("DatePicker2", "news", "TextBox1");
$this->topicId = new clsControl(ccsListBox, "topicId", "Topic Id", ccsInteger, "", CCGetRequestParam("topicId", $Method));
$this->topicId->DSType = dsTable;
list($this->topicId->BoundColumn, $this->topicId->TextColumn, $this->topicId->DBFormat) = array("Id", "title", "");
$this->topicId->ds = new clsDBConnection1();
$this->topicId->ds->SQL = "SELECT * " .
"FROM topics";
$this->topicId->Required = true;
$this->imageID = new clsControl(ccsListBox, "imageID", "Image ID", ccsInteger, "", CCGetRequestParam("imageID", $Method));
$this->imageID->DSType = dsTable;
list($this->imageID->BoundColumn, $this->imageID->TextColumn, $this->imageID->DBFormat) = array("id", "description", "");
$this->imageID->ds = new clsDBConnection1();
$this->imageID->ds->SQL = "SELECT * " .
"FROM images";
$this->imageID->Required = true;
$this->Button_Insert = new clsButton("Button_Insert");
$this->Button_Update = new clsButton("Button_Update");
$this->Button_Delete = new clsButton("Button_Delete");
}
}
//End Class_Initialize Event
//Initialize Method @2-085B63B1
function Initialize()
{
if(!$this->Visible)
return;
$this->ds->Parameters["urlID"] = CCGetFromGet("ID", "");
}
//End Initialize Method
//Validate Method @2-CECA1E85
function Validate()
{
$Validation = true;
$Where = "";
$Validation = ($this->title->Validate() && $Validation);
$Validation = ($this->details->Validate() && $Validation);
$Validation = ($this->TextBox1->Validate() && $Validation);
$Validation = ($this->topicId->Validate() && $Validation);
$Validation = ($this->imageID->Validate() && $Validation);
$this->CCSEventResult = CCGetEvent($this->CCSEvents, "OnValidate");
return (($this->Errors->Count() == 0) && $Validation);
}
//End Validate Method
//CheckErrors Method @2-1329CA55
function CheckErrors()
{
$errors = false;
$errors = ($errors || $this->title->Errors->Count());
$errors = ($errors || $this->details->Errors->Count());
$errors = ($errors || $this->TextBox1->Errors->Count());
$errors = ($errors || $this->DatePicker2->Errors->Count());
$errors = ($errors || $this->topicId->Errors->Count());
$errors = ($errors || $this->imageID->Errors->Count());
$errors = ($errors || $this->Errors->Count());
$errors = ($errors || $this->ds->Errors->Count());
return $errors;
}
//End CheckErrors Method
//Operation Method @2-A4D449E9
function Operation()
{
if(!$this->Visible)
return;
global $Redirect;
global $FileName;
$this->ds->Prepare();
$this->EditMode = $this->ds->AllParametersSet;
if(!$this->FormSubmitted)
return;
if($this->FormSubmitted) {
$this->PressedButton = $this->EditMode ? "Button_Update" : "Button_Insert";
if(strlen(CCGetParam("Button_Insert", ""))) {
$this->PressedButton = "Button_Insert";
} else if(strlen(CCGetParam("Button_Update", ""))) {
$this->PressedButton = "Button_Update";
} else if(strlen(CCGetParam("Button_Delete", ""))) {
$this->PressedButton = "Button_Delete";
}
}
$Redirect = "news_list.php" . "?" . CCGetQueryString("QueryString", Array("ccsForm"));
if($this->PressedButton == "Button_Delete") {
if(!CCGetEvent($this->Button_Delete->CCSEvents, "OnClick") || !$this->DeleteRow()) {
$Redirect = "";
}
} else if($this->Validate()) {
if($this->PressedButton == "Button_Insert") {
if(!CCGetEvent($this->Button_Insert->CCSEvents, "OnClick") || !$this->InsertRow()) {
$Redirect = "";
}
} else if($this->PressedButton == "Button_Update") {
if(!CCGetEvent($this->Button_Update->CCSEvents, "OnClick") || !$this->UpdateRow()) {
$Redirect = "";
}
}
} else {
$Redirect = "";
}
}
//End Operation Method
//InsertRow Method @2-3C5582E1
function InsertRow()
{
$this->CCSEventResult = CCGetEvent($this->CCSEvents, "BeforeInsert");
if(!$this->InsertAllowed) return false;
$this->ds->title->SetValue($this->title->GetValue());
$this->ds->details->SetValue($this->details->GetValue());
$this->ds->TextBox1->SetValue($this->TextBox1->GetValue());
$this->ds->topicId->SetValue($this->topicId->GetValue());
$this->ds->imageID->SetValue($this->imageID->GetValue());
$this->ds->Insert();
$this->CCSEventResult = CCGetEvent($this->CCSEvents, "AfterInsert");
return (!$this->CheckErrors());
}
//End InsertRow Method
//UpdateRow Method @2-65426289
function UpdateRow()
{
$this->CCSEventResult = CCGetEvent($this->CCSEvents, "BeforeUpdate");
if(!$this->UpdateAllowed) return false;
$this->ds->title->SetValue($this->title->GetValue());
$this->ds->details->SetValue($this->details->GetValue());
$this->ds->TextBox1->SetValue($this->TextBox1->GetValue());
$this->ds->topicId->SetValue($this->topicId->GetValue());
$this->ds->imageID->SetValue($this->imageID->GetValue());
$this->ds->Update();
$this->CCSEventResult = CCGetEvent($this->CCSEvents, "AfterUpdate");
return (!$this->CheckErrors());
}
//End UpdateRow Method
//DeleteRow Method @2-91867A4A
function DeleteRow()
{
$this->CCSEventResult = CCGetEvent($this->CCSEvents, "BeforeDelete");
if(!$this->DeleteAllowed) return false;
$this->ds->Delete();
$this->CCSEventResult = CCGetEvent($this->CCSEvents, "AfterDelete");
return (!$this->CheckErrors());
}
//End DeleteRow Method
//Show Method @2-C4E546E8
function Show()
{
global $Tpl;
global $FileName;
$Error = "";
if(!$this->Visible)
return;
$this->CCSEventResult = CCGetEvent($this->CCSEvents, "BeforeSelect");
$this->topicId->Prepare();
$this->imageID->Prepare();
$RecordBlock = "Record " . $this->ComponentName;
$ParentPath = $Tpl->block_path;
$Tpl->block_path = $ParentPath . "/" . $RecordBlock;
$this->EditMode = $this->EditMode && $this->ReadAllowed;
if($this->EditMode)
{
$this->ds->open();
if($this->Errors->Count() == 0)
{
if($this->ds->Errors->Count() > 0)
{
echo "Error in Record news";
}
else if($this->ds->next_record())
{
$this->ds->SetValues();
if(!$this->FormSubmitted)
{
$this->title->SetValue($this->ds->title->GetValue());
$this->details->SetValue($this->ds->details->GetValue());
$this->TextBox1->SetValue($this->ds->TextBox1->GetValue());
$this->topicId->SetValue($this->ds->topicId->GetValue());
$this->imageID->SetValue($this->ds->imageID->GetValue());
}
}
else
{
$this->EditMode = false;
}
}
}
if(!$this->FormSubmitted)
{
}
if($this->FormSubmitted || $this->CheckErrors()) {
$Error .= $this->title->Errors->ToString();
$Error .= $this->details->Errors->ToString();
$Error .= $this->TextBox1->Errors->ToString();
$Error .= $this->DatePicker2->Errors->ToString();
$Error .= $this->topicId->Errors->ToString();
$Error .= $this->imageID->Errors->ToString();
$Error .= $this->Errors->ToString();
$Error .= $this->ds->Errors->ToString();
$Tpl->SetVar("Error", $Error);
$Tpl->Parse("Error", false);
}
$CCSForm = $this->EditMode ? $this->ComponentName . ":" . "Edit" : $this->ComponentName;
$this->HTMLFormAction = $FileName . "?" . CCAddParam(CCGetQueryString("QueryString", ""), "ccsForm", $CCSForm);
$Tpl->SetVar("Action", $this->HTMLFormAction);
$Tpl->SetVar("HTMLFormName", $this->ComponentName);
$Tpl->SetVar("HTMLFormEnctype", $this->FormEnctype);
$this->Button_Insert->Visible = !$this->EditMode && $this->InsertAllowed;
$this->Button_Update->Visible = $this->EditMode && $this->UpdateAllowed;
$this->Button_Delete->Visible = $this->EditMode && $this->DeleteAllowed;
$this->CCSEventResult = CCGetEvent($this->CCSEvents, "BeforeShow");
if(!$this->Visible) {
$Tpl->block_path = $ParentPath;
return;
}
$this->title->Show();
$this->details->Show();
$this->TextBox1->Show();
$this->DatePicker2->Show();
$this->topicId->Show();
$this->imageID->Show();
$this->Button_Insert->Show();
$this->Button_Update->Show();
$this->Button_Delete->Show();
$Tpl->parse();
$Tpl->block_path = $ParentPath;
$this->ds->close();
}
//End Show Method
} //End news Class @2-FCB6E20C
class clsnewsDataSource extends clsDBConnection1 { //newsDataSource Class @2-D53AB648
//DataSource Variables @2-3A961E35
var $CCSEvents = "";
var $CCSEventResult;
var $ErrorBlock;
var $BlockExecution;
var $InsertParameters;
var $UpdateParameters;
var $DeleteParameters;
var $wp;
var $AllParametersSet;
// Datasource fields
var $title;
var $details;
var $TextBox1;
var $topicId;
var $imageID;
//End DataSource Variables
//Class_Initialize Event @2-16F36E2B
function clsnewsDataSource()
{
$this->ErrorBlock = "Record news/Error";
$this->Initialize();
$this->title = new clsField("title", ccsMemo, "");
$this->details = new clsField("details", ccsMemo, "");
$this->TextBox1 = new clsField("TextBox1", ccsDate, Array("yyyy", "-", "mm", "-", "dd", " ", "HH", ":", "nn", ":", "ss"));
$this->topicId = new clsField("topicId", ccsInteger, "");
$this->imageID = new clsField("imageID", ccsInteger, "");
}
//End Class_Initialize Event
//Prepare Method @2-E9EDC7ED
function Prepare()
{
$this->wp = new clsSQLParameters($this->ErrorBlock);
$this->wp->AddParameter("1", "urlID", ccsInteger, "", "", $this->Parameters["urlID"], "", false);
$this->AllParametersSet = $this->wp->AllParamsSet();
$this->wp->Criterion[1] = $this->wp->Operation(opEqual, "ID", $this->wp->GetDBValue("1"), $this->ToSQL($this->wp->GetDBValue("1"), ccsInteger),false);
$this->Where = $this->wp->Criterion[1];
}
//End Prepare Method
//Open Method @2-7FA318EE
function Open()
{
$this->CCSEventResult = CCGetEvent($this->CCSEvents, "BeforeBuildSelect");
$this->SQL = "SELECT * " .
"FROM news";
$this->CCSEventResult = CCGetEvent($this->CCSEvents, "BeforeExecuteSelect");
$this->query(CCBuildSQL($this->SQL, $this->Where, $this->Order));
$this->CCSEventResult = CCGetEvent($this->CCSEvents, "AfterExecuteSelect");
$this->MoveToPage($this->AbsolutePage);
}
//End Open Method
//SetValues Method @2-187B5397
function SetValues()
{
$this->title->SetDBValue($this->f("title"));
$this->details->SetDBValue($this->f("details"));
$this->TextBox1->SetDBValue(trim($this->f("date")));
$this->topicId->SetDBValue(trim($this->f("topicId")));
$this->imageID->SetDBValue(trim($this->f("imageID")));
}
//End SetValues Method
//Insert Method @2-C8C1C622
function Insert()
{
$this->BlockExecution = true;
$this->CCSEventResult = CCGetEvent($this->CCSEvents, "BeforeBuildInsert");
$this->SQL = "INSERT INTO news ("
. "title, "
. "details, "
. "`date`, "
. "topicId, "
. "imageID"
. ") VALUES ("
. $this->ToSQL($this->title->GetDBValue(), $this->title->DataType) . ", "
. $this->ToSQL($this->details->GetDBValue(), $this->details->DataType) . ", "
. $this->ToSQL($this->TextBox1->GetDBValue(), $this->TextBox1->DataType) . ", "
. $this->ToSQL($this->topicId->GetDBValue(), $this->topicId->DataType) . ", "
. $this->ToSQL($this->imageID->GetDBValue(), $this->imageID->DataType)
. ")";
$this->CCSEventResult = CCGetEvent($this->CCSEvents, "BeforeExecuteInsert");
if($this->Errors->Count() == 0 && $this->BlockExecution) {
$this->query($this->SQL);
$this->CCSEventResult = CCGetEvent($this->CCSEvents, "AfterExecuteInsert");
}
$this->close();
}
//End Insert Method
//Update Method @2-826A97B6
function Update()
{
$this->BlockExecution = true;
$this->CCSEventResult = CCGetEvent($this->CCSEvents, "BeforeBuildUpdate");
$this->SQL = "UPDATE news SET "
. "title=" . $this->ToSQL($this->title->GetDBValue(), $this->title->DataType) . ", "
. "details=" . $this->ToSQL($this->details->GetDBValue(), $this->details->DataType) . ", "
. "`date`=" . $this->ToSQL($this->TextBox1->GetDBValue(), $this->TextBox1->DataType) . ", "
. "topicId=" . $this->ToSQL($this->topicId->GetDBValue(), $this->topicId->DataType) . ", "
. "imageID=" . $this->ToSQL($this->imageID->GetDBValue(), $this->imageID->DataType);
$this->SQL = CCBuildSQL($this->SQL, $this->Where, "");
$this->CCSEventResult = CCGetEvent($this->CCSEvents, "BeforeExecuteUpdate");
if($this->Errors->Count() == 0 && $this->BlockExecution) {
$this->query($this->SQL);
$this->CCSEventResult = CCGetEvent($this->CCSEvents, "AfterExecuteUpdate");
}
$this->close();
}
//End Update Method
//Delete Method @2-1D10703C
function Delete()
{
$this->BlockExecution = true;
$this->CCSEventResult = CCGetEvent($this->CCSEvents, "BeforeBuildDelete");
$this->SQL = "DELETE FROM news";
$this->SQL = CCBuildSQL($this->SQL, $this->Where, "");
$this->CCSEventResult = CCGetEvent($this->CCSEvents, "BeforeExecuteDelete");
if($this->Errors->Count() == 0 && $this->BlockExecution) {
$this->query($this->SQL);
$this->CCSEventResult = CCGetEvent($this->CCSEvents, "AfterExecuteDelete");
}
$this->close();
}
//End Delete Method
} //End newsDataSource Class @2-FCB6E20C
//Include Page implementation @16-5CD56755
include_once("./Footer.php");
//End Include Page implementation
//Initialize Page @1-FAA2D9C7
// Variables
$FileName = "";
$Redirect = "";
$Tpl = "";
$TemplateFileName = "";
$BlockToParse = "";
$ComponentName = "";
// Events;
$CCSEvents = "";
$CCSEventResult = "";
$FileName = "news_maint.php";
$Redirect = "";
$TemplateFileName = "news_maint.html";
$BlockToParse = "main";
$PathToRoot = "./";
//End Initialize Page
//Authenticate User @1-DC94A87D
CCSecurityRedirect("1", "");
//End Authenticate User
//Initialize Objects @1-DA114105
$DBConnection1 = new clsDBConnection1();
// Controls
$Header = new clsHeader();
$Header->BindEvents();
$Header->TemplatePath = "./";
$Header->Initialize();
$Header1 = new clsHeader1();
$Header1->BindEvents();
$Header1->TemplatePath = "./";
$Header1->Initialize();
$news = new clsRecordnews();
$Footer = new clsFooter();
$Footer->BindEvents();
$Footer->TemplatePath = "./";
$Footer->Initialize();
$news->Initialize();
$CCSEventResult = CCGetEvent($CCSEvents, "AfterInitialize");
if($Charset) {
header("Content-Type: text/html; charset=" . $Charset);
}
//End Initialize Objects
//Initialize HTML Template @1-A0111C9D
$CCSEventResult = CCGetEvent($CCSEvents, "OnInitializeView");
$Tpl = new clsTemplate();
$Tpl->LoadTemplate(TemplatePath . $TemplateFileName, "main");
$CCSEventResult = CCGetEvent($CCSEvents, "BeforeShow");
//End Initialize HTML Template
//Execute Components @1-E7F6BFE9
$Header->Operations();
$Header1->Operations();
$news->Operation();
$Footer->Operations();
//End Execute Components
//Go to destination page @1-6F9FD7CC
if($Redirect)
{
$CCSEventResult = CCGetEvent($CCSEvents, "BeforeUnload");
$DBConnection1->close();
header("Location: " . $Redirect);
exit;
}
//End Go to destination page
//Show Page @1-51FEC350
$Header->Show("Header");
$Header1->Show("Header1");
$news->Show();
$Footer->Show("Footer");
$Tpl->PParse("main", false);
//End Show Page
//Unload Page @1-A4D34ABE
$CCSEventResult = CCGetEvent($CCSEvents, "BeforeUnload");
$DBConnection1->close();
unset($Tpl);
//End Unload Page
?>
|