Exemplo n.º 1
0
 /**
  * Renders SortingViewHelper
  *
  * Sets additional template variables for children of this viewhelper.
  *
  * @param Tx_PtExtlist_Domain_Model_List_Header_ListHeader $headers
  * @param Tx_PtExtlist_Domain_Model_List_Row $captions
  * @param string $headerKey
  * @param string $captionKey
  */
 public function render(Tx_PtExtlist_Domain_Model_List_Header_ListHeader $headers, Tx_PtExtlist_Domain_Model_List_Row $captions, $headerKey = 'header', $captionKey = "caption")
 {
     if ($headers === NULL || $captions === NULL) {
         return '';
     }
     $output = '';
     foreach ($headers as $header) {
         /* @var $header Tx_PtExtlist_Domain_Model_List_Header_HeaderColumn */
         if ($captions->hasItem($header->getColumnIdentifier()) && !in_array($header->getColumnIdentifier(), $this->arguments['exclude'])) {
             // Set additional variables in template vars for child elements
             $this->templateVariableContainer->add($captionKey, $captions->getItemById($header->getColumnIdentifier()));
             $this->templateVariableContainer->add('header', $header);
             $this->templateVariableContainer->add('sortable', $header->isSortable());
             $this->templateVariableContainer->add('sortingFields', $this->buildSortingFieldParams($header));
             $this->templateVariableContainer->add('sortColumnAtOnce', $header->getSortingConfig()->getColumnSorting());
             $output .= $this->renderChildren();
             $this->templateVariableContainer->remove('sortColumnAtOnce');
             $this->templateVariableContainer->remove('sortingFields');
             $this->templateVariableContainer->remove($captionKey);
             $this->templateVariableContainer->remove($headerKey);
             $this->templateVariableContainer->remove('sortable');
         }
     }
     return $output;
 }
Exemplo n.º 2
0
 /** @test */
 public function renderCellReturnsRenderedCell()
 {
     $row = new Tx_PtExtlist_Domain_Model_List_Row();
     $row->createAndAddCell('val1', 'field1');
     $row->createAndAddCell('val2', 'field2');
     $row->createAndAddCell('val3', 'field3');
     // see ConfigurationBuilderMock for column definition
     $columnConfig = new Tx_PtExtlist_Domain_Configuration_Columns_ColumnConfig($this->configurationBuilderMock, array('columnIdentifier' => 'column1', 'fieldIdentifier' => 'field1'));
     $cellContent = $this->cellRenderer->renderCell($columnConfig, $row, 0, 0);
     $this->assertEquals('val1', $cellContent->getValue());
 }
 protected function builddataBackendMock()
 {
     $this->testListData = new Tx_PtExtlist_Domain_Model_List_ListData();
     foreach ($this->testData as $data) {
         $row = new Tx_PtExtlist_Domain_Model_List_Row();
         $row->createAndAddCell($data / 10, 'field1');
         $row->createAndAddCell($data, 'field2');
         $row->createAndAddCell($data * 10, 'field3');
         $this->testListData->addRow($row);
     }
     $this->dataBackendMock = $this->getMock('Tx_PtExtlist_Domain_DataBackend_MySqlDataBackend_MySqlDataBackend', array('getListData', 'getAggregatesByConfigCollection'), array(), '', false);
     $this->dataBackendMock->expects($this->any())->method('getListData')->will($this->returnValue($this->testListData));
     $this->dataBackendMock->expects($this->any())->method('getAggregatesByConfigCollection')->will($this->returnValue(array('avgField2' => 5)));
 }
 /**
  * Returns list data structure for given domain objects.
  * Uses configuration currently set in mapper.
  *
  * @param mixed $domainObjects
  * @return Tx_PtExtlist_Domain_Model_List_ListData List data generated for given mapping configuration
  */
 public function getMappedListData($domainObjects)
 {
     Tx_PtExtbase_Assertions_Assert::isNotNull($this->fieldConfigurationCollection, array('message' => 'No mapper configuration has been set for domain object mapper! 1281635601'));
     $listData = new Tx_PtExtlist_Domain_Model_List_ListData();
     foreach ($domainObjects as $domainObject) {
         $listDataRow = new Tx_PtExtlist_Domain_Model_List_Row();
         foreach ($this->fieldConfigurationCollection as $fieldConfiguration) {
             /* @var $fieldConfiguration Tx_PtExtlist_Domain_Configuration_Data_Fields_FieldConfig */
             $property = $this->getPropertyNameByFieldConfig($fieldConfiguration);
             if ($property == '__object__') {
                 $value = $domainObject;
             } else {
                 $value = $this->getObjectPropertyValueByProperty($domainObject, $property);
             }
             $listDataRow->createAndAddCell($value, $fieldConfiguration->getIdentifier());
         }
         $listData->addRow($listDataRow);
     }
     return $listData;
 }
