Location: PHPKode > projects > Entier Studio > entierstudio/studio/classes/datas/data.TemporaryComponentTemplate.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.TemporaryComponentTemplate.php 81 2008-01-17 23:08:21Z yannromefort $
 */
//-----------------------------------------------------------------------------
//	namespace
if (!defined("DefTemporaryComponentTemplate")) {
    //-------------------------------------------------------------------------
    //	Define
    define("DefTemporaryComponentTemplate", "1");
    //-------------------------------------------------------------------------
    //	Include
    @require_once (FRAMEWORK_DIR . DATAROWOBJECT);
    //-------------------------------------------------------------------------
    //	Class
    class TemporaryComponentTemplate extends DataRow {
        //---------------------------------------------------------------------
        //	Attributes
        
        /**
         *
         * @var	boolean
         * @see
         */
        var $m_Upload = false;
        //---------------------------------------------------------------------
        //	Constructor
        
        /**
         *
         * @param	integer	TemporaryComponent		$TMPCOMPPKID	foreign key
         * @param	boolean							$TMPFILEFULL	retrieve full text
         *
         */
        function TemporaryComponentTemplate($TMPCOMPPKID = 0, $TMPFILEFULL = true) {
            //
            $this->m_tableSet[PRIMARYKEY] = "tbl_temporary_component_template";
            //
            $this->m_indexSet[PRIMARYKEY] = "TMPCOMPPKID";
            //
            $this->m_fieldSet["TMPCOMPPKID"] = $TMPCOMPPKID;
            $this->m_fieldSet["TMPFILEFULL"] = $TMPFILEFULL;
        }
        //---------------------------------------------------------------------
        //	Properties
        
        /**
         *
         * @param	string		filename
         * @return	boolean
         *
         */
        function set_import() {
            //
            $this->m_Upload = false;
            //
            $value = @addslashes(@trim($this->m_fieldSet["TMPFILETEXT"]));
            if (!empty($value)) {
                //
                $this->m_Upload = true;
                //
                $this->m_fieldSet["TMPFILETEXT"] = $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["TMPFILETEXT"] = true;
                    return (false);
                }
                //
                while (!feof($load)) {
                    $blob.= @fread($load, 1024);
                }
                fclose($load);
                //
                $data = @addslashes(@trim($blob));
                if ($data == "") {
                    $this->m_errorSet["TMPFILETEXT"] = true;
                    return (false);
                }
                //
                $this->m_fieldSet["TMPFILETEXT"] = $data;
                $this->m_fieldSet["TMPFILEMIME"] = $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["TMPFILETEXT"] = true;
                return (false);
            }
            //	TMPCOMPPKID = TemporaryComponent Pkid
            $value = $this->m_fieldSet["TMPCOMPPKID"];
            if (!empty($value)) {
                $insertSQL.= " TMPCOMPPKID";
                $valuesSQL.= " $value";
            } else {
                $this->m_errorSet["TMPCOMPPKID"] = true;
                return ("");
            }
            //	OBJETYPPKID = ObjectoryElementType Pkid
            $value = $this->m_fieldSet["OBJETYPPKID"];
            if (!empty($value)) {
                $insertSQL.= " ,OBJETYPPKID";
                $valuesSQL.= " ,$value";
            }
            //	TMPFILETEXT = TemporaryComponentTemplate file
            $value = $this->m_fieldSet["TMPFILETEXT"];
            if (!empty($value)) {
                $insertSQL.= " ,TMPFILETEXT";
                $valuesSQL.= " ,\"$value\"";
            }
            //	TMPFILELANG = TemporaryComponentTemplate processor
            $value = $this->m_fieldSet["TMPFILELANG"];
            if (!empty($value)) {
                $insertSQL.= " ,TMPFILELANG";
                $valuesSQL.= " ,\"$value\"";
            }
            //	TMPFILEMIME = TemporaryComponentTemplate file mime
            $value = $this->m_fieldSet["TMPFILEMIME"];
            if (!empty($value)) {
                $insertSQL.= " ,TMPFILEMIME";
                $valuesSQL.= " ,\"$value\"";
            }
            //	TMPMAKEMODE = TemporaryComponentTemplate date
            $value = $this->m_fieldSet["TMPMAKEMODE"];
            if (!empty($value)) {
                $insertSQL.= " ,TMPMAKEMODE";
                $valuesSQL.= " ,$value";
            }
            //	TMPMAKEMIME = TemporaryComponentTemplate output type
            $value = $this->m_fieldSet["TMPMAKEMIME"];
            if (!empty($value)) {
                $insertSQL.= " ,TMPMAKEMIME";
                $valuesSQL.= " ,$value";
            }
            //	TMPFILEDATE = TemporaryComponentTemplate date
            $value = Date("Y-m-d H:i:s");
            $insertSQL.= " ,TMPFILEDATE";
            $valuesSQL.= " ,\"$value\"";
            //	TMPFILESTAT = TemporaryComponentTemplate status
            $value = 1;
            $insertSQL.= " ,TMPFILESTAT";
            $valuesSQL.= " ,$value";
            //	TMPFILETYPE = TemporaryComponentTemplate type
            $value = $this->m_fieldSet["TMPFILETYPE"];
            if (!empty($value)) {
                $insertSQL.= " ,TMPFILETYPE";
                $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_temporary_component_template
                    *	ON
                    *			TMPCOMPPKID
                    *
                    */
                    //
                    $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";
                        //	TMPMAKEMODE = TemporaryComponentTemplate mode
                        $value = $this->m_fieldSet["TMPMAKEMODE"];
                        if (!empty($value)) $updateSQL.= ",TMPMAKEMODE=$value";
                        //	TMPMAKEMIME = TemporaryComponentTemplate output type
                        $value = $this->m_fieldSet["TMPMAKEMIME"];
                        if (!empty($value)) $updateSQL.= ",TMPMAKEMIME=\"$value\"";
                        //
                        if ($this->m_Upload == true) {
                            //	TMPFILETEXT = TemporaryComponentTemplate file
                            $value = $this->m_fieldSet["TMPFILETEXT"];
                            $updateSQL.= ",TMPFILETEXT=\"$value\"";
                            //	TMPFILELANG = TemporaryComponentTemplate processor
                            $value = $this->m_fieldSet["TMPFILELANG"];
                            $updateSQL.= ",TMPFILELANG=\"$value\"";
                            //	TMPFILEMIME = TemporaryComponentTemplate file mime
                            $value = $this->m_fieldSet["TMPFILEMIME"];
                            $updateSQL.= ",TMPFILEMIME=\"$value\"";
                        }
                        //
                        return ($updateSQL . " WHERE $field=$index");
                    }
                    break;
                }
                //
                return ("");
            }
            /**
             *
             * @param	integer	 index type
             * @return	string
             */
            function getSelectQuery($indexType = PRIMARYKEY) {
                //
                switch ($indexType) {
                    case PRIMARYKEY:
                        /*
                        *
                        *	SELECT
                        *			tbl_temporary_component_template			as t1
                        *	ON TMPCOMPPKID
                        *
                        */
                        //
                        $index = $this->m_fieldSet["TMPCOMPPKID"];
                        $value = $this->m_fieldSet["TMPFILEFULL"];
                        if ($index != 0) {
                            if ($value == true) return ("SELECT 
										TMPCOMPPKID,
										OBJETYPPKID,
										TMPFILETEXT,
										TMPFILEMIME,
										TMPFILELANG,
										TMPMAKEMODE,
										TMPMAKEMIME
									FROM 
										tbl_temporary_component_template
									WHERE 
										TMPCOMPPKID=$index");
                            else return ("SELECT 
										TMPCOMPPKID,
										OBJETYPPKID,
										TMPFILELANG,
										TMPMAKEMODE,
										TMPMAKEMIME
									FROM 
										tbl_temporary_component_template
									WHERE 
										TMPCOMPPKID=$index");
                        }
                        //
                        break;
                    }
                    //
                    return ("");
                }
        };
        //	Class
        //-------------------------------------------------------------------------
        
    }
    //	namespace
    //-----------------------------------------------------------------------------
    
?>
Return current item: Entier Studio