95 public function start($sClass = null, $sFunction = null, $aParams = null, $aViewsChain = null)
103 $sFunction = !is_null($sFunction) ? $sFunction :
oxRegistry::getConfig()->getRequestParameter(
'fnc');
106 $this->_process($sClass, $sFunction, $aParams, $aViewsChain);
128 if (isset($this->_blHandlerSet)) {
132 set_exception_handler(array(
oxNew(
'oxexceptionhandler', $this->
_isDebugMode()),
'handleUncaughtException'));
142 protected function _log($sClass, $sFnc)
148 $sShopID = $oSession->getVariable(
'actshop');
149 $sTime = date(
'Y-m-d H:i:s');
150 $sSidQuoted = $oDb->quote($oSession->getId());
151 $sUserIDQuoted = $oDb->quote($oSession->getVariable(
'usr'));
153 $sCnid = $oConfig->getRequestParameter(
'cnid');
154 $sAnid = $oConfig->getRequestParameter(
'aid') ? $oConfig->getRequestParameter(
'aid') : $oConfig->getRequestParameter(
'anid');
158 if ($sClass ==
'content') {
159 $sParameter = str_replace(
'.tpl',
'', $oConfig->getRequestParameter(
'tpl'));
160 } elseif ($sClass ==
'search') {
161 $sParameter = $oConfig->getRequestParameter(
'searchparam');
164 $sFncQuoted = $oDb->quote($sFnc);
165 $sClassQuoted = $oDb->quote($sClass);
166 $sParameterQuoted = $oDb->quote($sParameter);
168 $sQ =
"insert into oxlogs (oxtime, oxshopid, oxuserid, oxsessid, oxclass, oxfnc, oxcnid, oxanid, oxparameter) " .
169 "values( '$sTime', '$sShopID', $sUserIDQuoted, $sSidQuoted, $sClassQuoted, $sFncQuoted, " . $oDb->quote($sCnid) .
", " . $oDb->quote($sAnid) .
", $sParameterQuoted )";
181 $this->_dTimeStart = microtime(
true);
193 protected function _stopMonitor($blIsCache =
false, $blIsCached =
false, $sViewID = null, $aViewData = array())
197 $iDebug = $this->
getConfig()->getConfigParam(
'iDebug');
198 $oDebugInfo =
oxNew(
'oxDebugInfo');
200 $blHidden = ($iDebug == -1);
203 $sLogId = md5(time() . rand() . rand());
204 $sLog .=
"<div id='oxidDebugInfo_$sLogId'>";
206 $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>";
207 $sLog .=
"<div id='debugInfoBlock_$sLogId' style='display:" . ($blHidden ?
'none' :
'block') .
"' class='debugInfoBlock' align='left'>";
212 $sLog .= $oDebugInfo->formatTemplateData($aViewData);
216 $this->_dTimeEnd = microtime(
true);
219 $sLog .= $oDebugInfo->formatMemoryUsage();
221 $sLog .= $oDebugInfo->formatTimeStamp();
224 $sLog .= $oDebugInfo->formatExecutionTime($this->
getTotalTime());
227 $sLog .= $oDebugInfo->formatDbInfo();
230 if ($iDebug == 2 || $iDebug == 3 || $iDebug == 4) {
231 $sLog .= $oDebugInfo->formatAdoDbPerf();
236 $sLog .=
"<script type='text/javascript'>
237 var b = document.getElementById('oxidDebugInfo_$sLogId');
238 var c = document.body;
239 if (c) { c.appendChild(b.parentNode.removeChild(b));}
255 if ($this->_dTimeEnd && $this->_dTimeStart) {
269 if (isset($this->_blMainTasksExecuted)) {
273 startProfile(
'executeMaintenanceTasks');
274 oxNew(
"oxArticleList")->updateUpcomingPrices();
275 stopProfile(
'executeMaintenanceTasks');
293 protected function _process($sClass, $sFunction, $aParams = null, $aViewsChain = null)
295 startProfile(
'process');
304 if (!$oUtils->isSearchEngine() &&
307 $this->
_log($sClass, $sFunction);
322 $oException =
oxNew(
'oxSystemComponentException',
'Non public method cannot be accessed');
327 $oViewObject->executeFunction($oViewObject->getFncName());
333 $sOutput = $this->
_render($oViewObject);
338 $oOutput->setCharset($oViewObject->getCharSet());
345 $oOutput->sendHeaders();
348 $oOutput->output(
'content', $sOutput);
352 stopProfile(
'process');
355 $this->
_stopMonitor($oViewObject->getIsCallForCache(), $blIsCached, $sViewID, $oViewObject->getViewData());
358 $oOutput->flushOutput();
376 $oViewObject =
oxNew($sClass);
379 $oViewObject->setClassName($sClass);
380 $oViewObject->setFncName($sFunction);
381 $oViewObject->setViewParameters($aParams);
387 $oViewObject->init();
402 $blCanExecute =
true;
404 if (method_exists($oClass, $sFunction)) {
405 $oReflectionMethod =
new ReflectionMethod($oClass, $sFunction);
406 if (!$oReflectionMethod->isPublic()) {
407 $blCanExecute =
false;
411 return $blCanExecute;
424 $aErrors = $this->
_getErrors($sControllerName);
425 $aFmtErrors = array();
426 if (is_array($aErrors) && count($aErrors)) {
427 foreach ($aErrors as $sLocation => $aEx2) {
428 foreach ($aEx2 as $sKey => $oEr) {
429 $oErr = unserialize($oEr);
430 $aFmtErrors[$sLocation][$sKey] = $oErr->getOxMessage();
451 $sTemplateName = $oViewObject->render();
454 $sTemplateFile = $this->
getConfig()->getTemplatePath($sTemplateName, $this->
isAdmin());
455 if (!file_exists($sTemplateFile)) {
457 $oEx =
oxNew(
'oxSystemComponentException');
458 $oEx->setMessage(
'EXCEPTION_SYSTEMCOMPONENT_TEMPLATENOTFOUND');
459 $oEx->setComponent($sTemplateName);
461 $sTemplateName =
"message/exception.tpl";
471 $aViewData = $oOutput->processViewArray($oViewObject->getViewData(), $oViewObject->getClassName());
472 $oViewObject->setViewData($aViewData);
475 $aErrors = $this->
_getErrors($oViewObject->getClassName());
476 if (is_array($aErrors) && count($aErrors)) {
477 oxRegistry::get(
"oxUtilsView")->passAllErrorsToView($aViewData, $aErrors);
480 foreach (array_keys($aViewData) as $sViewName) {
481 $oSmarty->assign_by_ref($sViewName, $aViewData[$sViewName]);
485 $oSmarty->oxobject = $oViewObject;
488 $sOutput = $oSmarty->fetch($sTemplateName, $oViewObject->getViewId());
491 $sOutput = $oOutput->process($sOutput, $oViewObject->getClassName());
493 return $oOutput->addVersionTags($sOutput);
503 if (!$this->_oOutput) {
504 $this->_oOutput =
oxNew(
'oxOutput');
519 if (null === $this->_aErrors) {
522 if (null === $this->_aErrors) {
523 $this->_aErrors = array();
528 if (is_array($this->_aControllerErrors) && !empty($this->_aControllerErrors)) {
529 foreach ($this->_aControllerErrors as $sErrorName => $sControllerName) {
530 if ($sControllerName == $sCurrentControllerName) {
531 unset($this->_aAllErrors[$sErrorName]);
532 unset($this->_aControllerErrors[$sErrorName]);
536 $this->_aAllErrors = array();
558 if (!$blRunOnceExecuted && !$this->
isAdmin() && $oConfig->isProductiveMode()) {
561 if (file_exists($oConfig->getConfigParam(
'sShopDir') .
'/setup/index.php')) {
562 $sTpl =
'message/err_setup.tpl';
563 $oActView =
oxNew(
'oxubase');
565 $oSmarty->assign(
'oView', $oActView);
566 $oSmarty->assign(
'oViewConf', $oActView->getViewConfig());
582 $sOldReporting = error_reporting();
584 $iErrorReporting = E_ALL ^ E_NOTICE;
586 if (defined(
'E_DEPRECATED')) {
587 $iErrorReporting = $iErrorReporting ^ E_DEPRECATED;
590 if ($this->
getConfig()->isProductiveMode() && !ini_get(
'log_errors')) {
591 $iErrorReporting = 0;
595 return $iErrorReporting;
605 if (OxRegistry::get(
"OxConfigFile")->getVar(
'iDebug')) {
626 $this->_process(
'exceptionError',
'displayExceptionError');
681 $this->_process(
'exceptionError',
'displayExceptionError');
726 $iShopCount =
oxDb::getDb()->getOne(
'select count(*) from oxshops where oxactive = 1');
728 $sMallShopURL = $this->
getConfig()->getConfigParam(
'sMallShopURL');
731 if ($iShopCount && $iShopCount > 1 && $this->
getConfig()->getConfigParam(
'iMallMode') != 0 && !$sMallShopURL) {
732 $sClass =
'mallstart';