Location: PHPKode > projects > Entier Studio > entierstudio/studio/classes/views/view.DictionaryPropertyExplorer.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.DictionaryPropertyExplorer.php 90 2008-01-31 22:02:05Z yannromefort $
 */
//-----------------------------------------------------------------------------
//	namespace
if (!defined("DefDictionaryPropertyExplorer")) {
    //-------------------------------------------------------------------------
    //	Define
    define("DefDictionaryPropertyExplorer", "1");
    //-------------------------------------------------------------------------
    //	Include
    @require_once (FRAMEWORK_DIR . VIEWHELPER);
    //-------------------------------------------------------------------------
    //	Class
    class DictionaryPropertyExplorer extends ViewObject {
        //---------------------------------------------------------------------
        //	Constructor
        
        /**
         *
         * @param	integer	 Repository	pkid //	foreign key
         *
         */
        function DictionaryPropertyExplorer() {
        }
        //---------------------------------------------------------------------
        //	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
         * @return	boolean
         */
        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 DictionaryProperty-form.php
                    */
                    //
                    /*
                    * 1- DictionaryPropertyType
                    * 2- ApplicationCodificationSet
                    */
                    //
                    /*
                    * 1- DictionaryPropertyType
                    */
                    //
                    @include_once (COMPONENTS_DATA . "data.DictionaryPropertyType.php");
                    //
                    $propertyType = new DictionaryPropertyType($this->m_fieldSet["DICPTYPPKID"]);
                    if ($propertyType->selectRow($datasource) == false) {
                        //
                        $this->m_errorSet[VIEW_OBJECT_ERROR] = true;
                        //
                        return (false);
                    }
                    //
                    $template->assign($propertyType->fieldSet());
                    $template->assign($this->m_fieldSet); // side effect 4 root={REPOSITPKID}
                    //
                    /*
                    *	ApplicationCodificationSet Dropdownlist
                    */
                    //
                    @include_once (COMPONENTS_HTML . "html.ApplicationCodificationDDL.php");
                    //
                    $codificationSet = NULL;
                    $codificationSetDDL = new ApplicationCodificationDDL("stat", "formInput", 1);
                    $this->m_blockSet["DICSTATLIST"] = $codificationSetDDL->renderObject($datasource, $codificationSet, 1);
                    //
                    $template->assign($this->m_blockSet);
                    //
                    
                break;
                case ITEMVIEW:
                    /*
                    * * @see handler DictionaryProperty-view.php
                    */
                    //
                    /*
                    * 1- DictionaryProperty
                    * 2- ApplicationCodificationSet
                    * 3- DictionaryModelElementTypeSet
                    * 4- DictionaryModelElementTypeSet
                    */
                    //
                    /*
                    * 1- DictionaryProperty
                    */
                    // =- select PropertyType on primary key ( DICPROPPKID )
                    @include_once (COMPONENTS_DATA . "data.DictionaryProperty.php");
                    //
                    $property = new DictionaryProperty($this->m_fieldSet["DICPROPPKID"]);
                    if ($property->selectRow($datasource) == false) {
                        //
                        $this->m_errorSet[VIEW_OBJECT_ERROR] = true;
                        //
                        return (false);
                    }
                    //
                    $template->assign($property->fieldSet());
                    $template->assign($this->m_fieldSet); // side effect 4 root={REPOSITPKID}
                    //
                    /*
                    * 2- ApplicationCodificationSet Dropdownlist
                    */
                    //
                    @include_once (COMPONENTS_HTML . "html.ApplicationCodificationDDL.php");
                    //
                    $codificationSet = NULL;
                    $codificationSetDDL = new ApplicationCodificationDDL("stat", "formInput", 1);
                    $this->m_blockSet["DICSTATLIST"] = $codificationSetDDL->renderObject($datasource, $codificationSet, $property->get_field_value("DICPROPSTAT"));
                    //
                    unset($codificationSetDDL);
                    unset($codificationSet);
                    //
                    /*
                    * 3- DictionaryCoreElementTypeSet Dropdownlist
                    */
                    //
                    @include_once (COMPONENTS_DATA . "data.DictionaryCoreElementTypeSet.php");
                    //
                    $coreElementTypeSet = new DictionaryCoreElementTypeSet($property->get_field_value("REPTYPEPKID"));
                    if ($coreElementTypeSet->selectSet($datasource, FOREIGNKEY, PRIMARYKEY) == false) return (false);
                    //
                    $elementTypeDDL = new HTMLDropdownList("type", "listInput");
                    $this->m_blockSet["REPCELTLIST"] = $elementTypeDDL->renderObject($datasource, $coreElementTypeSet);
                    //
                    unset($coreElementTypeSet);
                    unset($elementTypeDDL);
                    //
                    /*
                    * 4- DictionaryModelElementTypeSet Dropdownlist
                    */
                    //
                    @include_once (COMPONENTS_DATA . "data.DictionaryModelElementTypeSet.php");
                    //
                    $modelElementTypeSet = new DictionaryModelElementTypeSet($property->get_field_value("REPTYPEPKID"));
                    if ($modelElementTypeSet->selectSet($datasource, FOREIGNKEY, PRIMARYKEY) == false) return (false);
                    //
                    $elementTypeDDL = new HTMLDropdownList("type", "listInput");
                    $this->m_blockSet["REPMELTLIST"] = $elementTypeDDL->renderObject($datasource, $modelElementTypeSet);
                    //
                    unset($modelElementTypeSet);
                    unset($elementTypeDDL);
                    //
                    /*
                    * 5- View assignement
                    */
                    //
                    $template->assign($this->m_blockSet);
                    //
                    break;
                case LISTVIEW:
                    /*
                    * * @see handler DictionaryProperty-list.php
                    */
                    //
                    break;
                case TREEVIEW:
                    /*
                    * @see view.RepositoryExplorer on renderView
                    */
                    //
                    /*
                    * 1- DictionaryPropertyTypeSet
                    * 2- DictionaryPropertyTypeSet
                    */
                    //
                    /*
                    * 1- DictionaryPropertyType
                    */
                    //
                    @include_once (COMPONENTS_DATA . "data.DictionaryPropertyTypeSet.php");
                    //
                    $propertyTypeSet = new DictionaryPropertyTypeSet($this->m_fieldSet["REPTYPEPKID"]);
                    if ($propertyTypeSet->selectSet($datasource, FOREIGNKEY, NATURALKEY) == false)
                        return (false);
                    //
                    /*
                    * 2- DictionaryPropertyTypeSet
                    */
                    //
                    @include_once (COMPONENTS_DATA . "data.DictionaryPropertySet.php");
                    //
                    for ($i = 0;$i < $propertyTypeSet->rowCount();$i++) {
                        //	select next item
                        if ($propertyTypeSet->fetchCursorRow($datasource) == false)
                            return (false);
                        //	render item
                        $template->select($block[0]);
                        $template->assign($propertyTypeSet->fieldSet());
                        $template->assign($this->m_fieldSet); // side effect 4 root={REPOSITPKID}
                        //
                        // Render list
                        $propertySet = new DictionaryPropertySet($this->m_fieldSet["REPOSITPKID"], $propertyTypeSet->get_field_value("DICPTYPPKID"));
                        if ($propertySet->selectSet($datasource) == true) {
                            //
                            for ($j = 0;$j < $propertySet->rowCount();$j++) {
                                //	select next item
                                if ($propertySet->fetchCursorRow($datasource) == false)
                                    return (false);
                                //	render item
                                $template->select($block[1]);
                                $template->assign($propertySet->fieldSet());
                                $template->render($block[1]);
                            }
                        }
                        //
                        $template->render($block[0]);
                        //
                        unset($propertySet);
                    }
                    //
                    unset($propertyTypeSet);
                    //
                    break;
                }
                //
                $template->output($mode);
                //
                return (true);
            }
        };
        //	Class
        //-------------------------------------------------------------------------
        
    }
    //	namespace
    //-----------------------------------------------------------------------------
    
?>
Return current item: Entier Studio