Skip to content

Commit

Permalink
Plugin updates
Browse files Browse the repository at this point in the history
  • Loading branch information
MarksSoftwareGmbH committed Mar 24, 2024
1 parent 5aa3f45 commit 5b22d48
Show file tree
Hide file tree
Showing 79 changed files with 7,398 additions and 184 deletions.
12 changes: 1 addition & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,14 +76,4 @@ When the composer update is finished
## Links

* **Marks Software GmbH website**: [https://www.marks-software.de](https://www.marks-software.de)
* **Marks Software GmbH on X / Twitter**: [https://twitter.com/SoftwareMarks](https://twitter.com/SoftwareMarks)

## Please donate and support

* **Bitcoin on-chain address**:

bc1q2640hpfc39gjdp6l4ejr0lqnyyw8ply4yg0uuu

<p align="center">
<img alt="bc1q2640hpfc39gjdp6l4ejr0lqnyyw8ply4yg0uuu" src="https://www.marks-software.de/uploads/bc1q2640hpfc39gjdp6l4ejr0lqnyyw8ply4yg0uuu.jpg" width="400" />
</p>
* **Marks Software GmbH on X / Twitter**: [https://twitter.com/SoftwareMarks](https://twitter.com/SoftwareMarks)
154 changes: 138 additions & 16 deletions plugins/YabCmsFf/config/routes.php

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,11 @@
*/
namespace YabCmsFf\Controller\Admin;

use YabCmsFf\Controller\Admin\AppController;
use Cake\Event\EventInterface;
use Cake\Http\CallbackStream;
use PhpOffice\PhpSpreadsheet\Spreadsheet;
use PhpOffice\PhpSpreadsheet\IOFactory;
use YabCmsFf\Controller\Admin\AppController;
use YabCmsFf\Utility\YabCmsFf;

/**
Expand Down Expand Up @@ -281,4 +284,228 @@ public function delete(int $id = null)

return $this->redirect(['action' => 'index']);
}

/**
* Export xlsx method
*
* @return \Cake\Http\Response|void Redirects to index.
* @throws \Cake\Datasource\Exception\RecordNotFoundException When record not found.
*/
public function exportXlsx()
{
$articleArticleTypeAttributeValues = $this->ArticleArticleTypeAttributeValues->find('all');
$header = $this->ArticleArticleTypeAttributeValues->tableColumns;

$articleArticleTypeAttributeValuesArray = [];
foreach($articleArticleTypeAttributeValues as $articleArticleTypeAttributeValue) {
$articleArticleTypeAttributeValueArray = [];
$articleArticleTypeAttributeValueArray['id'] = $articleArticleTypeAttributeValue->id;
$articleArticleTypeAttributeValueArray['article_id'] = $articleArticleTypeAttributeValue->article_id;
$articleArticleTypeAttributeValueArray['article_type_attribute_id'] = $articleArticleTypeAttributeValue->article_type_attribute_id;
$articleArticleTypeAttributeValueArray['value'] = $articleArticleTypeAttributeValue->value;
$articleArticleTypeAttributeValueArray['created'] = empty($articleArticleTypeAttributeValue->created)? NULL: $articleArticleTypeAttributeValue->created->i18nFormat('yyyy-MM-dd HH:mm:ss');
$articleArticleTypeAttributeValueArray['modified'] = empty($articleArticleTypeAttributeValue->modified)? NULL: $articleArticleTypeAttributeValue->modified->i18nFormat('yyyy-MM-dd HH:mm:ss');

$articleArticleTypeAttributeValuesArray[] = $articleArticleTypeAttributeValueArray;
}
$articleArticleTypeAttributeValues = $articleArticleTypeAttributeValuesArray;

$objSpreadsheet = new Spreadsheet();
$objSpreadsheet->setActiveSheetIndex(0);

$rowCount = 1;
$colCount = 1;
foreach ($header as $headerAlias) {
$col = 'A';
switch ($colCount) {
case 2: $col = 'B'; break;
case 3: $col = 'C'; break;
case 4: $col = 'D'; break;
case 5: $col = 'E'; break;
case 6: $col = 'F'; break;
case 7: $col = 'G'; break;
case 8: $col = 'H'; break;
case 9: $col = 'I'; break;
case 10: $col = 'J'; break;
case 11: $col = 'K'; break;
case 12: $col = 'L'; break;
case 13: $col = 'M'; break;
case 14: $col = 'N'; break;
case 15: $col = 'O'; break;
case 16: $col = 'P'; break;
case 17: $col = 'Q'; break;
case 18: $col = 'R'; break;
case 19: $col = 'S'; break;
case 20: $col = 'T'; break;
case 21: $col = 'U'; break;
case 22: $col = 'V'; break;
case 23: $col = 'W'; break;
case 24: $col = 'X'; break;
case 25: $col = 'Y'; break;
case 26: $col = 'Z'; break;
}

$objSpreadsheet->getActiveSheet()->setCellValue($col . $rowCount, $headerAlias);
$colCount++;
}

$rowCount = 1;
foreach ($articleArticleTypeAttributeValues as $dataEntity) {
$rowCount++;

$colCount = 1;
foreach ($dataEntity as $dataProperty) {
$col = 'A';
switch ($colCount) {
case 2: $col = 'B'; break;
case 3: $col = 'C'; break;
case 4: $col = 'D'; break;
case 5: $col = 'E'; break;
case 6: $col = 'F'; break;
case 7: $col = 'G'; break;
case 8: $col = 'H'; break;
case 9: $col = 'I'; break;
case 10: $col = 'J'; break;
case 11: $col = 'K'; break;
case 12: $col = 'L'; break;
case 13: $col = 'M'; break;
case 14: $col = 'N'; break;
case 15: $col = 'O'; break;
case 16: $col = 'P'; break;
case 17: $col = 'Q'; break;
case 18: $col = 'R'; break;
case 19: $col = 'S'; break;
case 20: $col = 'T'; break;
case 21: $col = 'U'; break;
case 22: $col = 'V'; break;
case 23: $col = 'W'; break;
case 24: $col = 'X'; break;
case 25: $col = 'Y'; break;
case 26: $col = 'Z'; break;
}

$objSpreadsheet->getActiveSheet()->setCellValue($col . $rowCount, $dataProperty);
$colCount++;
}
}

foreach (range('A', $objSpreadsheet->getActiveSheet()->getHighestDataColumn()) as $col) {
$objSpreadsheet
->getActiveSheet()
->getColumnDimension($col)
->setAutoSize(true);
}
$objSpreadsheetWriter = IOFactory::createWriter($objSpreadsheet, 'Xlsx');
$stream = new CallbackStream(function () use ($objSpreadsheetWriter) {
$objSpreadsheetWriter->save('php://output');
});

return $this->response
->withType('xlsx')
->withHeader('Content-Disposition', 'attachment;filename="' . strtolower($this->defaultTable) . '.' . 'xlsx"')
->withBody($stream);
}

/**
* Export csv method
*
* @return \Cake\Http\Response|void Redirects to index.
* @throws \Cake\Datasource\Exception\RecordNotFoundException When record not found.
*/
public function exportCsv()
{
$articleArticleTypeAttributeValues = $this->ArticleArticleTypeAttributeValues->find('all');
$delimiter = ';';
$enclosure = '"';
$header = $this->ArticleArticleTypeAttributeValues->tableColumns;
$extract = [
'id',
'article_id',
'article_type_attribute_id',
'value',
function ($row) {
return empty($row['created'])? NULL: $row['created']->i18nFormat('yyyy-MM-dd HH:mm:ss');
},
function ($row) {
return empty($row['modified'])? NULL: $row['modified']->i18nFormat('yyyy-MM-dd HH:mm:ss');
},
];

$this->setResponse($this->getResponse()->withDownload(strtolower($this->defaultTable) . '.' . 'csv'));
$this->set(compact('articleArticleTypeAttributeValues'));
$this
->viewBuilder()
->setClassName('CsvView.Csv')
->setOptions([
'serialize' => 'articleArticleTypeAttributeValues',
'delimiter' => $delimiter,
'enclosure' => $enclosure,
'header' => $header,
'extract' => $extract,
]);
}

/**
* Export xml method
*
* @return \Cake\Http\Response|void Redirects to index.
* @throws \Cake\Datasource\Exception\RecordNotFoundException When record not found.
*/
public function exportXml()
{
$articleArticleTypeAttributeValues = $this->ArticleArticleTypeAttributeValues->find('all');

$articleArticleTypeAttributeValuesArray = [];
foreach($articleArticleTypeAttributeValues as $articleArticleTypeAttributeValue) {
$articleArticleTypeAttributeValueArray = [];
$articleArticleTypeAttributeValueArray['id'] = $articleArticleTypeAttributeValue->id;
$articleArticleTypeAttributeValueArray['article_id'] = $articleArticleTypeAttributeValue->article_id;
$articleArticleTypeAttributeValueArray['article_type_attribute_id'] = $articleArticleTypeAttributeValue->article_type_attribute_id;
$articleArticleTypeAttributeValueArray['value'] = $articleArticleTypeAttributeValue->value;
$articleArticleTypeAttributeValueArray['created'] = empty($articleArticleTypeAttributeValue->created)? NULL: $articleArticleTypeAttributeValue->created->i18nFormat('yyyy-MM-dd HH:mm:ss');
$articleArticleTypeAttributeValueArray['modified'] = empty($articleArticleTypeAttributeValue->modified)? NULL: $articleArticleTypeAttributeValue->modified->i18nFormat('yyyy-MM-dd HH:mm:ss');

$articleArticleTypeAttributeValuesArray[] = $articleArticleTypeAttributeValueArray;
}
$articleArticleTypeAttributeValues = ['ArticleArticleTypeAttributeValues' => ['ArticleArticleTypeAttributeValue' => $articleArticleTypeAttributeValuesArray]];

$this->setResponse($this->getResponse()->withDownload(strtolower($this->defaultTable) . '.' . 'xml'));
$this->set(compact('articleArticleTypeAttributeValues'));
$this
->viewBuilder()
->setClassName('Xml')
->setOptions(['serialize' => 'articleArticleTypeAttributeValues']);
}

/**
* Export json method
*
* @return \Cake\Http\Response|void Redirects to index.
* @throws \Cake\Datasource\Exception\RecordNotFoundException When record not found.
*/
public function exportJson()
{
$articleArticleTypeAttributeValues = $this->ArticleArticleTypeAttributeValues->find('all');

$articleArticleTypeAttributeValuesArray = [];
foreach($articleArticleTypeAttributeValues as $articleArticleTypeAttributeValue) {
$articleArticleTypeAttributeValueArray = [];
$articleArticleTypeAttributeValueArray['id'] = $articleArticleTypeAttributeValue->id;
$articleArticleTypeAttributeValueArray['article_id'] = $articleArticleTypeAttributeValue->article_id;
$articleArticleTypeAttributeValueArray['article_type_attribute_id'] = $articleArticleTypeAttributeValue->article_type_attribute_id;
$articleArticleTypeAttributeValueArray['value'] = $articleArticleTypeAttributeValue->value;
$articleArticleTypeAttributeValueArray['created'] = empty($articleArticleTypeAttributeValue->created)? NULL: $articleArticleTypeAttributeValue->created->i18nFormat('yyyy-MM-dd HH:mm:ss');
$articleArticleTypeAttributeValueArray['modified'] = empty($articleArticleTypeAttributeValue->modified)? NULL: $articleArticleTypeAttributeValue->modified->i18nFormat('yyyy-MM-dd HH:mm:ss');

$articleArticleTypeAttributeValuesArray[] = $articleArticleTypeAttributeValueArray;
}
$articleArticleTypeAttributeValues = ['ArticleArticleTypeAttributeValues' => ['ArticleArticleTypeAttributeValue' => $articleArticleTypeAttributeValuesArray]];

$this->setResponse($this->getResponse()->withDownload(strtolower($this->defaultTable) . '.' . 'json'));
$this->set(compact('articleArticleTypeAttributeValues'));
$this
->viewBuilder()
->setClassName('Json')
->setOptions(['serialize' => 'articleArticleTypeAttributeValues']);
}
}
Loading

0 comments on commit 5b22d48

Please sign in to comment.