本文整理匯總了PHP中bbcode::bbcode_cache_init方法的典型用法代碼示例。如果您正苦於以下問題:PHP bbcode::bbcode_cache_init方法的具體用法?PHP bbcode::bbcode_cache_init怎麽用?PHP bbcode::bbcode_cache_init使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類bbcode
的用法示例。
在下文中一共展示了bbcode::bbcode_cache_init方法的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;
}