Пример #1
0
 /**
  * Return built HTML.
  *
  * @access	public
  * @return	mixed	String HTML to output or false on error.
  */
 public function getHtml()
 {
     if ($this->getVideoID() === false || $this->getWidth() === false || $this->getHeight() === false) {
         return false;
     }
     $html = false;
     if (array_key_exists('embed', $this->service)) {
         //Embed can be generated locally instead of calling out to the service to get it.
         $data = array($this->service['embed'], $this->getVideoID(), $this->getWidth(), $this->getHeight());
         if ($this->getExtraIds() !== false) {
             $data = array_merge($data, $this->getExtraIds());
         }
         $html = call_user_func_array('sprintf', $data);
     } elseif (array_key_exists('oembed', $this->service)) {
         //Call out to the service to get the embed HTML.
         if ($this->service['https_enabled']) {
             if (stristr($this->getVideoID(), 'https:') !== false) {
                 $protocol = 'https:';
             } else {
                 $protocol = 'http:';
             }
         }
         $url = sprintf($this->service['oembed'], $this->getVideoID(), $this->getWidth(), $this->getHeight(), $protocol);
         $oEmbed = OEmbed::newFromRequest($url);
         if ($oEmbed !== false) {
             $html = $oEmbed->getHtml();
         }
     }
     return $html;
 }
Пример #2
0
 /**
  * Return built HTML.
  *
  * @access	public
  * @return	mixed	String HTML to output or false on error.
  */
 public function getHtml()
 {
     if ($this->getVideoID() === false || $this->getWidth() === false || $this->getHeight() === false) {
         return false;
     }
     $html = false;
     if (isset($this->service['embed'])) {
         // Embed can be generated locally instead of calling out to the service to get it.
         $data = [$this->service['embed'], htmlentities($this->getVideoID(), ENT_QUOTES), $this->getWidth(), $this->getHeight()];
         if ($this->getExtraIds() !== false) {
             foreach ($this->getExtraIds() as $extraId) {
                 $data[] = htmlentities($extraId, ENT_QUOTES);
             }
         }
         $urlArgs = $this->getUrlArgs();
         if ($urlArgs !== false) {
             $data[] = $urlArgs;
         }
         $html = call_user_func_array('sprintf', $data);
     } elseif (isset($this->service['oembed'])) {
         // Call out to the service to get the embed HTML.
         if ($this->service['https_enabled']) {
             if (stristr($this->getVideoID(), 'https:') !== false) {
                 $protocol = 'https:';
             } else {
                 $protocol = 'http:';
             }
         }
         $url = sprintf($this->service['oembed'], $this->getVideoID(), $this->getWidth(), $this->getHeight(), $protocol);
         $oEmbed = OEmbed::newFromRequest($url);
         if ($oEmbed !== false) {
             $html = $oEmbed->getHtml();
         }
     }
     return $html;
 }