/**
  * @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);
 }
 /**
  * @return array
  */
 public function getPostProcessBackendLayoutTestValues()
 {
     $form = Form::create(array('id' => 'formId'));
     /** @var Provider|\PHPUnit_Framework_MockObject_MockObject $standardProvider */
     $standardProvider = $this->getMock('FluidTYPO3\\Flux\\Provider\\Provider', array('getControllerActionFromRecord', 'getForm'));
     $standardProvider->setTemplatePaths(array());
     $standardProvider->expects($this->any())->method('getForm')->willReturn($form);
     $actionLessProvider = clone $standardProvider;
     $exceptionProvider = clone $standardProvider;
     $emptyGridProvider = clone $standardProvider;
     $gridProvider = clone $standardProvider;
     $actionLessProvider->expects($this->any())->method('getControllerActionFromRecord')->willReturn(null);
     $exceptionProvider->expects($this->any())->method('getControllerActionFromRecord')->willThrowException(new \RuntimeException());
     /** @var Grid $grid */
     $grid = Grid::create();
     $grid->setParent($form);
     $emptyGridProvider->setGrid($grid);
     $emptyGridProvider->expects($this->any())->method('getControllerActionFromRecord')->willReturn('default');
     /** @var Grid $grid */
     $grid = Grid::create(array());
     $grid->setParent($form);
     $grid->createContainer('Row', 'row')->createContainer('Column', 'column')->setColSpan(3)->setRowSpan(3)->setColumnPosition(2);
     $gridProvider->setGrid($grid);
     $gridProvider->expects($this->any())->method('getControllerActionFromRecord')->willReturn('default');
     $gridArray = array('__config' => array('backend_layout.' => array('colCount' => 3, 'rowCount' => 1, 'rows.' => array('1.' => array('columns.' => array('1.' => array('name' => 'LLL:EXT:flux/Resources/Private/Language/locallang.xlf:flux.formId.columns.column', 'colPos' => 2, 'colspan' => 3, 'rowspan' => 3)))))), '__colPosList' => array(2), '__items' => array(array('LLL:EXT:flux/Resources/Private/Language/locallang.xlf:flux.formId.columns.column', 2, null)));
     return array(array($standardProvider, null, 'message', 0, array()), array($standardProvider, array(), 'message', 1, array()), array($actionLessProvider, array(), 'message', 1, array()), array($emptyGridProvider, array(), 'message', 1, array()), array($exceptionProvider, array(), 'debug', 1, array()), array($gridProvider, array(), 'message', 0, $gridArray));
 }
Esempio n. 3
0
 /**
  * @param Grid $grid
  * @param string $column
  * @return array
  */
 public function extractBlacklistAndWhitelistFromGridColumns(Grid $grid, $column)
 {
     $blacklist = array();
     $whitelist = array();
     foreach ($grid->getRows() as $gridRow) {
         foreach ($gridRow->getColumns() as $gridColumn) {
             $blacklistedTypes = $gridColumn->getVariable('Fluidcontent.deniedContentTypes');
             $whitelistedTypes = $gridColumn->getVariable('Fluidcontent.allowedContentTypes');
             if (!empty($blacklistedTypes)) {
                 $blacklist += GeneralUtility::trimExplode(',', $blacklistedTypes);
             }
             if (!empty($whitelistedTypes)) {
                 $whitelist += GeneralUtility::trimExplode(',', $whitelistedTypes);
             }
         }
     }
     $blacklist = array_unique($blacklist);
     $whitelist = array_unique($whitelist);
     return array($blacklist, $whitelist);
 }
Esempio n. 4
0
 /**
  * @param array $row
  * @return Grid|\FluidTYPO3\Flux\Provider\FluidTYPO3\Flux\Form\Container\Grid
  */
 public function getGrid(array $row)
 {
     $extensionKey = $this->getExtensionKey($row);
     $values = $this->getFlexFormValues($row);
     $areas = $this->recursivelyFetchAllContentAreaNames($values['structure']);
     /** @var Grid $grid */
     $grid = Grid::create();
     $grid->setExtensionName($extensionKey);
     foreach ($areas as $areaName) {
         $grid->createContainer('Row', 'row')->createContainer('Column', 'column')->createContainer('Content', $areaName)->setLabel($areaName);
     }
     return $grid;
 }
 /**
  * @test
  */
 public function canGetGridWhenItExistInStorage()
 {
     $form = Form::create();
     $grid = Form\Container\Grid::create();
     $grid->setName('test');
     $grids = array('test' => $grid);
     $instance = $this->createMockedInstanceForVariableContainerTests(array('getForm'));
     $instance->expects($this->any())->method('getForm')->will($this->returnValue($form));
     ObjectAccess::getProperty($instance, 'viewHelperVariableContainer', TRUE)->expects($this->any())->method('exists')->will($this->returnValue(TRUE));
     ObjectAccess::getProperty($instance, 'viewHelperVariableContainer', TRUE)->expects($this->any())->method('get')->will($this->returnValue($grids));
     $output = $this->callInaccessibleMethod($instance, 'getGrid', 'test');
     $this->assertSame($grid, $output);
 }
 /**
  * @return array
  */
 public function getBackendLayoutConfigurationTestValues()
 {
     $standardProvider = $this->getMock('FluidTYPO3\\Flux\\Provider\\Provider', array('getControllerActionFromRecord'));
     $standardProvider->setTemplatePaths(array());
     $actionLessProvider = clone $standardProvider;
     $exceptionProvider = clone $standardProvider;
     $emptyGridProvider = clone $standardProvider;
     $gridProvider = clone $standardProvider;
     $actionLessProvider->expects($this->any())->method('getControllerActionFromRecord')->willReturn(NULL);
     $exceptionProvider->expects($this->any())->method('getControllerActionFromRecord')->willThrowException(new \RuntimeException());
     $emptyGridProvider->setGrid(Grid::create());
     $emptyGridProvider->expects($this->any())->method('getControllerActionFromRecord')->willReturn('default');
     $grid = Grid::create(array());
     $grid->createContainer('Row', 'row')->createContainer('Column', 'column')->setColSpan(3)->setRowSpan(3)->setColumnPosition(2);
     $gridProvider->setGrid($grid);
     $gridProvider->expects($this->any())->method('getControllerActionFromRecord')->willReturn('default');
     $gridArray = array('colCount' => 3, 'rowCount' => 1, 'rows.' => array('1.' => array('columns.' => array('1.' => array('name' => 'translatedlabel', 'colPos' => 2, 'colspan' => 3, 'rowspan' => 3))), '2.' => array('columns.' => array('1.' => array('name' => 'Fluid Content Area', 'colPos' => ContentService::COLPOS_FLUXCONTENT)))));
     return array(array($standardProvider, NULL, array()), array($standardProvider, array(), array()), array($actionLessProvider, array(), array()), array($emptyGridProvider, array(), array()), array($exceptionProvider, array(), array()), array($gridProvider, array(), $gridArray));
 }
Esempio n. 7
0
 /**
  * @return array
  */
 public function getPostProcessBackendLayoutTestValues()
 {
     $standardProvider = $this->getMock('FluidTYPO3\\Flux\\Provider\\Provider', array('getControllerActionFromRecord'));
     $standardProvider->setTemplatePaths(array());
     $actionLessProvider = clone $standardProvider;
     $exceptionProvider = clone $standardProvider;
     $emptyGridProvider = clone $standardProvider;
     $gridProvider = clone $standardProvider;
     $actionLessProvider->expects($this->any())->method('getControllerActionFromRecord')->willReturn(NULL);
     $exceptionProvider->expects($this->any())->method('getControllerActionFromRecord')->willThrowException(new \RuntimeException());
     $emptyGridProvider->setGrid(Grid::create());
     $emptyGridProvider->expects($this->any())->method('getControllerActionFromRecord')->willReturn('default');
     $grid = Grid::create(array());
     $grid->createContainer('Row', 'row')->createContainer('Column', 'column')->setColSpan(3)->setRowSpan(3)->setColumnPosition(2);
     $gridProvider->setGrid($grid);
     $gridProvider->expects($this->any())->method('getControllerActionFromRecord')->willReturn('default');
     $gridArray = array('__config' => array('backend_layout.' => array('colCount' => 3, 'rowCount' => 1, 'rows.' => array('1.' => array('columns.' => array('1.' => array('name' => 'translatedlabel', 'colPos' => 2, 'colspan' => 3, 'rowspan' => 3)))))), '__colPosList' => array(2), '__items' => array(array('translatedlabel', 2, NULL)));
     return array(array($standardProvider, NULL, 'message', 0, array()), array($standardProvider, array(), 'message', 1, array()), array($actionLessProvider, array(), 'message', 1, array()), array($emptyGridProvider, array(), 'message', 1, array()), array($exceptionProvider, array(), 'debug', 1, array()), array($gridProvider, array(), 'message', 0, $gridArray));
 }
Esempio n. 8
0
 /**
  * @test
  * @dataProvider getPreviewTestOptions
  * @param array $options
  * @param string $finalAssertionMethod
  * @return void
  */
 public function rendersPreviews(array $options, $finalAssertionMethod)
 {
     $provider = $this->objectManager->get('FluidTYPO3\\Flux\\Provider\\Provider');
     $form = Form::create(array('name' => 'test', 'options' => array('preview' => $options)));
     $grid = Form\Container\Grid::create(array());
     $grid->createContainer('Row', 'row')->createContainer('Column', 'column');
     $provider->setGrid($grid);
     $provider->setForm($form);
     $provider->setTemplatePaths(array());
     $provider->setTemplatePathAndFilename($this->getAbsoluteFixtureTemplatePathAndFilename(self::FIXTURE_TEMPLATE_PREVIEW));
     $previewView = $this->getMock($this->createInstanceClassName(), array('registerTargetContentAreaInSession'));
     $previewView->expects($this->any())->method('registerTargetContentAreaInSession');
     $previewView->injectConfigurationService($this->objectManager->get('FluidTYPO3\\Flux\\Service\\FluxService'));
     $previewView->injectConfigurationManager($this->objectManager->get('TYPO3\\CMS\\Extbase\\Configuration\\ConfigurationManager'));
     $previewView->injectWorkspacesAwareRecordService($this->objectManager->get('FluidTYPO3\\Flux\\Service\\WorkspacesAwareRecordService'));
     $preview = $previewView->getPreview($provider, Records::$contentRecordIsParentAndHasChildren);
     $this->{$finalAssertionMethod}($preview);
 }
Esempio n. 9
0
 /**
  * @param array $settings
  * @return void
  */
 public function loadSettings(array $settings)
 {
     if (TRUE === isset($settings['name'])) {
         $this->setName($settings['name']);
     }
     if (TRUE === isset($settings['form'])) {
         $form = Form::create($settings['form']);
         if (TRUE === isset($settings['extensionKey'])) {
             $extensionKey = $settings['extensionKey'];
             $extensionName = ExtensionNamingUtility::getExtensionName($extensionKey);
             $form->setExtensionName($extensionName);
         }
         $settings['form'] = $form;
     }
     if (TRUE === isset($settings['grid'])) {
         $settings['grid'] = Grid::create($settings['grid']);
     }
     foreach ($settings as $name => $value) {
         $this->{$name} = $value;
     }
     $fieldName = $this->getFieldName(array());
     if (TRUE === isset($settings['listType'])) {
         $listType = $settings['listType'];
         $GLOBALS['TCA'][$this->tableName]['types']['list']['subtypes_addlist'][$listType] = $fieldName;
     }
     $GLOBALS['TCA'][$this->tableName]['columns'][$fieldName]['config']['type'] = 'flex';
 }
Esempio n. 10
0
 /**
  * @test
  */
 public function canSetGrid()
 {
     $grid = Grid::create(array('name' => 'test'));
     $record = Records::$contentRecordWithoutParentAndWithoutChildren;
     $provider = $this->getConfigurationProviderInstance();
     $provider->setGrid($grid);
     $this->assertSame($grid, $provider->getGrid($record));
 }
Esempio n. 11
0
 /**
  * @param array $row
  * @param Grid $grid
  * @param Form $form
  * @return string
  */
 protected function drawGrid(array $row, Grid $grid, Form $form)
 {
     $options = $this->getPreviewOptions($form);
     $canToggle = $this->getOptionToggle($options);
     $isCollapsed = $this->isRowCollapsed($row);
     $collapsedClass = TRUE === $canToggle && TRUE === $isCollapsed ? ' flux-grid-hidden' : '';
     $gridRows = $grid->getRows();
     $content = '';
     foreach ($gridRows as $gridRow) {
         $content .= '<tr>';
         $columns = $gridRow->getColumns();
         foreach ($columns as $column) {
             $content .= $this->drawGridColumn($row, $column);
         }
         $content .= '</tr>';
     }
     return sprintf($this->templates['grid'], $row['uid'], $collapsedClass, $content);
 }
