1
0
mirror of https://github.com/vichan-devel/vichan.git synced 2024-11-23 23:20:57 +01:00

simple catalog support for moderators

This commit is contained in:
sshscp15 2022-06-20 15:09:55 -03:00 committed by Fredrick Brennan
parent c170bc7ef2
commit 4db4ab9cf0
7 changed files with 37 additions and 8 deletions

View File

@ -1207,6 +1207,7 @@
// Location of files.
$config['file_index'] = 'index.html';
$config['file_page'] = '%d.html'; // NB: page is both an index page and a thread
$config['file_catalog'] = 'catalog.html';
$config['file_page50'] = '%d+50.html';
$config['file_page_slug'] = '%d-%s.html';
$config['file_page50_slug'] = '%d-%s+50.html';

View File

@ -734,6 +734,18 @@ function mod_board_log($board, $page_no = 1, $hide_names = false, $public = fals
mod_page(_('Board log'), 'mod/log.html', array('logs' => $logs, 'count' => $count, 'board' => $board, 'hide_names' => $hide_names, 'public' => $public));
}
function mod_view_catalog($boardName) {
global $config, $mod;
require_once($config['dir']['themes'].'/catalog/theme.php');
$settings = array();
$settings['boards'] = $boardName;
$settings['update_on_posts'] = true;
$settings['title'] = 'Catalog';
$settings['use_tooltipster'] = true;
$catalog = new Catalog();
echo $catalog->build($settings, $boardName, true);
}
function mod_view_board($boardName, $page_no = 1) {
global $config, $mod;

View File

@ -102,6 +102,7 @@ $pages = array(
// This should always be at the end:
'/(\%b)/' => 'view_board',
'/(\%b)/' . preg_quote($config['file_index'], '!') => 'view_board',
'/(\%b)/' . preg_quote($config['file_catalog'], '!') => 'view_catalog',
'/(\%b)/' . str_replace('%d', '(\d+)', preg_quote($config['file_page'], '!')) => 'view_board',
'/(\%b)/' . preg_quote($config['dir']['res'], '!') .
str_replace('%d', '(\d+)', preg_quote($config['file_page50'], '!')) => 'view_thread50',

View File

@ -80,7 +80,7 @@
[<a {% if page.selected %}class="selected"{% endif %}{% if not page.selected %}href="{{ page.link }}"{% endif %}>{{ page.num }}</a>]{% if loop.last %} {% endif %}
{% endfor %} {{ btn.next }}
{% if config.catalog_link %}
| <a href="{{ config.root }}{{ board.dir }}{{ config.catalog_link }}">{% trans %}Catalog{% endtrans %}</a>
| <a href="{{ config.root }}{% if mod %}{{ config.file_mod }}?/{% endif %}{{ board.dir }}{{ config.catalog_link }}">{% trans %}Catalog{% endtrans %}</a>
{% endif %}
</div>

View File

@ -14,7 +14,9 @@
{{ boardlist.top }}
<header>
<h1>{{ settings.title }} (<a href="{{link}}">/{{ board }}/</a>)</h1>
<div class="subtitle">{{ settings.subtitle }}</div>
<div class="subtitle">{{ settings.subtitle }}
{% if mod %}<p><a href="?/">{% trans %}Return to dashboard{% endtrans %}</a></p>{% endif %}
</div>
</header>
<span>{% trans 'Sort by' %}: </span>

View File

@ -42,7 +42,7 @@
// Wrap functions in a class so they don't interfere with normal Tinyboard operations
class Catalog {
public function build($settings, $board_name) {
public function build($settings, $board_name, $mod = false) {
global $config, $board;
if (!isset($board) || $board['uri'] != $board_name) {
@ -62,7 +62,11 @@
$board_name, $board_name, $board_name, $board_name, $board_name)) or error(db_error());
while ($post = $query->fetch(PDO::FETCH_ASSOC)) {
$post['link'] = $config['root'] . $board['dir'] . $config['dir']['res'] . link_for($post);
if ($mod)
$post['link'] = $config['root'] . $config['file_mod'] . '?/'. $board['dir'] . $config['dir']['res'] . link_for($post);
else
$post['link'] = $config['root'] . $board['dir'] . $config['dir']['res'] . link_for($post);
$post['board_name'] = $board['name'];
if ($post['embed'] && preg_match('/^https?:\/\/(\w+\.)?(?:youtube\.com\/watch\?v=|youtu\.be\/)([a-zA-Z0-9\-_]{10,11})(&.+)?$/i', $post['embed'], $matches)) {
@ -109,7 +113,9 @@
$config['additional_javascript'][] = $s;
}
file_write($config['dir']['home'] . $board_name . '/catalog.html', Element('themes/catalog/catalog.html', Array(
$link = ($mod) ? $config['root'] . $config['file_mod'] . '?/' . $board['dir'] : $config['root'] . $board['dir'];
$element = Element('themes/catalog/catalog.html', Array(
'settings' => $settings,
'config' => $config,
'boardlist' => createBoardlist(),
@ -117,8 +123,14 @@
'recent_posts' => $recent_posts,
'stats' => $stats,
'board' => $board_name,
'link' => $config['root'] . $board['dir']
)));
'link' => $link,
'mod' => $mod
));
if ($mod) {
return $element;
} else {
file_write($config['dir']['home'] . $board_name . '/catalog.html', $element);
file_write($config['dir']['home'] . $board_name . '/index.rss', Element('themes/catalog/index.rss', Array(
'config' => $config,
@ -126,4 +138,5 @@
'board' => $board
)));
}
}
};

View File

@ -63,7 +63,7 @@
<a id="thread-return" href="{{ return }}">[{% trans %}Return{% endtrans %}]</a>
<a id="thread-top" href="#top">[{% trans %}Go to top{% endtrans %}]</a>
{% if config.catalog_link %}
<a id="thread-catalog" href="{{ config.root }}{{ board.dir }}{{ config.catalog_link }}">[{% trans %}Catalog{% endtrans %}]</a>
<a id="thread-catalog" href="{{ config.root }}{% if mod %}{{ config.file_mod }}?/{% endif %}{{ board.dir }}{{ config.catalog_link }}">{% trans %}Catalog{% endtrans %}</a>
{% endif %}
</span>