From 07fd41e2bf4f576a7f14cdf0235366827d2bea18 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bjo=CC=88rn=20Fromme?= Date: Wed, 4 Jul 2018 19:58:11 +0200 Subject: [PATCH] Implement standard export for c&p --- .../Classes/Controller/ResellerController.php | 12 +- .../Classes/Domain/Model/Hotel.php | 20 +- .../Classes/Domain/Serialization/Hotel.php | 12 + .../Classes/Domain/Serialization/Product.php | 2 + .../ext/ep_products/ext_localconf.php | 4 +- .../Configuration/TypoScript/Page/Export.ts | 5 - .../Private/Templates/Reseller/Copypaste.html | 293 ++++++++++++++++++ .../Private/Templates/Reseller/List.html | 6 +- 8 files changed, 332 insertions(+), 22 deletions(-) create mode 100644 web/typo3conf/ext/ep_theme/Resources/Private/Templates/Reseller/Copypaste.html diff --git a/web/typo3conf/ext/ep_products/Classes/Controller/ResellerController.php b/web/typo3conf/ext/ep_products/Classes/Controller/ResellerController.php index 7b3b9557..6ff8607f 100644 --- a/web/typo3conf/ext/ep_products/Classes/Controller/ResellerController.php +++ b/web/typo3conf/ext/ep_products/Classes/Controller/ResellerController.php @@ -78,20 +78,20 @@ class ResellerController extends ActionController /** * @param Reseller $reseller * @param Product $product - * @return bool + * @throws \TYPO3\CMS\Extbase\Mvc\Exception\StopActionException * @throws \TYPO3\CMS\Extbase\Mvc\Exception\UnsupportedRequestTypeException */ - public function excelAction(Reseller $reseller, Product $product) + public function copypasteAction(Reseller $reseller, Product $product) { if (!$reseller->getProducts()->contains($product)) { $this->redirect('list', null, null, [ 'reseller' => $reseller ]); } - $data = $this->resellerService->preprocessSingle($product, $reseller); - var_dump($data); + $productData = $this->resellerService->preprocessSingle($product, $reseller); - return false; + $this->view->assign('reseller', $reseller); + $this->view->assign('productData', $productData); } /** @@ -100,8 +100,6 @@ class ResellerController extends ActionController */ public function xmlAction(Reseller $reseller) { - $products = $reseller->getProducts(); - $data = $this->resellerService->preprocessAll($reseller); $encoders = [new XmlEncoder('products')]; diff --git a/web/typo3conf/ext/ep_products/Classes/Domain/Model/Hotel.php b/web/typo3conf/ext/ep_products/Classes/Domain/Model/Hotel.php index c3ecd441..4b87ceb6 100644 --- a/web/typo3conf/ext/ep_products/Classes/Domain/Model/Hotel.php +++ b/web/typo3conf/ext/ep_products/Classes/Domain/Model/Hotel.php @@ -51,6 +51,18 @@ class Hotel extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity implements Te self::CATEGORY_SUPER_DELUXE => 'Superdeluxe', ]; + /** + * @var array + */ + public static $typeLabels = [ + 0 => 'Unbestimmt', + self::TYPE_HOLIDAY_FLAT => 'Ferienwohnung', + self::TYPE_SPORTS_CLUB => 'Sportclub', + self::TYPE_APPARTMENT => 'Appartment', + self::TYPE_GUESTHOUSE => 'Gästehaus', + self::TYPE_PENSION => 'Pension', + ]; + /** * @var bool */ @@ -163,9 +175,9 @@ class Hotel extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity implements Te protected $additionalCodes; /** - * @var string + * @var int */ - protected $type = ''; + protected $type = 0; /** * @var int @@ -609,7 +621,7 @@ class Hotel extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity implements Te } /** - * @return string $type + * @return int $type */ public function getType() { @@ -617,7 +629,7 @@ class Hotel extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity implements Te } /** - * @param string $type + * @param int $type */ public function setType($type) { diff --git a/web/typo3conf/ext/ep_products/Classes/Domain/Serialization/Hotel.php b/web/typo3conf/ext/ep_products/Classes/Domain/Serialization/Hotel.php index 9a1ffdef..7d935425 100644 --- a/web/typo3conf/ext/ep_products/Classes/Domain/Serialization/Hotel.php +++ b/web/typo3conf/ext/ep_products/Classes/Domain/Serialization/Hotel.php @@ -36,6 +36,16 @@ class Hotel */ public $name; + /** + * @var string + */ + public $type; + + /** + * @var string + */ + public $category; + /** * @var string */ @@ -60,6 +70,8 @@ class Hotel $hotel = new self; $hotel->name = $entity->getName(); + $hotel->category = \EP\EpProducts\Domain\Model\Hotel::$categoryLabels[$entity->getCategory()]; + $hotel->type = \EP\EpProducts\Domain\Model\Hotel::$typeLabels[$entity->getType()]; $hotel->description = SerializationUtility::sanitizeText($entity->getDescription()); $hotel->features = SerializationUtility::sanitizeText($entity->getFeatures()); diff --git a/web/typo3conf/ext/ep_products/Classes/Domain/Serialization/Product.php b/web/typo3conf/ext/ep_products/Classes/Domain/Serialization/Product.php index 193efc64..40e4663e 100644 --- a/web/typo3conf/ext/ep_products/Classes/Domain/Serialization/Product.php +++ b/web/typo3conf/ext/ep_products/Classes/Domain/Serialization/Product.php @@ -27,6 +27,7 @@ namespace EP\EpProducts\Domain\Serialization; * This copyright notice MUST APPEAR in all copies of the script! ***************************************************************/ +use EP\EpProducts\Domain\Model\Fact; use EP\EpProducts\Utility\SerializationUtility; class Product @@ -92,6 +93,7 @@ class Product $product->name = preg_replace('/[\r\n\s]+/', ' ', $entity->getName()); $product->facts['fact'] = array_map(function ($fact) { + /** @var Fact $fact */ return htmlspecialchars($fact->getName()); }, $entity->getFacts()->toArray()); diff --git a/web/typo3conf/ext/ep_products/ext_localconf.php b/web/typo3conf/ext/ep_products/ext_localconf.php index 20988d34..5b221527 100644 --- a/web/typo3conf/ext/ep_products/ext_localconf.php +++ b/web/typo3conf/ext/ep_products/ext_localconf.php @@ -301,10 +301,10 @@ $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['scheduler']['tasks'][\EP\EpProducts\T 'EP.' . $_EXTKEY, 'reseller', [ - 'Reseller' => 'list,xml,excel', + 'Reseller' => 'list,xml,copypaste', ], [ - 'Reseller' => 'list,xml,excel', + 'Reseller' => 'list,xml,copypaste', ] ); diff --git a/web/typo3conf/ext/ep_theme/Configuration/TypoScript/Page/Export.ts b/web/typo3conf/ext/ep_theme/Configuration/TypoScript/Page/Export.ts index 40b989da..df41ae11 100644 --- a/web/typo3conf/ext/ep_theme/Configuration/TypoScript/Page/Export.ts +++ b/web/typo3conf/ext/ep_theme/Configuration/TypoScript/Page/Export.ts @@ -24,8 +24,3 @@ xmlExport { } } } - -excelExport < xmlExport -excelExport.typeNum = 1984 -excelExport.config.additionalHeaders = Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet -excelExport.10.switchableControllerActions.Reseller.1 = excel diff --git a/web/typo3conf/ext/ep_theme/Resources/Private/Templates/Reseller/Copypaste.html b/web/typo3conf/ext/ep_theme/Resources/Private/Templates/Reseller/Copypaste.html new file mode 100644 index 00000000..07e2ffea --- /dev/null +++ b/web/typo3conf/ext/ep_theme/Resources/Private/Templates/Reseller/Copypaste.html @@ -0,0 +1,293 @@ + + + + + +
+
+
+

