Location: PHPKode > projects > Entier Studio > entierstudio/studio/classes/views/view.RepositoryCoreElementPropertyList.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.RepositoryCoreElementPropertyList.php 81 2008-01-17 23:08:21Z yannromefort $
 */
//-----------------------------------------------------------------------------
//	namespace
if (!defined("DefRepositoryCoreElementPropertyList")) {
    //-------------------------------------------------------------------------
    //	Define
    define("DefRepositoryCoreElementPropertyList", "1");
    //-------------------------------------------------------------------------
    //	Include
    @require_once (FRAMEWORK_DIR . VIEWHELPER);
    //-------------------------------------------------------------------------
    //	Class
    class RepositoryCoreElementPropertyList extends ViewObject {
        //---------------------------------------------------------------------
        //	Constructor
        /*
        * @param	integer	 Repository	pkid //	foreign key
        */
        function RepositoryCoreElementPropertyList($REPOSITPKID = 0) {
            //
            $this->m_fieldSet["REPOSITPKID"] = $REPOSITPKID;
        }
        //---------------------------------------------------------------------
        //	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 RepositoryCoreElementRuledPropertySet($property->get_field_value("DICPVALPKID") , $this->m_fieldSet["REPCELEPKID"], $this->m_fieldSet["REPCELTPKID"]);
            if ($propertySet->selectSet($datasource, REFLECTKEY) == 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("pvals[]", "listItem");
                        $template->assign("DICPVALLIST", $valueSetDDL->renderObject($datasource, $valueSet, $propertySet->get_field_value("DICPVALPKID")));
                    }
                    //
                    unset($valueSet);
                    unset($valueSetDDL);
                    //
                    $template->render($block);
                    //
                    //
                    // lookup for ruled properties
                    $REPCEPVPKID = $propertySet->get_field_value("REPCEPVPKID"); // empty quirk
                    if (!empty($REPCEPVPKID)) {
                        //
                        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- RepositoryModelElementPropertySet
                    */
                    //
                    @include_once (COMPONENTS_DATA . "data.RepositoryCoreElementPropertySet.php");
                    //
                    $propertySet = new RepositoryCoreElementPropertySet($this->m_fieldSet["REPOSITPKID"], $this->m_fieldSet["REPCELTPKID"], $this->m_fieldSet["REPCELEPKID"]);
                    if ($propertySet->selectSet($datasource, FOREIGNKEY) == 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.RepositoryCoreElementRuledPropertySet.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("pvals[]", "listItem");
                                $template->assign("DICPVALLIST", $valueSetDDL->renderObject($datasource, $valueSet, $propertySet->get_field_value("DICPVALPKID")));
                            }
                            //
                            unset($valueSet);
                            unset($valueSetDDL);
                            //
                            $template->render($block);
                            //
                            // lookup for ruled properties
                            $REPCEPVPKID = $propertySet->get_field_value("REPCEPVPKID"); // empty quirk
                            if (!empty($REPCEPVPKID)) {
                                //
                                if ($this->renderTree($datasource, $template, $block, $propertySet, 1) == false) return (false);
                            }
                        }
                    }
                    //
                    break;
                }
                //
                $template->output($mode);
                //
                return (true);
            }
    };
    //	Class
    //-------------------------------------------------------------------------
    
}
//	namespace
//-----------------------------------------------------------------------------
?>
Return current item: Entier Studio