Exemplo n.º 1
0
 /**
  * Renders list data
  *
  * @param Tx_PtExtlist_Domain_Model_List_ListData $listData
  * @return Tx_PtExtlist_Domain_Model_List_ListData
  */
 public function renderList(Tx_PtExtlist_Domain_Model_List_ListData $listData)
 {
     $pageStartIndex = $this->getPageStartingIndex();
     foreach ($listData as $rowIndex => $row) {
         $listData->getItemById($rowIndex)->addSpecialValue('absoluteRowIndex', $pageStartIndex + $rowIndex + 1);
     }
     return $listData;
 }
Exemplo n.º 2
0
 /**
  * This method makes existing renderer compatible to iteration list data
  *
  * @param Tx_PtExtlist_Domain_Model_List_Row $row
  * @param $rowIndex
  * @return Tx_PtExtlist_Domain_Model_List_Row
  */
 public function renderSingleRow(Tx_PtExtlist_Domain_Model_List_Row $row, $rowIndex)
 {
     $listData = new Tx_PtExtlist_Domain_Model_List_ListData();
     $listData->addRow($row, $rowIndex);
     $this->renderList($listData);
     $renderedRow = $listData->getFirstRow();
     unset($listData);
     return $renderedRow;
 }
Exemplo n.º 3
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');
 }
 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)));
 }
Exemplo n.º 5
0
 /**
  * @return integer
  */
 public function count()
 {
     if ($this->useIterationListData) {
         return $this->iterationListData->count();
     } else {
         return $this->listData->count();
     }
 }
Exemplo n.º 6
0
 /**
  * Maps raw list data with given mapper configuration.
  *
  * @param array $arrayData Raw array to be mapped
  * @return Tx_PtExtlist_Domain_Model_List_ListData Mapped list data structure
  */
 protected function mapWithConfiguration(array &$arrayData)
 {
     $listData = new Tx_PtExtlist_Domain_Model_List_ListData();
     foreach ($arrayData as $row) {
         $mappedRow = $this->mapRowWithConfiguration($this->processRowForMapping($row));
         $listData->addRow($mappedRow);
     }
     return $listData;
 }
 /**
  * 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.º 8
0
 /**
  * @return string
  */
 public function getFileName()
 {
     $parameters = array();
     if ($this->itemListData->count() > 0) {
         $item = $this->itemListData->getFirstRow()->getCell('image')->getValue();
         /** @var Tx_Yag_Domain_Model_Item $item */
         $parameters = array('album' => $item->getAlbum()->getName(), 'gallery' => $item->getAlbum()->getGallery()->getName());
     }
     $formattedFileName = Tx_PtExtlist_Utility_RenderValue::renderDataByConfigArray($parameters, $this->fileNameFormat);
     if (substr(strtolower($formattedFileName), -4, 4) != '.zip') {
         $formattedFileName .= '.zip';
     }
     $formattedFileName = $this->fileSystemDiv->cleanFileName($formattedFileName);
     return $formattedFileName;
 }
Exemplo n.º 9
0
 /**
  * Renders the given list through TypoScript.
  * Also uses the column definitions.
  *
  * @param Tx_PtExtlist_Domain_Model_List_ListData $listData
  * @return Tx_PtExtlist_Domain_Model_List_ListData
  */
 public function renderList(Tx_PtExtlist_Domain_Model_List_ListData $listData)
 {
     $itemUIds = array();
     $indexedArray = array();
     foreach ($listData as $listRow) {
         /** @var $listRow Tx_PtExtlist_Domain_Model_List_Row */
         $itemUIds[] = $listRow->getCell('itemUid')->getValue();
         $indexedArray[$listRow->getCell('itemUid')->getValue()] = $listRow;
     }
     $renderedListData = new Tx_PtExtlist_Domain_Model_List_ListData();
     if (!empty($itemUIds)) {
         $items = $this->itemRepository->getItemsByUids($itemUIds);
         foreach ($items as $item) {
             if ($item instanceof Tx_Yag_Domain_Model_Item) {
                 $itemUid = $item->getUid();
                 if (array_key_exists($itemUid, $indexedArray)) {
                     $indexedArray[$itemUid]->addCell(new Tx_PtExtlist_Domain_Model_List_Cell($item), 'image');
                 }
                 $renderedListData->addItem($indexedArray[$itemUid]);
             }
         }
     }
     return $renderedListData;
 }
Exemplo n.º 10
0
 /**
  * Returns a rendered aggregate list for a given row of aggregates
  *
  * @param Tx_PtExtlist_Domain_Model_List_ListData $aggregateListData
  * @return Tx_PtExtlist_Domain_Model_List_ListData Rendererd List of aggregate rows
  */
 public function renderAggregateList(Tx_PtExtlist_Domain_Model_List_ListData $aggregateListData)
 {
     if ($aggregateListData->count() == 0) {
         return $aggregateListData;
     }
     $renderedAggregateList = new Tx_PtExtlist_Domain_Model_List_ListData();
     $aggregateRowsConfiguration = $this->rendererConfiguration->getConfigurationBuilder()->buildAggregateRowsConfig();
     $aggregateDataRow = $aggregateListData->getItemByIndex(0);
     foreach ($aggregateRowsConfiguration as $aggregateRowIndex => $aggregateRowConfiguration) {
         $renderedAggregateList->addRow($this->rowRenderer->renderAggregateRow($aggregateDataRow, $aggregateRowConfiguration, $aggregateRowIndex));
     }
     return $renderedAggregateList;
 }
Exemplo n.º 11
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.º 12
0
 /**
  * Populates the listData the old way ..
  *
  * @param Tx_PtExtlist_Domain_Model_List_ListData $listData
  */
 protected function populateListDataByObjects(Tx_PtExtlist_Domain_Model_List_ListData $listData)
 {
     foreach ($this->testData['rows'] as $testRow) {
         $listData->addRow($this->createRowFromTestData($testRow));
     }
 }
Exemplo n.º 13
0
 /**
  * Build the aggregate list
  * @return Tx_PtExtlist_Domain_Model_List_ListData
  */
 public function buildAggregateListData()
 {
     $aggreagteListData = new Tx_PtExtlist_Domain_Model_List_ListData();
     $aggreagteListData->addRow($this->buildAggregateDataRow());
     return $aggreagteListData;
 }