Removed legacy functions

This commit is contained in:
Marcin Kurczewski 2014-05-15 10:32:53 +02:00
parent 22b18bfbc9
commit e84f8096bd
79 changed files with 211 additions and 223 deletions

View file

@ -1,6 +1,6 @@
<?php
require_once 'src/core.php';
$config = getConfig();
$config = Core::getConfig();
$fontsPath = TextHelper::absolutePath($config->main->mediaPath . DS . 'fonts');
$libPath = TextHelper::absolutePath($config->main->mediaPath . DS . 'lib');

View file

@ -2,12 +2,12 @@
require_once '../src/core.php';
$query = rtrim($_SERVER['REQUEST_URI'], '/');
$context = getContext();
$context = Core::getContext();
$context->query = $query;
function renderView()
{
$context = getContext();
$context = Core::getContext();
\Chibi\View::render($context->layoutName, $context);
}
@ -16,7 +16,7 @@ $context->simpleActionName = null;
\Chibi\Router::setObserver(function($route, $args)
{
$context = getContext();
$context = Core::getContext();
$context->route = $route;
list ($className, $methodName) = $route->destination;
@ -36,7 +36,7 @@ $context->simpleActionName = null;
$context->simpleActionName);
});
Assets::setTitle($config->main->title);
Assets::setTitle(Core::getConfig()->main->title);
$context->handleExceptions = false;
$context->json = isset($_GET['json']);

View file

@ -7,7 +7,7 @@ class Access
public static function init()
{
self::$privileges = [];
foreach (getConfig()->privileges as $key => $minAccessRankName)
foreach (Core::getConfig()->privileges as $key => $minAccessRankName)
{
if (strpos($key, '.') === false)
$key .= '.';

View file

@ -47,6 +47,6 @@ class AddCommentJob extends AbstractJob
public function isConfirmedEmailRequired()
{
return getConfig()->registration->needEmailForCommenting;
return Core::getConfig()->registration->needEmailForCommenting;
}
}

View file

@ -6,7 +6,7 @@ class ListCommentsJob extends AbstractJob implements IPagedJob
public function __construct()
{
$this->pager = new JobPager($this);
$this->pager->setPageSize(getConfig()->comments->commentsPerPage);
$this->pager->setPageSize(Core::getConfig()->comments->commentsPerPage);
}
public function getPager()

View file

@ -53,6 +53,6 @@ class PreviewCommentJob extends AbstractJob
public function isConfirmedEmailRequired()
{
return getConfig()->registration->needEmailForCommenting;
return Core::getConfig()->registration->needEmailForCommenting;
}
}

View file

@ -6,7 +6,7 @@ class GetLogJob extends AbstractJob implements IPagedJob
public function __construct()
{
$this->pager = new JobPager($this);
$this->pager->setPageSize(getConfig()->browsing->logsPerPage);
$this->pager->setPageSize(Core::getConfig()->browsing->logsPerPage);
}
public function getPager()
@ -26,7 +26,7 @@ class GetLogJob extends AbstractJob implements IPagedJob
//parse input
$page = max(1, intval($page));
$name = str_replace(['/', '\\'], '', $name); //paranoia mode
$path = TextHelper::absolutePath(dirname(getConfig()->main->logsPath) . DS . $name);
$path = TextHelper::absolutePath(dirname(Core::getConfig()->main->logsPath) . DS . $name);
if (!file_exists($path))
throw new SimpleNotFoundException('Specified log doesn\'t exist');

View file

