/**
  * Renders sortable column headers for the list view
  *
  * @param \Frohland\Ezqueries\Domain\Model\RecordManagement $recordManagement
  * @return string $code
  */
 public function render($recordManagement)
 {
     $columns = $recordManagement->getTable()->getSelectedColumns();
     $columnTypes = $recordManagement->getTable()->getColumnTypes();
     $orderBy = $recordManagement->getConditions()->getOrderBy();
     $order = $recordManagement->getConditions()->getOrder();
     $search = $recordManagement->getConditions()->getSearch();
     $filters = $recordManagement->getConditions()->getFilters();
     $code = '';
     $urlUtility = $this->objectManager->create('Frohland\\Ezqueries\\Utility\\URLUtility', $this->controllerContext->getUriBuilder());
     foreach ($columns as $column) {
         if ($columnTypes[$column['name']]['sortable'] == TRUE) {
             $arguments = array("orderBy" => $column['name'], "order" => 'ASC', "search" => $search, "filters" => $filters);
             $imgClass = 'tx_ezqueries_image_order';
             $class = '';
             if ($column['name'] == $orderBy) {
                 if ($order == 'ASC') {
                     $arguments = array("orderBy" => $column['name'], "order" => 'DESC', "search" => $search, "filters" => $filters);
                     $imgClass = 'tx_ezqueries_image_order tx_ezqueries_image_order_asc';
                 } else {
                     $arguments = array("orderBy" => $column['name'], "order" => 'ASC', "search" => $search, "filters" => $filters);
                     $imgClass = 'tx_ezqueries_image_order tx_ezqueries_image_order_desc';
                 }
             }
             $url = $urlUtility->createURL("list", $arguments);
             $columnValue = '<a class="tx_ezqueries_link tx_ezqueries_link_sort tx_ezqueries_list_link_sort ' . $imgClass . '" href="' . $url . '"><span class="tx_ezqueries_link_sort_text">' . $column['columnName'] . '</span></a>';
             $class = 'tx_ezqueries_list_header_sortable';
         } else {
             $columnValue = $column['columnName'];
             $class = '';
         }
         $code .= '<th class="tx_ezqueries_list_header ' . $class . ' tx_ezqueries_list_header_' . $column['cssName'] . '" nowrap="nowrap">' . $columnValue . '</th>';
     }
     return $code;
 }
Exemplo n.º 2
0
 /**
  * Renders new form elements
  *
  * @param \Frohland\Ezqueries\Domain\Model\RecordManagement $recordManagement
  * @return string $code
  */
 public function render($recordManagement)
 {
     $this->columns = $recordManagement->getTable()->getSelectedColumns();
     $this->columnTypes = $recordManagement->getTable()->getColumnTypes();
     $search = $recordManagement->getConditions()->getSearch();
     $filters = $recordManagement->getConditions()->getFilters();
     // Generate URL
     $arguments = array("search" => $search, "filters" => $filters);
     $urlUtility = $this->objectManager->create('Frohland\\Ezqueries\\Utility\\URLUtility', $this->controllerContext->getUriBuilder());
     $url = $urlUtility->createURL("create", $arguments);
     // Generate form
     $code = '<div class="tx_ezqueries_new"><form action="' . $url . '" method="post" id="tx_ezqueries_new_form" class="tx_ezqueries_form tx_ezqueries_new_form">';
     $code .= $this->generateFormElements($url);
     $code .= '</form></div>';
     return $code;
 }
