當前位置: 首頁>>代碼示例>>PHP>>正文


PHP bbcode::BBvideo_pass方法代碼示例

本文整理匯總了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;
}
開發者ID:VSEphpbb,項目名稱:Advanced-BBCode-Box-3,代碼行數:46,代碼來源:abbcode.php


注:本文中的bbcode::BBvideo_pass方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。