Back to PhocacartRenderFront class

Method displayVideo

public static
displayVideo
(mixed $url, mixed $view = 0, mixed $ywidth = 0, mixed $yheight = 0)

Method displayVideo - Source code

public static function displayVideo($url, $view = 0, $ywidth = 0, $yheight = 0)
{
    $o = '';
    $app = Factory::getApplication();
    $paramsC = PhocacartUtils::getComponentParameters();
    $width = $paramsC->get('video_width', 0);
    $height = $paramsC->get('video_height', 0);
    if ($url != '' && PhocacartUtils::isURLAddress($url)) {
        $ssl = strpos($url, 'https');
        $yLink = 'http://www.youtube.com/v/';
        if ($ssl != false) {
            $yLink = 'https://www.youtube.com/v/';
        }
        $shortUrl = 'http://youtu.be/';
        $shortUrl2 = 'https://youtu.be/';
        $pos = strpos($url, $shortUrl);
        $pos2 = strpos($url, $shortUrl2);
        if ($pos !== false) {
            $code = str_replace($shortUrl, '', $url);
        } else {
            if ($pos2 !== false) {
                $code = str_replace($shortUrl2, '', $url);
            } else {
                $codeArray = explode('=', $url);
                $code = str_replace($codeArray[0] . '=', '', $url);
            }
        }
        if ((int) $ywidth > 0) {
            $width = (int) $ywidth;
        }
        if ((int) $yheight > 0) {
            $height = (int) $yheight;
        }
        $attr = '';
        if ((int) $width > 0) {
            $attr .= ' width="' . (int) $width . '"';
        }
        if ((int) $height > 0) {
            $attr .= ' height="' . (int) $height . '"';
        }
        $o .= '<div class="ph-video-container">';
        $o .= '<iframe ' . $attr . ' src="https://www.youtube.com/embed/' . $code . '"></iframe>';
        $o .= '</div>';
        /*$o .= '<object height="'.(int)$height.'" width="'.(int)$width.'" data="http://www.youtube.com/v/'.$code.'" type="application/x-shockwave-flash">'
          .'<param name="movie" value="http://www.youtube.com/v/'.$code.'" />'
          .'<param name="allowFullScreen" value="true" />'
          .'<param name="allowscriptaccess" value="always" />'
          .'<embed src="'.$yLink.$code.'" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" height="'.(int)$height.'" width="'.(int)$width.'" /></object>';*/
    }
    return $o;
}