本文整理汇总了PHP中bbcode::BBvideo_pass方法的典型用法代码示例。如果您正苦于以下问题:PHP bbcode::BBvideo_pass方法的具体用法?PHP bbcode::BBvideo_pass怎么用?PHP bbcode::BBvideo_pass使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类bbcode
的用法示例。
在下文中一共展示了bbcode::BBvideo_pass方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: url_to_bbvideo
/**
* Transform posted URLs from video sites into BBvideo embedded code
* Not used in default installation. Part of add-on “Auto Embed Video From URLs”
* Called only from hook_bbvideo.php when optionally installed
*
* @param string $text string to transform
* @return string $text string with embed codes if applicable
* @version 3.0.13
*/
function url_to_bbvideo($text)
{
// Check to see if we have any links to process
if (strpos($text, '<a ') === false) {
return $text;
}
global $bbcode;
// if no BBCodes are on page, load them up
if (empty($bbcode)) {
$bbcode = new bbcode();
$bbcode->bbcode_cache_init();
}
// get array of all BBvideos
static $abbcode_video_ary = array();
if (empty($abbcode_video_ary)) {
$abbcode_video_ary = abbcode::video_init();
}
// Get all magic urls in the post text
preg_match_all('#<!-- [lmw] --><a class="[^"]*" href="([^"]*)"[^>]*>.*?<\\/a><!-- [lmw] -->#i', $text, $matches, PREG_SET_ORDER);
foreach ($matches as $links) {
$link = $links[0];
$url = $links[1];
// Check for valid BBvideo sites
foreach ($abbcode_video_ary as $video_name => $video_data) {
if (isset($video_data['match']) && preg_match($video_data['match'], $url)) {
$video_links[] = $link;
$embed_codes[] = $bbcode->BBvideo_pass($url, null, null);
break;
}
}
}
// Replace video links with embed codes
if (isset($video_links) && isset($embed_codes)) {
$text = str_replace($video_links, $embed_codes, $text);
}
return $text;
}