Пример #1
0
 /**
  * @covers media_subdef::rotate
  */
 public function testRotate()
 {
     $width_before = self::$objectPresent->get_width();
     $height_before = self::$objectPresent->get_height();
     self::$objectPresent->rotate(90, self::$DI['app']['media-alchemyst'], self::$DI['app']['mediavorus']);
     $this->assertEquals($width_before, self::$objectPresent->get_height());
     $this->assertEquals($height_before, self::$objectPresent->get_width());
 }
Пример #2
0
 /**
  * Php raw implementation of thumbnails.html.twig macro
  * @param \media_subdef $subdef
  * @return array
  */
 private function getDimensions(\media_subdef $subdef)
 {
     $outWidth = $subdef->get_width();
     $outHeight = $subdef->get_height() | $outWidth;
     $thumbnail_height = $subdef->get_height() > 0 ? $subdef->get_height() : 120;
     $thumbnail_width = $subdef->get_width() > 0 ? $subdef->get_width() : 120;
     $subdefRatio = 0;
     $thumbnailRatio = $thumbnail_width / $thumbnail_height;
     if ($outWidth > 0 && $outHeight > 0) {
         $subdefRatio = $outWidth / $outHeight;
     }
     if ($thumbnailRatio > $subdefRatio) {
         if ($outWidth > $thumbnail_width) {
             $outWidth = $thumbnail_width;
         }
         $outHeight = $outWidth / $thumbnail_width * $thumbnail_height;
         $top = ($outHeight - $outHeight) / 2;
     } else {
         if ($outHeight > $thumbnail_height) {
             $outHeight = $thumbnail_height;
         }
         $outWidth = $outHeight * $thumbnail_width / $thumbnail_height;
         $top = ($outHeight - $outHeight) / 2;
     }
     return ['width' => round($outWidth), 'height' => round($outHeight), 'top' => $top];
 }
Пример #3
0
 private function listEmbeddableMedia(Request $request, \record_adapter $record, \media_subdef $media)
 {
     if (!$media->is_physically_present()) {
         return null;
     }
     if ($this->getAuthenticator()->isAuthenticated()) {
         $acl = $this->getAclForUser();
         if ($media->get_name() !== 'document' && false === $acl->has_access_to_subdef($record, $media->get_name())) {
             return null;
         }
         if ($media->get_name() === 'document' && !$acl->has_right_on_base($record->getBaseId(), 'candwnldhd') && !$acl->has_hd_grant($record)) {
             return null;
         }
     }
     if ($media->get_permalink() instanceof \media_Permalink_Adapter) {
         $permalink = $this->listPermalink($media->get_permalink());
     } else {
         $permalink = null;
     }
     $urlTTL = (int) $request->get('subdef_url_ttl', $this->getConf()->get(['registry', 'general', 'default-subdef-url-ttl']));
     if ($urlTTL < 0) {
         $urlTTL = -1;
     }
     $issuer = $this->getAuthenticatedUser();
     return ['name' => $media->get_name(), 'permalink' => $permalink, 'height' => $media->get_height(), 'width' => $media->get_width(), 'filesize' => $media->get_size(), 'devices' => $media->getDevices(), 'player_type' => $media->get_type(), 'mime_type' => $media->get_mime(), 'substituted' => $media->is_substituted(), 'created_on' => $media->get_creation_date()->format(DATE_ATOM), 'updated_on' => $media->get_modification_date()->format(DATE_ATOM), 'url' => $this->generateSubDefinitionUrl($issuer, $media, $urlTTL), 'url_ttl' => $urlTTL];
 }
Пример #4
0
 /**
  * @retrieve detailled informations about one suddef
  *
  * @param  media_subdef $media
  *
  * @return array
  */
 private function list_embedable_media(Application $app, \record_adapter $record, \media_subdef $media)
 {
     if (!$media->is_physically_present()) {
         return null;
     }
     if ($app['authentication']->isAuthenticated()) {
         if ($media->get_name() !== 'document' && false === $app['acl']->get($app['authentication']->getUser())->has_access_to_subdef($record, $media->get_name())) {
             return null;
         }
         if ($media->get_name() === 'document' && !$app['acl']->get($app['authentication']->getUser())->has_right_on_base($record->get_base_id(), 'candwnldhd') && !$app['acl']->get($app['authentication']->getUser())->has_hd_grant($record)) {
             return null;
         }
     }
     if ($media->get_permalink() instanceof \media_Permalink_Adapter) {
         $permalink = $this->list_permalink($media->get_permalink());
     } else {
         $permalink = null;
     }
     return ['name' => $media->get_name(), 'permalink' => $permalink, 'height' => $media->get_height(), 'width' => $media->get_width(), 'filesize' => $media->get_size(), 'devices' => $media->getDevices(), 'player_type' => $media->get_type(), 'mime_type' => $media->get_mime()];
 }
Пример #5
0
 /**
  * @retrieve detailled informations about one suddef
  *
  * @param  media_subdef $media
  * @return array
  */
 protected function list_embedable_media(media_subdef $media)
 {
     if (!$media->is_physically_present()) {
         return null;
     }
     if ($media->get_permalink() instanceof media_Permalink_Adapter) {
         $permalink = $this->list_permalink($media->get_permalink());
     } else {
         $permalink = null;
     }
     return ['name' => $media->get_name(), 'permalink' => $permalink, 'height' => $media->get_height(), 'width' => $media->get_width(), 'filesize' => $media->get_size(), 'devices' => $media->getDevices(), 'player_type' => $media->get_type(), 'mime_type' => $media->get_mime()];
 }