/** * Handles autoloading of classes. * * @param string $class A class name. * * @return bool Returns true if the class has been loaded */ public static function autoload($class) { // class already exists if (self::classExists($class)) { return true; } $force = false; $lowerClass = strtolower($class); if (isset(self::$classes[$lowerClass])) { // we have a class path for the class, let's include it if (is_readable(self::$classes[$lowerClass])) { require_once self::$classes[$lowerClass]; if (self::classExists($class)) { return true; } } // there is a class path in cache, but the file does not exist or does not contain the class any more // but maybe the class exists in another already known file now // so all files have to be analysed again => $force reload $force = true; unset(self::$classes[$lowerClass]); self::$cacheChanged = true; } // Return true if class exists after calling $composerLoader if (self::$composerLoader->loadClass($class) && self::classExists($class)) { return true; } // Class not found, so reanalyse all directories if not already done or if $force==true // but only if an admin is logged in if ((!self::$reloaded || $force) && ($user = rex_backend_login::createUser()) && $user->isAdmin()) { self::reload($force); return self::autoload($class); } return false; }
<?php /** * History. * * @author jan@kristinus.de * * @package redaxo5 */ $mypage = 'history'; $history_date = rex_request('rex_history_date', 'string'); rex_perm::register('history[article_rollback]', null, rex_perm::OPTIONS); if ($history_date != '') { $user = rex_backend_login::createUser(); if (!$user) { throw new rex_exception('no permission'); } if (!$user->hasPerm('history[article_rollback]')) { throw new rex_exception('no permission for the slice version'); } rex_extension::register('ART_INIT', function (rex_extension_point $ep) { $article = $ep->getParam('article'); if ($article instanceof rex_article_content) { $article->getContentAsQuery(); } $article->setEval(true); }); rex_extension::register('ART_SLICES_QUERY', function (rex_extension_point $ep) { $history_date = rex_request('rex_history_date', 'string'); $history_revision = rex_request('history_revision', 'int', 0); $article = $ep->getParam('article');
/** * Handles a error message. * * @param int $errno The error code to handle * @param string $errstr The error message * @param string $errfile The file in which the error occured * @param int $errline The line of the file in which the error occured * * @throws ErrorException */ public static function handleError($errno, $errstr, $errfile, $errline) { if (in_array($errno, [E_USER_ERROR, E_ERROR, E_COMPILE_ERROR, E_RECOVERABLE_ERROR, E_PARSE])) { throw new ErrorException($errstr, 0, $errno, $errfile, $errline); } elseif ((error_reporting() & $errno) == $errno) { if (ini_get('display_errors') && (rex::isSetup() || rex::isDebugMode() || ($user = rex_backend_login::createUser()) && $user->isAdmin())) { echo '<div><b>' . self::getErrorType($errno) . "</b>: {$errstr} in <b>{$errfile}</b> on line <b>{$errline}</b></div>"; } rex_logger::logError($errno, $errstr, $errfile, $errline); } }