示例#1
0
 /**
  * @param \TYPO3\CMS\Core\Resource\File $file
  * @return $this
  */
 public function applyDefaultCategories(File $file)
 {
     $categoryList = ConfigurationUtility::getInstance()->get('default_categories');
     $categories = GeneralUtility::trimExplode(',', $categoryList, TRUE);
     foreach ($categories as $category) {
         $values = array('uid_local' => $category, 'uid_foreign' => $this->getFileMetadataIdentifier($file), 'tablenames' => 'sys_file_metadata', 'fieldname' => 'categories');
         $this->getDatabaseConnection()->exec_INSERTquery('sys_category_record_mm', $values);
     }
     $metaData['categories'] = count($categories);
     $file->_updateMetaDataProperties($metaData);
     $this->getMetaDataRepository()->update($file->getUid(), $metaData);
     $this->getFileIndexRepository()->updateIndexingTime($file->getUid());
     return $this;
 }
示例#2
0
 /**
  * Set the current preset value. Preset values come from the settings and can be:
  * image_thumbnail, image_mini, image_small, image_medium, image_large
  *
  * @throws \Fab\Media\Exception\EmptyValueException
  * @param string $preset image_thumbnail, image_mini, ...
  * @return \Fab\Media\Utility\ImagePresetUtility
  */
 public function preset($preset)
 {
     $size = ConfigurationUtility::getInstance()->get($preset);
     if (is_null($size)) {
         throw new \Fab\Media\Exception\EmptyValueException('No value for preset: ' . $preset, 1362501066);
     }
     $this->currentPreset = $preset;
     if (!isset($this->store[$this->currentPreset])) {
         // @todo use object Dimension instead
         $dimensions = GeneralUtility::trimExplode('x', $size);
         $this->store[$this->currentPreset]['width'] = empty($dimensions[0]) ? 0 : $dimensions[0];
         $this->store[$this->currentPreset]['height'] = empty($dimensions[1]) ? 0 : $dimensions[1];
     }
     return $this;
 }
示例#3
0
 /**
  * @test
  */
 public function setConfigurationValueAndCheckReturnedValueIsCorresponding()
 {
     $expected = 'bar';
     $this->fixture->set('foo', $expected);
     $this->assertSame($expected, $this->fixture->get('foo'));
 }
示例#4
0
 /**
  * @test
  */
 public function setOriginalImageAsPresetWithRandomValueAndCheckWidthAndHeightCorrespondsToThisRandomValue()
 {
     $preset = 'image_large';
     $actualWidth = rand(10, 100);
     $actualHeight = rand(10, 100);
     \Fab\Media\Utility\ConfigurationUtility::getInstance()->set('image_large', $actualWidth . 'x' . $actualHeight);
     $this->assertSame($actualWidth, $this->fixture->preset($preset)->getWidth());
     $this->assertSame($actualHeight, $this->fixture->preset($preset)->getHeight());
 }