Exemplo n.º 5
0
 /** @test */
 public function renderListReturnsRenderedListForGivenConfiguration()
 {
     $listData = new Tx_PtExtlist_Domain_Model_List_ListData();
     $row = new Tx_PtExtlist_Domain_Model_List_Row();
     $row->createAndAddCell('val1', 'field1');
     $row->createAndAddCell('val2', 'field2');
     $row->createAndAddCell('val3', 'field3');
     $row->createAndAddCell('val4', 'field4');
     $listData->addRow($row);
     $renderedList = $this->renderer->renderList($listData);
     $this->assertTrue(is_a($renderedList, 'Tx_PtExtlist_Domain_Model_List_ListData'));
     $this->assertEquals((string) $renderedList->getItemByIndex(0)->getCell('column1'), 'val1');
     $this->assertEquals((string) $renderedList->getItemByIndex(0)->getCell('column4'), 'val4');
 }
Exemplo n.º 6
0
 /** @test */
 public function renderRowRendersRowForGivenConfiguration()
 {
     $row = new Tx_PtExtlist_Domain_Model_List_Row();
     $row->createAndAddCell('val1', 'field1');
     $row->createAndAddCell('val2', 'field2');
     $row->createAndAddCell('val3', 'field3');
     $row->createAndAddCell('val4', 'field4');
     $cellRenderer = $this->getMock('Tx_PtExtlist_Domain_Renderer_Default_CellRenderer', array(), array(), '', false);
     $cellRenderer->expects($this->any())->method('renderCell')->will($this->returnValue(new Tx_PtExtlist_Domain_Model_List_Cell('test')));
     $rowRenderer = $this->getRowRenderer();
     $rowRenderer->injectCellRenderer($cellRenderer);
     $renderedRow = $rowRenderer->renderRow($row, 1);
     foreach ($renderedRow as $cell) {
         /* @var $cell Tx_PtExtlist_Domain_Model_List_Cell */
         $this->assertEquals($cell->getValue(), 'test');
     }
 }
Exemplo n.º 7
0
 /**
  * Creates a set of fields which are available. Defined by the 'fields' TS setup.
  *
  * @param Tx_PtExtlist_Domain_Model_List_Row $row
  * @param Tx_PtExtlist_Domain_Configuration_ColumnConfigInterface $columnConfig
  * @return array
  */
 protected function createFieldSet(Tx_PtExtlist_Domain_Model_List_Row $row, Tx_PtExtlist_Domain_Configuration_ColumnConfigInterface $columnConfig)
 {
     $fieldSet = array();
     foreach ($columnConfig->getFieldIdentifier() as $fieldConfig) {
         $fieldIdentifier = (string) $fieldConfig;
         $fieldSet[$fieldIdentifier] = $row->getCell($fieldIdentifier)->getValue();
     }
     if ($columnConfig->getContainsArrayData()) {
         $fieldSet = $this->createArrayDataFieldSet($fieldSet);
     }
     return $fieldSet;
 }
Exemplo n.º 8
0
 /**
  * @test
  */
 public function getAsArray()
 {
     $row = new Tx_PtExtlist_Domain_Model_List_Row();
     $row->createAndAddCell('testContent1', 'col1');
     $row->createAndAddCell('testContent2', 'col2');
     $row->addSpecialValue('key', 'value');
     $actual = $row->getAsArray();
     $this->assertEquals($this->dataArray, $actual);
 }
Exemplo n.º 9
0
 protected function createTemplateVariableContainer()
 {
     $templateVariableContainer = new \TYPO3\CMS\Fluid\Core\ViewHelper\TemplateVariableContainer();
     $header = new Tx_PtExtlist_Domain_Model_List_Row();
     $header->createAndAddCell('header1Value', 'col1');
     $header->createAndAddCell('header2Value', 'col2');
     $header->createAndAddCell('header3Value', 'col3');
     $row = new Tx_PtExtlist_Domain_Model_List_Row();
     $row->createAndAddCell('col1Value', 'col1');
     $row->createAndAddCell('col2Value', 'col2');
     $row->createAndAddCell('col3Value', 'col3');
     $listData = new Tx_PtExtlist_Domain_Model_List_ListData();
     $listData->addRow($row);
     $templateVariableContainer->add('listCaptions', $header);
     $templateVariableContainer->add('listData', $listData);
     return $templateVariableContainer;
 }
