mirror of
https://github.com/vichan-devel/vichan.git
synced 2025-01-19 01:24:05 +01:00
Update theme.php (#409)
fixed hardcoded root that broke spoilered images on the catalog if vichan was not installed on the web root.
This commit is contained in:
parent
2d1420b763
commit
b5eee58b96
@ -1,18 +1,18 @@
|
||||
<?php
|
||||
require 'info.php';
|
||||
|
||||
|
||||
function catalog_build($action, $settings, $board) {
|
||||
global $config;
|
||||
|
||||
|
||||
// Possible values for $action:
|
||||
// - all (rebuild everything, initialization)
|
||||
// - news (news has been updated)
|
||||
// - boards (board list changed)
|
||||
// - post (a reply has been made)
|
||||
// - post-thread (a thread has been made)
|
||||
|
||||
|
||||
$boards = explode(' ', $settings['boards']);
|
||||
|
||||
|
||||
if ($action == 'all') {
|
||||
foreach ($boards as $board) {
|
||||
$b = new Catalog();
|
||||
@ -39,35 +39,35 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Wrap functions in a class so they don't interfere with normal Tinyboard operations
|
||||
class Catalog {
|
||||
public function build($settings, $board_name) {
|
||||
global $config, $board;
|
||||
|
||||
if (!isset($board) || $board['uri'] != $board_name) {
|
||||
if (!isset($board) || $board['uri'] != $board_name) {
|
||||
if (!openBoard($board_name)) {
|
||||
error(sprintf(_("Board %s doesn't exist"), $board_name));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$recent_images = array();
|
||||
$recent_posts = array();
|
||||
$stats = array();
|
||||
|
||||
|
||||
$query = query(sprintf("SELECT *, `id` AS `thread_id`,
|
||||
(SELECT COUNT(`id`) FROM ``posts_%s`` WHERE `thread` = `thread_id`) AS `reply_count`,
|
||||
(SELECT SUM(`num_files`) FROM ``posts_%s`` WHERE `thread` = `thread_id` AND `num_files` IS NOT NULL) AS `image_count`,
|
||||
'%s' AS `board` FROM ``posts_%s`` WHERE `thread` IS NULL ORDER BY `bump` DESC",
|
||||
$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);
|
||||
$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)) {
|
||||
$post['youtube'] = $matches[2];
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($post['files']) && $post['files']) {
|
||||
$files = json_decode($post['files']);
|
||||
@ -87,7 +87,7 @@
|
||||
}
|
||||
}
|
||||
else if($files[0]->thumb == 'spoiler') {
|
||||
$post['file'] = '/' . $config['spoiler_image'];
|
||||
$post['file'] = $config['root'] . $config['spoiler_image'];
|
||||
}
|
||||
else {
|
||||
$post['file'] = $config['uri_thumb'] . $files[0]->thumb;
|
||||
@ -101,7 +101,7 @@
|
||||
$post['pubdate'] = date('r', $post['time']);
|
||||
$recent_posts[] = $post;
|
||||
}
|
||||
|
||||
|
||||
$required_scripts = array('js/jquery.min.js', 'js/jquery.mixitup.min.js', 'js/catalog.js');
|
||||
|
||||
foreach($required_scripts as $i => $s) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user