small commit
This commit is contained in:
parent
de09300cc8
commit
86c4ac9c05
7 changed files with 48 additions and 19 deletions
|
@ -40,7 +40,7 @@ class Align extends CodeDefinition
|
||||||
$alignments = [
|
$alignments = [
|
||||||
'left',
|
'left',
|
||||||
'center',
|
'center',
|
||||||
'right'
|
'right',
|
||||||
];
|
];
|
||||||
|
|
||||||
$content = "";
|
$content = "";
|
||||||
|
@ -55,6 +55,6 @@ class Align extends CodeDefinition
|
||||||
return $el->getAsBBCode();
|
return $el->getAsBBCode();
|
||||||
}
|
}
|
||||||
|
|
||||||
return '<div style="text-align: ' . $alignment . ';">' . $content . '</div>';
|
return "<div style='text-align: {$alignment};'>{$content}</div>";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,6 +36,10 @@ class Code extends CodeDefinition
|
||||||
*/
|
*/
|
||||||
public function asHtml(ElementNode $el)
|
public function asHtml(ElementNode $el)
|
||||||
{
|
{
|
||||||
return preg_replace("#\n*\[code\]\n*(.*?)\n*\[/code\]\n*#s", '<pre class="code"><code>\\1</code></pre>', $el->getAsBBCode());
|
return preg_replace(
|
||||||
|
"#\n*\[code\]\n*(.*?)\n*\[/code\]\n*#s",
|
||||||
|
'<pre class="code"><code>\\1</code></pre>',
|
||||||
|
$el->getAsBBCode()
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -45,15 +45,21 @@ class Lists extends CodeDefinition
|
||||||
public function asHtml(ElementNode $el)
|
public function asHtml(ElementNode $el)
|
||||||
{
|
{
|
||||||
$bodyHtml = '';
|
$bodyHtml = '';
|
||||||
|
|
||||||
foreach ($el->getChildren() as $child) {
|
foreach ($el->getChildren() as $child) {
|
||||||
$bodyHtml .= $child->getAsHTML();
|
$bodyHtml .= $child->getAsHTML();
|
||||||
}
|
}
|
||||||
|
|
||||||
$listPieces = explode('[*]', $bodyHtml);
|
$listPieces = explode('[*]', $bodyHtml);
|
||||||
|
|
||||||
unset($listPieces[0]);
|
unset($listPieces[0]);
|
||||||
|
|
||||||
$listPieces = array_map(function ($li) {
|
$listPieces = array_map(function ($li) {
|
||||||
return '<li>'.$li.'</li>';
|
return "<li>{$li}</li>";
|
||||||
}, $listPieces);
|
}, $listPieces);
|
||||||
return '<ul>'.implode('', $listPieces).'</ul>';
|
|
||||||
|
$list = implode('', $listPieces);
|
||||||
|
|
||||||
|
return "<ul>{$list}</ul>";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -52,6 +52,8 @@ class Size extends CodeDefinition
|
||||||
return $el->getAsBBCode();
|
return $el->getAsBBCode();
|
||||||
}
|
}
|
||||||
|
|
||||||
return '<span style="font-size: ' . ($size / 100) . 'em;">' . $content . '</span>';
|
$size = $size / 100;
|
||||||
|
|
||||||
|
return "<span style='font-size: {$size}em;'>{$content}</span>";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -47,7 +47,8 @@ class YouTube extends CodeDefinition
|
||||||
if (!$foundMatch) {
|
if (!$foundMatch) {
|
||||||
return $el->getAsBBCode();
|
return $el->getAsBBCode();
|
||||||
} else {
|
} else {
|
||||||
return "<iframe width=\"640\" height=\"390\" src=\"https://www.youtube.com/embed/".$matches[1]."\" frameborder=\"0\" allowfullscreen></iframe>";
|
return "<iframe width='640' height='390' src='https://www.youtube.com/embed/{$matches[1]}'
|
||||||
|
frameborder='0' allowfullscreen></iframe>";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -403,8 +403,4 @@ class ForumController extends Controller
|
||||||
|
|
||||||
return header("Location: {$threadLink}#p{$post->id}");
|
return header("Location: {$threadLink}#p{$post->id}");
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function postingBase($title, $text, $forum, $thread = 0, $post = 0)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,7 +36,8 @@ $thread->forum;
|
||||||
$forum = new Forum($forumId);
|
$forum = new Forum($forumId);
|
||||||
|
|
||||||
// Check if the user has access to the forum
|
// Check if the user has access to the forum
|
||||||
if (!$forum->permission(ForumPerms::VIEW, $currentUser->id) || !$forum->permission(ForumPerms::REPLY, $currentUser->id)) {
|
if (!$forum->permission(ForumPerms::VIEW, $currentUser->id)
|
||||||
|
|| !$forum->permission(ForumPerms::REPLY, $currentUser->id)) {
|
||||||
// Set render data
|
// Set render data
|
||||||
$renderData['page'] = [
|
$renderData['page'] = [
|
||||||
'title' => 'Information',
|
'title' => 'Information',
|
||||||
|
@ -52,7 +53,8 @@ if (!$forum->permission(ForumPerms::VIEW, $currentUser->id) || !$forum->permissi
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if the user has access to the forum
|
// Check if the user has access to the forum
|
||||||
if (!isset($thread) && !$forum->permission(ForumPerms::CREATE_THREADS, $currentUser->id)) {
|
if (!isset($thread)
|
||||||
|
&& !$forum->permission(ForumPerms::CREATE_THREADS, $currentUser->id)) {
|
||||||
// Set render data
|
// Set render data
|
||||||
$renderData['page'] = [
|
$renderData['page'] = [
|
||||||
'title' => 'Information',
|
'title' => 'Information',
|
||||||
|
@ -112,7 +114,9 @@ if ($mode != 'f') {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Prompt an error if the topic doesn't exist
|
// Prompt an error if the topic doesn't exist
|
||||||
if ($thread->status == 1 && !$forum->permission(ForumPerms::LOCK, $currentUser->id)) {
|
if ($thread->status == 1
|
||||||
|
&& !$forum->permission(ForumPerms::LOCK, $currentUser->id)) {
|
||||||
|
|
||||||
// Add page specific things
|
// Add page specific things
|
||||||
$renderData['page'] = [
|
$renderData['page'] = [
|
||||||
'redirect' => (isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : Router::route('forums.index')),
|
'redirect' => (isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : Router::route('forums.index')),
|
||||||
|
@ -128,7 +132,11 @@ if ($mode != 'f') {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if we're in quote mode
|
// Check if we're in quote mode
|
||||||
if ($mode == 'p' && isset($_GET['quote']) && $_GET['quote'] == $_GET['p'] && array_key_exists($_GET['p'], $thread->posts())) {
|
if ($mode == 'p'
|
||||||
|
&& isset($_GET['quote'])
|
||||||
|
&& $_GET['quote'] == $_GET['p']
|
||||||
|
&& array_key_exists($_GET['p'], $thread->posts())) {
|
||||||
|
|
||||||
// Reassign post for ease
|
// Reassign post for ease
|
||||||
$post = $thread->posts()[$_GET['p']];
|
$post = $thread->posts()[$_GET['p']];
|
||||||
|
|
||||||
|
@ -137,7 +145,11 @@ if ($mode != 'f') {
|
||||||
$posting['text'] = "[quote={$post->poster->username}]{$quotedPost}[/quote]";
|
$posting['text'] = "[quote={$post->poster->username}]{$quotedPost}[/quote]";
|
||||||
|
|
||||||
// Post editing
|
// Post editing
|
||||||
} elseif ($mode == 'p' && isset($_GET['edit']) && $_GET['edit'] == $_GET['p'] && array_key_exists($_GET['p'], $thread->posts())) {
|
} elseif ($mode == 'p'
|
||||||
|
&& isset($_GET['edit'])
|
||||||
|
&& $_GET['edit'] == $_GET['p']
|
||||||
|
&& array_key_exists($_GET['p'], $thread->posts())) {
|
||||||
|
|
||||||
// Permissions
|
// Permissions
|
||||||
if (!$currentUser->permission(ForumPerms::EDIT_OWN, Perms::FORUM)) {
|
if (!$currentUser->permission(ForumPerms::EDIT_OWN, Perms::FORUM)) {
|
||||||
// Add page specific things
|
// Add page specific things
|
||||||
|
@ -153,8 +165,11 @@ if ($mode != 'f') {
|
||||||
echo Template::render('global/information');
|
echo Template::render('global/information');
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Checks
|
// Checks
|
||||||
if ($thread->posts()[$_GET['p']]->poster->id != $currentUser->id && !$forum->permission(ForumPerms::EDIT_ANY, $currentUser->id)) {
|
if ($thread->posts()[$_GET['p']]->poster->id != $currentUser->id
|
||||||
|
&& !$forum->permission(ForumPerms::EDIT_ANY, $currentUser->id)) {
|
||||||
|
|
||||||
// Add page specific things
|
// Add page specific things
|
||||||
$renderData['page'] = [
|
$renderData['page'] = [
|
||||||
'redirect' => (isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : Router::route('forums.index')),
|
'redirect' => (isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : Router::route('forums.index')),
|
||||||
|
@ -179,7 +194,11 @@ if ($mode != 'f') {
|
||||||
'id' => $post->id,
|
'id' => $post->id,
|
||||||
]);
|
]);
|
||||||
// Post deletion
|
// Post deletion
|
||||||
} elseif ($mode == 'p' && isset($_GET['delete']) && $_GET['delete'] == $_GET['p'] && array_key_exists($_GET['p'], $thread->posts())) {
|
} elseif ($mode == 'p'
|
||||||
|
&& isset($_GET['delete'])
|
||||||
|
&& $_GET['delete'] == $_GET['p']
|
||||||
|
&& array_key_exists($_GET['p'], $thread->posts())) {
|
||||||
|
|
||||||
// Permissions
|
// Permissions
|
||||||
if (!$currentUser->permission(ForumPerms::DELETE_OWN, Perms::FORUM)) {
|
if (!$currentUser->permission(ForumPerms::DELETE_OWN, Perms::FORUM)) {
|
||||||
// Add page specific things
|
// Add page specific things
|
||||||
|
@ -197,7 +216,8 @@ if ($mode != 'f') {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Checks
|
// Checks
|
||||||
if ($thread->posts()[$_GET['p']]->poster->id != $currentUser->id && !$forum->permission(ForumPerms::DELETE_ANY, $currentUser->id)) {
|
if ($thread->posts()[$_GET['p']]->poster->id != $currentUser->id
|
||||||
|
&& !$forum->permission(ForumPerms::DELETE_ANY, $currentUser->id)) {
|
||||||
// Add page specific things
|
// Add page specific things
|
||||||
$renderData['page'] = [
|
$renderData['page'] = [
|
||||||
'redirect' => (isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : Router::route('forums.index')),
|
'redirect' => (isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : Router::route('forums.index')),
|
||||||
|
|
Reference in a new issue