Location: PHPKode > projects > Entier Studio > entierstudio/studio/classes/views/view.DirectoryResourceExplorer.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: view.DirectoryResourceExplorer.php 81 2008-01-17 23:08:21Z yannromefort $
 */
//-----------------------------------------------------------------------------
//	namespace
if (!defined("DefDirectoryResourceExplorer")) {
    //-------------------------------------------------------------------------
    //	Define
    define("DefDirectoryResourceExplorer", "1");
    //
    DEFINE(DATARESOURCE, 1);
    DEFINE(HOSTRESOURCE, 2);
    //-------------------------------------------------------------------------
    //	Include
    @require_once (FRAMEWORK_DIR . VIEWHELPER);
    //-------------------------------------------------------------------------
    //	Class
    class DirectoryResourceExplorer extends ViewObject {
        //---------------------------------------------------------------------
        //	Constructor
        
        /**
         *
         * @param	integer	 Directory	pkid			//	foreign key
         *
         */
        function DirectoryResourceExplorer() {
        }
        //---------------------------------------------------------------------
        //	Methods
        /*
        *
        * @access	private
        *
        * @param	object	DataSource object
        * @param	object	ViewTemplate object
        * @param	string	layout name is a template file name or a layer name in a template file
        * @param	string	block name in layout
        *
        */
        function renderTree(&$datasource, &$template, $block, $value) {
            //
            $elementSet = new ObjectoryElementSet($this->m_fieldSet["DIRPROJPKID"], $value);
            if ($elementSet->selectSet($datasource, REFLECTKEY) == true) {
                //
                for ($i = 0;$i < $elementSet->rowCount();$i++) {
                    //	select next ObjectoryElementSet row
                    if ($elementSet->fetchCursorRow($datasource) == false) return (false);
                    //
                    $template->select($block);
                    $template->assign($elementSet->fieldSet());
                    $template->render($block);
                    //	select ObjectoryElementSet dependent rows
                    if ($this->renderTree($datasource, $template, $block, $elementSet->get_field_value("OBJELEMPKID")) == false) return (false);
                }
            }
            //
            return (true);
        }
        /*
        *
        * @access	public
        *
        * @param	object	DataSource object
        * @param	object	ViewTemplate object
        * @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	{ FORMVIEW, ITEMVIEW, LISTVIEW, TREEVIEW... }
        * @param	integer	outputmode
        *
        */
        function renderView(&$datasource, &$template, $layout, $block, $view = NULL, $mode = OUTPUT) {
            //
            if (!is_object($template)) return (false);
            //
            if (($mode == OUTPUT) && ($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($template, $block, $view) == false) {
                    //
                    $this->m_errorSet[VIEW_RENDER_ERROR] = true;
                    //
                    return (false);
                }
            }
            //
            $template->assign($this->m_fieldSet);
            //
            @include_once (FRAMEWORK_DIR . "htmldropdownlist.php");
            //
            switch ($view) {
                case FORMVIEW:
                    /*
                    * * @see handler DirectoryResource-form.php
                    */
                    //
                    /*
                    * 1- Directory
                    * 2- DirectoryResourceAccessSet
                    * 3- ApplicationCodificationSet
                    */
                    //
                    /*
                    * 1- Directory
                    */
                    //
                    @include_once (COMPONENTS_DATA . "data.Directory.php");
                    //
                    $directory = new CurrentDirectory($this->m_fieldSet["DIRECTOPKID"]);
                    if ($directory->selectRow($datasource) == false) {
                        //
                        $this->m_errorSet[VIEW_OBJECT_ERROR] = true;
                        return (false);
                    }
                    //
                    $template->assign($directory->fieldSet());
                    //
                    /*
                    * 2- DirectoryResourceAccessSet Dropdownlist
                    */
                    //
                    @include_once (COMPONENTS_DATA . "data.DirectoryResourceAccessSet.php");
                    //
                    $accessSet = new DirectoryResourceAccessSet($this->m_fieldSet["DIRRESTPKID"]);
                    if ($accessSet->selectSet($datasource, FOREIGNKEY) == false) {
                        //
                        $this->m_errorSet[VIEW_OBJECT_ERROR] = true;
                        //
                        return (false);
                    }
                    //
                    $accessSetDDL = new HTMLDropdownList("list", "formInput");
                    $this->m_blockSet["DIRRACCLIST"] = $accessSetDDL->renderObject($datasource, $accessSet);
                    //
                    /*
                    * 3- ApplicationCodificationSet Dropdownlist
                    */
                    //
                    @include_once (COMPONENTS_HTML . "html.ApplicationCodificationDDL.php");
                    //
                    $codificationSet = NULL;
                    $codificationSetDDL = new ApplicationCodificationDDL("stat", "formInput", 1);
                    $this->m_blockSet["DIRSTATLIST"] = $codificationSetDDL->renderObject($datasource, $codificationSet, 1);
                    //
                    $template->assign($this->m_blockSet);
                    //
                    
                break;
                case ITEMVIEW:
                    /*
                    * * @see handler DirectoryResource-view.php
                    */
                    //
                    /*
                    * 1- DirectoryResource
                    * 2- DirectoryResourceAccessSet
                    * 3- ApplicationCodificationSet
                    * 4- RepositorySet
                    */
                    //
                    /*
                    * 1- DirectoryResource
                    */
                    //
                    @include_once (COMPONENTS_DATA . "data.DirectoryResource.php");
                    //
                    $resource = new DirectoryResource($this->m_fieldSet["DIRRESOPKID"]);
                    if ($resource->selectRow($datasource) == false) {
                        //
                        $this->m_errorSet[VIEW_OBJECT_ERROR] = true;
                        //
                        return (false);
                    }
                    //
                    $template->assign($resource->fieldSet());
                    //
                    /*
                    * 2- DirectoryResourceAccessSet Dropdownlist
                    */
                    //
                    @include_once (COMPONENTS_DATA . "data.DirectoryResourceAccessSet.php");
                    //
                    $accessSet = new DirectoryResourceAccessSet($resource->get_field_value("DIRRESTPKID"));
                    if ($accessSet->selectSet($datasource, FOREIGNKEY) == false) {
                        //
                        $this->m_errorSet[VIEW_OBJECT_ERROR] = true;
                        //
                        return (false);
                    }
                    //
                    $accessSetDDL = new HTMLDropdownList("list", "formInput");
                    $this->m_blockSet["DIRRACCLIST"] = $accessSetDDL->renderObject($datasource, $accessSet, $resource->get_field_value("DIRRACCPKID"));
                    //
                    /*
                    * 3- ApplicationCodificationSet Dropdownlist
                    */
                    //
                    @include_once (COMPONENTS_HTML . "html.ApplicationCodificationDDL.php");
                    //
                    $codificationSet = NULL;
                    $codificationSetDDL = new ApplicationCodificationDDL("stat", "formInput", 1);
                    $this->m_blockSet["DIRSTATLIST"] = $codificationSetDDL->renderObject($datasource, $codificationSet, $resource->get_field_value("DIRRESOSTAT"));
                    //
                    $template->assign($this->m_blockSet);
                    //
                    // Resource mapping
                    switch ($resource->get_field_value("DIRRESTPKID")) {
                        case DATARESOURCE:
                        case FILERESOURCE:
                            /*
                            * 4- RepositorySet
                            */
                            //
                            @include_once (COMPONENTS_DATA . "data.RepositorySet.php");
                            //
                            $repositorySet = new RepositorySet($resource->get_field_value("DIRECTOPKID"));
                            if ($repositorySet->selectSet($datasource, FOREIGNKEY) == true) {
                                //
                                for ($i = 0;$i < $repositorySet->rowCount();$i++) {
                                    //	select next item
                                    if ($repositorySet->fetchCursorRow($datasource) == false) return (false);
                                    //
                                    //	render item
                                    $template->select("menu1");
                                    $template->assign($repositorySet->fieldSet());
                                    $template->render("menu1");
                                }
                            }
                            //
                            break;
                        }
                        //
                        
                    break;
                    case PANEVIEW:
                        /*
                        * * @see ctrl.RepositoryModelResource.php
                        */
                        /*
                        * 1- DirectoryResource
                        * 2- ApplicationCodificationSet
                        * 3- DirectoryResourceAccessSet
                        * 4- RepositoryModelResourceTypeSet
                        */
                        //
                        /*
                        * 1- DirectoryResource
                        */
                        //
                        @include_once (COMPONENTS_DATA . "data.DirectoryResource.php");
                        //
                        $resource = new DirectoryResource($this->m_fieldSet["DIRRESOPKID"]);
                        if ($resource->selectRow($datasource) == false) {
                            //
                            $this->m_errorSet[VIEW_OBJECT_ERROR] = true;
                            //
                            return (false);
                        }
                        //
                        $template->assign($resource->fieldSet());
                        $template->assign($this->m_fieldSet); // side effect 4 REPOSITPKID
                        //
                        /*
                        * 2- ApplicationCodificationSet Dropdownlist
                        */
                        //
                        @include_once (COMPONENTS_HTML . "html.ApplicationCodificationDDL.php");
                        //
                        $codificationSet = NULL;
                        $codificationSetDDL = new ApplicationCodificationDDL("stat", "formInput", 1);
                        $this->m_blockSet["REPSTATLIST"] = $codificationSetDDL->renderObject($datasource, $codificationSet, $resource->get_field_value("DIRRESOSTAT"));
                        //
                        /*
                        * 3- DirectoryResourceAccessSet Dropdownlist
                        */
                        //
                        @include_once (COMPONENTS_DATA . "data.DirectoryResourceAccessSet.php");
                        //
                        $accessSet = new DirectoryResourceAccessSet($resource->get_field_value("DIRRESTPKID"));
                        if ($accessSet->selectSet($datasource, FOREIGNKEY) == false) {
                            //
                            $this->m_errorSet[VIEW_OBJECT_ERROR] = true;
                            //
                            return (false);
                        }
                        //
                        $accessSetDDL = new HTMLDropdownList("list", "formInput");
                        $this->m_blockSet["DIRRACCLIST"] = $accessSetDDL->renderObject($datasource, $accessSet, $resource->get_field_value("DIRRACCPKID"));
                        //
                        $template->assign($this->m_blockSet);
                        //
                        /*
                        * 4- RepositoryModelResourceTypeMap
                        */
                        //
                        @include_once (COMPONENTS_DATA . "data.RepositoryModelResourceTypeMap.php");
                        //
                        $resourceTypeSet = new RepositoryModelResourceTypeMap($this->m_fieldSet["REPMRETPKID"]);
                        if ($resourceTypeSet->selectSet($datasource) == true) {
                            //
                            $template->select("show");
                            //
                            for ($i = 0;$i < $resourceTypeSet->rowCount();$i++) {
                                //
                                if ($resourceTypeSet->fetchCursorRow($datasource) == false) return (false);
                                //
                                $template->select("menu");
                                $template->assign($resourceTypeSet->fieldSet());
                                $template->render("menu");
                            }
                            $template->render("show");
                        }
                        //
                        break;
                    case TREEVIEW:
                        /*
                        * * @see view.DirectoryExplorer on renderView
                        */
                        /*
                        * 1- DirectoryResourceSet
                        */
                        //
                        //
                        @include_once (COMPONENTS_DATA . "data.DirectoryResourceSet.php");
                        //
                        $resourceSet = new DirectoryResourceSet($this->m_fieldSet["DIRECTOPKID"], $this->m_fieldSet["DIRRESTPKID"]);
                        if ($resourceSet->selectSet($datasource, FOREIGNKEY) == true) {
                            //
                            for ($i = 0;$i < $resourceSet->rowCount();$i++) {
                                //	select next row
                                if ($resourceSet->fetchCursorRow($datasource) == false) return (false);
                                //
                                $template->select($block);
                                $template->assign($resourceSet->fieldSet());
                                $template->render($block);
                            }
                        }
                        //
                        break;
                    }
                    //
                    $template->output($mode);
                    //
                    return (true);
                }
        };
        //	Class
        //-------------------------------------------------------------------------
        
}
//	namespace
//-----------------------------------------------------------------------------
?>
Return current item: Entier Studio