Ejemplo n.º 1
0
 public function buildForm(FormBuilderInterface $builder, array $options)
 {
     parent::buildForm($builder, $options);
     $escapingStrategy = \ModUtil::getVar('CmfcmfMediaModule', 'descriptionEscapingStrategyForCollection');
     switch ($escapingStrategy) {
         case 'raw':
             $descriptionHelp = $this->__('You may use HTML.');
             break;
         case 'text':
             $descriptionHelp = $this->__('Only plaintext allowed.');
             break;
         case 'markdown':
             $descriptionHelp = $this->__('You may use MarkDown.');
             break;
         default:
             throw new \LogicException();
     }
     /** @var CollectionEntity $theCollection */
     $theCollection = $options['data'];
     $builder->add('title', 'text', ['label' => $this->__('Title')]);
     // If enabled, breaks slug generation of children when the slug is changed.
     //if (\ModUtil::getVar('CmfcmfMediaModule', 'slugEditable')) {
     //    $builder
     //        ->add('slug', 'text', [
     //            'label' => $this->__('Slug'),
     //            'required'=> false,
     //            'attr' => [
     //                'placeholder' => $this->__('Leave empty to autogenerate')
     //            ]
     //        ])
     //    ;
     //}
     $builder->add('description', 'textarea', ['label' => $this->__('Description'), 'required' => false, 'attr' => ['help' => $descriptionHelp]])->add('defaultTemplate', 'choice', ['label' => $this->__('Template'), 'required' => false, 'placeholder' => $this->__('Default'), 'choices' => $this->templateCollection->getCollectionTemplateTitles()])->add('parent', 'entity', ['class' => 'Cmfcmf\\Module\\MediaModule\\Entity\\Collection\\CollectionEntity', 'required' => false, 'label' => $this->__('Parent'), 'query_builder' => function (EntityRepository $er) use($theCollection) {
         $qb = $er->createQueryBuilder('c');
         $qb->orderBy('c.root', 'ASC')->addOrderBy('c.lft', 'ASC')->where($qb->expr()->not($qb->expr()->eq('c.id', ':uploadCollectionId')))->setParameter('uploadCollectionId', CollectionEntity::TEMPORARY_UPLOAD_COLLECTION_ID);
         if ($theCollection->getId() != null) {
             // The collection is currently edited.
             $qb->andWhere($qb->expr()->neq('c.id', ':id'))->setParameter('id', $theCollection->getId());
         }
         return $qb;
     }, 'data' => $this->parent, 'placeholder' => $this->__('[No parent]'), 'property' => 'indentedTitle'])->add('watermark', 'entity', ['class' => 'CmfcmfMediaModule:Watermark\\AbstractWatermarkEntity', 'required' => false, 'label' => $this->__('Watermark'), 'data' => $theCollection->getId() !== null ? $theCollection->getWatermark() : (isset($this->parent) ? $this->parent->getWatermark() : null), 'placeholder' => $this->__('No watermark'), 'property' => 'title']);
 }
