User settings: added opt-in tags in post thumbs

This commit is contained in:
Marcin Kurczewski 2013-11-25 12:07:50 +01:00
parent 505fe1bac3
commit c683fa3b0f
5 changed files with 32 additions and 1 deletions

View file

@ -31,6 +31,7 @@ thumbWidth=150
thumbHeight=150 thumbHeight=150
thumbStyle=outside thumbStyle=outside
endlessScrollingDefault=1 endlessScrollingDefault=1
showPostTagTitlesDefault=0
maxSearchTokens=4 maxSearchTokens=4
maxRelatedPosts=50 maxRelatedPosts=50

View file

@ -293,6 +293,7 @@ class UserController
$user->enableSafety($safety, in_array($safety, $suppliedSafety)); $user->enableSafety($safety, in_array($safety, $suppliedSafety));
$user->enableEndlessScrolling(InputHelper::get('endless-scrolling')); $user->enableEndlessScrolling(InputHelper::get('endless-scrolling'));
$user->enablePostTagTitles(InputHelper::get('post-tag-titles'));
Model_User::save($user); Model_User::save($user);
if ($user->id == $this->context->user->id) if ($user->id == $this->context->user->id)

View file

@ -3,6 +3,7 @@ class Model_User extends AbstractModel
{ {
const SETTING_SAFETY = 1; const SETTING_SAFETY = 1;
const SETTING_ENDLESS_SCROLLING = 2; const SETTING_ENDLESS_SCROLLING = 2;
const SETTING_POST_TAG_TITLES = 3;
@ -206,6 +207,19 @@ class Model_User extends AbstractModel
$this->setSetting(self::SETTING_SAFETY, $new); $this->setSetting(self::SETTING_SAFETY, $new);
} }
public function hasEnabledPostTagTitles()
{
$ret = $this->getSetting(self::SETTING_POST_TAG_TITLES);
if ($ret === null)
$ret = \Chibi\Registry::getConfig()->browsing->showPostTagTitlesDefault;
return $ret;
}
public function enablePostTagTitles($enabled)
{
$this->setSetting(self::SETTING_POST_TAG_TITLES, $enabled ? 1 : 0);
}
public function hasEnabledEndlessScrolling() public function hasEnabledEndlessScrolling()
{ {
$ret = $this->getSetting(self::SETTING_ENDLESS_SCROLLING); $ret = $this->getSetting(self::SETTING_ENDLESS_SCROLLING);

View file

@ -13,7 +13,12 @@
<?php echo in_array('tagged', $classNames) ? 'Tagged' : 'Untagged' ?> <?php echo in_array('tagged', $classNames) ? 'Tagged' : 'Untagged' ?>
</a> </a>
<?php endif ?> <?php endif ?>
<a class="link" href="<?php echo \Chibi\UrlHelper::route('post', 'view', ['id' => $this->context->post->id]) ?>">
<?php if ($this->context->user->hasEnabledPostTagTitles()): ?>
<a title="<?php echo join(', ', array_map(['TextHelper', 'reprTag'], $this->context->post->sharedTag)) ?>" class="link" href="<?php echo \Chibi\UrlHelper::route('post', 'view', ['id' => $this->context->post->id]) ?>">
<?php else: ?>
<a class="link" href="<?php echo \Chibi\UrlHelper::route('post', 'view', ['id' => $this->context->post->id]) ?>">
<?php endif ?>
<img class="thumb" src="<?php echo \Chibi\UrlHelper::route('post', 'thumb', ['name' => $this->context->post->name]) ?>" alt="@<?php echo $this->context->post->id ?>"/> <img class="thumb" src="<?php echo \Chibi\UrlHelper::route('post', 'thumb', ['name' => $this->context->post->name]) ?>" alt="@<?php echo $this->context->post->id ?>"/>
<?php <?php
$x = $x =

View file

@ -21,6 +21,16 @@
</div> </div>
</div> </div>
<div class="post-tag-titles">
<label class="left" for="post-tag-titles">Tags in thumbs:</label>
<div class="input-wrapper">
<label>
<input type="checkbox" id="post-tag-titles" name="post-tag-titles" <?php if ($this->context->transport->user->hasEnabledPostTagTitles()) echo ' checked="checked"' ?>/>
Enabled
</label>
</div>
</div>
<input type="hidden" name="submit" value="1"/> <input type="hidden" name="submit" value="1"/>
<?php $this->renderFile('message') ?> <?php $this->renderFile('message') ?>