Datenexport {productData.name}

+
+
+
+ + + + + + + + + + + + + +
+
+
+ zurück +
+
+
+
+ + +
+
+

+ {label} +

+
+
+
+ +
+ + +
+
+ +
+ + +
+
+ +
+ + +
+
+
+
+
+
+ + +
+
+

+ {label} +

+
+
+
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+

Termine, Zimmer und Leistungen

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
von{date.from}
bis{date.to}
Nächte{date.nights}
Abpreis{date.minprice} €
Bus inkl.{f:if(condition: date.busincluded, then: 'ja', else: 'nein')}
Skipass inkl.{f:if(condition: date.skipassincluded, then: 'ja', else: 'nein')}
Zimmer + + + + + + + + + + + + + + + + + +
BezeichnungPreisverfügbar
{room.name}{room.price} €{room.available}
+
Inklusivleistungen + {date.servicesincluded.service -> v:iterator.implode(glue: '
')} +
Zusatzleistungen + + + + + + + +
{service.label}{service.price} €
+
BuchungslinkURL
+
+
+
+
+
+ + +
+
+

+ {label} +

+
+
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+
+
+ + +
+
+

+ {label} +

+
+
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+ + +
+
+ + +
+
+
+
+ + +
+
+
+
+
+
+ + +
+
+

+ {label} +

+
+
+
+ + {image}
+
+
+
+
+
+ + diff --git a/web/typo3conf/ext/ep_theme/Resources/Private/Templates/Reseller/List.html b/web/typo3conf/ext/ep_theme/Resources/Private/Templates/Reseller/List.html index 3213674e..c05d073c 100644 --- a/web/typo3conf/ext/ep_theme/Resources/Private/Templates/Reseller/List.html +++ b/web/typo3conf/ext/ep_theme/Resources/Private/Templates/Reseller/List.html @@ -12,14 +12,12 @@

{reseller.name}

Gesamtexport XML

Export XML - -

Einzelexport Excel

+

Einzelexport für Copy&Paste

    -
  • Export XLS: {product.name}
  • +
  • {product.name}
-