eZ Publish  [4.0]
ezwizardbaseclassloader.php
Go to the documentation of this file.
00001 <?php
00002 //
00003 // Definition of eZWizardBaseClassLoader class
00004 //
00005 // Created on: <12-Nov-2004 16:24:31 kk>
00006 //
00007 // ## BEGIN COPYRIGHT, LICENSE AND WARRANTY NOTICE ##
00008 // SOFTWARE NAME: eZ Publish
00009 // SOFTWARE RELEASE: 4.0.x
00010 // COPYRIGHT NOTICE: Copyright (C) 1999-2008 eZ Systems AS
00011 // SOFTWARE LICENSE: GNU General Public License v2.0
00012 // NOTICE: >
00013 //   This program is free software; you can redistribute it and/or
00014 //   modify it under the terms of version 2.0  of the GNU General
00015 //   Public License as published by the Free Software Foundation.
00016 //
00017 //   This program is distributed in the hope that it will be useful,
00018 //   but WITHOUT ANY WARRANTY; without even the implied warranty of
00019 //   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00020 //   GNU General Public License for more details.
00021 //
00022 //   You should have received a copy of version 2.0 of the GNU General
00023 //   Public License along with this program; if not, write to the Free
00024 //   Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
00025 //   MA 02110-1301, USA.
00026 //
00027 //
00028 // ## END COPYRIGHT, LICENSE AND WARRANTY NOTICE ##
00029 //
00030 
00031 /*! \file ezwizardbaseclassloader.php
00032 */
00033 
00034 /*!
00035   \class eZWizardBaseClassLoader ezwizardbaseclassloader.php
00036   \brief The class eZWizardBaseClassLoader does
00037 
00038 */
00039 
00040 class eZWizardBaseClassLoader
00041 {
00042     /*!
00043      \static
00044      Create new specified class
00045     */
00046     static function createClass( $tpl,
00047                                  $module,
00048                                  $stepArray,
00049                                  $basePath,
00050                                  $storageName = false,
00051                                  $metaData = false )
00052     {
00053         if ( !$storageName )
00054         {
00055             $storageName = 'eZWizard';
00056         }
00057 
00058         if ( !$metaData )
00059         {
00060             $http = eZHTTPTool::instance();
00061             $metaData = $http->sessionVariable( $storageName . '_meta' );
00062         }
00063 
00064         if ( !isset( $metaData['current_step'] ) ||
00065              $metaData['current_step'] < 0 )
00066         {
00067             $metaData['current_step'] = 0;
00068             eZDebug::writeNotice( 'Setting wizard step to : ' . $metaData['current_step'],
00069                                   'eZWizardBaseClassLoader::createClass()' );
00070         }
00071         $currentStep = $metaData['current_step'];
00072 
00073         if ( count( $stepArray ) <= $currentStep )
00074         {
00075             eZDebug::writeError( 'Invalid wizard step count: ' . $currentStep,
00076                                  'eZWizardBaseClassLoader::createClass()'  );
00077             return false;
00078         }
00079 
00080         $filePath = $basePath . $stepArray[$currentStep]['file'];
00081         if ( !file_exists( $filePath ) )
00082         {
00083             eZDebug::writeError( 'Wizard file not found : ' . $filePath,
00084                                  'eZWizardBaseClassLoader::createClass()'  );
00085             return false;
00086         }
00087 
00088         include_once( $filePath );
00089 
00090         $className = $stepArray[$currentStep]['class'];
00091         eZDebug::writeNotice( 'Creating class : ' . $className,
00092                               'eZWizardBaseClassLoader::createClass()' );
00093         $returnClass =  new $className( $tpl, $module, $storageName );
00094 
00095         if ( isset( $stepArray[$currentStep]['operation'] ) )
00096         {
00097             $operation = $stepArray[$currentStep]['operation'];
00098             return $returnClass->$operation();
00099             eZDebug::writeNotice( 'Running : "' . $className . '->' . $operation . '()". Specified in StepArray',
00100                                   'eZWizardBaseClassLoader::createClass()' );
00101         }
00102 
00103         if ( isset( $metaData['current_stage'] ) )
00104         {
00105             $returnClass->setMetaData( 'current_stage', $metaData['current_stage'] );
00106             eZDebug::writeNotice( 'Setting wizard stage to : ' . $metaData['current_stage'],
00107                                   'eZWizardBaseClassLoader::createClass()' );
00108         }
00109 
00110         return $returnClass;
00111     }
00112 }
00113 
00114 ?>