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);
131 if (isset($this->_blHandlerSet)) {
135 set_exception_handler(array(
oxNew(
'oxexceptionhandler', $this->
_isDebugMode()),
'handleUncaughtException'));
147 protected function _log($sClass, $sFnc)
153 $sShopID = $oSession->getVariable(
'actshop');
154 $sTime = date(
'Y-m-d H:i:s');
155 $sSidQuoted = $oDb->quote($oSession->getId());
156 $sUserIDQuoted = $oDb->quote($oSession->getVariable(
'usr'));
158 $sCnid = $oConfig->getRequestParameter(
'cnid');
159 $sAnid = $oConfig->getRequestParameter(
'aid') ? $oConfig->getRequestParameter(
'aid') : $oConfig->getRequestParameter(
'anid');
163 if ($sClass ==
'content') {
164 $sParameter = str_replace(
'.tpl',
'', $oConfig->getRequestParameter(
'tpl'));
165 } elseif ($sClass ==
'search') {
166 $sParameter = $oConfig->getRequestParameter(
'searchparam');
169 $sFncQuoted = $oDb->quote($sFnc);
170 $sClassQuoted = $oDb->quote($sClass);
171 $sParameterQuoted = $oDb->quote($sParameter);
173 $sQ =
"insert into oxlogs (oxtime, oxshopid, oxuserid, oxsessid, oxclass, oxfnc, oxcnid, oxanid, oxparameter) " .
174 "values( '$sTime', '$sShopID', $sUserIDQuoted, $sSidQuoted, $sClassQuoted, $sFncQuoted, " . $oDb->quote($sCnid) .
", " . $oDb->quote($sAnid) .
", $sParameterQuoted )";
186 $this->_dTimeStart = microtime(
true);
198 protected function _stopMonitor($blIsCache =
false, $blIsCached =
false, $sViewID = null, $aViewData = array())
202 $iDebug = $this->
getConfig()->getConfigParam(
'iDebug');
203 $oDebugInfo =
oxNew(
'oxDebugInfo');
205 $blHidden = ($iDebug == -1);
208 $sLogId = md5(time() . rand() . rand());
209 $sLog .=
"<div id='oxidDebugInfo_$sLogId'>";
211 $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>";
212 $sLog .=
"<div id='debugInfoBlock_$sLogId' style='display:" . ($blHidden ?
'none' :
'block') .
"' class='debugInfoBlock' align='left'>";
217 $sLog .= $oDebugInfo->formatTemplateData($aViewData);
221 $this->_dTimeEnd = microtime(
true);
224 $sLog .= $oDebugInfo->formatMemoryUsage();
226 $sLog .= $oDebugInfo->formatTimeStamp();
229 $sLog .= $oDebugInfo->formatExecutionTime($this->
getTotalTime());
234 $sLog .= $oDebugInfo->formatDbInfo();
240 if ($iDebug == 2 || $iDebug == 3 || $iDebug == 4) {
241 $sLog .= $oDebugInfo->formatAdoDbPerf();
247 $sLog .=
"<script type='text/javascript'>
248 var b = document.getElementById('oxidDebugInfo_$sLogId');
249 var c = document.body;
250 if (c) { c.appendChild(b.parentNode.removeChild(b));}
266 if ($this->_dTimeEnd && $this->_dTimeStart) {
280 if (isset($this->_blMainTasksExecuted)) {
284 startProfile(
'executeMaintenanceTasks');
285 oxNew(
"oxArticleList")->updateUpcomingPrices();
286 stopProfile(
'executeMaintenanceTasks');
304 protected function _process($sClass, $sFunction, $aParams = null, $aViewsChain = null)
306 startProfile(
'process');
315 if (!$oUtils->isSearchEngine() &&
318 $this->
_log($sClass, $sFunction);
333 $oException =
oxNew(
'oxSystemComponentException',
'Non public method cannot be accessed');
338 $oViewObject->executeFunction($oViewObject->getFncName());
344 $sOutput = $this->
_render($oViewObject);
349 $oOutput->setCharset($oViewObject->getCharSet());
356 $oOutput->sendHeaders();
359 $oOutput->output(
'content', $sOutput);
363 stopProfile(
'process');
366 $this->
_stopMonitor($oViewObject->getIsCallForCache(), $blIsCached, $sViewID, $oViewObject->getViewData());
369 $oOutput->flushOutput();
387 $oViewObject =
oxNew($sClass);
390 $oViewObject->setClassName($sClass);
391 $oViewObject->setFncName($sFunction);
392 $oViewObject->setViewParameters($aParams);
398 $oViewObject->init();
413 $blCanExecute =
true;
415 if (method_exists($oClass, $sFunction)) {
416 $oReflectionMethod =
new ReflectionMethod($oClass, $sFunction);
417 if (!$oReflectionMethod->isPublic()) {
418 $blCanExecute =
false;
422 return $blCanExecute;
435 $aErrors = $this->
_getErrors($sControllerName);
436 $aFmtErrors = array();
437 if (is_array($aErrors) && count($aErrors)) {
438 foreach ($aErrors as $sLocation => $aEx2) {
439 foreach ($aEx2 as $sKey => $oEr) {
440 $oErr = unserialize($oEr);
441 $aFmtErrors[$sLocation][$sKey] = $oErr->getOxMessage();
462 $sTemplateName = $oViewObject->render();
465 $sTemplateFile = $this->
getConfig()->getTemplatePath($sTemplateName, $this->
isAdmin());
466 if (!file_exists($sTemplateFile)) {
468 $oEx =
oxNew(
'oxSystemComponentException');
469 $oEx->setMessage(
'EXCEPTION_SYSTEMCOMPONENT_TEMPLATENOTFOUND');
470 $oEx->setComponent($sTemplateName);
472 $sTemplateName =
"message/exception.tpl";
482 $aViewData = $oOutput->processViewArray($oViewObject->getViewData(), $oViewObject->getClassName());
483 $oViewObject->setViewData($aViewData);
486 $aErrors = $this->
_getErrors($oViewObject->getClassName());
487 if (is_array($aErrors) && count($aErrors)) {
488 oxRegistry::get(
"oxUtilsView")->passAllErrorsToView($aViewData, $aErrors);
491 foreach (array_keys($aViewData) as $sViewName) {
492 $oSmarty->assign_by_ref($sViewName, $aViewData[$sViewName]);
496 $oSmarty->oxobject = $oViewObject;
499 $sOutput = $oSmarty->fetch($sTemplateName, $oViewObject->getViewId());
502 $sOutput = $oOutput->process($sOutput, $oViewObject->getClassName());
504 return $oOutput->addVersionTags($sOutput);
514 if (!$this->_oOutput) {
515 $this->_oOutput =
oxNew(
'oxOutput');
530 if (null === $this->_aErrors) {
533 if (null === $this->_aErrors) {
534 $this->_aErrors = array();
539 if (is_array($this->_aControllerErrors) && !empty($this->_aControllerErrors)) {
540 foreach ($this->_aControllerErrors as $sErrorName => $sControllerName) {
541 if ($sControllerName == $sCurrentControllerName) {
542 unset($this->_aAllErrors[$sErrorName]);
543 unset($this->_aControllerErrors[$sErrorName]);
547 $this->_aAllErrors = array();
569 if (!$blRunOnceExecuted && !$this->
isAdmin() && $oConfig->isProductiveMode()) {
572 if (file_exists($oConfig->getConfigParam(
'sShopDir') .
'/setup/index.php')) {
573 $sTpl =
'message/err_setup.tpl';
574 $oActView =
oxNew(
'oxubase');
576 $oSmarty->assign(
'oView', $oActView);
577 $oSmarty->assign(
'oViewConf', $oActView->getViewConfig());
593 $sOldReporting = error_reporting();
595 $iErrorReporting = E_ALL ^ E_NOTICE;
597 if (defined(
'E_DEPRECATED')) {
598 $iErrorReporting = $iErrorReporting ^ E_DEPRECATED;
601 if ($this->
getConfig()->isProductiveMode() && !ini_get(
'log_errors')) {
602 $iErrorReporting = 0;
606 return $iErrorReporting;
616 if (OxRegistry::get(
"OxConfigFile")->getVar(
'iDebug')) {
637 $this->
_process(
'exceptionError',
'displayExceptionError');
694 $this->
_process(
'exceptionError',
'displayExceptionError');
739 $iShopCount =
oxDb::getDb()->getOne(
'select count(*) from oxshops where oxactive = 1');
741 $sMallShopURL = $this->
getConfig()->getConfigParam(
'sMallShopURL');
744 if ($iShopCount && $iShopCount > 1 && $this->
getConfig()->getConfigParam(
'iMallMode') != 0 && !$sMallShopURL) {
745 $sClass =
'mallstart';