예제 #1
0
파일: Flickr.php 프로젝트: SmartCrowd/Embed
 /**
  * {@inheritdoc}
  */
 public function getHeight()
 {
     if (!parent::getCode()) {
         return 425;
     }
     return parent::getHeight();
 }
예제 #2
0
파일: Google.php 프로젝트: SmartCrowd/Embed
 /**
  * {@inheritdoc}
  */
 public function run()
 {
     if ($this->request->match('*/maps/*')) {
         $this->addProvider('google', new Api\GoogleMaps());
     }
     parent::run();
 }
예제 #3
0
 /**
  * {@inheritdoc}
  */
 public function run()
 {
     if ($this->request->getHttpCode() === 429) {
         $this->addProvider('oembed', new Providers\OEmbed());
         return;
     }
     parent::run();
 }
예제 #4
0
파일: Github.php 프로젝트: heatery/Embed
 /**
  * {@inheritdoc}
  */
 public function run()
 {
     parent::run();
     $this->api = new Bag();
     $api = $this->request->createRequest($this->request->url->getUrl() . '.json');
     if ($json = $api->getJsonContent()) {
         $this->api->set($json);
     }
 }
예제 #5
0
파일: Github.php 프로젝트: slawus/Embed
 /**
  * {@inheritdoc}
  */
 public function getCode()
 {
     if ($this->request->match('https://github.com/*/*/blob/*')) {
         $username = $this->request->getDirectoryPosition(0);
         $repo = $this->request->getDirectoryPosition(1);
         $ref = $this->request->getDirectoryPosition(3);
         $path_to_file = implode('/', $this->request->getSlicePath(4));
         switch ($this->request->getExtension()) {
             case 'geojson':
                 //https://help.github.com/articles/mapping-geojson-files-on-github/#embedding-your-map-elsewhere
                 return "<script src=\"https://embed.githubusercontent.com/view/geojson/{$username}/{$repo}/{$ref}/{$path_to_file}\"></script>";
             case 'stl':
                 //https://help.github.com/articles/3d-file-viewer/#embedding-your-model-elsewhere
                 return "<script src=\"https://embed.githubusercontent.com/view/3d/{$username}/{$repo}/{$ref}/{$path_to_file}\"></script>";
         }
     }
     return parent::getCode();
 }
예제 #6
0
파일: Wikipedia.php 프로젝트: heatery/Embed
 /**
  * {@inheritdoc}
  */
 public function getImagesUrls()
 {
     $images = parent::getImagesUrls();
     $apiImages = $this->api->get('images');
     if (isset($apiImages['query']['pages'])) {
         $page = current($apiImages['query']['pages']);
         $imgs = [];
         foreach ($page['images'] as $image) {
             switch (strrchr($image['title'], '.')) {
                 case '.png':
                 case '.jpg':
                 case '.gif':
                 case '.jpeg':
                     $imgs[] = $image['title'];
                     break;
             }
         }
         //Get image urls
         if ($imgs) {
             $url = clone $this->request->url;
             $url->setPath('/w/api.php');
             $url->setParameter('action', 'query');
             $url->setParameter('prop', 'imageinfo');
             $url->setParameter('iiprop', 'url');
             $url->setParameter('format', 'json');
             $url->setParameter('continue', '');
             $url->setParameter('titles', implode('|', $imgs));
             $json = $this->request->createRequest($url)->getJsonContent();
             if (isset($json['query']['pages'])) {
                 foreach ($json['query']['pages'] as $page) {
                     if (isset($page['imageinfo'][0]['url'])) {
                         Utils::unshiftValue($images, ['value' => $page['imageinfo'][0]['url'], 'providers' => ['api']]);
                     }
                 }
             }
         }
     }
     return $images;
 }
예제 #7
0
 /**
  * {@inheritdoc}
  */
 public function run()
 {
     $this->addProvider('soundcloud', new Api\Soundcloud());
     parent::run();
 }
예제 #8
0
파일: Archive.php 프로젝트: slawus/Embed
 /**
  * {@inheritdoc}
  */
 public function run()
 {
     $this->addProvider('archive', new Api\Archive());
     parent::run();
 }
예제 #9
0
 /**
  * {@inheritdoc}
  */
 protected function run()
 {
     $this->addProvider('wikipedia', new Api\Wikipedia());
     parent::run();
 }
예제 #10
0
파일: Archive.php 프로젝트: heatery/Embed
 /**
  * {@inheritdoc}
  */
 public function getImagesUrls()
 {
     $images = parent::getImagesUrls();
     if ($url = $this->api->get('misc', 'image')) {
         Utils::unshiftValue($images, ['value' => $this->request->url->getAbsolute($url), 'providers' => ['api']]);
     }
     if (is_array($files = $this->api->get('files'))) {
         foreach ($files as $url => $info) {
             Utils::unshiftValue($images, ['value' => $this->request->url->getAbsolute($url), 'providers' => ['api']]);
         }
     }
     return $images;
 }
예제 #11
0
파일: Facebook.php 프로젝트: slawus/Embed
 /**
  * {@inheritdoc}
  */
 public function run()
 {
     $this->addProvider('facebook', new Api\Facebook());
     parent::run();
 }
예제 #12
0
 /**
  * {@inheritdoc}
  */
 public function run()
 {
     $this->addProvider('imageshack', new Api\Imageshack());
     parent::run();
 }
예제 #13
0
 /**
  * {@inheritdoc}
  */
 public function getAuthorUrl()
 {
     return $this->api->get('user', 'permalink_url') ?: parent::getAuthorUrl();
 }
예제 #14
0
파일: Facebook.php 프로젝트: heatery/Embed
 /**
  * {@inheritdoc}
  */
 public function getImagesUrls()
 {
     $images = parent::getImagesUrls();
     if (($cover = $this->api->get('cover')) && !empty($cover['source'])) {
         Utils::unshiftValue($images, ['value' => $cover['source'], 'providers' => ['api']]);
     }
     if ($id = $this->api->get('id')) {
         Utils::unshiftValue($images, ['value' => 'https://graph.facebook.com/' . $id . '/picture', 'providers' => ['api']]);
     }
     return $images;
 }