From c06d6f6ece425094d66b29e59e4015463a0b6739 Mon Sep 17 00:00:00 2001 From: Aimeos Date: Fri, 28 Jan 2022 09:07:58 +0100 Subject: [PATCH] Simplified account history component --- .../Html/Account/History/Detail/Standard.php | 238 ----------- .../Html/Account/History/Lists/Standard.php | 222 ---------- .../Client/Html/Account/History/Standard.php | 363 +++-------------- .../html/templates/account/history/body.php | 382 +++++++++++++++++- .../templates/account/history/detail-body.php | 236 ----------- .../html/templates/account/history/header.php | 2 +- .../templates/account/history/list-body.php | 180 --------- .../Account/History/Detail/StandardTest.php | 122 ------ .../Account/History/Lists/StandardTest.php | 83 ---- .../Html/Account/History/StandardTest.php | 126 +----- client/html/themes/default/account-history.js | 23 +- 11 files changed, 455 insertions(+), 1522 deletions(-) delete mode 100644 client/html/src/Client/Html/Account/History/Detail/Standard.php delete mode 100644 client/html/src/Client/Html/Account/History/Lists/Standard.php delete mode 100644 client/html/templates/account/history/detail-body.php delete mode 100644 client/html/templates/account/history/list-body.php delete mode 100644 client/html/tests/Client/Html/Account/History/Detail/StandardTest.php delete mode 100644 client/html/tests/Client/Html/Account/History/Lists/StandardTest.php diff --git a/client/html/src/Client/Html/Account/History/Detail/Standard.php b/client/html/src/Client/Html/Account/History/Detail/Standard.php deleted file mode 100644 index b680eb1c1a..0000000000 --- a/client/html/src/Client/Html/Account/History/Detail/Standard.php +++ /dev/null @@ -1,238 +0,0 @@ -/subparts = array( "subclient1", "subclient2" ) - * - * You can also remove one or more parts if they shouldn't be rendered: - * - * client/html//subparts = array( "subclient1" ) - * - * As the clients only generates structural HTML, the layout defined via CSS - * should support adding, removing or redetailing content by a fluid like - * design. - * - * @param array List of sub-client names - * @since 2015.02 - * @category Developer - */ - private $subPartPath = 'client/html/account/history/detail/subparts'; - private $subPartNames = []; - - - /** - * Returns the HTML code for insertion into the body. - * - * @param string $uid Unique identifier for the output if the content is placed more than once on the same page - * @return string HTML code - */ - public function body( string $uid = '' ) : string - { - $view = $this->view(); - - if( $view->param( 'his_action' ) != 'detail' ) { - return ''; - } - - $html = ''; - foreach( $this->getSubClients() as $subclient ) { - $html .= $subclient->setView( $view )->body( $uid ); - } - $view->detailBody = $html; - - /** client/html/account/history/detail/template-body - * Relative path to the HTML body template of the account history detail client. - * - * The template file contains the HTML code and processing instructions - * to generate the result shown in the body of the frontend. The - * configuration string is the path to the template file relative - * to the templates directory (usually in client/html/templates). - * - * You can overwrite the template file configuration in extensions and - * provide alternative templates. These alternative templates should be - * named like the default one but suffixed by - * an unique name. You may use the name of your project for this. If - * you've implemented an alternative client class as well, it - * should be suffixed by the name of the new class. - * - * @param string Relative path to the template creating code for the HTML page body - * @since 2015.02 - * @category Developer - * @see client/html/account/history/detail/template-header - */ - $tplconf = 'client/html/account/history/detail/template-body'; - $default = 'account/history/detail-body'; - - return $view->render( $view->config( $tplconf, $default ) ); - } - - - /** - * Returns the sub-client given by its name. - * - * @param string $type Name of the client type - * @param string|null $name Name of the sub-client (Default if null) - * @return \Aimeos\Client\Html\Iface Sub-client object - */ - public function getSubClient( string $type, string $name = null ) : \Aimeos\Client\Html\Iface - { - /** client/html/account/history/detail/decorators/excludes - * Excludes decorators added by the "common" option from the account history detail html client - * - * Decorators extend the functionality of a class by adding new aspects - * (e.g. log what is currently done), executing the methods of the underlying - * class only in certain conditions (e.g. only for logged in users) or - * modify what is returned to the caller. - * - * This option allows you to remove a decorator added via - * "client/html/common/decorators/default" before they are wrapped - * around the html client. - * - * client/html/account/history/detail/decorators/excludes = array( 'decorator1' ) - * - * This would remove the decorator named "decorator1" from the list of - * common decorators ("\Aimeos\Client\Html\Common\Decorator\*") added via - * "client/html/common/decorators/default" to the html client. - * - * @param array List of decorator names - * @since 2015.08 - * @category Developer - * @see client/html/common/decorators/default - * @see client/html/account/history/detail/decorators/global - * @see client/html/account/history/detail/decorators/local - */ - - /** client/html/account/history/detail/decorators/global - * Adds a list of globally available decorators only to the account history detail html client - * - * Decorators extend the functionality of a class by adding new aspects - * (e.g. log what is currently done), executing the methods of the underlying - * class only in certain conditions (e.g. only for logged in users) or - * modify what is returned to the caller. - * - * This option allows you to wrap global decorators - * ("\Aimeos\Client\Html\Common\Decorator\*") around the html client. - * - * client/html/account/history/detail/decorators/global = array( 'decorator1' ) - * - * This would add the decorator named "decorator1" defined by - * "\Aimeos\Client\Html\Common\Decorator\Decorator1" only to the html client. - * - * @param array List of decorator names - * @since 2015.08 - * @category Developer - * @see client/html/common/decorators/default - * @see client/html/account/history/detail/decorators/excludes - * @see client/html/account/history/detail/decorators/local - */ - - /** client/html/account/history/detail/decorators/local - * Adds a list of local decorators only to the account history detail html client - * - * Decorators extend the functionality of a class by adding new aspects - * (e.g. log what is currently done), executing the methods of the underlying - * class only in certain conditions (e.g. only for logged in users) or - * modify what is returned to the caller. - * - * This option allows you to wrap local decorators - * ("\Aimeos\Client\Html\Account\Decorator\*") around the html client. - * - * client/html/account/history/detail/decorators/local = array( 'decorator2' ) - * - * This would add the decorator named "decorator2" defined by - * "\Aimeos\Client\Html\Account\Decorator\Decorator2" only to the html client. - * - * @param array List of decorator names - * @since 2015.08 - * @category Developer - * @see client/html/common/decorators/default - * @see client/html/account/history/detail/decorators/excludes - * @see client/html/account/history/detail/decorators/global - */ - - return $this->createSubClient( 'account/history/detail/' . $type, $name ); - } - - - /** - * Returns the list of sub-client names configured for the client. - * - * @return array List of HTML client names - */ - protected function getSubClientNames() : array - { - return $this->context()->config()->get( $this->subPartPath, $this->subPartNames ); - } - - - /** - * Sets the necessary parameter values in the view. - * - * @param \Aimeos\MW\View\Iface $view The view object which generates the HTML output - * @param array &$tags Result array for the list of tags that are associated to the output - * @param string|null &$expire Result variable for the expiration date of the output (null for no expiry) - * @return \Aimeos\MW\View\Iface Modified view object - */ - public function data( \Aimeos\MW\View\Iface $view, array &$tags = [], string &$expire = null ) : \Aimeos\MW\View\Iface - { - if( ( $orderId = $view->param( 'his_id', null ) ) !== null ) - { - $context = $this->context(); - - $orderItem = \Aimeos\Controller\Frontend::create( $context, 'order' )->get( $orderId ); - $basket = \Aimeos\Controller\Frontend::create( $context, 'basket' )->load( $orderItem->getBaseId() ); - - if( $orderItem->getStatusPayment() >= $this->getDownloadPaymentStatus() ) { - $view->summaryShowDownloadAttributes = true; - } - - $view->orderItem = $orderItem; - $view->summaryBasket = $basket; - $view->summaryTaxRates = $this->getTaxRates( $basket ); - $view->summaryNamedTaxes = $this->getNamedTaxes( $basket ); - $view->summaryCostsDelivery = $this->getCostsDelivery( $basket ); - $view->summaryCostsPayment = $this->getCostsPayment( $basket ); - } - - return parent::data( $view, $tags, $expire ); - } -} diff --git a/client/html/src/Client/Html/Account/History/Lists/Standard.php b/client/html/src/Client/Html/Account/History/Lists/Standard.php deleted file mode 100644 index 34a6c27074..0000000000 --- a/client/html/src/Client/Html/Account/History/Lists/Standard.php +++ /dev/null @@ -1,222 +0,0 @@ -/subparts = array( "subclient1", "subclient2" ) - * - * You can also remove one or more parts if they shouldn't be rendered: - * - * client/html//subparts = array( "subclient1" ) - * - * As the clients only generates structural HTML, the layout defined via CSS - * should support adding, removing or reordering content by a fluid like - * design. - * - * @param array List of sub-client names - * @since 2014.03 - * @category Developer - */ - private $subPartPath = 'client/html/account/history/lists/subparts'; - private $subPartNames = []; - - - /** - * Returns the HTML code for insertion into the body. - * - * @param string $uid Unique identifier for the output if the content is placed more than once on the same page - * @return string HTML code - */ - public function body( string $uid = '' ) : string - { - $view = $this->view(); - - if( $view->param( 'his_action', 'list' ) != 'list' ) { - return ''; - } - - $html = ''; - foreach( $this->getSubClients() as $subclient ) { - $html .= $subclient->setView( $view )->body( $uid ); - } - $view->listsBody = $html; - - /** client/html/account/history/lists/template-body - * Relative path to the HTML body template of the account history list client. - * - * The template file contains the HTML code and processing instructions - * to generate the result shown in the body of the frontend. The - * configuration string is the path to the template file relative - * to the templates directory (usually in client/html/templates). - * - * You can overwrite the template file configuration in extensions and - * provide alternative templates. These alternative templates should be - * named like the default one but suffixed by - * an unique name. You may use the name of your project for this. If - * you've implemented an alternative client class as well, it - * should be suffixed by the name of the new class. - * - * @param string Relative path to the template creating code for the HTML page body - * @since 2014.03 - * @category Developer - * @see client/html/account/history/lists/template-header - */ - $tplconf = 'client/html/account/history/lists/template-body'; - $default = 'account/history/list-body'; - - return $view->render( $view->config( $tplconf, $default ) ); - } - - - /** - * Returns the sub-client given by its name. - * - * @param string $type Name of the client type - * @param string|null $name Name of the sub-client (Default if null) - * @return \Aimeos\Client\Html\Iface Sub-client object - */ - public function getSubClient( string $type, string $name = null ) : \Aimeos\Client\Html\Iface - { - /** client/html/account/history/lists/decorators/excludes - * Excludes decorators added by the "common" option from the account history list html client - * - * Decorators extend the functionality of a class by adding new aspects - * (e.g. log what is currently done), executing the methods of the underlying - * class only in certain conditions (e.g. only for logged in users) or - * modify what is returned to the caller. - * - * This option allows you to remove a decorator added via - * "client/html/common/decorators/default" before they are wrapped - * around the html client. - * - * client/html/account/history/lists/decorators/excludes = array( 'decorator1' ) - * - * This would remove the decorator named "decorator1" from the list of - * common decorators ("\Aimeos\Client\Html\Common\Decorator\*") added via - * "client/html/common/decorators/default" to the html client. - * - * @param array List of decorator names - * @since 2015.08 - * @category Developer - * @see client/html/common/decorators/default - * @see client/html/account/history/lists/decorators/global - * @see client/html/account/history/lists/decorators/local - */ - - /** client/html/account/history/lists/decorators/global - * Adds a list of globally available decorators only to the account history list html client - * - * Decorators extend the functionality of a class by adding new aspects - * (e.g. log what is currently done), executing the methods of the underlying - * class only in certain conditions (e.g. only for logged in users) or - * modify what is returned to the caller. - * - * This option allows you to wrap global decorators - * ("\Aimeos\Client\Html\Common\Decorator\*") around the html client. - * - * client/html/account/history/lists/decorators/global = array( 'decorator1' ) - * - * This would add the decorator named "decorator1" defined by - * "\Aimeos\Client\Html\Common\Decorator\Decorator1" only to the html client. - * - * @param array List of decorator names - * @since 2015.08 - * @category Developer - * @see client/html/common/decorators/default - * @see client/html/account/history/lists/decorators/excludes - * @see client/html/account/history/lists/decorators/local - */ - - /** client/html/account/history/lists/decorators/local - * Adds a list of local decorators only to the account history list html client - * - * Decorators extend the functionality of a class by adding new aspects - * (e.g. log what is currently done), executing the methods of the underlying - * class only in certain conditions (e.g. only for logged in users) or - * modify what is returned to the caller. - * - * This option allows you to wrap local decorators - * ("\Aimeos\Client\Html\Account\Decorator\*") around the html client. - * - * client/html/account/history/lists/decorators/local = array( 'decorator2' ) - * - * This would add the decorator named "decorator2" defined by - * "\Aimeos\Client\Html\Account\Decorator\Decorator2" only to the html client. - * - * @param array List of decorator names - * @since 2015.08 - * @category Developer - * @see client/html/common/decorators/default - * @see client/html/account/history/lists/decorators/excludes - * @see client/html/account/history/lists/decorators/global - */ - - return $this->createSubClient( 'account/history/lists/' . $type, $name ); - } - - - /** - * Returns the list of sub-client names configured for the client. - * - * @return array List of HTML client names - */ - protected function getSubClientNames() : array - { - return $this->context()->config()->get( $this->subPartPath, $this->subPartNames ); - } - - - /** - * Sets the necessary parameter values in the view. - * - * @param \Aimeos\MW\View\Iface $view The view object which generates the HTML output - * @param array &$tags Result array for the list of tags that are associated to the output - * @param string|null &$expire Result variable for the expiration date of the output (null for no expiry) - * @return \Aimeos\MW\View\Iface Modified view object - */ - public function data( \Aimeos\MW\View\Iface $view, array &$tags = [], string &$expire = null ) : \Aimeos\MW\View\Iface - { - $cntl = \Aimeos\Controller\Frontend::create( $this->context(), 'order' ); - $view->listsOrderItems = $cntl->sort( '-order.id' )->search(); - - return parent::data( $view, $tags, $expire ); - } -} diff --git a/client/html/src/Client/Html/Account/History/Standard.php b/client/html/src/Client/Html/Account/History/Standard.php index 2d81231dcd..a81fb40bd1 100644 --- a/client/html/src/Client/Html/Account/History/Standard.php +++ b/client/html/src/Client/Html/Account/History/Standard.php @@ -2,7 +2,6 @@ /** * @license LGPLv3, http://opensource.org/licenses/LGPL-3.0 - * @copyright Metaways Infosystems GmbH, 2013 * @copyright Aimeos (aimeos.org), 2015-2022 * @package Client * @subpackage Html @@ -19,327 +18,75 @@ * @subpackage Html */ class Standard - extends \Aimeos\Client\Html\Common\Client\Factory\Base + extends \Aimeos\Client\Html\Common\Client\Summary\Base implements \Aimeos\Client\Html\Iface { - /** client/html/account/history/subparts - * List of HTML sub-clients rendered within the account history section - * - * The output of the frontend is composed of the code generated by the HTML - * clients. Each HTML client can consist of serveral (or none) sub-clients - * that are responsible for rendering certain sub-parts of the output. The - * sub-clients can contain HTML clients themselves and therefore a - * hierarchical tree of HTML clients is composed. Each HTML client creates - * the output that is placed inside the container of its parent. - * - * At first, always the HTML code generated by the parent is printed, then - * the HTML code of its sub-clients. The order of the HTML sub-clients - * determines the order of the output of these sub-clients inside the parent - * container. If the configured list of clients is - * - * array( "subclient1", "subclient2" ) - * - * you can easily change the order of the output by reordering the subparts: - * - * client/html//subparts = array( "subclient1", "subclient2" ) - * - * You can also remove one or more parts if they shouldn't be rendered: - * - * client/html//subparts = array( "subclient1" ) - * - * As the clients only generates structural HTML, the layout defined via CSS - * should support adding, removing or reordering content by a fluid like - * design. - * - * @param array List of sub-client names - * @since 2014.03 - * @category Developer - */ - private $subPartPath = 'client/html/account/history/subparts'; - - /** client/html/account/history/lists/name - * Name of the list part used by the account history client implementation - * - * Use "Myname" if your class is named "\Aimeos\Client\Html\Account\History\Lists\Myname". - * The name is case-sensitive and you should avoid camel case names like "MyName". - * - * @param string Last part of the client class name - * @since 2014.03 - * @category Developer - */ - - /** client/html/account/history/order/name - * Name of the order part used by the account history client implementation - * - * Use "Myname" if your class is named "\Aimeos\Client\Html\Account\History\Order\Myname". - * The name is case-sensitive and you should avoid camel case names like "MyName". - * - * @param string Last part of the client class name - * @since 2015.02 - * @category Developer - */ - private $subPartNames = array( 'lists', 'detail' ); - private $view; - - /** - * Returns the HTML code for insertion into the body. + * Sets the necessary parameter values in the view. * - * @param string $uid Unique identifier for the output if the content is placed more than once on the same page - * @return string HTML code + * @param \Aimeos\MW\View\Iface $view The view object which generates the HTML output + * @param array &$tags Result array for the list of tags that are associated to the output + * @param string|null &$expire Result variable for the expiration date of the output (null for no expiry) + * @return \Aimeos\MW\View\Iface Modified view object */ - public function body( string $uid = '' ) : string + public function data( \Aimeos\MW\View\Iface $view, array &$tags = [], string &$expire = null ) : \Aimeos\MW\View\Iface { - $context = $this->context(); - $view = $this->view(); - - try - { - $view = $this->view = $this->view ?? $this->object()->data( $view ); - - $html = ''; - foreach( $this->getSubClients() as $subclient ) { - $html .= $subclient->setView( $view )->body( $uid ); - } - $view->historyBody = $html; - } - catch( \Aimeos\Client\Html\Exception $e ) - { - $error = array( $context->translate( 'client', $e->getMessage() ) ); - $view->historyErrorList = array_merge( $view->get( 'historyErrorList', [] ), $error ); - } - catch( \Aimeos\Controller\Frontend\Exception $e ) - { - $error = array( $context->translate( 'controller/frontend', $e->getMessage() ) ); - $view->historyErrorList = array_merge( $view->get( 'historyErrorList', [] ), $error ); - } - catch( \Aimeos\MShop\Exception $e ) - { - $error = array( $context->translate( 'mshop', $e->getMessage() ) ); - $view->historyErrorList = array_merge( $view->get( 'historyErrorList', [] ), $error ); - } - catch( \Exception $e ) - { - $error = array( $context->translate( 'client', 'A non-recoverable error occured' ) ); - $view->historyErrorList = array_merge( $view->get( 'historyErrorList', [] ), $error ); - $this->logException( $e ); - } - - /** client/html/account/history/template-body - * Relative path to the HTML body template of the account history client. - * - * The template file contains the HTML code and processing instructions - * to generate the result shown in the body of the frontend. The - * configuration string is the path to the template file relative - * to the templates directory (usually in client/html/templates). - * - * You can overwrite the template file configuration in extensions and - * provide alternative templates. These alternative templates should be - * named like the default one but suffixed by - * an unique name. You may use the name of your project for this. If - * you've implemented an alternative client class as well, it - * should be suffixed by the name of the new class. - * - * @param string Relative path to the template creating code for the HTML page body - * @since 2014.03 - * @category Developer - * @see client/html/account/history/template-header - */ - $tplconf = 'client/html/account/history/template-body'; - $default = 'account/history/body'; - - return $view->render( $view->config( $tplconf, $default ) ); + $view->historyItems = \Aimeos\Controller\Frontend::create( $this->context(), 'order' ) + ->uses( ['order/base', 'order/base/address', 'order/base/coupon', 'order/base/product', 'order/base/service'] ) + ->sort( '-order.id' ) + ->search() + ->each( function( $item ) { + $basket = $item->getBaseItem(); + $basket->set( 'summaryTaxrates', $this->getTaxRates( $basket ) ) + ->set( 'summaryNamedTaxes', $this->getNamedTaxes( $basket ) ) + ->set( 'summaryCostsPayment', $this->getCostsPayment( $basket ) ) + ->set( 'summaryCostsDelivery', $this->getCostsDelivery( $basket ) ); + } ); + + return parent::data( $view, $tags, $expire ); } - /** - * Returns the HTML string for insertion into the header. + /** client/html/account/history/template-body + * Relative path to the HTML body template of the account history client. * - * @param string $uid Unique identifier for the output if the content is placed more than once on the same page - * @return string|null String including HTML tags for the header on error - */ - public function header( string $uid = '' ) : ?string - { - $view = $this->view(); - - try - { - $view = $this->view = $this->view ?? $this->object()->data( $view ); - - $html = ''; - foreach( $this->getSubClients() as $subclient ) { - $html .= $subclient->setView( $view )->header( $uid ); - } - $view->historyHeader = $html; - - /** client/html/account/history/template-header - * Relative path to the HTML header template of the account history client. - * - * The template file contains the HTML code and processing instructions - * to generate the HTML code that is inserted into the HTML page header - * of the rendered page in the frontend. The configuration string is the - * path to the template file relative to the templates directory (usually - * in client/html/templates). - * - * You can overwrite the template file configuration in extensions and - * provide alternative templates. These alternative templates should be - * named like the default one but suffixed by - * an unique name. You may use the name of your project for this. If - * you've implemented an alternative client class as well, it - * should be suffixed by the name of the new class. - * - * @param string Relative path to the template creating code for the HTML page head - * @since 2014.03 - * @category Developer - * @see client/html/account/history/template-body - */ - $tplconf = 'client/html/account/history/template-header'; - $default = 'account/history/header'; - - return $view->render( $view->config( $tplconf, $default ) ); - } - catch( \Exception $e ) - { - $this->logException( $e ); - } - - return null; - } - - - /** - * Returns the sub-client given by its name. + * The template file contains the HTML code and processing instructions + * to generate the result shown in the body of the frontend. The + * configuration string is the path to the template file relative + * to the templates directory (usually in client/html/templates). * - * @param string $type Name of the client type - * @param string|null $name Name of the sub-client (Default if null) - * @return \Aimeos\Client\Html\Iface Sub-client object - */ - public function getSubClient( string $type, string $name = null ) : \Aimeos\Client\Html\Iface - { - /** client/html/account/history/decorators/excludes - * Excludes decorators added by the "common" option from the account history html client - * - * Decorators extend the functionality of a class by adding new aspects - * (e.g. log what is currently done), executing the methods of the underlying - * class only in certain conditions (e.g. only for logged in users) or - * modify what is returned to the caller. - * - * This option allows you to remove a decorator added via - * "client/html/common/decorators/default" before they are wrapped - * around the html client. - * - * client/html/account/history/decorators/excludes = array( 'decorator1' ) - * - * This would remove the decorator named "decorator1" from the list of - * common decorators ("\Aimeos\Client\Html\Common\Decorator\*") added via - * "client/html/common/decorators/default" to the html client. - * - * @param array List of decorator names - * @since 2014.05 - * @category Developer - * @see client/html/common/decorators/default - * @see client/html/account/history/decorators/global - * @see client/html/account/history/decorators/local - */ - - /** client/html/account/history/decorators/global - * Adds a list of globally available decorators only to the account history html client - * - * Decorators extend the functionality of a class by adding new aspects - * (e.g. log what is currently done), executing the methods of the underlying - * class only in certain conditions (e.g. only for logged in users) or - * modify what is returned to the caller. - * - * This option allows you to wrap global decorators - * ("\Aimeos\Client\Html\Common\Decorator\*") around the html client. - * - * client/html/account/history/decorators/global = array( 'decorator1' ) - * - * This would add the decorator named "decorator1" defined by - * "\Aimeos\Client\Html\Common\Decorator\Decorator1" only to the html client. - * - * @param array List of decorator names - * @since 2014.05 - * @category Developer - * @see client/html/common/decorators/default - * @see client/html/account/history/decorators/excludes - * @see client/html/account/history/decorators/local - */ - - /** client/html/account/history/decorators/local - * Adds a list of local decorators only to the account history html client - * - * Decorators extend the functionality of a class by adding new aspects - * (e.g. log what is currently done), executing the methods of the underlying - * class only in certain conditions (e.g. only for logged in users) or - * modify what is returned to the caller. - * - * This option allows you to wrap local decorators - * ("\Aimeos\Client\Html\Account\Decorator\*") around the html client. - * - * client/html/account/history/decorators/local = array( 'decorator2' ) - * - * This would add the decorator named "decorator2" defined by - * "\Aimeos\Client\Html\Account\Decorator\Decorator2" only to the html client. - * - * @param array List of decorator names - * @since 2014.05 - * @category Developer - * @see client/html/common/decorators/default - * @see client/html/account/history/decorators/excludes - * @see client/html/account/history/decorators/global - */ - - return $this->createSubClient( 'account/history/' . $type, $name ); - } - - - /** - * Processes the input, e.g. store given values. + * You can overwrite the template file configuration in extensions and + * provide alternative templates. These alternative templates should be + * named like the default one but suffixed by + * an unique name. You may use the name of your project for this. If + * you've implemented an alternative client class as well, it + * should be suffixed by the name of the new class. * - * A view must be available and this method doesn't generate any output - * besides setting view variables if necessary. + * @param string Relative path to the template creating code for the HTML page body + * @since 2014.03 + * @category Developer + * @see client/html/account/history/template-header */ - public function init() - { - $context = $this->context(); - $view = $this->view(); - - try - { - parent::init(); - } - catch( \Aimeos\MShop\Exception $e ) - { - $error = array( $context->translate( 'mshop', $e->getMessage() ) ); - $view->historyErrorList = array_merge( $view->get( 'historyErrorList', [] ), $error ); - } - catch( \Aimeos\Controller\Frontend\Exception $e ) - { - $error = array( $context->translate( 'controller/frontend', $e->getMessage() ) ); - $view->historyErrorList = array_merge( $view->get( 'historyErrorList', [] ), $error ); - } - catch( \Aimeos\Client\Html\Exception $e ) - { - $error = array( $context->translate( 'client', $e->getMessage() ) ); - $view->historyErrorList = array_merge( $view->get( 'historyErrorList', [] ), $error ); - } - catch( \Exception $e ) - { - $error = array( $context->translate( 'client', 'A non-recoverable error occured' ) ); - $view->historyErrorList = array_merge( $view->get( 'historyErrorList', [] ), $error ); - $this->logException( $e ); - } - } - - /** - * Returns the list of sub-client names configured for the client. + /** client/html/account/history/template-header + * Relative path to the HTML header template of the account history client. + * + * The template file contains the HTML code and processing instructions + * to generate the HTML code that is inserted into the HTML page header + * of the rendered page in the frontend. The configuration string is the + * path to the template file relative to the templates directory (usually + * in client/html/templates). * - * @return array List of HTML client names + * You can overwrite the template file configuration in extensions and + * provide alternative templates. These alternative templates should be + * named like the default one but suffixed by + * an unique name. You may use the name of your project for this. If + * you've implemented an alternative client class as well, it + * should be suffixed by the name of the new class. + * + * @param string Relative path to the template creating code for the HTML page head + * @since 2014.03 + * @category Developer + * @see client/html/account/history/template-body */ - protected function getSubClientNames() : array - { - return $this->context()->config()->get( $this->subPartPath, $this->subPartNames ); - } } diff --git a/client/html/templates/account/history/body.php b/client/html/templates/account/history/body.php index edbced94fd..2d73b6001b 100644 --- a/client/html/templates/account/history/body.php +++ b/client/html/templates/account/history/body.php @@ -2,24 +2,390 @@ /** * @license LGPLv3, http://opensource.org/licenses/LGPL-3.0 - * @copyright Metaways Infosystems GmbH, 2013 * @copyright Aimeos (aimeos.org), 2015-2022 */ + +/** client/html/account/history/url/target + * Destination of the URL where the controller specified in the URL is known + * + * The destination can be a page ID like in a content management system or the + * module of a software development framework. This "target" must contain or know + * the controller that should be called by the generated URL. + * + * @param string Destination of the URL + * @since 2014.03 + * @category Developer + * @see client/html/account/history/url/controller + * @see client/html/account/history/url/action + * @see client/html/account/history/url/config + */ + +/** client/html/account/history/url/controller + * Name of the controller whose action should be called + * + * In Model-View-Controller (MVC) applications, the controller contains the methods + * that create parts of the output displayed in the generated HTML page. Controller + * names are usually alpha-numeric. + * + * @param string Name of the controller + * @since 2014.03 + * @category Developer + * @see client/html/account/history/url/target + * @see client/html/account/history/url/action + * @see client/html/account/history/url/config + */ + +/** client/html/account/history/url/action + * Name of the action that should create the output + * + * In Model-View-Controller (MVC) applications, actions are the methods of a + * controller that create parts of the output displayed in the generated HTML page. + * Action names are usually alpha-numeric. + * + * @param string Name of the action + * @since 2014.03 + * @category Developer + * @see client/html/account/history/url/target + * @see client/html/account/history/url/controller + * @see client/html/account/history/url/config + */ + +/** client/html/account/history/url/config + * Associative list of configuration options used for generating the URL + * + * You can specify additional options as key/value pairs used when generating + * the URLs, like + * + * client/html//url/config = array( 'absoluteUri' => true ) + * + * The available key/value pairs depend on the application that embeds the e-commerce + * framework. This is because the infrastructure of the application is used for + * generating the URLs. The full list of available config options is referenced + * in the "see also" section of this page. + * + * @param string Associative list of configuration options + * @since 2014.03 + * @category Developer + * @see client/html/account/history/url/target + * @see client/html/account/history/url/controller + * @see client/html/account/history/url/action + * @see client/html/url/config + */ + +/// Date format with year (Y), month (m) and day (d). See http://php.net/manual/en/function.date.php +$dateformat = $this->translate( 'client', 'Y-m-d' ); +/// Order status (%1$s) and date (%2$s), e.g. "received at 2000-01-01" +$attrformat = $this->translate( 'client', '%1$s at %2$s' ); + $enc = $this->encoder(); +$basketSite = $this->config( 'client/html/basket/standard/url/site' ); ?> diff --git a/client/html/templates/account/history/detail-body.php b/client/html/templates/account/history/detail-body.php deleted file mode 100644 index 54decafbc0..0000000000 --- a/client/html/templates/account/history/detail-body.php +++ /dev/null @@ -1,236 +0,0 @@ -encoder(); - -$basketSite = $this->config( 'client/html/basket/standard/url/site' ); - - -?> -block()->start( 'account/history/detail' ) ?> - -block()->stop() ?> -block()->get( 'account/history/detail' ) ?> diff --git a/client/html/templates/account/history/header.php b/client/html/templates/account/history/header.php index e9bba530bf..1b367e42c5 100644 --- a/client/html/templates/account/history/header.php +++ b/client/html/templates/account/history/header.php @@ -13,4 +13,4 @@ -get( 'historyHeader' ) ?> +get( 'header' ) ?> diff --git a/client/html/templates/account/history/list-body.php b/client/html/templates/account/history/list-body.php deleted file mode 100644 index 8409924977..0000000000 --- a/client/html/templates/account/history/list-body.php +++ /dev/null @@ -1,180 +0,0 @@ -encoder(); - - -/** client/html/account/history/url/target - * Destination of the URL where the controller specified in the URL is known - * - * The destination can be a page ID like in a content management system or the - * module of a software development framework. This "target" must contain or know - * the controller that should be called by the generated URL. - * - * @param string Destination of the URL - * @since 2014.03 - * @category Developer - * @see client/html/account/history/url/controller - * @see client/html/account/history/url/action - * @see client/html/account/history/url/config - */ - -/** client/html/account/history/url/controller - * Name of the controller whose action should be called - * - * In Model-View-Controller (MVC) applications, the controller contains the methods - * that create parts of the output displayed in the generated HTML page. Controller - * names are usually alpha-numeric. - * - * @param string Name of the controller - * @since 2014.03 - * @category Developer - * @see client/html/account/history/url/target - * @see client/html/account/history/url/action - * @see client/html/account/history/url/config - */ - -/** client/html/account/history/url/action - * Name of the action that should create the output - * - * In Model-View-Controller (MVC) applications, actions are the methods of a - * controller that create parts of the output displayed in the generated HTML page. - * Action names are usually alpha-numeric. - * - * @param string Name of the action - * @since 2014.03 - * @category Developer - * @see client/html/account/history/url/target - * @see client/html/account/history/url/controller - * @see client/html/account/history/url/config - */ - -/** client/html/account/history/url/config - * Associative list of configuration options used for generating the URL - * - * You can specify additional options as key/value pairs used when generating - * the URLs, like - * - * client/html//url/config = array( 'absoluteUri' => true ) - * - * The available key/value pairs depend on the application that embeds the e-commerce - * framework. This is because the infrastructure of the application is used for - * generating the URLs. The full list of available config options is referenced - * in the "see also" section of this page. - * - * @param string Associative list of configuration options - * @since 2014.03 - * @category Developer - * @see client/html/account/history/url/target - * @see client/html/account/history/url/controller - * @see client/html/account/history/url/action - * @see client/html/url/config - */ - - -/// Date format with year (Y), month (m) and day (d). See http://php.net/manual/en/function.date.php -$dateformat = $this->translate( 'client', 'Y-m-d' ); -/// Order status (%1$s) and date (%2$s), e.g. "received at 2000-01-01" -$attrformat = $this->translate( 'client', '%1$s at %2$s' ); - - -?> -block()->start( 'account/history/list' ) ?> - -get( 'listsOrderItems', map() )->isEmpty() ) : ?> - - - - - -block()->stop() ?> -block()->get( 'account/history/list' ) ?> diff --git a/client/html/tests/Client/Html/Account/History/Detail/StandardTest.php b/client/html/tests/Client/Html/Account/History/Detail/StandardTest.php deleted file mode 100644 index 7f2d2fd88d..0000000000 --- a/client/html/tests/Client/Html/Account/History/Detail/StandardTest.php +++ /dev/null @@ -1,122 +0,0 @@ -context = \TestHelperHtml::context(); - - $this->view = \TestHelperHtml::view(); - $this->view->standardBasket = \Aimeos\MShop::create( $this->context, 'order/base' )->create(); - - $this->object = new \Aimeos\Client\Html\Account\History\Detail\Standard( $this->context ); - $this->object->setView( $this->view ); - } - - - protected function tearDown() : void - { - unset( $this->object, $this->context, $this->view ); - } - - - public function testBody() - { - $customer = $this->getCustomerItem( 'test@example.com' ); - $this->context->setUserId( $customer->getId() ); - - $this->view = \TestHelperHtml::view(); - $param = array( - 'his_action' => 'detail', - 'his_id' => $this->getOrderItem( $customer->getId() )->getId() - ); - - $helper = new \Aimeos\MW\View\Helper\Param\Standard( $this->view, $param ); - $this->view->addHelper( 'param', $helper ); - - $this->object->setView( $this->object->data( $this->view ) ); - - $output = $this->object->body(); - - $this->assertStringStartsWith( '