small commit

This commit is contained in:
Pachira 2016-03-24 01:40:59 +01:00
parent de09300cc8
commit 86c4ac9c05
7 changed files with 48 additions and 19 deletions

View file

@ -40,7 +40,7 @@ class Align extends CodeDefinition
$alignments = [
'left',
'center',
'right'
'right',
];
$content = "";
@ -55,6 +55,6 @@ class Align extends CodeDefinition
return $el->getAsBBCode();
}
return '<div style="text-align: ' . $alignment . ';">' . $content . '</div>';
return "<div style='text-align: {$alignment};'>{$content}</div>";
}
}

View file

@ -36,6 +36,10 @@ class Code extends CodeDefinition
*/
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()
);
}
}

View file

@ -45,15 +45,21 @@ class Lists extends CodeDefinition
public function asHtml(ElementNode $el)
{
$bodyHtml = '';
foreach ($el->getChildren() as $child) {
$bodyHtml .= $child->getAsHTML();
}
$listPieces = explode('[*]', $bodyHtml);
unset($listPieces[0]);
$listPieces = array_map(function ($li) {
return '<li>'.$li.'</li>';
return "<li>{$li}</li>";
}, $listPieces);
return '<ul>'.implode('', $listPieces).'</ul>';
$list = implode('', $listPieces);
return "<ul>{$list}</ul>";
}
}

View file

@ -52,6 +52,8 @@ class Size extends CodeDefinition
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>";
}
}

View file

@ -47,7 +47,8 @@ class YouTube extends CodeDefinition
if (!$foundMatch) {
return $el->getAsBBCode();
} 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>";
}
}
}

View file

@ -403,8 +403,4 @@ class ForumController extends Controller
return header("Location: {$threadLink}#p{$post->id}");
}
protected function postingBase($title, $text, $forum, $thread = 0, $post = 0)
{
}
}

View file

@ -36,7 +36,8 @@ $thread->forum;
$forum = new Forum($forumId);
// 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
$renderData['page'] = [
'title' => 'Information',
@ -52,7 +53,8 @@ if (!$forum->permission(ForumPerms::VIEW, $currentUser->id) || !$forum->permissi
}
// 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
$renderData['page'] = [
'title' => 'Information',
@ -112,7 +114,9 @@ if ($mode != 'f') {
}
// 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
$renderData['page'] = [
'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
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
$post = $thread->posts()[$_GET['p']];
@ -137,7 +145,11 @@ if ($mode != 'f') {
$posting['text'] = "[quote={$post->poster->username}]{$quotedPost}[/quote]";
// 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
if (!$currentUser->permission(ForumPerms::EDIT_OWN, Perms::FORUM)) {
// Add page specific things
@ -153,8 +165,11 @@ if ($mode != 'f') {
echo Template::render('global/information');
exit;
}
// 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
$renderData['page'] = [
'redirect' => (isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : Router::route('forums.index')),
@ -179,7 +194,11 @@ if ($mode != 'f') {
'id' => $post->id,
]);
// 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
if (!$currentUser->permission(ForumPerms::DELETE_OWN, Perms::FORUM)) {
// Add page specific things
@ -197,7 +216,8 @@ if ($mode != 'f') {
}
// 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
$renderData['page'] = [
'redirect' => (isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : Router::route('forums.index')),