Viewing file: linkovi_maint.php (17.95 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 @12-39DC296A
include_once("./Header.php");
//End Include Page implementation
class clsRecordlinkovi { //linkovi Class @2-2347AF91
//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-2E78F9CB
function clsRecordlinkovi()
{
global $FileName;
$this->Visible = true;
$this->Errors = new clsErrors();
$this->ErrorBlock = "Record linkovi/Error";
$this->ds = new clslinkoviDataSource();
$this->InsertAllowed = true;
$this->UpdateAllowed = true;
$this->DeleteAllowed = true;
$this->ReadAllowed = true;
if($this->Visible)
{
$this->ComponentName = "linkovi";
$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->naziv_linka = new clsControl(ccsTextArea, "naziv_linka", "Naziv Linka", ccsMemo, "", CCGetRequestParam("naziv_linka", $Method));
$this->naziv_linka->Required = true;
$this->opis_linka = new clsControl(ccsTextArea, "opis_linka", "Opis Linka", ccsMemo, "", CCGetRequestParam("opis_linka", $Method));
$this->opis_linka->Required = true;
$this->link = new clsControl(ccsTextBox, "link", "Link", ccsText, "", CCGetRequestParam("link", $Method));
$this->link->Required = true;
$this->kategorija = new clsControl(ccsTextBox, "kategorija", "Kategorija", ccsInteger, "", CCGetRequestParam("kategorija", $Method));
$this->kategorija->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-65FFA524
function Initialize()
{
if(!$this->Visible)
return;
$this->ds->Parameters["urlId_linka"] = CCGetFromGet("Id_linka", "");
}
//End Initialize Method
//Validate Method @2-16888117
function Validate()
{
$Validation = true;
$Where = "";
$Validation = ($this->naziv_linka->Validate() && $Validation);
$Validation = ($this->opis_linka->Validate() && $Validation);
$Validation = ($this->link->Validate() && $Validation);
$Validation = ($this->kategorija->Validate() && $Validation);
$this->CCSEventResult = CCGetEvent($this->CCSEvents, "OnValidate");
return (($this->Errors->Count() == 0) && $Validation);
}
//End Validate Method
//CheckErrors Method @2-D7BFA732
function CheckErrors()
{
$errors = false;
$errors = ($errors || $this->naziv_linka->Errors->Count());
$errors = ($errors || $this->opis_linka->Errors->Count());
$errors = ($errors || $this->link->Errors->Count());
$errors = ($errors || $this->kategorija->Errors->Count());
$errors = ($errors || $this->Errors->Count());
$errors = ($errors || $this->ds->Errors->Count());
return $errors;
}
//End CheckErrors Method
//Operation Method @2-42937D18
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 = "linkovi_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-BF17FB8D
function InsertRow()
{
$this->CCSEventResult = CCGetEvent($this->CCSEvents, "BeforeInsert");
if(!$this->InsertAllowed) return false;
$this->ds->naziv_linka->SetValue($this->naziv_linka->GetValue());
$this->ds->opis_linka->SetValue($this->opis_linka->GetValue());
$this->ds->link->SetValue($this->link->GetValue());
$this->ds->kategorija->SetValue($this->kategorija->GetValue());
$this->ds->Insert();
$this->CCSEventResult = CCGetEvent($this->CCSEvents, "AfterInsert");
return (!$this->CheckErrors());
}
//End InsertRow Method
//UpdateRow Method @2-AB237D16
function UpdateRow()
{
$this->CCSEventResult = CCGetEvent($this->CCSEvents, "BeforeUpdate");
if(!$this->UpdateAllowed) return false;
$this->ds->naziv_linka->SetValue($this->naziv_linka->GetValue());
$this->ds->opis_linka->SetValue($this->opis_linka->GetValue());
$this->ds->link->SetValue($this->link->GetValue());
$this->ds->kategorija->SetValue($this->kategorija->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-04B00A21
function Show()
{
global $Tpl;
global $FileName;
$Error = "";
if(!$this->Visible)
return;
$this->CCSEventResult = CCGetEvent($this->CCSEvents, "BeforeSelect");
$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 linkovi";
}
else if($this->ds->next_record())
{
$this->ds->SetValues();
if(!$this->FormSubmitted)
{
$this->naziv_linka->SetValue($this->ds->naziv_linka->GetValue());
$this->opis_linka->SetValue($this->ds->opis_linka->GetValue());
$this->link->SetValue($this->ds->link->GetValue());
$this->kategorija->SetValue($this->ds->kategorija->GetValue());
}
}
else
{
$this->EditMode = false;
}
}
}
if(!$this->FormSubmitted)
{
}
if($this->FormSubmitted || $this->CheckErrors()) {
$Error .= $this->naziv_linka->Errors->ToString();
$Error .= $this->opis_linka->Errors->ToString();
$Error .= $this->link->Errors->ToString();
$Error .= $this->kategorija->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->naziv_linka->Show();
$this->opis_linka->Show();
$this->link->Show();
$this->kategorija->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 linkovi Class @2-FCB6E20C
class clslinkoviDataSource extends clsDBConnection1 { //linkoviDataSource Class @2-9881A718
//DataSource Variables @2-A832E191
var $CCSEvents = "";
var $CCSEventResult;
var $ErrorBlock;
var $BlockExecution;
var $InsertParameters;
var $UpdateParameters;
var $DeleteParameters;
var $wp;
var $AllParametersSet;
// Datasource fields
var $naziv_linka;
var $opis_linka;
var $link;
var $kategorija;
//End DataSource Variables
//Class_Initialize Event @2-7B4DB617
function clslinkoviDataSource()
{
$this->ErrorBlock = "Record linkovi/Error";
$this->Initialize();
$this->naziv_linka = new clsField("naziv_linka", ccsMemo, "");
$this->opis_linka = new clsField("opis_linka", ccsMemo, "");
$this->link = new clsField("link", ccsText, "");
$this->kategorija = new clsField("kategorija", ccsInteger, "");
}
//End Class_Initialize Event
//Prepare Method @2-1BE35D73
function Prepare()
{
$this->wp = new clsSQLParameters($this->ErrorBlock);
$this->wp->AddParameter("1", "urlId_linka", ccsInteger, "", "", $this->Parameters["urlId_linka"], "", false);
$this->AllParametersSet = $this->wp->AllParamsSet();
$this->wp->Criterion[1] = $this->wp->Operation(opEqual, "Id_linka", $this->wp->GetDBValue("1"), $this->ToSQL($this->wp->GetDBValue("1"), ccsInteger),false);
$this->Where = $this->wp->Criterion[1];
}
//End Prepare Method
//Open Method @2-31C8CF01
function Open()
{
$this->CCSEventResult = CCGetEvent($this->CCSEvents, "BeforeBuildSelect");
$this->SQL = "SELECT * " .
"FROM linkovi";
$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-E80F16DE
function SetValues()
{
$this->naziv_linka->SetDBValue($this->f("naziv_linka"));
$this->opis_linka->SetDBValue($this->f("opis_linka"));
$this->link->SetDBValue($this->f("link"));
$this->kategorija->SetDBValue(trim($this->f("kategorija")));
}
//End SetValues Method
//Insert Method @2-CB7C5EF6
function Insert()
{
$this->BlockExecution = true;
$this->CCSEventResult = CCGetEvent($this->CCSEvents, "BeforeBuildInsert");
$this->SQL = "INSERT INTO linkovi ("
. "naziv_linka, "
. "opis_linka, "
. "link, "
. "kategorija"
. ") VALUES ("
. $this->ToSQL($this->naziv_linka->GetDBValue(), $this->naziv_linka->DataType) . ", "
. $this->ToSQL($this->opis_linka->GetDBValue(), $this->opis_linka->DataType) . ", "
. $this->ToSQL($this->link->GetDBValue(), $this->link->DataType) . ", "
. $this->ToSQL($this->kategorija->GetDBValue(), $this->kategorija->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-3718C9A9
function Update()
{
$this->BlockExecution = true;
$this->CCSEventResult = CCGetEvent($this->CCSEvents, "BeforeBuildUpdate");
$this->SQL = "UPDATE linkovi SET "
. "naziv_linka=" . $this->ToSQL($this->naziv_linka->GetDBValue(), $this->naziv_linka->DataType) . ", "
. "opis_linka=" . $this->ToSQL($this->opis_linka->GetDBValue(), $this->opis_linka->DataType) . ", "
. "link=" . $this->ToSQL($this->link->GetDBValue(), $this->link->DataType) . ", "
. "kategorija=" . $this->ToSQL($this->kategorija->GetDBValue(), $this->kategorija->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-86E25C46
function Delete()
{
$this->BlockExecution = true;
$this->CCSEventResult = CCGetEvent($this->CCSEvents, "BeforeBuildDelete");
$this->SQL = "DELETE FROM linkovi";
$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 linkoviDataSource Class @2-FCB6E20C
//Include Page implementation @13-5CD56755
include_once("./Footer.php");
//End Include Page implementation
//Initialize Page @1-E247D5AD
// Variables
$FileName = "";
$Redirect = "";
$Tpl = "";
$TemplateFileName = "";
$BlockToParse = "";
$ComponentName = "";
// Events;
$CCSEvents = "";
$CCSEventResult = "";
$FileName = "linkovi_maint.php";
$Redirect = "";
$TemplateFileName = "linkovi_maint.html";
$BlockToParse = "main";
$PathToRoot = "./";
//End Initialize Page
//Authenticate User @1-DC94A87D
CCSecurityRedirect("1", "");
//End Authenticate User
//Initialize Objects @1-3F17C8F1
$DBConnection1 = new clsDBConnection1();
// Controls
$Header = new clsHeader();
$Header->BindEvents();
$Header->TemplatePath = "./";
$Header->Initialize();
$linkovi = new clsRecordlinkovi();
$Footer = new clsFooter();
$Footer->BindEvents();
$Footer->TemplatePath = "./";
$Footer->Initialize();
$linkovi->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-EAB353F0
$Header->Operations();
$linkovi->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-A538D532
$Header->Show("Header");
$linkovi->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
?>
|