Exemplo n.º 10
0
 /**
  * Renders an aggregate row for given aggregate row configuration and given row index
  *
  * @param Tx_PtExtlist_Domain_Model_List_Row $aggregateDataRow Row to be rendered
  * @param Tx_PtExtlist_Domain_Configuration_Aggregates_AggregateRowConfig $aggregateRowConfig Config used to render aggregate row
  * @param integer $rowIndex Index of rendered row
  * @return Tx_PtExtlist_Domain_Model_List_ListData Rendered aggregate row
  */
 public function renderAggregateRow(Tx_PtExtlist_Domain_Model_List_Row $aggregateDataRow, Tx_PtExtlist_Domain_Configuration_Aggregates_AggregateRowConfig $aggregateRowConfig, $rowIndex)
 {
     $renderedRow = new Tx_PtExtlist_Domain_Model_List_Row();
     $columnCollection = $this->getColumnCollection();
     foreach ($columnCollection as $columnIdentifier => $column) {
         /* @var $column Tx_PtExtlist_Domain_Model_List_Header_HeaderColumn */
         $columnConfiguration = $column->getColumnConfig();
         if ($columnConfiguration->isAccessable() && $column->getIsVisible()) {
             if ($aggregateRowConfig->hasItem($columnConfiguration->getColumnIdentifier())) {
                 $cell = $this->renderCell($aggregateRowConfig->getItemById($columnConfiguration->getColumnIdentifier()), $aggregateDataRow, $columnIdentifier, $rowIndex);
             } else {
                 $cell = new Tx_PtExtlist_Domain_Model_List_Cell();
             }
             $renderedRow->addCell($cell, $columnIdentifier);
         }
     }
     unset($aggregateDataRow);
     return $renderedRow;
 }
Exemplo n.º 11
0
 /**
  * @param array $rowData
  * @return Tx_PtExtlist_Domain_Model_List_Row
  */
 protected function createRowFromTestData(array $rowData)
 {
     $row = new Tx_PtExtlist_Domain_Model_List_Row();
     $row->setSpecialValues($rowData['specialValues']);
     foreach ($rowData['columns'] as $key => $testCell) {
         $cell = new Tx_PtExtlist_Domain_Model_List_Cell($testCell['value']);
         $cell->setCSSClass($testCell['cssClass']);
         $cell->setColumnIndex($testCell['columnIndex']);
         $cell->setRowIndex($testCell['rowIndex']);
         $cell->addSpecialValue('key1', $testCell['specialValues']['key1']);
         $row->addCell($cell, $key);
     }
     return $row;
 }
Exemplo n.º 12
0
 /**
  * Build the aggregate data by configuration
  * 
  * @return Tx_PtExtlist_Domain_Model_List_Row
  */
 protected function buildAggregateDataRow()
 {
     $dataRow = new Tx_PtExtlist_Domain_Model_List_Row();
     $aggregateDataConfigCollection = $this->configurationBuilder->buildAggregateDataConfig();
     $aggregatesForPage = $this->getAggregatesForPage($aggregateDataConfigCollection->extractCollectionByScope('page'));
     $aggregatesForQuery = $this->getAggregatesForQuery($aggregateDataConfigCollection->extractCollectionByScope('query'));
     \TYPO3\CMS\Core\Utility\ArrayUtility::mergeRecursiveWithOverrule($aggregatesForQuery, $aggregatesForPage);
     foreach ($aggregatesForQuery as $key => $value) {
         $dataRow->createAndAddCell($value, $key);
     }
     return $dataRow;
 }
Exemplo n.º 13
0
 /**
  * Maps a single row of a list data structure with given configuration.
  *
  * @param array $row   Row of raw list data array
  * @return Tx_PtExtlist_Domain_Model_List_Row  Mapped row
  */
 protected function mapRowWithConfiguration(array &$row)
 {
     $mappedRow = new Tx_PtExtlist_Domain_Model_List_Row();
     foreach ($this->fieldConfigurationCollection as $mapping) {
         /* @var $mapping Tx_PtExtlist_Domain_Configuration_Data_Fields_FieldConfig */
         $mappedCellValue = $this->getMappedCellValue($mapping, $row);
         $mappedRow->createAndAddCell($mappedCellValue, $mapping->getIdentifier());
     }
     unset($row);
     return $mappedRow;
 }
Exemplo n.º 14
0
 protected function buildTestDataBackend()
 {
     $this->testListData = new Tx_PtExtlist_Domain_Model_List_ListData();
     foreach ($this->testData as $data) {
         $row = new Tx_PtExtlist_Domain_Model_List_Row();
         $row->createAndAddCell($data / 10, 'field1');
         $row->createAndAddCell($data, 'field2');
         $row->createAndAddCell($data * 10, 'field3');
         $this->testListData->addRow($row);
     }
     $this->testDataBackend = $this->getMock('Tx_PtExtlist_Domain_DataBackend_MySqlDataBackend_MySqlDataBackend', array('getListData'), array(), '', FALSE);
     $this->testDataBackend->expects($this->any())->method('getListData')->will($this->returnValue($this->testListData));
 }