当前位置: 首页>>代码示例>>PHP>>正文


PHP Gdn_Format::GetEmbedSize方法代码示例

本文整理汇总了PHP中Gdn_Format::GetEmbedSize方法的典型用法代码示例。如果您正苦于以下问题:PHP Gdn_Format::GetEmbedSize方法的具体用法?PHP Gdn_Format::GetEmbedSize怎么用?PHP Gdn_Format::GetEmbedSize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Gdn_Format的用法示例。


在下文中一共展示了Gdn_Format::GetEmbedSize方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: DoVideo

 function DoVideo($bbcode, $action, $name, $default, $params, $content)
 {
     list($Width, $Height) = Gdn_Format::GetEmbedSize();
     list($Type, $Code) = explode(';', $default);
     switch ($Type) {
         case 'youtube':
             return '<div class="Video P"><iframe width="' . $Width . '" height="' . $Height . '" src="http://www.youtube.com/embed/' . $Code . '" frameborder="0" allowfullscreen></iframe></div>';
         default:
             return $content;
     }
 }
开发者ID:SatiricMan,项目名称:addons,代码行数:11,代码来源:class.nbbc.plugin.php

示例2: LinksCallback

    protected static function LinksCallback($Matches)
    {
        static $Width, $Height, $InTag = 0, $InAnchor = FALSE;
        if (!isset($Width)) {
            list($Width, $Height) = Gdn_Format::GetEmbedSize();
        }
        if ($Matches === NULL) {
            $InTag = 0;
            $InAnchor = FALSE;
            return;
        }
        $InOut = $Matches[1];
        $Tag = strtolower($Matches[2]);
        //      $End = $Matches[3];
        //      $Url = $Matches[4];
        if ($InOut == '<') {
            $InTag++;
            if ($Tag == 'a') {
                $InAnchor = TRUE;
            }
        } elseif ($InOut == '</') {
            $InTag++;
            if ($Tag == 'a') {
                $InAnchor = FALSE;
            }
        } elseif ($Matches[3]) {
            $InTag--;
        }
        if (!isset($Matches[4]) || $InTag || $InAnchor) {
            return $Matches[0];
        }
        $Url = $Matches[4];
        if ((preg_match('`(?:https?|ftp)://www\\.youtube\\.com\\/watch\\?v=([^&]+)`', $Url, $Matches) || preg_match('`(?:https?)://www\\.youtu\\.be\\/([^&]+)`', $Url, $Matches)) && C('Garden.Format.YouTube')) {
            $ID = $Matches[1];
            $Result = <<<EOT
<div class="Video"><object width="{$Width}" height="{$Height}"><param name="movie" value="http://www.youtube.com/v/{$ID}&amp;hl=en_US&amp;fs=1&amp;"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/{$ID}&amp;hl=en_US&amp;fs=1&amp;" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="{$Width}" height="{$Height}"></embed></object></div>
EOT;
        } elseif (preg_match('`(?:https?|ftp)://vimeo\\.com\\/(\\d+)`', $Url, $Matches) && C('Garden.Format.Vimeo')) {
            $ID = $Matches[1];
            $Result = <<<EOT
<div class="Video"><object width="{$Width}" height="{$Height}"><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="movie" value="http://vimeo.com/moogaloop.swf?clip_id={$ID}&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=&amp;fullscreen=1" /><embed src="http://vimeo.com/moogaloop.swf?clip_id={$ID}&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=&amp;fullscreen=1" type="application/x-shockwave-flash" allowfullscreen="true" allowscriptaccess="always" width="{$Width}" height="{$Height}"></embed></object></div>
EOT;
        } else {
            $nofollow = self::$DisplayNoFollow ? ' rel="nofollow"' : '';
            // Strip punctuation off of the end of the url.
            $Punc = '';
            if (preg_match('`^(.+)([.?,;:])$`', $Url, $Matches)) {
                $Url = $Matches[1];
                $Punc = $Matches[2];
            }
            // Get human-readable text from url.
            $Text = $Url;
            if (strpos($Text, '%') !== FALSE) {
                $Text = rawurldecode($Text);
                $Text = htmlspecialchars($Text, ENT_QUOTES, C('Garden.Charset', ''));
            }
            $Result = <<<EOT
<a href="{$Url}" target="_blank"{$nofollow}>{$Text}</a>{$Punc}
EOT;
        }
        return $Result;
    }
