Location: PHPKode > projects > Entier Studio > entierstudio/studio/classes/views/view.OnlineDataResourceMapper.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.OnlineDataResourceMapper.php 94 2008-02-03 23:35:48Z yannromefort $
 */
//-----------------------------------------------------------------------------
//	namespace
if (!defined("DefOnlineDataResourceMapper")) {
    //-------------------------------------------------------------------------
    //	Define
    define("DefOnlineDataResourceMapper", "1");
    //-------------------------------------------------------------------------
    //	Include
    @require_once (FRAMEWORK_DIR . VIEWHELPER);
    //-------------------------------------------------------------------------
    //	Class
    class OnlineDataResourceMapper extends ViewObject {
        //---------------------------------------------------------------------
        //	Constructor
        
        /**
         *
         * @param
         *
         */
        function OnlineDataResourceMapper() {
            //
            
        }
        //---------------------------------------------------------------------
        //	Methods
        /*
        *
        * @access	private
        *
        * @param	object	DataSource object
        * @param	object	DataExplorer object
        * @param	object	ViewTemplate object
        * @param	string	layout name is a template file name or a layer name in a template file
        * @param	integer	reflection key
        * @param	integer	index
        * @param	string	Table path
        *
        */
        function RenderFieldList(&$datasource, &$dataexplorer, &$template, $block, $link, $pkid, $path) {
            //
            if ($dataexplorer->parseObject($path, "table") == true) {
                //
                while ($node = $dataexplorer->fetchObject($path, "table")) {
                    //
                    $nodeName = $node->m_nodeName;
                    $typeName = $node->m_typeName;
                    $nodeType = $node->m_nodeType;
                    $dataPath = $node->m_dataPath;
                    $dataType = $node->m_dataType;
                    $dataSize = $node->m_dataSize;
                    $dataProp = $node->m_dataProp;
                    $itemInfo = $node->m_dataType . " " . $node->m_dataSize . " " . $node->m_dataProp;
                    //
                    $modelResource = new RepositoryModelResourceIndexer();
                    $modelResource->set_field_value("REPMRESLINK", $link);
                    $modelResource->set_field_value("REPMRESFLAG", $dataProp);
                    //
                    $template->select($block);
                    //
                    if ($modelResource->selectRow($datasource, REFLECTKEY) == true) {
                        //
                        $modelResource->set_field_value("REPMRESVIEW", "view");
                    } else {
                        //
                        $modelResource->set_field_value("REPMRESVIEW", "form");
                        $modelResource->set_field_value("REPMRESLINK", $link);
                        $modelResource->set_field_value("REPMRETPKID", ATTRIBUTE_TYPE);
                    }
                    //
                    $template->assign(array(
                        NodePkid => $pkid,
                        NodeName => $nodeName,
                        DataProp => $dataProp,
                        ItemInfo => $itemInfo
                    ));
                    $template->assign($modelResource->fieldSet());
                    //
                    $template->render($block);
                }
            }
            //
            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);
            //
            $template->assign($this->m_fieldSet);
            //
            @include_once (FRAMEWORK_DIR . "htmldropdownlist.php");
            //
            switch ($view) {
                case ROOTVIEW:
                    /*
                    * * @see handler OnlineDataResource-root.php
                    */
                    /*
                    * 1- ObjectoryResource
                    */
                    //
                    @include_once (COMPONENTS_DATA . "data.ObjectoryResource.php");
                    //
                    $resource = new ObjectoryResource($this->m_fieldSet["OBJRESOPKID"]);
                    if ($resource->selectRow($datasource) == false) {
                        //
                        $this->m_errorSet[VIEW_OBJECT_ERROR] = true;
                        //
                        return (false);
                    }
                    //
                    $template->assign($resource->fieldSet());
                    //
                    /*
                    * 2- ApplicationCodificationSet Dropdownlist
                    */
                    //
                    @include_once (COMPONENTS_HTML . "html.ApplicationCodificationDDL.php");
                    //
                    $codificationSet = NULL;
                    $codificationSetDDL = new ApplicationCodificationDDL("stat", "formInput", 1);
                    $this->m_blockSet[OBJRESOSTAT] = $codificationSetDDL->renderObject($datasource, $codificationSet, $resource->get_field_value("OBJRESOSTAT"));
                    //
                    $template->assign($this->m_blockSet);
                    //
                    
                break;

                case TREEVIEW:
                    /*
                    * * @see class ProjectsExplorer
                    */
                    /*
                    * 1- OnlineResource
                    * 2- DataSourceExplorer
                    */
                    //
                    /*
                    * 1- OnlineResource
                    */
                    //
                    @include_once (COMPONENTS_DATA . "data.OnlineResource.php");
                    //
                    $resource = new OnlineResource($this->m_fieldSet["OBJRESOPKID"]);
                    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- DataSourceExplorer
                    */
                    //
                    $DIRRESOPKID = $resource->get_field_value("DIRRESOPKID");
                    $OBJRURLHOST = $resource->get_field_value("OBJRURLHOST");
                    $OBJRURLPORT = $resource->get_field_value("OBJRURLPORT");
                    $OBJRURLUSER = $resource->get_field_value("OBJRURLUSER");
                    $OBJRURLPASS = $resource->get_field_value("OBJRDECPASS");
                    $OBJRURLNAME = $resource->get_field_value("OBJRURLNAME");
                    $DIRRACCCODE = $resource->get_field_value("DIRRACCCODE");
                    //
                    if ("" == $DIRRACCCODE)
                        return (false);
                    //
                    $className = $DIRRACCCODE . "Explorer";
                    $classFile = @strtolower($DIRRACCCODE) . ".explorer.php";
                    //
                    @include_once (FRAMEWORK_DIR . $classFile);
                    if (false === class_exists($className))
                        return (false);
                    //
                    @set_time_limit(180);
                    //
                    $dataExplorer = new $className($OBJRURLHOST, $OBJRURLPORT, $OBJRURLUSER, $OBJRURLPASS, $OBJRURLNAME);
                    if ($dataExplorer->parseObject($OBJRURLNAME, "database") == false) {
                        //
                        $this->m_errorSet[DATA_SOURCE_ERROR] = true;
                        //
                        return (false);
                    }
                    //
                    $nodePkid = 0;
                    //
                    //
                    $root = $dataExplorer->getObject($OBJRURLNAME, "database");
                    if (!empty($root)) {
                        //
                        @include_once (COMPONENTS_DATA . "data.RepositoryModelResourceIndexer.php");
                        //
                        while ($node = $root->fetchElements($OBJRURLNAME, "database")) {
                            //
                            $nodePkid++;
                            //
                            $nodeName = $node->m_nodeName;
                            $typeName = $node->m_typeName;
                            $nodeType = $node->m_nodeType;
                            $dataPath = $node->m_dataPath;
                            $dataType = $node->m_dataType;
                            $dataSize = $node->m_dataSize;
                            $dataProp = $node->m_dataProp;
                            //
                            $modelResource = new RepositoryModelResourceIndexer();
                            $modelResource->set_field_value("DIRRESOPKID", $DIRRESOPKID);
                            $modelResource->set_field_value("REPMRESFLAG", $dataType);
                            //
                            $template->select($block[0]);
                            if ($modelResource->selectRow($datasource, FOREIGNKEY) == true) {
                                //
                                $modelResource->set_field_value("REPMRESVIEW", "view");
                                //
                                $template->assign(array(
                                    NodePkid => $nodePkid,
                                    NodeName => $nodeName
                                ));
                                $template->assign($modelResource->fieldSet());
                                //
                                $this->RenderFieldList(
										$datasource, 
										$dataExplorer, 
										$template, 
										$block[1], 
										$modelResource->get_field_value("REPMRESPKID"),
										$nodePkid, 
										$dataPath
										);
                            } else {
                                //
                                $modelResource->set_field_value("REPMRESVIEW", "form");
                                $modelResource->set_field_value("REPMRETPKID", CLASS_TYPE);
                                //
                                $template->assign($modelResource->fieldSet());
                                //
                                $template->assign(array(
                                    NodePkid => $nodePkid,
                                    NodeName => $nodeName,
                                    DataProp => $dataType
                                ));
                                
                            }
                            //
                            $template->render($block[0]);
                            //
                            unset($modelResource);
                        }
                    }
                    //
                    break;

                case FRAMEVIEW:
                    /*
                    * * @see handler OnlineDataResource-frame.php
                    */
                    /*
                    * 1- ObjectoryResource
                    */
                    //
                    @include_once (COMPONENTS_DATA . "data.ObjectoryResource.php");
                    //
                    $resource = new ObjectoryResource($this->m_fieldSet["OBJRESOPKID"]);
                    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
                    //
                    break;
                }
                //
                $template->output($mode);
                //
                return (true);
            }
    };
    //	Class
    //-------------------------------------------------------------------------
    
}
//	namespace
//-----------------------------------------------------------------------------
?>
Return current item: Entier Studio