Пример #1
0
 /**
  * @test
  */
 public function thumbnailHeightMightExceedImageHeightIfAllowUpScalingIsTrue()
 {
     $this->mockTagBuilder->expects($this->once())->method('render');
     $this->mockTagBuilder->expects($this->once())->method('addAttributes')->with(array('width' => null, 'height' => 456, 'src' => null));
     $this->mockImage->expects($this->once())->method('getThumbnail')->with(100, 456, 'inset')->will($this->returnValue($this->mockThumbnail));
     $this->viewHelper->render($this->mockImage, NULL, 456, FALSE, TRUE);
 }
Пример #2
0
 /**
  * @test
  */
 public function aspectRatioReturnedCorrectlyForPortraitImage()
 {
     $this->image->_set('width', 320);
     $this->image->_set('height', 480);
     $this->assertEquals(1.5, $this->image->getAspectRatio());
     $this->assertEquals(1.5, $this->image->getAspectRatio(FALSE));
     $this->assertEquals(0.6667, round($this->image->getAspectRatio(TRUE), 4));
 }
Пример #3
0
 /**
  * Make sure all object references are cloned.
  *
  */
 public function postClone()
 {
     // Images / resources
     if (is_object($this->bannerImage)) {
         // Clone does not work for this kind of reference.
         // Manual copy mode engaged.
         $this->bannerImage = $this->bannerImage->copy();
     }
     // Tags.
     $tempTags = new ArrayCollection();
     foreach ($this->tags as $tag) {
         $tempTags->add($tag);
     }
     $this->tags = $tempTags;
     // Knowledge Prerequisites.
     $tempKnowledgePrerequisites = new ArrayCollection();
     foreach ($this->knowledgePrerequisites as $knowledgePrerequisite) {
         $newKnowledgePrerequisite = clone $knowledgePrerequisite;
         $newKnowledgePrerequisite->setQuiz($this);
         $tempKnowledgePrerequisites->add($knowledgePrerequisite);
     }
     $this->knowledgePrerequisites = $tempKnowledgePrerequisites;
     $tempExercises = new ArrayCollection();
     foreach ($this->exercises as $exercise) {
         $newExercise = clone $exercise;
         $newExercise->postClone();
         $newExercise->setQuiz($this);
         $tempExercises->add($newExercise);
     }
     $this->exercises = $tempExercises;
     $tempSubjects = new ArrayCollection();
     foreach ($this->subjects as $subject) {
         $tempSubjects->add($subject);
     }
     $this->subjects = $tempSubjects;
     $tempLevels = new ArrayCollection();
     foreach ($this->levels as $level) {
         $tempLevels->add($level);
     }
     $this->levels = $tempLevels;
 }
Пример #4
0
 /**
  * @param \_OurBrand_\Quiz\Media\Domain\Model\ImageResource $image
  * @param array $processingInstructions
  * @return \_OurBrand_\Quiz\Media\Domain\Model\ImageResource
  */
 public function transformImage(\_OurBrand_\Quiz\Domain\Model\ImageResource $image, array $processingInstructions)
 {
     if (is_a($image->getOriginalResource(), '\\TYPO3\\Flow\\Resource\\Resource')) {
         $uniqueHash = sha1($image->getOriginalResource()->getResourcePointer()->getHash() . '|' . serialize($processingInstructions));
         if (!file_exists('resource://' . $uniqueHash)) {
             $imagine = $this->objectManager->get('Imagine\\Image\\ImagineInterface');
             $imagineImage = $imagine->open('resource://' . $image->getOriginalResource()->getResourcePointer()->getHash());
             $imagineImage = $this->applyProcessingInstructions($imagineImage, $processingInstructions);
             file_put_contents('resource://' . $uniqueHash, $imagineImage->get($image->getFileExtension(), array('quality' => 90)));
         }
         $resource = new \TYPO3\Flow\Resource\Resource();
         $resource->setFilename($image->getOriginalResource()->getFilename());
         $resource->setResourcePointer(new \TYPO3\Flow\Resource\ResourcePointer($uniqueHash));
         return $resource;
     }
 }
 /**
  * Implementation of clone magic method.
  */
 public function postClone()
 {
     if (!is_null($this->image)) {
         $this->image = $this->image->copy();
     }
 }
Пример #6
0
 /**
  * @return \_OurBrand_\Quiz\Domain\Model\ImageResource
  */
 public function copy()
 {
     $newImage = new ImageResource();
     if (is_object($this->getOriginalResource())) {
         $resource = new \TYPO3\Flow\Resource\Resource();
         $resource->setFilename($this->getOriginalResource()->getFilename());
         $resource->setResourcePointer($this->getOriginalResource()->getResourcePointer());
         $newImage->setOriginalResource($resource);
     }
     return $newImage;
 }
Пример #7
0
 /**
  * Implementation of custom clone method since
  * native php __clone raises error in Flow.
  * Override in exercises which have additional references to objects.
  */
 public function postClone()
 {
     if (is_object($this->image)) {
         $this->image = $this->image->copy();
     }
     if (is_object($this->pdfFile)) {
         $this->pdfFile = $this->pdfFile->copy();
     }
     if (is_object($this->soundFile)) {
         $this->soundFile = $this->soundFile->copy();
     }
 }
 /**
  * Reset image object
  *
  * @param \_OurBrand_\Quiz\Domain\Model\ImageResource $image
  */
 public function deleteAction($image)
 {
     $image->setOriginalResource(null);
     $image->setTitle('');
     $image->setCopyright('');
     $image->setAlt('');
     $image->setType('');
     $image->setHeight(0);
     $image->setWidth(0);
     $this->imageResourceRepository->update($image);
     if (!$this->request->hasArgument('ajax')) {
         $this->redirect('new', null, null, array('image' => $image));
     }
     return '1';
 }