예제 #1
0
 function renderExceptionMessage(\Exception $exception, $debug = false)
 {
     if ($debug) {
         echo ExceptionHandlerFormatter::format($exception, true);
     } else {
         $p = Main\IO\Path::convertRelativeToAbsolute("/error.php");
         if (Main\IO\File::isFileExists($p)) {
             include $p;
         } else {
             $context = Main\Application::getInstance();
             if ($context) {
                 echo Main\Localization\Loc::getMessage("eho_render_exception_message");
             } else {
                 echo "A error occurred during execution of this script. You can turn on extended error reporting in .settings.php file.";
             }
         }
     }
 }
예제 #2
0
 private static function loadRules($siteId)
 {
     $site = SiteTable::getRow(array("filter" => array("LID" => $siteId)));
     $docRoot = $site["DOC_ROOT"];
     if (!empty($docRoot)) {
         $docRoot = IO\Path::normalize($docRoot);
     } else {
         $docRoot = Application::getDocumentRoot();
     }
     $arUrlRewrite = array();
     if (IO\File::isFileExists($docRoot . "/urlrewrite.php")) {
         include $docRoot . "/urlrewrite.php";
     }
     foreach ($arUrlRewrite as &$rule) {
         if (!isset($rule["SORT"])) {
             $rule["SORT"] = self::DEFAULT_SORT;
         }
     }
     return $arUrlRewrite;
 }
예제 #3
0
 protected function sendToEventHandler(array $handler, Event $event)
 {
     try {
         $result = true;
         $event->addDebugInfo($handler);
         if (isset($handler["TO_MODULE_ID"]) && !empty($handler["TO_MODULE_ID"]) && $handler["TO_MODULE_ID"] != 'main') {
             $result = Loader::includeModule($handler["TO_MODULE_ID"]);
         } elseif (isset($handler["TO_PATH"]) && !empty($handler["TO_PATH"])) {
             $path = ltrim($handler["TO_PATH"], "/");
             if (($path = Loader::getLocal($path)) !== false) {
                 $result = (include_once $path);
             }
         } elseif (isset($handler["FULL_PATH"]) && !empty($handler["FULL_PATH"]) && IO\File::isFileExists($handler["FULL_PATH"])) {
             $result = (include_once $handler["FULL_PATH"]);
         }
         $event->addDebugInfo($result);
         if (isset($handler["TO_METHOD_ARG"]) && is_array($handler["TO_METHOD_ARG"]) && !empty($handler["TO_METHOD_ARG"])) {
             $args = $handler["TO_METHOD_ARG"];
         } else {
             $args = array();
         }
         if ($handler["VERSION"] > 1) {
             $args[] = $event;
         } else {
             $args = array_merge($args, array_values($event->getParameters()));
         }
         $callback = null;
         if (isset($handler["CALLBACK"])) {
             $callback = $handler["CALLBACK"];
         } elseif (!empty($handler["TO_CLASS"]) && !empty($handler["TO_METHOD"]) && class_exists($handler["TO_CLASS"])) {
             $callback = array($handler["TO_CLASS"], $handler["TO_METHOD"]);
         }
         if ($callback != null) {
             $result = call_user_func_array($callback, $args);
         }
         if ($result != null && !$result instanceof EventResult) {
             $result = new EventResult(EventResult::UNDEFINED, $result, $handler["TO_MODULE_ID"]);
         }
         $event->addDebugInfo($result);
         if ($result != null) {
             $event->addResult($result);
         }
     } catch (\Exception $ex) {
         if ($event->isDebugOn()) {
             $event->addException($ex);
         } else {
             throw $ex;
         }
     }
 }