예제 #1
0
 /**
  * Handles the given Exception.
  *
  * @param Throwable|Exception $exception The Exception to handle
  * @param bool                $showTrace
  */
 public static function handleException($exception, $showTrace = true)
 {
     rex_logger::logException($exception);
     while (ob_get_level()) {
         ob_end_clean();
     }
     $status = rex_response::HTTP_INTERNAL_ERROR;
     if ($exception instanceof rex_http_exception && $exception->getHttpCode()) {
         $status = $exception->getHttpCode();
     }
     rex_response::setStatus($status);
     if (rex::isSetup() || rex::isDebugMode() || ($user = rex_backend_login::createUser()) && $user->isAdmin()) {
         // TODO add a beautiful error page with usefull debugging info
         $buf = '';
         $buf .= '<pre>';
         $buf .= '"' . get_class($exception) . '" thrown in ' . $exception->getFile() . ' on line ' . $exception->getLine() . "\n";
         if ($exception->getMessage()) {
             $buf .= '<b>' . ($exception instanceof ErrorException ? self::getErrorType($exception->getSeverity()) . ': ' : '') . $exception->getMessage() . "</b>\n";
         }
         $cause = $exception->getPrevious();
         while ($cause) {
             $buf .= "\n";
             $buf .= 'caused by ' . get_class($cause) . ' in ' . $cause->getFile() . ' on line ' . $cause->getLine() . "\n";
             if ($cause->getMessage()) {
                 $buf .= '<b>' . ($cause instanceof ErrorException ? self::getErrorType($cause->getSeverity()) . ': ' : '') . $cause->getMessage() . "</b>\n";
             }
             $cause = $cause->getPrevious();
         }
         if ($showTrace) {
             $buf .= "\n";
             $buf .= $exception->getTraceAsString();
         }
         if (!rex::isSetup() && rex::isBackend() && !rex::isSafeMode()) {
             $buf .= "\n\n";
             $buf .= '<a href="' . rex_url::backendPage('packages', ['safemode' => 1]) . '">activate safe mode</a>';
         }
         $buf .= '</pre>';
     } else {
         // TODO small error page, without debug infos
         $buf = 'Oooops, an internal error occured!';
     }
     rex_response::sendContent($buf);
     exit;
 }
예제 #2
0
파일: addon.php 프로젝트: staabm/redaxo
 /**
  * {@inheritdoc}
  */
 public function getSystemPlugins()
 {
     if (rex::isSetup() || rex::isSafeMode()) {
         // in setup and safemode this method is called before the package .lang files are added to rex_i18n
         // so don't use getProperty(), to avoid loading all properties without translations
         $properties = rex_file::getConfig($this->getPath(parent::FILE_PACKAGE));
         $systemPlugins = isset($properties['system_plugins']) ? (array) $properties['system_plugins'] : [];
     } else {
         $systemPlugins = (array) $this->getProperty('system_plugins', []);
     }
     $plugins = [];
     foreach ($systemPlugins as $plugin) {
         if ($this->pluginExists($plugin)) {
             $plugins[$plugin] = $this->getPlugin($plugin);
         }
     }
     return $plugins;
 }
예제 #3
0
파일: packages.php 프로젝트: staabm/redaxo
<?php

/**
 * Packages loading.
 *
 * @package redaxo5
 */
