Location: PHPKode > projects > Entier Studio > entierstudio/studio/classes/views/view.ObjectoryComponentExporter.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.ObjectoryComponentExporter.php 121 2008-03-11 20:17:41Z yannromefort $
 */
//-----------------------------------------------------------------------------
//	namespace
if (!defined("DefObjectoryComponentExporter")) {
    //-------------------------------------------------------------------------
    //	Define
    define("DefObjectoryComponentExporter", "1");
    define(ROOTVIEW, 1);
    //-------------------------------------------------------------------------
    //	Include
    @require_once (FRAMEWORK_DIR . VIEWHELPER);
    //-------------------------------------------------------------------------
    //	Class
    class ObjectoryComponentExporter extends ViewObject {
        //---------------------------------------------------------------------
        //	Constructor
        
        /**
         *
         */
        function ObjectoryComponentExporter() {
            //
            
        }
        //---------------------------------------------------------------------
        //	Methods
        /**
         *
         * @access	private
         *
         * @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
         *
         */
        function RenderList(&$datasource, &$template, $block, $value) {
            //
            $releaseSet = new ObjectoryComponentReleasedSet($value);
            if ($releaseSet->selectSet($datasource) == true) {
                //
                for ($i = 0;$i < $releaseSet->rowCount();$i++) {
                    //	select next row
                    if ($releaseSet->fetchCursorRow($datasource) == false) return (false);
                    //
                    $template->select($block);
                    $template->assign($releaseSet->fieldSet());
                    $template->render($block);
                }
            }
            //
            return (true);
        }
        /**
         *
         * @access	private
         *
         * @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
         *
         */
        function renderTree(&$datasource, &$template, $block, $value) {
            //
            $componentSet = new ObjectoryComponentSet($this->m_fieldSet["OBJECTOPKID"], $value);
            if ($componentSet->selectSet($datasource, REFLECTKEY) == true) {
                //
                for ($i = 0;$i < $componentSet->rowCount();$i++) {
                    //	select next ObjectoryComponentSet row
                    if ($componentSet->fetchCursorRow($datasource) == false) return (false);
                    //
                    $template->select($block[0]);
                    $template->assign($componentSet->fieldSet());
                    //
                    if ($componentSet->get_field_value("OBJMAKEMODE") == 2) {
                        //
                        if ($this->RenderList($datasource, $template, $block[1], $componentSet->get_field_value("OBJCOMPPKID")) == false) return (false);
                    }
                    //
                    $template->render($block[0]);
                    //	select dependent rows
                    if ($this->renderTree($datasource, $template, $block, $componentSet->get_field_value("OBJCOMPPKID")) == 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	{ ITEMVIEW, LISTVIEW, TREEVIEW }
         * @param	integer	outputmode
         *
         */
        function renderView(&$datasource, &$template, $layout, $block = NULL, $view = NULL, $mode = OUTPUT) {
            //
            if (!is_object($template)) {
                //
                $this->m_errorSet[VIEW_SYSTEM_ERROR] = true;
                //
                return (false);
            }
            //
            if ($template->define($layout) == false) {
                //
                $this->m_errorSet[VIEW_LAYOUT_ERROR] = $layout;
                //
                return (false);
            }
            //
            switch ($view) {
                case FORMVIEW:
                    /*
                    * @see handler DeploymentComponent-form.php
                    */
                    //
                    
                break;
                case ITEMVIEW:
                    /*
                    * * @see handler DeploymentComponent-view.php
                    */
                    /*
                    * 1- ObjectoryComponent
                    */
                    //
                    @include_once (COMPONENTS_DATA . "data.ObjectoryComponent.php");
                    //
                    $component = new ObjectoryComponent($this->m_fieldSet["OBJCOMPPKID"]);
                    if ($component->selectRow($datasource) == false) {
                        //
                        $this->m_errorSet[VIEW_OBJECT_ERROR] = true;
                        //
                        return (false);
                    }
                    //
                    $template->assign($component->fieldSet());
                    //
                    
                break;
                case LISTVIEW:
                    /*
                    * @see handler ObjectoryComponentExporter-list.php
                    */
                    //
                    /*
                    * 1- ObjectoryComponent
                    * 2- ObjectoryResourceSet
                    */
                    //
                    /*
                    * 1- ObjectoryComponent
                    */
                    //
                    @include_once (COMPONENTS_DATA . "data.ObjectoryComponent.php");
                    //
                    $component = new ObjectoryComponent($this->m_fieldSet["OBJCOMPPKID"]);
                    if ($component->selectRow($datasource) == false) {
                        //
                        $this->m_errorSet[VIEW_OBJECT_ERROR] = true;
                        //
                        return (false);
                    }
                    //
                    $template->assign($component->fieldSet());
                    $template->assign($this->m_fieldSet);
                    //
                    /*
                    * 2- ObjectoryResourceSet
                    */
                    //
                    @include_once (COMPONENTS_DATA . "data.ObjectoryResourceSet.php");
                    //
                    $resourceSet = new ObjectoryResourceSet($component->get_field_value("DIRPROJPKID") , HOSTRESOURCE);
                    if ($resourceSet->selectSet($datasource, FOREIGNKEY) == true) {
                        //
                        for ($i = 0;$i < $resourceSet->rowCount();$i++) {
                            //	select next row
                            if ($resourceSet->fetchCursorRow($datasource) == false) return (false);
                            //
                            $template->select($block);
                            $template->assign($resourceSet->fieldSet());
                            $template->render($block);
                        }
                    }
                    //
                    break;
                case TREEVIEW:
                    /*
                    * @see handler DeploymentComponent-tree.php
                    */
                    /*
                    * 1- ObjectoryComponent
                    */
                    //
                    @include_once (COMPONENTS_DATA . "data.ObjectoryComponent.php");
                    //
                    $component = new ObjectoryComponent($this->m_fieldSet["OBJCOMPPKID"]);
                    if ($component->selectRow($datasource) == false) {
                        //
                        $this->m_errorSet[VIEW_OBJECT_ERROR] = true;
                        //
                        return (false);
                    }
                    //
                    $template->assign($component->fieldSet());
                    //
                    /*
                    * 2- ObjectoryComponentSet
                    */
                    //
                    @include_once (COMPONENTS_DATA . "data.ObjectoryComponentSet.php");
                    @include_once (COMPONENTS_DATA . "data.ObjectoryComponentReleasedSet.php");
                    //
                    $componentSet = new ObjectoryComponentSet(0, $component->get_field_value("OBJCOMPPKID"));
                    if ($componentSet->selectSet($datasource, REFLECTKEY, REFLECTKEY) == true) {
                        //
                        for ($i = 0;$i < $componentSet->rowCount();$i++) {
                            //	select next row
                            if ($componentSet->fetchCursorRow($datasource) == false) return (false);
                            //
                            $template->select($block[0]);
                            $template->assign($componentSet->fieldSet());
                            //
                            if ($componentSet->get_field_value("OBJMAKEMODE") == 2) {
                                //
                                if ($this->RenderList($datasource, $template, $block[1], $componentSet->get_field_value("OBJCOMPPKID")) == false) return (false);
                            }
                            //
                            $template->render($block[0]);
                            //	select dependent rows
                            if ($this->renderTree($datasource, $template, $block, $componentSet->get_field_value("OBJCOMPPKID")) == false) return (false);
                        }
                    }
                    //
                    break;
                case GRIDVIEW:
                    /*
                    * @see handler ObjectoryComponentExporter-grid.php
                    */
                    /*
                    * 1- ObjectoryResourceReleasedSet
                    */
                    //
                    @include_once (COMPONENTS_DATA . "data.ObjectoryResourceReleasedSet.php");
                    //
                    $releaseSet = new ObjectoryResourceReleasedSet($this->m_fieldSet["OBJRRELMILE"]);
                    if ($releaseSet->selectSet($datasource, FOREIGNKEY, FOREIGNKEY) == true) {
                        //
                        for ($i = 0;$i < $releaseSet->rowCount();$i++) {
                            //	select next row
                            if ($releaseSet->fetchCursorRow($datasource) == false) return (false);
                            //
                            $template->select($block);
                            $template->assign($releaseSet->fieldSet());
                            $template->render($block);
                        }
                    }
                    //
                    break;
                case FRAMEVIEW:
                    /*
                    * * @see handler DeploymentComponent-frame.php
                    */
                    /*
                    * 1- ObjectoryComponent
                    */
                    //
                    @include_once (COMPONENTS_DATA . "data.ObjectoryComponent.php");
                    //
                    $component = new ObjectoryComponent($this->m_fieldSet["OBJCOMPPKID"]);
                    if ($component->selectRow($datasource) == false) {
                        //
                        $this->m_errorSet[VIEW_OBJECT_ERROR] = true;
                        //
                        return (false);
                    }
                    //
                    $template->assign($component->fieldSet());
                    //
                    break;
                case PROCVIEW:
                    /*
                    * * @see handler DeploymentComponent-proc.php
                    */
                    //
                    /*
                    * 1- ObjectoryComponent
                    * 2- ObjectoryResource
                    * 3- ComponentPublication
                    */
                    //
                    /*
                    * 1- ObjectoryComponent
                    */
                    //
                    @include_once (COMPONENTS_DATA . "data.PublicationComponent.php");
                    //
                    $component = new PublicationComponent($this->m_fieldSet["OBJCOMPPKID"]);
                    if ($component->selectRow($datasource) == false) {
                        //
                        $this->m_errorSet[VIEW_OBJECT_ERROR] = true;
                        //
                        return (false);
                    }
                    //
                    /*
                    * 2- ObjectoryResource
                    */
                    //
                    @include_once (COMPONENTS_DATA . "data.OnlineResource.php");
                    //
                    $resource = new OnlineResource($this->m_fieldSet["OBJRESOPKID"]);
                    if ($resource->selectRow($datasource) == false) {
                        //
                        $this->m_errorSet[VIEW_OBJECT_ERROR] = true;
                        //
                        return (false);
                    }
                    /*
                    * 3- ComponentPublication
                    */
                    //
                    @set_time_limit(180);
                    //
                    @include_once (COMPONENTS_PROC . "proc.ComponentPublication.php");
                    //
                    $publisher = new ComponentPublication();
                    if ($publisher->publish($datasource, $component->fieldSet() , $resource->fieldSet() , $this->m_fieldSet["PUBPROCFLAG"]) == false) {
                        //
                        $this->m_errorSet[PROC_OBJECT_ERROR] = true;
                        //
                        return (false);
                    }
                    //
                    $this->m_fieldSet["PUBLISHID"] = $publisher->publicationId();
                    $this->m_fieldSet["PUBLISHNB"] = $publisher->publishedCount();
                    $this->m_fieldSet["GARBAGENB"] = $publisher->discardedCount();
                    //
                    $template->assign($this->m_fieldSet);
                    $template->assign($component->fieldSet());
                    $template->assign($resource->fieldSet());
                    //
                    break;
                }
                //
                $template->output($mode);
                //
                return (true);
            }
        };
        //	Class
        //-------------------------------------------------------------------------
        
    }
    //	namespace
    //-----------------------------------------------------------------------------
    
?>
Return current item: Entier Studio