Exemplo n.º 3
0
 /**
  * Renders new form elements
  *
  * @param \Frohland\Ezqueries\Domain\Model\RecordManagement $recordManagement
  * @param array $dataSource
  * @param string $foreignKey
  * @return string $code
  */
 public function render($recordManagement, $dataSource, $foreignKey)
 {
     $columns = $recordManagement->getTable()->getSelectedColumns();
     $foreignKeyRelationColumn = $recordManagement->getTable()->getForeignKeyRelationColumn();
     $records = $recordManagement->getRecords();
     // Generate URL
     $arguments = array('foreignKey' => $foreignKey);
     $urlUtility = $this->objectManager->create('Frohland\\Ezqueries\\Utility\\URLUtility', $this->controllerContext->getUriBuilder());
     $url = $urlUtility->createURL("assign", $arguments);
     // Generate form
     $code = '<form action="' . $url . '" method="post" name="tx_ezqueries_relation_form" id="tx_ezqueries_relation_form" class="tx_ezqueries_form tx_ezqueries_relation_form">';
     $code .= '<table class="tx_ezqueries_relation">';
     $code .= '<tr><td class="tx_ezqueries_relation_left_column">';
     $code .= '<div class="tx_ezqueries_relation_info_text tx_ezqueries_relation_info_text_selected_elements">' . \TYPO3\CMS\Extbase\Utility\LocalizationUtility::translate('relation_selected_elements', 'ezqueries') . '</div>';
     $code .= '</td><td class="tx_ezqueries_relation_right_column">';
     $code .= '<div class="tx_ezqueries_relation_info_text tx_ezqueries_relation_info_text_selectable_elements">' . \TYPO3\CMS\Extbase\Utility\LocalizationUtility::translate('relation_selectable_elements', 'ezqueries') . '</div>';
     $code .= '</td></tr>';
     $code .= '<tr><td class="tx_ezqueries_relation_left_column">';
     $code .= '<ul class="tx_ezqueries_relation_entries">';
     if ($records !== NULL) {
         foreach ($records as $record) {
             $recordData = $record->getData();
             $code .= '<li id="' . $recordData[$foreignKeyRelationColumn] . '" class="tx_ezqueries_relation_entry">';
             $code .= '<span class="tx_ezqueries_relation_entry_name">';
             foreach ($columns as $column => $name) {
                 $code .= $recordData[$column] . ' ';
             }
             $code .= '</span>';
             $code .= '<span class="tx_ezqueries_relation_delete_entry">X</span>';
             $code .= '</li>';
         }
     }
     $code .= '</ul>';
     $code .= '</td><td class="tx_ezqueries_relation_right_column">';
     $code .= '<div class="tx_ezqueries_select_wrapper tx_ezqueries_relation_select_wrapper">';
     $code .= '<div class="tx_ezqueries_select_filter">';
     $code .= '<input name="regexp" class="tx_ezqueries_select_filter_input" placeholder="' . \TYPO3\CMS\Extbase\Utility\LocalizationUtility::translate('select_filter_label', 'ezqueries') . '" />';
     $code .= '</div>';
     $code .= '<select name="tx_ezqueries_relation_select" class="tx_ezqueries_relation_select tx_ezqueries_select" size="10">';
     foreach ($dataSource as $sourceRecord) {
         $sourceRecordLength = count($sourceRecord);
         $code .= '<option class="tx_ezqueries_relation_option" value="' . $sourceRecord[$sourceRecordLength - 1] . '">';
         $counter = 0;
         foreach ($sourceRecord as $recordItem) {
             if ($counter < $sourceRecordLength - 1) {
                 if ($counter !== 0) {
                     $code .= ' ';
                 }
                 $code .= $recordItem;
             }
             $counter++;
         }
         $code .= '</option>';
     }
     $code .= '</select></div>';
     $code .= '<input class="tx_ezqueries_input_hidden tx_ezqueries_input_relation_data_old" type="hidden" value="';
     if ($records !== NULL) {
         foreach ($records as $record) {
             $recordData = $record->getData();
             $code .= $recordData[$foreignKeyRelationColumn] . '<->';
         }
     }
     $code .= '" name="tx_ezqueries_ezqueriesplugin[relationDataOld]" />';
     $code .= '<input class="tx_ezqueries_input_hidden tx_ezqueries_input_relation_data_new" type="hidden" value="';
     if ($records !== NULL) {
         foreach ($records as $record) {
             $recordData = $record->getData();
             $code .= $recordData[$foreignKeyRelationColumn] . '<->';
         }
     }
     $code .= '" name="tx_ezqueries_ezqueriesplugin[relationDataNew]" />';
     $code .= '</td></tr></table>';
     $code .= '<div class="tx_ezqueries_form_row tx_ezqueries_form_row_submit"><input class="tx_ezqueries_submit tx_ezqueries_submit_relation" name="' . $url . '" type="submit" value="' . \TYPO3\CMS\Extbase\Utility\LocalizationUtility::translate('relation_form_submit', 'ezqueries') . '" /></div>';
     $code .= '</form>';
     return $code;
 }
Exemplo n.º 4
0
 /**
  * Initialize the Template utility object
  *
  * @param string $templateType Type of the template (e.g. list, edit, detail)
  * @param \Frohland\Ezqueries\Domain\Model\RecordManagement $recordManagement
  * @param UriBuilder $uriBuilder UriBuilder
  */
 public function initTemplateUtility($templateType, $recordManagement, $uriBuilder)
 {
     $this->recordManagement = $recordManagement;
     $this->recordManagementRepository = $recordManagement->getRecordManagementRepository();
     $this->arguments = $recordManagement->getArguments();
     $this->templateType = $templateType;
     $this->record = $recordManagement->getRecords(0);
     $this->recordNumber = 0;
     if ($this->record) {
         $this->primaryKeys = $this->record->getPrimaryKeys();
     }
     $this->primaryKeysArray = $recordManagement->getPrimaryKeys();
     $this->columnTypes = $recordManagement->getTable()->getColumnTypes();
     $this->orderBy = $recordManagement->getConditions()->getOrderBy();
     $this->order = $recordManagement->getConditions()->getOrder();
     $this->search = $recordManagement->getConditions()->getSearch();
     $this->filters = $recordManagement->getConditions()->getFilters();
     $this->selectedColumns = $recordManagement->getTable()->getSelectedColumns();
     $this->uriBuilder = $uriBuilder;
     $i = 0;
     $this->recordPosition = 0;
     $countPrimaryKeys = count($this->primaryKeys);
     $countRightKeys = 0;
     if ($this->primaryKeysArray !== NULL) {
         foreach ($this->primaryKeysArray as $keys) {
             $countRightKeys = 0;
             foreach ($this->primaryKeys as $column => $value) {
                 if ($keys[$column] == $value) {
                     $countRightKeys++;
                 }
             }
             if ($countRightKeys == $countPrimaryKeys) {
                 $this->recordPosition = $i;
                 break;
             } else {
                 $i++;
             }
         }
     }
 }