/**
  * @dataProvider getTestElementsWhiteAndBlackListsAndExpectedList
  * @test
  * @param array $items
  * @param string $whitelist
  * @param string $blacklist
  * @param array $expectedList
  */
 public function processesWizardItems($items, $whitelist, $blacklist, $expectedList)
 {
     $objectManager = GeneralUtility::makeInstance('TYPO3\\CMS\\Extbase\\Object\\ObjectManager');
     /** @var WizardItemsHookSubscriber $instance */
     $instance = $objectManager->get('FluidTYPO3\\Fluidcontent\\Hooks\\WizardItemsHookSubscriber');
     $emulatedPageAndContentRecord = array('uid' => 1, 'tx_flux_column' => 'name');
     $controller = new NewContentElementController();
     $controller->colPos = 0;
     $controller->uid_pid = -1;
     $grid = new Grid();
     $row = new Row();
     $column = new Column();
     $column->setColumnPosition(0);
     $column->setName('name');
     $column->setVariable('Fluidcontent', array('allowedContentTypes' => $whitelist, 'deniedContentTypes' => $blacklist));
     $row->add($column);
     $grid->add($row);
     /** @var Provider $provider1 */
     $provider1 = $objectManager->get('FluidTYPO3\\Flux\\Provider\\Provider');
     $provider1->setTemplatePaths(array());
     $provider1->setTemplateVariables(array());
     $provider1->setGrid($grid);
     $provider2 = $this->getMock('FluidTYPO3\\Flux\\Provider\\Provider', array('getGrid'));
     $provider2->expects($this->exactly(1))->method('getGrid')->will($this->returnValue(NULL));
     /** @var ConfigurationService|\PHPUnit_Framework_MockObject_MockObject $configurationService */
     $configurationService = $this->getMock('FluidTYPO3\\Fluidcontent\\Service\\ConfigurationService', array('resolveConfigurationProviders', 'writeCachedConfigurationIfMissing'));
     $configurationService->expects($this->exactly(1))->method('resolveConfigurationProviders')->will($this->returnValue(array($provider1, $provider2)));
     /** @var WorkspacesAwareRecordService|\PHPUnit_Framework_MockObject_MockObject $recordService */
     $recordService = $this->getMock('FluidTYPO3\\Flux\\Service\\WorkspacesAwareRecordService', array('getSingle'));
     $recordService->expects($this->exactly(2))->method('getSingle')->will($this->returnValue($emulatedPageAndContentRecord));
     $instance->injectConfigurationService($configurationService);
     $instance->injectRecordService($recordService);
     $instance->manipulateWizardItems($items, $controller);
     $this->assertEquals($expectedList, $items);
 }
示例#2
0
 /**
  * @test
  */
 public function testDrawRecordDrawsEachRecord()
 {
     $column = new Form\Container\Column();
     $column->setLabel('test');
     $record = array();
     $instance = $this->getMock($this->createInstanceClassName(), array('getRecords', 'drawRecord', 'registerTargetContentAreaInSession', 'drawNewIcon', 'getInitializedPageLayoutView'));
     $instance->expects($this->once())->method('getRecords')->willReturn(array(array('foo' => 'bar'), array('bar' => 'foo')));
     $instance->expects($this->exactly(2))->method('drawRecord');
     $instance->expects($this->once())->method('getInitializedPageLayoutView')->willReturn(new PageLayoutView());
     $instance->expects($this->once())->method('drawNewIcon');
     $instance->expects($this->once())->method('registerTargetContentAreaInSession');
     $result = $this->callInaccessibleMethod($instance, 'drawGridColumn', $record, $column);
     $this->assertNotEmpty($result);
 }
 /**
  * @dataProvider getTestElementsWhiteAndBlackListsAndExpectedList
  * @test
  * @param array $items
  * @param string $whitelist
  * @param string $blacklist
  * @param array $expectedList
  */
 public function processesWizardItems($items, $whitelist, $blacklist, $expectedList)
 {
     $instance = $this->getMock('FluidTYPO3\\Flux\\Hooks\\WizardItemsHookSubscriber', array('getAreaNameAndParentFromRelativeRecordOrDefaults'));
     $instance->expects($this->once())->method('getAreaNameAndParentFromRelativeRecordOrDefaults')->willReturn(array(1, 'area'));
     $emulatedPageAndContentRecord = array('uid' => 1, 'tx_flux_column' => 'area');
     $controller = new NewContentElementController();
     $controller->colPos = 0;
     $controller->uid_pid = -1;
     $grid = new Grid();
     $row = new Row();
     $column = new Column();
     $column->setColumnPosition(0);
     $column->setName('area');
     $column->setVariable('allowedContentTypes', $whitelist);
     $column->setVariable('deniedContentTypes', $blacklist);
     $row->add($column);
     $grid->add($row);
     $provider1 = $this->objectManager->get('FluidTYPO3\\Flux\\Provider\\Provider');
     $provider1->setTemplatePaths(array());
     $provider1->setTemplateVariables(array());
     $provider1->setGrid($grid);
     $provider2 = $this->getMock('FluidTYPO3\\Flux\\Provider\\Provider', array('getGrid'));
     $provider2->expects($this->exactly(2))->method('getGrid')->will($this->returnValue(NULL));
     $configurationService = $this->getMock('FluidTYPO3\\Flux\\Service\\FluxService', array('resolveConfigurationProviders'));
     $configurationService->expects($this->exactly(2))->method('resolveConfigurationProviders')->will($this->returnValue(array($provider1, $provider2)));
     $recordService = $this->getMock('FluidTYPO3\\Flux\\Service\\WorkspacesAwareRecordService', array('getSingle'));
     $recordService->expects($this->exactly(2))->method('getSingle')->will($this->returnValue($emulatedPageAndContentRecord));
     $instance->injectConfigurationService($configurationService);
     $instance->injectRecordService($recordService);
     $instance->manipulateWizardItems($items, $controller);
     $this->assertEquals($expectedList, $items);
 }
