Encapsulated a few entity getters and setters

This commit is contained in:
Marcin Kurczewski 2014-05-04 20:09:03 +02:00
parent ee757f1149
commit b885411b2e
34 changed files with 151 additions and 103 deletions

View file

@ -8,7 +8,7 @@ class AddUserJob extends AbstractJob
$user = UserModel::spawn(); $user = UserModel::spawn();
$user->joinDate = time(); $user->joinDate = time();
$user->staffConfirmed = $firstUser; $user->staffConfirmed = $firstUser;
$user->name = $this->getArgument(EditUserNameJob::NEW_USER_NAME); $user->setName($this->getArgument(EditUserNameJob::NEW_USER_NAME));
UserModel::forgeId($user); UserModel::forgeId($user);
$arguments = $this->getArguments(); $arguments = $this->getArguments();

View file

@ -5,7 +5,7 @@ class DeleteUserJob extends AbstractUserJob
{ {
$user = $this->user; $user = $this->user;
$name = $user->name; $name = $user->getName();
UserModel::remove($user); UserModel::remove($user);
Logger::log('{user} removed {subject}\'s account', [ Logger::log('{user} removed {subject}\'s account', [

View file

@ -6,9 +6,9 @@ class EditPostTagsJob extends AbstractPostEditJob
$post = $this->post; $post = $this->post;
$tags = $this->getArgument(self::TAG_NAMES); $tags = $this->getArgument(self::TAG_NAMES);
$oldTags = array_map(function($tag) { return $tag->name; }, $post->getTags()); $oldTags = array_map(function($tag) { return $tag->getName(); }, $post->getTags());
$post->setTagsFromText($tags); $post->setTagsFromText($tags);
$newTags = array_map(function($tag) { return $tag->name; }, $post->getTags()); $newTags = array_map(function($tag) { return $tag->getName(); }, $post->getTags());
if (!$this->skipSaving) if (!$this->skipSaving)
{ {

View file

@ -8,11 +8,11 @@ class EditUserNameJob extends AbstractUserEditJob
$user = $this->user; $user = $this->user;
$newName = $this->getArgument(self::NEW_USER_NAME); $newName = $this->getArgument(self::NEW_USER_NAME);
$oldName = $user->name; $oldName = $user->getName();
if ($oldName == $newName) if ($oldName == $newName)
return $user; return $user;
$user->name = $newName; $user->setName($newName);
UserModel::validateUserName($user); UserModel::validateUserName($user);
if (!$this->skipSaving) if (!$this->skipSaving)

View file

@ -7,7 +7,7 @@ class FeaturePostJob extends AbstractPostJob
PropertyModel::set(PropertyModel::FeaturedPostId, $post->id); PropertyModel::set(PropertyModel::FeaturedPostId, $post->id);
PropertyModel::set(PropertyModel::FeaturedPostDate, time()); PropertyModel::set(PropertyModel::FeaturedPostDate, time());
PropertyModel::set(PropertyModel::FeaturedPostUserName, Auth::getCurrentUser()->name); PropertyModel::set(PropertyModel::FeaturedPostUserName, Auth::getCurrentUser()->getName());
Logger::log('{user} featured {post} on main page', [ Logger::log('{user} featured {post} on main page', [
'user' => TextHelper::reprPost(Auth::getCurrentUser()), 'user' => TextHelper::reprPost(Auth::getCurrentUser()),

View file

@ -13,7 +13,7 @@ class GetPostContentJob extends AbstractJob
$post = $this->post; $post = $this->post;
$config = getConfig(); $config = getConfig();
$path = $config->main->filesPath . DS . $post->name; $path = $config->main->filesPath . DS . $post->getName();
$path = TextHelper::absolutePath($path); $path = TextHelper::absolutePath($path);
if (!file_exists($path)) if (!file_exists($path))
throw new SimpleNotFoundException('Post file does not exist'); throw new SimpleNotFoundException('Post file does not exist');
@ -23,7 +23,7 @@ class GetPostContentJob extends AbstractJob
$fileName = sprintf('%s_%s_%s.%s', $fileName = sprintf('%s_%s_%s.%s',
$config->main->title, $config->main->title,
$post->id, $post->id,
join(',', array_map(function($tag) { return $tag->name; }, $post->getTags())), join(',', array_map(function($tag) { return $tag->getName(); }, $post->getTags())),
TextHelper::resolveMimeType($post->mimeType) ?: 'dat'); TextHelper::resolveMimeType($post->mimeType) ?: 'dat');
$fileName = preg_replace('/[[:^print:]]/', '', $fileName); $fileName = preg_replace('/[[:^print:]]/', '', $fileName);

View file

@ -10,7 +10,7 @@ class ListRelatedTagsJob extends ListTagsJob
$tags = TagSearchService::getRelatedTags($tag); $tags = TagSearchService::getRelatedTags($tag);
$tagCount = count($tags); $tagCount = count($tags);
$tags = array_filter($tags, function($tag) use ($otherTags) { return !in_array($tag->name, $otherTags); }); $tags = array_filter($tags, function($tag) use ($otherTags) { return !in_array($tag->getName(), $otherTags); });
$tags = array_slice($tags, 0, $pageSize); $tags = array_slice($tags, 0, $pageSize);
return $this->getPager($tags, $tagCount, $page, $pageSize); return $this->getPager($tags, $tagCount, $page, $pageSize);

View file

@ -15,7 +15,7 @@ class TogglePostTagJob extends AbstractPostJob
if ($tag === null) if ($tag === null)
{ {
$tag = TagModel::spawn(); $tag = TagModel::spawn();
$tag->name = $tagName; $tag->setName($tagName);
TagModel::save($tag); TagModel::save($tag);
} }
@ -24,7 +24,7 @@ class TogglePostTagJob extends AbstractPostJob
else else
{ {
foreach ($tags as $i => $tag) foreach ($tags as $i => $tag)
if ($tag->name == $tagName) if ($tag->getName() == $tagName)
unset($tags[$i]); unset($tags[$i]);
} }

View file

@ -6,7 +6,10 @@ class ToggleUserBanJob extends AbstractUserJob
$user = $this->user; $user = $this->user;
$banned = boolval($this->getArgument(self::STATE)); $banned = boolval($this->getArgument(self::STATE));
$user->banned = $banned; if ($banned)
$user->ban();
else
$user->unban();
UserModel::save($user); UserModel::save($user);
Logger::log( Logger::log(

View file

@ -13,22 +13,22 @@ class Auth
$config = getConfig(); $config = getConfig();
$context = getContext(); $context = getContext();
$dbUser = UserModel::findByNameOrEmail($name, false); $user = UserModel::findByNameOrEmail($name, false);
if ($dbUser === null) if ($user === null)
throw new SimpleException('Invalid username'); throw new SimpleException('Invalid username');
$passwordHash = UserModel::hashPassword($password, $dbUser->passSalt); $passwordHash = UserModel::hashPassword($password, $user->passSalt);
if ($passwordHash != $dbUser->passHash) if ($passwordHash != $user->passHash)
throw new SimpleException('Invalid password'); throw new SimpleException('Invalid password');
if (!$dbUser->staffConfirmed and $config->registration->staffActivation) if (!$user->staffConfirmed and $config->registration->staffActivation)
throw new SimpleException('Staff hasn\'t confirmed your registration yet'); throw new SimpleException('Staff hasn\'t confirmed your registration yet');
if ($dbUser->banned) if ($user->isBanned())
throw new SimpleException('You are banned'); throw new SimpleException('You are banned');
if ($config->registration->needEmailForRegistering) if ($config->registration->needEmailForRegistering)
Access::requireEmail($dbUser); Access::requireEmail($user);
if ($remember) if ($remember)
{ {
@ -36,7 +36,7 @@ class Auth
setcookie('auth', TextHelper::encrypt($token), time() + 365 * 24 * 3600, '/'); setcookie('auth', TextHelper::encrypt($token), time() + 365 * 24 * 3600, '/');
} }
self::setCurrentUser($dbUser); self::setCurrentUser($user);
} }
public static function tryAutoLogin() public static function tryAutoLogin()
@ -86,7 +86,7 @@ class Auth
{ {
$dummy = UserModel::spawn(); $dummy = UserModel::spawn();
$dummy->id = null; $dummy->id = null;
$dummy->name = UserModel::getAnonymousName(); $dummy->setName(UserModel::getAnonymousName());
$dummy->setAccessRank(new AccessRank(AccessRank::Anonymous)); $dummy->setAccessRank(new AccessRank(AccessRank::Anonymous));
return $dummy; return $dummy;
} }

View file

@ -36,7 +36,7 @@ class PostController
$context->massTagQuery = $query; $context->massTagQuery = $query;
if (!Access::check(new Privilege(Privilege::MassTag, 'all'))) if (!Access::check(new Privilege(Privilege::MassTag, 'all')))
$query = trim($query . ' submit:' . Auth::getCurrentUser()->name); $query = trim($query . ' submit:' . Auth::getCurrentUser()->getName());
} }
$ret = Api::run( $ret = Api::run(

View file

@ -36,7 +36,7 @@ class TagController
function($tag) function($tag)
{ {
return [ return [
'name' => $tag->name, 'name' => $tag->getName(),
'count' => $tag->getPostCount(), 'count' => $tag->getPostCount(),
]; ];
}, $ret->entities)); }, $ret->entities));
@ -61,7 +61,7 @@ class TagController
function($tag) function($tag)
{ {
return [ return [
'name' => $tag->name, 'name' => $tag->getName(),
'count' => $tag->getPostCount(), 'count' => $tag->getPostCount(),
]; ];
}, $ret->entities)); }, $ret->entities));

View file

@ -28,9 +28,9 @@ class UserController
$flagged = in_array(TextHelper::reprUser($user), SessionHelper::get('flagged', [])); $flagged = in_array(TextHelper::reprUser($user), SessionHelper::get('flagged', []));
if ($tab == 'uploads') if ($tab == 'uploads')
$query = 'submit:' . $user->name; $query = 'submit:' . $user->getName();
elseif ($tab == 'favs') elseif ($tab == 'favs')
$query = 'fav:' . $user->name; $query = 'fav:' . $user->getName();
elseif ($tab == 'delete') elseif ($tab == 'delete')
Access::assert(new Privilege(Privilege::DeleteUser)); Access::assert(new Privilege(Privilege::DeleteUser));

View file

@ -157,14 +157,14 @@ class TextHelper
{ {
if (!is_object($user)) if (!is_object($user))
return '+' . $user; return '+' . $user;
return '+' . $user->name; return '+' . $user->getName();
} }
public static function reprTag($tag) public static function reprTag($tag)
{ {
if (!is_object($tag)) if (!is_object($tag))
return '#' . $tag; return '#' . $tag;
return '#' . $tag->name; return '#' . $tag->getName();
} }
public static function reprTags($tags) public static function reprTags($tags)

View file

@ -5,7 +5,7 @@ use \Chibi\Database as Database;
class PostEntity extends AbstractEntity class PostEntity extends AbstractEntity
{ {
protected $type; protected $type;
public $name; protected $name;
public $origName; public $origName;
public $fileHash; public $fileHash;
public $fileSize; public $fileSize;
@ -151,7 +151,7 @@ class PostEntity extends AbstractEntity
if (!$tag) if (!$tag)
{ {
$tag = TagModel::spawn(); $tag = TagModel::spawn();
$tag->name = $tagName; $tag->setName($tagName);
TagModel::save($tag); TagModel::save($tag);
} }
$tags []= $tag; $tags []= $tag;
@ -163,7 +163,7 @@ class PostEntity extends AbstractEntity
{ {
$tagName = trim(strtolower($tagName)); $tagName = trim(strtolower($tagName));
foreach ($this->getTags() as $tag) foreach ($this->getTags() as $tag)
if (trim(strtolower($tag->name)) == $tagName) if (trim(strtolower($tag->getName())) == $tagName)
return true; return true;
return false; return false;
} }
@ -173,6 +173,16 @@ class PostEntity extends AbstractEntity
$this->hidden = boolval($hidden); $this->hidden = boolval($hidden);
} }
public function getName()
{
return $this->name;
}
public function setName($name)
{
$this->name = $name;
}
public function getType() public function getType()
{ {
return $this->type; return $this->type;
@ -202,17 +212,17 @@ class PostEntity extends AbstractEntity
public function getThumbCustomPath($width = null, $height = null) public function getThumbCustomPath($width = null, $height = null)
{ {
return PostModel::getThumbCustomPath($this->name, $width, $height); return PostModel::getThumbCustomPath($this->getName(), $width, $height);
} }
public function getThumbDefaultPath($width = null, $height = null) public function getThumbDefaultPath($width = null, $height = null)
{ {
return PostModel::getThumbDefaultPath($this->name, $width, $height); return PostModel::getThumbDefaultPath($this->getName(), $width, $height);
} }
public function getFullPath() public function getFullPath()
{ {
return PostModel::getFullPath($this->name); return PostModel::getFullPath($this->getName());
} }
public function hasCustomThumb($width = null, $height = null) public function hasCustomThumb($width = null, $height = null)
@ -374,7 +384,7 @@ class PostEntity extends AbstractEntity
{ {
$x = []; $x = [];
foreach ($this->getTags() as $tag) foreach ($this->getTags() as $tag)
$x []= TextHelper::reprTag($tag->name); $x []= TextHelper::reprTag($tag->getName());
foreach ($this->getRelations() as $relatedPost) foreach ($this->getRelations() as $relatedPost)
$x []= TextHelper::reprPost($relatedPost); $x []= TextHelper::reprPost($relatedPost);
$x []= $this->getSafety()->toInteger(); $x []= $this->getSafety()->toInteger();

View file

@ -4,7 +4,17 @@ use \Chibi\Database as Database;
class TagEntity extends AbstractEntity class TagEntity extends AbstractEntity
{ {
public $name; protected $name;
public function setName($name)
{
$this->name = $name;
}
public function getName()
{
return $this->name;
}
public function getPostCount() public function getPostCount()
{ {

View file

@ -4,7 +4,7 @@ use \Chibi\Database as Database;
class UserEntity extends AbstractEntity class UserEntity extends AbstractEntity
{ {
public $name; protected $name;
public $passSalt; public $passSalt;
public $passHash; public $passHash;
public $staffConfirmed; public $staffConfirmed;
@ -14,7 +14,32 @@ class UserEntity extends AbstractEntity
public $lastLoginDate; public $lastLoginDate;
protected $accessRank; protected $accessRank;
public $settings; public $settings;
public $banned; protected $banned = false;
public function isBanned()
{
return $this->banned;
}
public function ban()
{
$this->banned = true;
}
public function unban()
{
$this->banned = false;
}
public function getName()
{
return $this->name;
}
public function setName($name)
{
$this->name = $name;
}
public function getAccessRank() public function getAccessRank()
{ {
@ -31,7 +56,7 @@ class UserEntity extends AbstractEntity
{ {
$subject = !empty($this->emailConfirmed) $subject = !empty($this->emailConfirmed)
? $this->emailConfirmed ? $this->emailConfirmed
: $this->passSalt . $this->name; : $this->passSalt . $this->getName();
$hash = md5(strtolower(trim($subject))); $hash = md5(strtolower(trim($subject)));
$url = 'http://www.gravatar.com/avatar/' . $hash . '?s=' . $size . '&d=retro'; $url = 'http://www.gravatar.com/avatar/' . $hash . '?s=' . $size . '&d=retro';
return $url; return $url;

View file

@ -37,7 +37,7 @@ class PostModel extends AbstractCrudModel
$post->uploadDate = time(); $post->uploadDate = time();
do do
{ {
$post->name = md5(mt_rand() . uniqid()); $post->setName(md5(mt_rand() . uniqid()));
} }
while (file_exists($post->getFullPath())); while (file_exists($post->getFullPath()));
return $post; return $post;
@ -51,7 +51,7 @@ class PostModel extends AbstractCrudModel
$bindings = [ $bindings = [
'type' => $post->getType()->toInteger(), 'type' => $post->getType()->toInteger(),
'name' => $post->name, 'name' => $post->getName(),
'orig_name' => $post->origName, 'orig_name' => $post->origName,
'file_hash' => $post->fileHash, 'file_hash' => $post->fileHash,
'file_size' => $post->fileSize, 'file_size' => $post->fileSize,

View file

@ -156,7 +156,7 @@ class PostSearchParser extends AbstractSearchParser
$value = strtolower($value); $value = strtolower($value);
if (in_array($value, ['fav', 'favs', 'favd'])) if (in_array($value, ['fav', 'favs', 'favd']))
{ {
return $this->prepareCriterionForComplexToken('fav', $activeUser->name); return $this->prepareCriterionForComplexToken('fav', $activeUser->getName());
} }
elseif (in_array($value, ['like', 'liked', 'likes'])) elseif (in_array($value, ['like', 'liked', 'likes']))

View file

@ -25,7 +25,7 @@ class TagModel extends AbstractCrudModel
$stmt = new Sql\UpdateStatement(); $stmt = new Sql\UpdateStatement();
$stmt->setTable('tag'); $stmt->setTable('tag');
$stmt->setColumn('name', new Sql\Binding($tag->name)); $stmt->setColumn('name', new Sql\Binding($tag->getName()));
$stmt->setCriterion(new Sql\EqualsFunctor('id', new Sql\Binding($tag->id))); $stmt->setCriterion(new Sql\EqualsFunctor('id', new Sql\Binding($tag->id)));
Database::exec($stmt); Database::exec($stmt);
@ -58,8 +58,8 @@ class TagModel extends AbstractCrudModel
if ($targetTag and $targetTag->id != $sourceTag->id) if ($targetTag and $targetTag->id != $sourceTag->id)
throw new SimpleException('Target tag already exists'); throw new SimpleException('Target tag already exists');
$sourceTag->name = $targetName; $sourceTag->setName($targetName);
TagModel::validateTag($sourceTag->name); TagModel::validateTag($sourceTag->getName());
self::save($sourceTag); self::save($sourceTag);
}); });
} }

View file

@ -42,7 +42,7 @@ class UserModel extends AbstractCrudModel
self::forgeId($user); self::forgeId($user);
$bindings = [ $bindings = [
'name' => $user->name, 'name' => $user->getName(),
'pass_salt' => $user->passSalt, 'pass_salt' => $user->passSalt,
'pass_hash' => $user->passHash, 'pass_hash' => $user->passHash,
'staff_confirmed' => $user->staffConfirmed, 'staff_confirmed' => $user->staffConfirmed,
@ -52,7 +52,7 @@ class UserModel extends AbstractCrudModel
'last_login_date' => $user->lastLoginDate, 'last_login_date' => $user->lastLoginDate,
'access_rank' => $user->getAccessRank()->toInteger(), 'access_rank' => $user->getAccessRank()->toInteger(),
'settings' => $user->settings, 'settings' => $user->settings,
'banned' => $user->banned 'banned' => $user->isBanned(),
]; ];
$stmt = (new Sql\UpdateStatement) $stmt = (new Sql\UpdateStatement)
@ -190,7 +190,7 @@ class UserModel extends AbstractCrudModel
public static function validateUserName(UserEntity $user) public static function validateUserName(UserEntity $user)
{ {
$userName = trim($user->name); $userName = trim($user->getName());
$config = getConfig(); $config = getConfig();
$otherUser = self::findByName($userName, false); $otherUser = self::findByName($userName, false);

View file

@ -8,8 +8,8 @@ Assets::addScript('comment-edit.js');
<div class="avatar"> <div class="avatar">
<?php $commenter = $this->context->comment->getCommenter() ?> <?php $commenter = $this->context->comment->getCommenter() ?>
<?php if ($commenter): ?> <?php if ($commenter): ?>
<a href="<?= \Chibi\Router::linkTo(['UserController', 'genericView'], ['name' => $commenter->name]) ?>"> <a href="<?= \Chibi\Router::linkTo(['UserController', 'genericView'], ['name' => $commenter->getName()]) ?>">
<img src="<?= htmlspecialchars($commenter->getAvatarUrl(40)) ?>" alt="<?= $commenter->name ?>"/> <img src="<?= htmlspecialchars($commenter->getAvatarUrl(40)) ?>" alt="<?= $commenter->getName() ?>"/>
</a> </a>
<?php else: ?> <?php else: ?>
<img <img
@ -24,8 +24,8 @@ Assets::addScript('comment-edit.js');
<?php if ($commenter): ?> <?php if ($commenter): ?>
<a href="<?= \Chibi\Router::linkTo( <a href="<?= \Chibi\Router::linkTo(
['UserController', 'genericView'], ['UserController', 'genericView'],
['name' => $commenter->name]) ?>"> ['name' => $commenter->getName()]) ?>">
<?= $commenter->name ?> <?= $commenter->getName() ?>
</a> </a>
<?php else: ?> <?php else: ?>
<?= UserModel::getAnonymousName() ?> <?= UserModel::getAnonymousName() ?>

View file

@ -46,7 +46,7 @@
id="tags" id="tags"
placeholder="enter some tags&hellip;" placeholder="enter some tags&hellip;"
value="<?= join(',', array_map(function($tag) { value="<?= join(',', array_map(function($tag) {
return htmlspecialchars($tag->name); return htmlspecialchars($tag->getName());
}, $this->context->transport->post->getTags())) ?>"/> }, $this->context->transport->post->getTags())) ?>"/>
</div> </div>
</div> </div>

View file

@ -1,7 +1,7 @@
<?php <?php
Assets::setPageThumb(\Chibi\Router::linkTo( Assets::setPageThumb(\Chibi\Router::linkTo(
['PostController', 'thumbView'], ['PostController', 'thumbView'],
['name' => $this->context->transport->post->name])); ['name' => $this->context->transport->post->getName()]));
$post = $this->context->transport->post; $post = $this->context->transport->post;
?> ?>
@ -11,10 +11,10 @@ $post = $this->context->transport->post;
<a href="<?= $this->context->imageLink ?>"> <a href="<?= $this->context->imageLink ?>">
<?php endif ?> <?php endif ?>
<img alt="<?= $post->name ?>" <img alt="<?= $post->getName() ?>"
src="<?= \Chibi\Router::linkTo( src="<?= \Chibi\Router::linkTo(
['PostController', 'fileView'], ['PostController', 'fileView'],
['name' => $post->name]) ?>"/> ['name' => $post->getName()]) ?>"/>
<?php if (!empty($this->context->imageLink)): ?> <?php if (!empty($this->context->imageLink)): ?>
</a> </a>
@ -28,12 +28,12 @@ $post = $this->context->transport->post;
height="<?= $post->imageHeight ?>" height="<?= $post->imageHeight ?>"
data="<?= \Chibi\Router::linkTo( data="<?= \Chibi\Router::linkTo(
['PostController', 'fileView'], ['PostController', 'fileView'],
['name' => $post->name]) ?>"> ['name' => $post->getName()]) ?>">
<param name="wmode" value="opaque"/> <param name="wmode" value="opaque"/>
<param name="movie" value="<?= \Chibi\Router::linkTo( <param name="movie" value="<?= \Chibi\Router::linkTo(
['PostController', 'fileView'], ['PostController', 'fileView'],
['name' => $post->name]) ?>"/> ['name' => $post->getName()]) ?>"/>
</object> </object>
@ -53,7 +53,7 @@ $post = $this->context->transport->post;
type="<?= $post->mimeType ?>" type="<?= $post->mimeType ?>"
src="<?= \Chibi\Router::linkTo( src="<?= \Chibi\Router::linkTo(
['PostController', 'fileView'], ['PostController', 'fileView'],
['name' => $post->name]) ?>"> ['name' => $post->getName()]) ?>">
Your browser doesn't support HTML5 &lt;video&gt; tag. Your browser doesn't support HTML5 &lt;video&gt; tag.
</video> </video>

View file

@ -48,7 +48,7 @@ if ($masstag)
<img <img
class="thumb" class="thumb"
src="<?= \Chibi\Router::linkTo(['PostController', 'thumbView'], ['name' => $this->context->post->name]) ?>" src="<?= \Chibi\Router::linkTo(['PostController', 'thumbView'], ['name' => $this->context->post->getName()]) ?>"
alt="@<?= $this->context->post->id ?>"/> alt="@<?= $this->context->post->id ?>"/>
<?php <?php

View file

@ -72,13 +72,13 @@ $canEditAnything = count(array_filter($editPostPrivileges)) > 0;
<?php $tags = $this->context->transport->post->getTags() ?> <?php $tags = $this->context->transport->post->getTags() ?>
<h1>tags (<?= count($tags) ?>)</h1> <h1>tags (<?= count($tags) ?>)</h1>
<ul> <ul>
<?php uasort($tags, function($a, $b) { return strnatcasecmp($a->name, $b->name); }) ?> <?php uasort($tags, function($a, $b) { return strnatcasecmp($a->getName(), $b->getName()); }) ?>
<?php foreach ($tags as $tag): ?> <?php foreach ($tags as $tag): ?>
<li title="<?= $tag->name ?>"> <li title="<?= $tag->getName() ?>">
<a href="<?= \Chibi\Router::linkTo( <a href="<?= \Chibi\Router::linkTo(
['PostController', 'listView'], ['PostController', 'listView'],
['query' => $tag->name]) ?>" ['query' => $tag->getName()]) ?>"
><?= $tag->name ?> ><?= $tag->getName() ?>
</a> </a>
<span class="count"><?= TextHelper::useDecimalUnits($tag->getPostCount()) ?></span> <span class="count"><?= TextHelper::useDecimalUnits($tag->getPostCount()) ?></span>
</li> </li>
@ -92,11 +92,11 @@ $canEditAnything = count(array_filter($editPostPrivileges)) > 0;
<div class="uploader"> <div class="uploader">
<?php $uploader = $this->context->transport->post->getUploader() ?> <?php $uploader = $this->context->transport->post->getUploader() ?>
<?php if ($uploader): ?> <?php if ($uploader): ?>
<span class="value" title="<?= $val = $uploader->name ?>"> <span class="value" title="<?= $val = $uploader->getName() ?>">
<a href="<?= \Chibi\Router::linkTo( <a href="<?= \Chibi\Router::linkTo(
['UserController', 'genericView'], ['UserController', 'genericView'],
['name' => $uploader->name]) ?>"> ['name' => $uploader->getName()]) ?>">
<img src="<?= htmlentities($uploader->getAvatarUrl(24)) ?>" alt="<?= $uploader->name ?>"/> <img src="<?= htmlentities($uploader->getAvatarUrl(24)) ?>" alt="<?= $uploader->getName() ?>"/>
<?= $val ?> <?= $val ?>
</a> </a>
</span> </span>
@ -188,7 +188,7 @@ $canEditAnything = count(array_filter($editPostPrivileges)) > 0;
<div class="hl-option"> <div class="hl-option">
<a title="Download" href="<?= \Chibi\Router::linkTo( <a title="Download" href="<?= \Chibi\Router::linkTo(
['PostController', 'fileView'], ['PostController', 'fileView'],
['name' => $this->context->transport->post->name]) ?>"> ['name' => $this->context->transport->post->getName()]) ?>">
<i class="icon-dl"></i> <i class="icon-dl"></i>
<span> <span>
<?php <?php
@ -242,10 +242,10 @@ $canEditAnything = count(array_filter($editPostPrivileges)) > 0;
<ul> <ul>
<?php foreach ($this->context->transport->post->getFavorites() as $user): ?> <?php foreach ($this->context->transport->post->getFavorites() as $user): ?>
<li> <li>
<a title="<?= $user->name ?>" href="<?= \Chibi\Router::linkTo( <a title="<?= $user->getName() ?>" href="<?= \Chibi\Router::linkTo(
['UserController', 'genericView'], ['UserController', 'genericView'],
['name' => $user->name]) ?>"> ['name' => $user->getName()]) ?>">
<img src="<?= htmlspecialchars($user->getAvatarUrl()) ?>" alt="<?= $user->name ?>"> <img src="<?= htmlspecialchars($user->getAvatarUrl()) ?>" alt="<?= $user->getName() ?>">
</a> </a>
</li> </li>
<?php endforeach ?> <?php endforeach ?>

View file

@ -26,11 +26,11 @@ Assets::addStylesheet('static-main.css');
Tags:&nbsp; Tags:&nbsp;
<ul class="tags"> <ul class="tags">
<?php $tags = $this->context->featuredPost->getTags() ?> <?php $tags = $this->context->featuredPost->getTags() ?>
<?php uasort($tags, function($a, $b) { return strnatcasecmp($a->name, $b->name); }) ?> <?php uasort($tags, function($a, $b) { return strnatcasecmp($a->getName(), $b->getName()); }) ?>
<?php foreach ($tags as $tag): ?> <?php foreach ($tags as $tag): ?>
<li> <li>
<a href="<?= \Chibi\Router::linkTo(['PostController', 'listView'], ['query' => $tag->name]) ?>"> <a href="<?= \Chibi\Router::linkTo(['PostController', 'listView'], ['query' => $tag->getName()]) ?>">
<?= $tag->name ?> <?= $tag->getName() ?>
</a> </a>
</li> </li>
<?php endforeach ?> <?php endforeach ?>
@ -43,8 +43,8 @@ Assets::addStylesheet('static-main.css');
by by
<a href="<?= \Chibi\Router::linkTo( <a href="<?= \Chibi\Router::linkTo(
['UserController', 'genericView'], ['UserController', 'genericView'],
['name' => $this->context->featuredPostUser->name]) ?>"> ['name' => $this->context->featuredPostUser->getName()]) ?>">
<?= $this->context->featuredPostUser->name ?> <?= $this->context->featuredPostUser->getName() ?>
</a>, </a>,
<?php endif ?> <?php endif ?>

View file

@ -32,7 +32,7 @@
<div class="tags paginator-content"> <div class="tags paginator-content">
<ul> <ul>
<?php foreach ($this->context->transport->tags as $tag): ?> <?php foreach ($this->context->transport->tags as $tag): ?>
<?php $name = $tag->name ?> <?php $name = $tag->getName() ?>
<?php $count = $tag->getPostCount() ?> <?php $count = $tag->getPostCount() ?>
<li class="tag" title="<?= $name ?> (<?= $count ?>)"> <li class="tag" title="<?= $name ?> (<?= $count ?>)">
<a href="<?= str_replace('_query_', $name, $url) ?>" <a href="<?= str_replace('_query_', $name, $url) ?>"

View file

@ -57,7 +57,7 @@
\Chibi\Router::linkTo(['UserController', 'listView']), \Chibi\Router::linkTo(['UserController', 'listView']),
$activeController == 'user' and $activeAction != 'registration' and $activeController == 'user' and $activeAction != 'registration' and
(!isset($this->context->route->arguments['name']) or (!isset($this->context->route->arguments['name']) or
$this->context->route->arguments['name'] != Auth::getCurrentUser()->name)); $this->context->route->arguments['name'] != Auth::getCurrentUser()->getName()));
} }
if (!Auth::isLoggedIn()) if (!Auth::isLoggedIn())
@ -76,9 +76,9 @@
{ {
$registerNavItem( $registerNavItem(
'My account', 'My account',
\Chibi\Router::linkTo(['UserController', 'genericView'], ['name' => Auth::getCurrentUser()->name]), \Chibi\Router::linkTo(['UserController', 'genericView'], ['name' => Auth::getCurrentUser()->getName()]),
$activeController == 'user' and isset($this->context->route->arguments['name']) and $activeController == 'user' and isset($this->context->route->arguments['name']) and
$this->context->route->arguments['name'] == Auth::getCurrentUser()->name); $this->context->route->arguments['name'] == Auth::getCurrentUser()->getName());
$registerNavItem( $registerNavItem(
'Log out', 'Log out',

View file

@ -1,7 +1,7 @@
<form <form
action="<?= \Chibi\Router::linkTo( action="<?= \Chibi\Router::linkTo(
['UserController', 'deleteAction'], ['UserController', 'deleteAction'],
['name' => $this->context->transport->user->name]) ?>" ['name' => $this->context->transport->user->getName()]) ?>"
method="post" method="post"
class="delete confirmable" class="delete confirmable"
autocomplete="off" autocomplete="off"

View file

@ -1,7 +1,7 @@
<form <form
action="<?= \Chibi\Router::linkTo( action="<?= \Chibi\Router::linkTo(
['UserController', 'editAction'], ['UserController', 'editAction'],
['name' => $this->context->transport->user->name]) ?>" ['name' => $this->context->transport->user->getName()]) ?>"
method="post" method="post"
class="edit" class="edit"
autocomplete="off"> autocomplete="off">

View file

@ -44,15 +44,15 @@ if (Auth::getCurrentUser()->hasEnabledEndlessScrolling())
<div class="user"> <div class="user">
<a class="avatar" href="<?= \Chibi\Router::linkTo( <a class="avatar" href="<?= \Chibi\Router::linkTo(
['UserController', 'genericView'], ['UserController', 'genericView'],
['name' => $user->name]) ?>"> ['name' => $user->getName()]) ?>">
<img src="<?= htmlspecialchars($user->getAvatarUrl(100)) ?>" alt="<?= $user->name ?>"/> <img src="<?= htmlspecialchars($user->getAvatarUrl(100)) ?>" alt="<?= $user->getName() ?>"/>
</a> </a>
<div class="details"> <div class="details">
<h1> <h1>
<a href="<?= \Chibi\Router::linkTo( <a href="<?= \Chibi\Router::linkTo(
['UserController', 'genericView'], ['UserController', 'genericView'],
['name' => $user->name]) ?>"> ['name' => $user->getName()]) ?>">
<?= $user->name ?> <?= $user->getName() ?>
</a> </a>
</h1> </h1>

View file

@ -1,7 +1,7 @@
<form <form
action="<?= \Chibi\Router::linkTo( action="<?= \Chibi\Router::linkTo(
['UserController', 'settingsAction'], ['UserController', 'settingsAction'],
['name' => $this->context->transport->user->name]) ?>" ['name' => $this->context->transport->user->getName()]) ?>"
method="post" method="post"
class="settings"> class="settings">

View file

@ -1,5 +1,5 @@
<?php <?php
Assets::setSubTitle($this->context->transport->user->name); Assets::setSubTitle($this->context->transport->user->getName());
Assets::addStylesheet('user-view.css'); Assets::addStylesheet('user-view.css');
?> ?>
@ -7,13 +7,13 @@ Assets::addStylesheet('user-view.css');
<div class="avatar-wrapper"> <div class="avatar-wrapper">
<a href="<?= \Chibi\Router::linkTo( <a href="<?= \Chibi\Router::linkTo(
['UserController', 'genericView'], ['UserController', 'genericView'],
['name' => $this->context->transport->user->name]) ?>"> ['name' => $this->context->transport->user->getName()]) ?>">
<img <img
src="<?= htmlspecialchars($this->context->transport->user->getAvatarUrl(140)) ?>" src="<?= htmlspecialchars($this->context->transport->user->getAvatarUrl(140)) ?>"
alt="<?= $this->context->transport->user->name ?>"/> alt="<?= $this->context->transport->user->getName() ?>"/>
</a> </a>
<h1><?= $this->context->transport->user->name ?></h1> <h1><?= $this->context->transport->user->getName() ?></h1>
</div> </div>
<div class="unit details"> <div class="unit details">
@ -98,7 +98,7 @@ Assets::addStylesheet('user-view.css');
'text' => 'Edit account settings', 'text' => 'Edit account settings',
'link' => \Chibi\Router::linkTo( 'link' => \Chibi\Router::linkTo(
['UserController', 'editAction'], ['UserController', 'editAction'],
['name' => $this->context->transport->user->name, 'tab' => 'edit']), ['name' => $this->context->transport->user->getName(), 'tab' => 'edit']),
]; ];
} }
@ -112,7 +112,7 @@ Assets::addStylesheet('user-view.css');
'text' => 'Accept registration', 'text' => 'Accept registration',
'simple-action' => \Chibi\Router::linkTo( 'simple-action' => \Chibi\Router::linkTo(
['UserController', 'acceptRegistrationAction'], ['UserController', 'acceptRegistrationAction'],
['name' => $this->context->transport->user->name]), ['name' => $this->context->transport->user->getName()]),
]; ];
} }
@ -137,7 +137,7 @@ Assets::addStylesheet('user-view.css');
'text' => 'Flag for moderator attention', 'text' => 'Flag for moderator attention',
'simple-action' => \Chibi\Router::linkTo( 'simple-action' => \Chibi\Router::linkTo(
['UserController', 'flagAction'], ['UserController', 'flagAction'],
['name' => $this->context->transport->user->name]), ['name' => $this->context->transport->user->getName()]),
'data-confirm-text' => 'Are you sure you want to flag this user?', 'data-confirm-text' => 'Are you sure you want to flag this user?',
]; ];
} }
@ -155,7 +155,7 @@ Assets::addStylesheet('user-view.css');
'text' => 'Ban user', 'text' => 'Ban user',
'simple-action' => \Chibi\Router::linkTo( 'simple-action' => \Chibi\Router::linkTo(
['UserController', 'banAction'], ['UserController', 'banAction'],
['name' => $this->context->transport->user->name]), ['name' => $this->context->transport->user->getName()]),
'data-confirm-text' => 'Are you sure you want to ban this user?', 'data-confirm-text' => 'Are you sure you want to ban this user?',
]; ];
} }
@ -167,7 +167,7 @@ Assets::addStylesheet('user-view.css');
'text' => 'Unban user', 'text' => 'Unban user',
'simple-action' => \Chibi\Router::linkTo( 'simple-action' => \Chibi\Router::linkTo(
['UserController', 'unbanAction'], ['UserController', 'unbanAction'],
['name' => $this->context->transport->user->name]), ['name' => $this->context->transport->user->getName()]),
'data-confirm-text' => 'Are you sure you want to unban this user?', 'data-confirm-text' => 'Are you sure you want to unban this user?',
]; ];
} }
@ -183,7 +183,7 @@ Assets::addStylesheet('user-view.css');
'text' => 'Delete account', 'text' => 'Delete account',
'link' => \Chibi\Router::linkTo( 'link' => \Chibi\Router::linkTo(
['UserController', 'deleteAction'], ['UserController', 'deleteAction'],
['name' => $this->context->transport->user->name, 'tab' => 'delete']), ['name' => $this->context->transport->user->getName(), 'tab' => 'delete']),
]; ];
} }
@ -202,7 +202,7 @@ Assets::addStylesheet('user-view.css');
<?php endif ?> <?php endif ?>
<a href="<?= \Chibi\Router::linkTo( <a href="<?= \Chibi\Router::linkTo(
['UserController', 'genericView'], ['UserController', 'genericView'],
['name' => $this->context->transport->user->name, ['name' => $this->context->transport->user->getName(),
'tab' => 'favs', 'tab' => 'favs',
'page' => 1]) ?>"> 'page' => 1]) ?>">
Favs Favs
@ -216,7 +216,7 @@ Assets::addStylesheet('user-view.css');
<?php endif ?> <?php endif ?>
<a href="<?= \Chibi\Router::linkTo( <a href="<?= \Chibi\Router::linkTo(
['UserController', 'genericView'], ['UserController', 'genericView'],
['name' => $this->context->transport->user->name, ['name' => $this->context->transport->user->getName(),
'tab' => 'uploads', 'tab' => 'uploads',
'page' => 1]) ?>"> 'page' => 1]) ?>">
Uploads Uploads
@ -234,7 +234,7 @@ Assets::addStylesheet('user-view.css');
<?php endif ?> <?php endif ?>
<a href="<?= \Chibi\Router::linkTo( <a href="<?= \Chibi\Router::linkTo(
['UserController', 'genericView'], ['UserController', 'genericView'],
['name' => $this->context->transport->user->name, ['name' => $this->context->transport->user->getName(),
'tab' => 'settings']) ?>"> 'tab' => 'settings']) ?>">
Browsing settings Browsing settings
</a> </a>
@ -249,7 +249,7 @@ Assets::addStylesheet('user-view.css');
<?php endif ?> <?php endif ?>
<a href="<?= \Chibi\Router::linkTo( <a href="<?= \Chibi\Router::linkTo(
['UserController', 'genericView'], ['UserController', 'genericView'],
['name' => $this->context->transport->user->name, ['name' => $this->context->transport->user->getName(),
'tab' => 'edit']) ?>"> 'tab' => 'edit']) ?>">
Account settings Account settings
</a> </a>
@ -266,7 +266,7 @@ Assets::addStylesheet('user-view.css');
<?php endif ?> <?php endif ?>
<a href="<?= \Chibi\Router::linkTo( <a href="<?= \Chibi\Router::linkTo(
['UserController', 'genericView'], ['UserController', 'genericView'],
['name' => $this->context->transport->user->name, ['name' => $this->context->transport->user->getName(),
'tab' => 'delete']) ?>"> 'tab' => 'delete']) ?>">
Delete account Delete account
</a> </a>