94 public function start( $sClass = null, $sFunction = null, $aParams = null, $aViewsChain = null )
101 $sFunction = ( isset( $sFunction ) ) ? $sFunction :
oxRegistry::getConfig()->getRequestParameter(
'fnc' );
103 $this->
_process( $sClass, $sFunction, $aParams, $aViewsChain );
125 if (isset($this->_blHandlerSet)) {
128 set_exception_handler(array(
oxNew(
'oxexceptionhandler', $this->
_isDebugMode()),
'handleUncaughtException'));
140 protected function _log( $sClass, $sFnc )
144 $sTime = date(
'Y-m-d H:i:s' );
145 $sSidQuoted = $oDb->quote( $this->
getSession()->getId() );
151 if ( $sClass ==
'content' ) {
153 } elseif ( $sClass ==
'search' ) {
157 $sFncQuoted = $oDb->quote( $sFnc );
158 $sClassQuoted = $oDb->quote( $sClass );
159 $sParameterQuoted = $oDb->quote( $sParameter );
162 $sQ =
"insert into oxlogs (oxtime, oxshopid, oxuserid, oxsessid, oxclass, oxfnc, oxcnid, oxanid, oxparameter) ".
163 "values( '$sTime', '$sShopID', $sUserIDQuoted, $sSidQuoted, $sClassQuoted, $sFncQuoted, ".$oDb->quote( $sCnid ).
", ".$oDb->quote( $sAnid ).
", $sParameterQuoted )";
165 $oDb->execute( $sQ );
177 $this->_dTimeStart = microtime(
true);
191 protected function _stopMonitor( $blIsCache =
false, $blIsCached =
false, $sViewID = null, $aViewData = array() )
195 $iDebug = $this->
getConfig()->getConfigParam(
'iDebug' );
196 $oDebugInfo =
oxNew(
'oxDebugInfo');
198 $blHidden = ($iDebug == -1);
201 $sLogId = md5(time().rand().rand());
202 $sLog .=
"<div id='oxidDebugInfo_$sLogId'>";
204 $sLog .=
"<div style='color:#630;margin:15px 0 0;cursor:pointer' onclick='var el=document.getElementById(\"debugInfoBlock_$sLogId\"); if (el.style.display==\"block\")el.style.display=\"none\"; else el.style.display = \"block\";'> ".$oDebugInfo->formatGeneralInfo().
"(show/hide)</div>";
205 $sLog .=
"<div id='debugInfoBlock_$sLogId' style='display:".($blHidden?
'none':
'block').
"' class='debugInfoBlock' align='left'>";
209 if ( $iDebug == 4 ) {
210 $sLog .= $oDebugInfo->formatTemplateData($aViewData);
214 $this->_dTimeEnd = microtime(
true);
217 $sLog .= $oDebugInfo->formatMemoryUsage();
219 $sLog .= $oDebugInfo->formatTimeStamp();
222 $sLog .= $oDebugInfo->formatExecutionTime($this->
getTotalTime());
224 if ( $iDebug == 7 ) {
225 $sLog .= $oDebugInfo->formatDbInfo();
228 if ( $iDebug == 2 || $iDebug == 3 || $iDebug == 4 ) {
229 $sLog .= $oDebugInfo->formatAdoDbPerf();
234 $sLog .=
"<script type='text/javascript'>
235 var b = document.getElementById('oxidDebugInfo_$sLogId');
236 var c = document.body;
237 if (c) { c.appendChild(b.parentNode.removeChild(b));}
253 if ($this->_dTimeEnd && $this->_dTimeStart) {
267 if (isset($this->_blMainTasksExecuted)) {
271 startProfile(
'executeMaintenanceTasks');
272 oxNew(
"oxArticleList")->updateUpcomingPrices();
273 stopProfile(
'executeMaintenanceTasks');
293 protected function _process( $sClass, $sFunction, $aParams = null, $aViewsChain = null )
295 startProfile(
'process');
304 if ( !$oUtils->isSearchEngine() &&
306 $this->
_log( $sClass, $sFunction );
320 throw oxNew(
'oxSystemComponentException',
'Non public method cannot be accessed' );
324 $oViewObject->executeFunction( $oViewObject->getFncName() );
329 if ( !$blIsCached ) {
330 $sOutput = $this->
_render($oViewObject);
335 $oOutput->setCharset($oViewObject->getCharSet());
342 $oOutput->sendHeaders();
345 $oOutput->output(
'content', $sOutput);
349 stopProfile(
'process');
352 $this->
_stopMonitor( $oViewObject->getIsCallForCache(), $blIsCached, $sViewID, $oViewObject->getViewData() );
355 $oOutput->flushOutput();
373 $oViewObject =
oxNew( $sClass );
376 $oViewObject->setClassName( $sClass );
377 $oViewObject->setFncName( $sFunction );
378 $oViewObject->setViewParameters( $aParams );
380 $myConfig->setActiveView( $oViewObject );
384 $oViewObject->init();
398 $blCanExecute =
true;
400 if ( method_exists( $oClass, $sFunction ) ) {
401 $oReflectionMethod =
new ReflectionMethod( $oClass, $sFunction );
402 if ( !$oReflectionMethod->isPublic() ) {
403 $blCanExecute =
false;
406 return $blCanExecute;
419 $aErrors = $this->
_getErrors( $sControllerName );
420 $aFmtErrors = array();
421 if ( is_array($aErrors) && count($aErrors) ) {
422 foreach ( $aErrors as $sLocation => $aEx2 ) {
423 foreach ( $aEx2 as $sKey => $oEr ) {
424 $oErr = unserialize( $oEr );
425 $aFmtErrors[$sLocation][$sKey] = $oErr->getOxMessage();
445 $sTemplateName = $oViewObject->render();
448 $sTemplateFile = $this->
getConfig()->getTemplatePath( $sTemplateName, $this->
isAdmin() ) ;
449 if ( !file_exists( $sTemplateFile)) {
451 $oEx =
oxNew(
'oxSystemComponentException' );
452 $oEx->setMessage(
'EXCEPTION_SYSTEMCOMPONENT_TEMPLATENOTFOUND' );
453 $oEx->setComponent( $sTemplateName );
455 $sTemplateName =
"message/exception.tpl";
465 $aViewData = $oOutput->processViewArray( $oViewObject->getViewData(), $oViewObject->getClassName() );
466 $oViewObject->setViewData( $aViewData );
469 $aErrors = $this->
_getErrors( $oViewObject->getClassName() );
470 if ( is_array($aErrors) && count($aErrors) ) {
471 oxRegistry::get(
"oxUtilsView")->passAllErrorsToView( $aViewData, $aErrors );
474 foreach ( array_keys( $aViewData ) as $sViewName ) {
475 $oSmarty->assign_by_ref( $sViewName, $aViewData[$sViewName] );
479 $oSmarty->oxobject = $oViewObject;
482 $sOutput = $oSmarty->fetch( $sTemplateName, $oViewObject->getViewId() );
485 $sOutput = $oOutput->process( $sOutput, $oViewObject->getClassName() );
486 return $oOutput->addVersionTags( $sOutput );
496 if (!$this->_oOutput) {
497 $this->_oOutput =
oxNew(
'oxOutput');
511 if ( null === $this->_aErrors ) {
514 if ( null === $this->_aErrors ) {
515 $this->_aErrors = array();
520 if ( is_array($this->_aControllerErrors) && !empty($this->_aControllerErrors) ) {
521 foreach ( $this->_aControllerErrors as $sErrorName => $sControllerName ) {
522 if ( $sControllerName == $sCurrentControllerName ) {
523 unset( $this->_aAllErrors[$sErrorName] );
524 unset( $this->_aControllerErrors[$sErrorName] );
528 $this->_aAllErrors = array();
544 $blProductive =
true;
547 $iErrorReporting = error_reporting();
548 if ( defined(
'E_DEPRECATED' ) ) {
550 $iErrorReporting = E_ALL ^ E_NOTICE ^ E_DEPRECATED;
552 $iErrorReporting = E_ALL ^ E_NOTICE;
556 if ( ! ( $blProductive =
$myConfig->isProductiveMode() ) ) {
557 if ( is_null(
$myConfig->getConfigParam(
'iDebug' )) ) {
558 $myConfig->setConfigParam(
'iDebug', -1 );
563 if ( !ini_get(
'log_errors' ) ) {
564 $iErrorReporting = 0;
567 error_reporting($iErrorReporting);
570 if ( !$blRunOnceExecuted && !$this->
isAdmin() && $blProductive ) {
574 if ( file_exists(
$myConfig->getConfigParam(
'sShopDir' ) .
'/setup/index.php' ) ) {
575 $sTpl =
'message/err_setup.tpl';
579 $oActView =
oxNew(
'oxubase' );
581 $oSmarty->assign(
'oView', $oActView );
582 $oSmarty->assign(
'oViewConf', $oActView->getViewConfig() );
597 if ( OxRegistry::get(
"OxConfigFile")->getVar(
'iDebug') ) {
616 $this->
_process(
'exceptionError',
'displayExceptionError' );
621 if ( !
$myConfig->getConfigParam(
'iDebug' ) ) {
674 $this->
_process(
'exceptionError',
'displayExceptionError' );
695 if ( $oConfig->isMall() ) {
697 $iShopCount =
oxDb::getDb()->getOne(
'select count(*) from oxshops where oxactive = 1' );
699 $sMallShopURL = $oConfig->getConfigParam(
'sMallShopURL' );
700 if ( $iShopCount && $iShopCount > 1 && $oConfig->getConfigParam(
'iMallMode' ) != 0 && !$sMallShopURL ) {
702 $sClass =
'mallstart';