mirror of
https://github.com/vichan-devel/vichan.git
synced 2025-02-17 11:28:41 +01:00
simple catalog support for moderators
This commit is contained in:
parent
c170bc7ef2
commit
4db4ab9cf0
@ -1207,6 +1207,7 @@
|
|||||||
// Location of files.
|
// Location of files.
|
||||||
$config['file_index'] = 'index.html';
|
$config['file_index'] = 'index.html';
|
||||||
$config['file_page'] = '%d.html'; // NB: page is both an index page and a thread
|
$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_page50'] = '%d+50.html';
|
||||||
$config['file_page_slug'] = '%d-%s.html';
|
$config['file_page_slug'] = '%d-%s.html';
|
||||||
$config['file_page50_slug'] = '%d-%s+50.html';
|
$config['file_page50_slug'] = '%d-%s+50.html';
|
||||||
|
@ -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));
|
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) {
|
function mod_view_board($boardName, $page_no = 1) {
|
||||||
global $config, $mod;
|
global $config, $mod;
|
||||||
|
|
||||||
|
1
mod.php
1
mod.php
@ -102,6 +102,7 @@ $pages = array(
|
|||||||
// This should always be at the end:
|
// This should always be at the end:
|
||||||
'/(\%b)/' => 'view_board',
|
'/(\%b)/' => 'view_board',
|
||||||
'/(\%b)/' . preg_quote($config['file_index'], '!') => '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)/' . str_replace('%d', '(\d+)', preg_quote($config['file_page'], '!')) => 'view_board',
|
||||||
'/(\%b)/' . preg_quote($config['dir']['res'], '!') .
|
'/(\%b)/' . preg_quote($config['dir']['res'], '!') .
|
||||||
str_replace('%d', '(\d+)', preg_quote($config['file_page50'], '!')) => 'view_thread50',
|
str_replace('%d', '(\d+)', preg_quote($config['file_page50'], '!')) => 'view_thread50',
|
||||||
|
@ -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 %}
|
[<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 }}
|
{% endfor %} {{ btn.next }}
|
||||||
{% if config.catalog_link %}
|
{% 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 %}
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
@ -14,7 +14,9 @@
|
|||||||
{{ boardlist.top }}
|
{{ boardlist.top }}
|
||||||
<header>
|
<header>
|
||||||
<h1>{{ settings.title }} (<a href="{{link}}">/{{ board }}/</a>)</h1>
|
<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>
|
</header>
|
||||||
|
|
||||||
<span>{% trans 'Sort by' %}: </span>
|
<span>{% trans 'Sort by' %}: </span>
|
||||||
|
@ -42,7 +42,7 @@
|
|||||||
|
|
||||||
// Wrap functions in a class so they don't interfere with normal Tinyboard operations
|
// Wrap functions in a class so they don't interfere with normal Tinyboard operations
|
||||||
class Catalog {
|
class Catalog {
|
||||||
public function build($settings, $board_name) {
|
public function build($settings, $board_name, $mod = false) {
|
||||||
global $config, $board;
|
global $config, $board;
|
||||||
|
|
||||||
if (!isset($board) || $board['uri'] != $board_name) {
|
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());
|
$board_name, $board_name, $board_name, $board_name, $board_name)) or error(db_error());
|
||||||
|
|
||||||
while ($post = $query->fetch(PDO::FETCH_ASSOC)) {
|
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'];
|
$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)) {
|
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;
|
$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,
|
'settings' => $settings,
|
||||||
'config' => $config,
|
'config' => $config,
|
||||||
'boardlist' => createBoardlist(),
|
'boardlist' => createBoardlist(),
|
||||||
@ -117,8 +123,14 @@
|
|||||||
'recent_posts' => $recent_posts,
|
'recent_posts' => $recent_posts,
|
||||||
'stats' => $stats,
|
'stats' => $stats,
|
||||||
'board' => $board_name,
|
'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(
|
file_write($config['dir']['home'] . $board_name . '/index.rss', Element('themes/catalog/index.rss', Array(
|
||||||
'config' => $config,
|
'config' => $config,
|
||||||
@ -126,4 +138,5 @@
|
|||||||
'board' => $board
|
'board' => $board
|
||||||
)));
|
)));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
@ -63,7 +63,7 @@
|
|||||||
<a id="thread-return" href="{{ return }}">[{% trans %}Return{% endtrans %}]</a>
|
<a id="thread-return" href="{{ return }}">[{% trans %}Return{% endtrans %}]</a>
|
||||||
<a id="thread-top" href="#top">[{% trans %}Go to top{% endtrans %}]</a>
|
<a id="thread-top" href="#top">[{% trans %}Go to top{% endtrans %}]</a>
|
||||||
{% if config.catalog_link %}
|
{% 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 %}
|
{% endif %}
|
||||||
</span>
|
</span>
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user