mirror of
https://github.com/lkddi/nexusphp.git
synced 2026-04-27 06:07:22 +08:00
format_description() support another img bbcode syntax
This commit is contained in:
@@ -95,7 +95,7 @@ class Test extends Command
|
|||||||
*/
|
*/
|
||||||
public function handle()
|
public function handle()
|
||||||
{
|
{
|
||||||
$logFile = getLogFile("seed-points");
|
$logFile = format_description('[img=http://www.baidu.com][img]http://www.baidu.com[/img]');
|
||||||
dd($logFile);
|
dd($logFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
defined('VERSION_NUMBER') || define('VERSION_NUMBER', '1.8.0');
|
defined('VERSION_NUMBER') || define('VERSION_NUMBER', '1.8.0');
|
||||||
defined('RELEASE_DATE') || define('RELEASE_DATE', '2023-03-19');
|
defined('RELEASE_DATE') || define('RELEASE_DATE', '2023-03-26');
|
||||||
defined('IN_TRACKER') || define('IN_TRACKER', false);
|
defined('IN_TRACKER') || define('IN_TRACKER', false);
|
||||||
defined('PROJECTNAME') || define("PROJECTNAME","NexusPHP");
|
defined('PROJECTNAME') || define("PROJECTNAME","NexusPHP");
|
||||||
defined('NEXUSPHPURL') || define("NEXUSPHPURL","https://nexusphp.org");
|
defined('NEXUSPHPURL') || define("NEXUSPHPURL","https://nexusphp.org");
|
||||||
|
|||||||
+10
-1
@@ -5631,9 +5631,10 @@ function format_description($description)
|
|||||||
//匹配不同块
|
//匹配不同块
|
||||||
$attachPattern = '\[attach\].*\[\/attach\]';
|
$attachPattern = '\[attach\].*\[\/attach\]';
|
||||||
$imgPattern = '\[img\].*\[\/img\]';
|
$imgPattern = '\[img\].*\[\/img\]';
|
||||||
|
$imgPattern2 = '\[img=.*\]';
|
||||||
$urlPattern = '\[url=.*\].*\[\/url\]';
|
$urlPattern = '\[url=.*\].*\[\/url\]';
|
||||||
$quotePattern = '\[quote.*\].*\[\/quote\]';
|
$quotePattern = '\[quote.*\].*\[\/quote\]';
|
||||||
$pattern = "/($attachPattern)|($imgPattern)|($urlPattern)|($quotePattern)/isU";
|
$pattern = "/($attachPattern)|($imgPattern)|($imgPattern2)|($urlPattern)|($quotePattern)/isU";
|
||||||
// $pattern = "/($attachPattern)|($imgPattern)|($urlPattern)/isU";
|
// $pattern = "/($attachPattern)|($imgPattern)|($urlPattern)/isU";
|
||||||
$delimiter = '{{{}}}';
|
$delimiter = '{{{}}}';
|
||||||
$description = preg_replace_callback($pattern, function ($matches) use ($delimiter) {
|
$description = preg_replace_callback($pattern, function ($matches) use ($delimiter) {
|
||||||
@@ -5660,6 +5661,14 @@ function format_description($description)
|
|||||||
'url' => $matches[1]
|
'url' => $matches[1]
|
||||||
]
|
]
|
||||||
];
|
];
|
||||||
|
} elseif (preg_match('/\[img=(.*)\]/isU', $item, $matches)) {
|
||||||
|
//是否图片
|
||||||
|
$results[] = [
|
||||||
|
'type' => 'image',
|
||||||
|
'data' => [
|
||||||
|
'url' => $matches[1]
|
||||||
|
]
|
||||||
|
];
|
||||||
} elseif (preg_match('/\[url=(.*)\](.*)\[\/url\]/isU', $item, $matches)) {
|
} elseif (preg_match('/\[url=(.*)\](.*)\[\/url\]/isU', $item, $matches)) {
|
||||||
$results[] = [
|
$results[] = [
|
||||||
'type' => 'url',
|
'type' => 'url',
|
||||||
|
|||||||
Reference in New Issue
Block a user