Ejemplo n.º 2
0
 public function buildForm(FormBuilderInterface $builder, array $options)
 {
     parent::buildForm($builder, $options);
     $escapingStrategy = \ModUtil::getVar('CmfcmfMediaModule', 'descriptionEscapingStrategyForMedia');
     switch ($escapingStrategy) {
         case 'raw':
             $descriptionHelp = $this->__('You may use HTML.');
             break;
         case 'text':
             $descriptionHelp = $this->__('Only plaintext allowed.');
             break;
         case 'markdown':
             $descriptionHelp = $this->__('You may use MarkDown.');
             break;
         default:
             throw new \LogicException();
     }
     $hiddenAttr = ['class' => 'hidden'];
     $allowTemporaryUploadCollection = $this->allowTemporaryUploadCollection;
     $collectionOptions = ['required' => true, 'label' => $this->__('Collection'), 'class' => 'CmfcmfMediaModule:Collection\\CollectionEntity', 'query_builder' => function (EntityRepository $er) use($allowTemporaryUploadCollection) {
         $qb = $er->createQueryBuilder('c');
         $qb->orderBy('c.root', 'ASC')->addOrderBy('c.lft', 'ASC');
         if (!$allowTemporaryUploadCollection) {
             $qb->where($qb->expr()->not($qb->expr()->eq('c.id', ':uploadCollectionId')))->setParameter('uploadCollectionId', CollectionEntity::TEMPORARY_UPLOAD_COLLECTION_ID);
         }
         return $qb;
     }, 'placeholder' => $this->__('Select collection'), 'property' => 'indentedTitle'];
     if ($this->parent !== null) {
         $collectionOptions['data'] = $this->parent;
     }
     $builder->add('collection', 'entity', $collectionOptions)->add('title', isset($options['hiddenFields']) && in_array('title', $options['hiddenFields']) ? 'hidden' : 'text', ['label' => $this->__('Title')])->add('description', isset($options['hiddenFields']) && in_array('description', $options['hiddenFields']) ? 'hidden' : 'textarea', ['required' => false, 'label' => $this->__('Description'), 'attr' => ['help' => $descriptionHelp]])->add('license', 'entity', ['required' => false, 'label' => $this->__('License'), 'class' => 'CmfcmfMediaModule:License\\LicenseEntity', 'preferred_choices' => function (LicenseEntity $license) {
         return !$license->isOutdated();
     }, 'query_builder' => function (EntityRepository $er) {
         return $er->createQueryBuilder('l')->orderBy('l.title', 'ASC')->where('l.enabledForUpload = 1');
         // @todo Move to the actual uploadable file types.
     }, 'placeholder' => $this->__('Unknown'), 'property' => 'title', 'attr' => isset($options['hiddenFields']) && in_array('license', $options['hiddenFields']) ? $hiddenAttr : [], 'label_attr' => isset($options['hiddenFields']) && in_array('license', $options['hiddenFields']) ? $hiddenAttr : []])->add('author', isset($options['hiddenFields']) && in_array('author', $options['hiddenFields']) ? 'hidden' : 'text', ['label' => $this->__('Author'), 'required' => false, 'empty_data' => null])->add('authorUrl', isset($options['hiddenFields']) && in_array('authorUrl', $options['hiddenFields']) ? 'hidden' : 'url', ['label' => $this->__('Author URL'), 'required' => false, 'empty_data' => null])->add('authorAvatarUrl', isset($options['hiddenFields']) && in_array('authorAvatarUrl', $options['hiddenFields']) ? 'hidden' : 'url', ['label' => $this->__('Author Avatar URL'), 'required' => false, 'empty_data' => null])->add('mediaType', 'hidden', ['mapped' => false])->add('extraData', 'hidden');
     $builder->get('extraData')->addModelTransformer(new ArrayToJsonTransformer());
 }
Ejemplo n.º 3
0
 public function buildForm(FormBuilderInterface $builder, array $options)
 {
     parent::buildForm($builder, $options);
     $builder->add('id', 'text', ['required' => true, 'disabled' => $this->isEdit, 'label' => $this->__('License ID'), 'attr' => ['help' => $this->__('You won\'t be able to change the ID after creation. It should be something like "gplv3" or similar.')]])->add('title', 'text', ['label' => $this->__('Title'), 'required' => true, 'attr' => ['help' => $this->__('The title of the license to use for displaying it.')]])->add('url', 'url', ['label' => $this->__('Url'), 'required' => false, 'attr' => ['help' => $this->__('The place where you can look up the license text.')]])->add('imageUrl', 'url', ['label' => $this->__('Image Url'), 'required' => false, 'attr' => ['help' => $this->__('Optional url of a small license icon.')]])->add('outdated', 'checkbox', ['label' => $this->__('Outdated'), 'required' => false, 'attr' => ['help' => $this->__('Marks a license as outdated to give a visual hint while uploading.')]])->add('enabledForUpload', 'checkbox', ['label' => $this->__('Allow to use for uploads'), 'required' => false, 'attr' => ['help' => $this->__('If you check this box, you will be able to upload media and license it under this license.')]])->add('enabledForWeb', 'checkbox', ['label' => $this->__('Allow to use for web embeds'), 'required' => false, 'attr' => ['help' => $this->__('If you check this box, you will be able to embed media from the web using this license.')]])->add('submit', 'submit', ['label' => $this->__('Save')]);
 }
Ejemplo n.º 4
0
 public function buildForm(FormBuilderInterface $builder, array $options)
 {
     parent::buildForm($builder, $options);
     $builder->add('title', 'text', ['attr' => ['help' => $this->__('A title for you to recognize the watermark.')]])->add('positionX', 'number', ['scale' => 0, 'attr' => ['help' => $this->__('The x position of the watermark inside the picture. Negative numbers will position it right aligned.')]])->add('positionY', 'number', ['scale' => 0, 'attr' => ['help' => $this->__('The y position of the watermark inside the picture. Negative numbers will position it bottom aligned.')]])->add('minSizeX', 'number', ['scale' => 0, 'required' => false, 'attr' => ['help' => $this->__('Smaller images will not be watermarked.')]])->add('minSizeY', 'number', ['scale' => 0, 'required' => false, 'attr' => ['help' => $this->__('Smaller images will not be watermarked.')]])->add('relativeSize', 'number', ['scale' => 0, 'required' => false, 'attr' => ['help' => $this->__('The size of the watermark in percent. If set, it will resize the watermark accordingly.')]])->add('submit', 'submit', ['label' => $this->__('Save')]);
 }