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'));
144 protected function _log($sClass, $sFnc)
150 $sShopID = $oSession->getVariable(
'actshop');
151 $sTime = date(
'Y-m-d H:i:s');
152 $sSidQuoted = $oDb->quote($oSession->getId());
153 $sUserIDQuoted = $oDb->quote($oSession->getVariable(
'usr'));
155 $sCnid = $oConfig->getRequestParameter(
'cnid');
156 $sAnid = $oConfig->getRequestParameter(
'aid') ? $oConfig->getRequestParameter(
'aid') : $oConfig->getRequestParameter(
'anid');
160 if ($sClass ==
'content') {
161 $sParameter = str_replace(
'.tpl',
'', $oConfig->getRequestParameter(
'tpl'));
162 } elseif ($sClass ==
'search') {
163 $sParameter = $oConfig->getRequestParameter(
'searchparam');
166 $sFncQuoted = $oDb->quote($sFnc);
167 $sClassQuoted = $oDb->quote($sClass);
168 $sParameterQuoted = $oDb->quote($sParameter);
170 $sQ =
"insert into oxlogs (oxtime, oxshopid, oxuserid, oxsessid, oxclass, oxfnc, oxcnid, oxanid, oxparameter) " .
171 "values( '$sTime', '$sShopID', $sUserIDQuoted, $sSidQuoted, $sClassQuoted, $sFncQuoted, " . $oDb->quote($sCnid) .
", " . $oDb->quote($sAnid) .
", $sParameterQuoted )";
183 $this->_dTimeStart = microtime(
true);
195 protected function _stopMonitor($blIsCache =
false, $blIsCached =
false, $sViewID = null, $aViewData = array())
199 $iDebug = $this->
getConfig()->getConfigParam(
'iDebug');
200 $oDebugInfo =
oxNew(
'oxDebugInfo');
202 $blHidden = ($iDebug == -1);
205 $sLogId = md5(time() . rand() . rand());
206 $sLog .=
"<div id='oxidDebugInfo_$sLogId'>";
208 $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>";
209 $sLog .=
"<div id='debugInfoBlock_$sLogId' style='display:" . ($blHidden ?
'none' :
'block') .
"' class='debugInfoBlock' align='left'>";
214 $sLog .= $oDebugInfo->formatTemplateData($aViewData);
218 $this->_dTimeEnd = microtime(
true);
221 $sLog .= $oDebugInfo->formatMemoryUsage();
223 $sLog .= $oDebugInfo->formatTimeStamp();
226 $sLog .= $oDebugInfo->formatExecutionTime($this->
getTotalTime());
231 $sLog .= $oDebugInfo->formatDbInfo();
237 if ($iDebug == 2 || $iDebug == 3 || $iDebug == 4) {
238 $sLog .= $oDebugInfo->formatAdoDbPerf();
244 $sLog .=
"<script type='text/javascript'>
245 var b = document.getElementById('oxidDebugInfo_$sLogId');
246 var c = document.body;
247 if (c) { c.appendChild(b.parentNode.removeChild(b));}
263 if ($this->_dTimeEnd && $this->_dTimeStart) {
277 if (isset($this->_blMainTasksExecuted)) {
281 startProfile(
'executeMaintenanceTasks');
282 oxNew(
"oxArticleList")->updateUpcomingPrices();
283 stopProfile(
'executeMaintenanceTasks');
301 protected function _process($sClass, $sFunction, $aParams = null, $aViewsChain = null)
303 startProfile(
'process');
312 if (!$oUtils->isSearchEngine() &&
315 $this->
_log($sClass, $sFunction);
330 $oException =
oxNew(
'oxSystemComponentException',
'Non public method cannot be accessed');
335 $oViewObject->executeFunction($oViewObject->getFncName());
341 $sOutput = $this->
_render($oViewObject);
346 $oOutput->setCharset($oViewObject->getCharSet());
353 $oOutput->sendHeaders();
356 $oOutput->output(
'content', $sOutput);
360 stopProfile(
'process');
363 $this->
_stopMonitor($oViewObject->getIsCallForCache(), $blIsCached, $sViewID, $oViewObject->getViewData());
366 $oOutput->flushOutput();
384 $oViewObject =
oxNew($sClass);
387 $oViewObject->setClassName($sClass);
388 $oViewObject->setFncName($sFunction);
389 $oViewObject->setViewParameters($aParams);
395 $oViewObject->init();
410 $blCanExecute =
true;
412 if (method_exists($oClass, $sFunction)) {
413 $oReflectionMethod =
new ReflectionMethod($oClass, $sFunction);
414 if (!$oReflectionMethod->isPublic()) {
415 $blCanExecute =
false;
419 return $blCanExecute;
432 $aErrors = $this->
_getErrors($sControllerName);
433 $aFmtErrors = array();
434 if (is_array($aErrors) && count($aErrors)) {
435 foreach ($aErrors as $sLocation => $aEx2) {
436 foreach ($aEx2 as $sKey => $oEr) {
437 $oErr = unserialize($oEr);
438 $aFmtErrors[$sLocation][$sKey] = $oErr->getOxMessage();
459 $sTemplateName = $oViewObject->render();
462 $sTemplateFile = $this->
getConfig()->getTemplatePath($sTemplateName, $this->
isAdmin());
463 if (!file_exists($sTemplateFile)) {
465 $oEx =
oxNew(
'oxSystemComponentException');
466 $oEx->setMessage(
'EXCEPTION_SYSTEMCOMPONENT_TEMPLATENOTFOUND');
467 $oEx->setComponent($sTemplateName);
469 $sTemplateName =
"message/exception.tpl";
479 $aViewData = $oOutput->processViewArray($oViewObject->getViewData(), $oViewObject->getClassName());
480 $oViewObject->setViewData($aViewData);
483 $aErrors = $this->
_getErrors($oViewObject->getClassName());
484 if (is_array($aErrors) && count($aErrors)) {
485 oxRegistry::get(
"oxUtilsView")->passAllErrorsToView($aViewData, $aErrors);
488 foreach (array_keys($aViewData) as $sViewName) {
489 $oSmarty->assign_by_ref($sViewName, $aViewData[$sViewName]);
493 $oSmarty->oxobject = $oViewObject;
496 $sOutput = $oSmarty->fetch($sTemplateName, $oViewObject->getViewId());
499 $sOutput = $oOutput->process($sOutput, $oViewObject->getClassName());
501 return $oOutput->addVersionTags($sOutput);
511 if (!$this->_oOutput) {
512 $this->_oOutput =
oxNew(
'oxOutput');
527 if (null === $this->_aErrors) {
530 if (null === $this->_aErrors) {
531 $this->_aErrors = array();
536 if (is_array($this->_aControllerErrors) && !empty($this->_aControllerErrors)) {
537 foreach ($this->_aControllerErrors as $sErrorName => $sControllerName) {
538 if ($sControllerName == $sCurrentControllerName) {
539 unset($this->_aAllErrors[$sErrorName]);
540 unset($this->_aControllerErrors[$sErrorName]);
544 $this->_aAllErrors = array();
566 if (!$blRunOnceExecuted && !$this->
isAdmin() && $oConfig->isProductiveMode()) {
569 if (file_exists($oConfig->getConfigParam(
'sShopDir') .
'/setup/index.php')) {
570 $sTpl =
'message/err_setup.tpl';
571 $oActView =
oxNew(
'oxubase');
573 $oSmarty->assign(
'oView', $oActView);
574 $oSmarty->assign(
'oViewConf', $oActView->getViewConfig());
590 $sOldReporting = error_reporting();
592 $iErrorReporting = E_ALL ^ E_NOTICE;
594 if (defined(
'E_DEPRECATED')) {
595 $iErrorReporting = $iErrorReporting ^ E_DEPRECATED;
598 if ($this->
getConfig()->isProductiveMode() && !ini_get(
'log_errors')) {
599 $iErrorReporting = 0;
603 return $iErrorReporting;
613 if (OxRegistry::get(
"OxConfigFile")->getVar(
'iDebug')) {
634 $this->
_process(
'exceptionError',
'displayExceptionError');
689 $this->
_process(
'exceptionError',
'displayExceptionError');
734 $iShopCount =
oxDb::getDb()->getOne(
'select count(*) from oxshops where oxactive = 1');
736 $sMallShopURL = $this->
getConfig()->getConfigParam(
'sMallShopURL');
739 if ($iShopCount && $iShopCount > 1 && $this->
getConfig()->getConfigParam(
'iMallMode') != 0 && !$sMallShopURL) {
740 $sClass =
'mallstart';