Location: PHPKode > projects > Entier Studio > entierstudio/studio/handlers/ctrl.ObjectoryResource.php
<?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.ObjectoryResource.php 81 2008-01-17 23:08:21Z yannromefort $
 */
//-------------------------------------------------------------------------
// Safe mode
if (!defined('__ENTIER_FRONT_CONTROLLER__')) die(403);
//
//-------------------------------------------------------------------------
//	Post Handler
//
$resource = NULL;
$postback = !(empty($__verb));
$success = true;
$reset = false;
//
switch ($__verb) {
    case INSERT_CMD:
        //
        # Insert
        //
        @include_once (COMPONENTS_DATA . "data.ObjectoryResource.php");
        //
        $resource = new ObjectoryResource();
        //
        $resource->set_field_value("DIRPROJPKID", $userRequest->Parameter("fkid"));
        $resource->set_field_value("DIRRESOPKID", $userRequest->Parameter("list"));
        $resource->set_field_value("OBJRESONAME", $userRequest->Parameter("name"));
        $resource->set_field_value("OBJRESOTEXT", $userRequest->Parameter("text"));
        $resource->set_field_value("OBJRURLHOST", $userRequest->Parameter("host"));
        $resource->set_field_value("OBJRURLPORT", $userRequest->Parameter("port"));
        $resource->set_field_value("OBJRURLNAME", $userRequest->Parameter("base"));
        $resource->set_field_value("OBJRURLUSER", $userRequest->Parameter("ulog"));
        $resource->set_field_value("OBJRURLPASS", $userRequest->Parameter("pass"));
        $resource->set_field_value("OBJRESOSTAT", $userRequest->Parameter("stat"));
        //
        $success = $resource->insertRow($database);
        $reset = $success;
        //
        
    break;
    case UPDATE_CMD:
        //
        @include_once (COMPONENTS_DATA . "data.ObjectoryResource.php");
        //
        $resource = new ObjectoryResource($userRequest->Parameter("pkid"));
        $success = $resource->selectRow($database);
        if (true == $success) {
            //
            $reset = ($resource->get_field_value("OBJRESONAME") != trim($userRequest->Parameter("name")));
            //
            $resource->set_field_value("OBJRESONAME", $userRequest->Parameter("name"));
            $resource->set_field_value("OBJRESOTEXT", $userRequest->Parameter("text"));
            $resource->set_field_value("OBJRURLNAME", $userRequest->Parameter("base"));
            $resource->set_field_value("OBJRURLHOST", $userRequest->Parameter("host"));
            $resource->set_field_value("OBJRURLPORT", $userRequest->Parameter("port"));
            $resource->set_field_value("OBJRURLUSER", $userRequest->Parameter("ulog"));
            $resource->set_field_value("OBJRURLPASS", $userRequest->Parameter("pass"));
            $resource->set_field_value("OBJRESOSTAT", $userRequest->Parameter("stat"));
            //
            $success = $resource->updateRow($database);
        }
        //
        
    break;
    case DELETE_CMD:
        //
        # Delete
        //
        @include_once (COMPONENTS_DATA . "data.ObjectoryResource.php");
        //
        $resource = new ObjectoryResource($userRequest->Parameter("dkey"));
        $success = $resource->selectRow($database);
        if (true == $success) $success = $resource->deleteRow($database);
        $reset = $success;
        //
        break;
    case STATUS_CMD:
        //
        # Update status=0
        //
        @include_once (COMPONENTS_DATA . "data.ObjectoryResource.php");
        //
        $resource = new ObjectoryResource($userRequest->Parameter("dkey"));
        $success = $resource->selectRow($database);
        if (true == $success) $success = $resource->updateRow($database, DISPLAYKEY);
        $reset = $success;
        //
        break;
    }
    //
    //-------------------------------------------------------------------------
    //	View Handler
    //
    @include_once (COMPONENTS_VIEW . "view.ObjectoryResourceExplorer.php");
    //
    $resourceView = new ObjectoryResourceExplorer();
    //
    //	Mode Handler
    //
    $viewMode = NULLVIEW;
    $failMode = NULLVIEW;
    $viewHTML = "";
    $failHTML = "";
    $formMark = "";
    //
    switch ($__mode) {
        case "form":
            //
            $failMode = FORMVIEW;
            $failHTML = "$__ctrl-$__fail.$type.html";
            //
            $resourceView->set_field_value("DIRPUSRPKID", $userRequest->Parameter("__user"));
            $resourceView->set_field_value("DIRRESTPKID", $userRequest->Parameter("type"));
            //
            if (($__verb == INSERT_CMD) && (true == $success)) $resourceView->set_field_value("OBJRESOPKID", $resource->get_field_value("OBJRESOPKID"));
            //
            break;
        case "view":
            //
            $failMode = ITEMVIEW;
            $failHTML = "$__ctrl-$__view.$type.html";
            //
            $resourceView->set_field_value("OBJRESOPKID", $userRequest->Parameter("pkid"));
            $resourceView->set_field_value("OBJRESOTEST", $userRequest->Parameter("test"));
            //
            break;
        }
        //
        //	Error test
        if (false == $success) {
            //---------------------------------------------------------------------
            //	Error Handler:
            //
            $resourceView->set_error_value("DBERRNUMBER", $database->errorNumber());
            $resourceView->set_error_value("DBERRSTRING", $database->errorString());
            //
            if (is_object($resource)) {
                // Check critical errors
                if (($resource->get_error_value("DIRRESTPKID") == true)) {
                    //
                    $viewMode = FAILVIEW;
                    $viewHTML = "system.errors.html";
                } else {
                    //
                    // get input errors
                    //
                    $resourceView->set_error_value("DATAERRORSET", $resource->errorSet());
                    $resourceView->set_error_value("DATAFIELDSET", $resource->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;
                    $viewHTML = "$__ctrl-$__view.$type.html";
                    //
                    
                break;
                case "view":
                case "pane":
                    //
                    $viewMode = ITEMVIEW;
                    $viewHTML = "$__ctrl-$__view.$type.html";
                    //
                    
                break;
            }
            //
            //---------------------------------------------------------------------
            
        }
        //-------------------------------------------------------------------------
        //	Display View
        //
        if ($resourceView->renderView($database, $template, $viewHTML, $formMark, $viewMode) == false) {
            if ($resourceView->get_error_count() > 0) {
                //
                $viewMode = FAILVIEW;
                $viewHTML = "action.errors.html";
                //
                @include_once (FRAMEWORK_VIEW . "view.ExceptionView.php");
                //
                $exceptionView = new ExceptionView($resourceView->errorSet());
                $exceptionView->renderView($viewHTML, $formMark, $viewMode);
            }
        }
        //
        //-------------------------------------------------------------------------
        
?>
Return current item: Entier Studio