AmCharts.php
9 years ago
Animatron.php
9 years ago
Animoto.php
9 years ago
AolOn.php
9 years ago
AppNet.php
9 years ago
AudioSnaps.php
9 years ago
Bambuser.php
9 years ago
BlipTV.php
9 years ago
Cacoo.php
9 years ago
Chartblocks.php
9 years ago
Chirbit.php
9 years ago
CircuitLab.php
9 years ago
Clyp.php
9 years ago
Codepoints.php
9 years ago
CollegeHumor.php
9 years ago
Coub.php
9 years ago
CrowdRanking.php
9 years ago
DailyMile.php
9 years ago
DailyMotion.php
9 years ago
Deviantart.php
9 years ago
Dipity.php
9 years ago
DotSub.php
9 years ago
Edocr.php
9 years ago
EgliseInfo.php
9 years ago
Facebook.php
9 years ago
Flickr.php
9 years ago
FunnyOrDie.php
9 years ago
GeographCI.php
9 years ago
GeographDe.php
9 years ago
GeographUk.php
9 years ago
GettyImages.php
9 years ago
Gfycat.php
9 years ago
GithubGist.php
9 years ago
Gmep.php
9 years ago
Hq23.php
9 years ago
Huffduffer.php
9 years ago
Hulu.php
9 years ago
IFTTT.php
9 years ago
IFixIt.php
9 years ago
Infogram.php
9 years ago
Instagram.php
9 years ago
Issuu.php
9 years ago
Kickstarter.php
9 years ago
LearningApps.php
9 years ago
Meetup.php
9 years ago
MixCloud.php
9 years ago
MobyPicture.php
9 years ago
NFB.php
9 years ago
Officemix.php
9 years ago
OfficialFM.php
9 years ago
Oumy.php
9 years ago
Pastery.php
9 years ago
PollDaddy.php
9 years ago
PollEveryWhere.php
9 years ago
Portfolium.php
9 years ago
Rapidengage.php
9 years ago
Rdio.php
9 years ago
ReleaseWire.php
9 years ago
RepubHub.php
9 years ago
Reverbnation.php
9 years ago
Revision3.php
9 years ago
Roomshare.php
9 years ago
Rutube.php
9 years ago
Sapo.php
9 years ago
Screenr.php
9 years ago
Scribd.php
9 years ago
ShortNote.php
9 years ago
Shoudio.php
9 years ago
Showtheway.php
9 years ago
Silk.php
9 years ago
Sketchfab.php
9 years ago
SlideShare.php
9 years ago
SoundCloud.php
9 years ago
Speakerdeck.php
9 years ago
Spotify.php
9 years ago
Sway.php
9 years ago
Ted.php
9 years ago
TheySaidSo.php
9 years ago
Twitter.php
9 years ago
Ustream.php
9 years ago
Verse.php
9 years ago
Viddler.php
9 years ago
VideoFork.php
9 years ago
VideoJug.php
9 years ago
Vimeo.php
9 years ago
Vine.php
9 years ago
WordpressTV.php
9 years ago
YFrog.php
9 years ago
Yandex.php
9 years ago
Youtube.php
9 years ago
Sketchfab.php
78 lines
| 1 | <?php |
| 2 | /** |
| 3 | * Sketchfab.php |
| 4 | * |
| 5 | * @package Providers |
| 6 | * @author Michael Pratt <pratt@hablarmierda.net> |
| 7 | * @link http://www.michael-pratt.com/ |
| 8 | * |
| 9 | * For the full copyright and license information, please view the LICENSE |
| 10 | * file that was distributed with this source code. |
| 11 | */ |
| 12 | |
| 13 | namespace Embera\Providers; |
| 14 | |
| 15 | /** |
| 16 | * The sketchfab.com Provider |
| 17 | * @link http://sketchfab.com |
| 18 | */ |
| 19 | class Sketchfab extends \Embera\Adapters\Service |
| 20 | { |
| 21 | /** inline {@inheritdoc} */ |
| 22 | protected $apiUrl = 'https://sketchfab.com/oembed'; |
| 23 | |
| 24 | /** inline {@inheritdoc} */ |
| 25 | protected function validateUrl() |
| 26 | { |
| 27 | $this->url->stripLastSlash(); |
| 28 | |
| 29 | return ( |
| 30 | preg_match('~sketchfab\.com/models/(?:[^/]+)$~i', $this->url) || |
| 31 | preg_match('~sketchfab\.com/(?:[^/]+)/folders/(?:[^/]+)$~i', $this->url) |
| 32 | ); |
| 33 | } |
| 34 | |
| 35 | /** inline {@inheritdoc} */ |
| 36 | protected function normalizeUrl() |
| 37 | { |
| 38 | $this->url->stripWWW(); |
| 39 | $this->url->convertToHttps(); |
| 40 | |
| 41 | // old urls |
| 42 | if (preg_match('~sketchfab\.com/show/([^/]+)/?$~i', $this->url, $matches)) { |
| 43 | $this->url = new \Embera\Url('https://sketchfab.com/models/' . $matches[1]); |
| 44 | } else if (preg_match('~(/embed/?)$~', $this->url)) { |
| 45 | $this->url = new \Embera\Url(preg_replace('~(/embed/?)$~', '', $this->url)); |
| 46 | } |
| 47 | } |
| 48 | |
| 49 | /** inline {@inheritdoc} */ |
| 50 | protected function modifyResponse(array $response = array()) |
| 51 | { |
| 52 | if (!empty($response['html'])) { |
| 53 | $response['html'] = preg_replace('~<p(.*)>(.*)</p>~is', '', $response['html']); |
| 54 | } |
| 55 | |
| 56 | return $response; |
| 57 | } |
| 58 | |
| 59 | /** inline {@inheritdoc} */ |
| 60 | public function fakeResponse() |
| 61 | { |
| 62 | if (preg_match('~sketchfab\.com/(?:[^/]+)/folders/([^/]+)$~i', $this->url, $m)) { |
| 63 | $url = 'https://sketchfab.com/playlists/embed?folder=' . $m['1']; |
| 64 | } else { |
| 65 | $url = str_replace('/show/', '/embed/', $this->url) . '/embed'; |
| 66 | } |
| 67 | |
| 68 | return array( |
| 69 | 'type' => 'rich', |
| 70 | 'provider_name' => 'Sketchfab', |
| 71 | 'provider_url' => 'http://sketchfab.com', |
| 72 | 'html' => '<iframe width="{width}" height="{height}" src="' . $url . '" frameborder="0" allowfullscreen mozallowfullscreen="true" webkitallowfullscreen="true" onmousewheel=""></iframe>' |
| 73 | ); |
| 74 | } |
| 75 | } |
| 76 | |
| 77 | ?> |
| 78 |