<?php
/**
* Entier Studio
*
* LICENSE
*
* Copyright 2006 Entier Studio team.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* @package entier.studio
* @copyright Copyright (c) 2006 Entier Studio team. All rights reserved.
* @version $Id: ctrl.DictionaryProperty.php 81 2008-01-17 23:08:21Z yannromefort $
*/
//-------------------------------------------------------------------------
// Safe mode
if (!defined('__ENTIER_FRONT_CONTROLLER__')) die(403);
//
//-------------------------------------------------------------------------
// Post Handler
//
$property = NULL;
$postback = !(empty($__verb));
$success = true;
$reset = false;
//
switch ($__verb) {
case INSERT_CMD:
//
# Insert
//
@include_once (COMPONENTS_DATA . "data.DictionaryProperty.php");
//
$property = new DictionaryProperty();
//
$property->set_field_value("REPOSITPKID", $userRequest->Parameter("root"));
$property->set_field_value("DICPTYPPKID", $userRequest->Parameter("type"));
$property->set_field_value("DICPROPNAME", $userRequest->Parameter("name"));
$property->set_field_value("DICPROPCODE", $userRequest->Parameter("code"));
$property->set_field_value("DICPROPTEXT", $userRequest->Parameter("text"));
$property->set_field_value("DICPROPSTAT", $userRequest->Parameter("stat"));
$property->set_field_value("DICPROPTYPE", 1); // element property
//
$success = $property->insertRow($database);
$reset = $success;
//
break;
case UPDATE_CMD:
//
# Update
//
@include_once (COMPONENTS_DATA . "data.DictionaryProperty.php");
//
$property = new DictionaryProperty($userRequest->Parameter("pkid"));
$success = $property->selectRow($database);
if (true == $success) {
//
$reset = ($property->get_field_value("DICPROPNAME") != trim($userRequest->Parameter("name")));
//
//
$property->set_field_value("DICPROPNAME", $userRequest->Parameter("name"));
$property->set_field_value("DICPROPCODE", $userRequest->Parameter("code"));
$property->set_field_value("DICPROPTEXT", $userRequest->Parameter("text"));
$property->set_field_value("DICPROPSTAT", $userRequest->Parameter("stat"));
//
$success = $property->updateRow($database);
}
//
break;
case DELETE_CMD:
//
# Delete
//
@include_once (COMPONENTS_DATA . "data.DictionaryProperty.php");
//
$property = new DictionaryProperty($userRequest->Parameter("dkey"));
$success = $property->selectRow($database);
if (true == $success) $success = $property->deleteRow($database);
$reset = $success;
//
break;
case STATUS_CMD:
//
# Update status=0
//
@include_once (COMPONENTS_DATA . "data.DictionaryProperty.php");
//
$property = new DictionaryProperty($userRequest->Parameter("dkey"));
$success = $property->selectRow($database);
if (true == $success) $success = $property->updateRow($database, DISPLAYKEY);
//
$reset = $success;
//
break;
}
//
//-------------------------------------------------------------------------
// View Handler
//
@include_once (COMPONENTS_VIEW . "view.DictionaryPropertyExplorer.php");
//
$propertyView = new DictionaryPropertyExplorer();
//
// Mode Handler
//
$viewMode = NULLVIEW;
$viewHTML = "$__ctrl-$__view.html";
$failHTML = "$__ctrl-$__fail.html";
$formMark = "";
//
switch ($__mode) {
case "form":
//
$failMode = FORMVIEW;
//
//
$propertyView->set_field_value("REPOSITPKID", $userRequest->Parameter("root"));
$propertyView->set_field_value("DICPTYPPKID", $userRequest->Parameter("type"));
//
if (($__verb == INSERT_CMD) && (true == $success)) $propertyView->set_field_value("DICPROPPKID", $property->get_field_value("DICPROPPKID"));
//
break;
case "view":
//
$failMode = ITEMVIEW;
//
$propertyView->set_field_value("DICPROPPKID", $userRequest->Parameter("pkid"));
//
break;
}
//
// Error test
if (false == $success) {
//---------------------------------------------------------------------
// Error Handler:
//
$propertyView->set_error_value("DBERRNUMBER", $database->errorNumber());
$propertyView->set_error_value("DBERRSTRING", $database->errorString());
//
if (is_object($property)) {
// Check critical errors
if (($property->get_error_value("REPOSITPKID") == true) || ($property->get_error_value("DICPTYPPKID") == true)) {
//
$viewMode = FAILVIEW;
$viewHTML = "system.errors.html";
} else {
//
// get input errors
//
$propertyView->set_error_value("DATAERRORSET", $property->errorSet());
$propertyView->set_error_value("DATAFIELDSET", $property->fieldSet());
//
$formMark = "error";
$viewMode = $failMode;
$viewHTML = $failHTML;
}
}
//
//---------------------------------------------------------------------
} else {
//---------------------------------------------------------------------
// Reset handler
if (($postback == true) && ($reset == true)) $template->assign_global("_POSTVERB_", "$__verb");
//
// View Handler
switch ($__view) {
case "form":
//
$viewMode = FORMVIEW;
//
break;
case "view":
//
$viewMode = ITEMVIEW;
//
break;
}
//
//---------------------------------------------------------------------
}
//-------------------------------------------------------------------------
// Display View
//
if ($propertyView->renderView($database, $template, $viewHTML, $formMark, $viewMode) == false) {
if ($propertyView->get_error_count() > 0) {
//
$viewMode = FAILVIEW;
$viewHTML = "action.errors.html";
//
@include_once (FRAMEWORK_VIEW . "view.ExceptionView.php");
//
$exceptionView = new ExceptionView($propertyView->errorSet());
$exceptionView->renderView($viewHTML, $formMark, $viewMode);
}
}
//
//-------------------------------------------------------------------------
?>