refactor(web): fix table classes in backend

This commit is contained in:
Baoshuo Ren 2022-10-10 07:52:30 +08:00
parent 4e4e45160d
commit 1279ccf711
Signed by: baoshuo
GPG Key ID: 00CB9680AB29F51A
7 changed files with 8 additions and 65 deletions

View File

@ -522,15 +522,6 @@ $('#contest-countdown').countdown(<?= $contest['end_time']->getTimestamp() - UOJ
</aside>
</div>
<!-- 表格处理 -->
<script>
$(document).ready(function() {
$('.markdown-body table').each(function() {
$(this).addClass('table table-bordered');
});
});
</script>
<?php endif ?>
<?php if ($contest && $contest['cur_progress'] <= CONTEST_IN_PROGRESS): ?>

View File

@ -192,14 +192,6 @@ table-hover
</aside>
</div>
<script>
$(document).ready(function() {
$('.markdown-body table').each(function() {
$(this).addClass('table table-bordered');
});
});
</script>
<?php endif ?>
<?php echoUOJPageFooter() ?>

View File

@ -298,12 +298,4 @@ EOD;
</div>
<script>
$(document).ready(function() {
$('.markdown-body table').each(function() {
$(this).addClass('table table-bordered');
});
});
</script>
<?php echoUOJPageFooter() ?>

View File

@ -168,14 +168,6 @@
</aside>
</div>
<script>
$(document).ready(function() {
$('.markdown-body table').each(function() {
$(this).addClass('table table-bordered');
});
});
</script>
<?php endif ?>
<?php echoUOJPageFooter() ?>

View File

@ -369,15 +369,6 @@ $('#contest-countdown').countdown(<?= $contest['end_time']->getTimestamp() - UOJ
</aside>
</div>
<script>
$(document).ready(function() {
$('.markdown-body table').each(function() {
$(this).addClass('table table-bordered');
});
});
</script>
<?php endif ?>
<?php if ($contest && $contest['cur_progress'] <= CONTEST_IN_PROGRESS): ?>

View File

@ -114,7 +114,14 @@ class UOJBlogEditor {
if ($this->show_editor) {
if ($this->type == 'blog') {
$content_md = $_POST[$this->name . '_content_md'];
$this->post_data['content'] = $parsedown->text($this->post_data['content_md']);
$dom = new DOMDocument;
$dom->loadHTML(mb_convert_encoding($parsedown->text($this->post_data['content_md']), 'HTML-ENTITIES', 'UTF-8'));
$elements = $dom->getElementsByTagName('table');
foreach ($elements as $element) {
$element->setAttribute('class',
$element->getAttribute('class') . ' table table-bordered');
}
$this->post_data['content'] = $purifier->purify($dom->saveHTML());
if (preg_match('/^.*<!--.*readmore.*-->.*$/m', $this->post_data['content'], $matches, PREG_OFFSET_CAPTURE)) {
$content_less = substr($this->post_data['content'], 0, $matches[0][1]);
@ -203,18 +210,6 @@ class UOJBlogEditor {
echo '<article class="markdown-body">';
echo $this->post_data['content'];
echo '</article>';
if (isset($REQUIRE_LIB['bootstrap5'])) {
echo <<<EOD
<script>
$(document).ready(function() {
$('.markdown-body table').each(function() {
$(this).addClass('table table-bordered');
});
});
</script>
EOD;
}
echoUOJPageFooter(array('ShowPageFooter' => false));
} elseif ($this->type == 'slide') {
uojIncludeView('slide', array_merge(

View File

@ -39,16 +39,6 @@ text-decoration-none text-body
<article class="markdown-body">
<?= $content ?>
</article>
<?php if (isset($REQUIRE_LIB['bootstrap5'])): ?>
<script>
$(document).ready(function() {
$('.markdown-body table').each(function() {
$(this).addClass('table table-bordered');
});
});
</script>
<?php endif ?>
<!-- content end -->
<?php elseif ($blog_type == 'slide'): ?>