Jony/core/short.php

79 lines
3.5 KiB
PHP
Raw Normal View History

2021-01-29 15:38:41 +00:00
<?php
2021-02-06 10:33:20 +00:00
function _parseContent($post, $login)
2021-01-29 15:38:41 +00:00
{
2021-02-06 10:33:20 +00:00
$content = $post->content;
2021-02-18 13:28:07 +00:00
$content = _parseReply($content);
2021-03-26 07:27:06 +00:00
if (strpos($content, '{x}') !== false || strpos($content, '{ }') !== false) {
$content = strtr($content, array(
"{x}" => '<input type="checkbox" class="joe_detail__article-checkbox" checked disabled></input>',
"{ }" => '<input type="checkbox" class="joe_detail__article-checkbox" disabled></input>'
));
}
if (strpos($content, '{music') !== false) {
2021-03-30 08:45:25 +00:00
$content = preg_replace('/{music-list([^\/}]*)\/}/SU', '<joe-mlist $1></joe-mlist>', $content);
$content = preg_replace('/{music([^\/}]*)\/}/SU', '<joe-music $1></joe-music>', $content);
}
if (strpos($content, '{bilibili') !== false) {
$content = preg_replace('/{bilibili([^\/}]*)\/}/SU', '<joe-bilibili $1></joe-bilibili>', $content);
2021-03-26 07:27:06 +00:00
}
2021-02-21 09:45:35 +00:00
/* 过滤默认卡片 */
2021-03-05 07:49:33 +00:00
if (strpos($content, '{card-default') !== false) {
$content = preg_replace('/{card-default(.*)}/SU', '<joe-card $1>', $content);
$content = preg_replace('/{\/card-default}/SU', '</joe-card>', $content);
2021-02-05 02:29:26 +00:00
}
2021-02-21 09:45:35 +00:00
/* 过滤回复可见 */
2021-03-05 07:49:33 +00:00
if (strpos($content, '{hide') !== false) {
2021-02-21 09:45:35 +00:00
$db = Typecho_Db::get();
$hasComment = $db->fetchAll($db->select()->from('table.comments')->where('cid = ?', $post->cid)->where('mail = ?', $post->remember('mail', true))->limit(1));
if ($hasComment || $login) {
2021-03-05 07:49:33 +00:00
$content = strtr($content, array("{hide}" => "<joe-show>", "{/hide}" => "</joe-show>"));
2021-02-21 09:45:35 +00:00
} else {
2021-03-05 07:49:33 +00:00
$content = strtr($content, array("{hide}" => "<joe-hide>", "{/hide}" => "</joe-hide>"));
2021-02-21 09:45:35 +00:00
}
2021-02-05 02:29:26 +00:00
}
2021-03-26 07:27:06 +00:00
2021-03-05 07:49:33 +00:00
/* 过滤dplayer播放器 */
if (strpos($content, '{dplayer') !== false) {
$player = Helper::options()->JCustomPlayer ? Helper::options()->JCustomPlayer : '/usr/themes/Joe/library/player.php?url=';
$content = preg_replace('/{dplayer(.*)\/}/SU', '<joe-dplayer player="' . $player . '" $1></joe-dplayer>', $content);
}
2021-03-30 08:45:25 +00:00
2021-02-07 09:32:06 +00:00
/* 过滤复制粘贴功能 */
2021-03-05 07:49:33 +00:00
if (strpos($content, '{copy') !== false) {
$content = preg_replace('/{copy(.*)}/SU', '<joe-copy $1>', $content);
$content = preg_replace('/{\/copy}/SU', '</joe-copy>', $content);
2021-02-07 09:32:06 +00:00
}
2021-02-21 09:45:35 +00:00
/* 过滤居中标题 */
2021-03-05 07:49:33 +00:00
if (strpos($content, '{mtitle') !== false) {
$content = strtr($content, array("{mtitle}" => '<joe-mtitle>', "{/mtitle}" => '</joe-mtitle>'));
2021-02-21 09:45:35 +00:00
}
2021-03-05 07:49:33 +00:00
/* 过滤消息提示 */
if (strpos($content, '{message') !== false) {
$content = preg_replace('/{message(.*)}/SU', '<joe-message $1>', $content);
$content = preg_replace('/{\/message}/SU', '</joe-message>', $content);
}
/* 标签按钮 */
if (strpos($content, '{anote') !== false) {
$content = preg_replace('/{anote(.*)}/SU', '<joe-anote $1>', $content);
$content = preg_replace('/{\/anote}/SU', '</joe-anote>', $content);
}
/* 多彩按钮 */
if (strpos($content, '{abtn') !== false) {
$content = preg_replace('/{abtn(.*)}/SU', '<joe-abtn $1>', $content);
$content = preg_replace('/{\/abtn}/SU', '</joe-abtn>', $content);
2021-02-27 13:00:05 +00:00
}
2021-03-06 07:03:39 +00:00
/* 多彩按钮 */
if (strpos($content, '{timeline') !== false) {
$content = strtr($content, array("{timeline}" => '<joe-timeline>', "{/timeline}" => '</joe-timeline>'));
$content = strtr($content, array("{timeline-item}" => '<joe-timeline-item>', "{/timeline-item}" => '</joe-timeline-item>'));
}
2021-02-06 10:33:20 +00:00
echo $content;
2021-01-29 15:38:41 +00:00
}