/** * Implements Phata\Widgetfy\Site\Common::translate * * translate the provided URL into * HTML embed code of it * @param mixed[] $info array of preprocessed url information * @param mixed[] $options array of options * @return mixed[] array of embed information or NULL if not applicable */ public static function translate($info, $options = array()) { // fixed dimension to be 485 x 385 $d = Dimension::fromOptions($options, array('scale_model' => 'no-scale', 'default_width' => 485, 'default_height' => 385, 'dynamic' => FALSE)); // Note: NicoNico supports HTTP only. No HTTPS. return array('type' => 'javascript', 'javascript' => 'flash_embed', 'html' => '<script type="text/javascript" ' . 'src="http://ext.nicovideo.jp/thumb_watch/sm' . $info['vid'] . '"></script>', 'dimension' => $d); }
/** * Implements Phata\Widgetfy\Site\Common::translate * * translate the provided URL into * HTML embed code of it * @param mixed[] $info array of preprocessed url information * @param mixed[] $options array of options * @return mixed[] array of embed information or NULL if not applicable */ public static function translate($info, $options = array()) { // default dimension is 480 x 400 $d = Dimension::fromOptions($options, array('factor' => 0.7629, 'default_width' => 544)); $flashvars = http_build_query($info); return array('type' => 'flash_embed', 'html' => '<embed ' . $d->toAttr() . ' ' . 'quality="high" allowfullscreen="true" ' . 'type="application/x-shockwave-flash" ' . 'src="http://static.hdslb.com/miniloader.swf" ' . 'flashvars="' . $flashvars . '" ' . 'pluginspage="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash">' . '</embed>', 'dimension' => $d); }
/** * Implements Phata\Widgetfy\Site\Common::translate * * translate the provided URL into * HTML embed code of it * @param mixed[] $info array of preprocessed url information * @param mixed[] $options array of options * @return mixed[] array of embed information or NULL if not applicable */ public static function translate($info, $options = array()) { // default dimension 560 x 315 $d = Dimension::fromOptions($options, array('factor' => 0.5625, 'default_width' => 560)); // Note: Dailymotion supports HTTP only. No HTTPS. return array('type' => 'iframe', 'html' => '<iframe frameborder="0" ' . $d->toAttr() . ' ' . 'src="//www.dailymotion.com/embed/video/' . $info['id'] . '" ' . 'allowfullscreen></iframe>', 'dimension' => $d); }
/** * Implements Phata\Widgetfy\Site\Common::translate * * translate the provided URL into * HTML embed code of it * @param mixed[] $info array of preprocessed url information * @param mixed[] $options array of options * @return mixed[] array of embed information or NULL if not applicable */ public static function translate($info, $options = array()) { // default dimension is 640 x 360 $d = Dimension::fromOptions($options, array('factor' => 0.5625, 'default_width' => 640)); // Note: LiveLeak supports HTTP only. No HTTPS. return array('type' => 'iframe', 'html' => '<iframe ' . $d->toAttr() . ' ' . 'src="http://www.liveleak.com/ll_embed?f=' . $info['id'] . '" ' . 'frameborder="0" allowfullscreen></iframe>', 'dimension' => $d); }
/** * Implements Phata\Widgetfy\Site\Common::translate * * translate the provided URL into * HTML embed code of it * @param mixed[] $info array of preprocessed url information * @param mixed[] $options array of options * @return mixed[] array of embed information or NULL if not applicable */ public static function translate($info, $options = array()) { // default dimension is 480 x 400 $d = Dimension::fromOptions($options, array('factor' => 0.8332000000000001, 'default_width' => 480)); // build http query $http_query = http_build_query(array('type' => $info['tudou_type'], 'code' => $info['code'], 'lcode' => $info['lcode'], 'resourceId' => '0_06_05_99')); return array('type' => 'iframe', 'html' => '<iframe ' . $d->toAttr() . ' ' . 'src="http://www.tudou.com/programs/view/' . 'html5embed.action?' . $http_query . '" ' . 'allowtransparency="true" allowfullscreen="true" ' . 'scrolling="no" border="0" frameborder="0"></iframe>', 'dimension' => $d); }
/** * Implements Phata\Widgetfy\Site\Common::translate * * translate the provided URL into * HTML embed code of it * @param mixed[] $info array of preprocessed url information * @param mixed[] $options array of options * @return mixed[] array of embed information or NULL if not applicable */ public static function translate($info, $options = array()) { // default dimension (medium) is 640 x 480 $d = Dimension::fromOptions($options, array('factor' => 0.75, 'default_width' => 640)); // default dimension of widget is 420 x 220 $d2 = Dimension::fromOptions($options, array('scale_model' => 'no-scale', 'default_width' => 220, 'default_height' => $d->height > 420 ? $d->height : 420, 'dynamic' => FALSE)); // Note: Kickstarter supports HTTP only. No HTTPS. return array('type' => 'iframe', 'html' => '<iframe ' . $d->toAttr() . ' ' . 'src="//www.kickstarter.com/projects/' . $info['id'] . '/widget/video.html" ' . 'frameborder="0" scrolling="no"></iframe>', 'dimension' => $d, 'other' => array('type' => 'iframe', 'html' => '<iframe ' . $d2->toAttr() . ' ' . 'src="https://www.kickstarter.com/projects/' . $info['id'] . '/widget/card.html?v=2" ' . 'frameborder="0" scrolling="no"></iframe>', 'dimension' => $d2)); }
/** * Implements Phata\Widgetfy\Site\Common::translate * * translate the provided URL into * HTML embed code of it * @param mixed[] $info array of preprocessed url information * @param mixed[] $options array of options * @return mixed[] array of embed information or NULL if not applicable */ public static function translate($info, $options = array()) { // default width is 600 $d = Dimension::fromOptions($options, array('scale_model' => 'no-scale', 'default_width' => 560, 'default_height' => 560)); // build embed code with data-href if (isset($info['post_id'])) { return array('type' => 'javascript', 'javascript' => 'div', 'html' => '<blockquote class="twitter-video" lang="zh-tw"><a href="https://twitter.com/' . $info['username'] . '/status/' . $info['post_id'] . '"></a></blockquote>' . '<script async src="//platform.twitter.com/widgets.js" charset="utf-8"></script>', 'dimension' => $d); } }
/** * Implements Phata\Widgetfy\Site\Common::translate * * translate the provided URL into * HTML embed code of it * @param mixed[] $info array of preprocessed url information * @param mixed[] $options array of options * @return mixed[] array of embed information or NULL if not applicable */ public static function translate($info, $options = array()) { // default dimension is 610 x 343 $d = Dimension::fromOptions($options, array('factor' => 0.5622, 'default_width' => 610)); // Note: CollegeHumor supports HTTP only. No HTTPS. switch ($info['version']) { case 1: return array('type' => 'flash_object', 'html' => '<object type="application/x-shockwave-flash" ' . 'data="http://www.collegehumor.com/moogaloop/' . 'moogaloop.swf?clip_id=' . $info['vid'] . '&fullscreen=1" ' . $d->toAttr() . ' >' . '<param name="allowfullscreen" value="true" />' . '<param name="movie" quality="best" value="http://www.collegehumor.com/' . 'moogaloop/moogaloop.swf?clip_id=' . $info['vid'] . '&fullscreen=1" /></object>', 'dimension' => $d); case 2: return array('type' => 'iframe', 'html' => '<iframe src="http://www.collegehumor.com/e/' . $info['vid'] . '" ' . $d->toAttr() . ' ' . 'frameborder="0" webkitAllowFullScreen allowFullScreen></iframe>', 'dimension' => $d); } }
/** * Implements Phata\Widgetfy\MediaFile\Common::translate * * translate the provided URL into * HTML embed code of it * @param string[] $url_parsed result of parse_url($url) * @param mixed[] $options array of options * @return mixed[] array of embed information or NULL if not applicable */ public static function translate($info, $options = array()) { // hardcorded controls height $default_width = 400; $height_ctrl = 26; $d = Dimension::fromOptions($options, array('scale_model' => 'scale-width', 'default_width' => $default_width), 'scale-width'); // video portion $d_embed1 = Dimension::fromOptions($options, array('scale_model' => 'scale-width-height', 'default_width' => $default_width), 'scale-width'); // control portion $d_embed2 = Dimension::fromOptions($options, array('scale_model' => 'scale-width', 'default_width' => $default_width, 'default_height' => $height_ctrl), 'scale-width'); return array('html' => '<embed type="audio/x-pn-realaudio-plugin" ' . 'src="' . $info['url'] . '" ' . $d_embed1->toAttr() . ' autostart="false" ' . 'controls="imagewindow" nojava="true" ' . 'console="video" ' . 'pluginspage="https://www.real.com/"></embed><br>' . '<embed type="audio/x-pn-realaudio-plugin" ' . 'src="' . $info['url'] . '" ' . $d_embed2->toAttr() . ' autostart="false" ' . 'nojava="true" controls="ControlPanel" ' . 'console="video"></embed>', 'dimension' => $d); }
/** * Implements Phata\Widgetfy\Site\Common::translate * * translate the provided URL into * HTML embed code of it * @param mixed[] $info array of preprocessed url information * @param mixed[] $options array of options * @return mixed[] array of embed information or NULL if not applicable */ public static function translate($info, $options = array()) { // default dimension is 640 x 360 $d = Dimension::fromOptions($options); if ($info['path_type'] == 'video') { $params =& $info['params']; $query_params = array(); $query_str = ''; // calculating start time with "t" parameter if (!empty($params["t"])) { $start = self::calStartTime($params['t']); if ($start != 0) { $query_params['start'] = $start; } } // build query string if (!empty($query_params)) { $query_str = '?' . http_build_query($query_params); } // if vid exists in the link, and // the video can be embeded return array('type' => 'iframe', 'html' => '<iframe ' . $d->toAttr() . ' ' . 'src="//www.youtube.com/embed/' . $params['vid'] . $query_str . '" ' . 'frameborder="0" allowfullscreen></iframe>', 'dimension' => $d); } elseif ($info['path_type'] == 'playlist') { $args =& $info['query']; $location = $info['location']; if (isset($args['p'])) { $lid = $args['p']; $string = '//' . $location . '.youtube.com' . $info['path'] . '?p=' . $lid; } elseif (isset($args['list']) and preg_match('/^PL/', $args['list'])) { $lid = $args['list']; $string = '//' . $location . '.youtube.com' . $info['path'] . '?list=' . $args['list']; } return array('type' => 'iframe', 'html' => '<iframe ' . $d->toAttr() . ' ' . 'src="https://www.youtube.com/embed/videoseries?list=' . $lid . '" ' . 'frameborder="0" allowfullscreen></iframe>', 'dimension' => $d); } return NULL; }
/** * Implements Phata\Widgetfy\Site\Common::translate * * translate the provided URL into * HTML embed code of it * @param mixed[] $info array of preprocessed url information * @param mixed[] $options array of options * @return mixed[] array of embed information or NULL if not applicable */ public static function translate($info, $options = array()) { Cache::init(); $cache_group = 'vimeo'; $vid = $info['vid']; // try to retrieve api respond with the help of cache if (Cache::exists($cache_group, $vid)) { $cache = Cache::get($cache_group, $vid); $api_respond = $cache['value']; } else { $api_respond = file_get_contents('https://vimeo.com/api/v2/video/' . $vid . '.php'); $api_respond = unserialize($api_respond); Cache::set($cache_group, $vid, $api_respond); } if ($api_respond !== FALSE && !empty($api_respond)) { // read width, height from API $width = !empty($api_respond[0]['width']) ? $api_respond[0]['width'] : 640; $height = !empty($api_respond[0]['height']) ? $api_respond[0]['height'] : 320; // calculate the factor from API results $factor = round($height / $width, 4); // default dimension is calculated $d = Dimension::fromOptions($options, array('factor' => $factor, 'default_width' => 640)); return array('type' => 'iframe', 'html' => '<iframe src="//player.vimeo.com/video/' . $vid . '" ' . $d->toAttr() . ' ' . 'frameborder="0" webkitallowfullscreen ' . 'mozallowfullscreen allowfullscreen></iframe>', 'dimension' => $d); } return NULL; }
/** * Implements Phata\Widgetfy\MediaFile\Common::translate * * translate the provided URL into * HTML embed code of it * @param mixed[] $info array of preprocessed url information * @param mixed[] $options array of options * @return mixed[] array of embed information or NULL if not applicable */ public static function translate($info, $options = array()) { $d = Dimension::fromOptions($options, array('default_width' => 640, 'factor' => 0.75)); return array('html' => '<object id="mediaplayer" ' . $d->toAttr() . ' ' . 'classid="clsid:22d6f312-b0f6-11d0-94ab-0080c74c7e95" ' . 'standby="loading windows media player components..." ' . 'type="application/x-oleobject">' . '<param name="FileName" value="' . $info['filename'] . '" />' . '<param name="autostart" value="false" />' . '<param name="ShowControls" value="true" />' . '<param name="ShowStatusBar" value="false" />' . '<param name="ShowDisplay" value="false" />' . '<embed type="application/x-mplayer2" ' . 'src="' . $info['url'] . '" ' . 'name="mediaplayer" ' . $d->toAttr() . ' ' . 'ShowControls="1" ShowStatusBar="1" ShowDisplay="0" ' . 'autostart="0"></embed>' . '</object>', 'dimension' => $d); }
/** * Implements Phata\Widgetfy\Site\Common::translate * * translate the provided URL into * HTML embed code of it * @param mixed[] $info array of preprocessed url information * @param mixed[] $options array of options * @return mixed[] array of embed information or NULL if not applicable */ public static function translate($info, $options = array()) { // default size 510 x 498 $d = Dimension::fromOptions($options, array('factor' => 0.9764, 'default_width' => 510)); return array('type' => 'iframe', 'html' => '<iframe ' . $d->toAttr() . ' ' . 'src="http://player.youku.com/embed/' . $info['sid'] . '=" ' . 'frameborder="0" allowfullscreen></iframe>', 'dimension' => $d); }
/** * Implements Phata\Widgetfy\Site\Common::translate * * translate the provided URL into * HTML embed code of it * @param mixed[] $info array of preprocessed url information * @param mixed[] $options array of options * @return mixed[] array of embed information or NULL if not applicable */ public static function translate($info, $options = array()) { // default size (biggest) is 560 x 470 $d = Dimension::fromOptions($options, array('factor' => 0.8391999999999999, 'default_width' => 560)); return array('type' => 'iframe', 'html' => '<iframe src="http://www.56.com/iframe/' . $info['vid'] . '" ' . $d->toAttr() . ' ' . 'frameborder="0" allowfullscreen scrolling="no"></iframe>', 'dimension' => $d); }
/** * Implements Phata\Widgetfy\Site\Common::translate * * translate the provided URL into * HTML embed code of it * @param mixed[] $info array of preprocessed url information * @param mixed[] $options array of options * @return mixed[] array of embed information or NULL if not applicable */ public static function translate($info, $options = array()) { // default dimension is 600 x 338 $d = Dimension::fromOptions($options, array('factor' => 0.5633, 'default_width' => 600)); return array('type' => 'iframe', 'html' => '<iframe ' . 'src="http://www.metacafe.com/embed/' . $info['vid'] . '/" ' . $d->toAttr() . ' ' . 'allowFullScreen frameborder=0></iframe>', 'dimension' => $d); }
/** * Implements Phata\Widgetfy\Site\Common::translate * * translate the provided URL into * HTML embed code of it * @param mixed[] $info array of preprocessed url information * @param mixed[] $options array of options * @return mixed[] array of embed information or NULL if not applicable */ public static function translate($info, $options = array()) { // default size 640 x 360 $d = Dimension::fromOptions($options, array('factor' => 0.5625, 'default_width' => 640)); return array('type' => 'iframe', 'html' => '<iframe marginwidth="0" marginheight="0" ' . 'src="//vlog.xuite.net/embed/' . $info['vid'] . '?ar=0&as=0" ' . $d->toAttr() . ' ' . 'scrolling="no" frameborder="0"></iframe>', 'dimension' => $d); }
public function testFromOptionsNoScale() { $d = Dimension::fromOptions(array('width' => 600, 'height' => 400), array('scale_model' => 'no-scale', 'default_width' => 900, 'default_height' => 700)); $this->assertEquals('no-scale', $d->scale_model); $this->assertEquals(900, $d->width); $this->assertEquals(700, $d->height); $this->assertFalse($d->factor); $this->assertTrue($d->dynamic); }
/** * Implements Phata\Widgetfy\Site\Common::translate * * translate the provided URL into * HTML embed code of it * @param mixed[] $info array of preprocessed url information * @return mixed[] array of embed information or NULL if not applicable */ public static function translate($info, $options = array()) { // default dimension is 480 x 270 $d = Dimension::fromOptions($options, array('factor' => 0.5625, 'default_width' => 480)); return array('type' => 'iframe', 'html' => '<iframe src="http://widgets.ign.com/video/embed/content.html?' . 'slug=' . $info['slug'] . '" ' . 'scrolling="no" allowfullscreen="" frameborder="0" ' . $d->toAttr() . '></iframe>', 'dimension' => $d); }
/** * Implements Phata\Widgetfy\Site\Common::translate * * translate the provided URL into * HTML embed code of it * @param mixed[] $info array of preprocessed url information * @param mixed[] $options array of options * @return mixed[] array of embed information or NULL if not applicable */ public static function translate($info, $options = array()) { // default dimension is 610 x 190 $d = Dimension::fromOptions($options, array('scale_model' => 'scale-width', 'default_width' => 610, 'default_height' => 190)); return array('type' => 'iframe', 'html' => '<iframe src="//store.steampowered.com/widget/' . $info['id'] . '/" ' . $d->toAttr() . ' frameborder="0"></iframe>', 'dimension' => $d); }
/** * Implements Phata\Widgetfy\Site\Common::translate * * translate the provided URL into * HTML embed code of it * @param mixed[] $info array of preprocessed url information * @param mixed[] $options array of options * @return mixed[] array of embed information or NULL if not applicable */ public static function translate($info, $options = array()) { // default width is 600 $d = Dimension::fromOptions($options, array('scale_model' => 'scale-width', 'default_width' => 600)); // build embed code with data-href if (isset($info['data-href'])) { return array('type' => 'javascript', 'javascript' => 'div', 'html' => '<div id="fb-root"></div>' . '<script>(function(d, s, id) {' . 'var js, fjs = d.getElementsByTagName(s)[0];' . 'if (d.getElementById(id)) return;' . 'js = d.createElement(s); js.id = id;' . 'js.src = "//connect.facebook.net/zh_HK/sdk.js#xfbml=1&version=v2.3";' . 'fjs.parentNode.insertBefore(js, fjs);}(document, \'script\', \'facebook-jssdk\'));' . '</script>' . '<div class="fb-video" data-allowfullscreen="1" ' . 'data-href="' . $info['data-href'] . '" ' . 'data-width="' . $d->width . '"></div>', 'dimension' => $d); } }
/** * Implements Phata\Widgetfy\MediaFile\Common::translate * * translate the provided URL into * HTML embed code of it * @param mixed[] $info array of preprocessed url information * @param mixed[] $options array of options * @return mixed[] array of embed information or NULL if not applicable */ public static function translate($info, $options = array()) { // determine fallback message by filetype $message = ''; switch ($info['filetype']) { case 'ogg': $message = 'Sorry, your browser has the following problem(s):' . '<ul><li>It does not support playing <a href="http://www.theora.org/" target="_blank">OGG Theora</a>; or</li>' . '<li>It does not support the HTML5 <video> element.</li></ul> Please upgrade to a browser such as <a ' . 'href="http://www.getfirefox.com" target="_blank">Firefox</a>.'; break; case 'mp4': $message = 'Sorry, your browser has the following problem(s):' . '<ul><li>It does not support playing <strong>MP4 Video</strong>; or</li>' . '<li>It does not support the HTML5 <video> element.</li></ul> Please upgrade to a browser such as <a ' . 'href="http://www.google.com/chrome" target="_blank">Google Chrome</a>.'; break; case 'webm': $message = 'Sorry, your browser has the following problem(s):' . '<ul><li>It does not support playing <a href="http://www.webmproject.org/" target="_blank">WebM Video</a>; or</li>' . '<li>It does not support the HTML5 <video> element.</li></ul> Please upgrade to a browser such as <a ' . 'href="http://www.google.com/chrome" target="_blank">Google Chrome</a>.'; break; } // render output $d = Dimension::fromOptions($options, array('scale_model' => 'scale-width', 'default_width' => 640)); return array('html' => '<video ' . $d->toAttr() . ' controls="true" preload="metadata">' . '<source src="' . $info['url'] . '" type="video/' . $info['filetype'] . '" />' . $message . '</video>', 'dimension' => $d); }
/** * Implements Phata\Widgetfy\Site\Common::translate * * translate the provided URL into * HTML embed code of it * @param mixed[] $info array of preprocessed url information * @param mixed[] $options array of options * @return mixed[] array of embed information or NULL if not applicable */ public static function translate($info, $options = array()) { // default dimension is 480 x 400 $d = Dimension::fromOptions($options, array('factor' => 0.8332000000000001, 'default_width' => 480)); return array('type' => 'flash_embed', 'html' => '<embed src="//player.ku6.com/refer/' . $info['vid'] . '/v.swf" ' . $d->toAttr() . ' ' . 'allowscriptaccess="always" allowfullscreen="true" ' . 'type="application/x-shockwave-flash" flashvars="from=ku6"></embed>', 'dimension' => $d); }
/** * Implements Phata\Widgetfy\Site\Common::translate * * translate the provided URL into * HTML embed code of it * @param mixed[] $info array of preprocessed url information * @param mixed[] $options array of options * @return mixed[] array of embed information or NULL if not applicable */ public static function translate($info, $options = array()) { // default dimension 480 x 270 $d = Dimension::fromOptions($options, array('factor' => 0.5625, 'default_width' => 480)); return array('type' => 'iframe', 'html' => '<iframe ' . $d->toAttr() . ' ' . 'src="//media.myspace.com/play/video/' . $info['vname'] . '-' . $info['vid'] . '" ' . 'frameborder="0" allowtransparency="true" ' . 'webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe>', 'dimension' => $d); }
/** * Implements Phata\Widgetfy\Site\Common::translate * * translate the provided URL into * HTML embed code of it * @param mixed[] $info array of preprocessed url information * @param mixed[] $options array of options * @return mixed[] array of embed information or NULL if not applicable */ public static function translate($info, $options = array()) { // default dimension is 680 x 383 $d = Dimension::fromOptions($options, array('factor' => 0.5632, 'default_width' => 680, 'max_width' => 960)); return array('type' => 'iframe', 'html' => '<iframe src="' . $info['url'] . '" ' . 'allowtransparency="true" allowfullscreen="true" ' . 'scrolling="no" border="0" frameborder="0" ' . $d->toAttr() . ' ></iframe>', 'dimension' => $d); }
/** * Implements Phata\Widgetfy\Site\Common::translate * * translate the provided URL into * HTML embed code of it * @param mixed[] $info array of preprocessed url information * @param mixed[] $options array of options * @return mixed[] array of embed information or NULL if not applicable */ public static function translate($info, $options = array()) { // default dimension is 610 x 343 $d = Dimension::fromOptions($options, array('factor' => 0.5622, 'default_width' => 610)); return array('type' => 'iframe', 'html' => '<iframe src="//www.dorkly.com/e/' . $info['vid'] . '" ' . $d->toAttr() . ' ' . 'frameborder="0" webkitAllowFullScreen allowFullScreen></iframe>', 'dimension' => $d); }
/** * Implements Phata\Widgetfy\Site\Common::translate * * translate the provided URL into * HTML embed code of it * @param mixed[] $info array of preprocessed url information * @param mixed[] $options array of options * @return mixed[] array of embed information or NULL if not applicable */ public static function translate($info, $options = array()) { // default varies, but 640 x 360 (16:9) is usually OK $d = Dimension::fromOptions($options, array('factor' => 0.5625, 'default_width' => 640)); return array('type' => 'iframe', 'html' => '<iframe ' . $d->toAttr() . ' ' . 'src="//embed.ted.com/talks/' . $info['id'] . '.html" ' . 'frameborder="0" scrolling="no" ' . 'webkitAllowFullScreen mozallowfullscreen allowFullScreen></iframe>', 'dimension' => $d); }