Location: PHPKode > projects > Entier Studio > entierstudio/studio/classes/views/view.OnlineHostResourceExplorer.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 
 * @version	   $Id: view.OnlineHostResourceExplorer.php 82 2008-01-18 18:04:17Z yannromefort $
 * @copyright  Copyright (c) 2006 Entier Studio team. All rights reserved.
 */
//-----------------------------------------------------------------------------
//	namespace
if (!defined("DefOnlineHostResourceExplorer")) {
    //-------------------------------------------------------------------------
    //	Define
    define("DefOnlineHostResourceExplorer", "1");
    //-------------------------------------------------------------------------
    //	Include
    @require_once (FRAMEWORK_DIR . VIEWHELPER);
    //-------------------------------------------------------------------------
    //	Class
    class OnlineHostResourceExplorer extends ViewObject {
        //---------------------------------------------------------------------
        //	Attributes
        
        /**
         * node index
         * @var	integer
         * @see
         */
        var $m_nodePkid = 0;
        //---------------------------------------------------------------------
        //	Constructor
        
        /**
         *
         * @param
         *
         */
        function OnlineHostResourceExplorer() {
            //
            
        }
        //---------------------------------------------------------------------
        //	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 RenderDirectoryList(&$explorer, &$template, $block, $link, $path) {
            //
            if ($explorer->parseObject($path, "directory") == true) {
                //
                $root = $explorer->getObject($path, "directory");
                if (!empty($root)) {
                    //
                    while ($node = $root->fetchElements($path, "directory")) {
                        //
                        $this->m_nodePkid++;
                        //
                        if ($node->m_nodeType == DIRECTORY_NODE) {
                            //
                            $nodeName = $node->m_nodeName;
                            $typeName = $node->m_typeName;
                            $nodeType = $node->m_nodeType;
                            $dataPath = $node->m_dataPath;
                            $dataType = $node->m_dataType;
                            $dataSize = $node->m_dataSize;
                            //
                            $template->select($block);
                            $template->assign(array(
                                NodePkid => $this->m_nodePkid,
                                NodeLink => $link,
                                NodeName => $nodeName,
                                DataPath => @urlencode($dataPath) ,
                                TypeName => $typeName,
                                NodeType => $nodeType
                            ));
                            //
                            $template->render($block);
                            //
                            $this->RenderDirectoryList($explorer, $template, $block, $this->m_nodePkid, $dataPath);
                        }
                    }
                }
            }
            //
            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 FORMVIEW:
                    /*
                    * * @see handler OnlineResource-form.php
                    */
                    //
                    
                break;
                case ITEMVIEW:
                    /*
                    * * @see handler OnlineResource-view.php
                    */
                    /*
                    * 1- OnlineResource
                    */
                    // =- select PropertyType on primary key ( OBJRESOPKID )
                    @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());
                    //
                break;
                case LISTVIEW:
                    /*
                    * * @see handler OnlineResource-list.php
                    */
                    /*
                    * 1- OnlineResource
                    * 2- ResourceExplorer
                    */
                    //
                    /*
                    * 1- OnlineResource
                    */
                    // =- select PropertyType on primary key ( OBJRESOPKID )
                    @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());
                    //
                    $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");
                    //
                    $OBJRURLPATH = @urldecode($this->m_fieldSet["OBJRURLPATH"]);
                    $OBJRURLTYPE = $this->m_fieldSet["OBJRURLTYPE"];
                    //
                    if ($DIRRACCCODE == "") return (false);
                    //
                    $className = $DIRRACCCODE . "Explorer";
                    $classFile = @strtolower($DIRRACCCODE) . ".explorer.php";
                    //
                    @include_once (FRAMEWORK_DIR . $classFile);
                    if (class_exists($className) == false) return (false);
                    //
                    @set_time_limit(180);
                    //
                    $hostExplorer = new $className($OBJRURLHOST, $OBJRURLPORT, $OBJRURLUSER, $OBJRURLPASS, $OBJRURLNAME);
                    //
                    if ($hostExplorer->openSource() == false) {
                        //
                        $this->m_errorSet[HOST_SOURCE_ERROR] = true;
                        //
                        return (false);
                    }
                    //
                    if ($hostExplorer->parseObject($OBJRURLPATH, $OBJRURLTYPE) == false) {
                        //
                        $this->m_errorSet[HOST_OBJECT_ERROR] = true;
                        //                        
                        return (false);
                    }
                    //
                    $this->m_nodePkid = 0;
                    //
                    $root = $hostExplorer->getObject($OBJRURLPATH, $OBJRURLTYPE);
                    if (!empty($root)) {
                        //
                        while ($node = $root->fetchElements($OBJRURLPATH, $OBJRURLTYPE)) {
                            //
                            $this->m_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;
                            //
                            $template->select($block);
                            //
                            $template->assign(array(
                                NodePkid => $this->m_nodePkid,
                                NodeLink => $this->m_nodePkid,
                                NodeName => $nodeName,
                                DataPath => @urlencode($dataPath) ,
                                TypeName => $typeName,
                                NodeType => $nodeType
                            ));
                            //
                            $template->render($block);
                        }
                    }
                    //
                    if ($hostExplorer->closeSource() == false) {
                        //
                        $this->m_errorSet[HOST_SOURCE_ERROR] = true;
                        //
                        return (false);
                    }
                //
                break;
                case TREEVIEW:
                    /*
                    * * @see handler OnlineResource-tree.php
                    */
                    /*
                    * 1- OnlineResource
                    * 2- ResourceExplorer
                    */
                    //
                    /*
                    * 1- OnlineResource
                    */
                    // =- select PropertyType on primary key ( OBJRESOPKID )
                    @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());
                    //
                    $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 (class_exists($className) == false)
					    return (false);
                    //
                    @set_time_limit(180);
                    //
                    $hostExplorer = new $className($OBJRURLHOST, $OBJRURLPORT, $OBJRURLUSER, $OBJRURLPASS, $OBJRURLNAME);
                    //
                    if ($hostExplorer->openSource() == false) {
                        //
                        $this->m_errorSet[HOST_SOURCE_ERROR] = true;
                        //
                        return (false);
                    }
                    //
                    if ($hostExplorer->parseObject($OBJRURLNAME, "host") == false) {
                        //
                        $this->m_errorSet[HOST_OBJECT_ERROR] = true;
                        //
                        return (false);
                    }
                    //
                    $this->m_nodePkid = 0;
                    //
                    $root = $hostExplorer->getObject($OBJRURLNAME, "host");
                    if (!empty($root)) {
                        //                        
                        while ($node = $root->fetchElements($OBJRURLNAME, "host")) {
                            //                            
                            $this->m_nodePkid++;
                            //
                            if ($node->m_nodeType == DIRECTORY_NODE) {
                                //
                                $nodeName = $node->m_nodeName;
                                $typeName = $node->m_typeName;
                                $nodeType = $node->m_nodeType;
                                $dataPath = $node->m_dataPath;
                                $dataType = $node->m_dataType;
                                $dataSize = $node->m_dataSize;
                                //
                                $template->select($block[0]);
                                //
                                $template->assign(array(
                                    NodePkid => $this->m_nodePkid,
                                    NodeName => $nodeName,
                                    DataPath => @urlencode($dataPath) ,
                                    TypeName => $typeName,
                                    NodeType => $nodeType
                                ));
                                //
                                $this->RenderDirectoryList($hostExplorer, $template, $block[1], $this->m_nodePkid, $dataPath);
                                //
                                $template->render($block[0]);
                            }
                        }
                    }
                    //
                    if ($hostExplorer->closeSource() == false) {
                        //
                        $this->m_errorSet[HOST_SOURCE_ERROR] = true;
                        //
                        return (true);
                    }
                //
                break;
                case FRAMEVIEW:
                    /*
                    * * @see handler OnlineResource-frame.php
                    */
                    /*
                    * 1- ObjectoryResource
                    */
                    // =- select PropertyType on primary key ( OBJRESOPKID )
                    @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());
                    //
                    break;
                }
                //
                $template->output($mode);
                //
                return (true);
            }
        };
        //	Class
        //-------------------------------------------------------------------------
        
    }
    //	namespace
    //-----------------------------------------------------------------------------
    
?>
Return current item: Entier Studio