示例#4
0
 /**
  * @param array $row
  * @param Column $column
  * @param integer $colPosFluxContent
  * @param PageLayoutView $dblist
  * @param integer $target
  * @param string $id
  * @param string $content
  * @return string
  */
 protected function parseGridColumnTemplate(array $row, Column $column, $colPosFluxContent, $dblist, $target, $id, $content)
 {
     return sprintf($this->templates['gridColumn'], $column->getColspan(), $column->getRowspan(), $column->getStyle(), $colPosFluxContent, $dblist->tt_contentConfig['sys_language_uid'], $dblist->tt_contentConfig['sys_language_uid'], $column->getLabel(), $target, $id, $this->drawNewIcon($row, $column) . $this->drawPasteIcon($row, $column) . $this->drawPasteIcon($row, $column, TRUE), $content);
 }
示例#5
0
 /**
  * @param array $row
  * @param Column $column
  * @param integer $colPosFluxContent
  * @param PageLayoutView $dblist
  * @param integer $target
  * @param string $id
  * @param string $content
  * @return string
  */
 protected function parseGridColumnTemplate(array $row, Column $column, $colPosFluxContent, $dblist, $target, $id, $content)
 {
     $label = $column->getLabel();
     if (strpos($label, 'LLL:') === 0) {
         $label = LocalizationUtility::translate($label, ExtensionNamingUtility::getExtensionName($column->getExtensionName()));
         if (empty($label)) {
             $label = $column->getLabel();
         }
     }
     // this variable defines if this drop-area gets activated on drag action
     // of a ce with the same data-language_uid
     $templateClassJsSortableLanguageId = $row['sys_language_uid'];
     // this variable defines which drop-areas will be activated
     // with a drag action of this element
     $templateDataLanguageUid = $row['sys_language_uid'];
     // but for language mode all (uid -1):
     if ((int) $row['sys_language_uid'] === -1) {
         /** @var \TYPO3\CMS\Backend\Controller\PageLayoutController $pageLayoutController */
         $pageLayoutController = $GLOBALS['SOBE'];
         $isColumnView = (int) $pageLayoutController->MOD_SETTINGS['function'] === 1;
         $isLanguagesView = (int) $pageLayoutController->MOD_SETTINGS['function'] === 2;
         if ($isColumnView) {
             $templateClassJsSortableLanguageId = $pageLayoutController->current_sys_language;
             $templateDataLanguageUid = $pageLayoutController->current_sys_language;
         } elseif ($isLanguagesView) {
             // If this is a language-all (uid -1) grid-element in languages-view
             // we use language-uid 0 for this elements drop-areas.
             // This can be done because a ce with language-uid -1 in languages view
             // is in TYPO3 7.6.4 only displayed in the default-language-column (maybe a bug atm.?).
             // Additionally there is no access to the information which
             // language column is currently rendered from here!
             // ($lP in typo3/cms/typo3/sysext/backend/Classes/View/PageLayoutView.php L485)
             $templateClassJsSortableLanguageId = 0;
             $templateDataLanguageUid = 0;
         }
     }
     return sprintf($this->templates['gridColumn'], $column->getColspan(), $column->getRowspan(), $column->getStyle(), $colPosFluxContent, $templateClassJsSortableLanguageId, $templateDataLanguageUid, $label, $target, $id, $this->drawNewIcon($row, $column) . $this->drawPasteIcon($row, $column) . $this->drawPasteIcon($row, $column, TRUE), $content);
 }
示例#6
0
 /**
  * @param array $row
  * @param Column $column
  * @param boolean $reference
  * @param array $relativeTo
  * @return string
  */
 protected function drawPasteIcon(array $row, Column $column, $reference = FALSE, array $relativeTo = array())
 {
     $command = TRUE === $reference ? 'reference' : 'paste';
     $relativeUid = TRUE === isset($relativeTo['uid']) ? $relativeTo['uid'] : 0;
     $columnName = $column->getName();
     $relativeTo = $row['pid'] . '-' . $command . '-' . $relativeUid . '-' . $row['uid'] . (FALSE === empty($columnName) ? '-' . $columnName : '');
     return ClipBoardUtility::createIconWithUrl($relativeTo, $reference);
 }