Location: PHPKode > projects > Entier Studio > entierstudio/office/classes/views/view.DirectoryUnitExplorer.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.office
 * @copyright  Copyright (c) 2006 Entier Studio team. All rights reserved.
 * @version	   $Id: view.DirectoryUnitExplorer.php 81 2008-01-17 23:08:21Z yannromefort $
 */
//-----------------------------------------------------------------------------
//	namespace
if (!defined("DefDirectoryUnitExplorer")) {
    //-------------------------------------------------------------------------
    //	Define
    define("DefDirectoryUnitExplorer", "1");
    //-------------------------------------------------------------------------
    //	Include
    @require_once (FRAMEWORK_DIR . VIEWHELPER);
    //-------------------------------------------------------------------------
    //	Class
    class DirectoryUnitExplorer extends ViewObject {
        //---------------------------------------------------------------------
        //	Constructor
        
        /**
         *
         * @param	object	Instance of ViewTemplate
         * @param	object	Instance of DataSource
         */
        function DirectoryUnitExplorer($template, $database) {
            //
            parent::ViewObject($template, $database);
        }
        //---------------------------------------------------------------------
        //	Methods
        
        /**
         *
         * @access	public
         *
         * @return	object
         */
        function getObject() {
            //
            @include_once (COMPONENTS_DATA . "data.DirectoryUnit.php");
            //
            return (new DirectoryUnit);
        }
        /**
         *
         * @access	public
         *
         * @param	string	layout name is a template file name or a layer name in a template file
         * @param	string	block name in layout
         * @param	integer	view type	{ ITEMVIEW, LISTVIEW, TREEVIEW }
         * @param	integer	outputmode
         * @return	boolean
         */
        function renderView($layout, $block = NULL, $view = NULL, $mode = OUTPUT) {
            //
            if (!is_object($this->Template())) return (false);
            //
            if (isset($layout) && ($this->m_Template->define($layout) == false)) return (false);
            //
            /*
            * *- Error management
            */
            //
            if ($this->get_error_count() > 0) {
                //
                include_once (FRAMEWORK_VIEW . "view.ErrorMessage.php");
                //
                $errorMessage = new ErrorMessage($this->errorSet());
                if ($errorMessage->renderView($this->m_Template, $block, $view) == false) {
                    //
                    $this->m_errorSet[VIEW_RENDER_ERROR] = true;
                    //
                    return (false);
                }
            }
            //
            switch ($view) {
                case FORMVIEW:
                    /*
                    * @see handler DirectoryUnit-form.php
                    */
                    //
                    /*
                    * 1- DirectoryUser
                    * 2- ApplicationCodificationSet
                    //
                    /*
                    * 1- DirectoryUser
                    */
                    //
                    @include_once (COMPONENTS_DATA . "data.DirectoryUser.php");
                    //
                    $user = new DirectoryUser($this->m_fieldSet["LOGUSERPKID"]);
                    if ($user->selectRow($this->Database()) == false) {
                        //
                        $this->m_errorSet[VIEW_OBJECT_ERROR] = true;
                        //
                        return (false);
                    }
                    //
                    $this->m_Template->assign($user->fieldSet());
                    $this->m_Template->assign($this->m_fieldSet);
                    //
                    /*
                    * 2- ApplicationCodificationSet
                    */
                    //
                    @include_once (COMPONENTS_HTML . "html.ApplicationCodificationDDL.php");
                    //
                    $codificationSet = NULL;
                    $codificationSetDDL = new ApplicationCodificationDDL("stat", "formInput", 1);
                    $this->m_blockSet["DIRSTATLIST"] = $codificationSetDDL->renderObject($this->Database() , $codificationSet, 1);
                    //
                    $this->m_Template->assign($this->m_blockSet);
                    //
                    
                break;
                case ITEMVIEW:
                    /*
                    * @see handler DirectoryUnit-view.php
                    */
                    //
                    /*
                    * 1- DirectoryUnit
                    * 2- ApplicationCodificationSet
                    //
                    /*
                    * 1- DirectoryUnit
                    */
                    //
                    @include_once (COMPONENTS_DATA . "data.DirectoryUnit.php");
                    //
                    $organization = new DirectoryUnit($this->m_fieldSet["DIRUNITPKID"]);
                    if ($organization->selectRow($this->Database()) == false) {
                        //
                        $this->m_errorSet[DirectoryUnit] = true;
                        //
                        return (false);
                    }
                    //
                    $this->m_Template->assign($organization->fieldSet());
                    $this->m_Template->assign($this->m_fieldSet);
                    //
                    /*
                    * 2- ApplicationCodificationSet
                    */
                    //
                    @include_once (COMPONENTS_HTML . "html.ApplicationCodificationDDL.php");
                    //
                    $codificationSet = NULL;
                    $codificationSetDDL = new ApplicationCodificationDDL("stat", "formInput", 1);
                    $this->m_blockSet["DIRSTATLIST"] = $codificationSetDDL->renderObject($this->Database() , $codificationSet, $organization->get_field_value("DIRUNITSTAT"));
                    //
                    $this->m_Template->assign($this->m_blockSet);
                    //
                    
                break;
                case LISTVIEW:
                    /*
                    * @see handler DirectoryProject-list.php
                    */
                    //
                    /*
                    * 1- DirectoryUser
                    * 2- DirectoryUnitSet
                    */
                    //
                    /*
                    * 1- DirectoryUser
                    */
                    //
                    @include_once (COMPONENTS_DATA . "data.DirectoryUser.php");
                    //
                    $user = new DirectoryUser($this->m_fieldSet["LOGUSERPKID"]);
                    if ($user->selectRow($this->Database()) == false) {
                        //
                        $this->m_errorSet[VIEW_OBJECT_ERROR] = true;
                        //
                        return (false);
                    }
                    //
                    $this->m_Template->assign($user->fieldSet());
                    $this->m_Template->assign($this->m_fieldSet);
                    //
                    $this->m_Template->toggle("create", $user->get_authorization(AUTH_ORGN_CREATE));
                    //
                    /*
                    * 2- DirectoryUnitSet
                    */
                    //
                    @include_once (COMPONENTS_DATA . "data.DirectoryUnitSet.php");
                    //
                    $organizationSet = new DirectoryUnitSet($user->get_field_value("DIRECTOPKID"));
                    if ($organizationSet->selectSet($this->Database() , FOREIGNKEY, $this->m_fieldSet["LISTVIEWSRT"], $this->m_fieldSet["LISTVIEWORD"]) == true) {
                        //
                        for ($i = 0;$i < $organizationSet->rowCount();$i++) {
                            //	select row
                            if ($organizationSet->fetchCursorRow($this->Database()) == false) return (false);
                            //
                            $this->m_Template->select($block);
                            $this->m_Template->assign($organizationSet->fieldSet());
                            $this->m_Template->render($block);
                        }
                    }
                    //
                    break;
                }
                //
                $this->m_Template->output($mode);
                //
                return (true);
        }
    };
    //	Class
    //-------------------------------------------------------------------------
    
}
//	namespace
//-----------------------------------------------------------------------------
?>
Return current item: Entier Studio