rex_addon::initialize(!rex::isSetup());
if (rex::isSetup() || rex::isSafeMode()) {
    $packageOrder = array_keys(rex_package::getSetupPackages());
} else {
    $packageOrder = rex::getConfig('package-order', []);
}
// in the first run, we register all folders for class- and fragment-loading,
// so it is transparent in which order the addons are included afterwards.
foreach ($packageOrder as $packageId) {
    $package = rex_package::get($packageId);
    $folder = $package->getPath();
    // add addon path for i18n
    if (is_readable($folder . 'lang')) {
        rex_i18n::addDirectory($folder . 'lang');
    }
    // add package path for fragment loading
    if (is_readable($folder . 'fragments')) {
        rex_fragment::addDirectory($folder . 'fragments' . DIRECTORY_SEPARATOR);
    }
    // add addon path for class-loading
    if (is_readable($folder . 'lib')) {
        rex_autoload::addDirectory($folder . 'lib');
    }
    if (is_readable($folder . 'vendor')) {
예제 #4
0
 public static function appendPackagePages()
 {
     $insertPages = [];
     $addons = rex::isSafeMode() ? rex_addon::getSetupAddons() : rex_addon::getAvailableAddons();
     foreach ($addons as $addon) {
         $mainPage = self::pageCreate($addon->getProperty('page'), $addon, true);
         if (is_array($pages = $addon->getProperty('pages'))) {
             foreach ($pages as $key => $page) {
                 if (strpos($key, '/') !== false) {
                     $insertPages[$key] = [$addon, $page];
                 } else {
                     self::pageCreate($page, $addon, false, $mainPage, $key, true);
                 }
             }
         }
         // handle plugins
         $plugins = rex::isSafeMode() ? $addon->getSystemPlugins() : $addon->getAvailablePlugins();
         foreach ($plugins as $plugin) {
             self::pageCreate($plugin->getProperty('page'), $plugin, false, $mainPage);
             if (is_array($pages = $plugin->getProperty('pages'))) {
                 foreach ($pages as $key => $page) {
                     if (strpos($key, '/') !== false) {
                         $insertPages[$key] = [$plugin, $page];
                     } else {
                         self::pageCreate($page, $plugin, false, $mainPage, $key, true);
                     }
                 }
             }
         }
     }
     foreach ($insertPages as $key => $packagePage) {
         list($package, $page) = $packagePage;
         $key = explode('/', $key);
         if (!isset(self::$pages[$key[0]])) {
             continue;
         }
         $parentPage = self::$pages[$key[0]];
         for ($i = 1, $count = count($key) - 1; $i < $count && $parentPage; ++$i) {
             $parentPage = $parentPage->getSubpage($key[$i]);
         }
         if ($parentPage) {
             self::pageCreate($page, $package, false, $parentPage, $key[$i], strtr($parentPage->getFullKey(), '/', '.') . '.' . $key[$i] . '.');
         }
     }
 }
예제 #5
0
파일: top.php 프로젝트: eaCe/redaxo
    $body_attr['class'][] = 'rex-is-popup';
}
// ----- EXTENSION POINT
$body_attr = rex_extension::registerPoint(new rex_extension_point('PAGE_BODY_ATTR', $body_attr));
$body = '';
foreach ($body_attr as $k => $v) {
    $body .= ' ' . $k . '="';
    if (is_array($v)) {
        $body .= rex_string::normalize(implode(' ', $v), '-', ' ');
    }
    $body .= '"';
}
$hasNavigation = $curPage->hasNavigation();
$meta_items = [];
if (rex::getUser() && $hasNavigation) {
    if (rex::isSafeMode()) {
        $item = [];
        $item['title'] = rex_i18n::msg('safemode_deactivate');
        $item['href'] = rex_url::backendController(['safemode' => 0]);
        $meta_items[] = $item;
        unset($item);
    }
    $user_name = rex::getUser()->getValue('name') != '' ? rex::getUser()->getValue('name') : rex::getUser()->getValue('login');
    $item = [];
    $item['title'] = '<span class="text-muted">' . rex_i18n::msg('logged_in_as') . '</span> <a class="rex-username" href="' . rex_url::backendPage('profile') . '" title="' . rex_i18n::msg('profile_title') . '"><i class="rex-icon rex-icon-user"></i> ' . htmlspecialchars($user_name) . '</a>';
    $meta_items[] = $item;
    unset($item);
    $item = [];
    $item['title'] = '<i class="rex-icon rex-icon-sign-out"></i> ' . rex_i18n::msg('logout');
    $item['href'] = rex_url::backendController(['rex_logout' => 1]);
    $item['attributes'] = 'class="rex-logout"' . rex::getAccesskey(rex_i18n::msg('logout'), 'logout');
예제 #6
0
파일: boot.php 프로젝트: DECAF/redaxo
<?php

if (rex_addon::get('cronjob')->isAvailable() && !rex::isSafeMode()) {
    rex_cronjob_manager::registerType('rex_cronjob_export');
}