Skip to content

Commit

Permalink
Simplified locale select component
Browse files Browse the repository at this point in the history
  • Loading branch information
aimeos committed Feb 9, 2022
1 parent 6cd0a88 commit 5d904db
Show file tree
Hide file tree
Showing 10 changed files with 36 additions and 489 deletions.
150 changes: 3 additions & 147 deletions client/html/src/Client/Html/Locale/Select/Currency/Standard.php
Expand Up @@ -2,7 +2,6 @@

/**
* @license LGPLv3, http://opensource.org/licenses/LGPL-3.0
* @copyright Metaways Infosystems GmbH, 2014
* @copyright Aimeos (aimeos.org), 2015-2022
* @package Client
* @subpackage Html
Expand All @@ -22,42 +21,6 @@ class Standard
extends \Aimeos\Client\Html\Common\Client\Factory\Base
implements \Aimeos\Client\Html\Common\Client\Factory\Iface
{
/** client/html/locale/select/currency/subparts
* List of HTML sub-clients rendered within the locale select currency 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/<clients>/subparts = array( "subclient1", "subclient2" )
*
* You can also remove one or more parts if they shouldn't be rendered:
*
* client/html/<clients>/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.09
*/
private $subPartPath = 'client/html/locale/select/currency/subparts';
private $subPartNames = [];


/**
* Returns the HTML code for insertion into the body.
*
Expand All @@ -68,12 +31,6 @@ public function body( string $uid = '' ) : string
{
$view = $this->view();

$html = '';
foreach( $this->getSubClients() as $subclient ) {
$html .= $subclient->setView( $view )->body( $uid );
}
$view->currencyBody = $html;

/** client/html/locale/select/currency/template-body
* Relative path to the HTML body template of the locale select currency client.
*
Expand All @@ -100,90 +57,6 @@ public function body( string $uid = '' ) : string
}


/**
* 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/locale/select/currency/decorators/excludes
* Excludes decorators added by the "common" option from the locale select currency 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/locale/select/currency/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
* @see client/html/common/decorators/default
* @see client/html/locale/select/currency/decorators/global
* @see client/html/locale/select/currency/decorators/local
*/

/** client/html/locale/select/currency/decorators/global
* Adds a list of globally available decorators only to the locale select currency 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/locale/select/currency/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
* @see client/html/common/decorators/default
* @see client/html/locale/select/currency/decorators/excludes
* @see client/html/locale/select/currency/decorators/local
*/

/** client/html/locale/select/currency/decorators/local
* Adds a list of local decorators only to the locale select currency 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\Checkout\Decorator\*") around the html client.
*
* client/html/locale/select/currency/decorators/local = array( 'decorator2' )
*
* This would add the decorator named "decorator2" defined by
* "\Aimeos\Client\Html\Checkout\Decorator\Decorator2" only to the html client.
*
* @param array List of decorator names
* @since 2015.08
* @see client/html/common/decorators/default
* @see client/html/locale/select/currency/decorators/excludes
* @see client/html/locale/select/currency/decorators/global
*/

return $this->createSubClient( 'locale/select/currency/' . $type, $name );
}


/**
* Processes the input, e.g. store given values.
*
Expand All @@ -192,28 +65,11 @@ public function getSubClient( string $type, string $name = null ) : \Aimeos\Clie
*/
public function init()
{
$view = $this->view();
$context = $this->context();
$config = $context->config();
$session = $context->session();
$name = $context->config()->get( 'client/html/locale/select/currency/param-name', 'currency' );

$name = $config->get( 'client/html/locale/select/currency/param-name', 'currency' );

if( ( $currencyId = $view->param( $name ) ) !== null ) {
$session->set( 'aimeos/locale/currencyid', $currencyId );
if( $currencyId = $this->view()->param( $name ) ) {
$context->session()->set( 'aimeos/locale/currencyid', $currencyId );
}

parent::init();
}


/**
* 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 );
}
}
150 changes: 3 additions & 147 deletions client/html/src/Client/Html/Locale/Select/Language/Standard.php
Expand Up @@ -2,7 +2,6 @@

/**
* @license LGPLv3, http://opensource.org/licenses/LGPL-3.0
* @copyright Metaways Infosystems GmbH, 2014
* @copyright Aimeos (aimeos.org), 2015-2022
* @package Client
* @subpackage Html
Expand All @@ -22,42 +21,6 @@ class Standard
extends \Aimeos\Client\Html\Common\Client\Factory\Base
implements \Aimeos\Client\Html\Common\Client\Factory\Iface
{
/** client/html/locale/select/language/subparts
* List of HTML sub-clients rendered within the locale select language 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/<clients>/subparts = array( "subclient1", "subclient2" )
*
* You can also remove one or more parts if they shouldn't be rendered:
*
* client/html/<clients>/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.09
*/
private $subPartPath = 'client/html/locale/select/language/subparts';
private $subPartNames = [];


/**
* Returns the HTML code for insertion into the body.
*
Expand All @@ -68,12 +31,6 @@ public function body( string $uid = '' ) : string
{
$view = $this->view();

$html = '';
foreach( $this->getSubClients() as $subclient ) {
$html .= $subclient->setView( $view )->body( $uid );
}
$view->languageBody = $html;

/** client/html/locale/select/language/template-body
* Relative path to the HTML body template of the locale select language client.
*
Expand All @@ -100,90 +57,6 @@ public function body( string $uid = '' ) : string
}


/**
* 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/locale/select/language/decorators/excludes
* Excludes decorators added by the "common" option from the locale select language 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/locale/select/language/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
* @see client/html/common/decorators/default
* @see client/html/locale/select/language/decorators/global
* @see client/html/locale/select/language/decorators/local
*/

/** client/html/locale/select/language/decorators/global
* Adds a list of globally available decorators only to the locale select language 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/locale/select/language/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
* @see client/html/common/decorators/default
* @see client/html/locale/select/language/decorators/excludes
* @see client/html/locale/select/language/decorators/local
*/

/** client/html/locale/select/language/decorators/local
* Adds a list of local decorators only to the locale select language 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\Checkout\Decorator\*") around the html client.
*
* client/html/locale/select/language/decorators/local = array( 'decorator2' )
*
* This would add the decorator named "decorator2" defined by
* "\Aimeos\Client\Html\Checkout\Decorator\Decorator2" only to the html client.
*
* @param array List of decorator names
* @since 2015.08
* @see client/html/common/decorators/default
* @see client/html/locale/select/language/decorators/excludes
* @see client/html/locale/select/language/decorators/global
*/

return $this->createSubClient( 'locale/select/language/' . $type, $name );
}


/**
* Processes the input, e.g. store given values.
*
Expand All @@ -192,28 +65,11 @@ public function getSubClient( string $type, string $name = null ) : \Aimeos\Clie
*/
public function init()
{
$view = $this->view();
$context = $this->context();
$config = $context->config();
$session = $context->session();
$name = $context->config()->get( 'client/html/locale/select/language/param-name', 'locale' );

$name = $config->get( 'client/html/locale/select/language/param-name', 'locale' );

if( ( $languageId = $view->param( $name ) ) !== null ) {
$session->set( 'aimeos/locale/languageid', $languageId );
if( $languageId = $this->view()->param( $name ) ) {
$context->session()->set( 'aimeos/locale/languageid', $languageId );
}

parent::init();
}


/**
* 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 );
}
}

0 comments on commit 5d904db

Please sign in to comment.