开发者ID:seedbank,项目名称:old-repo,代码行数:62,代码来源:class.format.php

示例3: LinksCallback

    /**
     * Transform match to clickable links or to embedded equivalent.
     *
     * URLs are typically matched against, which are then translated into a
     * clickable link or transformed into their equivalent embed, if supported.
     * There is a universal config to disable automatic embedding.
     *
     * @param array $Matches Captured and grouped matches against string.
     * @return string
     */
    protected static function LinksCallback($Matches)
    {
        static $Width, $Height, $InTag = 0, $InAnchor = FALSE;
        if (!isset($Width)) {
            list($Width, $Height) = Gdn_Format::GetEmbedSize();
        }
        if ($Matches === NULL) {
            $InTag = 0;
            $InAnchor = FALSE;
            return;
        }
        $InOut = $Matches[1];
        $Tag = strtolower($Matches[2]);
        //      $End = $Matches[3];
        //      $Url = $Matches[4];
        if ($InOut == '<') {
            $InTag++;
            if ($Tag == 'a') {
                $InAnchor = TRUE;
            }
        } elseif ($InOut == '</') {
            $InTag++;
            if ($Tag == 'a') {
                $InAnchor = FALSE;
            }
        } elseif ($Matches[3]) {
            $InTag--;
        }
        if (!isset($Matches[4]) || $InTag || $InAnchor) {
            return $Matches[0];
        }
        $Url = $Matches[4];
        $YoutubeUrlMatch = 'https?://(www\\.)?youtube\\.com\\/watch\\?(.*)?v=(?P<ID>[^&#]+)([^#]*)(?P<HasTime>#t=(?P<Time>[0-9]+))?';
        $VimeoUrlMatch = 'https?://(www\\.)?vimeo\\.com/(?:channels/[a-z0-9]+/)?(\\d+)';
        $TwitterUrlMatch = 'https?://(?:www\\.)?twitter\\.com/(?:#!/)?(?:[^/]+)/status(?:es)?/([\\d]+)';
        $GithubCommitUrlMatch = 'https?://(?:www\\.)?github\\.com/([^/]+)/([^/]+)/commit/([\\w\\d]{40})';
        $VineUrlMatch = 'https?://(?:www\\.)?vine.co/v/([\\w\\d]+)';
        $InstagramUrlMatch = 'https?://(?:www\\.)?instagr(?:\\.am|am\\.com)/p/([\\w\\d]+)';
        $PintrestUrlMatch = 'https?://(?:www\\.)?pinterest.com/pin/([\\d]+)';
        $GettyUrlMatch = 'http://embed.gettyimages.com/([\\w\\d=?&;+-_]*)/([\\d]*)/([\\d]*)';
        // Youtube
        if ((preg_match("`{$YoutubeUrlMatch}`", $Url, $Matches) || preg_match('`(?:https?)://(www\\.)?youtu\\.be\\/(?P<ID>[^&#]+)(?P<HasTime>#t=(?P<Time>[0-9]+))?`', $Url, $Matches)) && C('Garden.Format.YouTube', true) && !C('Garden.Format.DisableUrlEmbeds')) {
            $ID = $Matches['ID'];
            $TimeMarker = isset($Matches['HasTime']) ? '&amp;start=' . $Matches['Time'] : '';
            $Result = '<span class="VideoWrap">';
            $Result .= '<span class="Video YouTube" id="youtube-' . $ID . '">';
            $Result .= '<span class="VideoPreview"><a href="//youtube.com/watch?v=' . $ID . '"><img src="//img.youtube.com/vi/' . $ID . '/0.jpg" width="' . $Width . '" height="' . $Height . '" border="0" /></a></span>';
            $Result .= '<span class="VideoPlayer"></span>';
            $Result .= '</span>';
            $Result .= '</span>';
            // Vimeo
        } elseif (preg_match("`{$VimeoUrlMatch}`", $Url, $Matches) && C('Garden.Format.Vimeo', true) && !C('Garden.Format.DisableUrlEmbeds')) {
            $ID = $Matches[2];
            $Result = <<<EOT
      <iframe src="//player.vimeo.com/video/{$ID}" width="{$Width}" height="{$Height}" frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe>
EOT;
            // Twitter
        } elseif (preg_match("`{$TwitterUrlMatch}`", $Url, $Matches) && C('Garden.Format.Twitter', true) && !C('Garden.Format.DisableUrlEmbeds')) {
            $Result = <<<EOT
<div class="twitter-card" data-tweeturl="{$Matches[0]}" data-tweetid="{$Matches[1]}"><a href="{$Matches[0]}" class="tweet-url" rel="nofollow" target="_blank">{$Matches[0]}</a></div>
EOT;
            // Github
            // @tim : 2013-08-22
            // Experiment on hold
            //
            //      } elseif (preg_match("`{$GithubCommitUrlMatch}`", $Url, $Matches) && C('Garden.Format.Github', true)) {
            //         $Result = <<<EOT
            //<div class="github-commit" data-commiturl="{$Matches[0]}" data-commituser="{$Matches[1]}" data-commitrepo="{$Matches[2]}" data-commithash="{$Matches[3]}"><a href="{$Matches[0]}" class="commit-url" rel="nofollow" target="_blank">{$Matches[0]}</a></div>
            //EOT;
            // Vine
        } elseif (preg_match("`{$VineUrlMatch}`i", $Url, $Matches) && C('Garden.Format.Vine', true) && !C('Garden.Format.DisableUrlEmbeds')) {
            $Result = <<<EOT
<div class="VideoWrap">
   <iframe class="vine-embed" src="//vine.co/v/{$Matches[1]}/embed/simple" width="320" height="320" frameborder="0"></iframe><script async src="//platform.vine.co/static/scripts/embed.js" charset="utf-8"></script>
</div>
EOT;
            // Instagram
        } elseif (preg_match("`{$InstagramUrlMatch}`i", $Url, $Matches) && C('Garden.Format.Instagram', true) && !C('Garden.Format.DisableUrlEmbeds')) {
            $Result = <<<EOT
<div class="VideoWrap">
   <iframe src="//instagram.com/p/{$Matches[1]}/embed/" width="412" height="510" frameborder="0" scrolling="no" allowtransparency="true"></iframe>
</div>
EOT;
            // Pintrest
        } elseif (preg_match("`({$PintrestUrlMatch})`", $Url, $Matches) && C('Garden.Format.Pintrest', true) && !C('Garden.Format.DisableUrlEmbeds')) {
            $Result = <<<EOT
<a data-pin-do="embedPin" href="//pinterest.com/pin/{$Matches[2]}/" class="pintrest-pin" rel="nofollow" target="_blank"></a>
EOT;
            // Getty
        } elseif (preg_match("`({$GettyUrlMatch})`i", $Url, $Matches) && C('Garden.Format.Getty', true) && !C('Garden.Format.DisableUrlEmbeds')) {
//.........这里部分代码省略.........
开发者ID:3marproof,项目名称:vanilla,代码行数:101,代码来源:class.format.php

示例4: LinksCallback

    protected static function LinksCallback($Matches)
    {
        static $Width, $Height, $InTag = 0, $InAnchor = FALSE;
        if (!isset($Width)) {
            list($Width, $Height) = Gdn_Format::GetEmbedSize();
        }
        if ($Matches === NULL) {
            $InTag = 0;
            $InAnchor = FALSE;
            return;
        }
        $InOut = $Matches[1];
        $Tag = strtolower($Matches[2]);
        //      $End = $Matches[3];
        //      $Url = $Matches[4];
        if ($InOut == '<') {
            $InTag++;
            if ($Tag == 'a') {
                $InAnchor = TRUE;
            }
        } elseif ($InOut == '</') {
            $InTag++;
            if ($Tag == 'a') {
                $InAnchor = FALSE;
            }
        } elseif ($Matches[3]) {
            $InTag--;
        }
        if (!isset($Matches[4]) || $InTag || $InAnchor) {
            return $Matches[0];
        }
        $Url = $Matches[4];
        if ((preg_match('`(?:https?|ftp)://(www\\.)?youtube\\.com\\/watch\\?(.*)?v=(?P<ID>[^&#]+)([^#]*)(?P<HasTime>#t=(?P<Time>[0-9]+))?`', $Url, $Matches) || preg_match('`(?:https?)://(www\\.)?youtu\\.be\\/(?P<ID>[^&#]+)(?P<HasTime>#t=(?P<Time>[0-9]+))?`', $Url, $Matches)) && C('Garden.Format.YouTube')) {
            $ID = $Matches['ID'];
            $TimeMarker = isset($Matches['HasTime']) ? '&amp;start=' . $Matches['Time'] : '';
            $Result = '<div class="VideoWrap">';
            $Result .= '<div class="Video YouTube" id="youtube-' . $ID . '">';
            $Result .= '<div class="VideoPreview"><a href="http://youtube.com/watch?v=' . $ID . '"><img src="http://img.youtube.com/vi/' . $ID . '/0.jpg" width="' . $Width . '" height="' . $Height . '" border="0" /></a></div>';
            $Result .= '<div class="VideoPlayer"></div>';
            $Result .= '</div>';
            $Result .= '</div>';
        } elseif (preg_match('`(?:https?|ftp)://(www\\.)?vimeo\\.com\\/(\\d+)`', $Url, $Matches) && C('Garden.Format.Vimeo')) {
            $ID = $Matches[2];
            $Result = <<<EOT
<div class="VideoWrap"><div class="Video Vimeo"><object width="{$Width}" height="{$Height}"><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="movie" value="http://vimeo.com/moogaloop.swf?clip_id={$ID}&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=&amp;fullscreen=1" /><embed src="http://vimeo.com/moogaloop.swf?clip_id={$ID}&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=&amp;fullscreen=1" type="application/x-shockwave-flash" allowfullscreen="true" allowscriptaccess="always" width="{$Width}" height="{$Height}"></embed></object></div></div>
EOT;
        } elseif (!self::$FormatLinks) {
            $Result = $Url;
        } else {
            // Strip punctuation off of the end of the url.
            $Punc = '';
            if (preg_match('`^(.+)([.?,;:])$`', $Url, $Matches)) {
                $Url = $Matches[1];
                $Punc = $Matches[2];
            }
            // Get human-readable text from url.
            $Text = $Url;
            if (strpos($Text, '%') !== FALSE) {
                $Text = rawurldecode($Text);
                $Text = htmlspecialchars($Text, ENT_QUOTES, C('Garden.Charset', ''));
            }
            $nofollow = self::$DisplayNoFollow ? ' rel="nofollow"' : '';
            $Result = <<<EOT
<a href="{$Url}" target="_blank"{$nofollow}>{$Text}</a>{$Punc}
EOT;
        }
        return $Result;
    }
开发者ID:robhazkes,项目名称:Garden,代码行数:68,代码来源:class.format.php


注:本文中的Gdn_Format::GetEmbedSize方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。