Initial commit
This commit is contained in:
commit
65e0da7e11
1397 changed files with 596542 additions and 0 deletions
12
site/OFF_plugins/embed/core/providers/collegehumor.php
Normal file
12
site/OFF_plugins/embed/core/providers/collegehumor.php
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
<?php
|
||||
|
||||
namespace Kirby\Embed\Providers;
|
||||
|
||||
class CollegeHumor extends Provider {
|
||||
|
||||
public function code($code) {
|
||||
$this->setAutoplay();
|
||||
return $code;
|
||||
}
|
||||
|
||||
}
|
||||
21
site/OFF_plugins/embed/core/providers/meetup.php
Normal file
21
site/OFF_plugins/embed/core/providers/meetup.php
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
<?php
|
||||
|
||||
namespace Kirby\Embed\Providers;
|
||||
|
||||
class Meetup extends Provider {
|
||||
|
||||
public function code($code) {
|
||||
$code .= $this->fixStyles();
|
||||
return $code;
|
||||
}
|
||||
|
||||
|
||||
// ================================================
|
||||
// Fix styles
|
||||
// ================================================
|
||||
|
||||
protected function fixStyles() {
|
||||
return '<style>#meetup_oembed{height: auto !important; text-align: left;}</style>';
|
||||
}
|
||||
|
||||
}
|
||||
21
site/OFF_plugins/embed/core/providers/phorkie.php
Normal file
21
site/OFF_plugins/embed/core/providers/phorkie.php
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
<?php
|
||||
|
||||
namespace Kirby\Embed\Providers;
|
||||
|
||||
class phorkie extends Provider {
|
||||
|
||||
public function code($code) {
|
||||
$code .= $this->fixStyles();
|
||||
return $code;
|
||||
}
|
||||
|
||||
|
||||
// ================================================
|
||||
// Fix styles
|
||||
// ================================================
|
||||
|
||||
protected function fixStyles() {
|
||||
return '<style>.phork {text-align: left;}</style>';
|
||||
}
|
||||
|
||||
}
|
||||
79
site/OFF_plugins/embed/core/providers/provider.php
Normal file
79
site/OFF_plugins/embed/core/providers/provider.php
Normal file
|
|
@ -0,0 +1,79 @@
|
|||
<?php
|
||||
|
||||
namespace Kirby\Embed\Providers;
|
||||
|
||||
class Provider {
|
||||
|
||||
public function __construct($core, $url) {
|
||||
$this->core = $core;
|
||||
$this->url = $url;
|
||||
|
||||
$this->init();
|
||||
}
|
||||
|
||||
|
||||
// ================================================
|
||||
// Placeholder methods
|
||||
// ================================================
|
||||
|
||||
protected function init() {}
|
||||
|
||||
public function supportsLazyVideo() { return $this->core->type() === 'video'; }
|
||||
|
||||
// ================================================
|
||||
// Custom URL parameter helpers
|
||||
// ================================================
|
||||
|
||||
protected function set($paramenter) {
|
||||
if($this->{$paramenter} !== false) {
|
||||
$this->parameter($paramenter . '=' . $this->{$paramenter});
|
||||
}
|
||||
}
|
||||
|
||||
protected function get($paramenter, $pattern) {
|
||||
$this->{$paramenter} = preg_match('/' . $paramenter . '=(' . $pattern . ')/', $this->url, $result) ? $result[1] : false;
|
||||
}
|
||||
|
||||
protected function getBool($paramenter) {
|
||||
$this->get($paramenter, '[0-1]');
|
||||
}
|
||||
|
||||
protected function getNumber($paramenter, $offset = 0) {
|
||||
$this->get($paramenter, '[0-9]*');
|
||||
if($offset !== 0) {
|
||||
$this->{$paramenter} += $offset;
|
||||
}
|
||||
}
|
||||
|
||||
protected function getString($paramenter) {
|
||||
$this->get($paramenter, '[a-zA-Z]*');
|
||||
}
|
||||
|
||||
protected function getAll($paramenter) {
|
||||
$this->get($paramenter, '[a-zA-Z0-9]*');
|
||||
}
|
||||
|
||||
|
||||
// ================================================
|
||||
// Video Autoplay
|
||||
// ================================================
|
||||
|
||||
protected function setAutoplay() {
|
||||
if($this->option('lazyvideo') || $this->option('autoplay')) {
|
||||
$this->parameter(['rel=0', 'autoplay=1', 'auto=1']);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ================================================
|
||||
// General helpers
|
||||
// ================================================
|
||||
|
||||
protected function option($option) {
|
||||
return $this->core->options[$option];
|
||||
}
|
||||
|
||||
protected function parameter($parameter) {
|
||||
return $this->core->url->parameter($parameter);
|
||||
}
|
||||
}
|
||||
42
site/OFF_plugins/embed/core/providers/slideshare.php
Normal file
42
site/OFF_plugins/embed/core/providers/slideshare.php
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
<?php
|
||||
|
||||
namespace Kirby\Embed\Providers;
|
||||
|
||||
class Slideshare extends Provider {
|
||||
|
||||
protected function init() {
|
||||
$this->getNumber('width');
|
||||
$this->getNumber('height');
|
||||
}
|
||||
|
||||
public function code($code) {
|
||||
$code = $this->setSizes($code);
|
||||
return $code;
|
||||
}
|
||||
|
||||
|
||||
// ================================================
|
||||
// Parameters for Panel Field Cheatsheet
|
||||
// ================================================
|
||||
|
||||
public function urlParameters() {
|
||||
return [
|
||||
['width', 'Set the width of the embed (e.g. 600)'],
|
||||
['height', 'Set the height of the embed (e.g. 80)'],
|
||||
];
|
||||
}
|
||||
|
||||
// ================================================
|
||||
// Sizes
|
||||
// ================================================
|
||||
|
||||
protected function setSizes($code) {
|
||||
if($this->width !== false) {
|
||||
$code = str_ireplace('<iframe', '<iframe width="' . $this->width . '"', $code);
|
||||
}
|
||||
if($this->height !== false) {
|
||||
$code = str_ireplace('<iframe', '<iframe height="' . $this->height . '"', $code);
|
||||
}
|
||||
return $code;
|
||||
}
|
||||
}
|
||||
48
site/OFF_plugins/embed/core/providers/spotify.php
Normal file
48
site/OFF_plugins/embed/core/providers/spotify.php
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
<?php
|
||||
|
||||
namespace Kirby\Embed\Providers;
|
||||
|
||||
class Spotify extends Provider {
|
||||
|
||||
protected function init() {
|
||||
$this->getString('theme');
|
||||
$this->getString('view');
|
||||
$this->getNumber('width');
|
||||
$this->getNumber('height');
|
||||
}
|
||||
|
||||
public function code($code) {
|
||||
$this->set('theme');
|
||||
$this->set('view');
|
||||
$code = $this->setSizes($code);
|
||||
return $code;
|
||||
}
|
||||
|
||||
|
||||
// ================================================
|
||||
// Parameters for Panel Field Cheatsheet
|
||||
// ================================================
|
||||
|
||||
public function urlParameters() {
|
||||
return [
|
||||
['view', 'Set the view style (list/coverart)'],
|
||||
['theme', 'Set the theme (white/black)'],
|
||||
['width', 'Set the width of the embed (e.g. 600)'],
|
||||
['height', 'Set the height of the embed (e.g. 80)'],
|
||||
];
|
||||
}
|
||||
|
||||
// ================================================
|
||||
// Sizes
|
||||
// ================================================
|
||||
|
||||
protected function setSizes($code) {
|
||||
if($this->width !== false) {
|
||||
$code = str_ireplace('<iframe', '<iframe width="' . $this->width . '"', $code);
|
||||
}
|
||||
if($this->height !== false) {
|
||||
$code = str_ireplace('<iframe', '<iframe height="' . $this->height . '"', $code);
|
||||
}
|
||||
return $code;
|
||||
}
|
||||
}
|
||||
9
site/OFF_plugins/embed/core/providers/ted.php
Normal file
9
site/OFF_plugins/embed/core/providers/ted.php
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
<?php
|
||||
|
||||
namespace Kirby\Embed\Providers;
|
||||
|
||||
class TED extends Provider {
|
||||
|
||||
public function supportsLazyVideo() { return false; }
|
||||
|
||||
}
|
||||
23
site/OFF_plugins/embed/core/providers/ustream.php
Normal file
23
site/OFF_plugins/embed/core/providers/ustream.php
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
<?php
|
||||
|
||||
namespace Kirby\Embed\Providers;
|
||||
|
||||
class Ustream extends Provider {
|
||||
|
||||
public function code($code) {
|
||||
$this->setAutoplay();
|
||||
return $code;
|
||||
}
|
||||
|
||||
|
||||
// ================================================
|
||||
// Autoplay
|
||||
// ================================================
|
||||
|
||||
protected function setAutoplay() {
|
||||
if($this->option('lazyvideo') || $this->option('autoplay')) {
|
||||
$this->parameter('autoplay=true');
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
53
site/OFF_plugins/embed/core/providers/vimeo.php
Normal file
53
site/OFF_plugins/embed/core/providers/vimeo.php
Normal file
|
|
@ -0,0 +1,53 @@
|
|||
<?php
|
||||
|
||||
namespace Kirby\Embed\Providers;
|
||||
|
||||
class Vimeo extends Provider {
|
||||
|
||||
protected function init() {
|
||||
$this->getBool('autopause');
|
||||
$this->getBool('badge');
|
||||
$this->getBool('byline');
|
||||
$this->getAll('color');
|
||||
$this->getBool('loop');
|
||||
$this->getBool('portrait');
|
||||
$this->getBool('title');
|
||||
}
|
||||
|
||||
public function code($code) {
|
||||
$this->setAutoplay();
|
||||
$this->set('autopause');
|
||||
$this->set('badge');
|
||||
$this->set('byline');
|
||||
$this->set('color');
|
||||
$this->set('loop');
|
||||
$this->set('portrait');
|
||||
$this->set('title');
|
||||
$this->setJsApi();
|
||||
return $code;
|
||||
}
|
||||
|
||||
public function urlParameters() {
|
||||
return [
|
||||
['autopause', 'Enables or disables pausing this video when another video is played (1/0)'],
|
||||
['badge', 'Enables or disables the badge on the video (1/0)'],
|
||||
['byline', 'Show the user’s byline on the video (1/0)'],
|
||||
['color', 'Specify the color of the video controls (e.g. 00aa00)'],
|
||||
['loop', 'Play the video again when it reaches the end (1/0)'],
|
||||
['portrait', 'Show the user’s portrait on the video (1/0)'],
|
||||
['title', 'Show the title on the video (1/0)'],
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
// ================================================
|
||||
// JS API
|
||||
// ================================================
|
||||
|
||||
protected function setJsApi() {
|
||||
if($this->option('jsapi')) {
|
||||
$this->parameter('api=1');
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
9
site/OFF_plugins/embed/core/providers/vine.php
Normal file
9
site/OFF_plugins/embed/core/providers/vine.php
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
<?php
|
||||
|
||||
namespace Kirby\Embed\Providers;
|
||||
|
||||
class Vine extends Provider {
|
||||
|
||||
public function supportsLazyVideo() { return false; }
|
||||
|
||||
}
|
||||
65
site/OFF_plugins/embed/core/providers/youtube.php
Normal file
65
site/OFF_plugins/embed/core/providers/youtube.php
Normal file
|
|
@ -0,0 +1,65 @@
|
|||
<?php
|
||||
|
||||
namespace Kirby\Embed\Providers;
|
||||
|
||||
class YouTube extends Provider {
|
||||
|
||||
protected function init() {
|
||||
$this->getAll('t');
|
||||
$this->getNumber('index');
|
||||
}
|
||||
|
||||
public function code($code) {
|
||||
$this->setAutoplay();
|
||||
$this->setTimecode();
|
||||
$this->set('index');
|
||||
$this->setJsApi();
|
||||
return $code;
|
||||
}
|
||||
|
||||
|
||||
// ================================================
|
||||
// Parameters for Panel Field Cheatsheet
|
||||
// ================================================
|
||||
|
||||
public function urlParameters() {
|
||||
return [
|
||||
['t', 'Timecode where the video should start (e.g. 1m4s)'],
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
|
||||
// ================================================
|
||||
// Timecode
|
||||
// ================================================
|
||||
|
||||
protected function setTimecode() {
|
||||
if($this->t !== false) {
|
||||
$this->parameter('start=' . $this->calculateTimecode());
|
||||
}
|
||||
}
|
||||
|
||||
protected function calculateTimecode() {
|
||||
$time = $this->disectTimecode('h') * 60 * 60;
|
||||
$time += $this->disectTimecode('m') * 60 ;
|
||||
$time += $this->disectTimecode('s');
|
||||
return $time;
|
||||
}
|
||||
|
||||
protected function disectTimecode($identifier) {
|
||||
return preg_match('/([0-9]+)' . $identifier . '/i', $this->t, $match) ? $match[0] : 0;
|
||||
}
|
||||
|
||||
|
||||
// ================================================
|
||||
// JS API
|
||||
// ================================================
|
||||
|
||||
protected function setJsApi() {
|
||||
if($this->option('jsapi')) {
|
||||
$this->parameter('enablejsapi=1');
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue