@@ -18,267 +18,267 @@ |
||
| 18 | 18 | * @subpackage Html |
| 19 | 19 | */ |
| 20 | 20 | class Standard |
| 21 | - extends \Aimeos\Client\Html\Common\Client\Factory\Base |
|
| 22 | - implements \Aimeos\Client\Html\Common\Client\Factory\Iface |
|
| 21 | + extends \Aimeos\Client\Html\Common\Client\Factory\Base |
|
| 22 | + implements \Aimeos\Client\Html\Common\Client\Factory\Iface |
|
| 23 | 23 | { |
| 24 | - /** client/html/catalog/detail/additional/property/standard/subparts |
|
| 25 | - * List of HTML sub-clients rendered within the catalog detail additional property section |
|
| 26 | - * |
|
| 27 | - * The output of the frontend is composed of the code generated by the HTML |
|
| 28 | - * clients. Each HTML client can consist of serveral (or none) sub-clients |
|
| 29 | - * that are responsible for rendering certain sub-parts of the output. The |
|
| 30 | - * sub-clients can contain HTML clients themselves and therefore a |
|
| 31 | - * hierarchical tree of HTML clients is composed. Each HTML client creates |
|
| 32 | - * the output that is placed inside the container of its parent. |
|
| 33 | - * |
|
| 34 | - * At first, always the HTML code generated by the parent is printed, then |
|
| 35 | - * the HTML code of its sub-clients. The order of the HTML sub-clients |
|
| 36 | - * determines the order of the output of these sub-clients inside the parent |
|
| 37 | - * container. If the configured list of clients is |
|
| 38 | - * |
|
| 39 | - * array( "subclient1", "subclient2" ) |
|
| 40 | - * |
|
| 41 | - * you can easily change the order of the output by reordering the subparts: |
|
| 42 | - * |
|
| 43 | - * client/html/<clients>/subparts = array( "subclient1", "subclient2" ) |
|
| 44 | - * |
|
| 45 | - * You can also remove one or more parts if they shouldn't be rendered: |
|
| 46 | - * |
|
| 47 | - * client/html/<clients>/subparts = array( "subclient1" ) |
|
| 48 | - * |
|
| 49 | - * As the clients only generates structural HTML, the layout defined via CSS |
|
| 50 | - * should support adding, removing or reordering content by a fluid like |
|
| 51 | - * design. |
|
| 52 | - * |
|
| 53 | - * @param array List of sub-client names |
|
| 54 | - * @since 2015.01 |
|
| 55 | - * @category Developer |
|
| 56 | - */ |
|
| 57 | - private $subPartPath = 'client/html/catalog/detail/additional/property/standard/subparts'; |
|
| 58 | - private $subPartNames = array(); |
|
| 59 | - private $cache; |
|
| 24 | + /** client/html/catalog/detail/additional/property/standard/subparts |
|
| 25 | + * List of HTML sub-clients rendered within the catalog detail additional property section |
|
| 26 | + * |
|
| 27 | + * The output of the frontend is composed of the code generated by the HTML |
|
| 28 | + * clients. Each HTML client can consist of serveral (or none) sub-clients |
|
| 29 | + * that are responsible for rendering certain sub-parts of the output. The |
|
| 30 | + * sub-clients can contain HTML clients themselves and therefore a |
|
| 31 | + * hierarchical tree of HTML clients is composed. Each HTML client creates |
|
| 32 | + * the output that is placed inside the container of its parent. |
|
| 33 | + * |
|
| 34 | + * At first, always the HTML code generated by the parent is printed, then |
|
| 35 | + * the HTML code of its sub-clients. The order of the HTML sub-clients |
|
| 36 | + * determines the order of the output of these sub-clients inside the parent |
|
| 37 | + * container. If the configured list of clients is |
|
| 38 | + * |
|
| 39 | + * array( "subclient1", "subclient2" ) |
|
| 40 | + * |
|
| 41 | + * you can easily change the order of the output by reordering the subparts: |
|
| 42 | + * |
|
| 43 | + * client/html/<clients>/subparts = array( "subclient1", "subclient2" ) |
|
| 44 | + * |
|
| 45 | + * You can also remove one or more parts if they shouldn't be rendered: |
|
| 46 | + * |
|
| 47 | + * client/html/<clients>/subparts = array( "subclient1" ) |
|
| 48 | + * |
|
| 49 | + * As the clients only generates structural HTML, the layout defined via CSS |
|
| 50 | + * should support adding, removing or reordering content by a fluid like |
|
| 51 | + * design. |
|
| 52 | + * |
|
| 53 | + * @param array List of sub-client names |
|
| 54 | + * @since 2015.01 |
|
| 55 | + * @category Developer |
|
| 56 | + */ |
|
| 57 | + private $subPartPath = 'client/html/catalog/detail/additional/property/standard/subparts'; |
|
| 58 | + private $subPartNames = array(); |
|
| 59 | + private $cache; |
|
| 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->propertyBody = $html; |
|
| 74 | + $html = ''; |
|
| 75 | + foreach( $this->getSubClients() as $subclient ) { |
|
| 76 | + $html .= $subclient->setView( $view )->getBody( $uid, $tags, $expire ); |
|
| 77 | + } |
|
| 78 | + $view->propertyBody = $html; |
|
| 79 | 79 | |
| 80 | - /** client/html/catalog/detail/additional/property/standard/template-body |
|
| 81 | - * Relative path to the HTML body template of the catalog detail additional property 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 2015.01 |
|
| 97 | - * @category Developer |
|
| 98 | - * @see client/html/catalog/detail/additional/property/standard/template-header |
|
| 99 | - */ |
|
| 100 | - $tplconf = 'client/html/catalog/detail/additional/property/standard/template-body'; |
|
| 101 | - $default = 'catalog/detail/additional-property-body-default.php'; |
|
| 80 | + /** client/html/catalog/detail/additional/property/standard/template-body |
|
| 81 | + * Relative path to the HTML body template of the catalog detail additional property 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 2015.01 |
|
| 97 | + * @category Developer |
|
| 98 | + * @see client/html/catalog/detail/additional/property/standard/template-header |
|
| 99 | + */ |
|
| 100 | + $tplconf = 'client/html/catalog/detail/additional/property/standard/template-body'; |
|
| 101 | + $default = 'catalog/detail/additional-property-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->propertyHeader = $html; |
|
| 119 | + $html = ''; |
|
| 120 | + foreach( $this->getSubClients() as $subclient ) { |
|
| 121 | + $html .= $subclient->setView( $view )->getHeader( $uid, $tags, $expire ); |
|
| 122 | + } |
|
| 123 | + $view->propertyHeader = $html; |
|
| 124 | 124 | |
| 125 | - /** client/html/catalog/detail/additional/property/standard/template-header |
|
| 126 | - * Relative path to the HTML header template of the catalog detail additional property 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 2015.01 |
|
| 143 | - * @category Developer |
|
| 144 | - * @see client/html/catalog/detail/additional/property/standard/template-body |
|
| 145 | - */ |
|
| 146 | - $tplconf = 'client/html/catalog/detail/additional/property/standard/template-header'; |
|
| 147 | - $default = 'catalog/detail/additional-property-header-default.php'; |
|
| 125 | + /** client/html/catalog/detail/additional/property/standard/template-header |
|
| 126 | + * Relative path to the HTML header template of the catalog detail additional property 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 2015.01 |
|
| 143 | + * @category Developer |
|
| 144 | + * @see client/html/catalog/detail/additional/property/standard/template-body |
|
| 145 | + */ |
|
| 146 | + $tplconf = 'client/html/catalog/detail/additional/property/standard/template-header'; |
|
| 147 | + $default = 'catalog/detail/additional-property-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/catalog/detail/additional/property/decorators/excludes |
|
| 163 | - * Excludes decorators added by the "common" option from the catalog detail additional property 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/catalog/detail/additional/property/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/catalog/detail/additional/property/decorators/global |
|
| 185 | - * @see client/html/catalog/detail/additional/property/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/catalog/detail/additional/property/decorators/excludes |
|
| 163 | + * Excludes decorators added by the "common" option from the catalog detail additional property 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/catalog/detail/additional/property/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/catalog/detail/additional/property/decorators/global |
|
| 185 | + * @see client/html/catalog/detail/additional/property/decorators/local |
|
| 186 | + */ |
|
| 187 | 187 | |
| 188 | - /** client/html/catalog/detail/additional/property/decorators/global |
|
| 189 | - * Adds a list of globally available decorators only to the catalog detail additional property 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/catalog/detail/additional/property/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/catalog/detail/additional/property/decorators/excludes |
|
| 209 | - * @see client/html/catalog/detail/additional/property/decorators/local |
|
| 210 | - */ |
|
| 188 | + /** client/html/catalog/detail/additional/property/decorators/global |
|
| 189 | + * Adds a list of globally available decorators only to the catalog detail additional property 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/catalog/detail/additional/property/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/catalog/detail/additional/property/decorators/excludes |
|
| 209 | + * @see client/html/catalog/detail/additional/property/decorators/local |
|
| 210 | + */ |
|
| 211 | 211 | |
| 212 | - /** client/html/catalog/detail/additional/property/decorators/local |
|
| 213 | - * Adds a list of local decorators only to the catalog detail additional property 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\Catalog\Decorator\*") around the html client. |
|
| 222 | - * |
|
| 223 | - * client/html/catalog/detail/additional/property/decorators/local = array( 'decorator2' ) |
|
| 224 | - * |
|
| 225 | - * This would add the decorator named "decorator2" defined by |
|
| 226 | - * "\Aimeos\Client\Html\Catalog\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/catalog/detail/additional/property/decorators/excludes |
|
| 233 | - * @see client/html/catalog/detail/additional/property/decorators/global |
|
| 234 | - */ |
|
| 212 | + /** client/html/catalog/detail/additional/property/decorators/local |
|
| 213 | + * Adds a list of local decorators only to the catalog detail additional property 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\Catalog\Decorator\*") around the html client. |
|
| 222 | + * |
|
| 223 | + * client/html/catalog/detail/additional/property/decorators/local = array( 'decorator2' ) |
|
| 224 | + * |
|
| 225 | + * This would add the decorator named "decorator2" defined by |
|
| 226 | + * "\Aimeos\Client\Html\Catalog\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/catalog/detail/additional/property/decorators/excludes |
|
| 233 | + * @see client/html/catalog/detail/additional/property/decorators/global |
|
| 234 | + */ |
|
| 235 | 235 | |
| 236 | - return $this->createSubClient( 'catalog/detail/additional/property/' . $type, $name ); |
|
| 237 | - } |
|
| 236 | + return $this->createSubClient( 'catalog/detail/additional/property/' . $type, $name ); |
|
| 237 | + } |
|
| 238 | 238 | |
| 239 | 239 | |
| 240 | - /** |
|
| 241 | - * Returns the list of sub-client names configured for the client. |
|
| 242 | - * |
|
| 243 | - * @return array List of HTML client names |
|
| 244 | - */ |
|
| 245 | - protected function getSubClientNames() |
|
| 246 | - { |
|
| 247 | - return $this->getContext()->getConfig()->get( $this->subPartPath, $this->subPartNames ); |
|
| 248 | - } |
|
| 240 | + /** |
|
| 241 | + * Returns the list of sub-client names configured for the client. |
|
| 242 | + * |
|
| 243 | + * @return array List of HTML client names |
|
| 244 | + */ |
|
| 245 | + protected function getSubClientNames() |
|
| 246 | + { |
|
| 247 | + return $this->getContext()->getConfig()->get( $this->subPartPath, $this->subPartNames ); |
|
| 248 | + } |
|
| 249 | 249 | |
| 250 | 250 | |
| 251 | - /** |
|
| 252 | - * Sets the necessary parameter values in the view. |
|
| 253 | - * |
|
| 254 | - * @param \Aimeos\MW\View\Iface $view The view object which generates the HTML output |
|
| 255 | - * @param array &$tags Result array for the list of tags that are associated to the output |
|
| 256 | - * @param string|null &$expire Result variable for the expiration date of the output (null for no expiry) |
|
| 257 | - * @return \Aimeos\MW\View\Iface Modified view object |
|
| 258 | - */ |
|
| 259 | - protected function setViewParams( \Aimeos\MW\View\Iface $view, array &$tags = array(), &$expire = null ) |
|
| 260 | - { |
|
| 261 | - if( !isset( $this->cache ) ) |
|
| 262 | - { |
|
| 263 | - if( isset( $view->detailProductItem ) ) |
|
| 264 | - { |
|
| 265 | - $manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'product/property' ); |
|
| 251 | + /** |
|
| 252 | + * Sets the necessary parameter values in the view. |
|
| 253 | + * |
|
| 254 | + * @param \Aimeos\MW\View\Iface $view The view object which generates the HTML output |
|
| 255 | + * @param array &$tags Result array for the list of tags that are associated to the output |
|
| 256 | + * @param string|null &$expire Result variable for the expiration date of the output (null for no expiry) |
|
| 257 | + * @return \Aimeos\MW\View\Iface Modified view object |
|
| 258 | + */ |
|
| 259 | + protected function setViewParams( \Aimeos\MW\View\Iface $view, array &$tags = array(), &$expire = null ) |
|
| 260 | + { |
|
| 261 | + if( !isset( $this->cache ) ) |
|
| 262 | + { |
|
| 263 | + if( isset( $view->detailProductItem ) ) |
|
| 264 | + { |
|
| 265 | + $manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'product/property' ); |
|
| 266 | 266 | |
| 267 | - $search = $manager->createSearch( true ); |
|
| 268 | - $expr = array( |
|
| 269 | - $search->compare( '==', 'product.property.parentid', $view->detailProductItem->getId() ), |
|
| 270 | - $search->getConditions(), |
|
| 271 | - ); |
|
| 272 | - $search->setConditions( $search->combine( '&&', $expr ) ); |
|
| 267 | + $search = $manager->createSearch( true ); |
|
| 268 | + $expr = array( |
|
| 269 | + $search->compare( '==', 'product.property.parentid', $view->detailProductItem->getId() ), |
|
| 270 | + $search->getConditions(), |
|
| 271 | + ); |
|
| 272 | + $search->setConditions( $search->combine( '&&', $expr ) ); |
|
| 273 | 273 | |
| 274 | - $properties = $manager->searchItems( $search ); |
|
| 274 | + $properties = $manager->searchItems( $search ); |
|
| 275 | 275 | |
| 276 | - $view->propertyItems = $properties; |
|
| 277 | - } |
|
| 276 | + $view->propertyItems = $properties; |
|
| 277 | + } |
|
| 278 | 278 | |
| 279 | - $this->cache = $view; |
|
| 280 | - } |
|
| 279 | + $this->cache = $view; |
|
| 280 | + } |
|
| 281 | 281 | |
| 282 | - return $this->cache; |
|
| 283 | - } |
|
| 282 | + return $this->cache; |
|
| 283 | + } |
|
| 284 | 284 | } |
| 285 | 285 | \ No newline at end of file |
@@ -19,230 +19,230 @@ |
||
| 19 | 19 | * @subpackage Html |
| 20 | 20 | */ |
| 21 | 21 | class Standard |
| 22 | - extends \Aimeos\Client\Html\Base |
|
| 22 | + extends \Aimeos\Client\Html\Base |
|
| 23 | 23 | { |
| 24 | - /** client/html/basket/mini/product/standard/subparts |
|
| 25 | - * List of HTML sub-clients rendered within the basket mini product section |
|
| 26 | - * |
|
| 27 | - * The output of the frontend is composed of the code generated by the HTML |
|
| 28 | - * clients. Each HTML client can consist of serveral (or none) sub-clients |
|
| 29 | - * that are responsible for rendering certain sub-parts of the output. The |
|
| 30 | - * sub-clients can contain HTML clients themselves and therefore a |
|
| 31 | - * hierarchical tree of HTML clients is composed. Each HTML client creates |
|
| 32 | - * the output that is placed inside the container of its parent. |
|
| 33 | - * |
|
| 34 | - * At first, always the HTML code generated by the parent is printed, then |
|
| 35 | - * the HTML code of its sub-clients. The order of the HTML sub-clients |
|
| 36 | - * determines the order of the output of these sub-clients inside the parent |
|
| 37 | - * container. If the configured list of clients is |
|
| 38 | - * |
|
| 39 | - * array( "subclient1", "subclient2" ) |
|
| 40 | - * |
|
| 41 | - * you can easily change the order of the output by reordering the subparts: |
|
| 42 | - * |
|
| 43 | - * client/html/<clients>/subparts = array( "subclient1", "subclient2" ) |
|
| 44 | - * |
|
| 45 | - * You can also remove one or more parts if they shouldn't be rendered: |
|
| 46 | - * |
|
| 47 | - * client/html/<clients>/subparts = array( "subclient1" ) |
|
| 48 | - * |
|
| 49 | - * As the clients only generates structural HTML, the layout defined via CSS |
|
| 50 | - * should support adding, removing or reordering content by a fluid like |
|
| 51 | - * design. |
|
| 52 | - * |
|
| 53 | - * @param array List of sub-client names |
|
| 54 | - * @since 2015.09 |
|
| 55 | - * @category Developer |
|
| 56 | - */ |
|
| 57 | - private $subPartPath = 'client/html/basket/mini/product/standard/subparts'; |
|
| 58 | - private $subPartNames = array(); |
|
| 59 | - |
|
| 60 | - |
|
| 61 | - /** |
|
| 62 | - * Returns the HTML code for insertion into the body. |
|
| 63 | - * |
|
| 64 | - * @param string $uid Unique identifier for the output if the content is placed more than once on the same page |
|
| 65 | - * @param array &$tags Result array for the list of tags that are associated to the output |
|
| 66 | - * @param string|null &$expire Result variable for the expiration date of the output (null for no expiry) |
|
| 67 | - * @return string HTML code |
|
| 68 | - */ |
|
| 69 | - public function getBody($uid = '', array &$tags = array(), &$expire = null) |
|
| 70 | - { |
|
| 71 | - $view = $this->setViewParams($this->getView(), $tags, $expire); |
|
| 72 | - |
|
| 73 | - $html = ''; |
|
| 74 | - foreach( $this->getSubClients() as $subclient ) { |
|
| 75 | - $html .= $subclient->setView( $view )->getBody( $uid, $tags, $expire ); |
|
| 76 | - } |
|
| 77 | - $view->productBody = $html; |
|
| 78 | - |
|
| 79 | - /** client/html/basket/mini/product/standard/template-body |
|
| 80 | - * Relative path to the HTML body template of the basket mini product client. |
|
| 81 | - * |
|
| 82 | - * The template file contains the HTML code and processing instructions |
|
| 83 | - * to generate the result shown in the body of the frontend. The |
|
| 84 | - * configuration string is the path to the template file relative |
|
| 85 | - * to the templates directory (usually in client/html/templates). |
|
| 86 | - * |
|
| 87 | - * You can overwrite the template file configuration in extensions and |
|
| 88 | - * provide alternative templates. These alternative templates should be |
|
| 89 | - * named like the default one but with the string "standard" replaced by |
|
| 90 | - * an unique name. You may use the name of your project for this. If |
|
| 91 | - * you've implemented an alternative client class as well, "standard" |
|
| 92 | - * should be replaced by the name of the new class. |
|
| 93 | - * |
|
| 94 | - * @param string Relative path to the template creating code for the HTML page body |
|
| 95 | - * @since 2015.09 |
|
| 96 | - * @category Developer |
|
| 97 | - * @see client/html/basket/mini/product/standard/template-header |
|
| 98 | - */ |
|
| 99 | - $tplconf = 'client/html/basket/mini/product/standard/template-body'; |
|
| 100 | - $default = 'basket/mini/product-body-default.php'; |
|
| 101 | - |
|
| 102 | - return $view->render( $view->config( $tplconf, $default ) ); |
|
| 103 | - } |
|
| 104 | - |
|
| 105 | - |
|
| 106 | - /** |
|
| 107 | - * Returns the HTML string for insertion into the header. |
|
| 108 | - * |
|
| 109 | - * @param string $uid Unique identifier for the output if the content is placed more than once on the same page |
|
| 110 | - * @param array &$tags Result array for the list of tags that are associated to the output |
|
| 111 | - * @param string|null &$expire Result variable for the expiration date of the output (null for no expiry) |
|
| 112 | - * @return string|null String including HTML tags for the header on error |
|
| 113 | - */ |
|
| 114 | - public function getHeader($uid = '', array &$tags = array(), &$expire = null) |
|
| 115 | - { |
|
| 116 | - $view = $this->setViewParams( $this->getView(), $tags, $expire ); |
|
| 117 | - |
|
| 118 | - $html = ''; |
|
| 119 | - foreach( $this->getSubClients() as $subclient ) { |
|
| 120 | - $html .= $subclient->setView( $view )->getHeader( $uid, $tags, $expire ); |
|
| 121 | - } |
|
| 122 | - $view->productHeader = $html; |
|
| 123 | - |
|
| 124 | - /** client/html/basket/mini/product/standard/template-header |
|
| 125 | - * Relative path to the HTML header template of the basket mini product client. |
|
| 126 | - * |
|
| 127 | - * The template file contains the HTML code and processing instructions |
|
| 128 | - * to generate the HTML code that is inserted into the HTML page header |
|
| 129 | - * of the rendered page in the frontend. The configuration string is the |
|
| 130 | - * path to the template file relative to the templates directory (usually |
|
| 131 | - * in client/html/templates). |
|
| 132 | - * |
|
| 133 | - * You can overwrite the template file configuration in extensions and |
|
| 134 | - * provide alternative templates. These alternative templates should be |
|
| 135 | - * named like the default one but with the string "standard" replaced by |
|
| 136 | - * an unique name. You may use the name of your project for this. If |
|
| 137 | - * you've implemented an alternative client class as well, "standard" |
|
| 138 | - * should be replaced by the name of the new class. |
|
| 139 | - * |
|
| 140 | - * @param string Relative path to the template creating code for the HTML page head |
|
| 141 | - * @since 2015.09 |
|
| 142 | - * @category Developer |
|
| 143 | - * @see client/html/basket/mini/product/standard/template-body |
|
| 144 | - */ |
|
| 145 | - $tplconf = 'client/html/basket/mini/product/standard/template-header'; |
|
| 146 | - $default = 'basket/mini/product-header-default.php'; |
|
| 147 | - |
|
| 148 | - return $view->render( $view->config( $tplconf, $default ) ); |
|
| 149 | - } |
|
| 150 | - |
|
| 151 | - |
|
| 152 | - /** |
|
| 153 | - * Returns the sub-client given by its name. |
|
| 154 | - * |
|
| 155 | - * @param string $type Name of the client type |
|
| 156 | - * @param string|null $name Name of the sub-client (Default if null) |
|
| 157 | - * @return \Aimeos\Client\Html\Iface Sub-client object |
|
| 158 | - */ |
|
| 159 | - public function getSubClient($type, $name = null) |
|
| 160 | - { |
|
| 161 | - /** client/html/basket/mini/product/decorators/excludes |
|
| 162 | - * Excludes decorators added by the "common" option from the basket mini product html client |
|
| 163 | - * |
|
| 164 | - * Decorators extend the functionality of a class by adding new aspects |
|
| 165 | - * (e.g. log what is currently done), executing the methods of the underlying |
|
| 166 | - * class only in certain conditions (e.g. only for logged in users) or |
|
| 167 | - * modify what is returned to the caller. |
|
| 168 | - * |
|
| 169 | - * This option allows you to remove a decorator added via |
|
| 170 | - * "client/html/common/decorators/default" before they are wrapped |
|
| 171 | - * around the html client. |
|
| 172 | - * |
|
| 173 | - * client/html/basket/mini/product/decorators/excludes = array( 'decorator1' ) |
|
| 174 | - * |
|
| 175 | - * This would remove the decorator named "decorator1" from the list of |
|
| 176 | - * common decorators ("\Aimeos\Client\Html\Common\Decorator\*") added via |
|
| 177 | - * "client/html/common/decorators/default" to the html client. |
|
| 178 | - * |
|
| 179 | - * @param array List of decorator names |
|
| 180 | - * @since 2015.08 |
|
| 181 | - * @category Developer |
|
| 182 | - * @see client/html/common/decorators/default |
|
| 183 | - * @see client/html/basket/mini/product/decorators/global |
|
| 184 | - * @see client/html/basket/mini/product/decorators/local |
|
| 185 | - */ |
|
| 186 | - |
|
| 187 | - /** client/html/basket/mini/product/decorators/global |
|
| 188 | - * Adds a list of globally available decorators only to the basket mini product html client |
|
| 189 | - * |
|
| 190 | - * Decorators extend the functionality of a class by adding new aspects |
|
| 191 | - * (e.g. log what is currently done), executing the methods of the underlying |
|
| 192 | - * class only in certain conditions (e.g. only for logged in users) or |
|
| 193 | - * modify what is returned to the caller. |
|
| 194 | - * |
|
| 195 | - * This option allows you to wrap global decorators |
|
| 196 | - * ("\Aimeos\Client\Html\Common\Decorator\*") around the html client. |
|
| 197 | - * |
|
| 198 | - * client/html/basket/mini/product/decorators/global = array( 'decorator1' ) |
|
| 199 | - * |
|
| 200 | - * This would add the decorator named "decorator1" defined by |
|
| 201 | - * "\Aimeos\Client\Html\Common\Decorator\Decorator1" only to the html client. |
|
| 202 | - * |
|
| 203 | - * @param array List of decorator names |
|
| 204 | - * @since 2015.08 |
|
| 205 | - * @category Developer |
|
| 206 | - * @see client/html/common/decorators/default |
|
| 207 | - * @see client/html/basket/mini/product/decorators/excludes |
|
| 208 | - * @see client/html/basket/mini/product/decorators/local |
|
| 209 | - */ |
|
| 210 | - |
|
| 211 | - /** client/html/basket/mini/product/decorators/local |
|
| 212 | - * Adds a list of local decorators only to the basket mini product html client |
|
| 213 | - * |
|
| 214 | - * Decorators extend the functionality of a class by adding new aspects |
|
| 215 | - * (e.g. log what is currently done), executing the methods of the underlying |
|
| 216 | - * class only in certain conditions (e.g. only for logged in users) or |
|
| 217 | - * modify what is returned to the caller. |
|
| 218 | - * |
|
| 219 | - * This option allows you to wrap local decorators |
|
| 220 | - * ("\Aimeos\Client\Html\Basket\Decorator\*") around the html client. |
|
| 221 | - * |
|
| 222 | - * client/html/basket/mini/product/decorators/local = array( 'decorator2' ) |
|
| 223 | - * |
|
| 224 | - * This would add the decorator named "decorator2" defined by |
|
| 225 | - * "\Aimeos\Client\Html\Basket\Decorator\Decorator2" only to the html client. |
|
| 226 | - * |
|
| 227 | - * @param array List of decorator names |
|
| 228 | - * @since 2015.08 |
|
| 229 | - * @category Developer |
|
| 230 | - * @see client/html/common/decorators/default |
|
| 231 | - * @see client/html/basket/mini/product/decorators/excludes |
|
| 232 | - * @see client/html/basket/mini/product/decorators/global |
|
| 233 | - */ |
|
| 234 | - |
|
| 235 | - return $this->createSubClient( 'basket/mini/product/' . $type, $name ); |
|
| 236 | - } |
|
| 237 | - |
|
| 238 | - |
|
| 239 | - /** |
|
| 240 | - * Returns the list of sub-client names configured for the client. |
|
| 241 | - * |
|
| 242 | - * @return array List of HTML client names |
|
| 243 | - */ |
|
| 244 | - protected function getSubClientNames() |
|
| 245 | - { |
|
| 246 | - return $this->getContext()->getConfig()->get( $this->subPartPath, $this->subPartNames ); |
|
| 247 | - } |
|
| 24 | + /** client/html/basket/mini/product/standard/subparts |
|
| 25 | + * List of HTML sub-clients rendered within the basket mini product section |
|
| 26 | + * |
|
| 27 | + * The output of the frontend is composed of the code generated by the HTML |
|
| 28 | + * clients. Each HTML client can consist of serveral (or none) sub-clients |
|
| 29 | + * that are responsible for rendering certain sub-parts of the output. The |
|
| 30 | + * sub-clients can contain HTML clients themselves and therefore a |
|
| 31 | + * hierarchical tree of HTML clients is composed. Each HTML client creates |
|
| 32 | + * the output that is placed inside the container of its parent. |
|
| 33 | + * |
|
| 34 | + * At first, always the HTML code generated by the parent is printed, then |
|
| 35 | + * the HTML code of its sub-clients. The order of the HTML sub-clients |
|
| 36 | + * determines the order of the output of these sub-clients inside the parent |
|
| 37 | + * container. If the configured list of clients is |
|
| 38 | + * |
|
| 39 | + * array( "subclient1", "subclient2" ) |
|
| 40 | + * |
|
| 41 | + * you can easily change the order of the output by reordering the subparts: |
|
| 42 | + * |
|
| 43 | + * client/html/<clients>/subparts = array( "subclient1", "subclient2" ) |
|
| 44 | + * |
|
| 45 | + * You can also remove one or more parts if they shouldn't be rendered: |
|
| 46 | + * |
|
| 47 | + * client/html/<clients>/subparts = array( "subclient1" ) |
|
| 48 | + * |
|
| 49 | + * As the clients only generates structural HTML, the layout defined via CSS |
|
| 50 | + * should support adding, removing or reordering content by a fluid like |
|
| 51 | + * design. |
|
| 52 | + * |
|
| 53 | + * @param array List of sub-client names |
|
| 54 | + * @since 2015.09 |
|
| 55 | + * @category Developer |
|
| 56 | + */ |
|
| 57 | + private $subPartPath = 'client/html/basket/mini/product/standard/subparts'; |
|
| 58 | + private $subPartNames = array(); |
|
| 59 | + |
|
| 60 | + |
|
| 61 | + /** |
|
| 62 | + * Returns the HTML code for insertion into the body. |
|
| 63 | + * |
|
| 64 | + * @param string $uid Unique identifier for the output if the content is placed more than once on the same page |
|
| 65 | + * @param array &$tags Result array for the list of tags that are associated to the output |
|
| 66 | + * @param string|null &$expire Result variable for the expiration date of the output (null for no expiry) |
|
| 67 | + * @return string HTML code |
|
| 68 | + */ |
|
| 69 | + public function getBody($uid = '', array &$tags = array(), &$expire = null) |
|
| 70 | + { |
|
| 71 | + $view = $this->setViewParams($this->getView(), $tags, $expire); |
|
| 72 | + |
|
| 73 | + $html = ''; |
|
| 74 | + foreach( $this->getSubClients() as $subclient ) { |
|
| 75 | + $html .= $subclient->setView( $view )->getBody( $uid, $tags, $expire ); |
|
| 76 | + } |
|
| 77 | + $view->productBody = $html; |
|
| 78 | + |
|
| 79 | + /** client/html/basket/mini/product/standard/template-body |
|
| 80 | + * Relative path to the HTML body template of the basket mini product client. |
|
| 81 | + * |
|
| 82 | + * The template file contains the HTML code and processing instructions |
|
| 83 | + * to generate the result shown in the body of the frontend. The |
|
| 84 | + * configuration string is the path to the template file relative |
|
| 85 | + * to the templates directory (usually in client/html/templates). |
|
| 86 | + * |
|
| 87 | + * You can overwrite the template file configuration in extensions and |
|
| 88 | + * provide alternative templates. These alternative templates should be |
|
| 89 | + * named like the default one but with the string "standard" replaced by |
|
| 90 | + * an unique name. You may use the name of your project for this. If |
|
| 91 | + * you've implemented an alternative client class as well, "standard" |
|
| 92 | + * should be replaced by the name of the new class. |
|
| 93 | + * |
|
| 94 | + * @param string Relative path to the template creating code for the HTML page body |
|
| 95 | + * @since 2015.09 |
|
| 96 | + * @category Developer |
|
| 97 | + * @see client/html/basket/mini/product/standard/template-header |
|
| 98 | + */ |
|
| 99 | + $tplconf = 'client/html/basket/mini/product/standard/template-body'; |
|
| 100 | + $default = 'basket/mini/product-body-default.php'; |
|
| 101 | + |
|
| 102 | + return $view->render( $view->config( $tplconf, $default ) ); |
|
| 103 | + } |
|
| 104 | + |
|
| 105 | + |
|
| 106 | + /** |
|
| 107 | + * Returns the HTML string for insertion into the header. |
|
| 108 | + * |
|
| 109 | + * @param string $uid Unique identifier for the output if the content is placed more than once on the same page |
|
| 110 | + * @param array &$tags Result array for the list of tags that are associated to the output |
|
| 111 | + * @param string|null &$expire Result variable for the expiration date of the output (null for no expiry) |
|
| 112 | + * @return string|null String including HTML tags for the header on error |
|
| 113 | + */ |
|
| 114 | + public function getHeader($uid = '', array &$tags = array(), &$expire = null) |
|
| 115 | + { |
|
| 116 | + $view = $this->setViewParams( $this->getView(), $tags, $expire ); |
|
| 117 | + |
|
| 118 | + $html = ''; |
|
| 119 | + foreach( $this->getSubClients() as $subclient ) { |
|
| 120 | + $html .= $subclient->setView( $view )->getHeader( $uid, $tags, $expire ); |
|
| 121 | + } |
|
| 122 | + $view->productHeader = $html; |
|
| 123 | + |
|
| 124 | + /** client/html/basket/mini/product/standard/template-header |
|
| 125 | + * Relative path to the HTML header template of the basket mini product client. |
|
| 126 | + * |
|
| 127 | + * The template file contains the HTML code and processing instructions |
|
| 128 | + * to generate the HTML code that is inserted into the HTML page header |
|
| 129 | + * of the rendered page in the frontend. The configuration string is the |
|
| 130 | + * path to the template file relative to the templates directory (usually |
|
| 131 | + * in client/html/templates). |
|
| 132 | + * |
|
| 133 | + * You can overwrite the template file configuration in extensions and |
|
| 134 | + * provide alternative templates. These alternative templates should be |
|
| 135 | + * named like the default one but with the string "standard" replaced by |
|
| 136 | + * an unique name. You may use the name of your project for this. If |
|
| 137 | + * you've implemented an alternative client class as well, "standard" |
|
| 138 | + * should be replaced by the name of the new class. |
|
| 139 | + * |
|
| 140 | + * @param string Relative path to the template creating code for the HTML page head |
|
| 141 | + * @since 2015.09 |
|
| 142 | + * @category Developer |
|
| 143 | + * @see client/html/basket/mini/product/standard/template-body |
|
| 144 | + */ |
|
| 145 | + $tplconf = 'client/html/basket/mini/product/standard/template-header'; |
|
| 146 | + $default = 'basket/mini/product-header-default.php'; |
|
| 147 | + |
|
| 148 | + return $view->render( $view->config( $tplconf, $default ) ); |
|
| 149 | + } |
|
| 150 | + |
|
| 151 | + |
|
| 152 | + /** |
|
| 153 | + * Returns the sub-client given by its name. |
|
| 154 | + * |
|
| 155 | + * @param string $type Name of the client type |
|
| 156 | + * @param string|null $name Name of the sub-client (Default if null) |
|
| 157 | + * @return \Aimeos\Client\Html\Iface Sub-client object |
|
| 158 | + */ |
|
| 159 | + public function getSubClient($type, $name = null) |
|
| 160 | + { |
|
| 161 | + /** client/html/basket/mini/product/decorators/excludes |
|
| 162 | + * Excludes decorators added by the "common" option from the basket mini product html client |
|
| 163 | + * |
|
| 164 | + * Decorators extend the functionality of a class by adding new aspects |
|
| 165 | + * (e.g. log what is currently done), executing the methods of the underlying |
|
| 166 | + * class only in certain conditions (e.g. only for logged in users) or |
|
| 167 | + * modify what is returned to the caller. |
|
| 168 | + * |
|
| 169 | + * This option allows you to remove a decorator added via |
|
| 170 | + * "client/html/common/decorators/default" before they are wrapped |
|
| 171 | + * around the html client. |
|
| 172 | + * |
|
| 173 | + * client/html/basket/mini/product/decorators/excludes = array( 'decorator1' ) |
|
| 174 | + * |
|
| 175 | + * This would remove the decorator named "decorator1" from the list of |
|
| 176 | + * common decorators ("\Aimeos\Client\Html\Common\Decorator\*") added via |
|
| 177 | + * "client/html/common/decorators/default" to the html client. |
|
| 178 | + * |
|
| 179 | + * @param array List of decorator names |
|
| 180 | + * @since 2015.08 |
|
| 181 | + * @category Developer |
|
| 182 | + * @see client/html/common/decorators/default |
|
| 183 | + * @see client/html/basket/mini/product/decorators/global |
|
| 184 | + * @see client/html/basket/mini/product/decorators/local |
|
| 185 | + */ |
|
| 186 | + |
|
| 187 | + /** client/html/basket/mini/product/decorators/global |
|
| 188 | + * Adds a list of globally available decorators only to the basket mini product html client |
|
| 189 | + * |
|
| 190 | + * Decorators extend the functionality of a class by adding new aspects |
|
| 191 | + * (e.g. log what is currently done), executing the methods of the underlying |
|
| 192 | + * class only in certain conditions (e.g. only for logged in users) or |
|
| 193 | + * modify what is returned to the caller. |
|
| 194 | + * |
|
| 195 | + * This option allows you to wrap global decorators |
|
| 196 | + * ("\Aimeos\Client\Html\Common\Decorator\*") around the html client. |
|
| 197 | + * |
|
| 198 | + * client/html/basket/mini/product/decorators/global = array( 'decorator1' ) |
|
| 199 | + * |
|
| 200 | + * This would add the decorator named "decorator1" defined by |
|
| 201 | + * "\Aimeos\Client\Html\Common\Decorator\Decorator1" only to the html client. |
|
| 202 | + * |
|
| 203 | + * @param array List of decorator names |
|
| 204 | + * @since 2015.08 |
|
| 205 | + * @category Developer |
|
| 206 | + * @see client/html/common/decorators/default |
|
| 207 | + * @see client/html/basket/mini/product/decorators/excludes |
|
| 208 | + * @see client/html/basket/mini/product/decorators/local |
|
| 209 | + */ |
|
| 210 | + |
|
| 211 | + /** client/html/basket/mini/product/decorators/local |
|
| 212 | + * Adds a list of local decorators only to the basket mini product html client |
|
| 213 | + * |
|
| 214 | + * Decorators extend the functionality of a class by adding new aspects |
|
| 215 | + * (e.g. log what is currently done), executing the methods of the underlying |
|
| 216 | + * class only in certain conditions (e.g. only for logged in users) or |
|
| 217 | + * modify what is returned to the caller. |
|
| 218 | + * |
|
| 219 | + * This option allows you to wrap local decorators |
|
| 220 | + * ("\Aimeos\Client\Html\Basket\Decorator\*") around the html client. |
|
| 221 | + * |
|
| 222 | + * client/html/basket/mini/product/decorators/local = array( 'decorator2' ) |
|
| 223 | + * |
|
| 224 | + * This would add the decorator named "decorator2" defined by |
|
| 225 | + * "\Aimeos\Client\Html\Basket\Decorator\Decorator2" only to the html client. |
|
| 226 | + * |
|
| 227 | + * @param array List of decorator names |
|
| 228 | + * @since 2015.08 |
|
| 229 | + * @category Developer |
|
| 230 | + * @see client/html/common/decorators/default |
|
| 231 | + * @see client/html/basket/mini/product/decorators/excludes |
|
| 232 | + * @see client/html/basket/mini/product/decorators/global |
|
| 233 | + */ |
|
| 234 | + |
|
| 235 | + return $this->createSubClient( 'basket/mini/product/' . $type, $name ); |
|
| 236 | + } |
|
| 237 | + |
|
| 238 | + |
|
| 239 | + /** |
|
| 240 | + * Returns the list of sub-client names configured for the client. |
|
| 241 | + * |
|
| 242 | + * @return array List of HTML client names |
|
| 243 | + */ |
|
| 244 | + protected function getSubClientNames() |
|
| 245 | + { |
|
| 246 | + return $this->getContext()->getConfig()->get( $this->subPartPath, $this->subPartNames ); |
|
| 247 | + } |
|
| 248 | 248 | } |
| 249 | 249 | \ No newline at end of file |
@@ -19,536 +19,536 @@ |
||
| 19 | 19 | * @subpackage Html |
| 20 | 20 | */ |
| 21 | 21 | class Standard |
| 22 | - extends \Aimeos\Client\Html\Basket\Base |
|
| 23 | - implements \Aimeos\Client\Html\Common\Client\Factory\Iface |
|
| 22 | + extends \Aimeos\Client\Html\Basket\Base |
|
| 23 | + implements \Aimeos\Client\Html\Common\Client\Factory\Iface |
|
| 24 | 24 | { |
| 25 | - /** client/html/basket/standard/standard/subparts |
|
| 26 | - * List of HTML sub-clients rendered within the basket standard 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.03 |
|
| 56 | - * @category Developer |
|
| 57 | - */ |
|
| 58 | - private $subPartPath = 'client/html/basket/standard/standard/subparts'; |
|
| 59 | - |
|
| 60 | - /** client/html/basket/standard/detail/name |
|
| 61 | - * Name of the detail part used by the basket standard detail client implementation |
|
| 62 | - * |
|
| 63 | - * Use "Myname" if your class is named "\Aimeos\Client\Html\Basket\Standard\Detail\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.03 |
|
| 68 | - * @category Developer |
|
| 69 | - */ |
|
| 70 | - |
|
| 71 | - /** client/html/basket/standard/coupon/name |
|
| 72 | - * Name of the detail part used by the basket standard coupon client implementation |
|
| 73 | - * |
|
| 74 | - * Use "Myname" if your class is named "\Aimeos\Client\Html\Basket\Standard\Detail\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.03 |
|
| 79 | - * @category Developer |
|
| 80 | - */ |
|
| 81 | - private $subPartNames = array( 'detail', 'coupon' ); |
|
| 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->standardBody = $html; |
|
| 107 | - } |
|
| 108 | - catch( \Aimeos\Client\Html\Exception $e ) |
|
| 109 | - { |
|
| 110 | - $error = array( $this->getContext()->getI18n()->dt( 'client', $e->getMessage() ) ); |
|
| 111 | - $view->standardErrorList = $view->get( 'standardErrorList', array() ) + $error; |
|
| 112 | - } |
|
| 113 | - catch( \Aimeos\Controller\Frontend\Exception $e ) |
|
| 114 | - { |
|
| 115 | - $error = array( $this->getContext()->getI18n()->dt( 'controller/frontend', $e->getMessage() ) ); |
|
| 116 | - $view->standardErrorList = $view->get( 'standardErrorList', array() ) + $error; |
|
| 117 | - } |
|
| 118 | - catch( \Aimeos\MShop\Exception $e ) |
|
| 119 | - { |
|
| 120 | - $error = array( $this->getContext()->getI18n()->dt( 'mshop', $e->getMessage() ) ); |
|
| 121 | - $view->standardErrorList = $view->get( 'standardErrorList', 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->standardErrorList = $view->get( 'standardErrorList', array() ) + $error; |
|
| 129 | - } |
|
| 130 | - |
|
| 131 | - /** client/html/basket/standard/standard/template-body |
|
| 132 | - * Relative path to the HTML body template of the basket standard 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.03 |
|
| 148 | - * @category Developer |
|
| 149 | - * @see client/html/basket/standard/standard/template-header |
|
| 150 | - */ |
|
| 151 | - $tplconf = 'client/html/basket/standard/standard/template-body'; |
|
| 152 | - $default = 'basket/standard/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->standardHeader = $html; |
|
| 177 | - } |
|
| 178 | - catch( \Exception $e ) |
|
| 179 | - { |
|
| 180 | - $this->getContext()->getLogger()->log( $e->getMessage() . PHP_EOL . $e->getTraceAsString() ); |
|
| 181 | - return ''; |
|
| 182 | - } |
|
| 183 | - |
|
| 184 | - /** client/html/basket/standard/standard/template-header |
|
| 185 | - * Relative path to the HTML header template of the basket standard client. |
|
| 186 | - * |
|
| 187 | - * The template file contains the HTML code and processing instructions |
|
| 188 | - * to generate the HTML code that is inserted into the HTML page header |
|
| 189 | - * of the rendered page in the frontend. The configuration string is the |
|
| 190 | - * path to the template file relative to the templates directory (usually |
|
| 191 | - * in client/html/templates). |
|
| 192 | - * |
|
| 193 | - * You can overwrite the template file configuration in extensions and |
|
| 194 | - * provide alternative templates. These alternative templates should be |
|
| 195 | - * named like the default one but with the string "standard" replaced by |
|
| 196 | - * an unique name. You may use the name of your project for this. If |
|
| 197 | - * you've implemented an alternative client class as well, "standard" |
|
| 198 | - * should be replaced by the name of the new class. |
|
| 199 | - * |
|
| 200 | - * @param string Relative path to the template creating code for the HTML page head |
|
| 201 | - * @since 2014.03 |
|
| 202 | - * @category Developer |
|
| 203 | - * @see client/html/basket/standard/standard/template-body |
|
| 204 | - */ |
|
| 205 | - $tplconf = 'client/html/basket/standard/standard/template-header'; |
|
| 206 | - $default = 'basket/standard/header-default.php'; |
|
| 207 | - |
|
| 208 | - return $view->render( $view->config( $tplconf, $default ) ); |
|
| 209 | - } |
|
| 210 | - |
|
| 211 | - |
|
| 212 | - /** |
|
| 213 | - * Returns the sub-client given by its name. |
|
| 214 | - * |
|
| 215 | - * @param string $type Name of the client type |
|
| 216 | - * @param string|null $name Name of the sub-client (Default if null) |
|
| 217 | - * @return \Aimeos\Client\Html\Iface Sub-client object |
|
| 218 | - */ |
|
| 219 | - public function getSubClient( $type, $name = null ) |
|
| 220 | - { |
|
| 221 | - /** client/html/basket/standard/decorators/excludes |
|
| 222 | - * Excludes decorators added by the "common" option from the basket standard html client |
|
| 223 | - * |
|
| 224 | - * Decorators extend the functionality of a class by adding new aspects |
|
| 225 | - * (e.g. log what is currently done), executing the methods of the underlying |
|
| 226 | - * class only in certain conditions (e.g. only for logged in users) or |
|
| 227 | - * modify what is returned to the caller. |
|
| 228 | - * |
|
| 229 | - * This option allows you to remove a decorator added via |
|
| 230 | - * "client/html/common/decorators/default" before they are wrapped |
|
| 231 | - * around the html client. |
|
| 232 | - * |
|
| 233 | - * client/html/basket/standard/decorators/excludes = array( 'decorator1' ) |
|
| 234 | - * |
|
| 235 | - * This would remove the decorator named "decorator1" from the list of |
|
| 236 | - * common decorators ("\Aimeos\Client\Html\Common\Decorator\*") added via |
|
| 237 | - * "client/html/common/decorators/default" to the html client. |
|
| 238 | - * |
|
| 239 | - * @param array List of decorator names |
|
| 240 | - * @since 2014.05 |
|
| 241 | - * @category Developer |
|
| 242 | - * @see client/html/common/decorators/default |
|
| 243 | - * @see client/html/basket/standard/decorators/global |
|
| 244 | - * @see client/html/basket/standard/decorators/local |
|
| 245 | - */ |
|
| 246 | - |
|
| 247 | - /** client/html/basket/standard/decorators/global |
|
| 248 | - * Adds a list of globally available decorators only to the basket standard html client |
|
| 249 | - * |
|
| 250 | - * Decorators extend the functionality of a class by adding new aspects |
|
| 251 | - * (e.g. log what is currently done), executing the methods of the underlying |
|
| 252 | - * class only in certain conditions (e.g. only for logged in users) or |
|
| 253 | - * modify what is returned to the caller. |
|
| 254 | - * |
|
| 255 | - * This option allows you to wrap global decorators |
|
| 256 | - * ("\Aimeos\Client\Html\Common\Decorator\*") around the html client. |
|
| 257 | - * |
|
| 258 | - * client/html/basket/standard/decorators/global = array( 'decorator1' ) |
|
| 259 | - * |
|
| 260 | - * This would add the decorator named "decorator1" defined by |
|
| 261 | - * "\Aimeos\Client\Html\Common\Decorator\Decorator1" only to the html client. |
|
| 262 | - * |
|
| 263 | - * @param array List of decorator names |
|
| 264 | - * @since 2014.05 |
|
| 265 | - * @category Developer |
|
| 266 | - * @see client/html/common/decorators/default |
|
| 267 | - * @see client/html/basket/standard/decorators/excludes |
|
| 268 | - * @see client/html/basket/standard/decorators/local |
|
| 269 | - */ |
|
| 270 | - |
|
| 271 | - /** client/html/basket/standard/decorators/local |
|
| 272 | - * Adds a list of local decorators only to the basket standard html client |
|
| 273 | - * |
|
| 274 | - * Decorators extend the functionality of a class by adding new aspects |
|
| 275 | - * (e.g. log what is currently done), executing the methods of the underlying |
|
| 276 | - * class only in certain conditions (e.g. only for logged in users) or |
|
| 277 | - * modify what is returned to the caller. |
|
| 278 | - * |
|
| 279 | - * This option allows you to wrap local decorators |
|
| 280 | - * ("\Aimeos\Client\Html\Basket\Decorator\*") around the html client. |
|
| 281 | - * |
|
| 282 | - * client/html/basket/standard/decorators/local = array( 'decorator2' ) |
|
| 283 | - * |
|
| 284 | - * This would add the decorator named "decorator2" defined by |
|
| 285 | - * "\Aimeos\Client\Html\Basket\Decorator\Decorator2" only to the html client. |
|
| 286 | - * |
|
| 287 | - * @param array List of decorator names |
|
| 288 | - * @since 2014.05 |
|
| 289 | - * @category Developer |
|
| 290 | - * @see client/html/common/decorators/default |
|
| 291 | - * @see client/html/basket/standard/decorators/excludes |
|
| 292 | - * @see client/html/basket/standard/decorators/global |
|
| 293 | - */ |
|
| 294 | - |
|
| 295 | - return $this->createSubClient( 'basket/standard/' . $type, $name ); |
|
| 296 | - } |
|
| 297 | - |
|
| 298 | - |
|
| 299 | - /** |
|
| 300 | - * Sets the necessary parameter values in the view. |
|
| 301 | - */ |
|
| 302 | - public function process() |
|
| 303 | - { |
|
| 304 | - $view = $this->getView(); |
|
| 305 | - $context = $this->getContext(); |
|
| 306 | - |
|
| 307 | - try |
|
| 308 | - { |
|
| 309 | - $options = array( |
|
| 310 | - |
|
| 311 | - /** client/html/basket/require-stock |
|
| 312 | - * Customers can order products only if there are enough products in stock |
|
| 313 | - * |
|
| 314 | - * Checks that the requested product quantity is in stock before |
|
| 315 | - * the customer can add them to his basket and order them. If there |
|
| 316 | - * are not enough products available, the customer will get a notice. |
|
| 317 | - * |
|
| 318 | - * @param boolean True if products must be in stock, false if products can be sold without stock |
|
| 319 | - * @since 2014.03 |
|
| 320 | - * @category Developer |
|
| 321 | - * @category User |
|
| 322 | - */ |
|
| 323 | - 'stock' => $view->config( 'client/html/basket/require-stock', true ), |
|
| 324 | - |
|
| 325 | - /** client/html/basket/require-variant |
|
| 326 | - * A variant of a selection product must be chosen |
|
| 327 | - * |
|
| 328 | - * Selection products normally consist of several article variants and by default |
|
| 329 | - * exactly one article variant of a selection product can be put into the basket. |
|
| 330 | - * |
|
| 331 | - * By setting this option to false, the selection product including the chosen |
|
| 332 | - * attributes (if any attribute values were selected) can be put into the basket |
|
| 333 | - * as well. This makes it possible to get all articles or a subset of articles |
|
| 334 | - * (e.g. all of a color) at once. |
|
| 335 | - * |
|
| 336 | - * @param boolean True if a variant must be chosen, false if also the selection product with attributes can be added |
|
| 337 | - * @since 2014.03 |
|
| 338 | - * @category Developer |
|
| 339 | - * @category User |
|
| 340 | - */ |
|
| 341 | - 'variant' => $view->config( 'client/html/basket/require-variant', true ), |
|
| 342 | - ); |
|
| 343 | - |
|
| 344 | - switch( $view->param( 'b_action' ) ) |
|
| 345 | - { |
|
| 346 | - case 'add': |
|
| 347 | - $this->addProducts( $view, $options ); |
|
| 348 | - break; |
|
| 349 | - case 'delete': |
|
| 350 | - $this->deleteProducts( $view ); |
|
| 351 | - break; |
|
| 352 | - default: |
|
| 353 | - $this->editProducts( $view, $options ); |
|
| 354 | - } |
|
| 355 | - |
|
| 356 | - parent::process(); |
|
| 357 | - |
|
| 358 | - $controller = \Aimeos\Controller\Frontend\Factory::createController( $context, 'basket' ); |
|
| 359 | - $controller->get()->check( \Aimeos\MShop\Order\Item\Base\Base::PARTS_PRODUCT ); |
|
| 360 | - } |
|
| 361 | - catch( \Aimeos\Client\Html\Exception $e ) |
|
| 362 | - { |
|
| 363 | - $error = array( $context->getI18n()->dt( 'client', $e->getMessage() ) ); |
|
| 364 | - $view->standardErrorList = $view->get( 'standardErrorList', array() ) + $error; |
|
| 365 | - } |
|
| 366 | - catch( \Aimeos\Controller\Frontend\Exception $e ) |
|
| 367 | - { |
|
| 368 | - $error = array( $context->getI18n()->dt( 'controller/frontend', $e->getMessage() ) ); |
|
| 369 | - $view->standardErrorList = $view->get( 'standardErrorList', array() ) + $error; |
|
| 370 | - } |
|
| 371 | - catch( \Aimeos\MShop\Plugin\Provider\Exception $e ) |
|
| 372 | - { |
|
| 373 | - $errors = array( $context->getI18n()->dt( 'mshop', $e->getMessage() ) ); |
|
| 374 | - $errors = array_merge( $errors, $this->translatePluginErrorCodes( $e->getErrorCodes() ) ); |
|
| 375 | - |
|
| 376 | - $view->summaryErrorCodes = $e->getErrorCodes(); |
|
| 377 | - $view->standardErrorList = $view->get( 'standardErrorList', array() ) + $errors; |
|
| 378 | - } |
|
| 379 | - catch( \Aimeos\MShop\Exception $e ) |
|
| 380 | - { |
|
| 381 | - $error = array( $context->getI18n()->dt( 'mshop', $e->getMessage() ) ); |
|
| 382 | - $view->standardErrorList = $view->get( 'standardErrorList', array() ) + $error; |
|
| 383 | - } |
|
| 384 | - catch( \Exception $e ) |
|
| 385 | - { |
|
| 386 | - $context->getLogger()->log( $e->getMessage() . PHP_EOL . $e->getTraceAsString() ); |
|
| 387 | - |
|
| 388 | - $error = array( $context->getI18n()->dt( 'client', 'A non-recoverable error occured' ) ); |
|
| 389 | - $view->standardErrorList = $view->get( 'standardErrorList', array() ) + $error; |
|
| 390 | - } |
|
| 391 | - } |
|
| 392 | - |
|
| 393 | - |
|
| 394 | - /** |
|
| 395 | - * Returns the list of sub-client names configured for the client. |
|
| 396 | - * |
|
| 397 | - * @return array List of HTML client names |
|
| 398 | - */ |
|
| 399 | - protected function getSubClientNames() |
|
| 400 | - { |
|
| 401 | - return $this->getContext()->getConfig()->get( $this->subPartPath, $this->subPartNames ); |
|
| 402 | - } |
|
| 403 | - |
|
| 404 | - |
|
| 405 | - /** |
|
| 406 | - * Sets the necessary parameter values in the view. |
|
| 407 | - * |
|
| 408 | - * @param \Aimeos\MW\View\Iface $view The view object which generates the HTML output |
|
| 409 | - * @param array &$tags Result array for the list of tags that are associated to the output |
|
| 410 | - * @param string|null &$expire Result variable for the expiration date of the output (null for no expiry) |
|
| 411 | - * @return \Aimeos\MW\View\Iface Modified view object |
|
| 412 | - */ |
|
| 413 | - protected function setViewParams( \Aimeos\MW\View\Iface $view, array &$tags = array(), &$expire = null ) |
|
| 414 | - { |
|
| 415 | - if( !isset( $this->cache ) ) |
|
| 416 | - { |
|
| 417 | - $context = $this->getContext(); |
|
| 418 | - $site = $context->getLocale()->getSite()->getCode(); |
|
| 419 | - |
|
| 420 | - if( ( $params = $context->getSession()->get( 'aimeos/catalog/detail/params/last' . $site ) ) !== null ) |
|
| 421 | - { |
|
| 422 | - $target = $view->config( 'client/html/catalog/detail/url/target' ); |
|
| 423 | - $controller = $view->config( 'client/html/catalog/detail/url/controller', 'catalog' ); |
|
| 424 | - $action = $view->config( 'client/html/catalog/detail/url/action', 'detail' ); |
|
| 425 | - $config = $view->config( 'client/html/catalog/detail/url/config', array() ); |
|
| 426 | - } |
|
| 427 | - else |
|
| 428 | - { |
|
| 429 | - $params = $context->getSession()->get( 'aimeos/catalog/lists/params/last' . $site, array() ); |
|
| 430 | - |
|
| 431 | - $target = $view->config( 'client/html/catalog/lists/url/target' ); |
|
| 432 | - $controller = $view->config( 'client/html/catalog/lists/url/controller', 'catalog' ); |
|
| 433 | - $action = $view->config( 'client/html/catalog/lists/url/action', 'list' ); |
|
| 434 | - $config = $view->config( 'client/html/catalog/lists/url/config', array() ); |
|
| 435 | - |
|
| 436 | - } |
|
| 437 | - |
|
| 438 | - if( empty( $params ) === false ) |
|
| 439 | - { |
|
| 440 | - $view->standardParams = $this->getClientParams( $view->param() ); |
|
| 441 | - $view->standardBackUrl = $view->url( $target, $controller, $action, $params, array(), $config ); |
|
| 442 | - } |
|
| 443 | - |
|
| 444 | - $view->standardBasket = \Aimeos\Controller\Frontend\Factory::createController( $context, 'basket' )->get(); |
|
| 445 | - |
|
| 446 | - $this->cache = $view; |
|
| 447 | - } |
|
| 448 | - |
|
| 449 | - return $this->cache; |
|
| 450 | - } |
|
| 451 | - |
|
| 452 | - |
|
| 453 | - /** |
|
| 454 | - * Adds the products specified by the view parameters to the basket. |
|
| 455 | - * |
|
| 456 | - * @param \Aimeos\MW\View\Iface $view View object |
|
| 457 | - * @param array $options List of options for addProducts() in basket controller |
|
| 458 | - */ |
|
| 459 | - protected function addProducts( \Aimeos\MW\View\Iface $view, array $options ) |
|
| 460 | - { |
|
| 461 | - $this->clearCached(); |
|
| 462 | - $products = (array) $view->param( 'b_prod', array() ); |
|
| 463 | - $controller = \Aimeos\Controller\Frontend\Factory::createController( $this->getContext(), 'basket' ); |
|
| 464 | - |
|
| 465 | - if( ( $prodid = $view->param( 'b_prodid', '' ) ) !== '' ) |
|
| 466 | - { |
|
| 467 | - $products[] = array( |
|
| 468 | - 'prodid' => $prodid, |
|
| 469 | - 'quantity' => $view->param( 'b_quantity', 1 ), |
|
| 470 | - 'attrvarid' => array_filter( (array) $view->param( 'b_attrvarid', array() ) ), |
|
| 471 | - 'attrconfid' => array_filter( (array) $view->param( 'b_attrconfid', array() ) ), |
|
| 472 | - 'attrhideid' => array_filter( (array) $view->param( 'b_attrhideid', array() ) ), |
|
| 473 | - 'attrcustid' => array_filter( (array) $view->param( 'b_attrcustid', array() ) ), |
|
| 474 | - 'warehouse' => $view->param( 'b_warehouse', 'default' ), |
|
| 475 | - ); |
|
| 476 | - } |
|
| 477 | - |
|
| 478 | - foreach( $products as $values ) { |
|
| 479 | - $this->addProduct( $controller, $values, $options ); |
|
| 480 | - } |
|
| 481 | - } |
|
| 482 | - |
|
| 483 | - |
|
| 484 | - /** |
|
| 485 | - * Adds a single product specified by its values to the basket. |
|
| 486 | - * |
|
| 487 | - * @param \Aimeos\Controller\Frontend\Basket\Iface $controller Basket frontend controller |
|
| 488 | - * @param array $values Associative list of key/value pairs from the view specifying the product |
|
| 489 | - * @param array $options List of options for addProducts() in basket frontend controller |
|
| 490 | - */ |
|
| 491 | - protected function addProduct( \Aimeos\Controller\Frontend\Basket\Iface $controller, array $values, array $options ) |
|
| 492 | - { |
|
| 493 | - $controller->addProduct( |
|
| 494 | - ( isset( $values['prodid'] ) ? (string) $values['prodid'] : '' ), |
|
| 495 | - ( isset( $values['quantity'] ) ? (int) $values['quantity'] : 1 ), |
|
| 496 | - $options, |
|
| 497 | - ( isset( $values['attrvarid'] ) ? array_filter( (array) $values['attrvarid'] ) : array() ), |
|
| 498 | - ( isset( $values['attrconfid'] ) ? array_filter( (array) $values['attrconfid'] ) : array() ), |
|
| 499 | - ( isset( $values['attrhideid'] ) ? array_filter( (array) $values['attrhideid'] ) : array() ), |
|
| 500 | - ( isset( $values['attrcustid'] ) ? array_filter( (array) $values['attrcustid'] ) : array() ), |
|
| 501 | - ( isset( $values['warehouse'] ) ? (string) $values['warehouse'] : 'default' ) |
|
| 502 | - ); |
|
| 503 | - } |
|
| 504 | - |
|
| 505 | - |
|
| 506 | - /** |
|
| 507 | - * Removes the products specified by the view parameters from the basket. |
|
| 508 | - * |
|
| 509 | - * @param \Aimeos\MW\View\Iface $view View object |
|
| 510 | - */ |
|
| 511 | - protected function deleteProducts( \Aimeos\MW\View\Iface $view ) |
|
| 512 | - { |
|
| 513 | - $this->clearCached(); |
|
| 514 | - $products = (array) $view->param( 'b_position', array() ); |
|
| 515 | - $controller = \Aimeos\Controller\Frontend\Factory::createController( $this->getContext(), 'basket' ); |
|
| 516 | - |
|
| 517 | - foreach( $products as $position ) { |
|
| 518 | - $controller->deleteProduct( $position ); |
|
| 519 | - } |
|
| 520 | - } |
|
| 521 | - |
|
| 522 | - |
|
| 523 | - /** |
|
| 524 | - * Edits the products specified by the view parameters to the basket. |
|
| 525 | - * |
|
| 526 | - * @param \Aimeos\MW\View\Iface $view View object |
|
| 527 | - * @param array $options List of options for editProducts() in basket controller |
|
| 528 | - */ |
|
| 529 | - protected function editProducts( \Aimeos\MW\View\Iface $view, array $options ) |
|
| 530 | - { |
|
| 531 | - $this->clearCached(); |
|
| 532 | - $products = (array) $view->param( 'b_prod', array() ); |
|
| 533 | - $controller = \Aimeos\Controller\Frontend\Factory::createController( $this->getContext(), 'basket' ); |
|
| 534 | - |
|
| 535 | - if( ( $position = $view->param( 'b_position', '' ) ) !== '' ) |
|
| 536 | - { |
|
| 537 | - $products[] = array( |
|
| 538 | - 'position' => $position, |
|
| 539 | - 'quantity' => $view->param( 'b_quantity', 1 ), |
|
| 540 | - 'attrconf-code' => array_filter( (array) $view->param( 'b_attrconfcode', array() ) ) |
|
| 541 | - ); |
|
| 542 | - } |
|
| 543 | - |
|
| 544 | - foreach( $products as $values ) |
|
| 545 | - { |
|
| 546 | - $controller->editProduct( |
|
| 547 | - ( isset( $values['position'] ) ? (int) $values['position'] : 0 ), |
|
| 548 | - ( isset( $values['quantity'] ) ? (int) $values['quantity'] : 1 ), |
|
| 549 | - $options, |
|
| 550 | - ( isset( $values['attrconf-code'] ) ? array_filter( (array) $values['attrconf-code'] ) : array() ) |
|
| 551 | - ); |
|
| 552 | - } |
|
| 553 | - } |
|
| 25 | + /** client/html/basket/standard/standard/subparts |
|
| 26 | + * List of HTML sub-clients rendered within the basket standard 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.03 |
|
| 56 | + * @category Developer |
|
| 57 | + */ |
|
| 58 | + private $subPartPath = 'client/html/basket/standard/standard/subparts'; |
|
| 59 | + |
|
| 60 | + /** client/html/basket/standard/detail/name |
|
| 61 | + * Name of the detail part used by the basket standard detail client implementation |
|
| 62 | + * |
|
| 63 | + * Use "Myname" if your class is named "\Aimeos\Client\Html\Basket\Standard\Detail\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.03 |
|
| 68 | + * @category Developer |
|
| 69 | + */ |
|
| 70 | + |
|
| 71 | + /** client/html/basket/standard/coupon/name |
|
| 72 | + * Name of the detail part used by the basket standard coupon client implementation |
|
| 73 | + * |
|
| 74 | + * Use "Myname" if your class is named "\Aimeos\Client\Html\Basket\Standard\Detail\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.03 |
|
| 79 | + * @category Developer |
|
| 80 | + */ |
|
| 81 | + private $subPartNames = array( 'detail', 'coupon' ); |
|
| 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->standardBody = $html; |
|
| 107 | + } |
|
| 108 | + catch( \Aimeos\Client\Html\Exception $e ) |
|
| 109 | + { |
|
| 110 | + $error = array( $this->getContext()->getI18n()->dt( 'client', $e->getMessage() ) ); |
|
| 111 | + $view->standardErrorList = $view->get( 'standardErrorList', array() ) + $error; |
|
| 112 | + } |
|
| 113 | + catch( \Aimeos\Controller\Frontend\Exception $e ) |
|
| 114 | + { |
|
| 115 | + $error = array( $this->getContext()->getI18n()->dt( 'controller/frontend', $e->getMessage() ) ); |
|
| 116 | + $view->standardErrorList = $view->get( 'standardErrorList', array() ) + $error; |
|
| 117 | + } |
|
| 118 | + catch( \Aimeos\MShop\Exception $e ) |
|
| 119 | + { |
|
| 120 | + $error = array( $this->getContext()->getI18n()->dt( 'mshop', $e->getMessage() ) ); |
|
| 121 | + $view->standardErrorList = $view->get( 'standardErrorList', 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->standardErrorList = $view->get( 'standardErrorList', array() ) + $error; |
|
| 129 | + } |
|
| 130 | + |
|
| 131 | + /** client/html/basket/standard/standard/template-body |
|
| 132 | + * Relative path to the HTML body template of the basket standard 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.03 |
|
| 148 | + * @category Developer |
|
| 149 | + * @see client/html/basket/standard/standard/template-header |
|
| 150 | + */ |
|
| 151 | + $tplconf = 'client/html/basket/standard/standard/template-body'; |
|
| 152 | + $default = 'basket/standard/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->standardHeader = $html; |
|
| 177 | + } |
|
| 178 | + catch( \Exception $e ) |
|
| 179 | + { |
|
| 180 | + $this->getContext()->getLogger()->log( $e->getMessage() . PHP_EOL . $e->getTraceAsString() ); |
|
| 181 | + return ''; |
|
| 182 | + } |
|
| 183 | + |
|
| 184 | + /** client/html/basket/standard/standard/template-header |
|
| 185 | + * Relative path to the HTML header template of the basket standard client. |
|
| 186 | + * |
|
| 187 | + * The template file contains the HTML code and processing instructions |
|
| 188 | + * to generate the HTML code that is inserted into the HTML page header |
|
| 189 | + * of the rendered page in the frontend. The configuration string is the |
|
| 190 | + * path to the template file relative to the templates directory (usually |
|
| 191 | + * in client/html/templates). |
|
| 192 | + * |
|
| 193 | + * You can overwrite the template file configuration in extensions and |
|
| 194 | + * provide alternative templates. These alternative templates should be |
|
| 195 | + * named like the default one but with the string "standard" replaced by |
|
| 196 | + * an unique name. You may use the name of your project for this. If |
|
| 197 | + * you've implemented an alternative client class as well, "standard" |
|
| 198 | + * should be replaced by the name of the new class. |
|
| 199 | + * |
|
| 200 | + * @param string Relative path to the template creating code for the HTML page head |
|
| 201 | + * @since 2014.03 |
|
| 202 | + * @category Developer |
|
| 203 | + * @see client/html/basket/standard/standard/template-body |
|
| 204 | + */ |
|
| 205 | + $tplconf = 'client/html/basket/standard/standard/template-header'; |
|
| 206 | + $default = 'basket/standard/header-default.php'; |
|
| 207 | + |
|
| 208 | + return $view->render( $view->config( $tplconf, $default ) ); |
|
| 209 | + } |
|
| 210 | + |
|
| 211 | + |
|
| 212 | + /** |
|
| 213 | + * Returns the sub-client given by its name. |
|
| 214 | + * |
|
| 215 | + * @param string $type Name of the client type |
|
| 216 | + * @param string|null $name Name of the sub-client (Default if null) |
|
| 217 | + * @return \Aimeos\Client\Html\Iface Sub-client object |
|
| 218 | + */ |
|
| 219 | + public function getSubClient( $type, $name = null ) |
|
| 220 | + { |
|
| 221 | + /** client/html/basket/standard/decorators/excludes |
|
| 222 | + * Excludes decorators added by the "common" option from the basket standard html client |
|
| 223 | + * |
|
| 224 | + * Decorators extend the functionality of a class by adding new aspects |
|
| 225 | + * (e.g. log what is currently done), executing the methods of the underlying |
|
| 226 | + * class only in certain conditions (e.g. only for logged in users) or |
|
| 227 | + * modify what is returned to the caller. |
|
| 228 | + * |
|
| 229 | + * This option allows you to remove a decorator added via |
|
| 230 | + * "client/html/common/decorators/default" before they are wrapped |
|
| 231 | + * around the html client. |
|
| 232 | + * |
|
| 233 | + * client/html/basket/standard/decorators/excludes = array( 'decorator1' ) |
|
| 234 | + * |
|
| 235 | + * This would remove the decorator named "decorator1" from the list of |
|
| 236 | + * common decorators ("\Aimeos\Client\Html\Common\Decorator\*") added via |
|
| 237 | + * "client/html/common/decorators/default" to the html client. |
|
| 238 | + * |
|
| 239 | + * @param array List of decorator names |
|
| 240 | + * @since 2014.05 |
|
| 241 | + * @category Developer |
|
| 242 | + * @see client/html/common/decorators/default |
|
| 243 | + * @see client/html/basket/standard/decorators/global |
|
| 244 | + * @see client/html/basket/standard/decorators/local |
|
| 245 | + */ |
|
| 246 | + |
|
| 247 | + /** client/html/basket/standard/decorators/global |
|
| 248 | + * Adds a list of globally available decorators only to the basket standard html client |
|
| 249 | + * |
|
| 250 | + * Decorators extend the functionality of a class by adding new aspects |
|
| 251 | + * (e.g. log what is currently done), executing the methods of the underlying |
|
| 252 | + * class only in certain conditions (e.g. only for logged in users) or |
|
| 253 | + * modify what is returned to the caller. |
|
| 254 | + * |
|
| 255 | + * This option allows you to wrap global decorators |
|
| 256 | + * ("\Aimeos\Client\Html\Common\Decorator\*") around the html client. |
|
| 257 | + * |
|
| 258 | + * client/html/basket/standard/decorators/global = array( 'decorator1' ) |
|
| 259 | + * |
|
| 260 | + * This would add the decorator named "decorator1" defined by |
|
| 261 | + * "\Aimeos\Client\Html\Common\Decorator\Decorator1" only to the html client. |
|
| 262 | + * |
|
| 263 | + * @param array List of decorator names |
|
| 264 | + * @since 2014.05 |
|
| 265 | + * @category Developer |
|
| 266 | + * @see client/html/common/decorators/default |
|
| 267 | + * @see client/html/basket/standard/decorators/excludes |
|
| 268 | + * @see client/html/basket/standard/decorators/local |
|
| 269 | + */ |
|
| 270 | + |
|
| 271 | + /** client/html/basket/standard/decorators/local |
|
| 272 | + * Adds a list of local decorators only to the basket standard html client |
|
| 273 | + * |
|
| 274 | + * Decorators extend the functionality of a class by adding new aspects |
|
| 275 | + * (e.g. log what is currently done), executing the methods of the underlying |
|
| 276 | + * class only in certain conditions (e.g. only for logged in users) or |
|
| 277 | + * modify what is returned to the caller. |
|
| 278 | + * |
|
| 279 | + * This option allows you to wrap local decorators |
|
| 280 | + * ("\Aimeos\Client\Html\Basket\Decorator\*") around the html client. |
|
| 281 | + * |
|
| 282 | + * client/html/basket/standard/decorators/local = array( 'decorator2' ) |
|
| 283 | + * |
|
| 284 | + * This would add the decorator named "decorator2" defined by |
|
| 285 | + * "\Aimeos\Client\Html\Basket\Decorator\Decorator2" only to the html client. |
|
| 286 | + * |
|
| 287 | + * @param array List of decorator names |
|
| 288 | + * @since 2014.05 |
|
| 289 | + * @category Developer |
|
| 290 | + * @see client/html/common/decorators/default |
|
| 291 | + * @see client/html/basket/standard/decorators/excludes |
|
| 292 | + * @see client/html/basket/standard/decorators/global |
|
| 293 | + */ |
|
| 294 | + |
|
| 295 | + return $this->createSubClient( 'basket/standard/' . $type, $name ); |
|
| 296 | + } |
|
| 297 | + |
|
| 298 | + |
|
| 299 | + /** |
|
| 300 | + * Sets the necessary parameter values in the view. |
|
| 301 | + */ |
|
| 302 | + public function process() |
|
| 303 | + { |
|
| 304 | + $view = $this->getView(); |
|
| 305 | + $context = $this->getContext(); |
|
| 306 | + |
|
| 307 | + try |
|
| 308 | + { |
|
| 309 | + $options = array( |
|
| 310 | + |
|
| 311 | + /** client/html/basket/require-stock |
|
| 312 | + * Customers can order products only if there are enough products in stock |
|
| 313 | + * |
|
| 314 | + * Checks that the requested product quantity is in stock before |
|
| 315 | + * the customer can add them to his basket and order them. If there |
|
| 316 | + * are not enough products available, the customer will get a notice. |
|
| 317 | + * |
|
| 318 | + * @param boolean True if products must be in stock, false if products can be sold without stock |
|
| 319 | + * @since 2014.03 |
|
| 320 | + * @category Developer |
|
| 321 | + * @category User |
|
| 322 | + */ |
|
| 323 | + 'stock' => $view->config( 'client/html/basket/require-stock', true ), |
|
| 324 | + |
|
| 325 | + /** client/html/basket/require-variant |
|
| 326 | + * A variant of a selection product must be chosen |
|
| 327 | + * |
|
| 328 | + * Selection products normally consist of several article variants and by default |
|
| 329 | + * exactly one article variant of a selection product can be put into the basket. |
|
| 330 | + * |
|
| 331 | + * By setting this option to false, the selection product including the chosen |
|
| 332 | + * attributes (if any attribute values were selected) can be put into the basket |
|
| 333 | + * as well. This makes it possible to get all articles or a subset of articles |
|
| 334 | + * (e.g. all of a color) at once. |
|
| 335 | + * |
|
| 336 | + * @param boolean True if a variant must be chosen, false if also the selection product with attributes can be added |
|
| 337 | + * @since 2014.03 |
|
| 338 | + * @category Developer |
|
| 339 | + * @category User |
|
| 340 | + */ |
|
| 341 | + 'variant' => $view->config( 'client/html/basket/require-variant', true ), |
|
| 342 | + ); |
|
| 343 | + |
|
| 344 | + switch( $view->param( 'b_action' ) ) |
|
| 345 | + { |
|
| 346 | + case 'add': |
|
| 347 | + $this->addProducts( $view, $options ); |
|
| 348 | + break; |
|
| 349 | + case 'delete': |
|
| 350 | + $this->deleteProducts( $view ); |
|
| 351 | + break; |
|
| 352 | + default: |
|
| 353 | + $this->editProducts( $view, $options ); |
|
| 354 | + } |
|
| 355 | + |
|
| 356 | + parent::process(); |
|
| 357 | + |
|
| 358 | + $controller = \Aimeos\Controller\Frontend\Factory::createController( $context, 'basket' ); |
|
| 359 | + $controller->get()->check( \Aimeos\MShop\Order\Item\Base\Base::PARTS_PRODUCT ); |
|
| 360 | + } |
|
| 361 | + catch( \Aimeos\Client\Html\Exception $e ) |
|
| 362 | + { |
|
| 363 | + $error = array( $context->getI18n()->dt( 'client', $e->getMessage() ) ); |
|
| 364 | + $view->standardErrorList = $view->get( 'standardErrorList', array() ) + $error; |
|
| 365 | + } |
|
| 366 | + catch( \Aimeos\Controller\Frontend\Exception $e ) |
|
| 367 | + { |
|
| 368 | + $error = array( $context->getI18n()->dt( 'controller/frontend', $e->getMessage() ) ); |
|
| 369 | + $view->standardErrorList = $view->get( 'standardErrorList', array() ) + $error; |
|
| 370 | + } |
|
| 371 | + catch( \Aimeos\MShop\Plugin\Provider\Exception $e ) |
|
| 372 | + { |
|
| 373 | + $errors = array( $context->getI18n()->dt( 'mshop', $e->getMessage() ) ); |
|
| 374 | + $errors = array_merge( $errors, $this->translatePluginErrorCodes( $e->getErrorCodes() ) ); |
|
| 375 | + |
|
| 376 | + $view->summaryErrorCodes = $e->getErrorCodes(); |
|
| 377 | + $view->standardErrorList = $view->get( 'standardErrorList', array() ) + $errors; |
|
| 378 | + } |
|
| 379 | + catch( \Aimeos\MShop\Exception $e ) |
|
| 380 | + { |
|
| 381 | + $error = array( $context->getI18n()->dt( 'mshop', $e->getMessage() ) ); |
|
| 382 | + $view->standardErrorList = $view->get( 'standardErrorList', array() ) + $error; |
|
| 383 | + } |
|
| 384 | + catch( \Exception $e ) |
|
| 385 | + { |
|
| 386 | + $context->getLogger()->log( $e->getMessage() . PHP_EOL . $e->getTraceAsString() ); |
|
| 387 | + |
|
| 388 | + $error = array( $context->getI18n()->dt( 'client', 'A non-recoverable error occured' ) ); |
|
| 389 | + $view->standardErrorList = $view->get( 'standardErrorList', array() ) + $error; |
|
| 390 | + } |
|
| 391 | + } |
|
| 392 | + |
|
| 393 | + |
|
| 394 | + /** |
|
| 395 | + * Returns the list of sub-client names configured for the client. |
|
| 396 | + * |
|
| 397 | + * @return array List of HTML client names |
|
| 398 | + */ |
|
| 399 | + protected function getSubClientNames() |
|
| 400 | + { |
|
| 401 | + return $this->getContext()->getConfig()->get( $this->subPartPath, $this->subPartNames ); |
|
| 402 | + } |
|
| 403 | + |
|
| 404 | + |
|
| 405 | + /** |
|
| 406 | + * Sets the necessary parameter values in the view. |
|
| 407 | + * |
|
| 408 | + * @param \Aimeos\MW\View\Iface $view The view object which generates the HTML output |
|
| 409 | + * @param array &$tags Result array for the list of tags that are associated to the output |
|
| 410 | + * @param string|null &$expire Result variable for the expiration date of the output (null for no expiry) |
|
| 411 | + * @return \Aimeos\MW\View\Iface Modified view object |
|
| 412 | + */ |
|
| 413 | + protected function setViewParams( \Aimeos\MW\View\Iface $view, array &$tags = array(), &$expire = null ) |
|
| 414 | + { |
|
| 415 | + if( !isset( $this->cache ) ) |
|
| 416 | + { |
|
| 417 | + $context = $this->getContext(); |
|
| 418 | + $site = $context->getLocale()->getSite()->getCode(); |
|
| 419 | + |
|
| 420 | + if( ( $params = $context->getSession()->get( 'aimeos/catalog/detail/params/last' . $site ) ) !== null ) |
|
| 421 | + { |
|
| 422 | + $target = $view->config( 'client/html/catalog/detail/url/target' ); |
|
| 423 | + $controller = $view->config( 'client/html/catalog/detail/url/controller', 'catalog' ); |
|
| 424 | + $action = $view->config( 'client/html/catalog/detail/url/action', 'detail' ); |
|
| 425 | + $config = $view->config( 'client/html/catalog/detail/url/config', array() ); |
|
| 426 | + } |
|
| 427 | + else |
|
| 428 | + { |
|
| 429 | + $params = $context->getSession()->get( 'aimeos/catalog/lists/params/last' . $site, array() ); |
|
| 430 | + |
|
| 431 | + $target = $view->config( 'client/html/catalog/lists/url/target' ); |
|
| 432 | + $controller = $view->config( 'client/html/catalog/lists/url/controller', 'catalog' ); |
|
| 433 | + $action = $view->config( 'client/html/catalog/lists/url/action', 'list' ); |
|
| 434 | + $config = $view->config( 'client/html/catalog/lists/url/config', array() ); |
|
| 435 | + |
|
| 436 | + } |
|
| 437 | + |
|
| 438 | + if( empty( $params ) === false ) |
|
| 439 | + { |
|
| 440 | + $view->standardParams = $this->getClientParams( $view->param() ); |
|
| 441 | + $view->standardBackUrl = $view->url( $target, $controller, $action, $params, array(), $config ); |
|
| 442 | + } |
|
| 443 | + |
|
| 444 | + $view->standardBasket = \Aimeos\Controller\Frontend\Factory::createController( $context, 'basket' )->get(); |
|
| 445 | + |
|
| 446 | + $this->cache = $view; |
|
| 447 | + } |
|
| 448 | + |
|
| 449 | + return $this->cache; |
|
| 450 | + } |
|
| 451 | + |
|
| 452 | + |
|
| 453 | + /** |
|
| 454 | + * Adds the products specified by the view parameters to the basket. |
|
| 455 | + * |
|
| 456 | + * @param \Aimeos\MW\View\Iface $view View object |
|
| 457 | + * @param array $options List of options for addProducts() in basket controller |
|
| 458 | + */ |
|
| 459 | + protected function addProducts( \Aimeos\MW\View\Iface $view, array $options ) |
|
| 460 | + { |
|
| 461 | + $this->clearCached(); |
|
| 462 | + $products = (array) $view->param( 'b_prod', array() ); |
|
| 463 | + $controller = \Aimeos\Controller\Frontend\Factory::createController( $this->getContext(), 'basket' ); |
|
| 464 | + |
|
| 465 | + if( ( $prodid = $view->param( 'b_prodid', '' ) ) !== '' ) |
|
| 466 | + { |
|
| 467 | + $products[] = array( |
|
| 468 | + 'prodid' => $prodid, |
|
| 469 | + 'quantity' => $view->param( 'b_quantity', 1 ), |
|
| 470 | + 'attrvarid' => array_filter( (array) $view->param( 'b_attrvarid', array() ) ), |
|
| 471 | + 'attrconfid' => array_filter( (array) $view->param( 'b_attrconfid', array() ) ), |
|
| 472 | + 'attrhideid' => array_filter( (array) $view->param( 'b_attrhideid', array() ) ), |
|
| 473 | + 'attrcustid' => array_filter( (array) $view->param( 'b_attrcustid', array() ) ), |
|
| 474 | + 'warehouse' => $view->param( 'b_warehouse', 'default' ), |
|
| 475 | + ); |
|
| 476 | + } |
|
| 477 | + |
|
| 478 | + foreach( $products as $values ) { |
|
| 479 | + $this->addProduct( $controller, $values, $options ); |
|
| 480 | + } |
|
| 481 | + } |
|
| 482 | + |
|
| 483 | + |
|
| 484 | + /** |
|
| 485 | + * Adds a single product specified by its values to the basket. |
|
| 486 | + * |
|
| 487 | + * @param \Aimeos\Controller\Frontend\Basket\Iface $controller Basket frontend controller |
|
| 488 | + * @param array $values Associative list of key/value pairs from the view specifying the product |
|
| 489 | + * @param array $options List of options for addProducts() in basket frontend controller |
|
| 490 | + */ |
|
| 491 | + protected function addProduct( \Aimeos\Controller\Frontend\Basket\Iface $controller, array $values, array $options ) |
|
| 492 | + { |
|
| 493 | + $controller->addProduct( |
|
| 494 | + ( isset( $values['prodid'] ) ? (string) $values['prodid'] : '' ), |
|
| 495 | + ( isset( $values['quantity'] ) ? (int) $values['quantity'] : 1 ), |
|
| 496 | + $options, |
|
| 497 | + ( isset( $values['attrvarid'] ) ? array_filter( (array) $values['attrvarid'] ) : array() ), |
|
| 498 | + ( isset( $values['attrconfid'] ) ? array_filter( (array) $values['attrconfid'] ) : array() ), |
|
| 499 | + ( isset( $values['attrhideid'] ) ? array_filter( (array) $values['attrhideid'] ) : array() ), |
|
| 500 | + ( isset( $values['attrcustid'] ) ? array_filter( (array) $values['attrcustid'] ) : array() ), |
|
| 501 | + ( isset( $values['warehouse'] ) ? (string) $values['warehouse'] : 'default' ) |
|
| 502 | + ); |
|
| 503 | + } |
|
| 504 | + |
|
| 505 | + |
|
| 506 | + /** |
|
| 507 | + * Removes the products specified by the view parameters from the basket. |
|
| 508 | + * |
|
| 509 | + * @param \Aimeos\MW\View\Iface $view View object |
|
| 510 | + */ |
|
| 511 | + protected function deleteProducts( \Aimeos\MW\View\Iface $view ) |
|
| 512 | + { |
|
| 513 | + $this->clearCached(); |
|
| 514 | + $products = (array) $view->param( 'b_position', array() ); |
|
| 515 | + $controller = \Aimeos\Controller\Frontend\Factory::createController( $this->getContext(), 'basket' ); |
|
| 516 | + |
|
| 517 | + foreach( $products as $position ) { |
|
| 518 | + $controller->deleteProduct( $position ); |
|
| 519 | + } |
|
| 520 | + } |
|
| 521 | + |
|
| 522 | + |
|
| 523 | + /** |
|
| 524 | + * Edits the products specified by the view parameters to the basket. |
|
| 525 | + * |
|
| 526 | + * @param \Aimeos\MW\View\Iface $view View object |
|
| 527 | + * @param array $options List of options for editProducts() in basket controller |
|
| 528 | + */ |
|
| 529 | + protected function editProducts( \Aimeos\MW\View\Iface $view, array $options ) |
|
| 530 | + { |
|
| 531 | + $this->clearCached(); |
|
| 532 | + $products = (array) $view->param( 'b_prod', array() ); |
|
| 533 | + $controller = \Aimeos\Controller\Frontend\Factory::createController( $this->getContext(), 'basket' ); |
|
| 534 | + |
|
| 535 | + if( ( $position = $view->param( 'b_position', '' ) ) !== '' ) |
|
| 536 | + { |
|
| 537 | + $products[] = array( |
|
| 538 | + 'position' => $position, |
|
| 539 | + 'quantity' => $view->param( 'b_quantity', 1 ), |
|
| 540 | + 'attrconf-code' => array_filter( (array) $view->param( 'b_attrconfcode', array() ) ) |
|
| 541 | + ); |
|
| 542 | + } |
|
| 543 | + |
|
| 544 | + foreach( $products as $values ) |
|
| 545 | + { |
|
| 546 | + $controller->editProduct( |
|
| 547 | + ( isset( $values['position'] ) ? (int) $values['position'] : 0 ), |
|
| 548 | + ( isset( $values['quantity'] ) ? (int) $values['quantity'] : 1 ), |
|
| 549 | + $options, |
|
| 550 | + ( isset( $values['attrconf-code'] ) ? array_filter( (array) $values['attrconf-code'] ) : array() ) |
|
| 551 | + ); |
|
| 552 | + } |
|
| 553 | + } |
|
| 554 | 554 | } |
| 555 | 555 | \ No newline at end of file |
@@ -78,7 +78,7 @@ discard block |
||
| 78 | 78 | * @since 2014.03 |
| 79 | 79 | * @category Developer |
| 80 | 80 | */ |
| 81 | - private $subPartNames = array( 'detail', 'coupon' ); |
|
| 81 | + private $subPartNames = array('detail', 'coupon'); |
|
| 82 | 82 | private $cache; |
| 83 | 83 | |
| 84 | 84 | |
@@ -90,42 +90,42 @@ discard block |
||
| 90 | 90 | * @param string|null &$expire Result variable for the expiration date of the output (null for no expiry) |
| 91 | 91 | * @return string HTML code |
| 92 | 92 | */ |
| 93 | - public function getBody( $uid = '', array &$tags = array(), &$expire = null ) |
|
| 93 | + public function getBody($uid = '', array &$tags = array(), &$expire = null) |
|
| 94 | 94 | { |
| 95 | 95 | $context = $this->getContext(); |
| 96 | 96 | $view = $this->getView(); |
| 97 | 97 | |
| 98 | 98 | try |
| 99 | 99 | { |
| 100 | - $view = $this->setViewParams( $view, $tags, $expire ); |
|
| 100 | + $view = $this->setViewParams($view, $tags, $expire); |
|
| 101 | 101 | |
| 102 | 102 | $html = ''; |
| 103 | - foreach( $this->getSubClients() as $subclient ) { |
|
| 104 | - $html .= $subclient->setView( $view )->getBody( $uid, $tags, $expire ); |
|
| 103 | + foreach ($this->getSubClients() as $subclient) { |
|
| 104 | + $html .= $subclient->setView($view)->getBody($uid, $tags, $expire); |
|
| 105 | 105 | } |
| 106 | 106 | $view->standardBody = $html; |
| 107 | 107 | } |
| 108 | - catch( \Aimeos\Client\Html\Exception $e ) |
|
| 108 | + catch (\Aimeos\Client\Html\Exception $e) |
|
| 109 | 109 | { |
| 110 | - $error = array( $this->getContext()->getI18n()->dt( 'client', $e->getMessage() ) ); |
|
| 111 | - $view->standardErrorList = $view->get( 'standardErrorList', array() ) + $error; |
|
| 110 | + $error = array($this->getContext()->getI18n()->dt('client', $e->getMessage())); |
|
| 111 | + $view->standardErrorList = $view->get('standardErrorList', array()) + $error; |
|
| 112 | 112 | } |
| 113 | - catch( \Aimeos\Controller\Frontend\Exception $e ) |
|
| 113 | + catch (\Aimeos\Controller\Frontend\Exception $e) |
|
| 114 | 114 | { |
| 115 | - $error = array( $this->getContext()->getI18n()->dt( 'controller/frontend', $e->getMessage() ) ); |
|
| 116 | - $view->standardErrorList = $view->get( 'standardErrorList', array() ) + $error; |
|
| 115 | + $error = array($this->getContext()->getI18n()->dt('controller/frontend', $e->getMessage())); |
|
| 116 | + $view->standardErrorList = $view->get('standardErrorList', array()) + $error; |
|
| 117 | 117 | } |
| 118 | - catch( \Aimeos\MShop\Exception $e ) |
|
| 118 | + catch (\Aimeos\MShop\Exception $e) |
|
| 119 | 119 | { |
| 120 | - $error = array( $this->getContext()->getI18n()->dt( 'mshop', $e->getMessage() ) ); |
|
| 121 | - $view->standardErrorList = $view->get( 'standardErrorList', array() ) + $error; |
|
| 120 | + $error = array($this->getContext()->getI18n()->dt('mshop', $e->getMessage())); |
|
| 121 | + $view->standardErrorList = $view->get('standardErrorList', array()) + $error; |
|
| 122 | 122 | } |
| 123 | - catch( \Exception $e ) |
|
| 123 | + catch (\Exception $e) |
|
| 124 | 124 | { |
| 125 | - $context->getLogger()->log( $e->getMessage() . PHP_EOL . $e->getTraceAsString() ); |
|
| 125 | + $context->getLogger()->log($e->getMessage().PHP_EOL.$e->getTraceAsString()); |
|
| 126 | 126 | |
| 127 | - $error = array( $context->getI18n()->dt( 'client', 'A non-recoverable error occured' ) ); |
|
| 128 | - $view->standardErrorList = $view->get( 'standardErrorList', array() ) + $error; |
|
| 127 | + $error = array($context->getI18n()->dt('client', 'A non-recoverable error occured')); |
|
| 128 | + $view->standardErrorList = $view->get('standardErrorList', array()) + $error; |
|
| 129 | 129 | } |
| 130 | 130 | |
| 131 | 131 | /** client/html/basket/standard/standard/template-body |
@@ -151,7 +151,7 @@ discard block |
||
| 151 | 151 | $tplconf = 'client/html/basket/standard/standard/template-body'; |
| 152 | 152 | $default = 'basket/standard/body-default.php'; |
| 153 | 153 | |
| 154 | - return $view->render( $view->config( $tplconf, $default ) ); |
|
| 154 | + return $view->render($view->config($tplconf, $default)); |
|
| 155 | 155 | } |
| 156 | 156 | |
| 157 | 157 | |
@@ -163,21 +163,21 @@ discard block |
||
| 163 | 163 | * @param string|null &$expire Result variable for the expiration date of the output (null for no expiry) |
| 164 | 164 | * @return string|null String including HTML tags for the header on error |
| 165 | 165 | */ |
| 166 | - public function getHeader( $uid = '', array &$tags = array(), &$expire = null ) |
|
| 166 | + public function getHeader($uid = '', array &$tags = array(), &$expire = null) |
|
| 167 | 167 | { |
| 168 | 168 | try |
| 169 | 169 | { |
| 170 | - $view = $this->setViewParams( $this->getView(), $tags, $expire ); |
|
| 170 | + $view = $this->setViewParams($this->getView(), $tags, $expire); |
|
| 171 | 171 | |
| 172 | 172 | $html = ''; |
| 173 | - foreach( $this->getSubClients() as $subclient ) { |
|
| 174 | - $html .= $subclient->setView( $view )->getHeader( $uid, $tags, $expire ); |
|
| 173 | + foreach ($this->getSubClients() as $subclient) { |
|
| 174 | + $html .= $subclient->setView($view)->getHeader($uid, $tags, $expire); |
|
| 175 | 175 | } |
| 176 | 176 | $view->standardHeader = $html; |
| 177 | 177 | } |
| 178 | - catch( \Exception $e ) |
|
| 178 | + catch (\Exception $e) |
|
| 179 | 179 | { |
| 180 | - $this->getContext()->getLogger()->log( $e->getMessage() . PHP_EOL . $e->getTraceAsString() ); |
|
| 180 | + $this->getContext()->getLogger()->log($e->getMessage().PHP_EOL.$e->getTraceAsString()); |
|
| 181 | 181 | return ''; |
| 182 | 182 | } |
| 183 | 183 | |
@@ -205,7 +205,7 @@ discard block |
||
| 205 | 205 | $tplconf = 'client/html/basket/standard/standard/template-header'; |
| 206 | 206 | $default = 'basket/standard/header-default.php'; |
| 207 | 207 | |
| 208 | - return $view->render( $view->config( $tplconf, $default ) ); |
|
| 208 | + return $view->render($view->config($tplconf, $default)); |
|
| 209 | 209 | } |
| 210 | 210 | |
| 211 | 211 | |
@@ -216,7 +216,7 @@ discard block |
||
| 216 | 216 | * @param string|null $name Name of the sub-client (Default if null) |
| 217 | 217 | * @return \Aimeos\Client\Html\Iface Sub-client object |
| 218 | 218 | */ |
| 219 | - public function getSubClient( $type, $name = null ) |
|
| 219 | + public function getSubClient($type, $name = null) |
|
| 220 | 220 | { |
| 221 | 221 | /** client/html/basket/standard/decorators/excludes |
| 222 | 222 | * Excludes decorators added by the "common" option from the basket standard html client |
@@ -292,7 +292,7 @@ discard block |
||
| 292 | 292 | * @see client/html/basket/standard/decorators/global |
| 293 | 293 | */ |
| 294 | 294 | |
| 295 | - return $this->createSubClient( 'basket/standard/' . $type, $name ); |
|
| 295 | + return $this->createSubClient('basket/standard/'.$type, $name); |
|
| 296 | 296 | } |
| 297 | 297 | |
| 298 | 298 | |
@@ -320,7 +320,7 @@ discard block |
||
| 320 | 320 | * @category Developer |
| 321 | 321 | * @category User |
| 322 | 322 | */ |
| 323 | - 'stock' => $view->config( 'client/html/basket/require-stock', true ), |
|
| 323 | + 'stock' => $view->config('client/html/basket/require-stock', true), |
|
| 324 | 324 | |
| 325 | 325 | /** client/html/basket/require-variant |
| 326 | 326 | * A variant of a selection product must be chosen |
@@ -338,55 +338,55 @@ discard block |
||
| 338 | 338 | * @category Developer |
| 339 | 339 | * @category User |
| 340 | 340 | */ |
| 341 | - 'variant' => $view->config( 'client/html/basket/require-variant', true ), |
|
| 341 | + 'variant' => $view->config('client/html/basket/require-variant', true), |
|
| 342 | 342 | ); |
| 343 | 343 | |
| 344 | - switch( $view->param( 'b_action' ) ) |
|
| 344 | + switch ($view->param('b_action')) |
|
| 345 | 345 | { |
| 346 | 346 | case 'add': |
| 347 | - $this->addProducts( $view, $options ); |
|
| 347 | + $this->addProducts($view, $options); |
|
| 348 | 348 | break; |
| 349 | 349 | case 'delete': |
| 350 | - $this->deleteProducts( $view ); |
|
| 350 | + $this->deleteProducts($view); |
|
| 351 | 351 | break; |
| 352 | 352 | default: |
| 353 | - $this->editProducts( $view, $options ); |
|
| 353 | + $this->editProducts($view, $options); |
|
| 354 | 354 | } |
| 355 | 355 | |
| 356 | 356 | parent::process(); |
| 357 | 357 | |
| 358 | - $controller = \Aimeos\Controller\Frontend\Factory::createController( $context, 'basket' ); |
|
| 359 | - $controller->get()->check( \Aimeos\MShop\Order\Item\Base\Base::PARTS_PRODUCT ); |
|
| 358 | + $controller = \Aimeos\Controller\Frontend\Factory::createController($context, 'basket'); |
|
| 359 | + $controller->get()->check(\Aimeos\MShop\Order\Item\Base\Base::PARTS_PRODUCT); |
|
| 360 | 360 | } |
| 361 | - catch( \Aimeos\Client\Html\Exception $e ) |
|
| 361 | + catch (\Aimeos\Client\Html\Exception $e) |
|
| 362 | 362 | { |
| 363 | - $error = array( $context->getI18n()->dt( 'client', $e->getMessage() ) ); |
|
| 364 | - $view->standardErrorList = $view->get( 'standardErrorList', array() ) + $error; |
|
| 363 | + $error = array($context->getI18n()->dt('client', $e->getMessage())); |
|
| 364 | + $view->standardErrorList = $view->get('standardErrorList', array()) + $error; |
|
| 365 | 365 | } |
| 366 | - catch( \Aimeos\Controller\Frontend\Exception $e ) |
|
| 366 | + catch (\Aimeos\Controller\Frontend\Exception $e) |
|
| 367 | 367 | { |
| 368 | - $error = array( $context->getI18n()->dt( 'controller/frontend', $e->getMessage() ) ); |
|
| 369 | - $view->standardErrorList = $view->get( 'standardErrorList', array() ) + $error; |
|
| 368 | + $error = array($context->getI18n()->dt('controller/frontend', $e->getMessage())); |
|
| 369 | + $view->standardErrorList = $view->get('standardErrorList', array()) + $error; |
|
| 370 | 370 | } |
| 371 | - catch( \Aimeos\MShop\Plugin\Provider\Exception $e ) |
|
| 371 | + catch (\Aimeos\MShop\Plugin\Provider\Exception $e) |
|
| 372 | 372 | { |
| 373 | - $errors = array( $context->getI18n()->dt( 'mshop', $e->getMessage() ) ); |
|
| 374 | - $errors = array_merge( $errors, $this->translatePluginErrorCodes( $e->getErrorCodes() ) ); |
|
| 373 | + $errors = array($context->getI18n()->dt('mshop', $e->getMessage())); |
|
| 374 | + $errors = array_merge($errors, $this->translatePluginErrorCodes($e->getErrorCodes())); |
|
| 375 | 375 | |
| 376 | 376 | $view->summaryErrorCodes = $e->getErrorCodes(); |
| 377 | - $view->standardErrorList = $view->get( 'standardErrorList', array() ) + $errors; |
|
| 377 | + $view->standardErrorList = $view->get('standardErrorList', array()) + $errors; |
|
| 378 | 378 | } |
| 379 | - catch( \Aimeos\MShop\Exception $e ) |
|
| 379 | + catch (\Aimeos\MShop\Exception $e) |
|
| 380 | 380 | { |
| 381 | - $error = array( $context->getI18n()->dt( 'mshop', $e->getMessage() ) ); |
|
| 382 | - $view->standardErrorList = $view->get( 'standardErrorList', array() ) + $error; |
|
| 381 | + $error = array($context->getI18n()->dt('mshop', $e->getMessage())); |
|
| 382 | + $view->standardErrorList = $view->get('standardErrorList', array()) + $error; |
|
| 383 | 383 | } |
| 384 | - catch( \Exception $e ) |
|
| 384 | + catch (\Exception $e) |
|
| 385 | 385 | { |
| 386 | - $context->getLogger()->log( $e->getMessage() . PHP_EOL . $e->getTraceAsString() ); |
|
| 386 | + $context->getLogger()->log($e->getMessage().PHP_EOL.$e->getTraceAsString()); |
|
| 387 | 387 | |
| 388 | - $error = array( $context->getI18n()->dt( 'client', 'A non-recoverable error occured' ) ); |
|
| 389 | - $view->standardErrorList = $view->get( 'standardErrorList', array() ) + $error; |
|
| 388 | + $error = array($context->getI18n()->dt('client', 'A non-recoverable error occured')); |
|
| 389 | + $view->standardErrorList = $view->get('standardErrorList', array()) + $error; |
|
| 390 | 390 | } |
| 391 | 391 | } |
| 392 | 392 | |
@@ -398,7 +398,7 @@ discard block |
||
| 398 | 398 | */ |
| 399 | 399 | protected function getSubClientNames() |
| 400 | 400 | { |
| 401 | - return $this->getContext()->getConfig()->get( $this->subPartPath, $this->subPartNames ); |
|
| 401 | + return $this->getContext()->getConfig()->get($this->subPartPath, $this->subPartNames); |
|
| 402 | 402 | } |
| 403 | 403 | |
| 404 | 404 | |
@@ -410,38 +410,38 @@ discard block |
||
| 410 | 410 | * @param string|null &$expire Result variable for the expiration date of the output (null for no expiry) |
| 411 | 411 | * @return \Aimeos\MW\View\Iface Modified view object |
| 412 | 412 | */ |
| 413 | - protected function setViewParams( \Aimeos\MW\View\Iface $view, array &$tags = array(), &$expire = null ) |
|
| 413 | + protected function setViewParams(\Aimeos\MW\View\Iface $view, array &$tags = array(), &$expire = null) |
|
| 414 | 414 | { |
| 415 | - if( !isset( $this->cache ) ) |
|
| 415 | + if (!isset($this->cache)) |
|
| 416 | 416 | { |
| 417 | 417 | $context = $this->getContext(); |
| 418 | 418 | $site = $context->getLocale()->getSite()->getCode(); |
| 419 | 419 | |
| 420 | - if( ( $params = $context->getSession()->get( 'aimeos/catalog/detail/params/last' . $site ) ) !== null ) |
|
| 420 | + if (($params = $context->getSession()->get('aimeos/catalog/detail/params/last'.$site)) !== null) |
|
| 421 | 421 | { |
| 422 | - $target = $view->config( 'client/html/catalog/detail/url/target' ); |
|
| 423 | - $controller = $view->config( 'client/html/catalog/detail/url/controller', 'catalog' ); |
|
| 424 | - $action = $view->config( 'client/html/catalog/detail/url/action', 'detail' ); |
|
| 425 | - $config = $view->config( 'client/html/catalog/detail/url/config', array() ); |
|
| 422 | + $target = $view->config('client/html/catalog/detail/url/target'); |
|
| 423 | + $controller = $view->config('client/html/catalog/detail/url/controller', 'catalog'); |
|
| 424 | + $action = $view->config('client/html/catalog/detail/url/action', 'detail'); |
|
| 425 | + $config = $view->config('client/html/catalog/detail/url/config', array()); |
|
| 426 | 426 | } |
| 427 | 427 | else |
| 428 | 428 | { |
| 429 | - $params = $context->getSession()->get( 'aimeos/catalog/lists/params/last' . $site, array() ); |
|
| 429 | + $params = $context->getSession()->get('aimeos/catalog/lists/params/last'.$site, array()); |
|
| 430 | 430 | |
| 431 | - $target = $view->config( 'client/html/catalog/lists/url/target' ); |
|
| 432 | - $controller = $view->config( 'client/html/catalog/lists/url/controller', 'catalog' ); |
|
| 433 | - $action = $view->config( 'client/html/catalog/lists/url/action', 'list' ); |
|
| 434 | - $config = $view->config( 'client/html/catalog/lists/url/config', array() ); |
|
| 431 | + $target = $view->config('client/html/catalog/lists/url/target'); |
|
| 432 | + $controller = $view->config('client/html/catalog/lists/url/controller', 'catalog'); |
|
| 433 | + $action = $view->config('client/html/catalog/lists/url/action', 'list'); |
|
| 434 | + $config = $view->config('client/html/catalog/lists/url/config', array()); |
|
| 435 | 435 | |
| 436 | 436 | } |
| 437 | 437 | |
| 438 | - if( empty( $params ) === false ) |
|
| 438 | + if (empty($params) === false) |
|
| 439 | 439 | { |
| 440 | - $view->standardParams = $this->getClientParams( $view->param() ); |
|
| 441 | - $view->standardBackUrl = $view->url( $target, $controller, $action, $params, array(), $config ); |
|
| 440 | + $view->standardParams = $this->getClientParams($view->param()); |
|
| 441 | + $view->standardBackUrl = $view->url($target, $controller, $action, $params, array(), $config); |
|
| 442 | 442 | } |
| 443 | 443 | |
| 444 | - $view->standardBasket = \Aimeos\Controller\Frontend\Factory::createController( $context, 'basket' )->get(); |
|
| 444 | + $view->standardBasket = \Aimeos\Controller\Frontend\Factory::createController($context, 'basket')->get(); |
|
| 445 | 445 | |
| 446 | 446 | $this->cache = $view; |
| 447 | 447 | } |
@@ -456,27 +456,27 @@ discard block |
||
| 456 | 456 | * @param \Aimeos\MW\View\Iface $view View object |
| 457 | 457 | * @param array $options List of options for addProducts() in basket controller |
| 458 | 458 | */ |
| 459 | - protected function addProducts( \Aimeos\MW\View\Iface $view, array $options ) |
|
| 459 | + protected function addProducts(\Aimeos\MW\View\Iface $view, array $options) |
|
| 460 | 460 | { |
| 461 | 461 | $this->clearCached(); |
| 462 | - $products = (array) $view->param( 'b_prod', array() ); |
|
| 463 | - $controller = \Aimeos\Controller\Frontend\Factory::createController( $this->getContext(), 'basket' ); |
|
| 462 | + $products = (array) $view->param('b_prod', array()); |
|
| 463 | + $controller = \Aimeos\Controller\Frontend\Factory::createController($this->getContext(), 'basket'); |
|
| 464 | 464 | |
| 465 | - if( ( $prodid = $view->param( 'b_prodid', '' ) ) !== '' ) |
|
| 465 | + if (($prodid = $view->param('b_prodid', '')) !== '') |
|
| 466 | 466 | { |
| 467 | 467 | $products[] = array( |
| 468 | 468 | 'prodid' => $prodid, |
| 469 | - 'quantity' => $view->param( 'b_quantity', 1 ), |
|
| 470 | - 'attrvarid' => array_filter( (array) $view->param( 'b_attrvarid', array() ) ), |
|
| 471 | - 'attrconfid' => array_filter( (array) $view->param( 'b_attrconfid', array() ) ), |
|
| 472 | - 'attrhideid' => array_filter( (array) $view->param( 'b_attrhideid', array() ) ), |
|
| 473 | - 'attrcustid' => array_filter( (array) $view->param( 'b_attrcustid', array() ) ), |
|
| 474 | - 'warehouse' => $view->param( 'b_warehouse', 'default' ), |
|
| 469 | + 'quantity' => $view->param('b_quantity', 1), |
|
| 470 | + 'attrvarid' => array_filter((array) $view->param('b_attrvarid', array())), |
|
| 471 | + 'attrconfid' => array_filter((array) $view->param('b_attrconfid', array())), |
|
| 472 | + 'attrhideid' => array_filter((array) $view->param('b_attrhideid', array())), |
|
| 473 | + 'attrcustid' => array_filter((array) $view->param('b_attrcustid', array())), |
|
| 474 | + 'warehouse' => $view->param('b_warehouse', 'default'), |
|
| 475 | 475 | ); |
| 476 | 476 | } |
| 477 | 477 | |
| 478 | - foreach( $products as $values ) { |
|
| 479 | - $this->addProduct( $controller, $values, $options ); |
|
| 478 | + foreach ($products as $values) { |
|
| 479 | + $this->addProduct($controller, $values, $options); |
|
| 480 | 480 | } |
| 481 | 481 | } |
| 482 | 482 | |
@@ -488,17 +488,17 @@ discard block |
||
| 488 | 488 | * @param array $values Associative list of key/value pairs from the view specifying the product |
| 489 | 489 | * @param array $options List of options for addProducts() in basket frontend controller |
| 490 | 490 | */ |
| 491 | - protected function addProduct( \Aimeos\Controller\Frontend\Basket\Iface $controller, array $values, array $options ) |
|
| 491 | + protected function addProduct(\Aimeos\Controller\Frontend\Basket\Iface $controller, array $values, array $options) |
|
| 492 | 492 | { |
| 493 | 493 | $controller->addProduct( |
| 494 | - ( isset( $values['prodid'] ) ? (string) $values['prodid'] : '' ), |
|
| 495 | - ( isset( $values['quantity'] ) ? (int) $values['quantity'] : 1 ), |
|
| 494 | + (isset($values['prodid']) ? (string) $values['prodid'] : ''), |
|
| 495 | + (isset($values['quantity']) ? (int) $values['quantity'] : 1), |
|
| 496 | 496 | $options, |
| 497 | - ( isset( $values['attrvarid'] ) ? array_filter( (array) $values['attrvarid'] ) : array() ), |
|
| 498 | - ( isset( $values['attrconfid'] ) ? array_filter( (array) $values['attrconfid'] ) : array() ), |
|
| 499 | - ( isset( $values['attrhideid'] ) ? array_filter( (array) $values['attrhideid'] ) : array() ), |
|
| 500 | - ( isset( $values['attrcustid'] ) ? array_filter( (array) $values['attrcustid'] ) : array() ), |
|
| 501 | - ( isset( $values['warehouse'] ) ? (string) $values['warehouse'] : 'default' ) |
|
| 497 | + (isset($values['attrvarid']) ? array_filter((array) $values['attrvarid']) : array()), |
|
| 498 | + (isset($values['attrconfid']) ? array_filter((array) $values['attrconfid']) : array()), |
|
| 499 | + (isset($values['attrhideid']) ? array_filter((array) $values['attrhideid']) : array()), |
|
| 500 | + (isset($values['attrcustid']) ? array_filter((array) $values['attrcustid']) : array()), |
|
| 501 | + (isset($values['warehouse']) ? (string) $values['warehouse'] : 'default') |
|
| 502 | 502 | ); |
| 503 | 503 | } |
| 504 | 504 | |
@@ -508,14 +508,14 @@ discard block |
||
| 508 | 508 | * |
| 509 | 509 | * @param \Aimeos\MW\View\Iface $view View object |
| 510 | 510 | */ |
| 511 | - protected function deleteProducts( \Aimeos\MW\View\Iface $view ) |
|
| 511 | + protected function deleteProducts(\Aimeos\MW\View\Iface $view) |
|
| 512 | 512 | { |
| 513 | 513 | $this->clearCached(); |
| 514 | - $products = (array) $view->param( 'b_position', array() ); |
|
| 515 | - $controller = \Aimeos\Controller\Frontend\Factory::createController( $this->getContext(), 'basket' ); |
|
| 514 | + $products = (array) $view->param('b_position', array()); |
|
| 515 | + $controller = \Aimeos\Controller\Frontend\Factory::createController($this->getContext(), 'basket'); |
|
| 516 | 516 | |
| 517 | - foreach( $products as $position ) { |
|
| 518 | - $controller->deleteProduct( $position ); |
|
| 517 | + foreach ($products as $position) { |
|
| 518 | + $controller->deleteProduct($position); |
|
| 519 | 519 | } |
| 520 | 520 | } |
| 521 | 521 | |
@@ -526,28 +526,28 @@ discard block |
||
| 526 | 526 | * @param \Aimeos\MW\View\Iface $view View object |
| 527 | 527 | * @param array $options List of options for editProducts() in basket controller |
| 528 | 528 | */ |
| 529 | - protected function editProducts( \Aimeos\MW\View\Iface $view, array $options ) |
|
| 529 | + protected function editProducts(\Aimeos\MW\View\Iface $view, array $options) |
|
| 530 | 530 | { |
| 531 | 531 | $this->clearCached(); |
| 532 | - $products = (array) $view->param( 'b_prod', array() ); |
|
| 533 | - $controller = \Aimeos\Controller\Frontend\Factory::createController( $this->getContext(), 'basket' ); |
|
| 532 | + $products = (array) $view->param('b_prod', array()); |
|
| 533 | + $controller = \Aimeos\Controller\Frontend\Factory::createController($this->getContext(), 'basket'); |
|
| 534 | 534 | |
| 535 | - if( ( $position = $view->param( 'b_position', '' ) ) !== '' ) |
|
| 535 | + if (($position = $view->param('b_position', '')) !== '') |
|
| 536 | 536 | { |
| 537 | 537 | $products[] = array( |
| 538 | 538 | 'position' => $position, |
| 539 | - 'quantity' => $view->param( 'b_quantity', 1 ), |
|
| 540 | - 'attrconf-code' => array_filter( (array) $view->param( 'b_attrconfcode', array() ) ) |
|
| 539 | + 'quantity' => $view->param('b_quantity', 1), |
|
| 540 | + 'attrconf-code' => array_filter((array) $view->param('b_attrconfcode', array())) |
|
| 541 | 541 | ); |
| 542 | 542 | } |
| 543 | 543 | |
| 544 | - foreach( $products as $values ) |
|
| 544 | + foreach ($products as $values) |
|
| 545 | 545 | { |
| 546 | 546 | $controller->editProduct( |
| 547 | - ( isset( $values['position'] ) ? (int) $values['position'] : 0 ), |
|
| 548 | - ( isset( $values['quantity'] ) ? (int) $values['quantity'] : 1 ), |
|
| 547 | + (isset($values['position']) ? (int) $values['position'] : 0), |
|
| 548 | + (isset($values['quantity']) ? (int) $values['quantity'] : 1), |
|
| 549 | 549 | $options, |
| 550 | - ( isset( $values['attrconf-code'] ) ? array_filter( (array) $values['attrconf-code'] ) : array() ) |
|
| 550 | + (isset($values['attrconf-code']) ? array_filter((array) $values['attrconf-code']) : array()) |
|
| 551 | 551 | ); |
| 552 | 552 | } |
| 553 | 553 | } |