Location: PHPKode > projects > Entier Studio > entierstudio/studio/classes/views/view.ObjectoryElementConstraintValueList.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.ObjectoryElementConstraintValueList.php 81 2008-01-17 23:08:21Z yannromefort $
 */
//-----------------------------------------------------------------------------
//	namespace
if (!defined("DefObjectoryElementConstraintValueList")) {
    //-------------------------------------------------------------------------
    //	Define
    define("DefObjectoryElementConstraintValueList", "1");
    //-------------------------------------------------------------------------
    //	Include
    @require_once (FRAMEWORK_DIR . VIEWHELPER);
    //-------------------------------------------------------------------------
    //	Class
    /*
    *
    */
    class ObjectoryElementConstraintValueList extends ViewObject {
        //---------------------------------------------------------------------
        //	Constructor
        /*
        *
        */
        function ObjectoryElementConstraintValueList() {
            //
            
        }
        //---------------------------------------------------------------------
        //	Methods
        
        /**
         *
         * @access	private
         *
         * @param	object	DataSource object
         * @param	object	ViewTemplate object
         * @param	string	block name in layout
         * @param	object	foreign key value
         * @param	integer	tree level
         * @return	boolean
         */
        function renderTree(&$datasource, &$template, $block, $property, $level) {
            //
            $propertySet = new ObjectoryElementRuledConstraintValueSet($property->get_field_value("DICPVALPKID") , $this->m_fieldSet["OBJELEMPKID"], $this->m_fieldSet["REPMELTPKID"]);
            if ($propertySet->selectSet($datasource, REFLECTKEY, NATURALKEY) == true) {
                # List items
                //
                $treelevel = $level+1;
                //
                for ($i = 0;$i < $propertySet->rowCount();$i++) {
                    // retrieve next row
                    if ($propertySet->fetchCursorRow($datasource) == false) return (false);
                    //
                    $template->select($block);
                    $template->assign("TreeSpan", $level*15);
                    $template->assign($propertySet->fieldSet());
                    //
                    // Property values Dropdownlist
                    $valueSet = new DictionaryPropertyValueSet($propertySet->get_field_value("DICPROPPKID"));
                    if ($valueSet->selectSet($datasource, FOREIGNKEY) == true) {
                        //
                        $valueSetDDL = new HTMLDropdownList("cvals[]", "listItem");
                        $template->assign("DICPVALLIST", $valueSetDDL->renderObject($datasource, $valueSet, $propertySet->get_field_value("DICPVALPKID")));
                    }
                    //
                    unset($valueSet);
                    unset($valueSetDDL);
                    //
                    $template->render($block);
                    //
                    //
                    // lookup for ruled properties
                    $OBJEPROPKID = $propertySet->get_field_value("OBJEPROPKID"); // empty quirk
                    if (!empty($OBJEPROPKID)) {
                        //
                        if ($this->renderTree($datasource, $template, $block, $propertySet, $treelevel++) == false) return (false);
                    }
                }
            }
            //
            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
         * @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);
            }
            //
            switch ($view) {
                case LISTVIEW:
                    /*
                    * @see view.RepositoryModelElementExplorer.php
                    */
                    /*
                    * 1- ObjectoryElementConstraintValueSet
                    */
                    //
                    @include_once (COMPONENTS_DATA . "data.ObjectoryElementConstraintValueSet.php");
                    //
                    $propertySet = new ObjectoryElementConstraintValueSet($this->m_fieldSet["REPMELTPKID"], $this->m_fieldSet["OBJELEMPKID"]);
                    if ($propertySet->selectSet($datasource, FOREIGNKEY, NATURALKEY) == true) {
                        //
                        if (!empty($layout) && ($template->define($layout) == false)) {
                            //
                            $this->m_errorSet[VIEW_LAYOUT_ERROR] = $layout;
                            //
                            return (false);
                        }
                        //
                        @include_once (FRAMEWORK_DIR . "htmldropdownlist.php");
                        @include_once (COMPONENTS_DATA . "data.DictionaryPropertyValueSet.php");
                        @include_once (COMPONENTS_DATA . "data.ObjectoryElementRuledConstraintValueSet.php");
                        //
                        # List items
                        for ($i = 0;$i < $propertySet->rowCount();$i++) {
                            // retrieve next row
                            if ($propertySet->fetchCursorRow($datasource) == false) return (false);
                            //
                            $template->select($block);
                            $template->assign($propertySet->fieldSet());
                            //
                            // Property values Dropdownlist
                            $valueSet = new DictionaryPropertyValueSet($propertySet->get_field_value("DICPROPPKID"));
                            if ($valueSet->selectSet($datasource, FOREIGNKEY) == true) {
                                //
                                $valueSetDDL = new HTMLDropdownList("cvals[]", "listItem");
                                $template->assign("DICPVALLIST", $valueSetDDL->renderObject($datasource, $valueSet, $propertySet->get_field_value("DICPVALPKID")));
                            }
                            //
                            unset($valueSet);
                            unset($valueSetDDL);
                            //
                            $template->render($block);
                            //
                            // lookup for ruled properties
                            $OBJEPROPKID = $propertySet->get_field_value("OBJEPROPKID"); // empty quirk
                            if (!empty($OBJEPROPKID)) {
                                //
                                if ($this->renderTree($datasource, $template, $block, $propertySet, 1) == false) return (false);
                            }
                        }
                    }
                    //
                    break;
                }
                //
                $template->output($mode);
                //
                return (true);
            }
    };
    //	Class
    //---------------------------------------------------------------------
    
}
//	namespace
//-----------------------------------------------------------------------------
?>
Return current item: Entier Studio