Location: PHPKode > projects > Entier Studio > entierstudio/studio/classes/views/view.RepositoryExplorer.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.RepositoryExplorer.php 90 2008-01-31 22:02:05Z yannromefort $
 */
//-----------------------------------------------------------------------------
//	namespace
if (!defined("DefRepositoryExplorer")) {
    //-------------------------------------------------------------------------
    //	Define
    define("DefRepositoryExplorer", "1");
    //-------------------------------------------------------------------------
    //	Include
    @require_once (FRAMEWORK_DIR . VIEWHELPER);
    //-------------------------------------------------------------------------
    //	Class
    class RepositoryExplorer extends ViewObject {
        //---------------------------------------------------------------------
        //	Constructor
        
        /**
         *
         * @param	integer	 Directory	pkid			//	foreign key
         */
        function RepositoryExplorer($DIRECTOPKID = 0) {
            //
            $this->m_fieldSet["DIRECTOPKID"] = $DIRECTOPKID;
        }
        //---------------------------------------------------------------------
        //	Methods
        /*
        *
        * @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	{ ITEMVIEW, LISTVIEW, TREEVIEW }
        * @param	integer	outputmode
        *
        */
        function renderView(&$datasource, &$template, $layout, $block, $view = NULL, $mode = OUTPUT) {
            //
            if (!is_object($template)) {
                //
                $this->m_errorSet[VIEW_SYSTEM_ERROR] = true;
                //
                return (false);
            }
            //
            if (!empty($layout) && ($template->define($layout) == false)) {
                //
                $this->m_errorSet[VIEW_LAYOUT_ERROR] = $layout;
                //
                return (false);
            }
            //
            switch ($view) {
                case ITEMVIEW:
                    //
                    /*
                    * 1- RepositorySet
                    */
                    //
                    @include_once (COMPONENTS_DATA . "data.RepositorySet.php");
                    //
                    $repositorySet = new RepositorySet($this->m_fieldSet["DIRECTOPKID"]);
                    if ($repositorySet->selectSet($datasource, FOREIGNKEY) == false)
                        return (false);
                    //
                    /*
                    * 2- RepositoryCoreElementTypeSet + RepositoryCoreComponentTypeSet
                    */
                    //
                    @include_once (COMPONENTS_DATA . "data.RepositoryCoreElementTypeSet.php");
                    @include_once (COMPONENTS_DATA . "data.RepositoryCoreComponentTypeSet.php");
                    //
                    for ($i = 0;$i < $repositorySet->rowCount();$i++) {
                        //	select next item
                        if ($repositorySet->fetchCursorRow($datasource) == false)
                           return (false);
                        //
                        $REPOSITPKID = $repositorySet->get_field_value("REPOSITPKID");
                        $REPTYPEPKID = $repositorySet->get_field_value("REPTYPEPKID");
                        //
						$elementTypeSet = new RepositoryCoreElementTypeSet(
												$REPOSITPKID,
												$REPTYPEPKID
												);
						if ($elementTypeSet->selectSet($datasource, FOREIGNKEY, PRIMARYKEY) == false)
						    return (false);
						//
						for ($j = 0;$j < $elementTypeSet->rowCount();$j++) {
						    //	select next item
						    if ($elementTypeSet->fetchCursorRow($datasource) == false)
						        return (false);
						    //	render item
						    $template->select($block."-element");
						    $template->assign($elementTypeSet->fieldSet());
						    $template->render($block."-element");
						}
						//
						$componentTypeSet = new RepositoryCoreComponentTypeSet(
												$REPOSITPKID,
												$REPTYPEPKID
												);
						if ($componentTypeSet->selectSet($datasource, FOREIGNKEY, PRIMARYKEY) == false)
						    return (false);
						//
						for ($k = 0;$k < $componentTypeSet->rowCount();$k++) {
						    //	select next item
						    if ($componentTypeSet->fetchCursorRow($datasource) == false)
						        return (false);
						    //	render item
						    $template->select($block."-component");
						    $template->assign($componentTypeSet->fieldSet());
						    $template->render($block."-component");
						}
                    }
                    //
                break;
                case TREEVIEW:
                    /*
                    * * @see  view.DirectoryProjectExplorer.php on DirectoryProjectExplorer.renderView
                    */
                    //
                    $repEList = "rep-mod-elist";
                    $repETree = "rep-mod-etree";
                    //
                    $repCList = "rep-mod-clist";
                    $repCTree = "rep-mod-ctree";
                    //
                    $dicPList = "rep-dic-plist";
                    $dicPTree = "rep-dic-ptree";
                    //
                    /*
                    * 1- RepositorySet
                    */
                    //
                    @include_once (COMPONENTS_DATA . "data.RepositorySet.php");
                    //
                    $repositorySet = new RepositorySet($this->m_fieldSet["DIRECTOPKID"]);
                    if ($repositorySet->selectSet($datasource, FOREIGNKEY) == false)
                        return (false);
                    //
                    /*
                    *	REPOSITORY TREE
                    *
                    */
                    //
                    @include_once (COMPONENTS_VIEW . "view.RepositoryCoreElementExplorer.php");
                    @include_once (COMPONENTS_VIEW . "view.RepositoryCoreComponentExplorer.php");
                    @include_once (COMPONENTS_VIEW . "view.DictionaryPropertyExplorer.php");
                    //
                    for ($i = 0;$i < $repositorySet->rowCount();$i++) {
                        //	select next item
                        if ($repositorySet->fetchCursorRow($datasource) == false)
                           return (false);
                        //
                        $REPTYPEPKID = $repositorySet->get_field_value("REPTYPEPKID");
                        $REPOSITPKID = $repositorySet->get_field_value("REPOSITPKID");
                        //
                        /*
                        *	REPOSITORY
                        *
                        */
                        //
                        //	2-1 RepositoryCoreElementExplorer Tree view
                        //
                        $RCE_Explorer = new RepositoryCoreElementExplorer();
                        $RCE_Explorer->set_field_value("REPOSITPKID", $REPOSITPKID);
                        $RCE_Explorer->set_field_value("REPTYPEPKID", $REPTYPEPKID);
                        $RCE_Explorer->renderView($datasource, $template, "", array(
                            $repEList,
                            $repETree
                        ) , TREEVIEW, RENDER);
                        unset($RCE_Explorer);
                        //
                        //	2-2 RepositoryCoreComponentExplorer Tree view
                        //
                        $RCC_Explorer = new RepositoryCoreComponentExplorer();
                        $RCC_Explorer->set_field_value("REPOSITPKID", $REPOSITPKID);
                        $RCC_Explorer->set_field_value("REPTYPEPKID", $REPTYPEPKID);
                        $RCC_Explorer->renderView($datasource, $template, "", array(
                            $repCList,
                            $repCTree
                        ) , TREEVIEW, RENDER);
                        unset($RCC_Explorer);
                        //
                        /*
                        *	DICTIONARY
                        *
                        */
                        //
                        //	2-3 DictionaryPropertyExplorer Tree view
                        //
                        $DIC_Explorer = new DictionaryPropertyExplorer();
                        $DIC_Explorer->set_field_value("REPOSITPKID", $REPOSITPKID);
                        $DIC_Explorer->set_field_value("REPTYPEPKID", $REPTYPEPKID);
                        $DIC_Explorer->renderView($datasource, $template, "", array(
                            $dicPList,
                            $dicPTree
                        ) , TREEVIEW, RENDER);
                        unset($DIC_Explorer);
                    }
                    //
                    break;
                }
                //
                $template->output($mode);
                //
                return (true);
            }
    };
    //	Class
    //-------------------------------------------------------------------------    
}
//	namespace
//-----------------------------------------------------------------------------
?>
Return current item: Entier Studio