forked from GithubBackups/vichan
extract create_pm_header
This commit is contained in:
parent
25b2b6bc6e
commit
23f3d15a52
@ -401,7 +401,18 @@ class Post {
|
|||||||
public function build($index=false) {
|
public function build($index=false) {
|
||||||
global $board, $config;
|
global $board, $config;
|
||||||
|
|
||||||
return Element($config['file_post_reply'], array('config' => $config, 'board' => $board, 'post' => &$this, 'index' => $index, 'mod' => $this->mod));
|
$options = [
|
||||||
|
'config' => $config,
|
||||||
|
'board' => $board,
|
||||||
|
'post' => &$this,
|
||||||
|
'index' => $index,
|
||||||
|
'mod' => $this->mod
|
||||||
|
];
|
||||||
|
if ($this->mod) {
|
||||||
|
$options['pm'] = create_pm_header();
|
||||||
|
}
|
||||||
|
|
||||||
|
return Element($config['file_post_reply'], $options);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -465,8 +476,21 @@ class Thread {
|
|||||||
|
|
||||||
event('show-thread', $this);
|
event('show-thread', $this);
|
||||||
|
|
||||||
|
$options = [
|
||||||
|
'config' => $config,
|
||||||
|
'board' => $board,
|
||||||
|
'post' => &$this,
|
||||||
|
'index' => $index,
|
||||||
|
'hasnoko50' => $hasnoko50,
|
||||||
|
'isnoko50' => $isnoko50,
|
||||||
|
'mod' => $this->mod
|
||||||
|
];
|
||||||
|
if ($this->mod) {
|
||||||
|
$options['pm'] = create_pm_header();
|
||||||
|
}
|
||||||
|
|
||||||
$file = ($index && $config['file_board']) ? $config['file_post_thread_fileboard'] : $config['file_post_thread'];
|
$file = ($index && $config['file_board']) ? $config['file_post_thread_fileboard'] : $config['file_post_thread'];
|
||||||
$built = Element($file, array('config' => $config, 'board' => $board, 'post' => &$this, 'index' => $index, 'hasnoko50' => $hasnoko50, 'isnoko50' => $isnoko50, 'mod' => $this->mod));
|
$built = Element($file, $options);
|
||||||
|
|
||||||
return $built;
|
return $built;
|
||||||
}
|
}
|
||||||
|
@ -1301,7 +1301,14 @@ function index($page, $mod=false, $brief = false) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ($config['file_board']) {
|
if ($config['file_board']) {
|
||||||
$body = Element($config['file_fileboard'], array('body' => $body, 'mod' => $mod));
|
$options = [
|
||||||
|
'body' => $body,
|
||||||
|
'mod' => $mod
|
||||||
|
];
|
||||||
|
if ($mod) {
|
||||||
|
$options['pm'] = create_pm_header();
|
||||||
|
}
|
||||||
|
$body = Element($config['file_fileboard'], $options);
|
||||||
}
|
}
|
||||||
|
|
||||||
return array(
|
return array(
|
||||||
@ -1620,7 +1627,7 @@ function incrementSpamHash($hash) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function buildIndex($global_api = "yes") {
|
function buildIndex($global_api = "yes") {
|
||||||
global $board, $config, $build_pages;
|
global $board, $config, $build_pages, $mod;
|
||||||
|
|
||||||
$catalog_api_action = generation_strategy('sb_api', array($board['uri']));
|
$catalog_api_action = generation_strategy('sb_api', array($board['uri']));
|
||||||
|
|
||||||
@ -1692,6 +1699,9 @@ function buildIndex($global_api = "yes") {
|
|||||||
$content['pages'][$page-1]['selected'] = true;
|
$content['pages'][$page-1]['selected'] = true;
|
||||||
$content['btn'] = getPageButtons($content['pages']);
|
$content['btn'] = getPageButtons($content['pages']);
|
||||||
$content['antibot'] = $antibot;
|
$content['antibot'] = $antibot;
|
||||||
|
if ($mod) {
|
||||||
|
$content['pm'] = create_pm_header();
|
||||||
|
}
|
||||||
|
|
||||||
file_write($filename, Element($config['file_board_index'], $content));
|
file_write($filename, Element($config['file_board_index'], $content));
|
||||||
}
|
}
|
||||||
@ -2274,7 +2284,7 @@ function buildThread($id, $return = false, $mod = false) {
|
|||||||
$hasnoko50 = $thread->postCount() >= $config['noko50_min'];
|
$hasnoko50 = $thread->postCount() >= $config['noko50_min'];
|
||||||
$antibot = $mod || $return ? false : create_antibot($board['uri'], $id);
|
$antibot = $mod || $return ? false : create_antibot($board['uri'], $id);
|
||||||
|
|
||||||
$body = Element($config['file_thread'], array(
|
$options = [
|
||||||
'board' => $board,
|
'board' => $board,
|
||||||
'thread' => $thread,
|
'thread' => $thread,
|
||||||
'body' => $thread->build(),
|
'body' => $thread->build(),
|
||||||
@ -2286,7 +2296,12 @@ function buildThread($id, $return = false, $mod = false) {
|
|||||||
'antibot' => $antibot,
|
'antibot' => $antibot,
|
||||||
'boardlist' => createBoardlist($mod),
|
'boardlist' => createBoardlist($mod),
|
||||||
'return' => ($mod ? '?' . $board['url'] . $config['file_index'] : $config['root'] . $board['dir'] . $config['file_index'])
|
'return' => ($mod ? '?' . $board['url'] . $config['file_index'] : $config['root'] . $board['dir'] . $config['file_index'])
|
||||||
));
|
];
|
||||||
|
if ($mod) {
|
||||||
|
$options['pm'] = create_pm_header();
|
||||||
|
}
|
||||||
|
|
||||||
|
$body = Element($config['file_thread'], $options);
|
||||||
|
|
||||||
// json api
|
// json api
|
||||||
if ($config['api']['enabled'] && !$mod) {
|
if ($config['api']['enabled'] && !$mod) {
|
||||||
@ -2323,7 +2338,7 @@ function buildThread($id, $return = false, $mod = false) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function buildThread50($id, $return = false, $mod = false, $thread = null, $antibot = false) {
|
function buildThread50($id, $return = false, $mod = false, $thread = null, $antibot = false) {
|
||||||
global $board, $config, $build_pages;
|
global $board, $config;
|
||||||
$id = round($id);
|
$id = round($id);
|
||||||
|
|
||||||
if ($antibot)
|
if ($antibot)
|
||||||
@ -2381,7 +2396,7 @@ function buildThread50($id, $return = false, $mod = false, $thread = null, $anti
|
|||||||
|
|
||||||
$hasnoko50 = $thread->postCount() >= $config['noko50_min'];
|
$hasnoko50 = $thread->postCount() >= $config['noko50_min'];
|
||||||
|
|
||||||
$body = Element($config['file_thread'], array(
|
$options = [
|
||||||
'board' => $board,
|
'board' => $board,
|
||||||
'thread' => $thread,
|
'thread' => $thread,
|
||||||
'body' => $thread->build(false, true),
|
'body' => $thread->build(false, true),
|
||||||
@ -2393,7 +2408,12 @@ function buildThread50($id, $return = false, $mod = false, $thread = null, $anti
|
|||||||
'antibot' => $mod ? false : ($antibot ? $antibot : create_antibot($board['uri'], $id)),
|
'antibot' => $mod ? false : ($antibot ? $antibot : create_antibot($board['uri'], $id)),
|
||||||
'boardlist' => createBoardlist($mod),
|
'boardlist' => createBoardlist($mod),
|
||||||
'return' => ($mod ? '?' . $board['url'] . $config['file_index'] : $config['root'] . $board['dir'] . $config['file_index'])
|
'return' => ($mod ? '?' . $board['url'] . $config['file_index'] : $config['root'] . $board['dir'] . $config['file_index'])
|
||||||
));
|
];
|
||||||
|
if ($mod) {
|
||||||
|
$options['pm'] = create_pm_header();
|
||||||
|
}
|
||||||
|
|
||||||
|
$body = Element($config['file_thread'], $options);
|
||||||
|
|
||||||
if ($return) {
|
if ($return) {
|
||||||
return $body;
|
return $body;
|
||||||
|
@ -28,6 +28,7 @@ function mod_page($title, $template, $args, $subtitle = false) {
|
|||||||
'title' => $title,
|
'title' => $title,
|
||||||
'subtitle' => $subtitle,
|
'subtitle' => $subtitle,
|
||||||
'boardlist' => createBoardlist($mod),
|
'boardlist' => createBoardlist($mod),
|
||||||
|
'pm' => create_pm_header(),
|
||||||
'body' => Element($template,
|
'body' => Element($template,
|
||||||
array_merge(
|
array_merge(
|
||||||
array('config' => $config, 'mod' => $mod),
|
array('config' => $config, 'mod' => $mod),
|
||||||
@ -511,7 +512,7 @@ function mod_new_board(Context $ctx) {
|
|||||||
if (!openBoard($_POST['uri']))
|
if (!openBoard($_POST['uri']))
|
||||||
error(_("Couldn't open board after creation."));
|
error(_("Couldn't open board after creation."));
|
||||||
|
|
||||||
$query = Element('posts.sql', array('board' => $board['uri']));
|
$query = Element('posts.sql', [ 'board' => $board['uri'] ]);
|
||||||
|
|
||||||
if (mysql_version() < 50503)
|
if (mysql_version() < 50503)
|
||||||
$query = preg_replace('/(CHARSET=|CHARACTER SET )utf8mb4/', '$1utf8', $query);
|
$query = preg_replace('/(CHARSET=|CHARACTER SET )utf8mb4/', '$1utf8', $query);
|
||||||
@ -785,6 +786,7 @@ function mod_view_board(Context $ctx, $boardName, $page_no = 1) {
|
|||||||
$page['btn'] = getPageButtons($page['pages'], true);
|
$page['btn'] = getPageButtons($page['pages'], true);
|
||||||
$page['mod'] = true;
|
$page['mod'] = true;
|
||||||
$page['config'] = $config;
|
$page['config'] = $config;
|
||||||
|
$page['pm'] = create_pm_header();
|
||||||
|
|
||||||
echo Element($config['file_board_index'], $page);
|
echo Element($config['file_board_index'], $page);
|
||||||
}
|
}
|
||||||
@ -2358,6 +2360,7 @@ function mod_reports(Context $ctx) {
|
|||||||
'report' => $report,
|
'report' => $report,
|
||||||
'config' => $config,
|
'config' => $config,
|
||||||
'mod' => $mod,
|
'mod' => $mod,
|
||||||
|
'pm' => create_pm_header(),
|
||||||
'token' => make_secure_link_token('reports/' . $report['id'] . '/dismiss'),
|
'token' => make_secure_link_token('reports/' . $report['id'] . '/dismiss'),
|
||||||
'token_all' => make_secure_link_token('reports/' . $report['id'] . '/dismiss&all'),
|
'token_all' => make_secure_link_token('reports/' . $report['id'] . '/dismiss&all'),
|
||||||
'token_post' => make_secure_link_token('reports/'. $report['id'] . '/dismiss&post'),
|
'token_post' => make_secure_link_token('reports/'. $report['id'] . '/dismiss&post'),
|
||||||
@ -2609,6 +2612,7 @@ function mod_config(Context $ctx, $board_config = false) {
|
|||||||
<p style="text-align:center">You may proceed with these changes manually by copying and pasting the following code to the end of <strong>' . $config_file . '</strong>:</p>
|
<p style="text-align:center">You may proceed with these changes manually by copying and pasting the following code to the end of <strong>' . $config_file . '</strong>:</p>
|
||||||
<textarea style="width:700px;height:370px;margin:auto;display:block;background:white;color:black" readonly>' . $config_append . '</textarea>
|
<textarea style="width:700px;height:370px;margin:auto;display:block;background:white;color:black" readonly>' . $config_append . '</textarea>
|
||||||
';
|
';
|
||||||
|
$page['pm'] = create_pm_header();
|
||||||
echo Element($config['file_page_template'], $page);
|
echo Element($config['file_page_template'], $page);
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
@ -2869,7 +2873,13 @@ function mod_edit_page(Context $ctx, $id) {
|
|||||||
|
|
||||||
$fn = (isset($board['uri']) ? ($board['uri'] . '/') : '') . $page['name'] . '.html';
|
$fn = (isset($board['uri']) ? ($board['uri'] . '/') : '') . $page['name'] . '.html';
|
||||||
$body = "<div class='ban'>$write</div>";
|
$body = "<div class='ban'>$write</div>";
|
||||||
$html = Element($config['file_page_template'], array('config' => $config, 'boardlist' => createBoardlist(), 'body' => $body, 'title' => utf8tohtml($page['title'])));
|
$html = Element($config['file_page_template'], [
|
||||||
|
'config' => $config,
|
||||||
|
'boardlist' => createBoardlist(),
|
||||||
|
'body' => $body,
|
||||||
|
'title' => utf8tohtml($page['title']),
|
||||||
|
'pm' => create_pm_header()
|
||||||
|
]);
|
||||||
file_write($fn, $html);
|
file_write($fn, $html);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -34,10 +34,6 @@ function Element($templateFile, array $options) {
|
|||||||
if (!$twig)
|
if (!$twig)
|
||||||
load_twig();
|
load_twig();
|
||||||
|
|
||||||
if (function_exists('create_pm_header') && ((isset($options['mod']) && $options['mod']) || isset($options['__mod'])) && !preg_match('!^mod/!', $templateFile)) {
|
|
||||||
$options['pm'] = create_pm_header();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isset($options['body']) && $config['debug']) {
|
if (isset($options['body']) && $config['debug']) {
|
||||||
$_debug = $debug;
|
$_debug = $debug;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user