Location: PHPKode > projects > Entier Studio > entierstudio/office/classes/views/view.DirectoryProjectExplorer.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.DirectoryProjectExplorer.php 81 2008-01-17 23:08:21Z yannromefort $
 */
//-----------------------------------------------------------------------------
//	namespace
if (!defined("DefDirectoryProjectExplorer")) {
    //-------------------------------------------------------------------------
    //	Define
    define("DefDirectoryProjectExplorer", "1");
    //-------------------------------------------------------------------------
    //	Include
    @require_once (FRAMEWORK_DIR . VIEWHELPER);
    //-------------------------------------------------------------------------
    //	Class
    class DirectoryProjectExplorer extends ViewObject {
        //---------------------------------------------------------------------
        //	Constructor
        
        /**
         *
         * @param	object	Instance of ViewTemplate
         * @param	object	Instance of DataSource
         */
        function DirectoryProjectExplorer($template, $database) {
            //
            parent::ViewObject($template, $database);
        }
        //---------------------------------------------------------------------
        //	Methods
        
        /**
         *
         * @access	public
         *
         * @return	object
         */
        function getObject() {
            //
            @include_once (COMPONENTS_DATA . "data.DirectoryProject.php");
            //
            return (new DirectoryProject);
        }
        /**
         *
         * @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 DirectoryProject-form.php
                    */
                    //
                    /*
                    * 1- RepositoryCoreElementType
                    * 2- DirectoryOrganisationSet
                    * 3- ApplicationCodificationSet
                    * 4- ObjectoryTypeSet
                    */
                    //
                    /*
                    * 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- DirectoryOrganisationSet Dropdownlist
                    */
                    //
                    if ($user->get_authorization(AUTH_SITE_SUPER)) {
                        //
                        @include_once (COMPONENTS_DATA . "data.DirectoryUnitSet.php");
                        //
                        $organizationSet = new DirectoryUnitSet($user->get_field_value("DIRECTOPKID"));
                        if ($organizationSet->selectSet($this->Database()) == false) {
                            //
                            $this->m_errorSet[HTML_OBJECT_ERROR] = true;
                            //
                            return (false);
                        }
                        //
                        @include_once (FRAMEWORK_DIR . "htmldropdownlist.php");
                        //
                        $organizationSetDDL = new HTMLDropdownList("fkid", "formInput", false);
                        $this->m_blockSet["DIRUNITLIST"] = $organizationSetDDL->renderObject($this->Database() , $organizationSet, $user->get_field_value("DIRUNITPKID"));
                        //
                        unset($organizationSetDDL);
                        unset($organizationSet);
                    }
                    //
                    /*
                    * 3- 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);
                    //
                    unset($codificationSetDDL);
                    unset($codificationSet);
                    //
                    /*
                    * 4- ObjectoryTypeSet
                    */
                    //
                    @include_once (COMPONENTS_DATA . "data.ObjectoryTypeSet.php");
                    //
                    $objectoryTypeSet = new ObjectoryTypeSet($user->get_field_value("DIRECTOPKID"));
                    if ($objectoryTypeSet->selectSet($this->Database() , FOREIGNKEY, $this->m_fieldSet["LISTVIEWSRT"], $this->m_fieldSet["LISTVIEWORD"]) == false) {
                        //
                        $this->m_errorSet[ObjectoryTypeSet] = true;
                        //
                        return (false);
                    }
                    //
                    $objectoryTypeSetDDL = new HTMLDropdownList("root", "formInput", false);
                    $this->m_blockSet["REPOSITLIST"] = $objectoryTypeSetDDL->renderObject($this->Database() , $objectoryTypeSet, 1);
                    //
                    unset($objectoryTypeSetDDL);
                    unset($objectoryTypeSet);
                    //
                    $this->m_Template->assign($this->m_blockSet);
                    //
                    
                break;
                case ITEMVIEW:
                    /*
                    * @see handler DirectoryProject-view.php
                    */
                    //
                    /*
                    * 1- DirectoryProject
                    * 2- ApplicationCodificationSet
                    */
                    //
                    /*
                    * 1- DirectoryProject
                    */
                    //
                    @include_once (COMPONENTS_DATA . "data.DirectoryProject.php");
                    //
                    $project = new DirectoryProject($this->m_fieldSet["DIRPROJPKID"]);
                    if ($project->selectRow($this->Database()) == false) {
                        //
                        $this->m_errorSet[VIEW_OBJECT_ERROR] = true;
                        //
                        return (false);
                    }
                    //
                    $this->m_Template->assign($project->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, $project->get_field_value("DIRPROJSTAT"));
                    //
                    $this->m_Template->assign($this->m_blockSet);
                    //
                    //
                    
                break;
                case LISTVIEW:
                    /*
                    * @see handler DirectoryProject-list.php
                    */
                    //
                    /*
                    * 1- DirectoryUser
                    * 2- DirectoryProjectSet
                    */
                    //
                    /*
                    * 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_PROJ_CREATE));
                    //
                    /*
                    * 2- DirectoryProjectSet
                    */
                    //
                    @include_once (COMPONENTS_DATA . "data.DirectoryProjectUserSet.php");
                    //
                    $projectSet = new DirectoryProjectUserSet(NOTSET_KEY, $user->get_field_value("DIRUSERPKID"));
                    if ($projectSet->selectSet($this->Database() , FOREIGNKEY, $this->m_fieldSet["LISTVIEWSRT"], $this->m_fieldSet["LISTVIEWORD"]) == true) {
                        //
                        for ($i = 0;$i < $projectSet->rowCount();$i++) {
                            //	select row
                            if ($projectSet->fetchCursorRow($this->Database()) == false) return (false);
                            //
                            $this->m_Template->select($block);
                            $this->m_Template->assign($projectSet->fieldSet());
                            $this->m_Template->render($block);
                        }
                    }
                    //
                    break;
                case GRIDVIEW:
                    /*
                    * @see handler DirectoryProject-grid.php
                    */
                    /*
                    * 1- DirectoryUser
                    * 2- DirectoryProjectSet
                    */
                    //
                    /*
                    * 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- DirectoryProjectSet
                    */
                    //
                    @include_once (COMPONENTS_DATA . "data.DirectoryProjectSet.php");
                    //
                    $projectSet = new DirectoryProjectSet($this->m_fieldSet["DIRUNITPKID"]);
                    if ($projectSet->selectSet($this->Database() , FOREIGNKEY, $this->m_fieldSet["LISTVIEWSRT"], $this->m_fieldSet["LISTVIEWORD"]) == true) {
                        //
                        for ($i = 0;$i < $projectSet->rowCount();$i++) {
                            //	select row
                            if ($projectSet->fetchCursorRow($this->Database()) == false) return (false);
                            //
                            $this->m_Template->select($block);
                            $this->m_Template->assign($projectSet->fieldSet());
                            $this->m_Template->render($block);
                        }
                    }
                    //
                    break;
                case TREEVIEW:
                    /*
                    * @see handler DirectoryProject-tree.php
                    */
                    //
                    break;
                case FRAMEVIEW:
                    /*
                    * * @see handler DirectoryProject-frame.php
                    */
                    /*
                    * 1- DirectoryUser
                    */
                    //
                    @include_once (COMPONENTS_DATA . "data.DirectoryUser.php");
                    //
                    $user = new DirectoryUser($this->m_fieldSet["DIRUSERPKID"]);
                    if ($user->selectRow($this->Database()) == false) {
                        //
                        $this->m_errorSet[VIEW_OBJECT_ERROR] = true;
                        //
                        return (false);
                    }
                    //
                    $this->m_Template->assign($user->fieldSet());
                    //
                    break;
                }
                //
                $this->m_Template->output($mode);
                //
                return (true);
            }
    };
    //	Class
    //-------------------------------------------------------------------------
    
}
//	namespace
//-----------------------------------------------------------------------------
?>
Return current item: Entier Studio