@@ -19,88 +19,88 @@ |
||
| 19 | 19 | * @subpackage Html |
| 20 | 20 | */ |
| 21 | 21 | abstract class Base |
| 22 | - extends \Aimeos\Client\Html\Common\Client\Factory\Base |
|
| 22 | + extends \Aimeos\Client\Html\Common\Client\Factory\Base |
|
| 23 | 23 | { |
| 24 | - /** |
|
| 25 | - * Returns a list of tax rates and values for the given basket. |
|
| 26 | - * |
|
| 27 | - * @param \Aimeos\MShop\Order\Item\Base\Iface $basket Basket containing the products, services, etc. |
|
| 28 | - * @return array Associative list of tax rates as key and corresponding amounts as value |
|
| 29 | - */ |
|
| 30 | - protected function getTaxRates( \Aimeos\MShop\Order\Item\Base\Iface $basket ) |
|
| 31 | - { |
|
| 32 | - $taxrates = array(); |
|
| 24 | + /** |
|
| 25 | + * Returns a list of tax rates and values for the given basket. |
|
| 26 | + * |
|
| 27 | + * @param \Aimeos\MShop\Order\Item\Base\Iface $basket Basket containing the products, services, etc. |
|
| 28 | + * @return array Associative list of tax rates as key and corresponding amounts as value |
|
| 29 | + */ |
|
| 30 | + protected function getTaxRates( \Aimeos\MShop\Order\Item\Base\Iface $basket ) |
|
| 31 | + { |
|
| 32 | + $taxrates = array(); |
|
| 33 | 33 | |
| 34 | - foreach( $basket->getProducts() as $product ) |
|
| 35 | - { |
|
| 36 | - $price = clone $product->getPrice(); |
|
| 37 | - $taxrate = $price->getTaxrate(); |
|
| 34 | + foreach( $basket->getProducts() as $product ) |
|
| 35 | + { |
|
| 36 | + $price = clone $product->getPrice(); |
|
| 37 | + $taxrate = $price->getTaxrate(); |
|
| 38 | 38 | |
| 39 | - if( isset( $taxrates[$taxrate] ) ) { |
|
| 40 | - $taxrates[$taxrate]->addItem( $price, $product->getQuantity() ); |
|
| 41 | - } else { |
|
| 42 | - $taxrates[$taxrate] = $price->addItem( $price, $product->getQuantity() - 1 ); |
|
| 43 | - } |
|
| 44 | - } |
|
| 39 | + if( isset( $taxrates[$taxrate] ) ) { |
|
| 40 | + $taxrates[$taxrate]->addItem( $price, $product->getQuantity() ); |
|
| 41 | + } else { |
|
| 42 | + $taxrates[$taxrate] = $price->addItem( $price, $product->getQuantity() - 1 ); |
|
| 43 | + } |
|
| 44 | + } |
|
| 45 | 45 | |
| 46 | - try |
|
| 47 | - { |
|
| 48 | - $price = clone $basket->getService( 'delivery' )->getPrice(); |
|
| 49 | - $taxrate = $price->getTaxrate(); |
|
| 46 | + try |
|
| 47 | + { |
|
| 48 | + $price = clone $basket->getService( 'delivery' )->getPrice(); |
|
| 49 | + $taxrate = $price->getTaxrate(); |
|
| 50 | 50 | |
| 51 | - if( isset( $taxrates[$taxrate] ) ) { |
|
| 52 | - $taxrates[$taxrate]->addItem( $price ); |
|
| 53 | - } else { |
|
| 54 | - $taxrates[$taxrate] = $price; |
|
| 55 | - } |
|
| 56 | - } |
|
| 57 | - catch( \Exception $e ) { ; } // if delivery service isn't available |
|
| 51 | + if( isset( $taxrates[$taxrate] ) ) { |
|
| 52 | + $taxrates[$taxrate]->addItem( $price ); |
|
| 53 | + } else { |
|
| 54 | + $taxrates[$taxrate] = $price; |
|
| 55 | + } |
|
| 56 | + } |
|
| 57 | + catch( \Exception $e ) { ; } // if delivery service isn't available |
|
| 58 | 58 | |
| 59 | - try |
|
| 60 | - { |
|
| 61 | - $price = clone $basket->getService( 'payment' )->getPrice(); |
|
| 62 | - $taxrate = $price->getTaxrate(); |
|
| 59 | + try |
|
| 60 | + { |
|
| 61 | + $price = clone $basket->getService( 'payment' )->getPrice(); |
|
| 62 | + $taxrate = $price->getTaxrate(); |
|
| 63 | 63 | |
| 64 | - if( isset( $taxrates[$taxrate] ) ) { |
|
| 65 | - $taxrates[$taxrate]->addItem( $price ); |
|
| 66 | - } else { |
|
| 67 | - $taxrates[$taxrate] = $price; |
|
| 68 | - } |
|
| 69 | - } |
|
| 70 | - catch( \Exception $e ) { ; } // if payment service isn't available |
|
| 64 | + if( isset( $taxrates[$taxrate] ) ) { |
|
| 65 | + $taxrates[$taxrate]->addItem( $price ); |
|
| 66 | + } else { |
|
| 67 | + $taxrates[$taxrate] = $price; |
|
| 68 | + } |
|
| 69 | + } |
|
| 70 | + catch( \Exception $e ) { ; } // if payment service isn't available |
|
| 71 | 71 | |
| 72 | - return $taxrates; |
|
| 73 | - } |
|
| 72 | + return $taxrates; |
|
| 73 | + } |
|
| 74 | 74 | |
| 75 | 75 | |
| 76 | - /** |
|
| 77 | - * Returns the payment status at which download files are shown |
|
| 78 | - * |
|
| 79 | - * @return integer Payment status from \Aimeos\MShop\Order\Item\Base |
|
| 80 | - */ |
|
| 81 | - protected function getDownloadPaymentStatus() |
|
| 82 | - { |
|
| 83 | - $config = $this->getContext()->getConfig(); |
|
| 84 | - $default = \Aimeos\MShop\Order\Item\Base::PAY_RECEIVED; |
|
| 76 | + /** |
|
| 77 | + * Returns the payment status at which download files are shown |
|
| 78 | + * |
|
| 79 | + * @return integer Payment status from \Aimeos\MShop\Order\Item\Base |
|
| 80 | + */ |
|
| 81 | + protected function getDownloadPaymentStatus() |
|
| 82 | + { |
|
| 83 | + $config = $this->getContext()->getConfig(); |
|
| 84 | + $default = \Aimeos\MShop\Order\Item\Base::PAY_RECEIVED; |
|
| 85 | 85 | |
| 86 | - /** client/html/common/summary/detail/download/payment-status |
|
| 87 | - * Minium payment status value for product download files |
|
| 88 | - * |
|
| 89 | - * This setting specifies the payment status value of an order for which |
|
| 90 | - * links to bought product download files are shown on the "thank you" |
|
| 91 | - * page, in the "MyAccount" and in the e-mails sent to the customers. |
|
| 92 | - * |
|
| 93 | - * The value is one of the payment constant values from |
|
| 94 | - * {@link https://github.com/aimeos/aimeos-core/blob/master/lib/mshoplib/src/MShop/Order/Item/Base.php#L105}. |
|
| 95 | - * Most of the time, only two values are of interest: |
|
| 96 | - * * 5: payment authorized |
|
| 97 | - * * 6: payment received |
|
| 98 | - * |
|
| 99 | - * @param integer Order payment constant value |
|
| 100 | - * @since 2016.3 |
|
| 101 | - * @category User |
|
| 102 | - * @category Developer |
|
| 103 | - */ |
|
| 104 | - return $config->get( 'client/html/common/summary/detail/download/payment-status', $default ); |
|
| 105 | - } |
|
| 86 | + /** client/html/common/summary/detail/download/payment-status |
|
| 87 | + * Minium payment status value for product download files |
|
| 88 | + * |
|
| 89 | + * This setting specifies the payment status value of an order for which |
|
| 90 | + * links to bought product download files are shown on the "thank you" |
|
| 91 | + * page, in the "MyAccount" and in the e-mails sent to the customers. |
|
| 92 | + * |
|
| 93 | + * The value is one of the payment constant values from |
|
| 94 | + * {@link https://github.com/aimeos/aimeos-core/blob/master/lib/mshoplib/src/MShop/Order/Item/Base.php#L105}. |
|
| 95 | + * Most of the time, only two values are of interest: |
|
| 96 | + * * 5: payment authorized |
|
| 97 | + * * 6: payment received |
|
| 98 | + * |
|
| 99 | + * @param integer Order payment constant value |
|
| 100 | + * @since 2016.3 |
|
| 101 | + * @category User |
|
| 102 | + * @category Developer |
|
| 103 | + */ |
|
| 104 | + return $config->get( 'client/html/common/summary/detail/download/payment-status', $default ); |
|
| 105 | + } |
|
| 106 | 106 | } |
| 107 | 107 | \ No newline at end of file |
@@ -53,8 +53,7 @@ discard block |
||
| 53 | 53 | } else { |
| 54 | 54 | $taxrates[$taxrate] = $price; |
| 55 | 55 | } |
| 56 | - } |
|
| 57 | - catch( \Exception $e ) { ; } // if delivery service isn't available |
|
| 56 | + } catch( \Exception $e ) { ; } // if delivery service isn't available |
|
| 58 | 57 | |
| 59 | 58 | try |
| 60 | 59 | { |
@@ -66,8 +65,7 @@ discard block |
||
| 66 | 65 | } else { |
| 67 | 66 | $taxrates[$taxrate] = $price; |
| 68 | 67 | } |
| 69 | - } |
|
| 70 | - catch( \Exception $e ) { ; } // if payment service isn't available |
|
| 68 | + } catch( \Exception $e ) { ; } // if payment service isn't available |
|
| 71 | 69 | |
| 72 | 70 | return $taxrates; |
| 73 | 71 | } |
@@ -19,6 +19,6 @@ |
||
| 19 | 19 | * @subpackage Html |
| 20 | 20 | */ |
| 21 | 21 | abstract class Base |
| 22 | - extends \Aimeos\Client\Html\Common\Client\Factory\Base |
|
| 22 | + extends \Aimeos\Client\Html\Common\Client\Factory\Base |
|
| 23 | 23 | { |
| 24 | 24 | } |
| 25 | 25 | \ No newline at end of file |
@@ -19,16 +19,16 @@ |
||
| 19 | 19 | * @subpackage Html |
| 20 | 20 | */ |
| 21 | 21 | interface Iface |
| 22 | - extends \Aimeos\Client\Html\Iface |
|
| 22 | + extends \Aimeos\Client\Html\Iface |
|
| 23 | 23 | { |
| 24 | - /** |
|
| 25 | - * Initializes a new client decorator object. |
|
| 26 | - * |
|
| 27 | - * @param \Aimeos\Client\Html\Iface $client Client object |
|
| 28 | - * @param \Aimeos\MShop\Context\Item\Iface $context Context object with required objects |
|
| 29 | - * @param array $templatePaths Associative list of the file system paths to the core or the extensions as key |
|
| 30 | - * and a list of relative paths inside the core or the extension as values |
|
| 31 | - */ |
|
| 32 | - public function __construct( \Aimeos\Client\Html\Iface $client, |
|
| 33 | - \Aimeos\MShop\Context\Item\Iface $context, array $templatePaths ); |
|
| 24 | + /** |
|
| 25 | + * Initializes a new client decorator object. |
|
| 26 | + * |
|
| 27 | + * @param \Aimeos\Client\Html\Iface $client Client object |
|
| 28 | + * @param \Aimeos\MShop\Context\Item\Iface $context Context object with required objects |
|
| 29 | + * @param array $templatePaths Associative list of the file system paths to the core or the extensions as key |
|
| 30 | + * and a list of relative paths inside the core or the extension as values |
|
| 31 | + */ |
|
| 32 | + public function __construct( \Aimeos\Client\Html\Iface $client, |
|
| 33 | + \Aimeos\MShop\Context\Item\Iface $context, array $templatePaths ); |
|
| 34 | 34 | } |
| 35 | 35 | \ No newline at end of file |
@@ -20,13 +20,13 @@ |
||
| 20 | 20 | */ |
| 21 | 21 | interface Iface |
| 22 | 22 | { |
| 23 | - /** |
|
| 24 | - * Creates a client object. |
|
| 25 | - * |
|
| 26 | - * @param \Aimeos\MShop\Context\Item\Iface $context Context instance with necessary objects |
|
| 27 | - * @param array List of file system paths where the templates are stored |
|
| 28 | - * @param string $name Client name (from configuration or "Standard" if null) |
|
| 29 | - * @return \Aimeos\Client\Html\Iface New client object |
|
| 30 | - */ |
|
| 31 | - public static function createClient( \Aimeos\MShop\Context\Item\Iface $context, array $templatePaths, $name = null ); |
|
| 23 | + /** |
|
| 24 | + * Creates a client object. |
|
| 25 | + * |
|
| 26 | + * @param \Aimeos\MShop\Context\Item\Iface $context Context instance with necessary objects |
|
| 27 | + * @param array List of file system paths where the templates are stored |
|
| 28 | + * @param string $name Client name (from configuration or "Standard" if null) |
|
| 29 | + * @return \Aimeos\Client\Html\Iface New client object |
|
| 30 | + */ |
|
| 31 | + public static function createClient( \Aimeos\MShop\Context\Item\Iface $context, array $templatePaths, $name = null ); |
|
| 32 | 32 | } |
@@ -20,155 +20,155 @@ |
||
| 20 | 20 | */ |
| 21 | 21 | class Base |
| 22 | 22 | { |
| 23 | - private static $objects = array(); |
|
| 24 | - |
|
| 25 | - |
|
| 26 | - /** |
|
| 27 | - * Injects a client object. |
|
| 28 | - * The object is returned via createClient() if an instance of the class |
|
| 29 | - * with the name name is requested. |
|
| 30 | - * |
|
| 31 | - * @param string $classname Full name of the class for which the object should be returned |
|
| 32 | - * @param \Aimeos\Client\Html\Iface|null $client ExtJS client object |
|
| 33 | - */ |
|
| 34 | - public static function injectClient( $classname, \Aimeos\Client\Html\Iface $client = null ) |
|
| 35 | - { |
|
| 36 | - self::$objects[$classname] = $client; |
|
| 37 | - } |
|
| 38 | - |
|
| 39 | - |
|
| 40 | - /** |
|
| 41 | - * Adds the decorators to the client object. |
|
| 42 | - * |
|
| 43 | - * @param \Aimeos\MShop\Context\Item\Iface $context Context instance with necessary objects |
|
| 44 | - * @param \Aimeos\Client\Html\Iface $client Client object |
|
| 45 | - * @param array $templatePaths List of file system paths where the templates are stored |
|
| 46 | - * @param array $decorators List of decorator name that should be wrapped around the client |
|
| 47 | - * @param string $classprefix Decorator class prefix, e.g. "\Aimeos\Client\Html\Catalog\Decorator\" |
|
| 48 | - * @return \Aimeos\Client\Html\Iface Client object |
|
| 49 | - */ |
|
| 50 | - protected static function addDecorators( \Aimeos\MShop\Context\Item\Iface $context, |
|
| 51 | - \Aimeos\Client\Html\Iface $client, array $templatePaths, array $decorators, $classprefix ) |
|
| 52 | - { |
|
| 53 | - $iface = '\\Aimeos\\Client\\Html\\Common\\Decorator\\Iface'; |
|
| 54 | - |
|
| 55 | - foreach( $decorators as $name ) |
|
| 56 | - { |
|
| 57 | - if( ctype_alnum( $name ) === false ) |
|
| 58 | - { |
|
| 59 | - $classname = is_string( $name ) ? $classprefix . $name : '<not a string>'; |
|
| 60 | - throw new \Aimeos\Client\Html\Exception( sprintf( 'Invalid class name "%1$s"', $classname ) ); |
|
| 61 | - } |
|
| 62 | - |
|
| 63 | - $classname = $classprefix . $name; |
|
| 64 | - |
|
| 65 | - if( class_exists( $classname ) === false ) { |
|
| 66 | - throw new \Aimeos\Client\Html\Exception( sprintf( 'Class "%1$s" not found', $classname ) ); |
|
| 67 | - } |
|
| 68 | - |
|
| 69 | - $client = new $classname( $client, $context, $templatePaths ); |
|
| 70 | - |
|
| 71 | - if( !( $client instanceof $iface ) ) { |
|
| 72 | - throw new \Aimeos\Client\Html\Exception( sprintf( 'Class "%1$s" does not implement "%2$s"', $classname, $iface ) ); |
|
| 73 | - } |
|
| 74 | - } |
|
| 75 | - |
|
| 76 | - return $client; |
|
| 77 | - } |
|
| 78 | - |
|
| 79 | - |
|
| 80 | - /** |
|
| 81 | - * Adds the decorators to the client object. |
|
| 82 | - * |
|
| 83 | - * @param \Aimeos\MShop\Context\Item\Iface $context Context instance with necessary objects |
|
| 84 | - * @param \Aimeos\Client\Html\Iface $client Client object |
|
| 85 | - * @param array $templatePaths List of file system paths where the templates are stored |
|
| 86 | - * @param string $path Path of the client in lower case, e.g. "catalog/detail" |
|
| 87 | - * @return \Aimeos\Client\Html\Iface Client object |
|
| 88 | - */ |
|
| 89 | - protected static function addClientDecorators( \Aimeos\MShop\Context\Item\Iface $context, |
|
| 90 | - \Aimeos\Client\Html\Iface $client, array $templatePaths, $path ) |
|
| 91 | - { |
|
| 92 | - if( !is_string( $path ) || $path === '' ) { |
|
| 93 | - throw new \Aimeos\Client\Html\Exception( sprintf( 'Invalid domain "%1$s"', $path ) ); |
|
| 94 | - } |
|
| 95 | - |
|
| 96 | - $localClass = str_replace( ' ', '\\', ucwords( str_replace( '/', ' ', $path ) ) ); |
|
| 97 | - $config = $context->getConfig(); |
|
| 98 | - |
|
| 99 | - /** client/html/common/decorators/default |
|
| 100 | - * Configures the list of decorators applied to all html clients |
|
| 101 | - * |
|
| 102 | - * Decorators extend the functionality of a class by adding new aspects |
|
| 103 | - * (e.g. log what is currently done), executing the methods of the underlying |
|
| 104 | - * class only in certain conditions (e.g. only for logged in users) or |
|
| 105 | - * modify what is returned to the caller. |
|
| 106 | - * |
|
| 107 | - * This option allows you to configure a list of decorator names that should |
|
| 108 | - * be wrapped around the original instance of all created clients: |
|
| 109 | - * |
|
| 110 | - * client/html/common/decorators/default = array( 'decorator1', 'decorator2' ) |
|
| 111 | - * |
|
| 112 | - * This would wrap the decorators named "decorator1" and "decorator2" around |
|
| 113 | - * all client instances in that order. The decorator classes would be |
|
| 114 | - * "\Aimeos\Client\Html\Common\Decorator\Decorator1" and |
|
| 115 | - * "\Aimeos\Client\Html\Common\Decorator\Decorator2". |
|
| 116 | - * |
|
| 117 | - * @param array List of decorator names |
|
| 118 | - * @since 2014.03 |
|
| 119 | - * @category Developer |
|
| 120 | - */ |
|
| 121 | - $decorators = $config->get( 'client/html/common/decorators/default', array() ); |
|
| 122 | - $excludes = $config->get( 'client/html/' . $path . '/decorators/excludes', array() ); |
|
| 123 | - |
|
| 124 | - foreach( $decorators as $key => $name ) |
|
| 125 | - { |
|
| 126 | - if( in_array( $name, $excludes ) ) { |
|
| 127 | - unset( $decorators[$key] ); |
|
| 128 | - } |
|
| 129 | - } |
|
| 130 | - |
|
| 131 | - $classprefix = '\\Aimeos\\Client\\Html\\Common\\Decorator\\'; |
|
| 132 | - $client = self::addDecorators( $context, $client, $templatePaths, $decorators, $classprefix ); |
|
| 133 | - |
|
| 134 | - $classprefix = '\\Aimeos\\Client\\Html\\Common\\Decorator\\'; |
|
| 135 | - $decorators = $config->get( 'client/html/' . $path . '/decorators/global', array() ); |
|
| 136 | - $client = self::addDecorators( $context, $client, $templatePaths, $decorators, $classprefix ); |
|
| 137 | - |
|
| 138 | - $classprefix = '\\Aimeos\\Client\\Html\\' . $localClass . '\\Decorator\\'; |
|
| 139 | - $decorators = $config->get( 'client/html/' . $path . '/decorators/local', array() ); |
|
| 140 | - $client = self::addDecorators( $context, $client, $templatePaths, $decorators, $classprefix ); |
|
| 141 | - |
|
| 142 | - return $client; |
|
| 143 | - } |
|
| 144 | - |
|
| 145 | - |
|
| 146 | - /** |
|
| 147 | - * Creates a client object. |
|
| 148 | - * |
|
| 149 | - * @param \Aimeos\MShop\Context\Item\Iface $context Context instance with necessary objects |
|
| 150 | - * @param string $classname Name of the client class |
|
| 151 | - * @param string $interface Name of the client interface |
|
| 152 | - * @param array $templatePaths List of file system paths where the templates are stored |
|
| 153 | - * @return \Aimeos\Client\Html\\Iface Client object |
|
| 154 | - * @throws \Aimeos\Client\Html\Exception If client couldn't be found or doesn't implement the interface |
|
| 155 | - */ |
|
| 156 | - protected static function createClientBase( \Aimeos\MShop\Context\Item\Iface $context, $classname, $interface, $templatePaths ) |
|
| 157 | - { |
|
| 158 | - if( isset( self::$objects[$classname] ) ) { |
|
| 159 | - return self::$objects[$classname]; |
|
| 160 | - } |
|
| 161 | - |
|
| 162 | - if( class_exists( $classname ) === false ) { |
|
| 163 | - throw new \Aimeos\Client\Html\Exception( sprintf( 'Class "%1$s" not available', $classname ) ); |
|
| 164 | - } |
|
| 165 | - |
|
| 166 | - $client = new $classname( $context, $templatePaths ); |
|
| 167 | - |
|
| 168 | - if( !( $client instanceof $interface ) ) { |
|
| 169 | - throw new \Aimeos\Client\Html\Exception( sprintf( 'Class "%1$s" does not implement interface "%2$s"', $classname, $interface ) ); |
|
| 170 | - } |
|
| 171 | - |
|
| 172 | - return $client; |
|
| 173 | - } |
|
| 23 | + private static $objects = array(); |
|
| 24 | + |
|
| 25 | + |
|
| 26 | + /** |
|
| 27 | + * Injects a client object. |
|
| 28 | + * The object is returned via createClient() if an instance of the class |
|
| 29 | + * with the name name is requested. |
|
| 30 | + * |
|
| 31 | + * @param string $classname Full name of the class for which the object should be returned |
|
| 32 | + * @param \Aimeos\Client\Html\Iface|null $client ExtJS client object |
|
| 33 | + */ |
|
| 34 | + public static function injectClient( $classname, \Aimeos\Client\Html\Iface $client = null ) |
|
| 35 | + { |
|
| 36 | + self::$objects[$classname] = $client; |
|
| 37 | + } |
|
| 38 | + |
|
| 39 | + |
|
| 40 | + /** |
|
| 41 | + * Adds the decorators to the client object. |
|
| 42 | + * |
|
| 43 | + * @param \Aimeos\MShop\Context\Item\Iface $context Context instance with necessary objects |
|
| 44 | + * @param \Aimeos\Client\Html\Iface $client Client object |
|
| 45 | + * @param array $templatePaths List of file system paths where the templates are stored |
|
| 46 | + * @param array $decorators List of decorator name that should be wrapped around the client |
|
| 47 | + * @param string $classprefix Decorator class prefix, e.g. "\Aimeos\Client\Html\Catalog\Decorator\" |
|
| 48 | + * @return \Aimeos\Client\Html\Iface Client object |
|
| 49 | + */ |
|
| 50 | + protected static function addDecorators( \Aimeos\MShop\Context\Item\Iface $context, |
|
| 51 | + \Aimeos\Client\Html\Iface $client, array $templatePaths, array $decorators, $classprefix ) |
|
| 52 | + { |
|
| 53 | + $iface = '\\Aimeos\\Client\\Html\\Common\\Decorator\\Iface'; |
|
| 54 | + |
|
| 55 | + foreach( $decorators as $name ) |
|
| 56 | + { |
|
| 57 | + if( ctype_alnum( $name ) === false ) |
|
| 58 | + { |
|
| 59 | + $classname = is_string( $name ) ? $classprefix . $name : '<not a string>'; |
|
| 60 | + throw new \Aimeos\Client\Html\Exception( sprintf( 'Invalid class name "%1$s"', $classname ) ); |
|
| 61 | + } |
|
| 62 | + |
|
| 63 | + $classname = $classprefix . $name; |
|
| 64 | + |
|
| 65 | + if( class_exists( $classname ) === false ) { |
|
| 66 | + throw new \Aimeos\Client\Html\Exception( sprintf( 'Class "%1$s" not found', $classname ) ); |
|
| 67 | + } |
|
| 68 | + |
|
| 69 | + $client = new $classname( $client, $context, $templatePaths ); |
|
| 70 | + |
|
| 71 | + if( !( $client instanceof $iface ) ) { |
|
| 72 | + throw new \Aimeos\Client\Html\Exception( sprintf( 'Class "%1$s" does not implement "%2$s"', $classname, $iface ) ); |
|
| 73 | + } |
|
| 74 | + } |
|
| 75 | + |
|
| 76 | + return $client; |
|
| 77 | + } |
|
| 78 | + |
|
| 79 | + |
|
| 80 | + /** |
|
| 81 | + * Adds the decorators to the client object. |
|
| 82 | + * |
|
| 83 | + * @param \Aimeos\MShop\Context\Item\Iface $context Context instance with necessary objects |
|
| 84 | + * @param \Aimeos\Client\Html\Iface $client Client object |
|
| 85 | + * @param array $templatePaths List of file system paths where the templates are stored |
|
| 86 | + * @param string $path Path of the client in lower case, e.g. "catalog/detail" |
|
| 87 | + * @return \Aimeos\Client\Html\Iface Client object |
|
| 88 | + */ |
|
| 89 | + protected static function addClientDecorators( \Aimeos\MShop\Context\Item\Iface $context, |
|
| 90 | + \Aimeos\Client\Html\Iface $client, array $templatePaths, $path ) |
|
| 91 | + { |
|
| 92 | + if( !is_string( $path ) || $path === '' ) { |
|
| 93 | + throw new \Aimeos\Client\Html\Exception( sprintf( 'Invalid domain "%1$s"', $path ) ); |
|
| 94 | + } |
|
| 95 | + |
|
| 96 | + $localClass = str_replace( ' ', '\\', ucwords( str_replace( '/', ' ', $path ) ) ); |
|
| 97 | + $config = $context->getConfig(); |
|
| 98 | + |
|
| 99 | + /** client/html/common/decorators/default |
|
| 100 | + * Configures the list of decorators applied to all html clients |
|
| 101 | + * |
|
| 102 | + * Decorators extend the functionality of a class by adding new aspects |
|
| 103 | + * (e.g. log what is currently done), executing the methods of the underlying |
|
| 104 | + * class only in certain conditions (e.g. only for logged in users) or |
|
| 105 | + * modify what is returned to the caller. |
|
| 106 | + * |
|
| 107 | + * This option allows you to configure a list of decorator names that should |
|
| 108 | + * be wrapped around the original instance of all created clients: |
|
| 109 | + * |
|
| 110 | + * client/html/common/decorators/default = array( 'decorator1', 'decorator2' ) |
|
| 111 | + * |
|
| 112 | + * This would wrap the decorators named "decorator1" and "decorator2" around |
|
| 113 | + * all client instances in that order. The decorator classes would be |
|
| 114 | + * "\Aimeos\Client\Html\Common\Decorator\Decorator1" and |
|
| 115 | + * "\Aimeos\Client\Html\Common\Decorator\Decorator2". |
|
| 116 | + * |
|
| 117 | + * @param array List of decorator names |
|
| 118 | + * @since 2014.03 |
|
| 119 | + * @category Developer |
|
| 120 | + */ |
|
| 121 | + $decorators = $config->get( 'client/html/common/decorators/default', array() ); |
|
| 122 | + $excludes = $config->get( 'client/html/' . $path . '/decorators/excludes', array() ); |
|
| 123 | + |
|
| 124 | + foreach( $decorators as $key => $name ) |
|
| 125 | + { |
|
| 126 | + if( in_array( $name, $excludes ) ) { |
|
| 127 | + unset( $decorators[$key] ); |
|
| 128 | + } |
|
| 129 | + } |
|
| 130 | + |
|
| 131 | + $classprefix = '\\Aimeos\\Client\\Html\\Common\\Decorator\\'; |
|
| 132 | + $client = self::addDecorators( $context, $client, $templatePaths, $decorators, $classprefix ); |
|
| 133 | + |
|
| 134 | + $classprefix = '\\Aimeos\\Client\\Html\\Common\\Decorator\\'; |
|
| 135 | + $decorators = $config->get( 'client/html/' . $path . '/decorators/global', array() ); |
|
| 136 | + $client = self::addDecorators( $context, $client, $templatePaths, $decorators, $classprefix ); |
|
| 137 | + |
|
| 138 | + $classprefix = '\\Aimeos\\Client\\Html\\' . $localClass . '\\Decorator\\'; |
|
| 139 | + $decorators = $config->get( 'client/html/' . $path . '/decorators/local', array() ); |
|
| 140 | + $client = self::addDecorators( $context, $client, $templatePaths, $decorators, $classprefix ); |
|
| 141 | + |
|
| 142 | + return $client; |
|
| 143 | + } |
|
| 144 | + |
|
| 145 | + |
|
| 146 | + /** |
|
| 147 | + * Creates a client object. |
|
| 148 | + * |
|
| 149 | + * @param \Aimeos\MShop\Context\Item\Iface $context Context instance with necessary objects |
|
| 150 | + * @param string $classname Name of the client class |
|
| 151 | + * @param string $interface Name of the client interface |
|
| 152 | + * @param array $templatePaths List of file system paths where the templates are stored |
|
| 153 | + * @return \Aimeos\Client\Html\\Iface Client object |
|
| 154 | + * @throws \Aimeos\Client\Html\Exception If client couldn't be found or doesn't implement the interface |
|
| 155 | + */ |
|
| 156 | + protected static function createClientBase( \Aimeos\MShop\Context\Item\Iface $context, $classname, $interface, $templatePaths ) |
|
| 157 | + { |
|
| 158 | + if( isset( self::$objects[$classname] ) ) { |
|
| 159 | + return self::$objects[$classname]; |
|
| 160 | + } |
|
| 161 | + |
|
| 162 | + if( class_exists( $classname ) === false ) { |
|
| 163 | + throw new \Aimeos\Client\Html\Exception( sprintf( 'Class "%1$s" not available', $classname ) ); |
|
| 164 | + } |
|
| 165 | + |
|
| 166 | + $client = new $classname( $context, $templatePaths ); |
|
| 167 | + |
|
| 168 | + if( !( $client instanceof $interface ) ) { |
|
| 169 | + throw new \Aimeos\Client\Html\Exception( sprintf( 'Class "%1$s" does not implement interface "%2$s"', $classname, $interface ) ); |
|
| 170 | + } |
|
| 171 | + |
|
| 172 | + return $client; |
|
| 173 | + } |
|
| 174 | 174 | } |
@@ -20,74 +20,74 @@ |
||
| 20 | 20 | */ |
| 21 | 21 | interface Iface |
| 22 | 22 | { |
| 23 | - /** |
|
| 24 | - * Returns the sub-client given by its name. |
|
| 25 | - * |
|
| 26 | - * @param string $type Name of the client type |
|
| 27 | - * @param string|null $name Name of the sub-client (Default if null) |
|
| 28 | - * @return \Aimeos\Client\Html\Iface Sub-client object |
|
| 29 | - */ |
|
| 30 | - public function getSubClient( $type, $name = null ); |
|
| 23 | + /** |
|
| 24 | + * Returns the sub-client given by its name. |
|
| 25 | + * |
|
| 26 | + * @param string $type Name of the client type |
|
| 27 | + * @param string|null $name Name of the sub-client (Default if null) |
|
| 28 | + * @return \Aimeos\Client\Html\Iface Sub-client object |
|
| 29 | + */ |
|
| 30 | + public function getSubClient( $type, $name = null ); |
|
| 31 | 31 | |
| 32 | - /** |
|
| 33 | - * Returns the HTML string for insertion into the header. |
|
| 34 | - * |
|
| 35 | - * @param string $uid Unique identifier for the output if the content is placed more than once on the same page |
|
| 36 | - * @param array &$tags Result array for the list of tags that are associated to the output |
|
| 37 | - * @param string|null &$expire Result variable for the expiration date of the output (null for no expiry) |
|
| 38 | - * @return string|null String including HTML tags for the header on error |
|
| 39 | - */ |
|
| 40 | - public function getHeader( $uid = '', array &$tags = array(), &$expire = null ); |
|
| 32 | + /** |
|
| 33 | + * Returns the HTML string for insertion into the header. |
|
| 34 | + * |
|
| 35 | + * @param string $uid Unique identifier for the output if the content is placed more than once on the same page |
|
| 36 | + * @param array &$tags Result array for the list of tags that are associated to the output |
|
| 37 | + * @param string|null &$expire Result variable for the expiration date of the output (null for no expiry) |
|
| 38 | + * @return string|null String including HTML tags for the header on error |
|
| 39 | + */ |
|
| 40 | + public function getHeader( $uid = '', array &$tags = array(), &$expire = null ); |
|
| 41 | 41 | |
| 42 | - /** |
|
| 43 | - * Returns the HTML code for insertion into the body. |
|
| 44 | - * |
|
| 45 | - * @param string $uid Unique identifier for the output if the content is placed more than once on the same page |
|
| 46 | - * @param array &$tags Result array for the list of tags that are associated to the output |
|
| 47 | - * @param string|null &$expire Result variable for the expiration date of the output (null for no expiry) |
|
| 48 | - * @return string HTML code |
|
| 49 | - */ |
|
| 50 | - public function getBody( $uid = '', array &$tags = array(), &$expire = null ); |
|
| 42 | + /** |
|
| 43 | + * Returns the HTML code for insertion into the body. |
|
| 44 | + * |
|
| 45 | + * @param string $uid Unique identifier for the output if the content is placed more than once on the same page |
|
| 46 | + * @param array &$tags Result array for the list of tags that are associated to the output |
|
| 47 | + * @param string|null &$expire Result variable for the expiration date of the output (null for no expiry) |
|
| 48 | + * @return string HTML code |
|
| 49 | + */ |
|
| 50 | + public function getBody( $uid = '', array &$tags = array(), &$expire = null ); |
|
| 51 | 51 | |
| 52 | - /** |
|
| 53 | - * Returns the view object that will generate the HTML output. |
|
| 54 | - * |
|
| 55 | - * @return \Aimeos\MW\View\Iface $view The view object which generates the HTML output |
|
| 56 | - */ |
|
| 57 | - public function getView(); |
|
| 52 | + /** |
|
| 53 | + * Returns the view object that will generate the HTML output. |
|
| 54 | + * |
|
| 55 | + * @return \Aimeos\MW\View\Iface $view The view object which generates the HTML output |
|
| 56 | + */ |
|
| 57 | + public function getView(); |
|
| 58 | 58 | |
| 59 | - /** |
|
| 60 | - * Sets the view object that will generate the HTML output. |
|
| 61 | - * |
|
| 62 | - * @param \Aimeos\MW\View\Iface $view The view object which generates the HTML output |
|
| 63 | - * @return \Aimeos\Client\Html\Iface Reference to this object for fluent calls |
|
| 64 | - */ |
|
| 65 | - public function setView( \Aimeos\MW\View\Iface $view ); |
|
| 59 | + /** |
|
| 60 | + * Sets the view object that will generate the HTML output. |
|
| 61 | + * |
|
| 62 | + * @param \Aimeos\MW\View\Iface $view The view object which generates the HTML output |
|
| 63 | + * @return \Aimeos\Client\Html\Iface Reference to this object for fluent calls |
|
| 64 | + */ |
|
| 65 | + public function setView( \Aimeos\MW\View\Iface $view ); |
|
| 66 | 66 | |
| 67 | - /** |
|
| 68 | - * Modifies the cached body content to replace content based on sessions or cookies. |
|
| 69 | - * |
|
| 70 | - * @param string $content Cached content |
|
| 71 | - * @param string $uid Unique identifier for the output if the content is placed more than once on the same page |
|
| 72 | - * @return string Modified body content |
|
| 73 | - */ |
|
| 74 | - public function modifyBody( $content, $uid ); |
|
| 67 | + /** |
|
| 68 | + * Modifies the cached body content to replace content based on sessions or cookies. |
|
| 69 | + * |
|
| 70 | + * @param string $content Cached content |
|
| 71 | + * @param string $uid Unique identifier for the output if the content is placed more than once on the same page |
|
| 72 | + * @return string Modified body content |
|
| 73 | + */ |
|
| 74 | + public function modifyBody( $content, $uid ); |
|
| 75 | 75 | |
| 76 | - /** |
|
| 77 | - * Modifies the cached header content to replace content based on sessions or cookies. |
|
| 78 | - * |
|
| 79 | - * @param string $content Cached content |
|
| 80 | - * @param string $uid Unique identifier for the output if the content is placed more than once on the same page |
|
| 81 | - * @return string Modified header content |
|
| 82 | - */ |
|
| 83 | - public function modifyHeader( $content, $uid ); |
|
| 76 | + /** |
|
| 77 | + * Modifies the cached header content to replace content based on sessions or cookies. |
|
| 78 | + * |
|
| 79 | + * @param string $content Cached content |
|
| 80 | + * @param string $uid Unique identifier for the output if the content is placed more than once on the same page |
|
| 81 | + * @return string Modified header content |
|
| 82 | + */ |
|
| 83 | + public function modifyHeader( $content, $uid ); |
|
| 84 | 84 | |
| 85 | - /** |
|
| 86 | - * Processes the input, e.g. store given values. |
|
| 87 | - * A view must be available and this method doesn't generate any output |
|
| 88 | - * besides setting view variables. |
|
| 89 | - * |
|
| 90 | - * @return boolean False if processing is stopped, otherwise all processing was completed successfully |
|
| 91 | - */ |
|
| 92 | - public function process(); |
|
| 85 | + /** |
|
| 86 | + * Processes the input, e.g. store given values. |
|
| 87 | + * A view must be available and this method doesn't generate any output |
|
| 88 | + * besides setting view variables. |
|
| 89 | + * |
|
| 90 | + * @return boolean False if processing is stopped, otherwise all processing was completed successfully |
|
| 91 | + */ |
|
| 92 | + public function process(); |
|
| 93 | 93 | } |
@@ -19,253 +19,253 @@ |
||
| 19 | 19 | * @subpackage Html |
| 20 | 20 | */ |
| 21 | 21 | class Standard |
| 22 | - extends \Aimeos\Client\Html\Common\Client\Factory\Base |
|
| 23 | - implements \Aimeos\Client\Html\Common\Client\Factory\Iface |
|
| 22 | + extends \Aimeos\Client\Html\Common\Client\Factory\Base |
|
| 23 | + implements \Aimeos\Client\Html\Common\Client\Factory\Iface |
|
| 24 | 24 | { |
| 25 | - /** client/html/locale/select/currency/standard/subparts |
|
| 26 | - * List of HTML sub-clients rendered within the locale select currency section |
|
| 27 | - * |
|
| 28 | - * The output of the frontend is composed of the code generated by the HTML |
|
| 29 | - * clients. Each HTML client can consist of serveral (or none) sub-clients |
|
| 30 | - * that are responsible for rendering certain sub-parts of the output. The |
|
| 31 | - * sub-clients can contain HTML clients themselves and therefore a |
|
| 32 | - * hierarchical tree of HTML clients is composed. Each HTML client creates |
|
| 33 | - * the output that is placed inside the container of its parent. |
|
| 34 | - * |
|
| 35 | - * At first, always the HTML code generated by the parent is printed, then |
|
| 36 | - * the HTML code of its sub-clients. The order of the HTML sub-clients |
|
| 37 | - * determines the order of the output of these sub-clients inside the parent |
|
| 38 | - * container. If the configured list of clients is |
|
| 39 | - * |
|
| 40 | - * array( "subclient1", "subclient2" ) |
|
| 41 | - * |
|
| 42 | - * you can easily change the order of the output by reordering the subparts: |
|
| 43 | - * |
|
| 44 | - * client/html/<clients>/subparts = array( "subclient1", "subclient2" ) |
|
| 45 | - * |
|
| 46 | - * You can also remove one or more parts if they shouldn't be rendered: |
|
| 47 | - * |
|
| 48 | - * client/html/<clients>/subparts = array( "subclient1" ) |
|
| 49 | - * |
|
| 50 | - * As the clients only generates structural HTML, the layout defined via CSS |
|
| 51 | - * should support adding, removing or reordering content by a fluid like |
|
| 52 | - * design. |
|
| 53 | - * |
|
| 54 | - * @param array List of sub-client names |
|
| 55 | - * @since 2014.09 |
|
| 56 | - * @category Developer |
|
| 57 | - */ |
|
| 58 | - private $subPartPath = 'client/html/locale/select/currency/standard/subparts'; |
|
| 59 | - private $subPartNames = array(); |
|
| 25 | + /** client/html/locale/select/currency/standard/subparts |
|
| 26 | + * List of HTML sub-clients rendered within the locale select currency section |
|
| 27 | + * |
|
| 28 | + * The output of the frontend is composed of the code generated by the HTML |
|
| 29 | + * clients. Each HTML client can consist of serveral (or none) sub-clients |
|
| 30 | + * that are responsible for rendering certain sub-parts of the output. The |
|
| 31 | + * sub-clients can contain HTML clients themselves and therefore a |
|
| 32 | + * hierarchical tree of HTML clients is composed. Each HTML client creates |
|
| 33 | + * the output that is placed inside the container of its parent. |
|
| 34 | + * |
|
| 35 | + * At first, always the HTML code generated by the parent is printed, then |
|
| 36 | + * the HTML code of its sub-clients. The order of the HTML sub-clients |
|
| 37 | + * determines the order of the output of these sub-clients inside the parent |
|
| 38 | + * container. If the configured list of clients is |
|
| 39 | + * |
|
| 40 | + * array( "subclient1", "subclient2" ) |
|
| 41 | + * |
|
| 42 | + * you can easily change the order of the output by reordering the subparts: |
|
| 43 | + * |
|
| 44 | + * client/html/<clients>/subparts = array( "subclient1", "subclient2" ) |
|
| 45 | + * |
|
| 46 | + * You can also remove one or more parts if they shouldn't be rendered: |
|
| 47 | + * |
|
| 48 | + * client/html/<clients>/subparts = array( "subclient1" ) |
|
| 49 | + * |
|
| 50 | + * As the clients only generates structural HTML, the layout defined via CSS |
|
| 51 | + * should support adding, removing or reordering content by a fluid like |
|
| 52 | + * design. |
|
| 53 | + * |
|
| 54 | + * @param array List of sub-client names |
|
| 55 | + * @since 2014.09 |
|
| 56 | + * @category Developer |
|
| 57 | + */ |
|
| 58 | + private $subPartPath = 'client/html/locale/select/currency/standard/subparts'; |
|
| 59 | + private $subPartNames = array(); |
|
| 60 | 60 | |
| 61 | 61 | |
| 62 | - /** |
|
| 63 | - * Returns the HTML code for insertion into the body. |
|
| 64 | - * |
|
| 65 | - * @param string $uid Unique identifier for the output if the content is placed more than once on the same page |
|
| 66 | - * @param array &$tags Result array for the list of tags that are associated to the output |
|
| 67 | - * @param string|null &$expire Result variable for the expiration date of the output (null for no expiry) |
|
| 68 | - * @return string HTML code |
|
| 69 | - */ |
|
| 70 | - public function getBody( $uid = '', array &$tags = array(), &$expire = null ) |
|
| 71 | - { |
|
| 72 | - $view = $this->setViewParams( $this->getView(), $tags, $expire ); |
|
| 62 | + /** |
|
| 63 | + * Returns the HTML code for insertion into the body. |
|
| 64 | + * |
|
| 65 | + * @param string $uid Unique identifier for the output if the content is placed more than once on the same page |
|
| 66 | + * @param array &$tags Result array for the list of tags that are associated to the output |
|
| 67 | + * @param string|null &$expire Result variable for the expiration date of the output (null for no expiry) |
|
| 68 | + * @return string HTML code |
|
| 69 | + */ |
|
| 70 | + public function getBody( $uid = '', array &$tags = array(), &$expire = null ) |
|
| 71 | + { |
|
| 72 | + $view = $this->setViewParams( $this->getView(), $tags, $expire ); |
|
| 73 | 73 | |
| 74 | - $html = ''; |
|
| 75 | - foreach( $this->getSubClients() as $subclient ) { |
|
| 76 | - $html .= $subclient->setView( $view )->getBody( $uid, $tags, $expire ); |
|
| 77 | - } |
|
| 78 | - $view->currencyBody = $html; |
|
| 74 | + $html = ''; |
|
| 75 | + foreach( $this->getSubClients() as $subclient ) { |
|
| 76 | + $html .= $subclient->setView( $view )->getBody( $uid, $tags, $expire ); |
|
| 77 | + } |
|
| 78 | + $view->currencyBody = $html; |
|
| 79 | 79 | |
| 80 | - /** client/html/locale/select/currency/standard/template-body |
|
| 81 | - * Relative path to the HTML body template of the locale select currency client. |
|
| 82 | - * |
|
| 83 | - * The template file contains the HTML code and processing instructions |
|
| 84 | - * to generate the result shown in the body of the frontend. The |
|
| 85 | - * configuration string is the path to the template file relative |
|
| 86 | - * to the templates directory (usually in client/html/templates). |
|
| 87 | - * |
|
| 88 | - * You can overwrite the template file configuration in extensions and |
|
| 89 | - * provide alternative templates. These alternative templates should be |
|
| 90 | - * named like the default one but with the string "standard" replaced by |
|
| 91 | - * an unique name. You may use the name of your project for this. If |
|
| 92 | - * you've implemented an alternative client class as well, "standard" |
|
| 93 | - * should be replaced by the name of the new class. |
|
| 94 | - * |
|
| 95 | - * @param string Relative path to the template creating code for the HTML page body |
|
| 96 | - * @since 2014.09 |
|
| 97 | - * @category Developer |
|
| 98 | - * @see client/html/locale/select/currency/standard/template-header |
|
| 99 | - */ |
|
| 100 | - $tplconf = 'client/html/locale/select/currency/standard/template-body'; |
|
| 101 | - $default = 'locale/select/currency-body-default.php'; |
|
| 80 | + /** client/html/locale/select/currency/standard/template-body |
|
| 81 | + * Relative path to the HTML body template of the locale select currency client. |
|
| 82 | + * |
|
| 83 | + * The template file contains the HTML code and processing instructions |
|
| 84 | + * to generate the result shown in the body of the frontend. The |
|
| 85 | + * configuration string is the path to the template file relative |
|
| 86 | + * to the templates directory (usually in client/html/templates). |
|
| 87 | + * |
|
| 88 | + * You can overwrite the template file configuration in extensions and |
|
| 89 | + * provide alternative templates. These alternative templates should be |
|
| 90 | + * named like the default one but with the string "standard" replaced by |
|
| 91 | + * an unique name. You may use the name of your project for this. If |
|
| 92 | + * you've implemented an alternative client class as well, "standard" |
|
| 93 | + * should be replaced by the name of the new class. |
|
| 94 | + * |
|
| 95 | + * @param string Relative path to the template creating code for the HTML page body |
|
| 96 | + * @since 2014.09 |
|
| 97 | + * @category Developer |
|
| 98 | + * @see client/html/locale/select/currency/standard/template-header |
|
| 99 | + */ |
|
| 100 | + $tplconf = 'client/html/locale/select/currency/standard/template-body'; |
|
| 101 | + $default = 'locale/select/currency-body-default.php'; |
|
| 102 | 102 | |
| 103 | - return $view->render( $view->config( $tplconf, $default ) ); |
|
| 104 | - } |
|
| 103 | + return $view->render( $view->config( $tplconf, $default ) ); |
|
| 104 | + } |
|
| 105 | 105 | |
| 106 | 106 | |
| 107 | - /** |
|
| 108 | - * Returns the HTML string for insertion into the header. |
|
| 109 | - * |
|
| 110 | - * @param string $uid Unique identifier for the output if the content is placed more than once on the same page |
|
| 111 | - * @param array &$tags Result array for the list of tags that are associated to the output |
|
| 112 | - * @param string|null &$expire Result variable for the expiration date of the output (null for no expiry) |
|
| 113 | - * @return string|null String including HTML tags for the header on error |
|
| 114 | - */ |
|
| 115 | - public function getHeader( $uid = '', array &$tags = array(), &$expire = null ) |
|
| 116 | - { |
|
| 117 | - $view = $this->setViewParams( $this->getView(), $tags, $expire ); |
|
| 107 | + /** |
|
| 108 | + * Returns the HTML string for insertion into the header. |
|
| 109 | + * |
|
| 110 | + * @param string $uid Unique identifier for the output if the content is placed more than once on the same page |
|
| 111 | + * @param array &$tags Result array for the list of tags that are associated to the output |
|
| 112 | + * @param string|null &$expire Result variable for the expiration date of the output (null for no expiry) |
|
| 113 | + * @return string|null String including HTML tags for the header on error |
|
| 114 | + */ |
|
| 115 | + public function getHeader( $uid = '', array &$tags = array(), &$expire = null ) |
|
| 116 | + { |
|
| 117 | + $view = $this->setViewParams( $this->getView(), $tags, $expire ); |
|
| 118 | 118 | |
| 119 | - $html = ''; |
|
| 120 | - foreach( $this->getSubClients() as $subclient ) { |
|
| 121 | - $html .= $subclient->setView( $view )->getHeader( $uid, $tags, $expire ); |
|
| 122 | - } |
|
| 123 | - $view->currencyHeader = $html; |
|
| 119 | + $html = ''; |
|
| 120 | + foreach( $this->getSubClients() as $subclient ) { |
|
| 121 | + $html .= $subclient->setView( $view )->getHeader( $uid, $tags, $expire ); |
|
| 122 | + } |
|
| 123 | + $view->currencyHeader = $html; |
|
| 124 | 124 | |
| 125 | - /** client/html/locale/select/currency/standard/template-header |
|
| 126 | - * Relative path to the HTML header template of the locale select currency client. |
|
| 127 | - * |
|
| 128 | - * The template file contains the HTML code and processing instructions |
|
| 129 | - * to generate the HTML code that is inserted into the HTML page header |
|
| 130 | - * of the rendered page in the frontend. The configuration string is the |
|
| 131 | - * path to the template file relative to the templates directory (usually |
|
| 132 | - * in client/html/templates). |
|
| 133 | - * |
|
| 134 | - * You can overwrite the template file configuration in extensions and |
|
| 135 | - * provide alternative templates. These alternative templates should be |
|
| 136 | - * named like the default one but with the string "standard" replaced by |
|
| 137 | - * an unique name. You may use the name of your project for this. If |
|
| 138 | - * you've implemented an alternative client class as well, "standard" |
|
| 139 | - * should be replaced by the name of the new class. |
|
| 140 | - * |
|
| 141 | - * @param string Relative path to the template creating code for the HTML page head |
|
| 142 | - * @since 2014.09 |
|
| 143 | - * @category Developer |
|
| 144 | - * @see client/html/locale/select/currency/standard/template-body |
|
| 145 | - */ |
|
| 146 | - $tplconf = 'client/html/locale/select/currency/standard/template-header'; |
|
| 147 | - $default = 'locale/select/currency-header-default.php'; |
|
| 125 | + /** client/html/locale/select/currency/standard/template-header |
|
| 126 | + * Relative path to the HTML header template of the locale select currency client. |
|
| 127 | + * |
|
| 128 | + * The template file contains the HTML code and processing instructions |
|
| 129 | + * to generate the HTML code that is inserted into the HTML page header |
|
| 130 | + * of the rendered page in the frontend. The configuration string is the |
|
| 131 | + * path to the template file relative to the templates directory (usually |
|
| 132 | + * in client/html/templates). |
|
| 133 | + * |
|
| 134 | + * You can overwrite the template file configuration in extensions and |
|
| 135 | + * provide alternative templates. These alternative templates should be |
|
| 136 | + * named like the default one but with the string "standard" replaced by |
|
| 137 | + * an unique name. You may use the name of your project for this. If |
|
| 138 | + * you've implemented an alternative client class as well, "standard" |
|
| 139 | + * should be replaced by the name of the new class. |
|
| 140 | + * |
|
| 141 | + * @param string Relative path to the template creating code for the HTML page head |
|
| 142 | + * @since 2014.09 |
|
| 143 | + * @category Developer |
|
| 144 | + * @see client/html/locale/select/currency/standard/template-body |
|
| 145 | + */ |
|
| 146 | + $tplconf = 'client/html/locale/select/currency/standard/template-header'; |
|
| 147 | + $default = 'locale/select/currency-header-default.php'; |
|
| 148 | 148 | |
| 149 | - return $view->render( $view->config( $tplconf, $default ) ); |
|
| 150 | - } |
|
| 149 | + return $view->render( $view->config( $tplconf, $default ) ); |
|
| 150 | + } |
|
| 151 | 151 | |
| 152 | 152 | |
| 153 | - /** |
|
| 154 | - * Returns the sub-client given by its name. |
|
| 155 | - * |
|
| 156 | - * @param string $type Name of the client type |
|
| 157 | - * @param string|null $name Name of the sub-client (Default if null) |
|
| 158 | - * @return \Aimeos\Client\Html\Iface Sub-client object |
|
| 159 | - */ |
|
| 160 | - public function getSubClient( $type, $name = null ) |
|
| 161 | - { |
|
| 162 | - /** client/html/locale/select/currency/decorators/excludes |
|
| 163 | - * Excludes decorators added by the "common" option from the locale select currency html client |
|
| 164 | - * |
|
| 165 | - * Decorators extend the functionality of a class by adding new aspects |
|
| 166 | - * (e.g. log what is currently done), executing the methods of the underlying |
|
| 167 | - * class only in certain conditions (e.g. only for logged in users) or |
|
| 168 | - * modify what is returned to the caller. |
|
| 169 | - * |
|
| 170 | - * This option allows you to remove a decorator added via |
|
| 171 | - * "client/html/common/decorators/default" before they are wrapped |
|
| 172 | - * around the html client. |
|
| 173 | - * |
|
| 174 | - * client/html/locale/select/currency/decorators/excludes = array( 'decorator1' ) |
|
| 175 | - * |
|
| 176 | - * This would remove the decorator named "decorator1" from the list of |
|
| 177 | - * common decorators ("\Aimeos\Client\Html\Common\Decorator\*") added via |
|
| 178 | - * "client/html/common/decorators/default" to the html client. |
|
| 179 | - * |
|
| 180 | - * @param array List of decorator names |
|
| 181 | - * @since 2015.08 |
|
| 182 | - * @category Developer |
|
| 183 | - * @see client/html/common/decorators/default |
|
| 184 | - * @see client/html/locale/select/currency/decorators/global |
|
| 185 | - * @see client/html/locale/select/currency/decorators/local |
|
| 186 | - */ |
|
| 153 | + /** |
|
| 154 | + * Returns the sub-client given by its name. |
|
| 155 | + * |
|
| 156 | + * @param string $type Name of the client type |
|
| 157 | + * @param string|null $name Name of the sub-client (Default if null) |
|
| 158 | + * @return \Aimeos\Client\Html\Iface Sub-client object |
|
| 159 | + */ |
|
| 160 | + public function getSubClient( $type, $name = null ) |
|
| 161 | + { |
|
| 162 | + /** client/html/locale/select/currency/decorators/excludes |
|
| 163 | + * Excludes decorators added by the "common" option from the locale select currency html client |
|
| 164 | + * |
|
| 165 | + * Decorators extend the functionality of a class by adding new aspects |
|
| 166 | + * (e.g. log what is currently done), executing the methods of the underlying |
|
| 167 | + * class only in certain conditions (e.g. only for logged in users) or |
|
| 168 | + * modify what is returned to the caller. |
|
| 169 | + * |
|
| 170 | + * This option allows you to remove a decorator added via |
|
| 171 | + * "client/html/common/decorators/default" before they are wrapped |
|
| 172 | + * around the html client. |
|
| 173 | + * |
|
| 174 | + * client/html/locale/select/currency/decorators/excludes = array( 'decorator1' ) |
|
| 175 | + * |
|
| 176 | + * This would remove the decorator named "decorator1" from the list of |
|
| 177 | + * common decorators ("\Aimeos\Client\Html\Common\Decorator\*") added via |
|
| 178 | + * "client/html/common/decorators/default" to the html client. |
|
| 179 | + * |
|
| 180 | + * @param array List of decorator names |
|
| 181 | + * @since 2015.08 |
|
| 182 | + * @category Developer |
|
| 183 | + * @see client/html/common/decorators/default |
|
| 184 | + * @see client/html/locale/select/currency/decorators/global |
|
| 185 | + * @see client/html/locale/select/currency/decorators/local |
|
| 186 | + */ |
|
| 187 | 187 | |
| 188 | - /** client/html/locale/select/currency/decorators/global |
|
| 189 | - * Adds a list of globally available decorators only to the locale select currency html client |
|
| 190 | - * |
|
| 191 | - * Decorators extend the functionality of a class by adding new aspects |
|
| 192 | - * (e.g. log what is currently done), executing the methods of the underlying |
|
| 193 | - * class only in certain conditions (e.g. only for logged in users) or |
|
| 194 | - * modify what is returned to the caller. |
|
| 195 | - * |
|
| 196 | - * This option allows you to wrap global decorators |
|
| 197 | - * ("\Aimeos\Client\Html\Common\Decorator\*") around the html client. |
|
| 198 | - * |
|
| 199 | - * client/html/locale/select/currency/decorators/global = array( 'decorator1' ) |
|
| 200 | - * |
|
| 201 | - * This would add the decorator named "decorator1" defined by |
|
| 202 | - * "\Aimeos\Client\Html\Common\Decorator\Decorator1" only to the html client. |
|
| 203 | - * |
|
| 204 | - * @param array List of decorator names |
|
| 205 | - * @since 2015.08 |
|
| 206 | - * @category Developer |
|
| 207 | - * @see client/html/common/decorators/default |
|
| 208 | - * @see client/html/locale/select/currency/decorators/excludes |
|
| 209 | - * @see client/html/locale/select/currency/decorators/local |
|
| 210 | - */ |
|
| 188 | + /** client/html/locale/select/currency/decorators/global |
|
| 189 | + * Adds a list of globally available decorators only to the locale select currency html client |
|
| 190 | + * |
|
| 191 | + * Decorators extend the functionality of a class by adding new aspects |
|
| 192 | + * (e.g. log what is currently done), executing the methods of the underlying |
|
| 193 | + * class only in certain conditions (e.g. only for logged in users) or |
|
| 194 | + * modify what is returned to the caller. |
|
| 195 | + * |
|
| 196 | + * This option allows you to wrap global decorators |
|
| 197 | + * ("\Aimeos\Client\Html\Common\Decorator\*") around the html client. |
|
| 198 | + * |
|
| 199 | + * client/html/locale/select/currency/decorators/global = array( 'decorator1' ) |
|
| 200 | + * |
|
| 201 | + * This would add the decorator named "decorator1" defined by |
|
| 202 | + * "\Aimeos\Client\Html\Common\Decorator\Decorator1" only to the html client. |
|
| 203 | + * |
|
| 204 | + * @param array List of decorator names |
|
| 205 | + * @since 2015.08 |
|
| 206 | + * @category Developer |
|
| 207 | + * @see client/html/common/decorators/default |
|
| 208 | + * @see client/html/locale/select/currency/decorators/excludes |
|
| 209 | + * @see client/html/locale/select/currency/decorators/local |
|
| 210 | + */ |
|
| 211 | 211 | |
| 212 | - /** client/html/locale/select/currency/decorators/local |
|
| 213 | - * Adds a list of local decorators only to the locale select currency html client |
|
| 214 | - * |
|
| 215 | - * Decorators extend the functionality of a class by adding new aspects |
|
| 216 | - * (e.g. log what is currently done), executing the methods of the underlying |
|
| 217 | - * class only in certain conditions (e.g. only for logged in users) or |
|
| 218 | - * modify what is returned to the caller. |
|
| 219 | - * |
|
| 220 | - * This option allows you to wrap local decorators |
|
| 221 | - * ("\Aimeos\Client\Html\Checkout\Decorator\*") around the html client. |
|
| 222 | - * |
|
| 223 | - * client/html/locale/select/currency/decorators/local = array( 'decorator2' ) |
|
| 224 | - * |
|
| 225 | - * This would add the decorator named "decorator2" defined by |
|
| 226 | - * "\Aimeos\Client\Html\Checkout\Decorator\Decorator2" only to the html client. |
|
| 227 | - * |
|
| 228 | - * @param array List of decorator names |
|
| 229 | - * @since 2015.08 |
|
| 230 | - * @category Developer |
|
| 231 | - * @see client/html/common/decorators/default |
|
| 232 | - * @see client/html/locale/select/currency/decorators/excludes |
|
| 233 | - * @see client/html/locale/select/currency/decorators/global |
|
| 234 | - */ |
|
| 212 | + /** client/html/locale/select/currency/decorators/local |
|
| 213 | + * Adds a list of local decorators only to the locale select currency html client |
|
| 214 | + * |
|
| 215 | + * Decorators extend the functionality of a class by adding new aspects |
|
| 216 | + * (e.g. log what is currently done), executing the methods of the underlying |
|
| 217 | + * class only in certain conditions (e.g. only for logged in users) or |
|
| 218 | + * modify what is returned to the caller. |
|
| 219 | + * |
|
| 220 | + * This option allows you to wrap local decorators |
|
| 221 | + * ("\Aimeos\Client\Html\Checkout\Decorator\*") around the html client. |
|
| 222 | + * |
|
| 223 | + * client/html/locale/select/currency/decorators/local = array( 'decorator2' ) |
|
| 224 | + * |
|
| 225 | + * This would add the decorator named "decorator2" defined by |
|
| 226 | + * "\Aimeos\Client\Html\Checkout\Decorator\Decorator2" only to the html client. |
|
| 227 | + * |
|
| 228 | + * @param array List of decorator names |
|
| 229 | + * @since 2015.08 |
|
| 230 | + * @category Developer |
|
| 231 | + * @see client/html/common/decorators/default |
|
| 232 | + * @see client/html/locale/select/currency/decorators/excludes |
|
| 233 | + * @see client/html/locale/select/currency/decorators/global |
|
| 234 | + */ |
|
| 235 | 235 | |
| 236 | - return $this->createSubClient( 'locale/select/currency/' . $type, $name ); |
|
| 237 | - } |
|
| 236 | + return $this->createSubClient( 'locale/select/currency/' . $type, $name ); |
|
| 237 | + } |
|
| 238 | 238 | |
| 239 | 239 | |
| 240 | - /** |
|
| 241 | - * Processes the input, e.g. store given values. |
|
| 242 | - * A view must be available and this method doesn't generate any output |
|
| 243 | - * besides setting view variables. |
|
| 244 | - */ |
|
| 245 | - public function process() |
|
| 246 | - { |
|
| 247 | - $view = $this->getView(); |
|
| 248 | - $context = $this->getContext(); |
|
| 249 | - $config = $context->getConfig(); |
|
| 250 | - $session = $context->getSession(); |
|
| 240 | + /** |
|
| 241 | + * Processes the input, e.g. store given values. |
|
| 242 | + * A view must be available and this method doesn't generate any output |
|
| 243 | + * besides setting view variables. |
|
| 244 | + */ |
|
| 245 | + public function process() |
|
| 246 | + { |
|
| 247 | + $view = $this->getView(); |
|
| 248 | + $context = $this->getContext(); |
|
| 249 | + $config = $context->getConfig(); |
|
| 250 | + $session = $context->getSession(); |
|
| 251 | 251 | |
| 252 | - $name = $config->get( 'client/html/locale/select/currency/param-name', 'loc_currencyid' ); |
|
| 252 | + $name = $config->get( 'client/html/locale/select/currency/param-name', 'loc_currencyid' ); |
|
| 253 | 253 | |
| 254 | - if( ( $currencyId = $view->param( $name ) ) !== null ) { |
|
| 255 | - $session->set( 'aimeos/locale/currencyId', $currencyId ); |
|
| 256 | - } |
|
| 254 | + if( ( $currencyId = $view->param( $name ) ) !== null ) { |
|
| 255 | + $session->set( 'aimeos/locale/currencyId', $currencyId ); |
|
| 256 | + } |
|
| 257 | 257 | |
| 258 | - parent::process(); |
|
| 259 | - } |
|
| 258 | + parent::process(); |
|
| 259 | + } |
|
| 260 | 260 | |
| 261 | 261 | |
| 262 | - /** |
|
| 263 | - * Returns the list of sub-client names configured for the client. |
|
| 264 | - * |
|
| 265 | - * @return array List of HTML client names |
|
| 266 | - */ |
|
| 267 | - protected function getSubClientNames() |
|
| 268 | - { |
|
| 269 | - return $this->getContext()->getConfig()->get( $this->subPartPath, $this->subPartNames ); |
|
| 270 | - } |
|
| 262 | + /** |
|
| 263 | + * Returns the list of sub-client names configured for the client. |
|
| 264 | + * |
|
| 265 | + * @return array List of HTML client names |
|
| 266 | + */ |
|
| 267 | + protected function getSubClientNames() |
|
| 268 | + { |
|
| 269 | + return $this->getContext()->getConfig()->get( $this->subPartPath, $this->subPartNames ); |
|
| 270 | + } |
|
| 271 | 271 | } |
| 272 | 272 | \ No newline at end of file |
@@ -19,68 +19,68 @@ |
||
| 19 | 19 | * @subpackage Html |
| 20 | 20 | */ |
| 21 | 21 | class Factory |
| 22 | - extends \Aimeos\Client\Html\Common\Factory\Base |
|
| 23 | - implements \Aimeos\Client\Html\Common\Factory\Iface |
|
| 22 | + extends \Aimeos\Client\Html\Common\Factory\Base |
|
| 23 | + implements \Aimeos\Client\Html\Common\Factory\Iface |
|
| 24 | 24 | { |
| 25 | - /** |
|
| 26 | - * Creates a locale select client object. |
|
| 27 | - * |
|
| 28 | - * @param \Aimeos\MShop\Context\Item\Iface $context Shop context instance with necessary objects |
|
| 29 | - * @param array $templatePaths List of file system paths where the templates are stored |
|
| 30 | - * @param string|null $name Client name (default: "Standard") |
|
| 31 | - * @return \Aimeos\Client\Html\Iface Filter part implementing \Aimeos\Client\Html\Iface |
|
| 32 | - * @throws \Aimeos\Client\Html\Exception If requested client implementation couldn't be found or initialisation fails |
|
| 33 | - */ |
|
| 34 | - public static function createClient( \Aimeos\MShop\Context\Item\Iface $context, array $templatePaths, $name = null ) |
|
| 35 | - { |
|
| 36 | - /** client/html/locale/select/name |
|
| 37 | - * Class name of the used locale select client implementation |
|
| 38 | - * |
|
| 39 | - * Each default HTML client can be replace by an alternative imlementation. |
|
| 40 | - * To use this implementation, you have to set the last part of the class |
|
| 41 | - * name as configuration value so the client factory knows which class it |
|
| 42 | - * has to instantiate. |
|
| 43 | - * |
|
| 44 | - * For example, if the name of the default class is |
|
| 45 | - * |
|
| 46 | - * \Aimeos\Client\Html\Locale\Select\Standard |
|
| 47 | - * |
|
| 48 | - * and you want to replace it with your own version named |
|
| 49 | - * |
|
| 50 | - * \Aimeos\Client\Html\Locale\Select\Myselect |
|
| 51 | - * |
|
| 52 | - * then you have to set the this configuration option: |
|
| 53 | - * |
|
| 54 | - * client/html/locale/select/name = Myselect |
|
| 55 | - * |
|
| 56 | - * The value is the last part of your own class name and it's case sensitive, |
|
| 57 | - * so take care that the configuration value is exactly named like the last |
|
| 58 | - * part of the class name. |
|
| 59 | - * |
|
| 60 | - * The allowed characters of the class name are A-Z, a-z and 0-9. No other |
|
| 61 | - * characters are possible! You should always start the last part of the class |
|
| 62 | - * name with an upper case character and continue only with lower case characters |
|
| 63 | - * or numbers. Avoid chamel case names like "MySelect"! |
|
| 64 | - * |
|
| 65 | - * @param string Last part of the class name |
|
| 66 | - * @since 2014.03 |
|
| 67 | - * @category Developer |
|
| 68 | - */ |
|
| 69 | - if( $name === null ) { |
|
| 70 | - $name = $context->getConfig()->get( 'client/html/locale/select/name', 'Standard' ); |
|
| 71 | - } |
|
| 25 | + /** |
|
| 26 | + * Creates a locale select client object. |
|
| 27 | + * |
|
| 28 | + * @param \Aimeos\MShop\Context\Item\Iface $context Shop context instance with necessary objects |
|
| 29 | + * @param array $templatePaths List of file system paths where the templates are stored |
|
| 30 | + * @param string|null $name Client name (default: "Standard") |
|
| 31 | + * @return \Aimeos\Client\Html\Iface Filter part implementing \Aimeos\Client\Html\Iface |
|
| 32 | + * @throws \Aimeos\Client\Html\Exception If requested client implementation couldn't be found or initialisation fails |
|
| 33 | + */ |
|
| 34 | + public static function createClient( \Aimeos\MShop\Context\Item\Iface $context, array $templatePaths, $name = null ) |
|
| 35 | + { |
|
| 36 | + /** client/html/locale/select/name |
|
| 37 | + * Class name of the used locale select client implementation |
|
| 38 | + * |
|
| 39 | + * Each default HTML client can be replace by an alternative imlementation. |
|
| 40 | + * To use this implementation, you have to set the last part of the class |
|
| 41 | + * name as configuration value so the client factory knows which class it |
|
| 42 | + * has to instantiate. |
|
| 43 | + * |
|
| 44 | + * For example, if the name of the default class is |
|
| 45 | + * |
|
| 46 | + * \Aimeos\Client\Html\Locale\Select\Standard |
|
| 47 | + * |
|
| 48 | + * and you want to replace it with your own version named |
|
| 49 | + * |
|
| 50 | + * \Aimeos\Client\Html\Locale\Select\Myselect |
|
| 51 | + * |
|
| 52 | + * then you have to set the this configuration option: |
|
| 53 | + * |
|
| 54 | + * client/html/locale/select/name = Myselect |
|
| 55 | + * |
|
| 56 | + * The value is the last part of your own class name and it's case sensitive, |
|
| 57 | + * so take care that the configuration value is exactly named like the last |
|
| 58 | + * part of the class name. |
|
| 59 | + * |
|
| 60 | + * The allowed characters of the class name are A-Z, a-z and 0-9. No other |
|
| 61 | + * characters are possible! You should always start the last part of the class |
|
| 62 | + * name with an upper case character and continue only with lower case characters |
|
| 63 | + * or numbers. Avoid chamel case names like "MySelect"! |
|
| 64 | + * |
|
| 65 | + * @param string Last part of the class name |
|
| 66 | + * @since 2014.03 |
|
| 67 | + * @category Developer |
|
| 68 | + */ |
|
| 69 | + if( $name === null ) { |
|
| 70 | + $name = $context->getConfig()->get( 'client/html/locale/select/name', 'Standard' ); |
|
| 71 | + } |
|
| 72 | 72 | |
| 73 | - if( ctype_alnum( $name ) === false ) |
|
| 74 | - { |
|
| 75 | - $classname = is_string( $name ) ? '\\Aimeos\\Client\\Html\\Locale\\Select\\' . $name : '<not a string>'; |
|
| 76 | - throw new \Aimeos\Client\Html\Exception( sprintf( 'Invalid characters in class name "%1$s"', $classname ) ); |
|
| 77 | - } |
|
| 73 | + if( ctype_alnum( $name ) === false ) |
|
| 74 | + { |
|
| 75 | + $classname = is_string( $name ) ? '\\Aimeos\\Client\\Html\\Locale\\Select\\' . $name : '<not a string>'; |
|
| 76 | + throw new \Aimeos\Client\Html\Exception( sprintf( 'Invalid characters in class name "%1$s"', $classname ) ); |
|
| 77 | + } |
|
| 78 | 78 | |
| 79 | - $iface = '\\Aimeos\\Client\\Html\\Iface'; |
|
| 80 | - $classname = '\\Aimeos\\Client\\Html\\Locale\\Select\\' . $name; |
|
| 79 | + $iface = '\\Aimeos\\Client\\Html\\Iface'; |
|
| 80 | + $classname = '\\Aimeos\\Client\\Html\\Locale\\Select\\' . $name; |
|
| 81 | 81 | |
| 82 | - $client = self::createClientBase( $context, $classname, $iface, $templatePaths ); |
|
| 82 | + $client = self::createClientBase( $context, $classname, $iface, $templatePaths ); |
|
| 83 | 83 | |
| 84 | - return self::addClientDecorators( $context, $client, $templatePaths, 'locale/select' ); |
|
| 85 | - } |
|
| 84 | + return self::addClientDecorators( $context, $client, $templatePaths, 'locale/select' ); |
|
| 85 | + } |
|
| 86 | 86 | } |
| 87 | 87 | \ No newline at end of file |
@@ -19,360 +19,360 @@ |
||
| 19 | 19 | * @subpackage Html |
| 20 | 20 | */ |
| 21 | 21 | class Standard |
| 22 | - extends \Aimeos\Client\Html\Common\Client\Factory\Base |
|
| 23 | - implements \Aimeos\Client\Html\Common\Client\Factory\Iface |
|
| 22 | + extends \Aimeos\Client\Html\Common\Client\Factory\Base |
|
| 23 | + implements \Aimeos\Client\Html\Common\Client\Factory\Iface |
|
| 24 | 24 | { |
| 25 | - /** client/html/locale/select/standard/subparts |
|
| 26 | - * List of HTML sub-clients rendered within the locale select section |
|
| 27 | - * |
|
| 28 | - * The output of the frontend is composed of the code generated by the HTML |
|
| 29 | - * clients. Each HTML client can consist of serveral (or none) sub-clients |
|
| 30 | - * that are responsible for rendering certain sub-parts of the output. The |
|
| 31 | - * sub-clients can contain HTML clients themselves and therefore a |
|
| 32 | - * hierarchical tree of HTML clients is composed. Each HTML client creates |
|
| 33 | - * the output that is placed inside the container of its parent. |
|
| 34 | - * |
|
| 35 | - * At first, always the HTML code generated by the parent is printed, then |
|
| 36 | - * the HTML code of its sub-clients. The order of the HTML sub-clients |
|
| 37 | - * determines the order of the output of these sub-clients inside the parent |
|
| 38 | - * container. If the configured list of clients is |
|
| 39 | - * |
|
| 40 | - * array( "subclient1", "subclient2" ) |
|
| 41 | - * |
|
| 42 | - * you can easily change the order of the output by reordering the subparts: |
|
| 43 | - * |
|
| 44 | - * client/html/<clients>/subparts = array( "subclient1", "subclient2" ) |
|
| 45 | - * |
|
| 46 | - * You can also remove one or more parts if they shouldn't be rendered: |
|
| 47 | - * |
|
| 48 | - * client/html/<clients>/subparts = array( "subclient1" ) |
|
| 49 | - * |
|
| 50 | - * As the clients only generates structural HTML, the layout defined via CSS |
|
| 51 | - * should support adding, removing or reordering content by a fluid like |
|
| 52 | - * design. |
|
| 53 | - * |
|
| 54 | - * @param array List of sub-client names |
|
| 55 | - * @since 2014.09 |
|
| 56 | - * @category Developer |
|
| 57 | - */ |
|
| 58 | - private $subPartPath = 'client/html/locale/select/standard/subparts'; |
|
| 59 | - |
|
| 60 | - /** client/html/locale/select/language/name |
|
| 61 | - * Name of the language part used by the locale selector client implementation |
|
| 62 | - * |
|
| 63 | - * Use "Myname" if your class is named "\Aimeos\Client\Html\Locale\Select\Language\Myname". |
|
| 64 | - * The name is case-sensitive and you should avoid camel case names like "MyName". |
|
| 65 | - * |
|
| 66 | - * @param string Last part of the client class name |
|
| 67 | - * @since 2014.09 |
|
| 68 | - * @category Developer |
|
| 69 | - */ |
|
| 70 | - |
|
| 71 | - /** client/html/locale/select/currency/name |
|
| 72 | - * Name of the currency part used by the locale selector client implementation |
|
| 73 | - * |
|
| 74 | - * Use "Myname" if your class is named "\Aimeos\Client\Html\Locale\Select\Currency\Myname". |
|
| 75 | - * The name is case-sensitive and you should avoid camel case names like "MyName". |
|
| 76 | - * |
|
| 77 | - * @param string Last part of the client class name |
|
| 78 | - * @since 2014.09 |
|
| 79 | - * @category Developer |
|
| 80 | - */ |
|
| 81 | - private $subPartNames = array( 'language', 'currency' ); |
|
| 82 | - private $cache; |
|
| 83 | - |
|
| 84 | - |
|
| 85 | - /** |
|
| 86 | - * Returns the HTML code for insertion into the body. |
|
| 87 | - * |
|
| 88 | - * @param string $uid Unique identifier for the output if the content is placed more than once on the same page |
|
| 89 | - * @param array &$tags Result array for the list of tags that are associated to the output |
|
| 90 | - * @param string|null &$expire Result variable for the expiration date of the output (null for no expiry) |
|
| 91 | - * @return string HTML code |
|
| 92 | - */ |
|
| 93 | - public function getBody( $uid = '', array &$tags = array(), &$expire = null ) |
|
| 94 | - { |
|
| 95 | - $context = $this->getContext(); |
|
| 96 | - $view = $this->getView(); |
|
| 97 | - |
|
| 98 | - try |
|
| 99 | - { |
|
| 100 | - $view = $this->setViewParams( $view, $tags, $expire ); |
|
| 101 | - |
|
| 102 | - $html = ''; |
|
| 103 | - foreach( $this->getSubClients() as $subclient ) { |
|
| 104 | - $html .= $subclient->setView( $view )->getBody( $uid, $tags, $expire ); |
|
| 105 | - } |
|
| 106 | - $view->selectBody = $html; |
|
| 107 | - } |
|
| 108 | - catch( \Aimeos\Client\Html\Exception $e ) |
|
| 109 | - { |
|
| 110 | - $error = array( $this->getContext()->getI18n()->dt( 'client', $e->getMessage() ) ); |
|
| 111 | - $view->selectErrorList = $view->get( 'selectErrorList', array() ) + $error; |
|
| 112 | - } |
|
| 113 | - catch( \Aimeos\Controller\Frontend\Exception $e ) |
|
| 114 | - { |
|
| 115 | - $error = array( $this->getContext()->getI18n()->dt( 'controller/frontend', $e->getMessage() ) ); |
|
| 116 | - $view->selectErrorList = $view->get( 'selectErrorList', array() ) + $error; |
|
| 117 | - } |
|
| 118 | - catch( \Aimeos\MShop\Exception $e ) |
|
| 119 | - { |
|
| 120 | - $error = array( $this->getContext()->getI18n()->dt( 'mshop', $e->getMessage() ) ); |
|
| 121 | - $view->selectErrorList = $view->get( 'selectErrorList', array() ) + $error; |
|
| 122 | - } |
|
| 123 | - catch( \Exception $e ) |
|
| 124 | - { |
|
| 125 | - $context->getLogger()->log( $e->getMessage() . PHP_EOL . $e->getTraceAsString() ); |
|
| 126 | - |
|
| 127 | - $error = array( $context->getI18n()->dt( 'client', 'A non-recoverable error occured' ) ); |
|
| 128 | - $view->selectErrorList = $view->get( 'selectErrorList', array() ) + $error; |
|
| 129 | - } |
|
| 130 | - |
|
| 131 | - /** client/html/locale/select/standard/template-body |
|
| 132 | - * Relative path to the HTML body template of the locale select client. |
|
| 133 | - * |
|
| 134 | - * The template file contains the HTML code and processing instructions |
|
| 135 | - * to generate the result shown in the body of the frontend. The |
|
| 136 | - * configuration string is the path to the template file relative |
|
| 137 | - * to the templates directory (usually in client/html/templates). |
|
| 138 | - * |
|
| 139 | - * You can overwrite the template file configuration in extensions and |
|
| 140 | - * provide alternative templates. These alternative templates should be |
|
| 141 | - * named like the default one but with the string "standard" replaced by |
|
| 142 | - * an unique name. You may use the name of your project for this. If |
|
| 143 | - * you've implemented an alternative client class as well, "standard" |
|
| 144 | - * should be replaced by the name of the new class. |
|
| 145 | - * |
|
| 146 | - * @param string Relative path to the template creating code for the HTML page body |
|
| 147 | - * @since 2014.09 |
|
| 148 | - * @category Developer |
|
| 149 | - * @see client/html/locale/select/standard/template-header |
|
| 150 | - */ |
|
| 151 | - $tplconf = 'client/html/locale/select/standard/template-body'; |
|
| 152 | - $default = 'locale/select/body-default.php'; |
|
| 153 | - |
|
| 154 | - return $view->render( $view->config( $tplconf, $default ) ); |
|
| 155 | - } |
|
| 156 | - |
|
| 157 | - |
|
| 158 | - /** |
|
| 159 | - * Returns the HTML string for insertion into the header. |
|
| 160 | - * |
|
| 161 | - * @param string $uid Unique identifier for the output if the content is placed more than once on the same page |
|
| 162 | - * @param array &$tags Result array for the list of tags that are associated to the output |
|
| 163 | - * @param string|null &$expire Result variable for the expiration date of the output (null for no expiry) |
|
| 164 | - * @return string|null String including HTML tags for the header on error |
|
| 165 | - */ |
|
| 166 | - public function getHeader( $uid = '', array &$tags = array(), &$expire = null ) |
|
| 167 | - { |
|
| 168 | - try |
|
| 169 | - { |
|
| 170 | - $view = $this->setViewParams( $this->getView(), $tags, $expire ); |
|
| 171 | - |
|
| 172 | - $html = ''; |
|
| 173 | - foreach( $this->getSubClients() as $subclient ) { |
|
| 174 | - $html .= $subclient->setView( $view )->getHeader( $uid, $tags, $expire ); |
|
| 175 | - } |
|
| 176 | - $view->selectHeader = $html; |
|
| 177 | - |
|
| 178 | - /** client/html/locale/select/standard/template-header |
|
| 179 | - * Relative path to the HTML header template of the locale select client. |
|
| 180 | - * |
|
| 181 | - * The template file contains the HTML code and processing instructions |
|
| 182 | - * to generate the HTML code that is inserted into the HTML page header |
|
| 183 | - * of the rendered page in the frontend. The configuration string is the |
|
| 184 | - * path to the template file relative to the templates directory (usually |
|
| 185 | - * in client/html/templates). |
|
| 186 | - * |
|
| 187 | - * You can overwrite the template file configuration in extensions and |
|
| 188 | - * provide alternative templates. These alternative templates should be |
|
| 189 | - * named like the default one but with the string "standard" replaced by |
|
| 190 | - * an unique name. You may use the name of your project for this. If |
|
| 191 | - * you've implemented an alternative client class as well, "standard" |
|
| 192 | - * should be replaced by the name of the new class. |
|
| 193 | - * |
|
| 194 | - * @param string Relative path to the template creating code for the HTML page head |
|
| 195 | - * @since 2014.09 |
|
| 196 | - * @category Developer |
|
| 197 | - * @see client/html/locale/select/standard/template-body |
|
| 198 | - */ |
|
| 199 | - $tplconf = 'client/html/locale/select/standard/template-header'; |
|
| 200 | - $default = 'locale/select/header-default.php'; |
|
| 201 | - |
|
| 202 | - return $view->render( $view->config( $tplconf, $default ) ); |
|
| 203 | - } |
|
| 204 | - catch( \Exception $e ) |
|
| 205 | - { |
|
| 206 | - $this->getContext()->getLogger()->log( $e->getMessage() . PHP_EOL . $e->getTraceAsString() ); |
|
| 207 | - } |
|
| 208 | - } |
|
| 209 | - |
|
| 210 | - |
|
| 211 | - /** |
|
| 212 | - * Returns the sub-client given by its name. |
|
| 213 | - * |
|
| 214 | - * @param string $type Name of the client type |
|
| 215 | - * @param string|null $name Name of the sub-client (Default if null) |
|
| 216 | - * @return \Aimeos\Client\Html\Iface Sub-client object |
|
| 217 | - */ |
|
| 218 | - public function getSubClient( $type, $name = null ) |
|
| 219 | - { |
|
| 220 | - /** client/html/locale/select/decorators/excludes |
|
| 221 | - * Excludes decorators added by the "common" option from the locale select html client |
|
| 222 | - * |
|
| 223 | - * Decorators extend the functionality of a class by adding new aspects |
|
| 224 | - * (e.g. log what is currently done), executing the methods of the underlying |
|
| 225 | - * class only in certain conditions (e.g. only for logged in users) or |
|
| 226 | - * modify what is returned to the caller. |
|
| 227 | - * |
|
| 228 | - * This option allows you to remove a decorator added via |
|
| 229 | - * "client/html/common/decorators/default" before they are wrapped |
|
| 230 | - * around the html client. |
|
| 231 | - * |
|
| 232 | - * client/html/locale/select/decorators/excludes = array( 'decorator1' ) |
|
| 233 | - * |
|
| 234 | - * This would remove the decorator named "decorator1" from the list of |
|
| 235 | - * common decorators ("\Aimeos\Client\Html\Common\Decorator\*") added via |
|
| 236 | - * "client/html/common/decorators/default" to the html client. |
|
| 237 | - * |
|
| 238 | - * @param array List of decorator names |
|
| 239 | - * @since 2014.05 |
|
| 240 | - * @category Developer |
|
| 241 | - * @see client/html/common/decorators/default |
|
| 242 | - * @see client/html/locale/select/decorators/global |
|
| 243 | - * @see client/html/locale/select/decorators/local |
|
| 244 | - */ |
|
| 245 | - |
|
| 246 | - /** client/html/locale/select/decorators/global |
|
| 247 | - * Adds a list of globally available decorators only to the locale select html client |
|
| 248 | - * |
|
| 249 | - * Decorators extend the functionality of a class by adding new aspects |
|
| 250 | - * (e.g. log what is currently done), executing the methods of the underlying |
|
| 251 | - * class only in certain conditions (e.g. only for logged in users) or |
|
| 252 | - * modify what is returned to the caller. |
|
| 253 | - * |
|
| 254 | - * This option allows you to wrap global decorators |
|
| 255 | - * ("\Aimeos\Client\Html\Common\Decorator\*") around the html client. |
|
| 256 | - * |
|
| 257 | - * client/html/locale/select/decorators/global = array( 'decorator1' ) |
|
| 258 | - * |
|
| 259 | - * This would add the decorator named "decorator1" defined by |
|
| 260 | - * "\Aimeos\Client\Html\Common\Decorator\Decorator1" only to the html client. |
|
| 261 | - * |
|
| 262 | - * @param array List of decorator names |
|
| 263 | - * @since 2014.05 |
|
| 264 | - * @category Developer |
|
| 265 | - * @see client/html/common/decorators/default |
|
| 266 | - * @see client/html/locale/select/decorators/excludes |
|
| 267 | - * @see client/html/locale/select/decorators/local |
|
| 268 | - */ |
|
| 269 | - |
|
| 270 | - /** client/html/locale/select/decorators/local |
|
| 271 | - * Adds a list of local decorators only to the locale select html client |
|
| 272 | - * |
|
| 273 | - * Decorators extend the functionality of a class by adding new aspects |
|
| 274 | - * (e.g. log what is currently done), executing the methods of the underlying |
|
| 275 | - * class only in certain conditions (e.g. only for logged in users) or |
|
| 276 | - * modify what is returned to the caller. |
|
| 277 | - * |
|
| 278 | - * This option allows you to wrap local decorators |
|
| 279 | - * ("\Aimeos\Client\Html\Locale\Decorator\*") around the html client. |
|
| 280 | - * |
|
| 281 | - * client/html/locale/select/decorators/local = array( 'decorator2' ) |
|
| 282 | - * |
|
| 283 | - * This would add the decorator named "decorator2" defined by |
|
| 284 | - * "\Aimeos\Client\Html\Locale\Decorator\Decorator2" only to the html client. |
|
| 285 | - * |
|
| 286 | - * @param array List of decorator names |
|
| 287 | - * @since 2014.05 |
|
| 288 | - * @category Developer |
|
| 289 | - * @see client/html/common/decorators/default |
|
| 290 | - * @see client/html/locale/select/decorators/excludes |
|
| 291 | - * @see client/html/locale/select/decorators/global |
|
| 292 | - */ |
|
| 293 | - return $this->createSubClient( 'locale/select/' . $type, $name ); |
|
| 294 | - } |
|
| 295 | - |
|
| 296 | - |
|
| 297 | - /** |
|
| 298 | - * Returns the list of sub-client names configured for the client. |
|
| 299 | - * |
|
| 300 | - * @return array List of HTML client names |
|
| 301 | - */ |
|
| 302 | - protected function getSubClientNames() |
|
| 303 | - { |
|
| 304 | - return $this->getContext()->getConfig()->get( $this->subPartPath, $this->subPartNames ); |
|
| 305 | - } |
|
| 306 | - |
|
| 307 | - |
|
| 308 | - /** |
|
| 309 | - * Sets the necessary parameter values in the view. |
|
| 310 | - * |
|
| 311 | - * @param \Aimeos\MW\View\Iface $view The view object which generates the HTML output |
|
| 312 | - * @param array &$tags Result array for the list of tags that are associated to the output |
|
| 313 | - * @param string|null &$expire Result variable for the expiration date of the output (null for no expiry) |
|
| 314 | - * @return \Aimeos\MW\View\Iface Modified view object |
|
| 315 | - */ |
|
| 316 | - protected function setViewParams( \Aimeos\MW\View\Iface $view, array &$tags = array(), &$expire = null ) |
|
| 317 | - { |
|
| 318 | - if( !isset( $this->cache ) ) |
|
| 319 | - { |
|
| 320 | - $map = array(); |
|
| 321 | - $context = $this->getContext(); |
|
| 322 | - $config = $context->getConfig(); |
|
| 323 | - $locale = $context->getLocale(); |
|
| 324 | - |
|
| 325 | - /** client/html/locale/select/language/param-name |
|
| 326 | - * Name of the parameter that contains the language ID value |
|
| 327 | - * |
|
| 328 | - * Frameworks and applications normally use its own predefined parameter |
|
| 329 | - * that contains the current language ID if they are multi-language |
|
| 330 | - * capable. To adapt the Aimeos parameter name to the already used name, |
|
| 331 | - * you are able to configure it by using this setting. |
|
| 332 | - * |
|
| 333 | - * @param string Parameter name for language ID |
|
| 334 | - * @since 2015.06 |
|
| 335 | - * @see client/html/locale/select/currency/param-name |
|
| 336 | - */ |
|
| 337 | - $langname = $config->get( 'client/html/locale/select/language/param-name', 'loc_languageid' ); |
|
| 338 | - |
|
| 339 | - /** client/html/locale/select/currency/param-name |
|
| 340 | - * Name of the parameter that contains the currency ID value |
|
| 341 | - * |
|
| 342 | - * Frameworks and applications normally use its own predefined parameter |
|
| 343 | - * that contains the current currency ID if they already support multiple |
|
| 344 | - * currencies. To adapt the Aimeos parameter name to the already used name, |
|
| 345 | - * you are able to configure it by using this setting. |
|
| 346 | - * |
|
| 347 | - * @param string Parameter name for currency ID |
|
| 348 | - * @since 2015.06 |
|
| 349 | - * @see client/html/locale/select/language/param-name |
|
| 350 | - */ |
|
| 351 | - $curname = $config->get( 'client/html/locale/select/currency/param-name', 'loc_currencyid' ); |
|
| 352 | - |
|
| 353 | - |
|
| 354 | - $manager = \Aimeos\MShop\Factory::createManager( $context, 'locale' ); |
|
| 355 | - |
|
| 356 | - $search = $manager->createSearch( true ); |
|
| 357 | - $search->setSortations( array( $search->sort( '+', 'locale.position' ) ) ); |
|
| 358 | - |
|
| 359 | - foreach( $manager->searchItems( $search ) as $item ) |
|
| 360 | - { |
|
| 361 | - $curId = $item->getCurrencyId(); |
|
| 362 | - $langId = $item->getLanguageId(); |
|
| 363 | - $map[$langId][$curId] = array( $langname => $langId, $curname => $curId ); |
|
| 364 | - } |
|
| 365 | - |
|
| 366 | - $params = $view->param(); |
|
| 367 | - |
|
| 368 | - $view->selectMap = $map; |
|
| 369 | - $view->selectParams = $params; |
|
| 370 | - $view->selectLanguageId = $locale->getLanguageId(); |
|
| 371 | - $view->selectCurrencyId = $locale->getCurrencyId(); |
|
| 372 | - |
|
| 373 | - $this->cache = $view; |
|
| 374 | - } |
|
| 375 | - |
|
| 376 | - return $this->cache; |
|
| 377 | - } |
|
| 25 | + /** client/html/locale/select/standard/subparts |
|
| 26 | + * List of HTML sub-clients rendered within the locale select section |
|
| 27 | + * |
|
| 28 | + * The output of the frontend is composed of the code generated by the HTML |
|
| 29 | + * clients. Each HTML client can consist of serveral (or none) sub-clients |
|
| 30 | + * that are responsible for rendering certain sub-parts of the output. The |
|
| 31 | + * sub-clients can contain HTML clients themselves and therefore a |
|
| 32 | + * hierarchical tree of HTML clients is composed. Each HTML client creates |
|
| 33 | + * the output that is placed inside the container of its parent. |
|
| 34 | + * |
|
| 35 | + * At first, always the HTML code generated by the parent is printed, then |
|
| 36 | + * the HTML code of its sub-clients. The order of the HTML sub-clients |
|
| 37 | + * determines the order of the output of these sub-clients inside the parent |
|
| 38 | + * container. If the configured list of clients is |
|
| 39 | + * |
|
| 40 | + * array( "subclient1", "subclient2" ) |
|
| 41 | + * |
|
| 42 | + * you can easily change the order of the output by reordering the subparts: |
|
| 43 | + * |
|
| 44 | + * client/html/<clients>/subparts = array( "subclient1", "subclient2" ) |
|
| 45 | + * |
|
| 46 | + * You can also remove one or more parts if they shouldn't be rendered: |
|
| 47 | + * |
|
| 48 | + * client/html/<clients>/subparts = array( "subclient1" ) |
|
| 49 | + * |
|
| 50 | + * As the clients only generates structural HTML, the layout defined via CSS |
|
| 51 | + * should support adding, removing or reordering content by a fluid like |
|
| 52 | + * design. |
|
| 53 | + * |
|
| 54 | + * @param array List of sub-client names |
|
| 55 | + * @since 2014.09 |
|
| 56 | + * @category Developer |
|
| 57 | + */ |
|
| 58 | + private $subPartPath = 'client/html/locale/select/standard/subparts'; |
|
| 59 | + |
|
| 60 | + /** client/html/locale/select/language/name |
|
| 61 | + * Name of the language part used by the locale selector client implementation |
|
| 62 | + * |
|
| 63 | + * Use "Myname" if your class is named "\Aimeos\Client\Html\Locale\Select\Language\Myname". |
|
| 64 | + * The name is case-sensitive and you should avoid camel case names like "MyName". |
|
| 65 | + * |
|
| 66 | + * @param string Last part of the client class name |
|
| 67 | + * @since 2014.09 |
|
| 68 | + * @category Developer |
|
| 69 | + */ |
|
| 70 | + |
|
| 71 | + /** client/html/locale/select/currency/name |
|
| 72 | + * Name of the currency part used by the locale selector client implementation |
|
| 73 | + * |
|
| 74 | + * Use "Myname" if your class is named "\Aimeos\Client\Html\Locale\Select\Currency\Myname". |
|
| 75 | + * The name is case-sensitive and you should avoid camel case names like "MyName". |
|
| 76 | + * |
|
| 77 | + * @param string Last part of the client class name |
|
| 78 | + * @since 2014.09 |
|
| 79 | + * @category Developer |
|
| 80 | + */ |
|
| 81 | + private $subPartNames = array( 'language', 'currency' ); |
|
| 82 | + private $cache; |
|
| 83 | + |
|
| 84 | + |
|
| 85 | + /** |
|
| 86 | + * Returns the HTML code for insertion into the body. |
|
| 87 | + * |
|
| 88 | + * @param string $uid Unique identifier for the output if the content is placed more than once on the same page |
|
| 89 | + * @param array &$tags Result array for the list of tags that are associated to the output |
|
| 90 | + * @param string|null &$expire Result variable for the expiration date of the output (null for no expiry) |
|
| 91 | + * @return string HTML code |
|
| 92 | + */ |
|
| 93 | + public function getBody( $uid = '', array &$tags = array(), &$expire = null ) |
|
| 94 | + { |
|
| 95 | + $context = $this->getContext(); |
|
| 96 | + $view = $this->getView(); |
|
| 97 | + |
|
| 98 | + try |
|
| 99 | + { |
|
| 100 | + $view = $this->setViewParams( $view, $tags, $expire ); |
|
| 101 | + |
|
| 102 | + $html = ''; |
|
| 103 | + foreach( $this->getSubClients() as $subclient ) { |
|
| 104 | + $html .= $subclient->setView( $view )->getBody( $uid, $tags, $expire ); |
|
| 105 | + } |
|
| 106 | + $view->selectBody = $html; |
|
| 107 | + } |
|
| 108 | + catch( \Aimeos\Client\Html\Exception $e ) |
|
| 109 | + { |
|
| 110 | + $error = array( $this->getContext()->getI18n()->dt( 'client', $e->getMessage() ) ); |
|
| 111 | + $view->selectErrorList = $view->get( 'selectErrorList', array() ) + $error; |
|
| 112 | + } |
|
| 113 | + catch( \Aimeos\Controller\Frontend\Exception $e ) |
|
| 114 | + { |
|
| 115 | + $error = array( $this->getContext()->getI18n()->dt( 'controller/frontend', $e->getMessage() ) ); |
|
| 116 | + $view->selectErrorList = $view->get( 'selectErrorList', array() ) + $error; |
|
| 117 | + } |
|
| 118 | + catch( \Aimeos\MShop\Exception $e ) |
|
| 119 | + { |
|
| 120 | + $error = array( $this->getContext()->getI18n()->dt( 'mshop', $e->getMessage() ) ); |
|
| 121 | + $view->selectErrorList = $view->get( 'selectErrorList', array() ) + $error; |
|
| 122 | + } |
|
| 123 | + catch( \Exception $e ) |
|
| 124 | + { |
|
| 125 | + $context->getLogger()->log( $e->getMessage() . PHP_EOL . $e->getTraceAsString() ); |
|
| 126 | + |
|
| 127 | + $error = array( $context->getI18n()->dt( 'client', 'A non-recoverable error occured' ) ); |
|
| 128 | + $view->selectErrorList = $view->get( 'selectErrorList', array() ) + $error; |
|
| 129 | + } |
|
| 130 | + |
|
| 131 | + /** client/html/locale/select/standard/template-body |
|
| 132 | + * Relative path to the HTML body template of the locale select client. |
|
| 133 | + * |
|
| 134 | + * The template file contains the HTML code and processing instructions |
|
| 135 | + * to generate the result shown in the body of the frontend. The |
|
| 136 | + * configuration string is the path to the template file relative |
|
| 137 | + * to the templates directory (usually in client/html/templates). |
|
| 138 | + * |
|
| 139 | + * You can overwrite the template file configuration in extensions and |
|
| 140 | + * provide alternative templates. These alternative templates should be |
|
| 141 | + * named like the default one but with the string "standard" replaced by |
|
| 142 | + * an unique name. You may use the name of your project for this. If |
|
| 143 | + * you've implemented an alternative client class as well, "standard" |
|
| 144 | + * should be replaced by the name of the new class. |
|
| 145 | + * |
|
| 146 | + * @param string Relative path to the template creating code for the HTML page body |
|
| 147 | + * @since 2014.09 |
|
| 148 | + * @category Developer |
|
| 149 | + * @see client/html/locale/select/standard/template-header |
|
| 150 | + */ |
|
| 151 | + $tplconf = 'client/html/locale/select/standard/template-body'; |
|
| 152 | + $default = 'locale/select/body-default.php'; |
|
| 153 | + |
|
| 154 | + return $view->render( $view->config( $tplconf, $default ) ); |
|
| 155 | + } |
|
| 156 | + |
|
| 157 | + |
|
| 158 | + /** |
|
| 159 | + * Returns the HTML string for insertion into the header. |
|
| 160 | + * |
|
| 161 | + * @param string $uid Unique identifier for the output if the content is placed more than once on the same page |
|
| 162 | + * @param array &$tags Result array for the list of tags that are associated to the output |
|
| 163 | + * @param string|null &$expire Result variable for the expiration date of the output (null for no expiry) |
|
| 164 | + * @return string|null String including HTML tags for the header on error |
|
| 165 | + */ |
|
| 166 | + public function getHeader( $uid = '', array &$tags = array(), &$expire = null ) |
|
| 167 | + { |
|
| 168 | + try |
|
| 169 | + { |
|
| 170 | + $view = $this->setViewParams( $this->getView(), $tags, $expire ); |
|
| 171 | + |
|
| 172 | + $html = ''; |
|
| 173 | + foreach( $this->getSubClients() as $subclient ) { |
|
| 174 | + $html .= $subclient->setView( $view )->getHeader( $uid, $tags, $expire ); |
|
| 175 | + } |
|
| 176 | + $view->selectHeader = $html; |
|
| 177 | + |
|
| 178 | + /** client/html/locale/select/standard/template-header |
|
| 179 | + * Relative path to the HTML header template of the locale select client. |
|
| 180 | + * |
|
| 181 | + * The template file contains the HTML code and processing instructions |
|
| 182 | + * to generate the HTML code that is inserted into the HTML page header |
|
| 183 | + * of the rendered page in the frontend. The configuration string is the |
|
| 184 | + * path to the template file relative to the templates directory (usually |
|
| 185 | + * in client/html/templates). |
|
| 186 | + * |
|
| 187 | + * You can overwrite the template file configuration in extensions and |
|
| 188 | + * provide alternative templates. These alternative templates should be |
|
| 189 | + * named like the default one but with the string "standard" replaced by |
|
| 190 | + * an unique name. You may use the name of your project for this. If |
|
| 191 | + * you've implemented an alternative client class as well, "standard" |
|
| 192 | + * should be replaced by the name of the new class. |
|
| 193 | + * |
|
| 194 | + * @param string Relative path to the template creating code for the HTML page head |
|
| 195 | + * @since 2014.09 |
|
| 196 | + * @category Developer |
|
| 197 | + * @see client/html/locale/select/standard/template-body |
|
| 198 | + */ |
|
| 199 | + $tplconf = 'client/html/locale/select/standard/template-header'; |
|
| 200 | + $default = 'locale/select/header-default.php'; |
|
| 201 | + |
|
| 202 | + return $view->render( $view->config( $tplconf, $default ) ); |
|
| 203 | + } |
|
| 204 | + catch( \Exception $e ) |
|
| 205 | + { |
|
| 206 | + $this->getContext()->getLogger()->log( $e->getMessage() . PHP_EOL . $e->getTraceAsString() ); |
|
| 207 | + } |
|
| 208 | + } |
|
| 209 | + |
|
| 210 | + |
|
| 211 | + /** |
|
| 212 | + * Returns the sub-client given by its name. |
|
| 213 | + * |
|
| 214 | + * @param string $type Name of the client type |
|
| 215 | + * @param string|null $name Name of the sub-client (Default if null) |
|
| 216 | + * @return \Aimeos\Client\Html\Iface Sub-client object |
|
| 217 | + */ |
|
| 218 | + public function getSubClient( $type, $name = null ) |
|
| 219 | + { |
|
| 220 | + /** client/html/locale/select/decorators/excludes |
|
| 221 | + * Excludes decorators added by the "common" option from the locale select html client |
|
| 222 | + * |
|
| 223 | + * Decorators extend the functionality of a class by adding new aspects |
|
| 224 | + * (e.g. log what is currently done), executing the methods of the underlying |
|
| 225 | + * class only in certain conditions (e.g. only for logged in users) or |
|
| 226 | + * modify what is returned to the caller. |
|
| 227 | + * |
|
| 228 | + * This option allows you to remove a decorator added via |
|
| 229 | + * "client/html/common/decorators/default" before they are wrapped |
|
| 230 | + * around the html client. |
|
| 231 | + * |
|
| 232 | + * client/html/locale/select/decorators/excludes = array( 'decorator1' ) |
|
| 233 | + * |
|
| 234 | + * This would remove the decorator named "decorator1" from the list of |
|
| 235 | + * common decorators ("\Aimeos\Client\Html\Common\Decorator\*") added via |
|
| 236 | + * "client/html/common/decorators/default" to the html client. |
|
| 237 | + * |
|
| 238 | + * @param array List of decorator names |
|
| 239 | + * @since 2014.05 |
|
| 240 | + * @category Developer |
|
| 241 | + * @see client/html/common/decorators/default |
|
| 242 | + * @see client/html/locale/select/decorators/global |
|
| 243 | + * @see client/html/locale/select/decorators/local |
|
| 244 | + */ |
|
| 245 | + |
|
| 246 | + /** client/html/locale/select/decorators/global |
|
| 247 | + * Adds a list of globally available decorators only to the locale select html client |
|
| 248 | + * |
|
| 249 | + * Decorators extend the functionality of a class by adding new aspects |
|
| 250 | + * (e.g. log what is currently done), executing the methods of the underlying |
|
| 251 | + * class only in certain conditions (e.g. only for logged in users) or |
|
| 252 | + * modify what is returned to the caller. |
|
| 253 | + * |
|
| 254 | + * This option allows you to wrap global decorators |
|
| 255 | + * ("\Aimeos\Client\Html\Common\Decorator\*") around the html client. |
|
| 256 | + * |
|
| 257 | + * client/html/locale/select/decorators/global = array( 'decorator1' ) |
|
| 258 | + * |
|
| 259 | + * This would add the decorator named "decorator1" defined by |
|
| 260 | + * "\Aimeos\Client\Html\Common\Decorator\Decorator1" only to the html client. |
|
| 261 | + * |
|
| 262 | + * @param array List of decorator names |
|
| 263 | + * @since 2014.05 |
|
| 264 | + * @category Developer |
|
| 265 | + * @see client/html/common/decorators/default |
|
| 266 | + * @see client/html/locale/select/decorators/excludes |
|
| 267 | + * @see client/html/locale/select/decorators/local |
|
| 268 | + */ |
|
| 269 | + |
|
| 270 | + /** client/html/locale/select/decorators/local |
|
| 271 | + * Adds a list of local decorators only to the locale select html client |
|
| 272 | + * |
|
| 273 | + * Decorators extend the functionality of a class by adding new aspects |
|
| 274 | + * (e.g. log what is currently done), executing the methods of the underlying |
|
| 275 | + * class only in certain conditions (e.g. only for logged in users) or |
|
| 276 | + * modify what is returned to the caller. |
|
| 277 | + * |
|
| 278 | + * This option allows you to wrap local decorators |
|
| 279 | + * ("\Aimeos\Client\Html\Locale\Decorator\*") around the html client. |
|
| 280 | + * |
|
| 281 | + * client/html/locale/select/decorators/local = array( 'decorator2' ) |
|
| 282 | + * |
|
| 283 | + * This would add the decorator named "decorator2" defined by |
|
| 284 | + * "\Aimeos\Client\Html\Locale\Decorator\Decorator2" only to the html client. |
|
| 285 | + * |
|
| 286 | + * @param array List of decorator names |
|
| 287 | + * @since 2014.05 |
|
| 288 | + * @category Developer |
|
| 289 | + * @see client/html/common/decorators/default |
|
| 290 | + * @see client/html/locale/select/decorators/excludes |
|
| 291 | + * @see client/html/locale/select/decorators/global |
|
| 292 | + */ |
|
| 293 | + return $this->createSubClient( 'locale/select/' . $type, $name ); |
|
| 294 | + } |
|
| 295 | + |
|
| 296 | + |
|
| 297 | + /** |
|
| 298 | + * Returns the list of sub-client names configured for the client. |
|
| 299 | + * |
|
| 300 | + * @return array List of HTML client names |
|
| 301 | + */ |
|
| 302 | + protected function getSubClientNames() |
|
| 303 | + { |
|
| 304 | + return $this->getContext()->getConfig()->get( $this->subPartPath, $this->subPartNames ); |
|
| 305 | + } |
|
| 306 | + |
|
| 307 | + |
|
| 308 | + /** |
|
| 309 | + * Sets the necessary parameter values in the view. |
|
| 310 | + * |
|
| 311 | + * @param \Aimeos\MW\View\Iface $view The view object which generates the HTML output |
|
| 312 | + * @param array &$tags Result array for the list of tags that are associated to the output |
|
| 313 | + * @param string|null &$expire Result variable for the expiration date of the output (null for no expiry) |
|
| 314 | + * @return \Aimeos\MW\View\Iface Modified view object |
|
| 315 | + */ |
|
| 316 | + protected function setViewParams( \Aimeos\MW\View\Iface $view, array &$tags = array(), &$expire = null ) |
|
| 317 | + { |
|
| 318 | + if( !isset( $this->cache ) ) |
|
| 319 | + { |
|
| 320 | + $map = array(); |
|
| 321 | + $context = $this->getContext(); |
|
| 322 | + $config = $context->getConfig(); |
|
| 323 | + $locale = $context->getLocale(); |
|
| 324 | + |
|
| 325 | + /** client/html/locale/select/language/param-name |
|
| 326 | + * Name of the parameter that contains the language ID value |
|
| 327 | + * |
|
| 328 | + * Frameworks and applications normally use its own predefined parameter |
|
| 329 | + * that contains the current language ID if they are multi-language |
|
| 330 | + * capable. To adapt the Aimeos parameter name to the already used name, |
|
| 331 | + * you are able to configure it by using this setting. |
|
| 332 | + * |
|
| 333 | + * @param string Parameter name for language ID |
|
| 334 | + * @since 2015.06 |
|
| 335 | + * @see client/html/locale/select/currency/param-name |
|
| 336 | + */ |
|
| 337 | + $langname = $config->get( 'client/html/locale/select/language/param-name', 'loc_languageid' ); |
|
| 338 | + |
|
| 339 | + /** client/html/locale/select/currency/param-name |
|
| 340 | + * Name of the parameter that contains the currency ID value |
|
| 341 | + * |
|
| 342 | + * Frameworks and applications normally use its own predefined parameter |
|
| 343 | + * that contains the current currency ID if they already support multiple |
|
| 344 | + * currencies. To adapt the Aimeos parameter name to the already used name, |
|
| 345 | + * you are able to configure it by using this setting. |
|
| 346 | + * |
|
| 347 | + * @param string Parameter name for currency ID |
|
| 348 | + * @since 2015.06 |
|
| 349 | + * @see client/html/locale/select/language/param-name |
|
| 350 | + */ |
|
| 351 | + $curname = $config->get( 'client/html/locale/select/currency/param-name', 'loc_currencyid' ); |
|
| 352 | + |
|
| 353 | + |
|
| 354 | + $manager = \Aimeos\MShop\Factory::createManager( $context, 'locale' ); |
|
| 355 | + |
|
| 356 | + $search = $manager->createSearch( true ); |
|
| 357 | + $search->setSortations( array( $search->sort( '+', 'locale.position' ) ) ); |
|
| 358 | + |
|
| 359 | + foreach( $manager->searchItems( $search ) as $item ) |
|
| 360 | + { |
|
| 361 | + $curId = $item->getCurrencyId(); |
|
| 362 | + $langId = $item->getLanguageId(); |
|
| 363 | + $map[$langId][$curId] = array( $langname => $langId, $curname => $curId ); |
|
| 364 | + } |
|
| 365 | + |
|
| 366 | + $params = $view->param(); |
|
| 367 | + |
|
| 368 | + $view->selectMap = $map; |
|
| 369 | + $view->selectParams = $params; |
|
| 370 | + $view->selectLanguageId = $locale->getLanguageId(); |
|
| 371 | + $view->selectCurrencyId = $locale->getCurrencyId(); |
|
| 372 | + |
|
| 373 | + $this->cache = $view; |
|
| 374 | + } |
|
| 375 | + |
|
| 376 | + return $this->cache; |
|
| 377 | + } |
|
| 378 | 378 | } |
| 379 | 379 | \ No newline at end of file |
@@ -82,23 +82,19 @@ discard block |
||
| 82 | 82 | $html .= $subclient->setView( $view )->getBody( $uid, $tags, $expire ); |
| 83 | 83 | } |
| 84 | 84 | $view->watchBody = $html; |
| 85 | - } |
|
| 86 | - catch( \Aimeos\Client\Html\Exception $e ) |
|
| 85 | + } catch( \Aimeos\Client\Html\Exception $e ) |
|
| 87 | 86 | { |
| 88 | 87 | $error = array( $this->getContext()->getI18n()->dt( 'client', $e->getMessage() ) ); |
| 89 | 88 | $view->watchErrorList = $view->get( 'watchErrorList', array() ) + $error; |
| 90 | - } |
|
| 91 | - catch( \Aimeos\Controller\Frontend\Exception $e ) |
|
| 89 | + } catch( \Aimeos\Controller\Frontend\Exception $e ) |
|
| 92 | 90 | { |
| 93 | 91 | $error = array( $this->getContext()->getI18n()->dt( 'controller/frontend', $e->getMessage() ) ); |
| 94 | 92 | $view->watchErrorList = $view->get( 'watchErrorList', array() ) + $error; |
| 95 | - } |
|
| 96 | - catch( \Aimeos\MShop\Exception $e ) |
|
| 93 | + } catch( \Aimeos\MShop\Exception $e ) |
|
| 97 | 94 | { |
| 98 | 95 | $error = array( $this->getContext()->getI18n()->dt( 'mshop', $e->getMessage() ) ); |
| 99 | 96 | $view->watchErrorList = $view->get( 'watchErrorList', array() ) + $error; |
| 100 | - } |
|
| 101 | - catch( \Exception $e ) |
|
| 97 | + } catch( \Exception $e ) |
|
| 102 | 98 | { |
| 103 | 99 | $context->getLogger()->log( $e->getMessage() . PHP_EOL . $e->getTraceAsString() ); |
| 104 | 100 | |
@@ -178,8 +174,7 @@ discard block |
||
| 178 | 174 | $default = 'account/watch/header-default.php'; |
| 179 | 175 | |
| 180 | 176 | return $view->render( $view->config( $tplconf, $default ) ); |
| 181 | - } |
|
| 182 | - catch( \Exception $e ) |
|
| 177 | + } catch( \Exception $e ) |
|
| 183 | 178 | { |
| 184 | 179 | $this->getContext()->getLogger()->log( $e->getMessage() . PHP_EOL . $e->getTraceAsString() ); |
| 185 | 180 | } |