diagnostics_main.php

Go to the documentation of this file.
00001 <?php
00002 
00007 class Diagnostics_Main extends oxAdminDetails
00008 {
00009 
00015     protected $_blError          = false;
00016 
00022     protected $_sErrorMessage   = null;
00023 
00029     protected $_oDiagnostics = null;
00030 
00036     protected $_oRenderer = null;
00037 
00043     protected $_oOutput = null;
00044 
00050     protected $_sShopDir = '';
00051 
00057     protected function _hasError()
00058     {
00059         return $this->_blError;
00060     }
00061 
00067     protected function _getErrorMessage()
00068     {
00069         return $this->_sErrorMessage;
00070     }
00071 
00072 
00073 
00078     public function __construct()
00079     {
00080         parent::__construct();
00081 
00082         $this->_sShopDir = $this->getConfig()->getConfigParam( 'sShopDir' );
00083         $this->_oOutput = oxNew ( "oxDiagnosticsOutput" );
00084         $this->_oRenderer = oxNew ( "oxSmartyRenderer" );
00085     }
00086 
00092     public function render()
00093     {
00094         parent::render();
00095 
00096         if ( $this->_hasError() ) {
00097             $this->_aViewData['sErrorMessage'] = $this->_getErrorMessage();
00098         }
00099 
00100         return "diagnostics_form.tpl";
00101     }
00102 
00108     protected function _getFilesToCheck()
00109     {
00110         $oDiagnostics = oxNew( 'oxDiagnostics' );
00111         $aFilePathList = $oDiagnostics->getFileCheckerPathList();
00112         $aFileExtensionList = $oDiagnostics->getFileCheckerExtensionList();
00113 
00114         $oFileCollector = oxNew ( "oxFileCollector" );
00115         $oFileCollector->setBaseDirectory( $this->_sShopDir );
00116 
00117         foreach ( $aFilePathList as $sPath ) {
00118             if ( is_file( $this->_sShopDir . $sPath ) ) {
00119                 $oFileCollector->addFile( $sPath );
00120             }
00121             elseif ( is_dir( $this->_sShopDir . $sPath ) ) {
00122                 $oFileCollector->addDirectoryFiles( $sPath, $aFileExtensionList, true );
00123             }
00124         }
00125 
00126         return $oFileCollector->getFiles();
00127     }
00128 
00135     protected function _checkOxidFiles( $aFileList )
00136     {
00137         $oFileChecker = oxNew ( "oxFileChecker" );
00138         $oFileChecker->setBaseDirectory( $this->_sShopDir );
00139         $oFileChecker->setVersion( $this->getConfig()->getVersion() );
00140         $oFileChecker->setEdition( $this->getConfig()->getEdition() );
00141         $oFileChecker->setRevision( $this->getConfig()->getRevision() );
00142 
00143         if ( !$oFileChecker->init() ) {
00144             $this->_blError = true;
00145             $this->_sErrorMessage = $oFileChecker->getErrorMessage();
00146             return null;
00147         }
00148 
00149         $oFileCheckerResult = oxNew( "oxFileCheckerResult" );
00150 
00151         $blListAllFiles = ( $this->getParam( 'listAllFiles' ) == 'listAllFiles' );
00152         $oFileCheckerResult->setListAllFiles( $blListAllFiles );
00153 
00154         foreach ( $aFileList as $sFile ) {
00155             $aCheckResult = $oFileChecker->checkFile( $sFile );
00156             $oFileCheckerResult->addResult( $aCheckResult );
00157         }
00158 
00159         return $oFileCheckerResult;
00160     }
00161 
00168     protected function _getFileCheckReport( $oFileCheckerResult )
00169     {
00170         $aViewData = array(
00171             "sVersion" => $this->getConfig()->getVersion(),
00172             "sEdition" => $this->getConfig()->getEdition(),
00173             "sRevision" => $this->getConfig()->getRevision(),
00174             "aResultSummary" => $oFileCheckerResult->getResultSummary(),
00175             "aResultOutput" => $oFileCheckerResult->getResult(),
00176         );
00177 
00178         return $this->_oRenderer->renderTemplate( "version_checker_result.tpl", $aViewData );
00179     }
00180 
00186     public function startDiagnostics()
00187     {
00188         $sReport = "";
00189 
00190         $aDiagnosticsResult = $this->_runBasicDiagnostics();
00191         $sReport .= $this->_oRenderer->renderTemplate( "diagnostics_main.tpl", $aDiagnosticsResult );
00192 
00193         if ( $this->getParam('oxdiag_frm_chkvers' ) )
00194         {
00195             $aFileList = $this->_getFilesToCheck();
00196             $oFileCheckerResult = $this->_checkOxidFiles( $aFileList );
00197 
00198             if ( $this->_hasError() ) {
00199                 return;
00200             }
00201 
00202             $sReport .= $this->_getFileCheckReport( $oFileCheckerResult );
00203         }
00204 
00205         $this->_oOutput->storeResult( $sReport );
00206 
00207         $sResult = $this->_oOutput->readResultFile();
00208         $this->_aViewData['sResult'] = $sResult;
00209     }
00210 
00211 
00212     protected function _runBasicDiagnostics()
00213     {
00214         $aViewData = array();
00215         $oDiagnostics = oxNew( 'oxDiagnostics' );
00216 
00217         $oDiagnostics->setShopLink( oxRegistry::getConfig()->getConfigParam( 'sShopURL' ) );
00218         $oDiagnostics->setEdition( oxRegistry::getConfig()->getFullEdition() );
00219         $oDiagnostics->setVersion( oxRegistry::getConfig()->getVersion() );
00220         $oDiagnostics->setRevision( oxRegistry::getConfig()->getRevision() );
00221 
00225         if ( $this->getParam( 'runAnalysis' ) ) {
00226             $aViewData['runAnalysis'] = true;
00227             $aViewData['aShopDetails'] = $oDiagnostics->getShopDetails();
00228         }
00229 
00233         if ( $this->getParam('oxdiag_frm_modules' ) ) {
00234 
00235             $sModulesDir = $this->getConfig()->getModulesDir();
00236             $oModuleList = oxNew('oxModuleList');
00237             $aModules = $oModuleList->getModulesFromDir( $sModulesDir);
00238 
00239             $aViewData['oxdiag_frm_modules'] = true;
00240             $aViewData['mylist'] = $aModules;
00241         }
00242 
00246         if ( $this->getParam('oxdiag_frm_health' ) ) {
00247 
00248             $oSysReq = new oxSysRequirements();
00249             $aViewData['oxdiag_frm_health'] = true;
00250             $aViewData['aInfo'] = $oSysReq->getSystemInfo();
00251             $aViewData['aCollations'] = $oSysReq->checkCollation();
00252         }
00253 
00258         if ( $this->getParam('oxdiag_frm_php' ) ) {
00259             $aViewData['oxdiag_frm_php'] = true;
00260             $aViewData['aPhpConfigparams'] = $oDiagnostics->getPhpSelection();
00261             $aViewData['sPhpDecoder'] = $oDiagnostics->getPhpDecoder();
00262         }
00263 
00267         if ( $this->getParam('oxdiag_frm_server' ) ) {
00268             $aViewData['isExecAllowed'] = $oDiagnostics->isExecAllowed();
00269             $aViewData['oxdiag_frm_server'] = true;
00270             $aViewData['aServerInfo'] = $oDiagnostics->getServerInfo();
00271         }
00272 
00273         if ( $this->getParam('oxdiag_frm_chkvers' ) ) {
00274             $aViewData['oxdiag_frm_chkvers'] = true;
00275         }
00276 
00277         return $aViewData;
00278     }
00279 
00285     public function downloadResultFile()
00286     {
00287         $this->_oOutput->downloadResultFile();
00288         exit();
00289     }
00290 
00296     public function getSupportContactForm()
00297     {
00298         $aLinks = array(
00299             "de" => "http://www.oxid-esales.com/de/support-services/supportanfrage.html",
00300             "en" => "http://www.oxid-esales.com/en/support-services/support-request.html"
00301         );
00302 
00303         $oLang = oxRegistry::getLang();
00304         $aLanguages = $oLang->getLanguageArray();
00305         $iLangId = $oLang->getTplLanguage();
00306         $sLangCode = $aLanguages[$iLangId]->abbr;
00307 
00308         if (!array_key_exists( $sLangCode, $aLinks))
00309             $sLangCode = "de";
00310 
00311         return $aLinks[$sLangCode];
00312     }
00313 
00320     public function getParam( $sParam )
00321     {
00322         return $this->getConfig()->getRequestParameter( $sParam );
00323     }
00324 
00325 }