Location: PHPKode > projects > Entier Studio > entierstudio/studio/classes/datas/data.RepositoryModelComponent.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: data.RepositoryModelComponent.php 121 2008-03-11 20:17:41Z yannromefort $
 */
//-----------------------------------------------------------------------------
//	namespace
if (!defined("DefRepositoryModelComponent")) {
    //-------------------------------------------------------------------------
    //	Define
    define("DefRepositoryModelComponent", "1");
    //
    define("DEBUG", "10");
    //-------------------------------------------------------------------------
    //	Include
    @require_once (FRAMEWORK_DIR . DATAROWOBJECT);
    @require_once (FRAMEWORK_DIR . "./filters/filter.locator.php");
    @require_once (FRAMEWORK_DIR . "./filters/filter.forminput.php");
    @require_once (FRAMEWORK_DIR . "./validators/validator.locator.php");
    @require_once (FRAMEWORK_DIR . "./validators/validator.identifier.php");
    //-------------------------------------------------------------------------
    //	Class
    class RepositoryModelComponent extends DataRow {
        //---------------------------------------------------------------------
        //	Constructor
        /*
        *
        * @param	integer		RepositoryModelComponent pkid		REPMCOMPKID
        *
        */
        //
        function RepositoryModelComponent($REPMCOMPKID = 0) {
            //
            $this->m_tableSet[PRIMARYKEY] = "tbl_repository_model_component";
            //
            $this->m_indexSet[PRIMARYKEY] = "REPMCOMPKID";
            $this->m_indexSet[FOREIGNKEY] = "REPMCOTPKID";
            $this->m_indexSet[NATURALKEY] = "REPMCOMNAME";
            $this->m_indexSet[REFLECTKEY] = "REPMCOTPKID";
            //
            $this->m_fieldSet["REPMCOMPKID"] = $REPMCOMPKID;
        }
        //---------------------------------------------------------------------
        //	Methods
        /*
        *
        * @access	protected
        *
        * @param	integer	index type
        */
        //
        function getInsertQuery($indexType = FOREIGNKEY) {
            //
            $table = $this->m_tableSet[PRIMARYKEY];
            //
            $insertSQL = "INSERT INTO $table ( ";
            $valuesSQL = "VALUES ( ";
            //	REPMCOTPKID = RepositoryModelComponentType Pkid
            $value = $this->m_fieldSet["REPMCOTPKID"];
            if (!empty($value)) {
                $insertSQL.= " REPMCOTPKID";
                $valuesSQL.= " $value";
            } else {
                $this->m_errorSet["REPMCOTPKID"] = true;
                return ("");
            }
            //	REPMCOMLINK = RepositoryModelComponent reflection link
            $value = $this->m_fieldSet["REPMCOMLINK"];
            switch ($indexType) {
                case FOREIGNKEY:
                    //
                    if (isset($value)) {
                        $this->m_errorSet["REPMCOMLINK"] = true;
                        return ("");
                    }
                    //
                    
                break;
                case REFLECTKEY:
                    //
                    if (empty($value)) {
                        $this->m_errorSet["REPMCOMLINK"] = true;
                        return ("");
                    }
                    //
                    
                break;
            }
            if (isset($value)) {
                $insertSQL.= " ,REPMCOMLINK";
                $valuesSQL.= " ,$value";
            }
            //	REPMCOMROOT = RepositoryModelComponent root node
            $value = $this->m_fieldSet["REPMCOMROOT"];
            switch ($indexType) {
                case FOREIGNKEY:
                    //
                    if (isset($value)) {
                        $this->m_errorSet["REPMCOMROOT"] = true;
                        return ("");
                    }
                    //
                    
                break;
                case REFLECTKEY:
                    //
                    if (empty($value)) {
                        $this->m_errorSet["REPMCOMROOT"] = true;
                        return ("");
                    }
                    //
                    
                break;
            }
            if (isset($value)) {
                $insertSQL.= " ,REPMCOMROOT";
                $valuesSQL.= " ,$value";
            }
            //	REPCCOMPKID = RepositoryCoreComponentType Pkid
            $value = $this->m_fieldSet["REPCCOMPKID"];
            if (!empty($value)) {
                $insertSQL.= " ,REPCCOMPKID";
                $valuesSQL.= " ,$value";
            } else {
                $this->m_errorSet["REPCCOMPKID"] = true;
                return ("");
            }
            //	REPMCOMNAME = RepositoryModelComponent name
            $value = FilterFormInput::filter($this->m_fieldSet["REPMCOMNAME"]);
            if (!empty($value)) {
                $insertSQL.= " ,REPMCOMNAME";
                $valuesSQL.= " ,$value";
            } else {
                $this->m_errorSet["REPMCOMNAME"] = true;
                return ("");
            }
            //	REPMCOMPATH = RepositoryModelComponent locator
            $value = FilterLocator::filter($this->m_fieldSet["REPMCOMPATH"]);
            if (ValidatorLocator::isValid($value, $this->m_fieldSet["REPMCOTPKID"])) {
                $insertSQL.= " ,REPMCOMPATH";
                $valuesSQL.= " ,$value";
            } else {
                $this->m_errorSet["REPMCOMPATH"] = true;
                return ("");
            }
            //	REPMCOMTEXT = RepositoryModelComponent description
            $value = FilterFormInput::filter($this->m_fieldSet["REPMCOMTEXT"], true);
            if (!empty($value)) {
                $insertSQL.= " ,REPMCOMTEXT";
                $valuesSQL.= " ,$value";
            }
            //	REPMCOMDATE = RepositoryModelComponent date
            $value = Date("Y-m-d H:i:s");
            $insertSQL.= " ,REPMCOMDATE";
            $valuesSQL.= " ,\"$value\"";
            //	REPMCOMSTAT = RepositoryModelComponent status
            $value = 1;
            $insertSQL.= " ,REPMCOMSTAT";
            $valuesSQL.= " ,$value";
            //	REPMCOMTYPE = RepositoryModelComponent type
            $value = $this->m_fieldSet["REPMCOMTYPE"];
            if (!empty($value)) {
                $insertSQL.= " ,REPMCOMTYPE";
                $valuesSQL.= " ,$value";
            }
            //
            return ($insertSQL . ") " . $valuesSQL . ")");
        }
        /**
         *
         * @access	protected
         *
         * @param	integer	index type
         */
        function getUpdateQuery($indexType = PRIMARYKEY) {
            //
            $table = $this->m_tableSet[PRIMARYKEY];
            //
            switch ($indexType) {
                case PRIMARYKEY:
                    /*
                    *	UPDATE
                    *			tbl_repository_model_component
                    *	ON
                    *			REPMCOMPKID
                    *
                    */
                    //
                    $field = $this->m_indexSet[PRIMARYKEY];
                    $index = $this->m_fieldSet["$field"];
                    if ($index != 0) {
                        //
                        $updateSQL = "UPDATE $table SET ";
                        //	REPMCOMNAME = RepositoryModelComponent name
                        $value = FilterFormInput::filter($this->m_fieldSet["REPMCOMNAME"]);
                        if (!empty($value)) $updateSQL.= " REPMCOMNAME=$value";
                        else {
                            $this->m_errorSet["REPMCOMNAME"] = true;
                            return ("");
                        }
                        //	REPMCOMLINK = RepositoryModelComponent reflection link
                        $value = $this->m_fieldSet["REPMCOMLINK"];
                        if (!empty($value)) $updateSQL.= ",REPMCOMLINK=$value";
                        else {
                            if ($this->m_fieldSet["REPMCOTPKID"] != ARCHITECTURE_TYPE) {
                                $this->m_errorSet["REPMCOMLINK"] = true;
                                return ("");
                            }
                        }
                        //	REPCCOMPKID = RepositoryCoreComponentType Pkid
                        $value = @trim($this->m_fieldSet["REPCCOMPKID"]);
                        if (!empty($value)) $updateSQL.= ",REPCCOMPKID=$value";
                        else {
                            $this->m_errorSet["REPCCOMPKID"] = true;
                            return ("");
                        }
                        //	REPMCOMPATH = RepositoryModelComponent locator
                        $value = FilterLocator::filter($this->m_fieldSet["REPMCOMPATH"]);
                        if (ValidatorLocator::isValid($value, $this->m_fieldSet["REPMCOTPKID"]))
                            $updateSQL.= ",REPMCOMPATH=$value";
                        else {
                            $this->m_errorSet["REPMCOMPATH"] = true;
                            return ("");
                        }
                        //	REPMCOMTEXT = RepositoryModelComponent description
                        $value = FilterFormInput::filter($this->m_fieldSet["REPMCOMTEXT"], true);
                        if (!empty($value)) $updateSQL.= ",REPMCOMTEXT=$value";
                        //	REPMCOMSTAT = RepositoryModelComponent status
                        $value = $this->m_fieldSet["REPMCOMSTAT"];
                        $updateSQL.= ",REPMCOMSTAT=$value";
                        //	REPMCOMTYPE = RepositoryModelComponent type
                        $value = $this->m_fieldSet["REPMCOMTYPE"];
                        $updateSQL.= ",REPMCOMTYPE=$value";
                        //
                        return ($updateSQL . " WHERE $field=$index");
                    }
                    break;
                case DISPLAYKEY:
                    /*
                    *	UPDATE
                    *			tbl_repository_model_component
                    *	SET
                    *			REPMCOMNAME='~REPMCOMNAME'
                    *			REPMCOMSTAT=0
                    *	ON
                    *			REPMCOMPKID
                    *
                    */
                    //
                    $field = $this->m_indexSet[PRIMARYKEY];
                    $index = $this->m_fieldSet["$field"];
                    if ($index != 0) return ("UPDATE $table 
								SET 
									REPMCOMNAME= CONCAT('~', REPMCOMNAME, '$index' ),
									REPMCOMSTAT=0 
								WHERE 
									$field=$index 
								AND
									REPMCOMSTAT=1");
                    //
                    break;
                }
                //
                return ("");
            }
            /*
            *
            * @access	protected
            *
            * @param	integer	index type
            */
            function getSelectQuery($indexType = PRIMARYKEY) {
                //
                $table = $this->m_tableSet[PRIMARYKEY];
                //
                switch ($indexType) {
                    case PRIMARYKEY:
                        /*
                        *	SELECT
                        *			tbl_repository_model_component
                        *		<-> tbl_repository_core_component
                        *		<-> tbl_repository_core_component_type
                        *		<-> tbl_repository_model_component_type
                        *	ON
                        *		REPMCOMPKID
                        *
                        * @see
                        *
                        */
                        //
                        $index = $this->m_fieldSet["REPMCOMPKID"];
                        if ($index != 0) return ("SELECT 
									t1.*,
									t2.REPOSITPKID,
									t2.REPCCOTPKID,
									t2.REPCCOMNAME, 
									t3.REPTYPEPKID,
									t3.REPCCOTNAME, 
									t4.REPMCOTTYPE 
								FROM 
									tbl_repository_model_component as t1, 
									tbl_repository_core_component as t2, 
									tbl_repository_core_component_type as t3, 
									tbl_repository_model_component_type as t4 
								WHERE 
									t1.REPMCOMPKID=$index 
								AND 
									t1.REPMCOMSTAT<>0 
								AND 
									t1.REPCCOMPKID=t2.REPCCOMPKID 
								AND 
									t2.REPCCOMSTAT<>0 
								AND 
									t2.REPCCOTPKID=t3.REPCCOTPKID 
								AND 
									t3.REPCCOTPKID=t4.REPCCOTPKID");
                        break;
                    case FOREIGNKEY:
                        /*
                        *	SELECT
                        *				tbl_repository_core_component
                        *			<-> tbl_repository_core_component_type
                        *			<-> tbl_repository_model_component_type
                        *			<-> tbl_repository_model_component
                        *	ON
                        *			REPCCOMPKID WITH REPMCOMLINK=NULL
                        *
                        * @see class renderView in view.RepositoryModelComponentExplorer.php line 77
                        */
                        //
                        $index = $this->m_fieldSet["REPCCOMPKID"];
                        if ($index != 0) return ("SELECT 
									t1.REPCCOMPKID,
									t1.REPOSITPKID, 
									t1.REPCCOTPKID, 
									t1.REPCCOMNAME,
									t2.REPTYPEPKID,
									t4.REPMCOMPKID, 
									t4.REPMCOMTYPE 
								FROM 
									tbl_repository_core_component as t1, 
									tbl_repository_core_component_type as t2, 
									tbl_repository_model_component_type as t3, 
									tbl_repository_model_component as t4 
								WHERE 
									t1.REPCCOMPKID=$index 
								AND 
									t1.REPCCOTPKID=t2.REPCCOTPKID 
								AND 
									t2.REPCCOTPKID=t3.REPCCOTPKID 
								AND 
									t3.REPMCOTTYPE=1 
								AND 
									t3.REPMCOTSTAT>0 
								AND 
									t1.REPCCOMPKID=t4.REPCCOMPKID 
								AND 
									t3.REPMCOTPKID=t4.REPMCOTPKID 
								AND 
									t4.REPMCOMSTAT<>0");
                        //
                        break;
                    }
                    //
                    return ("");
                }
        };
        //	Class
        //-------------------------------------------------------------------------
        
    }
    //	namespace
    //-----------------------------------------------------------------------------
    
?>
Return current item: Entier Studio