@ -3,7 +3,7 @@ class ListLogsJob extends AbstractJob
{
public function execute()
{
$path = TextHelper::absolutePath(getConfig()->main->logsPath);
$path = TextHelper::absolutePath(Core::getConfig()->main->logsPath);
$logs = [];
foreach (glob(dirname($path) . DS . '*.log') as $log)

View file

@ -31,7 +31,7 @@ class AddPostJob extends AbstractJob
PostModel::save($post);
Logger::log('{user} added {post} (tags: {tags}, safety: {safety}, source: {source})', [
'user' => ($anonymous and !getConfig()->misc->logAnonymousUploads)
'user' => ($anonymous and !Core::getConfig()->misc->logAnonymousUploads)
? TextHelper::reprUser(UserModel::getAnonymousName())
: TextHelper::reprUser(Auth::getCurrentUser()),
'post' => TextHelper::reprPost($post),
@ -56,6 +56,6 @@ class AddPostJob extends AbstractJob
public function isConfirmedEmailRequired()
{
return getConfig()->registration->needEmailForUploading;
return Core::getConfig()->registration->needEmailForUploading;
}
}

View file

@ -11,7 +11,7 @@ class GetPostContentJob extends AbstractJob
public function execute()
{
$post = $this->postRetriever->retrieve();
$config = getConfig();
$config = Core::getConfig();
$path = $post->tryGetWorkingFullPath();
if (!$path)

View file

@ -30,7 +30,7 @@ class GetPostThumbJob extends AbstractJob
if (!$path)
{
$path = getConfig()->main->mediaPath . DS . 'img' . DS . 'thumb.jpg';
$path = Core::getConfig()->main->mediaPath . DS . 'img' . DS . 'thumb.jpg';
$path = TextHelper::absolutePath($path);
}
}

View file

@ -6,7 +6,7 @@ class ListPostsJob extends AbstractJob implements IPagedJob
public function __construct()
{
$this->pager = new JobPager($this);
$this->pager->setPageSize(getConfig()->browsing->postsPerPage);
$this->pager->setPageSize(Core::getConfig()->browsing->postsPerPage);
}
public function getPager()

View file

@ -6,7 +6,7 @@ class ListRelatedTagsJob extends AbstractJob implements IPagedJob
public function __construct()
{
$this->pager = new JobPager($this);
$this->pager->setPageSize(getConfig()->browsing->tagsRelated);
$this->pager->setPageSize(Core::getConfig()->browsing->tagsRelated);
}
public function getPager()

View file

@ -6,7 +6,7 @@ class ListTagsJob extends AbstractJob implements IPagedJob
public function __construct()
{
$this->pager = new JobPager($this);
$this->pager->setPageSize(getConfig()->browsing->tagsPerPage);
$this->pager->setPageSize(Core::getConfig()->browsing->tagsPerPage);
}
public function getPager()

View file

@ -54,7 +54,7 @@ class ActivateUserEmailJob extends AbstractJob
public static function sendEmail($user)
{
$regConfig = getConfig()->registration;
$regConfig = Core::getConfig()->registration;
if (!$regConfig->confirmationEmailEnabled)
{

View file

@ -10,7 +10,7 @@ class EditUserEmailJob extends AbstractJob
public function execute()
{
if (getConfig()->registration->needEmailForRegistering)
if (Core::getConfig()->registration->needEmailForRegistering)
if (!$this->hasArgument(JobArgs::ARG_NEW_EMAIL) or empty($this->getArgument(JobArgs::ARG_NEW_EMAIL)))
throw new SimpleException('E-mail address is required - you will be sent confirmation e-mail.');

View file

@ -6,7 +6,7 @@ class ListUsersJob extends AbstractJob implements IPagedJob
public function __construct()
{
$this->pager = new JobPager($this);
$this->pager->setPageSize(getConfig()->browsing->usersPerPage);
$this->pager->setPageSize(Core::getConfig()->browsing->usersPerPage);
}
public function getPager()

View file

@ -58,7 +58,7 @@ class PasswordResetJob extends AbstractJob
public static function sendEmail($user)
{
$regConfig = getConfig()->registration;
$regConfig = Core::getConfig()->registration;
$mail = new Mail();
$mail->body = $regConfig->passwordResetEmailBody;

View file

@ -10,8 +10,8 @@ class Auth
public static function login($name, $password, $remember)
{
$config = getConfig();
$context = getContext();
$config = Core::getConfig();
$context = Core::getContext();
$user = UserModel::tryGetByEmail($name);
if ($user === null)

View file

@ -10,7 +10,7 @@ class AuthController
public function loginAction()
{
$context = getContext();
$context = Core::getContext();
$context->viewName = 'auth-login';
$context->handleExceptions = true;
@ -33,7 +33,7 @@ class AuthController
return;
if (\Chibi\Util\Headers::getCode() != 200)
return;
$context = getContext();
$context = Core::getContext();
if ($context->simpleControllerName == 'auth')
return;
$_SESSION['login-redirect-url'] = $context->query;

View file

@ -9,7 +9,7 @@ class CommentController
JobArgs::ARG_PAGE_NUMBER => $page,
]);
$context = getContext();
$context = Core::getContext();
$context->transport->posts = $ret->entities;
$context->transport->paginator = $ret;
}
@ -25,7 +25,7 @@ class CommentController
JobArgs::ARG_NEW_TEXT => InputHelper::get('text')
]);
getContext()->transport->textPreview = $comment->getTextMarkdown();
Core::getContext()->transport->textPreview = $comment->getTextMarkdown();
}
Api::run(
@ -38,7 +38,7 @@ class CommentController
public function editView($id)
{
getContext()->transport->comment = CommentModel::getById($id);
Core::getContext()->transport->comment = CommentModel::getById($id);
}
public function editAction($id)
@ -52,7 +52,7 @@ class CommentController
JobArgs::ARG_NEW_TEXT => InputHelper::get('text')
]);
getContext()->transport->textPreview = $comment->getTextMarkdown();
Core::getContext()->transport->textPreview = $comment->getTextMarkdown();
}
Api::run(

View file

@ -4,12 +4,12 @@ class LogController
public function listView()
{
$ret = Api::run(new ListLogsJob(), []);
getContext()->transport->logs = $ret;
Core::getContext()->transport->logs = $ret;
}
public function logView($name, $page = 1, $filter = '')
{
$context = getContext();
$context = Core::getContext();
$context->viewName = 'log-view';
//redirect requests in form of ?query=... to canonical address

View file

@ -3,7 +3,7 @@ class PostController
{
public function listView($query = null, $page = 1, $source = 'posts', $additionalInfo = null)
{
$context = getContext();
$context = Core::getContext();
$context->viewName = 'post-list-wrapper';
$context->source = $source;
$context->additionalInfo = $additionalInfo;
@ -116,7 +116,7 @@ class PostController
$post = Api::run(new GetPostJob(), [
JobArgs::ARG_POST_ID => $id]);
$context = getContext()->transport->post = $post;
$context = Core::getContext()->transport->post = $post;
}
public function editAction($id)
@ -217,7 +217,7 @@ class PostController
public function genericView($id)
{
$context = getContext();
$context = Core::getContext();
$context->viewName = 'post-view';
$post = Api::run(new GetPostJob(), [
@ -257,7 +257,7 @@ class PostController
{
$ret = Api::run(new GetPostContentJob(), [JobArgs::ARG_POST_NAME => $name]);
$context = getContext();
$context = Core::getContext();
$context->transport->cacheDaysToLive = 14;
$context->transport->customFileName = $ret->fileName;
$context->transport->mimeType = $ret->mimeType;
@ -271,7 +271,7 @@ class PostController
{
$ret = Api::run(new GetPostThumbJob(), [JobArgs::ARG_POST_NAME => $name]);
$context = getContext();
$context = Core::getContext();
$context->transport->cacheDaysToLive = 365;
$context->transport->customFileName = $ret->fileName;
$context->transport->mimeType = 'image/jpeg';

View file

@ -3,7 +3,7 @@ class StaticPagesController
{
public function mainPageView()
{
$context = getContext();
$context = Core::getContext();
$context->transport->postCount = PostModel::getCount();
$context->viewName = 'static-main';
$context->transport->postSpaceUsage = PostModel::getSpaceUsage();
@ -21,8 +21,8 @@ class StaticPagesController
public function helpView($tab = null)
{
$config = getConfig();
$context = getContext();
$config = Core::getConfig();
$context = Core::getContext();
if (empty($config->help->paths) or empty($config->help->title))
throw new SimpleException('Help is disabled');

View file

@ -10,7 +10,7 @@ class TagController
JobArgs::ARG_QUERY => $filter,
]);
$context = getContext();
$context = Core::getContext();
$context->viewName = 'tag-list-wrapper';
$context->highestUsage = TagSearchService::getMostUsedTag()->getPostCount();
$context->filter = $filter;
@ -30,7 +30,7 @@ class TagController
JobArgs::ARG_PAGE_NUMBER => 1,
]);
$context = getContext();
$context = Core::getContext();
$context->transport->tags =
array_values(array_map(
function($tag)
@ -55,7 +55,7 @@ class TagController
JobArgs::ARG_PAGE_NUMBER => 1
]);
$context = getContext();
$context = Core::getContext();
$context->transport->tags =
array_values(array_map(
function($tag)
@ -69,13 +69,13 @@ class TagController
public function mergeView()
{
$context = getContext();
$context = Core::getContext();
$context->viewName = 'tag-list-wrapper';
}
public function mergeAction()
{
$context = getContext();
$context = Core::getContext();
$context->viewName = 'tag-list-wrapper';
$context->handleExceptions = true;
@ -91,13 +91,13 @@ class TagController
public function renameView()
{
$context = getContext();
$context = Core::getContext();
$context->viewName = 'tag-list-wrapper';
}
public function renameAction()
{
$context = getContext();
$context = Core::getContext();
$context->viewName = 'tag-list-wrapper';
$context->handleExceptions = true;
@ -113,7 +113,7 @@ class TagController
public function massTagRedirectView()
{
$context = getContext();
$context = Core::getContext();
$context->viewName = 'tag-list-wrapper';
Access::assert(new Privilege(Privilege::MassTag));

View file

@ -10,7 +10,7 @@ class UserController
JobArgs::ARG_QUERY => $filter,
]);
$context = getContext();
$context = Core::getContext();
$context->filter = $filter;
$context->transport->users = $ret->entities;
@ -45,7 +45,7 @@ class UserController
elseif ($tab == 'edit' and !(new EditUserJob)->canEditAnything(Auth::getCurrentUser()))
Access::fail();
$context = getContext();
$context = Core::getContext();
$context->flagged = $flagged;
$context->transport->tab = $tab;
$context->transport->user = $user;
@ -87,7 +87,7 @@ class UserController
]
], $identifier));
getContext()->transport->user = $user;
Core::getContext()->transport->user = $user;
if ($user->getId() == Auth::getCurrentUser()->getId())
Auth::setCurrentUser($user);
@ -194,7 +194,7 @@ class UserController
public function registrationView()
{
$context = getContext();
$context = Core::getContext();
$context->handleExceptions = true;
//check if already logged in
@ -219,7 +219,7 @@ class UserController
JobArgs::ARG_NEW_EMAIL => InputHelper::get('email'),
]);
if (!getConfig()->registration->needEmailForRegistering and !getConfig()->registration->staffActivation)
if (!Core::getConfig()->registration->needEmailForRegistering and !Core::getConfig()->registration->staffActivation)
{
Auth::setCurrentUser($user);
}
@ -228,10 +228,10 @@ class UserController
if (Mailer::getMailCounter() > 0)
{
$message .= ' Please wait for activation e-mail.';
if (getConfig()->registration->staffActivation)
if (Core::getConfig()->registration->staffActivation)
$message .= ' After this, your registration must be confirmed by staff.';
}
elseif (getConfig()->registration->staffActivation)
elseif (Core::getConfig()->registration->staffActivation)
$message .= ' Your registration must be now confirmed by staff.';
Messenger::message($message);
@ -239,14 +239,14 @@ class UserController
public function activationView()
{
$context = getContext();
$context = Core::getContext();
$context->viewName = 'user-select';
Assets::setSubTitle('account activation');
}
public function activationAction($tokenText)
{
$context = getContext();
$context = Core::getContext();
$context->viewName = 'message';
Assets::setSubTitle('account activation');
$identifier = InputHelper::get('identifier');
@ -265,25 +265,25 @@ class UserController
JobArgs::ARG_TOKEN => $tokenText ]);
$message = 'Activation completed successfully.';
if (getConfig()->registration->staffActivation)
if (Core::getConfig()->registration->staffActivation)
$message .= ' However, your account still must be confirmed by staff.';
Messenger::message($message);
if (!getConfig()->registration->staffActivation)
if (!Core::getConfig()->registration->staffActivation)
Auth::setCurrentUser($user);
}
}
public function passwordResetView()
{
$context = getContext();
$context = Core::getContext();
$context->viewName = 'user-select';
Assets::setSubTitle('password reset');
}
public function passwordResetAction($tokenText)
{
$context = getContext();
$context = Core::getContext();
$context->viewName = 'message';
Assets::setSubTitle('password reset');
$identifier = InputHelper::get('identifier');
@ -310,7 +310,7 @@ class UserController
private function requirePasswordConfirmation()
{
$user = getContext()->transport->user;
$user = Core::getContext()->transport->user;
if (Auth::getCurrentUser()->getId() == $user->getId())
{
$suppliedPassword = InputHelper::get('current-password');

View file

@ -220,7 +220,7 @@ class TextHelper
public static function encrypt($text)
{
$salt = getConfig()->main->salt;
$salt = Core::getConfig()->main->salt;
$alg = MCRYPT_RIJNDAEL_256;
$mode = MCRYPT_MODE_CBC;
$iv = mcrypt_create_iv(mcrypt_get_iv_size($alg, $mode), MCRYPT_RAND);
@ -231,7 +231,7 @@ class TextHelper
{
try
{
$salt = getConfig()->main->salt;
$salt = Core::getConfig()->main->salt;
list ($iv, $hash) = explode('|', $text, 2);
$iv = base64_decode($iv);
$hash = base64_decode($hash);
@ -262,7 +262,7 @@ class TextHelper
public static function absolutePath($path)
{
if ($path{0} != DS)
$path = getConfig()->rootDir . DS . $path;
$path = Core::getConfig()->rootDir . DS . $path;
$path = self::cleanPath($path);
return $path;

View file

@ -145,7 +145,7 @@ class ThumbnailHelper
throw new SimpleException('Invalid thumbnail file type');
}
$config = getConfig();
$config = Core::getConfig();
switch ($config->browsing->thumbStyle)
{
case 'outside':

View file

@ -51,7 +51,7 @@ class Logger
public static function getLogPath()
{
return TextHelper::absolutePath(
TextHelper::replaceTokens(getConfig()->main->logsPath, [
TextHelper::replaceTokens(Core::getConfig()->main->logsPath, [
'yyyy' => date('Y'),
'mm' => date('m'),
'dd' => date('d')]));

View file

@ -6,7 +6,7 @@ class Messenger
if (empty($message))
return;
$context = getContext();
$context = Core::getContext();
if (!preg_match('/[.?!]$/', $message))
$message .= '.';

View file

@ -22,7 +22,7 @@ final class CommentEntity extends AbstractEntity implements IValidatable
public function validate()
{
$config = getConfig();
$config = Core::getConfig();
if (strlen($this->getText()) < $config->comments->minLength)
throw new SimpleException('Comment must have at least %d characters', $config->comments->minLength);

View file

@ -66,7 +66,7 @@ final class PostEntity extends AbstractEntity implements IValidatable
$this->getSafety()->validate();
$maxSourceLength = getConfig()->posts->maxSourceLength;
$maxSourceLength = Core::getConfig()->posts->maxSourceLength;
if (strlen($this->getSource()) > $maxSourceLength)
throw new SimpleException('Source must have at most %d characters', $maxSourceLength);
}
@ -351,7 +351,7 @@ final class PostEntity extends AbstractEntity implements IValidatable
public function setCustomThumbnailFromPath($srcPath)
{
$config = getConfig();
$config = Core::getConfig();
$mimeType = mime_content_type($srcPath);
if (!in_array($mimeType, ['image/gif', 'image/png', 'image/jpeg']))
@ -366,8 +366,8 @@ final class PostEntity extends AbstractEntity implements IValidatable
public function generateThumb()
{
$width = getConfig()->browsing->thumbWidth;
$height = getConfig()->browsing->thumbHeight;
$width = Core::getConfig()->browsing->thumbWidth;
$height = Core::getConfig()->browsing->thumbHeight;
$dstPath = $this->getThumbPath($width, $height);
if (file_exists($this->getThumbCustomSourcePath()))

View file

@ -21,9 +21,9 @@ final class TagEntity extends AbstractEntity implements IValidatable
public function validate()
{
$minLength = getConfig()->tags->minLength;
$maxLength = getConfig()->tags->maxLength;
$regex = getConfig()->tags->regex;
$minLength = Core::getConfig()->tags->minLength;
$maxLength = Core::getConfig()->tags->maxLength;
$regex = Core::getConfig()->tags->regex;
$name = $this->getName();

View file

@ -60,7 +60,7 @@ final class UserEntity extends AbstractEntity implements IValidatable
private function validateUserName()
{
$userName = $this->getName();
$config = getConfig();
$config = Core::getConfig();
$otherUser = UserModel::tryGetByName($userName);
if ($otherUser !== null and $otherUser->getId() != $this->getId())
@ -90,7 +90,7 @@ final class UserEntity extends AbstractEntity implements IValidatable
if (!$this->_passwordChanged)
return;
$config = getConfig();
$config = Core::getConfig();
$passMinLength = intval($config->registration->passMinLength);
$passRegex = $config->registration->passRegex;
@ -131,7 +131,7 @@ final class UserEntity extends AbstractEntity implements IValidatable
private function throwDuplicateUserError($otherUser, $reason)
{
$config = getConfig();
$config = Core::getConfig();
if (!$otherUser->getConfirmedEmail()
and isset($config->registration->needEmailForRegistering)

View file

@ -277,7 +277,7 @@ final class PostModel extends AbstractCrudModel
private static function getThumbPathTokenized($text, $name)
{
return TextHelper::absolutePath(TextHelper::replaceTokens($text, [
'fullpath' => getConfig()->main->thumbsPath . DS . $name]));
'fullpath' => Core::getConfig()->main->thumbsPath . DS . $name]));
}
public static function tryGetWorkingFullPath($name)
@ -291,7 +291,7 @@ final class PostModel extends AbstractCrudModel
public static function getFullPath($name)
{
return TextHelper::absolutePath(getConfig()->main->filesPath . DS . $name);
return TextHelper::absolutePath(Core::getConfig()->main->filesPath . DS . $name);
}
@ -303,7 +303,7 @@ final class PostModel extends AbstractCrudModel
return PropertyModel::get(PropertyModel::PostSpaceUsage);
$totalBytes = 0;
$paths = [getConfig()->main->filesPath, getConfig()->main->thumbsPath];
$paths = [Core::getConfig()->main->filesPath, Core::getConfig()->main->thumbsPath];
foreach ($paths as $path)
{
@ -332,7 +332,7 @@ final class PostModel extends AbstractCrudModel
public static function featureRandomPostIfNecessary()
{
$config = getConfig();
$config = Core::getConfig();
$featuredPostRotationTime = $config->misc->featuredPostMaxDays * 24 * 3600;
$featuredPostId = PropertyModel::get(PropertyModel::FeaturedPostId);

View file

@ -9,7 +9,7 @@ class PostSearchParser extends AbstractSearchParser
protected function processSetup(&$tokens)
{
$config = getConfig();
$config = Core::getConfig();
$this->tags = [];
$crit = new Sql\ConjunctionFunctor();

View file

@ -188,7 +188,7 @@ final class UserModel extends AbstractCrudModel
public static function hashPassword($pass, $salt2)
{
$salt1 = getConfig()->main->salt;
$salt1 = Core::getConfig()->main->salt;
return sha1($salt1 . $salt2 . $pass);
}
}

View file

@ -111,13 +111,13 @@ class UserSettings implements IValidatable
$this->set(self::SETTING_SAFETY, (new PostSafety(PostSafety::Safe))->toInteger());
if ($this->get(self::SETTING_HIDE_DISLIKED_POSTS) === null)
$this->set(self::SETTING_HIDE_DISLIKED_POSTS, !(bool) getConfig()->browsing->showDislikedPostsDefault);
$this->set(self::SETTING_HIDE_DISLIKED_POSTS, !(bool) Core::getConfig()->browsing->showDislikedPostsDefault);
if ($this->get(self::SETTING_POST_TAG_TITLES) === null)
$this->set(self::SETTING_POST_TAG_TITLES, (bool) getConfig()->browsing->showPostTagTitlesDefault);
$this->set(self::SETTING_POST_TAG_TITLES, (bool) Core::getConfig()->browsing->showPostTagTitlesDefault);
if ($this->get(self::SETTING_ENDLESS_SCROLLING) === null)
$this->set(self::SETTING_ENDLESS_SCROLLING, (bool) getConfig()->browsing->endlessScrollingDefault);
$this->set(self::SETTING_ENDLESS_SCROLLING, (bool) Core::getConfig()->browsing->endlessScrollingDefault);
}
private function ensureCorrectTypes()

View file

@ -20,7 +20,7 @@ Assets::setSubTitle('comments');
<?php
$this->context->post = $post;
$comments = array_reverse($post->getComments());
$commentsToDisplay = array_slice($comments, 0, getConfig()->comments->maxCommentsInList);
$commentsToDisplay = array_slice($comments, 0, Core::getConfig()->comments->maxCommentsInList);
?>
<?php \Chibi\View::render('post-small', $this->context) ?>
</div>

View file

@ -41,7 +41,7 @@ Assets::addScript('core.js');
<hr/>
<div class="left">
<span>
<a href="<?= getConfig()->misc->githubLink ?>">
<a href="<?= Core::getConfig()->misc->githubLink ?>">
szurubooru&nbsp;<?= PropertyModel::get(PropertyModel::EngineVersion) ?>
</a>
</span>
@ -59,7 +59,7 @@ Assets::addScript('core.js');
</div>
</footer>
<?php if (getConfig()->misc->debugQueries): ?>
<?php if (Core::getConfig()->misc->debugQueries): ?>
<?= \Chibi\View::render('debug', $this->context) ?>
<?php endif ?>

View file

@ -29,7 +29,7 @@ if (!function_exists('pageUrl'))
{
function pageUrl($page)
{
$context = getContext();
$context = Core::getContext();
$destination = $context->route->destination;
$page = max(1, min($context->transport->paginator->pageCount, $page));
$params = $context->route->arguments;

View file

@ -2,7 +2,7 @@
Assets::setSubtitle('help');
Assets::addStylesheet('static-help.css');
$tabs = getConfig()->help->subTitles;
$tabs = Core::getConfig()->help->subTitles;
$firstTab = !empty($tabs) ? array_keys($tabs)[0] : null;
$showTabs = count($tabs) > 1;
?>

View file

@ -4,7 +4,7 @@ Assets::addStylesheet('static-main.css');
?>
<div id="welcome">
<h1><?= getConfig()->main->title ?></h1>
<h1><?= Core::getConfig()->main->title ?></h1>
<p>
<span>
<?php printf('serving %d posts (%s)',

View file

@ -85,10 +85,10 @@
\Chibi\Router::linkTo(['AuthController', 'logoutAction']));
}
if (!empty(getConfig()->help->title))
if (!empty(Core::getConfig()->help->title))
{
$registerNavItem(
getConfig()->help->title,
Core::getConfig()->help->title,
\Chibi\Router::linkTo(['StaticPagesController', 'helpView']),
$activeController == 'static-pages' and $activeAction == 'help');
}

View file

@ -14,7 +14,7 @@ Assets::addStylesheet('user-list.css');
'order:date,desc' => 'Sort new&rarr;old',
];
if (getConfig()->registration->staffActivation)
if (Core::getConfig()->registration->staffActivation)
$filters['pending'] = 'Pending staff review';
?>

View file

@ -104,7 +104,7 @@ Assets::addStylesheet('user-view.css');
if (Access::check(new Privilege(Privilege::AcceptUserRegistration))
and !$this->context->transport->user->isStaffConfirmed()
and getConfig()->registration->staffActivation)
and Core::getConfig()->registration->staffActivation)
{
$options []=
[

View file

@ -37,7 +37,6 @@ final class Core
static function prepareConfig($testEnvironment)
{
//load config manually
global $config;
global $rootDir;
$configPaths = [];
@ -178,16 +177,5 @@ final class Core
}
}
//legacy
function getConfig()
{
return Core::getConfig();
}
function getContext()
{
return Core::getContext();
}
Core::prepareConfig(false);
Core::prepareEnvironment(false);

View file

@ -10,7 +10,7 @@ class TestSupport
public function getPath($assetName)
{
return TextHelper::absolutePath(getConfig()->rootDir . DS . 'tests' . DS . 'Files' . DS . $assetName);
return TextHelper::absolutePath(Core::getConfig()->rootDir . DS . 'tests' . DS . 'Files' . DS . $assetName);
}
public function assertTagNames($post, $tags)

View file

@ -19,7 +19,7 @@ abstract class AbstractFullApiTest extends AbstractTest
protected function getAllJobs()
{
$pathToJobs = getConfig()->rootDir . DS . 'src' . DS . 'Api' . DS . 'Jobs';
$pathToJobs = Core::getConfig()->rootDir . DS . 'src' . DS . 'Api' . DS . 'Jobs';
$directory = new RecursiveDirectoryIterator($pathToJobs);
$iterator = new RecursiveIteratorIterator($directory);
$regex = new RegexIterator($iterator, '/^.+Job\.php$/i');

View file

@ -33,13 +33,13 @@ class AbstractTest
protected function grantAccess($privilege)
{
getConfig()->privileges->$privilege = 'anonymous';
Core::getConfig()->privileges->$privilege = 'anonymous';
Access::init();
}
protected function revokeAccess($privilege)
{
getConfig()->privileges->$privilege = 'nobody';
Core::getConfig()->privileges->$privilege = 'nobody';
Access::init();
}
}

View file

@ -60,7 +60,7 @@ class ApiAuthTest extends AbstractFullApiTest
public function testAuthEnforcing()
{
getConfig()->registration->needEmailForCommenting = false;
Core::getConfig()->registration->needEmailForCommenting = false;
$this->grantAccess('addComment');
$comment = $this->commentMocker->mockSingle();

View file

@ -3,8 +3,8 @@ class ApiEmailRequirementsTest extends AbstractFullApiTest
{
public function testRegularEmailRequirements()
{
getConfig()->registration->needEmailForCommenting = true;
getConfig()->registration->needEmailForUploading = true;
Core::getConfig()->registration->needEmailForCommenting = true;
Core::getConfig()->registration->needEmailForUploading = true;
$this->testRegularEmailRequirement(new AcceptUserRegistrationJob());
$this->testRegularEmailRequirement(new ActivateUserEmailJob());
@ -68,10 +68,10 @@ class ApiEmailRequirementsTest extends AbstractFullApiTest
{
$this->testedJobs []= $job;
getConfig()->registration->needEmailForCommenting = false;
Core::getConfig()->registration->needEmailForCommenting = false;
$this->assert->areEqual(false, $job->isConfirmedEmailRequired());
getConfig()->registration->needEmailForCommenting = true;
Core::getConfig()->registration->needEmailForCommenting = true;
$this->assert->areEqual(true, $job->isConfirmedEmailRequired());
}
@ -81,10 +81,10 @@ class ApiEmailRequirementsTest extends AbstractFullApiTest
$this->testedJobs []= $job;
getConfig()->registration->needEmailForUploading = false;
Core::getConfig()->registration->needEmailForUploading = false;
$this->assert->areEqual(false, $job->isConfirmedEmailRequired());
getConfig()->registration->needEmailForUploading = true;
Core::getConfig()->registration->needEmailForUploading = true;
$this->assert->areEqual(true, $job->isConfirmedEmailRequired());
}
@ -92,7 +92,7 @@ class ApiEmailRequirementsTest extends AbstractFullApiTest
{
$this->grantAccess('addComment');
$this->login($this->userMocker->mockSingle());
getConfig()->registration->needEmailForCommenting = true;
Core::getConfig()->registration->needEmailForCommenting = true;
$this->assert->throws(function()
{
$post = $this->postMocker->mockSingle();

View file

@ -195,7 +195,7 @@ class ApiPrivilegeTest extends AbstractFullApiTest
$this->assert->throws(function()
{
$post = $this->postMocker->mockSingle();
getConfig()->registration->needEmailForCommenting = false;
Core::getConfig()->registration->needEmailForCommenting = false;
return Api::run(
new AddCommentJob(),
[

View file

@ -3,7 +3,7 @@ class ActivateUserEmailJobTest extends AbstractTest
{
public function testSending()
{
getConfig()->registration->needEmailForRegistering = true;
Core::getConfig()->registration->needEmailForRegistering = true;
Mailer::mockSending();
$user = $this->userMocker->mockSingle();
@ -35,7 +35,7 @@ class ActivateUserEmailJobTest extends AbstractTest
public function testConfirming()
{
getConfig()->registration->needEmailForRegistering = true;
Core::getConfig()->registration->needEmailForRegistering = true;
Mailer::mockSending();
$user = $this->userMocker->mockSingle();
@ -74,7 +74,7 @@ class ActivateUserEmailJobTest extends AbstractTest
public function testUsingTokenTwice()
{
getConfig()->registration->needEmailForRegistering = true;
Core::getConfig()->registration->needEmailForRegistering = true;
Mailer::mockSending();
$user = $this->userMocker->mockSingle();

View file

@ -31,7 +31,7 @@ class AddCommentJobTest extends AbstractTest
$this->prepare();
$this->assert->doesNotThrow(function()
{
$this->runApi(str_repeat('b', getConfig()->comments->minLength));
$this->runApi(str_repeat('b', Core::getConfig()->comments->minLength));
});
}
@ -40,7 +40,7 @@ class AddCommentJobTest extends AbstractTest
$this->prepare();
$this->assert->doesNotThrow(function()
{
$this->runApi(str_repeat('b', getConfig()->comments->maxLength));
$this->runApi(str_repeat('b', Core::getConfig()->comments->maxLength));
});
}
@ -49,7 +49,7 @@ class AddCommentJobTest extends AbstractTest
$this->prepare();
$this->assert->throws(function()
{
$this->runApi(str_repeat('b', getConfig()->comments->minLength - 1));
$this->runApi(str_repeat('b', Core::getConfig()->comments->minLength - 1));
}, 'Comment must have at least');
}
@ -58,7 +58,7 @@ class AddCommentJobTest extends AbstractTest
$this->prepare();
$this->assert->throws(function()
{
$this->runApi(str_repeat('b', getConfig()->comments->maxLength + 1));
$this->runApi(str_repeat('b', Core::getConfig()->comments->maxLength + 1));
}, 'Comment must have at most');
}
@ -109,7 +109,7 @@ class AddCommentJobTest extends AbstractTest
protected function prepare()
{
getConfig()->registration->needEmailForCommenting = false;
Core::getConfig()->registration->needEmailForCommenting = false;
$this->grantAccess('addComment');
$this->login($this->userMocker->mockSingle());
}

View file

@ -154,6 +154,6 @@ class AddPostJobTest extends AbstractTest
protected function prepare()
{
getConfig()->registration->needEmailForUploading = false;
Core::getConfig()->registration->needEmailForUploading = false;
}
}

View file

@ -45,14 +45,14 @@ class AddUserJobTest extends AbstractTest
new AddUserJob(),
[
JobArgs::ARG_NEW_USER_NAME => 'dummy',
JobArgs::ARG_NEW_PASSWORD => str_repeat('s', getConfig()->registration->passMinLength - 1),
JobArgs::ARG_NEW_PASSWORD => str_repeat('s', Core::getConfig()->registration->passMinLength - 1),
]);
}, 'Password must have at least');
}
public function testSkippingMailingUponFailing() //yo dog
{
getConfig()->registration->needEmailForRegistering = true;
Core::getConfig()->registration->needEmailForRegistering = true;
Mailer::mockSending();
$this->assert->areEqual(0, Mailer::getMailCounter());
@ -64,7 +64,7 @@ class AddUserJobTest extends AbstractTest
new AddUserJob(),
[
JobArgs::ARG_NEW_USER_NAME => 'dummy',
JobArgs::ARG_NEW_PASSWORD => str_repeat('s', getConfig()->registration->passMinLength - 1),
JobArgs::ARG_NEW_PASSWORD => str_repeat('s', Core::getConfig()->registration->passMinLength - 1),
JobArgs::ARG_NEW_EMAIL => 'godzilla@whitestar.gov',
]);
}, 'Password must have at least');
@ -89,7 +89,7 @@ class AddUserJobTest extends AbstractTest
$this->assert->isTrue(strlen($user->getPasswordHash()) < 100);
getConfig()->registration->needEmailForRegistering = false;
Core::getConfig()->registration->needEmailForRegistering = false;
$this->assert->doesNotThrow(function() use ($pass)
{
Auth::login('dummy', $pass, false);
@ -143,11 +143,11 @@ class AddUserJobTest extends AbstractTest
public function testEmailsMixedConfirmation()
{
getConfig()->registration->needEmailForRegistering = true;
Core::getConfig()->registration->needEmailForRegistering = true;
Mailer::mockSending();
$this->assert->areEqual(0, Mailer::getMailCounter());
getConfig()->privileges->changeUserEmailNoConfirm = 'admin';
Core::getConfig()->privileges->changeUserEmailNoConfirm = 'admin';
$this->grantAccess('registerAccount');
$user1 = $this->assert->doesNotThrow(function()
@ -185,11 +185,11 @@ class AddUserJobTest extends AbstractTest
public function testEmailsEveryoneMustConfirm()
{
getConfig()->registration->needEmailForRegistering = true;
Core::getConfig()->registration->needEmailForRegistering = true;
Mailer::mockSending();
$this->assert->areEqual(0, Mailer::getMailCounter());
getConfig()->privileges->changeUserEmailNoConfirm = 'nobody';
Core::getConfig()->privileges->changeUserEmailNoConfirm = 'nobody';
$this->grantAccess('registerAccount');
$user1 = $this->assert->doesNotThrow(function()
@ -225,11 +225,11 @@ class AddUserJobTest extends AbstractTest
public function testEmailsEveryoneSkipConfirm()
{
getConfig()->registration->needEmailForRegistering = true;
Core::getConfig()->registration->needEmailForRegistering = true;
Mailer::mockSending();
$this->assert->areEqual(0, Mailer::getMailCounter());
getConfig()->privileges->changeUserEmailNoConfirm = 'anonymous';
Core::getConfig()->privileges->changeUserEmailNoConfirm = 'anonymous';
$this->grantAccess('registerAccount');
$user1 = $this->assert->doesNotThrow(function()
@ -265,7 +265,7 @@ class AddUserJobTest extends AbstractTest
public function testEmailsTwoUsersSameMail()
{
getConfig()->registration->needEmailForRegistering = true;
Core::getConfig()->registration->needEmailForRegistering = true;
Mailer::mockSending();
$this->assert->areEqual(0, Mailer::getMailCounter());

View file

@ -28,7 +28,7 @@ class EditCommentJobTest extends AbstractTest
$this->grantAccess('editComment.own');
$this->assert->doesNotThrow(function()
{
$this->runApi(str_repeat('b', getConfig()->comments->minLength));
$this->runApi(str_repeat('b', Core::getConfig()->comments->minLength));
});
}
@ -38,7 +38,7 @@ class EditCommentJobTest extends AbstractTest
$this->grantAccess('editComment.own');
$this->assert->doesNotThrow(function()
{
$this->runApi(str_repeat('b', getConfig()->comments->maxLength));
$this->runApi(str_repeat('b', Core::getConfig()->comments->maxLength));
});
}
@ -48,7 +48,7 @@ class EditCommentJobTest extends AbstractTest
$this->grantAccess('editComment.own');
$this->assert->throws(function()
{
$this->runApi(str_repeat('b', getConfig()->comments->minLength - 1));
$this->runApi(str_repeat('b', Core::getConfig()->comments->minLength - 1));
}, 'Comment must have at least');
}
@ -58,7 +58,7 @@ class EditCommentJobTest extends AbstractTest
$this->grantAccess('editComment.own');
$this->assert->throws(function()
{
$this->runApi(str_repeat('b', getConfig()->comments->maxLength + 1));
$this->runApi(str_repeat('b', Core::getConfig()->comments->maxLength + 1));
}, 'Comment must have at most');
}

View file

@ -23,7 +23,7 @@ class EditPostSourceJobTest extends AbstractTest
$this->grantAccess('editPostSource.own');
$this->assert->doesNotThrow(function()
{
$this->runApi(str_repeat('a', getConfig()->posts->maxSourceLength));
$this->runApi(str_repeat('a', Core::getConfig()->posts->maxSourceLength));
});
}
@ -33,7 +33,7 @@ class EditPostSourceJobTest extends AbstractTest
$this->grantAccess('editPostSource.own');
$this->assert->throws(function()
{
$this->runApi(str_repeat('a', getConfig()->posts->maxSourceLength + 1));
$this->runApi(str_repeat('a', Core::getConfig()->posts->maxSourceLength + 1));
}, 'Source must have at most');
}

View file

@ -49,7 +49,7 @@ class EditPostTagsJobTest extends AbstractTest
$post = $this->postMocker->mockSingle();
$this->grantAccess('editPostTags');
$newTagNames = [str_repeat('u', getConfig()->tags->minLength - 1)];
$newTagNames = [str_repeat('u', Core::getConfig()->tags->minLength - 1)];
$this->assert->throws(function() use ($post, $newTagNames)
{
Api::run(
@ -66,7 +66,7 @@ class EditPostTagsJobTest extends AbstractTest
$post = $this->postMocker->mockSingle();
$this->grantAccess('editPostTags');
$newTagNames = [str_repeat('u', getConfig()->tags->maxLength + 1)];
$newTagNames = [str_repeat('u', Core::getConfig()->tags->maxLength + 1)];
$this->assert->throws(function() use ($post, $newTagNames)
{
Api::run(

View file

@ -41,7 +41,7 @@ class EditUserAccessRankJobTest extends AbstractTest
public function testHigherThanMyselfDenial()
{
getConfig()->privileges->changeUserAccessRank = 'power-user';
Core::getConfig()->privileges->changeUserAccessRank = 'power-user';
Access::init();
$user = $this->userMocker->mockSingle();

View file

@ -3,11 +3,11 @@ class EditUserEmailJobTest extends AbstractTest
{
public function testNoConfirmation()
{
getConfig()->registration->needEmailForRegistering = false;
Core::getConfig()->registration->needEmailForRegistering = false;
Mailer::mockSending();
$this->assert->areEqual(0, Mailer::getMailCounter());
getConfig()->privileges->changeUserEmailNoConfirm = 'anonymous';
Core::getConfig()->privileges->changeUserEmailNoConfirm = 'anonymous';
$this->grantAccess('changeUserEmail');
$user = $this->userMocker->mockSingle();
@ -30,11 +30,11 @@ class EditUserEmailJobTest extends AbstractTest
public function testConfirmation()
{
getConfig()->registration->needEmailForRegistering = false;
Core::getConfig()->registration->needEmailForRegistering = false;
Mailer::mockSending();
$this->assert->areEqual(0, Mailer::getMailCounter());
getConfig()->privileges->changeUserEmailNoConfirm = 'admin';
Core::getConfig()->privileges->changeUserEmailNoConfirm = 'admin';
$this->grantAccess('changeUserEmail');
$user = $this->userMocker->mockSingle();
@ -57,10 +57,10 @@ class EditUserEmailJobTest extends AbstractTest
public function testInvalidEmail()
{
getConfig()->registration->needEmailForRegistering = false;
Core::getConfig()->registration->needEmailForRegistering = false;
Mailer::mockSending();
getConfig()->privileges->changeUserEmailNoConfirm = 'nobody';
Core::getConfig()->privileges->changeUserEmailNoConfirm = 'nobody';
$this->grantAccess('changeUserEmail');
$user = $this->userMocker->mockSingle();
@ -78,11 +78,11 @@ class EditUserEmailJobTest extends AbstractTest
public function testChangingToExistingDenial()
{
getConfig()->registration->needEmailForRegistering = false;
Core::getConfig()->registration->needEmailForRegistering = false;
Mailer::mockSending();
$this->assert->areEqual(0, Mailer::getMailCounter());
getConfig()->privileges->changeUserEmailNoConfirm = 'anonymous';
Core::getConfig()->privileges->changeUserEmailNoConfirm = 'anonymous';
$this->grantAccess('changeUserEmail');
list ($user, $otherUser)

View file

@ -28,7 +28,7 @@ class EditUserNameJobTest extends AbstractTest
$this->grantAccess('changeUserName');
$user = $this->userMocker->mockSingle();
$newName = str_repeat('a', getConfig()->registration->userNameMinLength - 1);
$newName = str_repeat('a', Core::getConfig()->registration->userNameMinLength - 1);
$this->assert->throws(function() use ($user, $newName)
{
@ -46,7 +46,7 @@ class EditUserNameJobTest extends AbstractTest
$this->grantAccess('changeUserName');
$user = $this->userMocker->mockSingle();
$newName = str_repeat('a', getConfig()->registration->userNameMaxLength + 1);
$newName = str_repeat('a', Core::getConfig()->registration->userNameMaxLength + 1);
$this->assert->throws(function() use ($user, $newName)
{

View file

@ -16,7 +16,7 @@ class EditUserPasswordJobTest extends AbstractTest
$this->grantAccess('changeUserPassword');
$user = $this->userMocker->mockSingle();
$newPassword = str_repeat('a', getConfig()->registration->passMinLength - 1);
$newPassword = str_repeat('a', Core::getConfig()->registration->passMinLength - 1);
$oldPasswordHash = $user->getPasswordHash();
$this->assert->throws(function() use ($user, $newPassword)
@ -51,7 +51,7 @@ class EditUserPasswordJobTest extends AbstractTest
$this->assert->areEqual($newPasswordHash, $user->getPasswordHash());
getConfig()->registration->needEmailForRegistering = false;
Core::getConfig()->registration->needEmailForRegistering = false;
$this->assert->doesNotThrow(function() use ($user, $newPassword)
{
Auth::login($user->getName(), $newPassword, false);

View file

@ -37,7 +37,7 @@ class GetLogJobTest extends AbstractTest
private function run($args)
{
getConfig()->browsing->logsPerPage = 2;
Core::getConfig()->browsing->logsPerPage = 2;
$this->grantAccess('viewLog');
Logger::log('line1');
Logger::log('line2');

View file

@ -18,7 +18,7 @@ class GetPostThumbJobTest extends AbstractTest
$this->assert->isNotNull($post->tryGetWorkingFullPath());
$this->assert->areEqual('image/jpeg', $output->mimeType);
$this->assert->areNotEqual(
file_get_contents(getConfig()->main->mediaPath . DS . 'img' . DS . 'thumb.jpg'),
file_get_contents(Core::getConfig()->main->mediaPath . DS . 'img' . DS . 'thumb.jpg'),
$output->fileContent);
}

View file

@ -44,7 +44,7 @@ class ListCommentJobTest extends AbstractTest
$this->grantAccess('listComments');
$this->grantAccess('listPosts');
getConfig()->comments->commentsPerPage = 2;
Core::getConfig()->comments->commentsPerPage = 2;
$this->assert->areEqual(0, CommentModel::getCount());

View file

@ -5,12 +5,12 @@ class ListLogsJobTest extends AbstractTest
{
$this->grantAccess('listLogs');
getConfig()->main->logsPath = TextHelper::absolutePath(getConfig()->rootDir . '/tests/logs/test1.log');
Core::getConfig()->main->logsPath = TextHelper::absolutePath(Core::getConfig()->rootDir . '/tests/logs/test1.log');
Logger::init();
Logger::log('nonsense');
getConfig()->main->logsPath = TextHelper::absolutePath(getConfig()->rootDir . '/tests/logs/test2.log');
Core::getConfig()->main->logsPath = TextHelper::absolutePath(Core::getConfig()->rootDir . '/tests/logs/test2.log');
Logger::init();
Logger::log('nonsense');

View file

@ -5,7 +5,7 @@ class ListPostsJobTest extends AbstractTest
{
$this->grantAccess('listPosts');
$posts = $this->postMocker->mockMultiple(3);
getConfig()->browsing->postsPerPage = 2;
Core::getConfig()->browsing->postsPerPage = 2;
$ret = $this->assert->doesNotThrow(function()
{

View file

@ -7,7 +7,7 @@ class ListRelatedTagsJobTest extends AbstractTest
$this->grantAccess('listPosts');
$tags = $this->tagMocker->mockMultiple(3);
getConfig()->browsing->tagsRelated = 1;
Core::getConfig()->browsing->tagsRelated = 1;
$post = $this->postMocker->mockSingle();
$post->setTags($tags);

View file

@ -7,7 +7,7 @@ class ListTagsJobTest extends AbstractTest
$this->grantAccess('listPosts');
$tags = $this->tagMocker->mockMultiple(3);
getConfig()->browsing->tagsPerPage = 2;
Core::getConfig()->browsing->tagsPerPage = 2;
$post = $this->postMocker->mockSingle();
$post->setTags($tags);

View file

@ -6,7 +6,7 @@ class ListUsersJobTest extends AbstractTest
$this->grantAccess('listUsers');
$users = $this->userMocker->mockMultiple(3);
getConfig()->browsing->usersPerPage = 2;
Core::getConfig()->browsing->usersPerPage = 2;
$ret = $this->assert->doesNotThrow(function()
{

View file

@ -3,7 +3,7 @@ class PasswordResetJobTest extends AbstractTest
{
public function testDontSendIfUnconfirmedMail()
{
getConfig()->registration->needEmailForRegistering = true;
Core::getConfig()->registration->needEmailForRegistering = true;
Mailer::mockSending();
$user = $this->userMocker->mockSingle();
@ -22,7 +22,7 @@ class PasswordResetJobTest extends AbstractTest
public function testSending()
{
getConfig()->registration->needEmailForRegistering = true;
Core::getConfig()->registration->needEmailForRegistering = true;
Mailer::mockSending();
$user = $this->userMocker->mockSingle();
@ -54,7 +54,7 @@ class PasswordResetJobTest extends AbstractTest
public function testObtainingNewPassword()
{
getConfig()->registration->needEmailForRegistering = true;
Core::getConfig()->registration->needEmailForRegistering = true;
Mailer::mockSending();
$user = $this->userMocker->mockSingle();
@ -94,7 +94,7 @@ class PasswordResetJobTest extends AbstractTest
public function testUsingTokenTwice()
{
getConfig()->registration->needEmailForRegistering = true;
Core::getConfig()->registration->needEmailForRegistering = true;
Mailer::mockSending();
$user = $this->userMocker->mockSingle();

View file

@ -26,7 +26,7 @@ class PreviewCommentJobTest extends AbstractTest
$this->prepare();
$this->assert->doesNotThrow(function()
{
return $this->runApi(str_repeat('b', getConfig()->comments->minLength));
return $this->runApi(str_repeat('b', Core::getConfig()->comments->minLength));
});
}
@ -35,7 +35,7 @@ class PreviewCommentJobTest extends AbstractTest
$this->prepare();
$this->assert->doesNotThrow(function()
{
return $this->runApi(str_repeat('b', getConfig()->comments->maxLength));
return $this->runApi(str_repeat('b', Core::getConfig()->comments->maxLength));
});
}
@ -44,7 +44,7 @@ class PreviewCommentJobTest extends AbstractTest
$this->prepare();
$this->assert->throws(function()
{
return $this->runApi(str_repeat('b', getConfig()->comments->minLength - 1));
return $this->runApi(str_repeat('b', Core::getConfig()->comments->minLength - 1));
}, 'Comment must have at least');
}
@ -53,7 +53,7 @@ class PreviewCommentJobTest extends AbstractTest
$this->prepare();
$this->assert->throws(function()
{
return $this->runApi(str_repeat('b', getConfig()->comments->maxLength + 1));
return $this->runApi(str_repeat('b', Core::getConfig()->comments->maxLength + 1));
}, 'Comment must have at most');
}
@ -106,7 +106,7 @@ class PreviewCommentJobTest extends AbstractTest
protected function prepare()
{
getConfig()->registration->needEmailForCommenting = false;
Core::getConfig()->registration->needEmailForCommenting = false;
$this->grantAccess('addComment');
$this->login($this->userMocker->mockSingle());
}

View file

@ -28,7 +28,7 @@ class AccessTest extends AbstractTest
public function testAccessRanks2()
{
getConfig()->privileges->listPosts = 'power-user';
Core::getConfig()->privileges->listPosts = 'power-user';
Access::init();
$user = $this->userMocker->mockSingle();
@ -50,7 +50,7 @@ class AccessTest extends AbstractTest
public function testSubPrivilegesOnlySub()
{
getConfig()->privileges->{'listPosts.own'} = 'power-user';
Core::getConfig()->privileges->{'listPosts.own'} = 'power-user';
Access::init();
$user = $this->userMocker->mockSingle();
@ -62,16 +62,16 @@ class AccessTest extends AbstractTest
public function testSubPrivilegesSubAndGeneralNormalOrder()
{
getConfig()->privileges->{'listPosts.own'} = 'power-user';
getConfig()->privileges->{'listPosts'} = 'admin';
Core::getConfig()->privileges->{'listPosts.own'} = 'power-user';
Core::getConfig()->privileges->{'listPosts'} = 'admin';
Access::init();
$this->testSubPrivilegesSubAndGeneral();
}
public function testSubPrivilegesSubAndGeneralReverseOrder()
{
getConfig()->privileges->{'listPosts'} = 'admin';
getConfig()->privileges->{'listPosts.own'} = 'power-user';
Core::getConfig()->privileges->{'listPosts'} = 'admin';
Core::getConfig()->privileges->{'listPosts.own'} = 'power-user';
Access::init();
$this->testSubPrivilegesSubAndGeneral();
}
@ -92,18 +92,18 @@ class AccessTest extends AbstractTest
public function testSubPrivilegesMultipleSubAndGeneralNormalOrder()
{
getConfig()->privileges->{'listPosts.own'} = 'power-user';
getConfig()->privileges->{'listPosts.all'} = 'admin';
getConfig()->privileges->{'listPosts'} = 'nobody';
Core::getConfig()->privileges->{'listPosts.own'} = 'power-user';
Core::getConfig()->privileges->{'listPosts.all'} = 'admin';
Core::getConfig()->privileges->{'listPosts'} = 'nobody';
Access::init();
$this->testSubPrivilegesMultipleSubAndGeneral();
}
public function testSubPrivilegesMultipleSubAndGeneralReverseOrder()
{
getConfig()->privileges->{'listPosts'} = 'nobody';
getConfig()->privileges->{'listPosts.own'} = 'power-user';
getConfig()->privileges->{'listPosts.all'} = 'admin';
Core::getConfig()->privileges->{'listPosts'} = 'nobody';
Core::getConfig()->privileges->{'listPosts.own'} = 'power-user';
Core::getConfig()->privileges->{'listPosts.all'} = 'admin';
Access::init();
$this->testSubPrivilegesMultipleSubAndGeneral();
}

View file

@ -3,8 +3,8 @@ class AuthTest extends AbstractTest
{
public function testValidPassword()
{
getConfig()->registration->staffActivation = false;
getConfig()->registration->needEmailForRegistering = false;
Core::getConfig()->registration->staffActivation = false;
Core::getConfig()->registration->needEmailForRegistering = false;
$user = $this->prepareValidUser();
UserModel::save($user);
@ -19,8 +19,8 @@ class AuthTest extends AbstractTest
public function testLoginViaEmail()
{
getConfig()->registration->staffActivation = false;
getConfig()->registration->needEmailForRegistering = false;
Core::getConfig()->registration->staffActivation = false;
Core::getConfig()->registration->needEmailForRegistering = false;
$user = $this->prepareValidUser();
$user->setConfirmedEmail('godzilla@whitestar.gov');
@ -65,8 +65,8 @@ class AuthTest extends AbstractTest
public function testBanned()
{
getConfig()->registration->staffActivation = false;
getConfig()->registration->needEmailForRegistering = false;
Core::getConfig()->registration->staffActivation = false;
Core::getConfig()->registration->needEmailForRegistering = false;
$user = $this->prepareValidUser();
$user->ban();
@ -80,8 +80,8 @@ class AuthTest extends AbstractTest
public function testStaffConfirmationEnabledFail()
{
getConfig()->registration->staffActivation = true;
getConfig()->registration->needEmailForRegistering = false;
Core::getConfig()->registration->staffActivation = true;
Core::getConfig()->registration->needEmailForRegistering = false;
$user = $this->prepareValidUser();
$user->setStaffConfirmed(false);
@ -95,8 +95,8 @@ class AuthTest extends AbstractTest
public function testStaffConfirmationEnabledPass()
{
getConfig()->registration->staffActivation = true;
getConfig()->registration->needEmailForRegistering = false;
Core::getConfig()->registration->staffActivation = true;
Core::getConfig()->registration->needEmailForRegistering = false;
$user = $this->prepareValidUser();
$user->setStaffConfirmed(true);
@ -112,8 +112,8 @@ class AuthTest extends AbstractTest
public function testStaffConfirmationDisabledPass()
{
getConfig()->registration->staffActivation = false;
getConfig()->registration->needEmailForRegistering = false;
Core::getConfig()->registration->staffActivation = false;
Core::getConfig()->registration->needEmailForRegistering = false;
$user = $this->prepareValidUser();
$user->setStaffConfirmed(false);
@ -129,8 +129,8 @@ class AuthTest extends AbstractTest
public function testMailConfirmationEnabledFail1()
{
getConfig()->registration->staffActivation = false;
getConfig()->registration->needEmailForRegistering = true;
Core::getConfig()->registration->staffActivation = false;
Core::getConfig()->registration->needEmailForRegistering = true;
$user = $this->prepareValidUser();
$user->setStaffConfirmed(false);
@ -144,8 +144,8 @@ class AuthTest extends AbstractTest
public function testMailConfirmationEnabledFail2()
{
getConfig()->registration->staffActivation = false;
getConfig()->registration->needEmailForRegistering = true;
Core::getConfig()->registration->staffActivation = false;
Core::getConfig()->registration->needEmailForRegistering = true;
$user = $this->prepareValidUser();
$user->setStaffConfirmed(false);
@ -160,8 +160,8 @@ class AuthTest extends AbstractTest
public function testMailConfirmationEnabledPass()
{
getConfig()->registration->staffActivation = false;
getConfig()->registration->needEmailForRegistering = true;
Core::getConfig()->registration->staffActivation = false;
Core::getConfig()->registration->needEmailForRegistering = true;
$user = $this->prepareValidUser();
$user->setStaffConfirmed(false);

View file

@ -26,10 +26,10 @@ class LoggerTest extends AbstractTest
public function testPathChanging()
{
$logPath = TextHelper::absolutePath(getConfig()->rootDir . '/tests/logs/{yyyy}-{mm}-{dd}.log');
$realLogPath = TextHelper::absolutePath(getConfig()->rootDir . '/tests/logs/' . date('Y-m-d') . '.log');
$logPath = TextHelper::absolutePath(Core::getConfig()->rootDir . '/tests/logs/{yyyy}-{mm}-{dd}.log');
$realLogPath = TextHelper::absolutePath(Core::getConfig()->rootDir . '/tests/logs/' . date('Y-m-d') . '.log');
getConfig()->main->logsPath = $logPath;
Core::getConfig()->main->logsPath = $logPath;
$this->assert->doesNotThrow(function()
{
Logger::init();

View file

@ -74,7 +74,7 @@ class PostModelTest extends AbstractTest
public function testAutoFeaturingOutdated()
{
$post = $this->postMocker->mockSingle();
$minTimestamp = getConfig()->misc->featuredPostMaxDays * 24 * 3600;
$minTimestamp = Core::getConfig()->misc->featuredPostMaxDays * 24 * 3600;
$this->assert->isTrue(PostModel::featureRandomPostIfNecessary());
PropertyModel::set(PropertyModel::FeaturedPostUnixTime, time() - $minTimestamp - 1);

View file

@ -3,7 +3,7 @@ class UserModelTest extends AbstractTest
{
public function testSavingTwoUsersSameNameNoActivation()
{
getConfig()->registration->needEmailForRegistering = false;
Core::getConfig()->registration->needEmailForRegistering = false;
list ($user1, $user2) = $this->prepareTwoUsersWithSameName();
$this->assert->throws(function() use ($user2)
{
@ -13,7 +13,7 @@ class UserModelTest extends AbstractTest
public function testSavingTwoUsersSameNameEmailActivation()
{
getConfig()->registration->needEmailForRegistering = true;
Core::getConfig()->registration->needEmailForRegistering = true;
list ($user1, $user2) = $this->prepareTwoUsersWithSameName();
$this->assert->throws(function() use ($user2)
{
@ -23,7 +23,7 @@ class UserModelTest extends AbstractTest
public function testSavingTwoUsersSameNameStaffActivation()
{
getConfig()->registration->staffActivation = true;
Core::getConfig()->registration->staffActivation = true;
list ($user1, $user2) = $this->prepareTwoUsersWithSameName();
$this->assert->throws(function() use ($user2)
{
@ -33,7 +33,7 @@ class UserModelTest extends AbstractTest
public function testSavingTwoUsersSameEmailNoActivation()
{
getConfig()->registration->needEmailForRegistering = false;
Core::getConfig()->registration->needEmailForRegistering = false;
list ($user1, $user2) = $this->prepareTwoUsersWithSameEmail(false, false);
$this->assert->throws(function() use ($user2)
{
@ -43,7 +43,7 @@ class UserModelTest extends AbstractTest
public function testSavingTwoUsersSameEmailEmailActivation()
{
getConfig()->registration->needEmailForRegistering = true;
Core::getConfig()->registration->needEmailForRegistering = true;
list ($user1, $user2) = $this->prepareTwoUsersWithSameEmail(false, false);
$this->assert->throws(function() use ($user2)
{
@ -53,7 +53,7 @@ class UserModelTest extends AbstractTest
public function testSavingTwoUsersSameEmailStaffActivation()
{
getConfig()->registration->staffActivation = true;
Core::getConfig()->registration->staffActivation = true;
list ($user1, $user2) = $this->prepareTwoUsersWithSameEmail(false, false);
$this->assert->throws(function() use ($user2)
{