Location: PHPKode > projects > Entier Studio > entierstudio/studio/classes/datas/data.ObjectoryComponentTemplate.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.ObjectoryComponentTemplate.php 81 2008-01-17 23:08:21Z yannromefort $
 */
//-----------------------------------------------------------------------------
//	namespace
if (!defined("DefObjectoryComponentTemplate")) {
    //-------------------------------------------------------------------------
    //	Define
    define("DefObjectoryComponentTemplate", "1");
    //-------------------------------------------------------------------------
    //	Include
    @require_once (FRAMEWORK_DIR . DATAROWOBJECT);
    //-------------------------------------------------------------------------
    //	Class
    class ObjectoryComponentTemplate extends DataRow {
        //---------------------------------------------------------------------
        //	Attributes
        
        /**
         *
         * @var	boolean
         * @see
         */
        var $m_Upload = false;
        //---------------------------------------------------------------------
        //	Constructor
        
        /**
         *
         * @param	integer	ObjectoryComponent	$OBJCOMPPKID	primary key
         * @param	boolean						$OBJFILEFULL	retrieve full text
         *
         */
        function ObjectoryComponentTemplate($OBJCOMPPKID = 0, $OBJFILEFULL = true) {
            //
            $this->m_tableSet[PRIMARYKEY] = "tbl_objectory_component_template";
            $this->m_indexSet[PRIMARYKEY] = "OBJCOMPPKID";
            //
            $this->m_fieldSet["OBJCOMPPKID"] = $OBJCOMPPKID;
            $this->m_fieldSet["OBJFILEFULL"] = $OBJFILEFULL;
        }
        //---------------------------------------------------------------------
        //	Properties
        
        /**
         *
         * @param	string		filename
         * @return	boolean
         *
         */
        function set_import() {
            //
            $this->m_Upload = false;
            //
            $value = @addslashes(@trim($this->m_fieldSet["OBJFILETEXT"]));
            if (!empty($value)) {
                //
                $this->m_Upload = true;
                //
                $this->m_fieldSet["OBJFILETEXT"] = $value;
                //
                return (true);
            }
            //
            return (false);
        }
        /**
         *
         * @param	string		filename
         * @return	boolean
         *
         */
        function set_upload($uploadFile = "") {
            //
            $this->m_Upload = false;
            //
            if (!empty($uploadFile)) {
                //
                $temp = $_FILES[$uploadFile]['tmp_name'];
                $mime = $_FILES[$uploadFile]['type'];
                //
                $load = @fopen($temp, "rb");
                if ($load == false) {
                    $this->m_errorSet["OBJFILETEXT"] = true;
                    return (false);
                }
                //
                while (!feof($load)) {
                    $blob.= @fread($load, 1024);
                }
                fclose($load);
                //
                $data = @addslashes(@trim($blob));
                if ($data == "") {
                    $this->m_errorSet["OBJFILETEXT"] = true;
                    return (false);
                }
                //
                $this->m_fieldSet["OBJFILETEXT"] = $data;
                $this->m_fieldSet["OBJFILEMIME"] = $mime;
                //
                $this->m_Upload = true;
                //
                return (true);
            }
            //
            return (false);
        }
        //---------------------------------------------------------------------
        //	Methods
        
        /**
         *
         * @access	protected
         *
         * @param	integer	index type
         */
        //
        function getInsertQuery($indexType = FOREIGNKEY) {
            //
            $table = $this->m_tableSet[PRIMARYKEY];
            //
            $insertSQL = "INSERT INTO $table ( ";
            $valuesSQL = "VALUES ( ";
            //
            if ($this->m_Upload == false) {
                $this->m_errorSet["OBJFILETEXT"] = true;
                return (false);
            }
            //	OBJCOMPPKID = ObjectoryComponent Pkid
            $value = $this->m_fieldSet["OBJCOMPPKID"];
            if (!empty($value)) {
                $insertSQL.= " OBJCOMPPKID";
                $valuesSQL.= " $value";
            } else {
                $this->m_errorSet["OBJCOMPPKID"] = true;
                return ("");
            }
            //	OBJETYPPKID = ObjectoryElementType Pkid
            $value = $this->m_fieldSet["OBJETYPPKID"];
            if (!empty($value)) {
                $insertSQL.= " ,OBJETYPPKID";
                $valuesSQL.= " ,$value";
            }
            //	OBJFILETEXT ObjectoryComponentTemplate file
            $value = $this->m_fieldSet["OBJFILETEXT"];
            if (!empty($value)) {
                $insertSQL.= " ,OBJFILETEXT";
                $valuesSQL.= " ,\"$value\"";
            }
            //	OBJFILELANG = ObjectoryComponentTemplate processor
            $value = $this->m_fieldSet["OBJFILELANG"];
            if (!empty($value)) {
                $insertSQL.= " ,OBJFILELANG";
                $valuesSQL.= " ,\"$value\"";
            }
            //	OBJFILEMIME = ObjectoryComponentTemplate file mime
            $value = $this->m_fieldSet["OBJFILEMIME"];
            if (!empty($value)) {
                $insertSQL.= " ,OBJFILEMIME";
                $valuesSQL.= " ,\"$value\"";
            }
            //	OBJMAKEMODE = ObjectoryComponentTemplate date
            $value = $this->m_fieldSet["OBJMAKEMODE"];
            if (!empty($value)) {
                $insertSQL.= " ,OBJMAKEMODE";
                $valuesSQL.= " ,$value";
            }
            //	OBJMAKEMIME = ObjectoryComponentTemplate output type
            $value = $this->m_fieldSet["OBJMAKEMIME"];
            if (!empty($value)) {
                $insertSQL.= " ,OBJMAKEMIME";
                $valuesSQL.= " ,$value";
            }
            //	OBJFILEDATE = ObjectoryComponentTemplate date
            $value = Date("Y-m-d H:i:s");
            $insertSQL.= " ,OBJFILEDATE";
            $valuesSQL.= " ,\"$value\"";
            //	OBJFILESTAT = ObjectoryComponentTemplate status
            $value = 1;
            $insertSQL.= " ,OBJFILESTAT";
            $valuesSQL.= " ,$value";
            //	OBJFILETYPE = ObjectoryComponentTemplate type
            $value = $this->m_fieldSet["OBJFILETYPE"];
            if (!empty($value)) {
                $insertSQL.= " ,OBJFILETYPE";
                $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_template
                    *	ON
                    *			OBJCOMPPKID
                    *
                    */
                    //
                    $field = $this->m_indexSet[PRIMARYKEY];
                    $index = $this->m_fieldSet["$field"];
                    if ($index != 0) {
                        //
                        $updateSQL = "UPDATE $table SET ";
                        //	OBJETYPPKID = ObjectoryElementType Pkid
                        $value = @trim($this->m_fieldSet["OBJETYPPKID"]);
                        if (!empty($value)) $updateSQL.= " OBJETYPPKID=$value";
                        else $updateSQL.= " OBJETYPPKID=NULL";
                        //	OBJMAKEMODE = ObjectoryComponentTemplate mode
                        $value = $this->m_fieldSet["OBJMAKEMODE"];
                        if (!empty($value)) $updateSQL.= ",OBJMAKEMODE=$value";
                        //	OBJMAKEMIME = ObjectoryComponentTemplate output type
                        $value = $this->m_fieldSet["OBJMAKEMIME"];
                        if (!empty($value)) $updateSQL.= ",OBJMAKEMIME=\"$value\"";
                        //
                        if ($this->m_Upload == true) {
                            //	OBJFILETEXT = ObjectoryComponentTemplate file
                            $value = $this->m_fieldSet["OBJFILETEXT"];
                            $updateSQL.= ",OBJFILETEXT=\"$value\"";
                            //	OBJFILELANG = ObjectoryComponentTemplate processor
                            $value = $this->m_fieldSet["OBJFILELANG"];
                            $updateSQL.= ",OBJFILELANG=\"$value\"";
                            //	OBJFILEMIME = ObjectoryComponentTemplate file mime
                            $value = $this->m_fieldSet["OBJFILEMIME"];
                            $updateSQL.= ",OBJFILEMIME=\"$value\"";
                        }
                        //
                        return ($updateSQL . " WHERE $field=$index");
                    }
                    break;
                }
                //
                return ("");
            }
            /**
             *
             * @param	integer	 index type
             * @return	string
             */
            function getSelectQuery($indexType = PRIMARYKEY) {
                //
                $table = $this->m_tableSet[PRIMARYKEY];
                //
                switch ($indexType) {
                    case PRIMARYKEY:
                        /*
                        *
                        *	SELECT
                        *			tbl_objectory_component			as t1
                        *	ON OBJCOMPPKID
                        *
                        */
                        //
                        $index = $this->m_fieldSet["OBJCOMPPKID"];
                        $value = $this->m_fieldSet["OBJFILEFULL"];
                        if ($index != 0) {
                            if ($value == true) return ("SELECT 
										OBJCOMPPKID,
										OBJETYPPKID,
										OBJFILETEXT, 
										OBJFILEMIME, 
										OBJFILELANG,
										OBJMAKEMODE,
										OBJMAKEMIME
									FROM 
										$table  
									WHERE 
										OBJCOMPPKID=$index");
                            else return ("SELECT 
										OBJCOMPPKID,
										OBJETYPPKID,
										OBJFILELANG,
										OBJMAKEMODE,
										OBJMAKEMIME
									FROM 
										$table  
									WHERE 
										OBJCOMPPKID=$index");
                        }
                        //
                        break;
                    }
                    //
                    return ("");
                }
        };
        //	Class
        //-------------------------------------------------------------------------
        
    }
    //	namespace
    //-----------------------------------------------------------------------------
    
?>
Return current item: Entier Studio