Esempio n. 12
0
 /**
  * Reads a Grid constructed using flux:grid, returning an array of
  * defined rows and columns along with any content areas.
  *
  * Note about specific implementations:
  *
  * * EXT:fluidpages uses the Grid to render a BackendLayout on TYPO3 6.0 and above
  * * EXT:flux uses the Grid to render content areas inside content elements
  *   registered with Flux
  *
  * But your custom extension is of course allowed to use the Grid for any
  * purpose. You can even read the Grid from - for example - the currently
  * selected page template to know exactly how the BackendLayout looks.
  *
  * @param ViewContext $viewContext
  * @param string $gridName
  * @return Grid|NULL
  */
 public function getGridFromTemplateFile(ViewContext $viewContext, $gridName = 'grid')
 {
     $templatePathAndFilename = $viewContext->getTemplatePathAndFilename();
     $section = $viewContext->getSectionName();
     $grid = NULL;
     if (TRUE === file_exists($templatePathAndFilename)) {
         $exposedView = $this->getPreparedExposedTemplateView($viewContext);
         $exposedView->setTemplatePathAndFilename($templatePathAndFilename);
         $grid = $exposedView->getGrid($section, $gridName);
     }
     if (NULL === $grid) {
         $grid = Grid::create(array('name' => $gridName));
     }
     return $grid;
 }
 /**
  * @param array $record
  * @param boolean $withGrid
  * @return Provider
  */
 protected function getMockProvider(array $record, $withGrid = TRUE)
 {
     $instance = $this->getMock('FluidTYPO3\\Flux\\Provider\\Provider', array('getViewVariables', 'getGrid'));
     if (FALSE === $withGrid) {
         $instance->expects($this->any())->method('getGrid')->willReturn(NULL);
     } else {
         $grid = Grid::create();
         $grid->createContainer('Row', 'row')->createContainer('Column', 'column')->setColumnPosition(1)->setVariable('Fluidcontent', array('deniedContentTypes' => 'html', 'allowedContentTypes' => 'text'));
         $instance->expects($this->any())->method('getGrid')->willReturn($grid);
     }
     return $instance;
 }
Esempio n. 14
0
 /**
  * Reads a Grid constructed using flux:grid, returning an array of
  * defined rows and columns along with any content areas.
  *
  * Note about specific implementations:
  *
  * * EXT:fluidpages uses the Grid to render a BackendLayout on TYPO3 6.0 and above
  * * EXT:flux uses the Grid to render content areas inside content elements
  *   registered with Flux
  *
  * But your custom extension is of course allowed to use the Grid for any
  * purpose. You can even read the Grid from - for example - the currently
  * selected page template to know exactly how the BackendLayout looks.
  *
  * @param string $templatePathAndFilename
  * @param string $section
  * @param string $gridName
  * @param array $paths
  * @param string $extensionName
  * @param array $variables
  * @return Grid|NULL
  */
 public function getGridFromTemplateFile($templatePathAndFilename, $section = 'Configuration', $gridName = 'grid', array $paths = array(), $extensionName = NULL, array $variables = array())
 {
     $grid = NULL;
     if (TRUE === file_exists($templatePathAndFilename)) {
         $exposedView = $this->getPreparedExposedTemplateView($extensionName, 'Flux', $paths, $variables);
         $exposedView->setTemplatePathAndFilename($templatePathAndFilename);
         $grid = $exposedView->getGrid($section, $gridName);
     }
     if (NULL === $grid) {
         $grid = Grid::create(array('name' => $gridName));
     }
     return $grid;
 }
Esempio n. 15
0
    /**
     * @param array $row
     * @param Grid $grid
     * @param Form $form
     * @return string
     */
    protected function drawGrid(array $row, Grid $grid, Form $form)
    {
        $options = $this->getPreviewOptions($form);
        $canToggle = $this->getOptionToggle($options);
        $isCollapsed = $this->isRowCollapsed($row);
        $collapsedClass = TRUE === $canToggle && TRUE === $isCollapsed ? ' flux-grid-hidden' : '';
        $gridRows = $grid->getRows();
        $content = '';
        foreach ($gridRows as $gridRow) {
            $content .= '<tr>';
            $columns = $gridRow->getColumns();
            foreach ($columns as $column) {
                $content .= $this->drawGridColumn($row, $column);
            }
            $content .= '</tr>';
        }
        return <<<CONTENT
\t\t<table cellspacing="0" cellpadding="0" id="content-grid-{$row['uid']}" class="flux-grid{$collapsedClass}">
\t\t\t<tbody>
\t\t\t\t{$content}
\t\t\t</tbody>
\t\t</table>
CONTENT;
    }