function media_file_image_tag(DmMedia $file, $options = array()) { $options = array_merge(array( 'width' => $file->isImage() ? 128 : 64, 'height' => $file->isImage() ? 98 : 64 ), dmString::toArray($options, true)); if ($file->isImage()) { $image = _media($file); } else { if (file_exists( dmOs::join( sfConfig::get('sf_web_dir') . '/dmCorePlugin/images/media/' . dmOs::getFileExtension($file->getFile(), false) . '.png' ) )) { $image = _media('/dmCorePlugin/images/media/' . dmOs::getFileExtension($file->getFile(), false) . '.png'); } else { $image = _media('/dmCorePlugin/images/media/unknown.png'); } } return $image->size($options['width'], $options['height']); }
function media_file_image_tag(DmMedia $file, $options = array()) { $options = array_merge(array('width' => $file->isImage() ? 128 : 64, 'height' => $file->isImage() ? 98 : 64), dmString::toArray($options, true)); if ($file->isImage()) { $image = _media($file); } else { $image = _media('/dmCorePlugin/images/media/unknown.png'); } return $image->size($options['width'], $options['height']); }
function media_file_infos(DmMedia $object) { $infos = array(__('Size') => dmOs::humanizeSize($object->get('size')), __('Type') => $object->get('mime'), __('Created at') => format_date($object->get('created_at'), 'f'), __('Updated at') => format_date($object->get('updated_at'), 'f'), __('Url') => $object->getFullWebPath()); if ($object->isImage()) { $infos = array_merge(array(__('Dimensions') => $object->getDimensions()), $infos); } return $infos; }
public static function factory(myDoctrineRecord $record, $local, $alias, $required) { /* * Check first is local column has a value * not to modify the record */ if ($record->get($local)) { $media = $record->get($alias); } else { $media = new DmMedia(); $media->set('dm_media_folder_id', $record->getDmMediaFolder()->get('id')); } $form = new self($media); $form->configureRequired($required); $form->setRecord($record); return $form; }
protected function fromMedia(DmMedia $media) { $this->source = $media; $this->type = self::MEDIA; $this->pathFromWebDir = '/' . $media->getWebPath(); $this->mime = $this->getSimpleMime($media->get('mime')); }
protected function sortRecordsCallback(DmMedia $a, DmMedia $b) { return $this->mediaPositions[$a->get('id')] > $this->mediaPositions[$b->get('id')]; }
public function hasMedia(DmMedia $media) { return dmDb::table($this->getGalleryRelClass())->createQuery('r')->where('r.dm_record_id = ?', $this->getInvoker()->get('id'))->andWhere('r.dm_media_id = ?', $media->get('id'))->exists(); }
/** * @return DmMedia the new media with $toMedia values */ public function copyTo(DmMedia $toMedia) { $toMedia->set('file', $this->get('file')); if (!copy($this->getFullPath(), $toMedia->getFullPath())) { throw new dmException(sprintf('Can not copy from %s to %s', $this->getFullPath(), $toMedia->getFullPath())); } $toMedia->fromArray(array('legend' => $this->get('legend'), 'author' => $this->get('author'), 'license' => $this->get('license'), 'mime' => $this->get('mime'), 'dimensions' => $this->get('dimensions'))); return $toMedia; }