Location: PHPKode > projects > Entier Studio > entierstudio/classes/view.EntierStudioInstaller.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.EntierStudioInstaller.php 104 2008-02-07 21:30:22Z yannromefort $
 */
//-----------------------------------------------------------------------------
//	namespace
if (!defined("DefEntierStudioInstaller")) {
    //-------------------------------------------------------------------------
    //	Define
    define("DefEntierStudioInstaller", "1");
    define(STEP_1, 1);
    define(STEP_2, 2);
    define(STEP_3, 3);
    define(STEP_4, 4);
    define(STEP_5, 5);
    define(STEP_6, 6);
    define(STEP_7, 7);
    //-------------------------------------------------------------------------
    //	Include
    @require_once (FRAMEWORK_DIR . VIEWHELPER);
    //-------------------------------------------------------------------------
    //	Class
    class EntierStudioInstaller extends ViewObject {
        //---------------------------------------------------------------------
        //	Constructor
        
        /**
         *
         * @param
         */
        function EntierStudioInstaller($template, $database) {
            //
            parent::ViewObject($template, $database);
        }
        //---------------------------------------------------------------------
        //	Methods
        /*
        *
        * @access	public
        * @return	String
        */
        function errorString() {
            //
            switch ($this->get_error_value("DBINSTSTEP")) {
                case 1:
                    //
                    return ("missing parameter(s)");
                    //
                    
                break;
                case 2:
                    //
                    switch ($this->get_error_value("DBERRORNUM")) {
                        case DATAERR_SESS:
                            //
                            return ("MySQL session error");
                            //
                            
                        break;
                        case DATAERR_OPEN:
                            //
                            return ("cant't open connection");
                            //
                            
                        break;
                        case DATAERR_LIFE:
                            //
                            return ("existing database");
                            //
                            
                        break;
                        case DATAERR_BASE:
                            //
                            return ("can't create database");
                            //
                            
                        break;
                        case DATAERR_FILE:
                            //
                            return ("can't open file");
                            //
                            
                        break;
                        case DATAERR_DATA:
                            //
                            return ("can't read datas");
                            //
                            
                        break;
                        case DATAERR_EXEC:
                            //
                            print $this->get_error_value("DBERRORQRY");
                            exit();
                            return (" Import run error");
                            //
                            
                        break;
                    }
                    //
                    
                break;
                case 3:
                    //
                    
                break;
            }
            //
            return ("");
        }
        /**
         * write configuration parameters string
         * @access	public
         * @return	string
         */
        function writeConfigText() {
            //
            $textBuff = "<?php\n";
            $textBuff.= "\t//\n";
            $textBuff.= ("\tdefine( \"EN_SERVER_CODE\", \"" . md5(uniqid("")) . "\" );\n");
            $textBuff.= "\t//\n";
            $textBuff.= ("\tdefine( \"DB_SERVER_HOST\", \"" . $this->get_field_value("DBINSTHOST") . "\" );\n");
            $textBuff.= ("\tdefine( \"DB_SERVER_PORT\", \"" . $this->get_field_value("DBINSTPORT") . "\" );\n");
            $textBuff.= ("\tdefine( \"DB_SERVER_USER\", \"" . $this->get_field_value("DBINSTUSER") . "\" );\n");
            $textBuff.= ("\tdefine( \"DB_SERVER_PASS\", \"" . $this->get_field_value("DBINSTPASS") . "\" );\n");
            $textBuff.= ("\tdefine( \"DB_ENTIER_BASE\", \"" . $this->get_field_value("DBINSTSTEP") . "\" );\n");
            $textBuff.= "?>";
            //
            return ($textBuff);
        }
        /*
        *
        * @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($layout, $block, $view = NULL, $mode = OUTPUT) {
            //
            if (!is_object($this->m_Template)) {
                //
                $this->m_errorSet[VIEW_SYSTEM_ERROR] = true;
                //
                return (false);
            }
            //
            if (!empty($layout) && ($this->m_Template->define($layout) == false)) {
                //
                $this->m_errorSet[VIEW_LAYOUT_ERROR] = $layout;
                //
                return (false);
            }
            //
            switch ($view) {
                case STEP_1:
                    //
                    include_once (CLASSES_DIR . "proc.HostRequirements.php");
                    //
                    $hostCaps = new HostRequirements();
                    if ($hostCaps->checkRequirements() == false) $button = "step-ko";
                    else $button = "step-ok";
                    //
                    // 1- PHP Version
                    $REQUIREDPHP = $hostCaps->RequiredPHP();
                    $this->set_block_value("PHPVERSION", $hostCaps->PHPVersion());
                    $this->set_block_value("PASS01", $REQUIREDPHP ? "TestPass" : "TestFail");
                    //
                    // 2- PHP Modules
                    // 2-1 MYSQLMODULE Pass
                    $MYSQLMODULE = $hostCaps->PHPModule("mysql");
                    $this->set_block_value("MYSQLMODULE", $MYSQLMODULE ? "installed" : "not installed");
                    $this->set_block_value("PASS02", $MYSQLMODULE ? "TestPass" : "TestFail");
                    //
                    // 2-2 XSLTMODULE Pass
                    $XSLTMODULE = $hostCaps->PHPModule("xslt");
                    $this->set_block_value("XSLTMODULE", $XSLTMODULE ? "installed" : "not installed");
                    $this->set_block_value("PASS03", $XSLTMODULE ? "TestPass" : "TestFail");
                    //
                    // 2-3 FTPMODULE Pass
                    $FTPMODULE	= $hostCaps->PHPModule("ftp");
                    $this->set_block_value("FTPMODULE", $FTPMODULE ? "installed" : "not installed");
                    $this->set_block_value("PASS04", $FTPMODULE ? "TestPass" : "TestNone");
                    //
                    // 2-4 SSHMODULE Pass
                    $SSHMODULE = $hostCaps->PHPModule("ssh2");
                    $this->set_block_value("SSHMODULE", $SSHMODULE ? "installed" : "not installed");
                    $this->set_block_value("PASS05", $SSHMODULE ? "TestPass" : "TestNone");
                    //
                    // 3- SQL Version
                    $this->set_block_value("SQLVERSION", $hostCaps->SQLVersion());
                    //
                    // 4- Directories
                    // 4-1 INCLUDEDIR Pass
                    $INCLUDEDIR = $hostCaps->DirInstall("include");
                    $this->set_block_value("INCLUDEDIR", $INCLUDEDIR ? "existing" : "not existing");
                    $this->set_block_value("PASS07", $INCLUDEDIR ? "TestPass" : "TestFail");
                    //
                    // 4-2 INSTALLDIR Pass
                    $INSTALLDIR = $hostCaps->DirInstall("install");
                    $this->set_block_value("INSTALLDIR", $INSTALLDIR ? "existing" : "not existing");
                    $this->set_block_value("PASS08", $INSTALLDIR ? "TestPass" : "TestFail");
                    //
                    // 5- Files
                    // 5-1 CFGFILEDB Pass
                    $CFGFILEDB = $hostCaps->DirInstall("configdb");
                    $this->set_block_value("CFGFILEDB", $CFGFILEDB ? "writable" : "not writable");
                    $this->set_block_value("PASS09", $CFGFILEDB ? "TestPass" : "TestFail");
                    //
                    // 5-2 INSFILEDB Pass
                    $INSFILEDB = $hostCaps->DirInstall("instaldb");
                    $this->set_block_value("INSFILEDB", $INSFILEDB ? "existing" : "not existing");
                    $this->set_block_value("PASS10", $INSFILEDB ? "TestPass" : "TestFail");
                    //
                    $this->m_Template->assign($this->BlockSet());
                    //
                    $this->m_Template->select($button);
                    $this->m_Template->render($button);
                    //
                    break;
                case STEP_4:
                    /*
                    * *- Error management
                    */
                    //
                    if ($this->get_error_count() > 0) {
                        //
                        $this->m_Template->select("error");
                        //
                        $this->set_block_value("ERRORMESSAGE", $this->errorString());
                        //
                        $this->m_Template->assign($this->BlockSet());
                        $this->m_Template->render("error");
                    }
                    //
                    break;
                case STEP_5:
                    //
                    $this->set_block_value("DBINSTTEXT", $this->writeConfigText());
                    //
                    $this->m_Template->assign($this->BlockSet());
                    //
                    break;
                case STEP_6:
                    //
                    /*
                    * *- Error management
                    */
                    //
                    if ($this->get_error_count() > 0) {
                        //
                        @include_once (FRAMEWORK_VIEW . "view.ErrorMessage.php");
                        //
                        $errorMessage = new ErrorMessage($this->errorSet());
                        if ($errorMessage->renderView($this->m_Template, "error", $view) == false) {
                            $this->m_errorSet[VIEW_RENDER_ERROR] = true;
                            //
                            return (false);
                        }
                    }
                    //
                    break;
                }
                //
                $this->m_Template->output();
                //
                return (true);
            }
    };
    //	Class
    //-------------------------------------------------------------------------
    
}
//	namespace
//-----------------------------------------------------------------------------
?>
Return current item: Entier Studio