Pimcore\Model\Document\Tag\Video::getVimeoCode PHP Метод

getVimeoCode() публичный Метод

public getVimeoCode ( )
    public function getVimeoCode()
    {
        if (!$this->id) {
            return $this->getEmptyCode();
        }
        $options = $this->getOptions();
        $code = "";
        $uid = "video_" . uniqid();
        // get vimeo id
        if (preg_match("@vimeo.*/([\\d]+)@i", $this->id, $matches)) {
            $vimeoId = intval($matches[1]);
        } else {
            // for object-videos
            $vimeoId = $this->id;
        }
        if (ctype_digit($vimeoId)) {
            $width = "100%";
            if (array_key_exists("width", $options)) {
                $width = $options["width"];
            }
            $height = "300";
            if (array_key_exists("height", $options)) {
                $height = $options["height"];
            }
            $valid_vimeo_prams = ["autoplay", "loop"];
            $additional_params = "";
            $clipConfig = [];
            if (is_array($options["config"]["clip"])) {
                $clipConfig = $options["config"]["clip"];
            }
            // this is to be backward compatible to <= v 1.4.7
            $configurations = $clipConfig;
            if (is_array($options["vimeo"])) {
                $configurations = array_merge($clipConfig, $options["vimeo"]);
            }
            if (!empty($configurations)) {
                foreach ($configurations as $key => $value) {
                    if (in_array($key, $valid_vimeo_prams)) {
                        if (is_bool($value)) {
                            if ($value) {
                                $additional_params .= "&" . $key . "=1";
                            } else {
                                $additional_params .= "&" . $key . "=0";
                            }
                        } else {
                            $additional_params .= "&" . $key . "=" . $value;
                        }
                    }
                }
            }
            $code .= '<div id="pimcore_video_' . $this->getName() . '" class="pimcore_tag_video">
                <iframe src="//player.vimeo.com/video/' . $vimeoId . '?title=0&amp;byline=0&amp;portrait=0' . $additional_params . '" width="' . $width . '" height="' . $height . '" frameborder="0" webkitAllowFullScreen mozallowfullscreen allowFullScreen></iframe>
            </div>';
            return $code;
        }
        // default => return the empty code
        return $this->getEmptyCode();
    }