Location: PHPKode > projects > Entier Studio > entierstudio/studio/classes/views/view.RepositoryCoreElementExplorer.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.RepositoryCoreElementExplorer.php 90 2008-01-31 22:02:05Z yannromefort $
 */
//-----------------------------------------------------------------------------
//	namespace
if (!defined("DefRepositoryCoreElementExplorer")) {
    //-------------------------------------------------------------------------
    //	Define
    define("DefRepositoryCoreElementExplorer", "1");
    //-------------------------------------------------------------------------
    //	Include
    @require_once (FRAMEWORK_DIR . VIEWHELPER);
    //-------------------------------------------------------------------------
    //	Class
    class RepositoryCoreElementExplorer extends ViewObject {
        //---------------------------------------------------------------------
        //	Constructor
        
        /**
         *
         * @param	integer	 Repository	pkid //	foreign key
         *
         */
        function RepositoryCoreElementExplorer() {
        }
        //---------------------------------------------------------------------
        //	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	{ FORMVIEW, 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);
            }
            //
            /*
            * *- 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);
                }
            }
            //
            switch ($view) {
                case FORMVIEW:
                    /*
                    * * @see handler RepositoryCoreElement-form.php
                    */
                    //
                    /*
                    * 1- RepositoryCoreElementType
                    * 2- ApplicationCodificationSet
                    * 3- RepositoryCoreElementPropertyList
                    */
                    //
                    /*
                    * 1- RepositoryCoreElementType
                    */
                    //
                    @include_once (COMPONENTS_DATA . "data.RepositoryCoreElementType.php");
                    //
                    $elementType = new RepositoryCoreElementType($this->m_fieldSet["REPCELTPKID"]);
                    if ($elementType->selectRow($datasource) == false) {
                        //
                        $this->m_errorSet[VIEW_OBJECT_ERROR] = true;
                        //
                        return (false);
                    }
                    //
                    $template->assign($elementType->fieldSet());
                    $template->assign($this->m_fieldSet); // side effect 4 root={REPOSITPKID}
                    //
                    /*
                    * 2- ApplicationCodificationSet Dropdownlist status
                    */
                    //
                    @include_once (COMPONENTS_HTML . "html.ApplicationCodificationDDL.php");
                    //
                    $codificationSet = NULL;
                    $codificationSetDDL = new ApplicationCodificationDDL("stat", "formInput", 1);
                    $this->m_blockSet["REPSTATLIST"] = $codificationSetDDL->renderObject($datasource, $codificationSet, 1);
                    //
                    $template->assign($this->m_blockSet);
                    //
                    /*
                    * 3- RepositoryCoreElementPropertyList
                    */
                    //
                    @include_once (COMPONENTS_VIEW . "view.RepositoryCoreElementPropertyList.php");
                    //
                    $propertyList = new RepositoryCoreElementPropertyList($this->m_fieldSet["REPOSITPKID"]);
                    $propertyList->set_field_value("REPCELTPKID", $this->m_fieldSet["REPCELTPKID"]);
                    $propertyList->set_field_value("REPCELEPKID", 0);
                    if ($propertyList->renderView($datasource, $template, "prop", "prop", LISTVIEW, RENDER) == false) {
                        //
                        $this->m_errorSet[VIEW_RENDER_ERROR] = true;
                        //
                        return (false);
                    }
                    //
                    
                break;
                case ITEMVIEW:
                    /*
                    * * @see handler RepositoryCoreElement-view.php
                    */
                    //
                    /*
                    * 1- RepositoryCoreElement
                    * 2- ApplicationCodificationSet
                    * 3- RepositoryCoreElementPropertyList
                    */
                    //
                    /*
                    * 1- RepositoryCoreElement
                    */
                    //
                    @include_once (COMPONENTS_DATA . "data.RepositoryCoreElement.php");
                    //
                    $element = new RepositoryCoreElement($this->m_fieldSet["REPCELEPKID"]);
                    //
                    if ($element->selectRow($datasource) == false) {
                        //
                        $this->m_errorSet[VIEW_OBJECT_ERROR] = true;
                        //
                        return (false);
                    }
                    //
                    $template->assign($element->fieldSet());
                    //
                    /*
                    * 2- ApplicationCodificationSet Dropdownlist status
                    */
                    //
                    @include_once (COMPONENTS_HTML . "html.ApplicationCodificationDDL.php");
                    //
                    $codificationSet = NULL;
                    $codificationSetDDL = new ApplicationCodificationDDL("stat", "formInput", 1);
                    $this->m_blockSet["REPSTATLIST"] = $codificationSetDDL->renderObject($datasource, $codificationSet, $element->get_field_value("REPCELESTAT"));
                    //
                    $template->assign($this->m_blockSet);
                    $template->assign($this->m_fieldSet);
                    //
                    /*
                    * 3- RepositoryCoreElementPropertyList
                    */
                    //
                    @include_once (COMPONENTS_VIEW . "view.RepositoryCoreElementPropertyList.php");
                    //
                    $propertyList = new RepositoryCoreElementPropertyList($element->get_field_value("REPOSITPKID"));
                    $propertyList->set_field_value("REPCELTPKID", $element->get_field_value("REPCELTPKID"));
                    $propertyList->set_field_value("REPCELEPKID", $element->get_field_value("REPCELEPKID"));
                    if ($propertyList->renderView($datasource, $template, "prop", "prop", LISTVIEW, RENDER) == false) {
                        //
                        $this->m_errorSet[VIEW_RENDER_ERROR] = true;
                        //
                        return (false);
                    }
                    //
                    /*
                    * 4- Model enabled
                    */
                    //
                    $template->toggle("show", $element->get_field_value("REPCELTTYPE") == MODEL_ENABLED);
                    //
                    
                break;
                case LISTVIEW:
                    /*
                    * * @see handler RepositoryCoreElement-list.php
                    */
                    /*
                    * 1- RepositoryCoreElementSet
                    */
                    //
                    @include_once (COMPONENTS_DATA . "data.RepositoryCoreElementSet.php");
                    //
                    $elementSet = new RepositoryCoreElementSet($this->m_fieldSet["REPOSITPKID"], $this->m_fieldSet["REPCELTPKID"]);
                    if ($elementSet->selectSet($datasource, FOREIGNKEY) == false)
                        return (false);
                    //
                    for ($i = 0;$i < $elementSet->rowCount();$i++) {
                        //	select next item
                        if ($elementSet->fetchCursorRow($datasource) == false)
                            return (false);
                        //	render item
                        $template->select($block);
                        $template->assign($elementSet->fieldSet());
                        $template->render($block);
                    }
                    //
                    $template->assign($elementSet->fieldSet());
                    //
                    break;
                case TREEVIEW:
                    /*
                    * @see view.RepositoryExplorer on renderView
                    */
                    //
                    /*
                    * 1- RepositoryCoreElementTypeSet
                    * 2- RepositoryCoreComponentSet
                    */
                    //
                    /*
                    * 1- RepositoryCoreElementTypeSet
                    */
                    //
                    @include_once (COMPONENTS_DATA . "data.RepositoryCoreElementTypeSet.php");
                    //
                    $elementTypeSet = new RepositoryCoreElementTypeSet($this->m_fieldSet["REPOSITPKID"], $this->m_fieldSet["REPTYPEPKID"]);
                    if ($elementTypeSet->selectSet($datasource, FOREIGNKEY, PRIMARYKEY) == false)
                        return (false);
                    //
                    /*
                    * 2- RepositoryCoreElementSet
                    */
                    //
                    @include_once (COMPONENTS_DATA . "data.RepositoryCoreElementSet.php");
                    //
                    for ($i = 0;$i < $elementTypeSet->rowCount();$i++) {
                        //	select next item
                        if ($elementTypeSet->fetchCursorRow($datasource) == false)
                            return (false);
                        //	render item
                        $template->select($block[0]);
                        $template->assign($elementTypeSet->fieldSet());
                        $template->assign($this->m_fieldSet); // side effect 4 root={REPOSITPKID}
                        //
                        // Render list
                        $elementSet = new RepositoryCoreElementSet($this->m_fieldSet["REPOSITPKID"], $elementTypeSet->get_field_value("REPCELTPKID"));
                        if ($elementSet->selectSet($datasource) == true) {
                            //
                            for ($j = 0;$j < $elementSet->rowCount();$j++) {
                                //	select next item
                                if ($elementSet->fetchCursorRow($datasource) == false) return (false);
                                //	render item
                                $template->select($block[1]);
                                $template->assign($elementSet->fieldSet());
                                $template->render($block[1]);
                            }
                        }
                        //
                        $template->render($block[0]);
                        //
                        unset($elementSet);
                    }
                    //
                    unset($elementTypeSet);
                    //
                    break;
                }
                //
                $template->output($mode);
                //
                return (true);
            }
        };
    //	Class
    //-------------------------------------------------------------------------
}
//	namespace
//-----------------------------------------------------------------------------    
?>
Return current item: Entier Studio