diff --git a/.dev/macro/core.php b/.dev/macro/core.php index 4ad634daad..7433d15663 100644 --- a/.dev/macro/core.php +++ b/.dev/macro/core.php @@ -18,11 +18,9 @@ * * @category LiteCommerce * @author Creative Development LLC - * @copyright Copyright (c) 2011 Creative Development LLC . All rights reserved + * @copyright Copyright (c) 2011-2012 Creative Development LLC . All rights reserved * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) * @link http://www.litecommerce.com/ - * @see ____file_see____ - * @since 1.0.18 */ define('MACRO_START_DIR', getcwd()); @@ -52,8 +50,6 @@ * @param string $msg Error message * * @return void - * @see ____func_see____ - * @since 1.0.18 */ function macro_error($msg) { @@ -67,8 +63,6 @@ function macro_error($msg) * @param string $name Name * * @return string - * @see ____func_see____ - * @since 1.0.18 */ function macro_get_named_argument($name) { @@ -83,8 +77,6 @@ function macro_get_named_argument($name) * @param integer $number Index * * @return string - * @see ____func_see____ - * @since 1.0.18 */ function macro_get_plain_argument($number) { @@ -97,8 +89,6 @@ function macro_get_plain_argument($number) * @param string $path Path * * @return string - * @see ____func_see____ - * @since 1.0.18 */ function macro_convert_path_to_class_name($path) { @@ -111,8 +101,6 @@ function macro_convert_path_to_class_name($path) * @param string $class Class name * * @return string - * @see ____func_see____ - * @since 1.0.18 */ function macro_convert_class_name_to_path($class) { @@ -126,8 +114,6 @@ function macro_convert_class_name_to_path($class) * @param string $data File content * * @return void - * @see ____func_see____ - * @since 1.0.18 */ function macro_file_put_contents($path, $data) { @@ -146,8 +132,6 @@ function macro_file_put_contents($path, $data) * @param string $path path * * @return boolean - * @see ____func_see____ - * @since 1.0.18 */ function macro_is_entity($path) { @@ -162,8 +146,6 @@ function macro_is_entity($path) * @param string $moduleName Module name OPTIONAL * * @return string - * @see ____func_see____ - * @since 1.0.24 */ function macro_assemble_class_name($suffix, $moduleAuthor = null, $moduleName = null) { @@ -180,8 +162,6 @@ function macro_assemble_class_name($suffix, $moduleAuthor = null, $moduleName = * @param string $moduleName Module name OPTIONAL * * @return string - * @see ____func_see____ - * @since 1.0.24 */ function macro_assemble_tpl_name($suffix, $moduleAuthor = null, $moduleName = null) { @@ -196,8 +176,6 @@ function macro_assemble_tpl_name($suffix, $moduleAuthor = null, $moduleName = nu * @param string $class Class full name * * @return string - * @see ____func_see____ - * @since 1.0.24 */ function macro_get_class_short_name($class) { @@ -212,8 +190,6 @@ function macro_get_class_short_name($class) * @param string $camel Camel case string * * @return string - * @see ____func_see____ - * @since 1.0.24 */ function macro_convert_camel_to_human_readable($camel) { @@ -233,8 +209,6 @@ function macro_convert_camel_to_human_readable($camel) * @param string &$path Path * * @return void - * @see ____func_see____ - * @since 1.0.18 */ function macro_check_file_path(&$path) { @@ -255,8 +229,6 @@ function macro_check_file_path(&$path) * @param string $path Path * * @return void - * @see ____func_see____ - * @since 1.0.18 */ function macro_check_class_file_path($path) { @@ -273,8 +245,6 @@ function macro_check_class_file_path($path) * @param string &$class Class * * @return void - * @see ____func_see____ - * @since 1.0.18 */ function macro_check_class(&$class) { @@ -290,8 +260,6 @@ function macro_check_class(&$class) * @param string $module Name * * @return void - * @see ____func_see____ - * @since 1.0.18 */ function macro_check_module($author, $module) { @@ -315,8 +283,6 @@ function macro_check_module($author, $module) * @param string $path Path * * @return string - * @see ____func_see____ - * @since 1.0.18 */ function macro_get_file_header($path) { @@ -341,11 +307,9 @@ function macro_get_file_header($path) * * @category LiteCommerce * @author Creative Development LLC - * @copyright Copyright (c) 2011 Creative Development LLC . All rights reserved + * @copyright Copyright (c) 2011-2012 Creative Development LLC . All rights reserved * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) * @link http://www.litecommerce.com/ - * @see ____file_see____ - * @since 1.0.0 */ @@ -358,8 +322,6 @@ function macro_get_file_header($path) * @param string $path Path * * @return string - * @see ____func_see____ - * @since 1.0.18 */ function macro_get_class_repo_header($path) { @@ -381,8 +343,6 @@ function macro_get_class_repo_header($path) * @param string $path Path * * @return string - * @see ____func_see____ - * @since 1.0.18 */ function macro_get_class_header($path) { @@ -396,8 +356,6 @@ function macro_get_class_header($path) /** * Abstract widget * - * @see ____class_see____ - * @since 1.0.0 */ HEAD; } diff --git a/.dev/macro/create-crud-list.php b/.dev/macro/create-crud-list.php index 4893b7f681..c5ba1623d3 100755 --- a/.dev/macro/create-crud-list.php +++ b/.dev/macro/create-crud-list.php @@ -19,11 +19,9 @@ * * @category LiteCommerce * @author Creative Development LLC - * @copyright Copyright (c) 2011 Creative Development LLC . All rights reserved + * @copyright Copyright (c) 2011-2012 Creative Development LLC . All rights reserved * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) * @link http://www.litecommerce.com/ - * @see ____file_see____ - * @since 1.0.0 */ /** @@ -225,8 +223,6 @@ function($var) use ($targetOneControllerPath) { /** * $targetHumanReadableName controller * - * @see ____class_see____ - * @since 1.0.0 */ class $targetShort extends \\XLite\\Controller\\Admin\\AAdmin { @@ -240,8 +236,6 @@ class $targetShort extends \\XLite\\Controller\\Admin\\AAdmin * Update list * * @return void - * @see ____func_see____ - * @since 1.0.0 */ protected function doActionUpdate() { @@ -262,8 +256,6 @@ protected function doActionUpdate() * @param string \$paramName Parameter name * * @return mixed - * @see ____func_see____ - * @since 1.0.0 */ public function getCondition(\$paramName) { @@ -278,8 +270,6 @@ public function getCondition(\$paramName) * Save search conditions * * @return void - * @see ____func_see____ - * @since 1.0.0 */ protected function doActionSearch() { @@ -292,8 +282,6 @@ protected function doActionSearch() * Return search parameters * * @return array - * @see ____func_see____ - * @since 1.0.0 */ protected function getSearchParams() { @@ -314,8 +302,6 @@ protected function getSearchParams() * Get search conditions * * @return array - * @see ____func_see____ - * @since 1.0.0 */ protected function getConditions() { @@ -358,8 +344,6 @@ protected function getConditions() /** * $targetHumanReadableName page view * - * @see ____class_see____ - * @since 1.0.0 * * @ListChild (list="admin.center", zone="admin") */ @@ -369,8 +353,6 @@ class $targetShort extends \\XLite\\View\\AView * Return list of allowed targets * * @return array - * @see ____func_see____ - * @since 1.0.0 */ public static function getAllowedTargets() { @@ -381,8 +363,6 @@ public static function getAllowedTargets() * Return widget default template * * @return string - * @see ____func_see____ - * @since 1.0.0 */ protected function getDefaultTemplate() { @@ -393,8 +373,6 @@ protected function getDefaultTemplate() * Check - search box is visible or not * * @return boolean - * @see ____func_see____ - * @since 1.0.0 */ protected function isSearchVisible() { @@ -424,10 +402,9 @@ protected function isSearchVisible() * $targetHumanReadableName page template * * @author Creative Development LLC - * @copyright Copyright (c) 2011 Creative Development LLC . All rights reserved + * @copyright Copyright (c) 2011-2012 Creative Development LLC . All rights reserved * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) * @link http://www.litecommerce.com/ - * @since 1.0.0 *} @@ -467,10 +444,9 @@ protected function isSearchVisible() * $targetHumanReadableName list search template * * @author Creative Development LLC - * @copyright Copyright (c) 2011 Creative Development LLC . All rights reserved + * @copyright Copyright (c) 2011-2012 Creative Development LLC . All rights reserved * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) * @link http://www.litecommerce.com/ - * @since 1.0.0 *} @@ -498,8 +474,6 @@ protected function isSearchVisible() /** * $targetHumanReadableName list search form * - * @see ____class_see____ - * @since 1.0.0 */ class $formListSearchClassShort extends \\XLite\\View\\Form\\AForm { @@ -507,8 +481,6 @@ class $formListSearchClassShort extends \\XLite\\View\\Form\\AForm * Return default value for the "target" parameter * * @return string - * @see ____func_see____ - * @since 1.0.0 */ protected function getDefaultTarget() { @@ -519,8 +491,6 @@ protected function getDefaultTarget() * Return default value for the "action" parameter * * @return string - * @see ____func_see____ - * @since 1.0.0 */ protected function getDefaultAction() { @@ -555,10 +525,9 @@ protected function getDefaultAction() * $fieldHumanReadable condition * * @author Creative Development LLC - * @copyright Copyright (c) 2011 Creative Development LLC . All rights reserved + * @copyright Copyright (c) 2011-2012 Creative Development LLC . All rights reserved * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) * @link http://www.litecommerce.com/ - * @since 1.0.0 * * @ListChild (list="$itemsListViewList.search.conditions", weight="$weight") *} @@ -586,10 +555,9 @@ protected function getDefaultAction() * Search button * * @author Creative Development LLC - * @copyright Copyright (c) 2011 Creative Development LLC . All rights reserved + * @copyright Copyright (c) 2011-2012 Creative Development LLC . All rights reserved * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) * @link http://www.litecommerce.com/ - * @since 1.0.0 * * @ListChild (list="$itemsListViewList.search.conditions", weight="last") *} @@ -621,10 +589,9 @@ protected function getDefaultAction() * $targetHumanReadableName list table template * * @author Creative Development LLC - * @copyright Copyright (c) 2011 Creative Development LLC . All rights reserved + * @copyright Copyright (c) 2011-2012 Creative Development LLC . All rights reserved * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) * @link http://www.litecommerce.com/ - * @since 1.0.0 *} @@ -650,8 +617,6 @@ protected function getDefaultAction() /** * $targetHumanReadableName list table form * - * @see ____class_see____ - * @since 1.0.0 */ class $formListTableClassShort extends \\XLite\\View\\Form\\ItemsList\\AItemsList { @@ -659,8 +624,6 @@ class $formListTableClassShort extends \\XLite\\View\\Form\\ItemsList\\AItemsLis * Return default value for the "target" parameter * * @return string - * @see ____func_see____ - * @since 1.0.0 */ protected function getDefaultTarget() { @@ -671,8 +634,6 @@ protected function getDefaultTarget() * Return default value for the "action" parameter * * @return string - * @see ____func_see____ - * @since 1.0.0 */ protected function getDefaultAction() { @@ -701,8 +662,6 @@ protected function getDefaultAction() /** * $targetHumanReadableName items list * - * @see ____class_see____ - * @since 1.0.0 */ class $itemsListClassShort extends \\XLite\\View\\ItemsList\\Model\\Table { @@ -745,8 +704,6 @@ class $itemsListClassShort extends \\XLite\\View\\ItemsList\\Model\\Table * Get a list of CSS files required to display the widget properly * * @return array - * @see ____func_see____ - * @since 1.0.0 */ public function getCSSFiles() { @@ -769,8 +726,6 @@ public function getCSSFiles() * Define widget parameters * * @return void - * @see ____func_see____ - * @since 1.0.0 */ protected function defineWidgetParams() { @@ -801,8 +756,6 @@ protected function defineWidgetParams() * Define columns structure * * @return array - * @see ____func_see____ - * @since 1.0.0 */ protected function defineColumns() { @@ -843,8 +796,6 @@ protected function defineColumns() * Define repository name * * @return string - * @see ____func_see____ - * @since 1.0.0 */ protected function defineRepositoryName() { @@ -860,8 +811,6 @@ protected function defineRepositoryName() * Get create entity URL * * @return string - * @see ____func_see____ - * @since 1.0.0 */ protected function getCreateURL() { @@ -878,8 +827,6 @@ protected function getCreateURL() * Get create button label * * @return string - * @see ____func_see____ - * @since 1.0.0 */ protected function getCreateButtonLabel() { @@ -895,8 +842,6 @@ protected function getCreateButtonLabel() * Inline creation mechanism position * * @return integer - * @see ____func_see____ - * @since 1.0.0 */ protected function isInlineCreation() { @@ -924,8 +869,6 @@ protected function isInlineCreation() * Mark list as removable * * @return boolean - * @see ____func_see____ - * @since 1.0.0 */ protected function isRemoved() { @@ -942,8 +885,6 @@ protected function isRemoved() * Mark list as switchyabvle (enable / disable) * * @return boolean - * @see ____func_see____ - * @since 1.0.0 */ protected function isSwitchable() { @@ -960,8 +901,6 @@ protected function isSwitchable() * Mark list as sortable * * @return integer - * @see ____func_see____ - * @since 1.0.0 */ protected function getSortableType() { @@ -989,8 +928,6 @@ protected function getSortableType() * Get container class * * @return string - * @see ____func_see____ - * @since 1.0.0 */ protected function getContainerClass() { @@ -1008,8 +945,6 @@ protected function getContainerClass() * Get panel class * * @return \XLite\View\Base\FormStickyPanel - * @see ____func_see____ - * @since 1.0.0 */ protected function getPanelClass() { @@ -1027,8 +962,6 @@ protected function getPanelClass() * Return class name for the list pager * * @return string - * @see ____func_see____ - * @since 1.0.0 */ protected function getPagerClass() { @@ -1048,8 +981,6 @@ protected function getPagerClass() * Return search parameters. * * @return array - * @see ____func_see____ - * @since 1.0.0 */ static public function getSearchParams() { @@ -1076,8 +1007,6 @@ static public function getSearchParams() * Define so called "request" parameters * * @return void - * @see ____func_see____ - * @since 1.0.0 */ protected function defineRequestParams() { @@ -1102,8 +1031,6 @@ protected function defineRequestParams() * TODO refactor * * @return \XLite\Core\CommonCell - * @see ____func_see____ - * @since 1.0.0 */ protected function getSearchCondition() { @@ -1142,10 +1069,9 @@ protected function getSearchCondition() * $targetHumanReadableName list styles * * @author Creative Development LLC - * @copyright Copyright (c) 2011 Creative Development LLC . All rights reserved + * @copyright Copyright (c) 2011-2012 Creative Development LLC . All rights reserved * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) * @link http://www.litecommerce.com/ - * @since 1.0.0 */ CODE; @@ -1170,8 +1096,6 @@ protected function getSearchCondition() /** * $targetHumanReadableName items list's sticky panel * - * @see ____class_see____ - * @since 1.0.0 */ class $itemsListPanelClassShort extends \\XLite\\View\\StickyPanel\\ItemsListForm { @@ -1206,8 +1130,6 @@ class $itemsListPanelClassShort extends \\XLite\\View\\StickyPanel\\ItemsListFor /** * $targetHumanReadableName repository * - * @see ____class_see____ - * @since 1.0.0 */ class $entityRepoClassShort extends $entityRepoParentClass { @@ -1257,8 +1179,6 @@ class $entityRepoClassShort extends $entityRepoParentClass * @param boolean \$countOnly "Count only" flag. Do not need to add "order by" clauses if only count is needed. * * @return void - * @see ____func_see____ - * @since 1.0.0 */ protected function prepareCnd$fieldUpper(\Doctrine\ORM\QueryBuilder \$queryBuilder, \$value, \$countOnly) { @@ -1287,8 +1207,6 @@ protected function prepareCnd$fieldUpper(\Doctrine\ORM\QueryBuilder \$queryBuild * @param array \$value Condition data * * @return void - * @see ____func_see____ - * @since 1.0.0 */ protected function prepareCndLimit(\Doctrine\ORM\QueryBuilder \$queryBuilder, array \$value) { @@ -1316,8 +1234,6 @@ protected function prepareCndLimit(\Doctrine\ORM\QueryBuilder \$queryBuilder, ar * @param boolean \$countOnly "Count only" flag. Do not need to add "order by" clauses if only count is needed. * * @return void - * @see ____func_see____ - * @since 1.0.0 */ protected function prepareCndOrderBy(\Doctrine\ORM\QueryBuilder \$queryBuilder, \$value, \$countOnly) { @@ -1350,8 +1266,6 @@ protected function prepareCndOrderBy(\Doctrine\ORM\QueryBuilder \$queryBuilder, * @param boolean \$countOnly Return items list or only its size OPTIONAL * * @return \Doctrine\ORM\PersistentCollection|integer - * @see ____func_see____ - * @since 1.0.0 */ public function search(\XLite\Core\CommonCell \$cnd, \$countOnly = false) { @@ -1373,8 +1287,6 @@ public function search(\XLite\Core\CommonCell \$cnd, \$countOnly = false) * @param \Doctrine\ORM\QueryBuilder \$qb Query builder routine * * @return \Doctrine\ORM\PersistentCollection|integer - * @see ____func_see____ - * @since 1.0.0 */ public function searchCount(\Doctrine\ORM\QueryBuilder \$qb) { @@ -1389,8 +1301,6 @@ public function searchCount(\Doctrine\ORM\QueryBuilder \$qb) * @param \Doctrine\ORM\QueryBuilder \$qb Query builder routine * * @return \Doctrine\ORM\PersistentCollection|integer - * @see ____func_see____ - * @since 1.0.0 */ public function searchResult(\Doctrine\ORM\QueryBuilder \$qb) { @@ -1406,8 +1316,6 @@ public function searchResult(\Doctrine\ORM\QueryBuilder \$qb) * @param boolean \$countOnly Count only flag * * @return void - * @see ____func_see____ - * @since 1.0.0 */ protected function callSearchConditionHandler(\$value, \$key, \Doctrine\ORM\QueryBuilder \$queryBuilder, \$countOnly) { @@ -1422,8 +1330,6 @@ protected function callSearchConditionHandler(\$value, \$key, \Doctrine\ORM\Quer * @param string \$param Name of param to check * * @return boolean - * @see ____func_see____ - * @since 1.0.0 */ protected function isSearchParamHasHandler(\$param) { @@ -1434,8 +1340,6 @@ protected function isSearchParamHasHandler(\$param) * Return list of handling search params * * @return array - * @see ____func_see____ - * @since 1.0.0 */ protected function getHandlingSearchParams() { @@ -1473,8 +1377,6 @@ protected function getHandlingSearchParams() /** * $targetHumanReadableName menu item * - * @see ____class_see____ - * @since 1.0.0 * * @ListChild (list="$menuList", weight="last", zone="admin") */ @@ -1484,8 +1386,6 @@ class $menuShortClass extends \\XLite\\View\\TopMenu\\Node\\$menuParent\\A$menuP * Define widget parameters * * @return void - * @see ____func_see____ - * @since 1.0.0 */ protected function defineWidgetParams() { @@ -1522,17 +1422,13 @@ protected function defineWidgetParams() /** * $targetOneHumanReadableName controller * - * @see ____class_see____ - * @since 1.0.0 */ class $targetOneShort extends \\XLite\\Controller\\Admin\\AAdmin { /** * Controller parameters * - * @var array - * @see ____var_see____ - * @since 1.0.0 + * @var array */ protected \$params = array('target', 'id'); @@ -1540,8 +1436,6 @@ class $targetOneShort extends \\XLite\\Controller\\Admin\\AAdmin * Return the current page title (for the content area) * * @return string - * @see ____func_see____ - * @since 1.0.0 */ public function getTitle() { @@ -1559,8 +1453,6 @@ public function getTitle() * Update model * * @return void - * @see ____func_see____ - * @since 1.0.0 */ protected function doActionUpdate() { @@ -1573,8 +1465,6 @@ protected function doActionUpdate() * Get model form class * * @return string - * @see ____func_see____ - * @since 1.0.0 */ protected function getModelFormClass() { @@ -1603,8 +1493,6 @@ protected function getModelFormClass() /** * $targetOneHumanReadableName page view * - * @see ____class_see____ - * @since 1.0.0 * * @ListChild (list="admin.center", zone="admin") */ @@ -1614,8 +1502,6 @@ class $targetOneShort extends \\XLite\\View\\AView * Return list of allowed targets * * @return array - * @see ____func_see____ - * @since 1.0.0 */ public static function getAllowedTargets() { @@ -1626,8 +1512,6 @@ public static function getAllowedTargets() * Return widget default template * * @return string - * @see ____func_see____ - * @since 1.0.0 */ protected function getDefaultTemplate() { @@ -1655,10 +1539,9 @@ protected function getDefaultTemplate() * $targetOneHumanReadableName page template * * @author Creative Development LLC - * @copyright Copyright (c) 2011 Creative Development LLC . All rights reserved + * @copyright Copyright (c) 2011-2012 Creative Development LLC . All rights reserved * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) * @link http://www.litecommerce.com/ - * @since 1.0.0 *} CODE; @@ -1684,17 +1567,13 @@ protected function getDefaultTemplate() /** * $targetOneHumanReadableName view model * - * @see ____class_see____ - * @since 1.0.0 */ class $oneViewModelClassShort extends \\XLite\\View\\Model\\AModel { /** * Shema default * - * @var array - * @see ____var_see____ - * @since 1.0.0 + * @var array */ protected \$schemaDefault = array( @@ -1733,8 +1612,6 @@ class $oneViewModelClassShort extends \\XLite\\View\\Model\\AModel * Return current model ID * * @return integer - * @see ____func_see____ - * @since 1.0.0 */ public function getModelId() { @@ -1745,8 +1622,6 @@ public function getModelId() * This object will be used if another one is not pased * * @return \\$entityClass - * @see ____func_see____ - * @since 1.0.0 */ protected function getDefaultModelObject() { @@ -1761,8 +1636,6 @@ protected function getDefaultModelObject() * Return name of web form widget class * * @return string - * @see ____func_see____ - * @since 1.0.0 */ protected function getFormClass() { @@ -1773,8 +1646,6 @@ protected function getFormClass() * Return list of the "Button" widgets * * @return array - * @see ____func_see____ - * @since 1.0.0 */ protected function getFormButtons() { @@ -1796,8 +1667,6 @@ protected function getFormButtons() * Add top message * * @return void - * @see ____func_see____ - * @since 1.0.0 */ protected function addDataSavedTopMessage() { @@ -1833,8 +1702,6 @@ protected function addDataSavedTopMessage() /** * $targetHumanReadableName list search form * - * @see ____class_see____ - * @since 1.0.0 */ class $formOneClassShort extends \\XLite\\View\\Form\\AForm { @@ -1842,8 +1709,6 @@ class $formOneClassShort extends \\XLite\\View\\Form\\AForm * Register CSS files * * @return array - * @see ____func_see____ - * @since 1.0.0 */ public function getCSSFiles() { @@ -1858,8 +1723,6 @@ public function getCSSFiles() * Return default value for the "target" parameter * * @return string - * @see ____func_see____ - * @since 1.0.0 */ protected function getDefaultTarget() { @@ -1870,8 +1733,6 @@ protected function getDefaultTarget() * Return default value for the "action" parameter * * @return string - * @see ____func_see____ - * @since 1.0.0 */ protected function getDefaultAction() { @@ -1882,8 +1743,6 @@ protected function getDefaultAction() * Get default class name * * @return string - * @see ____func_see____ - * @since 1.0.0 */ protected function getDefaultClassName() { @@ -1894,8 +1753,6 @@ protected function getDefaultClassName() * Return list of the form default parameters * * @return array - * @see ____func_see____ - * @since 1.0.0 */ protected function getDefaultParams() { @@ -1924,10 +1781,9 @@ protected function getDefaultParams() * $targetOneHumanReadableName view model styles * * @author Creative Development LLC - * @copyright Copyright (c) 2011 Creative Development LLC . All rights reserved + * @copyright Copyright (c) 2011-2012 Creative Development LLC . All rights reserved * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) * @link http://www.litecommerce.com/ - * @since 1.0.0 */ CODE; diff --git a/.dev/macro/load-yaml.php b/.dev/macro/load-yaml.php new file mode 100755 index 0000000000..4accec7793 --- /dev/null +++ b/.dev/macro/load-yaml.php @@ -0,0 +1,50 @@ +#!/usr/bin/env php + + * @copyright Copyright (c) 2010-2012 Creative Development LLC . All rights reserved + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + * @link http://www.litecommerce.com/ + */ + +require_once __DIR__ . '/core.php'; + +// get arguments +$path = macro_get_plain_argument(0); + +// Check arguments +macro_check_file_path($path); + +\XLite\Core\Database::getInstance()->loadFixturesFromYaml($path); + +die(0); + +/** + * Help + */ +function macro_help() +{ + return <<getMain(); - $this->assertEquals('Paypal Website Payments Standard', $main::getModuleName(), 'Wrong module name'); + $this->assertEquals('PayPal (outside of the US)', $main::getModuleName(), 'Wrong module name'); } public function testGetDescription() { $main = $this->getMain(); - $this->assertEquals('Enables taking credit card payments for your online store via Paypal (Website Payments Standard).', $main::getDescription(), 'Wrong description'); + $this->assertEquals('Enables taking credit card payments for your online store via PayPal (Website Payments Standard).', $main::getDescription(), 'Wrong description'); } public function testGetVersion() { $main = $this->getMain(); - $this->assertEquals('1.1.0', $main::getVersion(), 'Wrong version'); + $this->assertEquals('1.1.1', $main::getVersion(), 'Wrong version'); } public function testShowSettingsForm() diff --git a/.dev/tests/Classes/Module/CDev/PaypalWPS/Model/Payment/Processor/PaypalWPS.php b/.dev/tests/Classes/Module/CDev/PaypalWPS/Model/Payment/Processor/PaypalWPS.php index c3515d114a..f67efe6367 100644 --- a/.dev/tests/Classes/Module/CDev/PaypalWPS/Model/Payment/Processor/PaypalWPS.php +++ b/.dev/tests/Classes/Module/CDev/PaypalWPS/Model/Payment/Processor/PaypalWPS.php @@ -146,7 +146,7 @@ public function testGetSettingsWidget() $order = $this->getTestOrder(); $p = $order->getPaymentMethod()->getProcessor(); - $this->assertEquals('modules/CDev/PaypalWPS/config.tpl', $p->getSettingsWidget(), 'check settings widget'); + $this->assertEquals('\\XLite\\Module\\CDev\\PaypalWPS\\View\\PaypalSettings', $p->getSettingsWidget(), 'check settings widget'); } public function testIsConfigured() diff --git a/.gitignore b/.gitignore index b59f4be725..d5240d5d9d 100644 --- a/.gitignore +++ b/.gitignore @@ -33,3 +33,4 @@ /src/var/.modules.structures.registry.php /src/var/.modules.structures.registry.hash.php /nbproject +*.swp diff --git a/src/Includes/install/install.php b/src/Includes/install/install.php index daf323e46d..b98064436f 100644 --- a/src/Includes/install/install.php +++ b/src/Includes/install/install.php @@ -1194,7 +1194,7 @@ function doUpdateMainHtaccess(&$params, $silentMode = false) $util = '\Includes\Utils\FileManager'; $util::replace( - $util::getDir($util::getDir(__DIR__)) . LC_DS . '.htaccess', + $util::getDir($util::getDir(__DIR__)) . LC_DS . '.htaccess', '\1RewriteBase ' . $params['xlite_web_dir'], '/^(\s*)#\s*RewriteBase\s+____WEB_DIR____\s*$/mi' ); @@ -1400,9 +1400,9 @@ function doCreateAdminAccount(&$params, $silentMode = false) $role = \XLite\Core\Database::getRepo('XLite\Model\Role')->findOneByName('Administrator'); $profile->addRoles($role); - + $profile->create(); - + $role->addProfiles($profile); \XLite\Core\Database::getEM()->persist($role); \XLite\Core\Database::getEM()->flush(); @@ -1545,9 +1545,9 @@ function doFinishInstallation(&$params, $silentMode = false) /** * Sanitize host value (remove port as some servers include it to HTTP_HOST variable) - * + * * @param string $host Host value - * + * * @return string */ function x_install_get_host($host) diff --git a/src/classes/XLite/Controller/Admin/AddonsListInstalled.php b/src/classes/XLite/Controller/Admin/AddonsListInstalled.php index 484c44dc77..8d6f83dd61 100644 --- a/src/classes/XLite/Controller/Admin/AddonsListInstalled.php +++ b/src/classes/XLite/Controller/Admin/AddonsListInstalled.php @@ -87,6 +87,8 @@ protected function getModules($cellName) /** * Enable module + * + * @todo TO REMOVE? * * @return void */ @@ -173,7 +175,7 @@ protected function doActionUninstall() // Disable this and depended modules \Includes\Utils\ModulesManager::disableModule($module->getActualName()); \Includes\Utils\ModulesManager::removeModuleFromDisabledStructure($module->getActualName()); - + // Remove from DB \XLite\Core\Database::getRepo('\XLite\Model\Module')->delete($module); diff --git a/src/classes/XLite/Controller/Admin/AddonsListMarketplace.php b/src/classes/XLite/Controller/Admin/AddonsListMarketplace.php index 9744bd06b8..fe557c10ee 100644 --- a/src/classes/XLite/Controller/Admin/AddonsListMarketplace.php +++ b/src/classes/XLite/Controller/Admin/AddonsListMarketplace.php @@ -40,4 +40,16 @@ public function getTitle() { return 'Modules Marketplace'; } + + /** + * Clear marketplace cache + * + * @return void + */ + protected function doActionClearCache() + { + \XLite\Core\Marketplace::getInstance()->clearActionCache(\XLite\Core\Marketplace::ACTION_GET_ADDONS_LIST); + + $this->setReturnURL($this->buildURL('addons_list_marketplace')); + } } diff --git a/src/classes/XLite/Controller/Admin/AddressField.php b/src/classes/XLite/Controller/Admin/AddressField.php new file mode 100644 index 0000000000..6c22f289a3 --- /dev/null +++ b/src/classes/XLite/Controller/Admin/AddressField.php @@ -0,0 +1,93 @@ + + * @copyright Copyright (c) 2011-2012 Creative Development LLC . All rights reserved + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + * @link http://www.litecommerce.com/ + */ + +namespace XLite\Controller\Admin; + +/** + * Address field + * + */ +class AddressField extends \XLite\Controller\Admin\AAdmin +{ + /** + * Controller parameters + * + * @var array + */ + protected $param = array('target', 'id'); + + /** + * Address field id + * + * @var integer + */ + protected $id; + + /** + * Return the current page title (for the content area) + * + * @return string + */ + public function getTitle() + { + return 'Address field'; + } + + /** + * Common method to determine current location + * + * @return string + */ + protected function getLocation() + { + return $this->getTitle(); + } + + /** + * Update address field + * + * @return void + */ + public function doActionUpdate() + { + $this->getModelForm()->performAction('modify'); + + if ($this->getModelForm()->getModelObject()->getId()) { + $this->setReturnUrl(\XLite\Core\Converter::buildURL('address_fields')); + } + } + + /** + * Get model form class + * + * @return void + */ + protected function getModelFormClass() + { + return 'XLite\View\Model\Address\Field'; + } + +} + diff --git a/src/classes/XLite/Controller/Admin/AddressFields.php b/src/classes/XLite/Controller/Admin/AddressFields.php new file mode 100644 index 0000000000..b91fe03f10 --- /dev/null +++ b/src/classes/XLite/Controller/Admin/AddressFields.php @@ -0,0 +1,54 @@ + + * @copyright Copyright (c) 2011-2012 Creative Development LLC . All rights reserved + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + * @link http://www.litecommerce.com/ + */ + +namespace XLite\Controller\Admin; + +/** + * Address fields controller + * + */ +class AddressFields extends \XLite\Controller\Admin\AAdmin +{ + /** + * Return the current page title (for the content area) + * + * @return string + */ + public function getTitle() + { + return 'Address fields'; + } + + /** + * Update list + * + * @return void + */ + protected function doActionUpdate() + { + $list = new \XLite\View\ItemsList\Model\Address\Fields(); + $list->processQuick(); + } +} diff --git a/src/classes/XLite/Controller/Admin/Attribute.php b/src/classes/XLite/Controller/Admin/Attribute.php new file mode 100644 index 0000000000..8c31b1db7c --- /dev/null +++ b/src/classes/XLite/Controller/Admin/Attribute.php @@ -0,0 +1,173 @@ + + * @copyright Copyright (c) 2011-2012 Creative Development LLC . All rights reserved + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + * @link http://www.litecommerce.com/ + */ + +namespace XLite\Controller\Admin; + +/** + * Attribute controller + * + */ +class Attribute extends \XLite\Controller\Admin\AAdmin +{ + /** + * Controller parameters + * + * @var array + */ + protected $params = array('target', 'id', 'product_class_id'); + + /** + * Product class + * + * @var \XLite\Model\ProductClass + */ + protected $productClass; + + /** + * Attribute + * + * @var \XLite\Model\Attribute + */ + protected $attribute; + + /** + * Check ACL permissions + * + * @return boolean + */ + public function checkACL() + { + return parent::checkACL() + || \XLite\Core\Auth::getInstance()->isPermissionAllowed('manage catalog'); + } + + /** + * Check if current page is accessible + * + * @return boolean + */ + public function checkAccess() + { + return parent::checkAccess() + && $this->getProductClass() + && $this->isAJAX(); + } + + /** + * Get product class + * + * @return \XLite\Model\ProductClass + */ + public function getProductClass() + { + if ( + is_null($this->productClass) + && \XLite\Core\Request::getInstance()->product_class_id + ) { + $this->productClass = \XLite\Core\Database::getRepo('XLite\Model\ProductClass') + ->find(intval(\XLite\Core\Request::getInstance()->product_class_id)); + } + + return $this->productClass; + } + + /** + * Get attribute + * + * @return \XLite\Model\Attribute + */ + public function getAttribute() + { + if ( + is_null($this->attribute) + && \XLite\Core\Request::getInstance()->id + ) { + $this->attribute = \XLite\Core\Database::getRepo('XLite\Model\Attribute') + ->find(intval(\XLite\Core\Request::getInstance()->id)); + } + + return $this->attribute; + } + + /** + * Return the current page title (for the content area) + * + * @return string + */ + public function getTitle() + { + $id = intval(\XLite\Core\Request::getInstance()->id); + $model = $id + ? \XLite\Core\Database::getRepo('XLite\Model\Attribute')->find($id) + : null; + + return ($model && $model->getId()) + ? \XLite\Core\Translation::getInstance()->lbl('Edit attribute values') + : \XLite\Core\Translation::getInstance()->lbl('New attribute'); + } + + /** + * Update model + * + * @return void + */ + protected function doActionUpdate() + { + if ($this->getModelForm()->getModelObject()->getId()) { + $this->setSilenceClose(); + + } else { + $this->setInternalRedirect(); + } + + $list = new \XLite\View\ItemsList\Model\AttributeOption; + $list->processQuick(); + + if ($this->getModelForm()->performAction('modify')) { + $this->setReturnUrl( + \XLite\Core\Converter::buildURL( + 'attribute', + '', + array( + 'id' => $this->getModelForm()->getModelObject()->getId(), + 'product_class_id' => \XLite\Core\Request::getInstance()->product_class_id, + 'widget' => 'XLite\View\Attribute' + ) + ) + ); + } + } + + /** + * Get model form class + * + * @return string + */ + protected function getModelFormClass() + { + return 'XLite\View\Model\Attribute'; + } + +} diff --git a/src/classes/XLite/Controller/Admin/AttributeGroup.php b/src/classes/XLite/Controller/Admin/AttributeGroup.php new file mode 100644 index 0000000000..b9670b85b3 --- /dev/null +++ b/src/classes/XLite/Controller/Admin/AttributeGroup.php @@ -0,0 +1,116 @@ + + * @copyright Copyright (c) 2011-2012 Creative Development LLC . All rights reserved + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + * @link http://www.litecommerce.com/ + */ + +namespace XLite\Controller\Admin; + +/** + * Attribute group controller + * + */ +class AttributeGroup extends \XLite\Controller\Admin\AAdmin +{ + /** + * Controller parameters + * + * @var array + */ + protected $params = array('target', 'id', 'product_class_id'); + + /** + * Product class + * + * @var \XLite\Model\ProductClass + */ + protected $productClass; + + /** + * Check ACL permissions + * + * @return boolean + */ + public function checkACL() + { + return (parent::checkACL() || \XLite\Core\Auth::getInstance()->isPermissionAllowed('manage catalog')) + && $this->getProductClass(); + } + + /** + * Get product class + * + * @return \XLite\Model\ProductClass + */ + public function getProductClass() + { + if ( + is_null($this->productClass) + && \XLite\Core\Request::getInstance()->product_class_id + ) { + $this->productClass = \XLite\Core\Database::getRepo('XLite\Model\ProductClass') + ->find(intval(\XLite\Core\Request::getInstance()->product_class_id)); + } + + return $this->productClass; + } + + /** + * Return the current page title (for the content area) + * + * @return string + */ + public function getTitle() + { + $id = intval(\XLite\Core\Request::getInstance()->id); + $model = $id + ? \XLite\Core\Database::getRepo('XLite\Model\AttributeGroup')->find($id) + : null; + + return ($model && $model->getId()) + ? $model->getName() + : \XLite\Core\Translation::getInstance()->lbl('AttributeGroup'); + } + + /** + * Update model + * + * @return void + */ + protected function doActionUpdate() + { + if ($this->getModelForm()->performAction('modify')) { + $this->setReturnUrl(\XLite\Core\Converter::buildURL('attribute_groups')); + } + } + + /** + * Get model form class + * + * @return string + */ + protected function getModelFormClass() + { + return 'XLite\View\Model\AttributeGroup'; + } + +} diff --git a/src/classes/XLite/Controller/Admin/AttributeGroups.php b/src/classes/XLite/Controller/Admin/AttributeGroups.php new file mode 100644 index 0000000000..52da3b5805 --- /dev/null +++ b/src/classes/XLite/Controller/Admin/AttributeGroups.php @@ -0,0 +1,181 @@ + + * @copyright Copyright (c) 2011-2012 Creative Development LLC . All rights reserved + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + * @link http://www.litecommerce.com/ + */ + +namespace XLite\Controller\Admin; + +/** + * Attribute groups controller + * + */ +class AttributeGroups extends \XLite\Controller\Admin\AAdmin +{ + /** + * Controller parameters + * + * @var array + */ + protected $params = array('target', 'product_class_id'); + + /** + * Product class + * + * @var \XLite\Model\ProductClass + */ + protected $productClass; + + /** + * Check ACL permissions + * + * @return boolean + */ + public function checkACL() + { + return parent::checkACL() + || \XLite\Core\Auth::getInstance()->isPermissionAllowed('manage catalog'); + } + + /** + * Check if current page is accessible + * + * @return boolean + */ + public function checkAccess() + { + return parent::checkAccess() + && $this->getProductClass() + && $this->isAJAX(); + } + + /** + * Get product class + * + * @return \XLite\Model\ProductClass + */ + public function getProductClass() + { + if ( + is_null($this->productClass) + && \XLite\Core\Request::getInstance()->product_class_id + ) { + $this->productClass = \XLite\Core\Database::getRepo('XLite\Model\ProductClass') + ->find(intval(\XLite\Core\Request::getInstance()->product_class_id)); + } + + return $this->productClass; + } + + /** + * Update list + * + * @return void + */ + protected function doActionUpdate() + { + $this->setSilenceClose(); + $list = new \XLite\View\ItemsList\Model\AttributeGroup; + $list->processQuick(); + } + + /** + * Return the current page title (for the content area) + * + * @return string + */ + public function getTitle() + { + return static::t('Manage attribute groups'); + } + + // {{{ Search + + /** + * Get search condition parameter by name + * + * @param string $paramName Parameter name + * + * @return mixed + */ + public function getCondition($paramName) + { + $searchParams = $this->getConditions(); + + return isset($searchParams[$paramName]) + ? $searchParams[$paramName] + : null; + } + + /** + * Save search conditions + * + * @return void + */ + protected function doActionSearch() + { + $cellName = \XLite\View\ItemsList\Model\AttributeGroup::getSessionCellName(); + + \XLite\Core\Session::getInstance()->$cellName = $this->getSearchParams(); + } + + /** + * Return search parameters + * + * @return array + */ + protected function getSearchParams() + { + $searchParams = $this->getConditions(); + + foreach ( + \XLite\View\ItemsList\Model\AttributeGroup::getSearchParams() as $requestParam + ) { + if (isset(\XLite\Core\Request::getInstance()->$requestParam)) { + $searchParams[$requestParam] = \XLite\Core\Request::getInstance()->$requestParam; + } + } + + return $searchParams; + } + + /** + * Get search conditions + * + * @return array + */ + protected function getConditions() + { + $cellName = \XLite\View\ItemsList\Model\AttributeGroup::getSessionCellName(); + + $searchParams = \XLite\Core\Session::getInstance()->$cellName; + + if (!is_array($searchParams)) { + $searchParams = array(); + } + + return $searchParams; + } + + // }}} + +} diff --git a/src/classes/XLite/Controller/Admin/AttributeOption.php b/src/classes/XLite/Controller/Admin/AttributeOption.php new file mode 100644 index 0000000000..778f80f9f7 --- /dev/null +++ b/src/classes/XLite/Controller/Admin/AttributeOption.php @@ -0,0 +1,80 @@ + + * @copyright Copyright (c) 2011-2012 Creative Development LLC . All rights reserved + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + * @link http://www.litecommerce.com/ + */ + +namespace XLite\Controller\Admin; + +/** + * Attribute option controller + * + */ +class AttributeOption extends \XLite\Controller\Admin\AAdmin +{ + /** + * Controller parameters + * + * @var array + */ + protected $params = array('target', 'id'); + + /** + * Return the current page title (for the content area) + * + * @return string + */ + public function getTitle() + { + $id = intval(\XLite\Core\Request::getInstance()->id); + $model = $id + ? \XLite\Core\Database::getRepo('XLite\Model\AttributeOption')->find($id) + : null; + + return ($model && $model->getId()) + ? $model->getName() + : \XLite\Core\Translation::getInstance()->lbl('AttributeOption'); + } + + /** + * Update model + * + * @return void + */ + protected function doActionUpdate() + { + if ($this->getModelForm()->performAction('modify')) { + $this->setReturnUrl(\XLite\Core\Converter::buildURL('attribute_options')); + } + } + + /** + * Get model form class + * + * @return string + */ + protected function getModelFormClass() + { + return 'XLite\View\Model\AttributeOption'; + } + +} \ No newline at end of file diff --git a/src/classes/XLite/Controller/Admin/AttributeOptions.php b/src/classes/XLite/Controller/Admin/AttributeOptions.php new file mode 100644 index 0000000000..5dd8d4d0a7 --- /dev/null +++ b/src/classes/XLite/Controller/Admin/AttributeOptions.php @@ -0,0 +1,105 @@ + + * @copyright Copyright (c) 2011-2012 Creative Development LLC . All rights reserved + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + * @link http://www.litecommerce.com/ + */ + +namespace XLite\Controller\Admin; + +/** + * Attribute options controller + * + */ +class AttributeOptions extends \XLite\Controller\Admin\AAdmin +{ + + // {{{ Search + + /** + * Get search condition parameter by name + * + * @param string $paramName Parameter name + * + * @return mixed + */ + public function getCondition($paramName) + { + $searchParams = $this->getConditions(); + + return isset($searchParams[$paramName]) + ? $searchParams[$paramName] + : null; + } + + /** + * Save search conditions + * + * @return void + */ + protected function doActionSearch() + { + $cellName = \XLite\View\ItemsList\Model\AttributeOption::getSessionCellName(); + + \XLite\Core\Session::getInstance()->$cellName = $this->getSearchParams(); + } + + /** + * Return search parameters + * + * @return array + */ + protected function getSearchParams() + { + $searchParams = $this->getConditions(); + + foreach ( + \XLite\View\ItemsList\Model\AttributeOption::getSearchParams() as $requestParam + ) { + if (isset(\XLite\Core\Request::getInstance()->$requestParam)) { + $searchParams[$requestParam] = \XLite\Core\Request::getInstance()->$requestParam; + } + } + + return $searchParams; + } + + /** + * Get search conditions + * + * @return array + */ + protected function getConditions() + { + $cellName = \XLite\View\ItemsList\Model\AttributeOption::getSessionCellName(); + + $searchParams = \XLite\Core\Session::getInstance()->$cellName; + + if (!is_array($searchParams)) { + $searchParams = array(); + } + + return $searchParams; + } + + // }}} + +} \ No newline at end of file diff --git a/src/classes/XLite/Controller/Admin/Attributes.php b/src/classes/XLite/Controller/Admin/Attributes.php new file mode 100644 index 0000000000..d3ea8e11b2 --- /dev/null +++ b/src/classes/XLite/Controller/Admin/Attributes.php @@ -0,0 +1,185 @@ + + * @copyright Copyright (c) 2011-2012 Creative Development LLC . All rights reserved + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + * @link http://www.litecommerce.com/ + */ + +namespace XLite\Controller\Admin; + +/** + * Attributes controller + * + */ +class Attributes extends \XLite\Controller\Admin\AAdmin +{ + /** + * Controller parameters + * + * @var array + */ + protected $params = array('target', 'product_class_id'); + + /** + * Product class + * + * @var \XLite\Model\ProductClass + */ + protected $productClass; + + /** + * Check ACL permissions + * + * @return boolean + */ + public function checkACL() + { + return (parent::checkACL() || \XLite\Core\Auth::getInstance()->isPermissionAllowed('manage catalog')) + && $this->getProductClass(); + } + + /** + * Get product class + * + * @return \XLite\Model\ProductClass + */ + public function getProductClass() + { + if ( + is_null($this->productClass) + && \XLite\Core\Request::getInstance()->product_class_id + ) { + $this->productClass = \XLite\Core\Database::getRepo('XLite\Model\ProductClass') + ->find(intval(\XLite\Core\Request::getInstance()->product_class_id)); + } + + return $this->productClass; + } + + /** + * Get product class + * + * @return \Doctrine\ORM\PersistentCollection + */ + public function getAttributeGroups() + { + return $this->getProductClass()->getAttributeGroups(); + } + + /** + * Update list + * + * @return void + */ + protected function doActionUpdate() + { + $list = new \XLite\View\ItemsList\Model\Attribute; + $list->processQuick(); + } + + /** + * Return the current page title (for the content area) + * + * @return string + */ + public function getTitle() + { + return $this->getProductClass() + ? static::t( + 'Attributes for X product class', + array( + 'class' => $this->getProductClass()->getName() + ) + ) + : null; + } + + // {{{ Search + + /** + * Get search condition parameter by name + * + * @param string $paramName Parameter name + * + * @return mixed + */ + public function getCondition($paramName) + { + $searchParams = $this->getConditions(); + + return isset($searchParams[$paramName]) + ? $searchParams[$paramName] + : null; + } + + /** + * Save search conditions + * + * @return void + */ + protected function doActionSearch() + { + $cellName = \XLite\View\ItemsList\Model\Attribute::getSessionCellName(); + + \XLite\Core\Session::getInstance()->$cellName = $this->getSearchParams(); + } + + /** + * Return search parameters + * + * @return array + */ + protected function getSearchParams() + { + $searchParams = $this->getConditions(); + + foreach ( + \XLite\View\ItemsList\Model\Attribute::getSearchParams() as $requestParam + ) { + if (isset(\XLite\Core\Request::getInstance()->$requestParam)) { + $searchParams[$requestParam] = \XLite\Core\Request::getInstance()->$requestParam; + } + } + + return $searchParams; + } + + /** + * Get search conditions + * + * @return array + */ + protected function getConditions() + { + $cellName = \XLite\View\ItemsList\Model\Attribute::getSessionCellName(); + + $searchParams = \XLite\Core\Session::getInstance()->$cellName; + + if (!is_array($searchParams)) { + $searchParams = array(); + } + + return $searchParams; + } + + // }}} + +} diff --git a/src/classes/XLite/Controller/Admin/Autocomplete.php b/src/classes/XLite/Controller/Admin/Autocomplete.php index b1b0d9cb88..f15b1cdb02 100644 --- a/src/classes/XLite/Controller/Admin/Autocomplete.php +++ b/src/classes/XLite/Controller/Admin/Autocomplete.php @@ -51,7 +51,7 @@ protected function doNoAction() $method = 'assembleDictionary' . \XLite\Core\Converter::convertToCamelCase($dictionary); if (method_exists($this, $method)) { $this->data = $this->processData( - $this->$method(strval(\XLite\Core\Request::getInstance()->erm)) + $this->$method(strval(\XLite\Core\Request::getInstance()->term)) ); } } @@ -95,4 +95,34 @@ public function processRequest() print ($content); } + + + /** + * Assemble dictionary - conversation recipient + * + * @param string $term Term + * + * @return array + */ + protected function assembleDictionaryAttributeOption($term) + { + $cnd = new \XLite\Core\CommonCell; + if ($term) { + $cnd->{\XLite\Model\Repo\AttributeOption::SEARCH_NAME} = $term; + } + + $id = intval(\XLite\Core\Request::getInstance()->id); + if ($id) { + $cnd->{\XLite\Model\Repo\AttributeOption::SEARCH_ATTRIBUTE} = $id; + } + + $list = array(); + + foreach (\XLite\Core\Database::getRepo('\XLite\Model\AttributeOption')->search($cnd) as $a) { + $list[$a->getName()] = $a->getName(); + } + + return $list; + } + } diff --git a/src/classes/XLite/Controller/Admin/ImportExport.php b/src/classes/XLite/Controller/Admin/ImportExport.php index 29a42105d3..2dc0119025 100644 --- a/src/classes/XLite/Controller/Admin/ImportExport.php +++ b/src/classes/XLite/Controller/Admin/ImportExport.php @@ -85,6 +85,14 @@ class ImportExport extends \XLite\Controller\Admin\AAdmin */ protected $importCell; + /** + * Clean URLs cache + * + * @var array + */ + protected $cleanURLs = array(); + + /** * Check ACL permissions * @@ -739,6 +747,8 @@ protected function startImportStep() } } } + + $this->cleanURLs = \XLite\Core\Database::getRepo('XLite\Model\Product')->findAllCleanURLs(); } /** @@ -1028,7 +1038,27 @@ protected function importCleanURL(\XLite\Model\Product $product, $data) $product->setCleanURL(null); } else { - $product->setCleanURL($data); + + if (isset($this->cleanURLs[$data]) && (empty($this->cleanURLs[$data]) || intval($product->getProductId()) != $this->cleanURLs[$data])) { + + // Add log message + $this->logImportWarning( + static::t( + 'Duplicated clean URL: X', + array('value' => $data) + ), + $this->importCell['position'], + 'cleanURL', + $data, + $product + ); + + $product->setCleanURL(null); + + } else { + $product->setCleanURL($data); + $this->cleanURLs[$data] = 0; + } } } diff --git a/src/classes/XLite/Controller/Admin/Product.php b/src/classes/XLite/Controller/Admin/Product.php index 1789eb07dd..3e358db26c 100644 --- a/src/classes/XLite/Controller/Admin/Product.php +++ b/src/classes/XLite/Controller/Admin/Product.php @@ -99,6 +99,9 @@ public function getPages() if (!$this->isNew()) { $list['images'] = 'Product images'; $list['inventory'] = 'Inventory tracking'; + if ($this->getProduct()->getAttributesCount()) { + $list['attributes'] = 'Attributes'; + } } return $list; @@ -118,6 +121,9 @@ protected function getPageTemplates() if (!$this->isNew()) { $list['images'] = 'product/product_images.tpl'; $list['inventory'] = 'product/inventory.tpl'; + if ($this->getProduct()->getAttributesCount()) { + $list['attributes'] = 'product/attributes.tpl'; + } } return $list; @@ -446,5 +452,34 @@ protected function doActionUpdateInventory() \XLite\Core\Database::getEM()->flush(); } + /** + * Update attributes + * + * @return void + */ + protected function doActionUpdateAttributes() + { + $this->getProduct()->setAttrSepTab((bool) \XLite\Core\Request::getInstance()->attrSepTab); + $cnd = new \XLite\Core\CommonCell; + $cnd->product = $this->getProduct(); + $attributes = \XLite\Core\Database::getRepo('\XLite\Model\Attribute')->search($cnd); + $attributeValues = \XLite\Core\Request::getInstance()->attributeValues; + + if ( + count($attributes) + && $attributeValues + && is_array($attributeValues) + ) { + foreach ($attributes as $a) { + if (isset($attributeValues[$a->getId()])) { + $a->setAttributeValue($this->getProduct(), $attributeValues[$a->getId()]); + } + } + } + + \XLite\Core\Database::getEM()->flush(); + \XLite\Core\TopMessage::addInfo('Attributes have been updated successfully'); + } + // }}} } diff --git a/src/classes/XLite/Controller/Admin/ProductClass.php b/src/classes/XLite/Controller/Admin/ProductClass.php index f30c41134f..cc3430ed94 100644 --- a/src/classes/XLite/Controller/Admin/ProductClass.php +++ b/src/classes/XLite/Controller/Admin/ProductClass.php @@ -32,22 +32,11 @@ class ProductClass extends \XLite\Controller\Admin\AAdmin { /** - * Constants - */ - const STATUS_ERROR = 'error'; - const STATUS_INAPPLY = 'inapply'; - const STATUS_SUCCESS = 'success'; - const STATUS_FAILED = 'failed'; - - /** - * data + * Controller parameters * * @var array */ - protected $data = array( - 'status' => self::STATUS_ERROR, - 'data' => '', - ); + protected $params = array('target', 'id'); /** * Check ACL permissions @@ -60,71 +49,42 @@ public function checkACL() } /** - * Remove product class + * Return the current page title (for the content area) * - * @return void + * @return string */ - protected function doActionRemove() + public function getTitle() { - if (isset(\XLite\Core\Request::getInstance()->id)) { - \XLite\Core\Database::getRepo('\XLite\Model\ProductClass')->deleteById( - \XLite\Core\Request::getInstance()->id - ); - } - - $this->setReturnURL($this->buildURL('product_classes')); + $id = intval(\XLite\Core\Request::getInstance()->id); + $model = $id + ? \XLite\Core\Database::getRepo('XLite\Model\ProductClass')->find($id) + : null; + + return ($model && $model->getId()) + ? $model->getName() + : \XLite\Core\Translation::getInstance()->lbl('ProductClass'); } /** - * AJAX product class update + * Update model * * @return void */ protected function doActionUpdate() { - $data = array( - 'name' => \XLite\Core\Request::getInstance()->name, - ); - - \XLite\Core\Database::getRepo('\XLite\Model\ProductClass')->updateById( - \XLite\Core\Request::getInstance()->id, - $data - ); + if ($this->getModelForm()->performAction('modify')) { + $this->setReturnUrl(\XLite\Core\Converter::buildURL('product_classes')); + } } /** - * AJAX product class adding - * - * @return void + * Get model form class + * + * @return string */ - protected function doActionAdd() + protected function getModelFormClass() { - $data = new \XLite\Model\ProductClass(); - $data->setName(\XLite\Core\Request::getInstance()->name); - - $data = \XLite\Core\Database::getRepo('\XLite\Model\ProductClass')->insert($data); - - $this->data['data'] = array( - 'id' => $data->getId(), - 'name' => $data->getName(), - ); - - $this->data['status'] = static::STATUS_SUCCESS; + return 'XLite\View\Model\ProductClass'; } - /** - * Send JSON data after "ADD" action - * - * @return void - */ - protected function actionPostprocessAdd() - { - header('Content-type: application/json'); - $data = json_encode($this->data); - header('Content-Length: ' . strlen($data)); - - echo ($data); - - exit (0); - } } diff --git a/src/classes/XLite/Controller/Admin/ProductClasses.php b/src/classes/XLite/Controller/Admin/ProductClasses.php index 8757fc66c5..fb6360c33d 100644 --- a/src/classes/XLite/Controller/Admin/ProductClasses.php +++ b/src/classes/XLite/Controller/Admin/ProductClasses.php @@ -26,63 +26,111 @@ namespace XLite\Controller\Admin; /** - * Product classes + * Product classes controller * */ class ProductClasses extends \XLite\Controller\Admin\AAdmin { + /** - * Field name for new 'name' value + * Check ACL permissions + * + * @return boolean */ - const NEW_NAME = 'new_name'; + public function checkACL() + { + return parent::checkACL() || \XLite\Core\Auth::getInstance()->isPermissionAllowed('manage catalog'); + } /** - * Field name for 'name' array values + * Return the current page title (for the content area) + * + * @return string */ - const NAME = 'name'; + public function getTitle() + { + return static::t('Product classes'); + } + /** + * Update list + * + * @return void + */ + protected function doActionUpdate() + { + $list = new \XLite\View\ItemsList\Model\ProductClass; + $list->processQuick(); + } + + // {{{ Search /** - * Check ACL permissions + * Get search condition parameter by name * - * @return boolean + * @param string $paramName Parameter name + * + * @return mixed */ - public function checkACL() + public function getCondition($paramName) { - return parent::checkACL() || \XLite\Core\Auth::getInstance()->isPermissionAllowed('manage catalog'); + $searchParams = $this->getConditions(); + + return isset($searchParams[$paramName]) + ? $searchParams[$paramName] + : null; } /** - * Update action + * Save search conditions * * @return void */ - protected function doActionUpdate() + protected function doActionSearch() { - $data = $this->getPostedData(); + $cellName = \XLite\View\ItemsList\Model\ProductClass::getSessionCellName(); - if (!empty($data[static::NEW_NAME])) { - $this->addClass($data[static::NEW_NAME]); - } + \XLite\Core\Session::getInstance()->$cellName = $this->getSearchParams(); + } - if (isset($data[static::NEW_NAME])) { - unset($data[static::NEW_NAME]); - } + /** + * Return search parameters + * + * @return array + */ + protected function getSearchParams() + { + $searchParams = $this->getConditions(); - if (!empty($data)) { - \XLite\Core\Database::getRepo('\XLite\Model\ProductClass')->updateInBatchById($data); + foreach ( + \XLite\View\ItemsList\Model\ProductClass::getSearchParams() as $requestParam + ) { + if (isset(\XLite\Core\Request::getInstance()->$requestParam)) { + $searchParams[$requestParam] = \XLite\Core\Request::getInstance()->$requestParam; + } } + + return $searchParams; } /** - * Add product class entry - * - * @param string $name Name value + * Get search conditions * - * @return void + * @return array */ - protected function addClass($name) + protected function getConditions() { - \XLite\Core\Database::getRepo('\XLite\Model\ProductClass')->insert(array(static::NAME => strval($name))); + $cellName = \XLite\View\ItemsList\Model\ProductClass::getSessionCellName(); + + $searchParams = \XLite\Core\Session::getInstance()->$cellName; + + if (!is_array($searchParams)) { + $searchParams = array(); + } + + return $searchParams; } + + // }}} + } diff --git a/src/classes/XLite/Controller/Admin/ShippingSettings.php b/src/classes/XLite/Controller/Admin/ShippingSettings.php index b525b97c22..03b85fad9c 100644 --- a/src/classes/XLite/Controller/Admin/ShippingSettings.php +++ b/src/classes/XLite/Controller/Admin/ShippingSettings.php @@ -60,8 +60,7 @@ public function getTitle() public function doActionUpdate() { $postedData = \XLite\Core\Request::getInstance()->getData(); - $options = \XLite\Core\Database::getRepo('\XLite\Model\Config') - ->findBy(array('category' => $this->getOptionsCategory())); + $options = \XLite\Core\Database::getRepo('\XLite\Model\Config')->findBy(array('category' => $this->getOptionsCategory())); $isUpdated = false; foreach ($options as $key => $option) { @@ -105,6 +104,6 @@ public function getStateById($stateId) */ protected function getOptionsCategory() { - return 'Shipping'; + return \XLite\Model\Config::SHIPPING_CATEGORY; } } diff --git a/src/classes/XLite/Controller/Customer/ACustomer.php b/src/classes/XLite/Controller/Customer/ACustomer.php index 80916c3141..a607fac69d 100644 --- a/src/classes/XLite/Controller/Customer/ACustomer.php +++ b/src/classes/XLite/Controller/Customer/ACustomer.php @@ -407,4 +407,64 @@ protected function performRedirectToCleanURL() } // }}} + + public function getAddressFields() + { + $result = array(); + + foreach (\XLite\Core\Database::getRepo('XLite\Model\AddressField')->findAllEnabled() as $field) { + $result[$field->getServiceName()] = array( + \XLite\View\Model\Address\Address::SCHEMA_CLASS => $field->getSchemaClass(), + \XLite\View\Model\Address\Address::SCHEMA_LABEL => $field->getName(), + \XLite\View\Model\Address\Address::SCHEMA_REQUIRED => $field->getRequired(), + \XLite\View\Model\Address\Address::SCHEMA_MODEL_ATTRIBUTES => array( + \XLite\View\FormField\Input\Base\String::PARAM_MAX_LENGTH => 'length', + ), + \XLite\View\FormField\AFormField::PARAM_WRAPPER_CLASS => 'address-' . $field->getServiceName(), + ); + } + + return $result; + } + + /** + * getFieldValue + * + * @param string $fieldName Field name + * @param boolean $processValue Process value flag OPTIONAL + * + * @return string + **/ + public function getFieldValue($fieldName, $address, $processValue = false) + { + $result = ''; + + if (isset($address)) { + + $methodName = 'get' . \XLite\Core\Converter::getInstance()->convertToCamelCase($fieldName); + + // $methodName assembled from 'get' + camelized $fieldName + $result = $address->$methodName(); + + if ($result && false !== $processValue) { + + switch ($fieldName) { + + case 'state_id': + $result = $address->getState()->getState(); + break; + + case 'country_code': + $result = $address->getCountry()->getCountry(); + break; + + default: + + } + } + } + + return $result; + } + } diff --git a/src/classes/XLite/Controller/Customer/Checkout.php b/src/classes/XLite/Controller/Customer/Checkout.php index 6de366d595..994fe5ea2c 100644 --- a/src/classes/XLite/Controller/Customer/Checkout.php +++ b/src/classes/XLite/Controller/Customer/Checkout.php @@ -181,7 +181,7 @@ protected function doActionCheckout() $this->redirect($this->buildURL('checkout')); } else { - // Register 'Place order' event in the order history + // Register 'Place order' event in the order history \XLite\Core\OrderHistory::getInstance()->registerPlaceOrder($this->getCart()->getOrderId()); // Make order payment step @@ -707,7 +707,7 @@ protected function updateShippingAddress() } } - $address->map($this->prepareAddressData($data)); + $address->map($this->prepareAddressData($data, 'shipping')); if (!$profile->getBillingAddress()) { @@ -801,7 +801,7 @@ protected function updateBillingAddress() } } - $address->map($this->prepareAddressData($data)); + $address->map($this->prepareAddressData($data, 'billing')); \XLite\Core\Event::updateCart( array( @@ -823,10 +823,20 @@ protected function updateBillingAddress() * * @return array */ - protected function prepareAddressData(array $data) + protected function prepareAddressData(array $data, $type = 'shipping') { unset($data['save_as_new']); + $requiredFields = 'shipping' == $type + ? \XLite\Core\Database::getRepo('XLite\Model\AddressField')->getShippingRequiredFields() + : \XLite\Core\Database::getRepo('XLite\Model\AddressField')->getBillingRequiredFields(); + + foreach ($requiredFields as $fieldName) { + if (!isset($data[$fieldName]) && \XLite\Model\Address::getDefaultFieldValue($fieldName)) { + $data[$fieldName] = \XLite\Model\Address::getDefaultFieldValue($fieldName); + } + } + return $data; } diff --git a/src/classes/XLite/Core/Mailer.php b/src/classes/XLite/Core/Mailer.php index f45619b1ce..89be875c78 100644 --- a/src/classes/XLite/Core/Mailer.php +++ b/src/classes/XLite/Core/Mailer.php @@ -255,7 +255,10 @@ public static function sendOrderCreatedCustomer(\XLite\Model\Order $order) static::compose( \XLite\Core\Config::getInstance()->Company->orders_department, $order->getProfile()->getLogin(), - 'order_created' + 'order_created', + array(), + true, + \XLite::MAIL_INTERFACE ); \XLite\Core\OrderHistory::getInstance()->registerCustomerEmailSent($order->getOrderId()); @@ -275,7 +278,10 @@ public static function sendOrderCreatedAdmin(\XLite\Model\Order $order) static::compose( \XLite\Core\Config::getInstance()->Company->site_administrator, \XLite\Core\Config::getInstance()->Company->orders_department, - 'order_created_admin' + 'order_created_admin', + array(), + true, + \XLite::MAIL_INTERFACE ); \XLite\Core\OrderHistory::getInstance()->registerAdminEmailSent($order->getOrderId()); @@ -315,7 +321,10 @@ public static function sendProcessOrderAdmin(\XLite\Model\Order $order) static::compose( \XLite\Core\Config::getInstance()->Company->site_administrator, \XLite\Core\Config::getInstance()->Company->orders_department, - 'order_processed' + 'order_processed', + array(), + true, + \XLite::MAIL_INTERFACE ); \XLite\Core\OrderHistory::getInstance()->registerAdminEmailSent($order->getOrderId()); @@ -336,7 +345,10 @@ public static function sendProcessOrderCustomer(\XLite\Model\Order $order) static::compose( \XLite\Core\Config::getInstance()->Company->site_administrator, $order->getProfile()->getLogin(), - 'order_processed' + 'order_processed', + array(), + true, + \XLite::MAIL_INTERFACE ); \XLite\Core\OrderHistory::getInstance()->registerCustomerEmailSent($order->getOrderId()); @@ -377,7 +389,10 @@ public static function sendFailedOrderAdmin(\XLite\Model\Order $order) static::compose( \XLite\Core\Config::getInstance()->Company->site_administrator, \XLite\Core\Config::getInstance()->Company->orders_department, - 'order_failed' + 'order_failed', + array(), + true, + \XLite::MAIL_INTERFACE ); \XLite\Core\OrderHistory::getInstance()->registerAdminEmailSent($order->getOrderId()); @@ -398,7 +413,10 @@ public static function sendFailedOrderCustomer(\XLite\Model\Order $order) static::compose( \XLite\Core\Config::getInstance()->Company->orders_department, $order->getProfile()->getLogin(), - 'order_failed' + 'order_failed', + array(), + true, + \XLite::MAIL_INTERFACE ); \XLite\Core\OrderHistory::getInstance()->registerCustomerEmailSent($order->getOrderId()); @@ -507,17 +525,18 @@ protected static function register($name, $value = '') /** * Compose and send wrapper for \XLite\View\Mailer::compose() * - * @param string $from ____param_comment____ - * @param string $to ____param_comment____ - * @param string $dir ____param_comment____ - * @param array $customHeaders ____param_comment____ OPTIONAL - * @param boolean $doSend ____param_comment____ OPTIONAL + * @param string $from Email FROM + * @param string $to Email TO + * @param string $dir Directory where mail templates are located + * @param array $customHeaders Array of custom mail headers OPTIONAL + * @param boolean $doSend Flag: if true - send email immediately OPTIONAL + * @param string $mailInterface Intarface to compile mail templates (skin name: customer, admin or mail) OPTIONAL * * @return void */ - protected static function compose($from, $to, $dir, $customHeaders = array(), $doSend = true) + protected static function compose($from, $to, $dir, $customHeaders = array(), $doSend = true, $mailInterface = \XLite::CUSTOMER_INTERFACE) { - static::getMailer()->compose($from, $to, $dir, $customHeaders, static::$mailInterface); + static::getMailer()->compose($from, $to, $dir, $customHeaders, $mailInterface); if ($doSend) { diff --git a/src/classes/XLite/Core/Marketplace.php b/src/classes/XLite/Core/Marketplace.php index 1348ac42de..c23a373745 100644 --- a/src/classes/XLite/Core/Marketplace.php +++ b/src/classes/XLite/Core/Marketplace.php @@ -524,6 +524,8 @@ protected function prepareResponseForGetAddonsAction(array $data) 'isSystem' => (bool) $this->getField($module, static::FIELD_IS_SYSTEM), ); + $result[$key] = array_merge($result[$key], $this->adjustResponseItemForGetAddonsAction($module)); + } else { // :TODO: add logging here @@ -533,6 +535,18 @@ protected function prepareResponseForGetAddonsAction(array $data) return $result; } + /** + * Adjust result array item for get_addons action + * + * @param array $module + * + * @return array + */ + protected function adjustResponseItemForGetAddonsAction($module) + { + return array(); + } + // }}} // {{{ "Get addon pack" request diff --git a/src/classes/XLite/Model/AEntity.php b/src/classes/XLite/Model/AEntity.php index c519be5c76..374c66489b 100644 --- a/src/classes/XLite/Model/AEntity.php +++ b/src/classes/XLite/Model/AEntity.php @@ -80,9 +80,9 @@ public function map(array $data) // $method is assembled from 'set' + getMethodName() $this->$method($value); - } elseif (property_exists($this, $key)) { + } else { - $this->$key = $value; + $this->setterProperty($key, $value); } } } @@ -197,28 +197,58 @@ public function __call($method, array $args = array()) if ($result) { $property = \XLite\Core\Converter::convertFromCamelCase($matches[2]); + } + + $return = 'set' === $matches[1] + ? $this->setterProperty($property, array_shift($args)) + : $this->getterProperty($property); + + if (is_null($return)) { - $result = property_exists($this, $property); + throw new \BadMethodCallException( + get_class($this) . '::' . $method . '() - method not exists or invalid getter/setter' + ); } - $return = null; + return $return; + } + + /** + * Universal setter + * + * @param string $property + * @param mixed $value + * + * @return true|null Returns TRUE if the setting succeeds. NULL if the setting fails + */ + public function setterProperty($property, $value) + { + $result = property_exists($this, $property); if ($result) { - if ('set' === $matches[1]) { + $this->$property = $value; + } - $this->$property = array_shift($args); + return $result ?: null; + } - } else { + /** + * Universal getter + * + * @param string $property + * + * @return mixed|null Returns NULL if it is impossible to get the property + */ + public function getterProperty($property) + { + $result = property_exists($this, $property); - $return = $this->$property; - } + $return = null; - } else { + if ($result) { - throw new \BadMethodCallException( - get_class($this) . '::' . $method . '() - method not exists or invalid getter/setter' - ); + $return = $this->$property; } return $return; diff --git a/src/classes/XLite/Model/Address.php b/src/classes/XLite/Model/Address.php index 928d1ba69b..152283a403 100644 --- a/src/classes/XLite/Model/Address.php +++ b/src/classes/XLite/Model/Address.php @@ -47,6 +47,14 @@ class Address extends \XLite\Model\Base\PersonalAddress const SHIPPING = 's'; + /** + * Address fields collection + * + * @var \Doctrine\Common\Collections\ArrayCollection + * + * @OneToMany (targetEntity="XLite\Model\AddressFieldValue", mappedBy="address", cascade={"persist"}) + */ + protected $addressFields; /** * Flag: is it a billing address @@ -69,48 +77,130 @@ class Address extends \XLite\Model\Base\PersonalAddress /** * Profile: many-to-one relation with profile entity * - * @var \Doctrine\Common\Collections\ArrayCollection + * @var \XLite\Model\Profile * * @ManyToOne (targetEntity="XLite\Model\Profile", inversedBy="addresses") * @JoinColumn (name="profile_id", referencedColumnName="profile_id") */ protected $profile; + /** + * Universal setter + * + * @param string $property + * @param mixed $value + * + * @return true|null Returns TRUE if the setting succeeds. NULL if the setting fails + */ + public function setterProperty($property, $value) + { + $result = parent::setterProperty($property, $value); + + if (is_null($result)) { + + $addressField = \XLite\Core\Database::getRepo('XLite\Model\AddressField') + ->findOneBy(array('serviceName' => $property)); + + if ($addressField) { + + $repo = \XLite\Core\Database::getRepo('XLite\Model\AddressFieldValue'); + + $data = array( + 'address' => $this, + 'addressField' => $addressField, + ); + + $addressFieldValue = $repo->findOneBy($data); + + if ($addressFieldValue) { + $addressFieldValue->setValue($value); + + $repo->update($addressFieldValue); + } else { + + $data['value'] = $value; + $addressFieldValue = new \XLite\Model\AddressFieldValue($data); + + $repo->insert($addressFieldValue); + } + + $result = true; + } + } + + return $result; + } /** - * Get billing address-specified required fields + * Universal getter * - * @return array + * @param string $property + * + * @return mixed|null Returns NULL if it is impossible to get the property */ - public function getBillingRequiredFields() + public function getterProperty($property) { - return array( - 'name', - 'street', - 'city', - 'zipcode', - 'state', - 'country', - ); + $result = parent::getterProperty($property); + + if (is_null($result)) { + + $addressField = \XLite\Core\Database::getRepo('XLite\Model\AddressField') + ->findOneBy(array('serviceName' => $property)); + + if ($addressField) { + + $addressFieldValue = \XLite\Core\Database::getRepo('XLite\Model\AddressFieldValue') + ->findOneBy(array( + 'address' => $this->getAddressId(), + 'addressField' => $addressField->getId(), + )); + + $result = $addressFieldValue + ? $addressFieldValue->getValue() + : static::getDefaultFieldPlainValue($property); + } + } + + return $result; } /** - * Get shipping address-specified required fields + * Get default value for the field * - * @return array + * @param string $fieldName Field service name + * + * @return mixed */ - public function getShippingRequiredFields() + public static function getDefaultFieldValue($fieldName) { - return array( - 'name', - 'street', - 'city', - 'zipcode', - 'state', - 'country', - ); + $result = null; + + switch ($fieldName) { + case 'country': + $code = \XLite\Core\Config::getInstance()->Shipping->anonymous_country; + $result = \XLite\Core\Database::getRepo('XLite\Model\Country')->findOneByCode($code); + break; + + case 'state': + $id = \XLite\Core\Config::getInstance()->Shipping->anonymous_state; + $result = \XLite\Core\Database::getRepo('XLite\Model\State')->find($id); + break; + + case 'zipcode': + $result = \XLite\Core\Config::getInstance()->Shipping->anonymous_zipcode; + break; + + case 'city': + $result = \XLite\Core\Config::getInstance()->Shipping->anonymous_city; + break; + + default: + } + + return $result; } + /** * Get required fields by address type * @@ -121,12 +211,12 @@ public function getShippingRequiredFields() public function getRequiredFieldsByType($atype) { switch ($atype) { - case self::BILLING: - $list = $this->getBillingRequiredFields(); + case static::BILLING: + $list = \XLite\Core\Database::getRepo('XLite\Model\AddressField')->getBillingRequiredFields(); break; - case self::SHIPPING: - $list = $this->getShippingRequiredFields(); + case static::SHIPPING: + $list = \XLite\Core\Database::getRepo('XLite\Model\AddressField')->getShippingRequiredFields(); break; default: @@ -146,30 +236,28 @@ public function cloneEntity() { $entity = parent::cloneEntity(); - if ($this->getProfile()) { - $entity->setProfile($this->getProfile()); - } + $cnd = array('address' => $this); - return $entity; - } + foreach (\XLite\Core\Database::getRepo('XLite\Model\AddressField')->findAllEnabled() as $field) { + $cnd['addressField'] = $field; - /** - * Check if address has duplicates - * - * @return boolean - */ - protected function checkAddress() - { - $result = parent::checkAddress(); + $fieldValue = \XLite\Core\Database::getRepo('XLite\Model\AddressFieldValue')->findOneBy($cnd); + + if ($fieldValue) { - $sameAddress = $this->getRepository()->findSameAddress($this); + $newFieldValue = $fieldValue->cloneEntity(); + $newFieldValue->setAddress($entity); + $newFieldValue->setAddressField($field); + } - if ($sameAddress) { - \XLite\Core\TopMessage::addWarning('Address was not saved as other address with specified fields is already exists.'); - $result = false; + \XLite\Core\Database::getEM()->persist($newFieldValue); } - return $result; + if ($this->getProfile()) { + $entity->setProfile($this->getProfile()); + } + + return $entity; } } diff --git a/src/classes/XLite/Model/AddressField.php b/src/classes/XLite/Model/AddressField.php new file mode 100644 index 0000000000..6bf6f166aa --- /dev/null +++ b/src/classes/XLite/Model/AddressField.php @@ -0,0 +1,138 @@ + + * @copyright Copyright (c) 2011-2012 Creative Development LLC . All rights reserved + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + * @link http://www.litecommerce.com/ + */ + +namespace XLite\Model; + +/** + * Address field model + * + * + * @Entity (repositoryClass="\XLite\Model\Repo\AddressField") + * @Table (name="address_field") + */ +class AddressField extends \XLite\Model\Base\I18n +{ + /** + * Unique id + * + * @var integer + * + * @Id + * @GeneratedValue (strategy="AUTO") + * @Column (type="integer", nullable=false) + */ + protected $id; + + /** + * Service name for address field + * For example: firstname, lastname, country_code and so on. + * + * The field is named with this value in the address forms. + * Also the "service-name-{$serviceName}" CSS class is added to the field + * + * @var string + * @Column(type="string", length=128, unique=true, nullable=false) + */ + protected $serviceName; + + /** + * Getter name for address field (for AView::getAddressSectionData) + * For example: + * country for country_code + * state for state_id, custom_state + * + * The field is named with this value in the address forms. + * Also the "service-name-{$serviceName}" CSS class is added to the field + * + * @var string + * @Column(type="string", length=128, nullable=false) + */ + protected $viewGetterName = ''; + + /** + * Schema class for "Form field widget". + * This class will be used in form widgets + * + * Possible values are: + * + * \XLite\View\FormField\Input\Text + * \XLite\View\FormField\Select\Country + * \XLite\View\FormField\Select\Title + * + * For more information check "\XLite\View\FormField\*" class family. + * + * The '\XLite\View\FormField\Input\Text' class (standard input text field) + * is taken for additional fields by default. + * + * @var string + * @Column(type="string", length=256, nullable=false) + */ + protected $schemaClass = '\XLite\View\FormField\Input\Text'; + + /** + * Flag if the field is an additional one (This field could be removed) + * + * @var boolean + * @Column(type="boolean") + */ + protected $additional = true; + + /** + * Flag if the field is a required one + * + * @var boolean + * @Column(type="boolean") + */ + protected $required = true; + + /** + * Flag if the field is an enabled one + * + * @var boolean + * @Column(type="boolean") + */ + protected $enabled = true; + + /** + * Position + * + * @var integer + * + * @Column (type="integer") + */ + protected $position = 0; + + + /** + * Return CSS classes for this field name entry + * + * @return string + */ + public function getCSSFieldName() + { + return 'address-' . $this->getServiceName() . ($this->getAdditional() ? ' field-additional' : ''); + } + +} diff --git a/src/classes/XLite/Model/AddressFieldTranslation.php b/src/classes/XLite/Model/AddressFieldTranslation.php new file mode 100644 index 0000000000..2911d96543 --- /dev/null +++ b/src/classes/XLite/Model/AddressFieldTranslation.php @@ -0,0 +1,46 @@ + + * @copyright Copyright (c) 2011-2012 Creative Development LLC . All rights reserved + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + * @link http://www.litecommerce.com/ + */ + +namespace XLite\Model; + +/** + * Category multilingual data + * + * + * @Entity + * @Table (name="address_field_translation") + */ +class AddressFieldTranslation extends \XLite\Model\Base\Translation +{ + /** + * Field name + * + * @var string + * + * @Column (type="string", length=255) + */ + protected $name; + +} diff --git a/src/classes/XLite/Model/AddressFieldValue.php b/src/classes/XLite/Model/AddressFieldValue.php new file mode 100644 index 0000000000..d76cd33d80 --- /dev/null +++ b/src/classes/XLite/Model/AddressFieldValue.php @@ -0,0 +1,76 @@ + + * @copyright Copyright (c) 2011-2012 Creative Development LLC . All rights reserved + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + * @link http://www.litecommerce.com/ + */ + +namespace XLite\Model; + +/** + * Address field value (additional fields) model + * + * + * @Entity (repositoryClass="\XLite\Model\Repo\AddressFieldValue") + * @Table (name="address_field_value") + */ +class AddressFieldValue extends \XLite\Model\AEntity +{ + /** + * Unique id + * + * @var integer + * + * @Id + * @GeneratedValue (strategy="AUTO") + * @Column (type="integer", nullable=false) + */ + protected $id; + + /** + * Additional field value + * + * @var string + * @Column(type="string", length=255, nullable=false) + */ + protected $value = ''; + + /** + * Address field model relation + * + * @var \XLite\Model\AddressField + * + * @ManyToOne (targetEntity="XLite\Model\AddressField", cascade="all") + * @JoinColumn(name="address_field_id", referencedColumnName="id", onDelete="SET NULL") + */ + protected $addressField; + + /** + * Address model relation + * + * @var \XLite\Model\Address + * + * @ManyToOne (targetEntity="XLite\Model\Address", cascade="all") + * @JoinColumn(name="address_id", referencedColumnName="address_id") + */ + protected $address; + +} diff --git a/src/classes/XLite/Model/Attribute.php b/src/classes/XLite/Model/Attribute.php new file mode 100644 index 0000000000..94667fa049 --- /dev/null +++ b/src/classes/XLite/Model/Attribute.php @@ -0,0 +1,410 @@ + + * @copyright Copyright (c) 2011-2012 Creative Development LLC . All rights reserved + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + * @link http://www.litecommerce.com/ + */ + +namespace XLite\Model; + +/** + * Attribute + * + * @Entity + * @Table (name="attributes") + */ +class Attribute extends \XLite\Model\Base\I18n +{ + /* + * Attribute types + */ + const TYPE_NUMBER = 'N'; + const TYPE_TEXT = 'T'; + const TYPE_CHECKBOX = 'C'; + const TYPE_SELECT = 'S'; + + /** + * ID + * + * @var integer + * + * @Id + * @GeneratedValue (strategy="AUTO") + * @Column (type="uinteger") + */ + protected $id; + + /** + * Position + * + * @var integer + * @see ____var_see____ + * @since 1.0.0 + * + * @Column (type="integer") + */ + protected $position = 0; + + /** + * Default value + * + * @var text + * @see ____var_see____ + * @since 1.0.0 + * + * @Column (type="text") + */ + protected $defaultValue = ''; + + /** + * Decimals + * + * @var integer + * @see ____var_see____ + * @since 1.0.0 + * + * @Column (type="integer", length=1) + */ + protected $decimals = 0; + + /** + * Product class + * + * @var \XLite\Model\ProductClass + * + * @ManyToOne (targetEntity="XLite\Model\ProductClass", inversedBy="attributes") + * @JoinColumn (name="product_class_id", referencedColumnName="id") + */ + protected $product_class; + + /** + * Attribute group + * + * @var selfGroup + * + * @ManyToOne (targetEntity="XLite\Model\AttributeGroup", inversedBy="attributes") + * @JoinColumn (name="attribute_group_id", referencedColumnName="id", onDelete="SET NULL") + */ + protected $attribute_group; + + /** + * Attribute options + * + * @var \Doctrine\Common\Collections\Collection + * + * @OneToMany (targetEntity="XLite\Model\AttributeOption", mappedBy="attribute") + */ + protected $attribute_options; + + /** + * Option type + * + * @var string + * + * @Column (type="fixedstring", length=1) + */ + protected $type = self::TYPE_TEXT; + + /** + * Constructor + * + * @param array $data Entity properties OPTIONAL + * + * @return void + */ + public function __construct(array $data = array()) + { + $this->attribute_options = new \Doctrine\Common\Collections\ArrayCollection(); + + parent::__construct($data); + } + + /** + * Return number of products associated with this attribute + * + * @return integer + */ + public function getProductsCount() + { + return count($this->getClass()->getProducts()); + } + + /** + * Return list of types or type + * + * @param string $type Type OPTIONAL + * + * @return array | string + */ + public static function getTypes($type = null) + { + $list = array( + self::TYPE_TEXT => 'Text', + self::TYPE_NUMBER => 'Number', + self::TYPE_CHECKBOX => 'Checkbox', + self::TYPE_SELECT => 'Select', + ); + + return isset($type) + ? (isset($list[$type]) ? $list[$type] : null) + : $list; + } + + /** + * Return values associated with this attribute + * + * @return mixed + */ + public function getAttributeValues() + { + $cnd = new \XLite\Core\CommonCell; + $cnd->attribute = $this; + + return \XLite\Core\Database::getRepo($this->getAttributeValueClass()) + ->search($cnd); + } + + /** + * Return number of values associated with this attribute + * + * @return integer + */ + public function getAttributeValuesCount() + { + $cnd = new \XLite\Core\CommonCell; + $cnd->attribute = $this; + + return \XLite\Core\Database::getRepo($this->getAttributeValueClass()) + ->search($cnd, true); + } + + /** + * Set type + * + * @param string $type Type + * + * @return void + */ + public function setType($type) + { + $types = static::getTypes(); + + if (isset($types[$type])) { + if ( + $this->type + && $type != $this->type + && $this->getId() + ) { + $this->setDefaultValue($this->defaultValue); + foreach ($this->getAttributeOptions() as $option) { + \XLite\Core\Database::getEM()->remove($option); + } + foreach ($this->getAttributeValues() as $value) { + \XLite\Core\Database::getEM()->remove($value); + } + } + $this->type = $type; + } + } + + /** + * Set default type + * + * @param string $value Value + * + * @return void + */ + public function setDefaultValue($value) + { + if (self::TYPE_NUMBER == $this->type) { + $value = (float)$value; + + } elseif (self::TYPE_CHECKBOX == $this->type) { + $value = (boolean)$value; + + } + + $this->defaultValue = $value; + } + + /** + * Get default value + * + * @return mixed + */ + public function getDefaultValue() + { + $value = $this->defaultValue; + if (self::TYPE_NUMBER == $this->type) { + $value = (float)$value; + + } elseif (self::TYPE_CHECKBOX == $this->type) { + $value = (boolean)$value; + + } + + return $value; + } + + /** + * Return name of widget class + * + * @return string + */ + public function getWidgetClass() + { + switch ($this->getType()) { + case self::TYPE_NUMBER: + $class = '\XLite\View\FormField\Input\Text\Float'; + break; + + case self::TYPE_TEXT: + $class = '\XLite\View\FormField\Textarea\Simple'; + break; + + case self::TYPE_CHECKBOX: + $class = '\XLite\View\FormField\Input\Checkbox\Enabled'; + break; + + case self::TYPE_SELECT: + $class = '\XLite\View\FormField\Input\Text\AttributeOption'; + break; + + } + + return $class; + } + + /** + * Return name of value class + * + * @return string + */ + public function getAttributeValueClass() + { + return '\XLite\Model\AttributeValue\AttributeValue' + . $this->getTypes($this->getType()); + } + + /** + * Return field comment + * + * @return string + */ + public function getFieldComment() + { + return self::TYPE_NUMBER == $this->getType() + ? $this->getUnit() + : ''; + } + + /** + * Set attribute value + * + * @param \XLite\Model\Product $product Product + * @param mixed $value Value + * + * @return void + */ + public function setAttributeValue(\XLite\Model\Product $product, $value) + { + $class = $this->getAttributeValueClass(); + $attributeValue = \XLite\Core\Database::getRepo($class) + ->findOneBy(array('product' => $product, 'attribute' => $this)); + + if (!$attributeValue) { + !$attributeValue = new $class(); + $attributeValue->setProduct($product); + $attributeValue->setAttribute($this); + \XLite\Core\Database::getEM()->persist($attributeValue); + } + + if (self::TYPE_SELECT == $this->getType()) { + $value = trim($value); + if ($value) { + $attributeOption = \XLite\Core\Database::getRepo('XLite\Model\AttributeOption') + ->findOneByNameAndAttribute($value, $this); + + if (!$attributeOption) { + $attributeOption = new \XLite\Model\AttributeOption(); + $attributeOption->setAttribute($this); + $attributeOption->setName($value); + \XLite\Core\Database::getEM()->persist($attributeOption); + } + $attributeValue->setAttributeOption($attributeOption); + } + + } else { + $attributeValue->setValue($value); + } + } + + /** + * Get attribute value + * + * @param \XLite\Model\Product $product Product + * @param bollean $asString As string flag OPTIONAL + * + * @return mixed + */ + public function getAttributeValue(\XLite\Model\Product $product, $asString = false) + { + $attributeValue = \XLite\Core\Database::getRepo($this->getAttributeValueClass()) + ->findOneBy(array('product' => $product, 'attribute' => $this)); + + if (self::TYPE_SELECT == $this->getType()) { + if ($attributeValue) { + $attributeValue = $attributeValue->getAttributeOption(); + } else { + $attributeValue = \XLite\Core\Database::getRepo('XLite\Model\AttributeOption') + ->findOneBy(array('defaultValue' => 1, 'attribute' => $this)); + } + + if ( + $attributeValue + && $asString + ) { + $attributeValue = $attributeValue->getName(); + } + + } elseif ($attributeValue) { + $attributeValue = $attributeValue->getValue(); + } + + if (is_null($attributeValue)) { + $attributeValue = self::TYPE_SELECT == $this->getType() + ? '' + : $this->getDefaultValue(); + } + + if ($asString) { + if(self::TYPE_NUMBER == $this->getType()) { + $attributeValue = number_format($attributeValue, $this->getDecimals()) + . ' ' . $this->getUnit(); + + } elseif (self::TYPE_CHECKBOX == $this->getType()) { + $attributeValue = static::t($attributeValue ? 'yes' : 'no'); + } + } + + return $attributeValue; + } +} diff --git a/src/classes/XLite/Model/AttributeGroup.php b/src/classes/XLite/Model/AttributeGroup.php new file mode 100644 index 0000000000..f21f746cd4 --- /dev/null +++ b/src/classes/XLite/Model/AttributeGroup.php @@ -0,0 +1,100 @@ + + * @copyright Copyright (c) 2011-2012 Creative Development LLC . All rights reserved + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + * @link http://www.litecommerce.com/ + */ + +namespace XLite\Model; + +/** + * Attribute group + * + * @Entity + * @Table (name="attribute_groups") + */ +class AttributeGroup extends \XLite\Model\Base\I18n +{ + /** + * ID + * + * @var integer + * + * @Id + * @GeneratedValue (strategy="AUTO") + * @Column (type="uinteger") + */ + protected $id; + + /** + * Position + * + * @var integer + * @see ____var_see____ + * @since 1.0.0 + * + * @Column (type="integer") + */ + protected $position = 0; + + /** + * Product class + * + * @var \XLite\Model\ProductClass + * + * @ManyToOne (targetEntity="XLite\Model\ProductClass", inversedBy="attribute_groups") + * @JoinColumn (name="product_class_id", referencedColumnName="id") + */ + protected $product_class; + + /** + * Attributes + * + * @var \Doctrine\Common\Collections\Collection + * + * @OneToMany (targetEntity="XLite\Model\Attribute", mappedBy="attribute_group") + */ + protected $attributes; + + /** + * Constructor + * + * @param array $data Entity properties OPTIONAL + * + * @return void + */ + public function __construct(array $data = array()) + { + $this->attributes = new \Doctrine\Common\Collections\ArrayCollection(); + + parent::__construct($data); + } + + /** + * Return number of attributes associated with this class + * + * @return integer + */ + public function getAttributesCount() + { + return count($this->getAttributes()); + } +} diff --git a/src/classes/XLite/Model/AttributeGroupTranslation.php b/src/classes/XLite/Model/AttributeGroupTranslation.php new file mode 100644 index 0000000000..9c13cf7d30 --- /dev/null +++ b/src/classes/XLite/Model/AttributeGroupTranslation.php @@ -0,0 +1,51 @@ + + * @copyright Copyright (c) 2011-2012 Creative Development LLC . All rights reserved + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + * @link http://www.litecommerce.com/ + */ + +namespace XLite\Model; + +/** + * Attribute group multilingual data + * + * + * @Entity + * + * @Table (name="attribute_group_translations", + * indexes={ + * @Index (name="ci", columns={"code","id"}), + * @Index (name="id", columns={"id"}) + * } + * ) + */ +class AttributeGroupTranslation extends \XLite\Model\Base\Translation +{ + /** + * Name + * + * @var string + * + * @Column (type="string", length=255) + */ + protected $name; +} diff --git a/src/classes/XLite/Model/AttributeOption.php b/src/classes/XLite/Model/AttributeOption.php new file mode 100644 index 0000000000..52ce7a6ae4 --- /dev/null +++ b/src/classes/XLite/Model/AttributeOption.php @@ -0,0 +1,67 @@ + + * @copyright Copyright (c) 2011-2012 Creative Development LLC . All rights reserved + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + * @link http://www.litecommerce.com/ + */ + +namespace XLite\Model; + +/** + * Attribute option + * + * @Entity + * @Table (name="attribute_options") + */ +class AttributeOption extends \XLite\Model\Base\I18n +{ + /** + * ID + * + * @var integer + * + * @Id + * @GeneratedValue (strategy="AUTO") + * @Column (type="uinteger") + */ + protected $id; + + /** + * Default flag + * + * @var boolean + * @see ____var_see____ + * @since 1.0.0 + * + * @Column (type="boolean") + */ + protected $defaultValue = false; + + /** + * Attribute + * + * @var \XLite\Model\Attribute + * + * @ManyToOne (targetEntity="XLite\Model\Attribute", inversedBy="attribute_options") + * @JoinColumn (name="attribute_id", referencedColumnName="id") + */ + protected $attribute; +} diff --git a/src/classes/XLite/Model/AttributeOptionTranslation.php b/src/classes/XLite/Model/AttributeOptionTranslation.php new file mode 100644 index 0000000000..a0a2d9bbef --- /dev/null +++ b/src/classes/XLite/Model/AttributeOptionTranslation.php @@ -0,0 +1,51 @@ + + * @copyright Copyright (c) 2011-2012 Creative Development LLC . All rights reserved + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + * @link http://www.litecommerce.com/ + */ + +namespace XLite\Model; + +/** + * Attribute option multilingual data + * + * + * @Entity + * + * @Table (name="attribute_option_translations", + * indexes={ + * @Index (name="ci", columns={"code","id"}), + * @Index (name="id", columns={"id"}) + * } + * ) + */ +class AttributeOptionTranslation extends \XLite\Model\Base\Translation +{ + /** + * Name + * + * @var string + * + * @Column (type="string", length=255) + */ + protected $name; +} diff --git a/src/classes/XLite/Model/AttributeTranslation.php b/src/classes/XLite/Model/AttributeTranslation.php new file mode 100644 index 0000000000..14566904e1 --- /dev/null +++ b/src/classes/XLite/Model/AttributeTranslation.php @@ -0,0 +1,63 @@ + + * @copyright Copyright (c) 2011-2012 Creative Development LLC . All rights reserved + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + * @link http://www.litecommerce.com/ + */ + +namespace XLite\Model; + +/** + * Attribute multilingual data + * + * + * @Entity + * + * @Table (name="attribute_translations", + * indexes={ + * @Index (name="ci", columns={"code","id"}), + * @Index (name="id", columns={"id"}) + * } + * ) + */ +class AttributeTranslation extends \XLite\Model\Base\Translation +{ + /** + * Name + * + * @var string + * + * @Column (type="string", length=255) + */ + protected $name; + + /** + * Unit + * + * @var string + * @see ____var_see____ + * @since 1.0.0 + * + * @Column (type="string", length=255) + */ + protected $unit = ''; + +} diff --git a/src/classes/XLite/Model/AttributeValue/AAttributeValue.php b/src/classes/XLite/Model/AttributeValue/AAttributeValue.php new file mode 100644 index 0000000000..7d8bd307a7 --- /dev/null +++ b/src/classes/XLite/Model/AttributeValue/AAttributeValue.php @@ -0,0 +1,65 @@ + + * @copyright Copyright (c) 2011-2012 Creative Development LLC . All rights reserved + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + * @link http://www.litecommerce.com/ + */ + +namespace XLite\Model\AttributeValue; + +/** + * Abstract attribute value + * + * @MappedSuperclass + */ +abstract class AAttributeValue extends \XLite\Model\AEntity +{ + /** + * ID + * + * @var integer + * + * @Id + * @GeneratedValue (strategy="AUTO") + * @Column (type="uinteger") + */ + protected $id; + + /** + * Product + * + * @var \XLite\Model\Product + * + * @ManyToOne (targetEntity="XLite\Model\Product") + * @JoinColumn (name="product_id", referencedColumnName="product_id") + */ + protected $product; + + /** + * Attribute + * + * @var \XLite\Model\Attribute + * + * @ManyToOne (targetEntity="XLite\Model\Attribute") + * @JoinColumn (name="attribute_id", referencedColumnName="id") + */ + protected $attribute; +} diff --git a/src/classes/XLite/Model/AttributeValue/AttributeValueCheckbox.php b/src/classes/XLite/Model/AttributeValue/AttributeValueCheckbox.php new file mode 100644 index 0000000000..e397ce46f8 --- /dev/null +++ b/src/classes/XLite/Model/AttributeValue/AttributeValueCheckbox.php @@ -0,0 +1,50 @@ + + * @copyright Copyright (c) 2011-2012 Creative Development LLC . All rights reserved + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + * @link http://www.litecommerce.com/ + */ + +namespace XLite\Model\AttributeValue; + +/** + * Attribute value (checkbox) + * + * @Entity (repositoryClass="\XLite\Model\Repo\AttributeValue\AttributeValueCheckbox") + * @Table (name="attribute_values_checkbox", + * indexes={ + * @Index (name="product_id", columns={"product_id"}), + * @Index (name="attribute_id", columns={"attribute_id"}), + * @Index (name="value", columns={"value"}) + * } + * ) + */ +class AttributeValueCheckbox extends \XLite\Model\AttributeValue\AAttributeValue +{ + /** + * Value + * + * @var boolean + * + * @Column (type="boolean") + */ + protected $value = false; +} diff --git a/src/classes/XLite/Model/AttributeValue/AttributeValueNumber.php b/src/classes/XLite/Model/AttributeValue/AttributeValueNumber.php new file mode 100644 index 0000000000..e0cf31e4e4 --- /dev/null +++ b/src/classes/XLite/Model/AttributeValue/AttributeValueNumber.php @@ -0,0 +1,50 @@ + + * @copyright Copyright (c) 2011-2012 Creative Development LLC . All rights reserved + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + * @link http://www.litecommerce.com/ + */ + +namespace XLite\Model\AttributeValue; + +/** + * Attribute value (number) + * + * @Entity (repositoryClass="\XLite\Model\Repo\AttributeValue\AttributeValueNumber") + * @Table (name="attribute_values_number", + * indexes={ + * @Index (name="product_id", columns={"product_id"}), + * @Index (name="attribute_id", columns={"attribute_id"}), + * @Index (name="value", columns={"value"}) + * } + * ) + */ +class AttributeValueNumber extends \XLite\Model\AttributeValue\AAttributeValue +{ + /** + * Value + * + * @var float + * + * @Column (type="decimal", precision=14, scale=4) + */ + protected $value = 0; +} diff --git a/src/classes/XLite/Model/AttributeValue/AttributeValueSelect.php b/src/classes/XLite/Model/AttributeValue/AttributeValueSelect.php new file mode 100644 index 0000000000..8ad6158e55 --- /dev/null +++ b/src/classes/XLite/Model/AttributeValue/AttributeValueSelect.php @@ -0,0 +1,51 @@ + + * @copyright Copyright (c) 2011-2012 Creative Development LLC . All rights reserved + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + * @link http://www.litecommerce.com/ + */ + +namespace XLite\Model\AttributeValue; + +/** + * Attribute value (select) + * + * @Entity (repositoryClass="\XLite\Model\Repo\AttributeValue\AttributeValueSelect") + * @Table (name="attribute_values_select", + * indexes={ + * @Index (name="product_id", columns={"product_id"}), + * @Index (name="attribute_id", columns={"attribute_id"}), + * @Index (name="attribute_option_id", columns={"attribute_option_id"}) + * } + * ) + */ +class AttributeValueSelect extends \XLite\Model\AttributeValue\AAttributeValue +{ + /** + * Attribute option + * + * @var \XLite\Model\AttributeOption + * + * @ManyToOne (targetEntity="XLite\Model\AttributeOption") + * @JoinColumn (name="attribute_option_id", referencedColumnName="id") + */ + protected $attribute_option; +} diff --git a/src/classes/XLite/Model/AttributeValue/AttributeValueText.php b/src/classes/XLite/Model/AttributeValue/AttributeValueText.php new file mode 100644 index 0000000000..ef42289b46 --- /dev/null +++ b/src/classes/XLite/Model/AttributeValue/AttributeValueText.php @@ -0,0 +1,49 @@ + + * @copyright Copyright (c) 2011-2012 Creative Development LLC . All rights reserved + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + * @link http://www.litecommerce.com/ + */ + +namespace XLite\Model\AttributeValue; + +/** + * Attribute value (text) + * + * @Entity (repositoryClass="\XLite\Model\Repo\AttributeValue\AttributeValueText") + * @Table (name="attribute_values_text", + * indexes={ + * @Index (name="product_id", columns={"product_id"}), + * @Index (name="attribute_id", columns={"attribute_id"}) + * } + * ) + */ +class AttributeValueText extends \XLite\Model\AttributeValue\AAttributeValue +{ + /** + * Value + * + * @var text + * + * @Column (type="text") + */ + protected $value; +} diff --git a/src/classes/XLite/Model/Base/Address.php b/src/classes/XLite/Model/Base/Address.php index e96fe33eea..d938ec27c1 100644 --- a/src/classes/XLite/Model/Base/Address.php +++ b/src/classes/XLite/Model/Base/Address.php @@ -53,33 +53,6 @@ abstract class Address extends \XLite\Model\AEntity */ protected $address_type = 'R'; - /** - * Phone - * - * @var string - * - * @Column (type="string", length=32) - */ - protected $phone = ''; - - /** - * Street, number of building, apartment etc - * - * @var string - * - * @Column (type="string", length=255) - */ - protected $street = ''; - - /** - * City - * - * @var string - * - * @Column (type="string", length=255) - */ - protected $city = ''; - /** * State * @@ -90,15 +63,6 @@ abstract class Address extends \XLite\Model\AEntity */ protected $state; - /** - * Custom state - * - * @var string - * - * @Column (type="string", length=255) - */ - protected $custom_state = ''; - /** * Country * @@ -109,34 +73,16 @@ abstract class Address extends \XLite\Model\AEntity */ protected $country; - /** - * Zip/postal code - * - * @var string - * - * @Column (type="string", length=32) - */ - protected $zipcode = ''; - /** * Get address fields list * * @return array(string) */ - public static function getAddressFields() + public function getAddressFields() { - return array( - 'phone', - 'street', - 'city', - 'zipcode', - 'state_id', - 'custom_state', - 'country_code', - ); + return \XLite\Core\Database::getRepo('XLite\Model\AddressField')->findEnabledFields(); } - /** * Get state * @@ -159,12 +105,39 @@ public function getState() return $state; } + /** + * Set country + * + * @param integer $countryCode Country code + */ + public function setCountryCode($countryCode) + { + $this->setterProperty('country_code', $countryCode); + + $this->setCountry(\XLite\Core\Database::getRepo('XLite\Model\Country')->findOneBy(array('code' => $countryCode))); + } + + /** + * Set state + * + * @param integer $state State id + * + * @return void + */ + public function setStateId($stateId) + { + $this->setterProperty('state_id', $stateId); + + $this->setState(\XLite\Core\Database::getRepo('XLite\Model\State')->find($stateId)); + } + /** * Set state * * @param mixed $state State object or state id or custom state name * * @return void + * @todo Refactor? */ public function setState($state) { @@ -174,25 +147,14 @@ public function setState($state) if ($state->getStateId()) { if (!$this->state || $this->state->getStateId() != $state->getStateId()) { $this->state = $state; - $this->setCustomState(''); } - } else { - $this->state = null; - - if ($state->getState()) { - $this->setCustomState($state->getState()); - } } - } elseif (is_string($state)) { - // Set custom state $this->state = null; - $this->setCustomState($state); - } } @@ -203,7 +165,9 @@ public function setState($state) */ public function getStateId() { - return $this->getState() ? $this->getState()->getStateId() : null; + return $this->getState() + ? ($this->getState()->getStateId() ?: static::getDefaultFieldPlainValue('state_id')) + : static::getDefaultFieldPlainValue('state_id'); } /** @@ -213,7 +177,79 @@ public function getStateId() */ public function getCountryCode() { - return $this->getCountry() ? $this->getCountry()->getCode() : null; + return $this->getCountry() + ? ($this->getCountry()->getCode() ?: static::getDefaultFieldPlainValue('country_code')) + : static::getDefaultFieldPlainValue('country_code'); + } + + /** + * Get country name + * + * @return string + */ + public function getCountryName() + { + return $this->getCountry() ? $this->getCountry()->getCountry() : null; + } + + /** + * Get state name + * + * @return string + */ + public function getStateName() + { + return $this->getState()->getState(); + } + + /** + * Return default field value + * + * @param string $fieldName Field name + * + * @return string + */ + public static function getDefaultFieldPlainValue($fieldName) + { + $field = \XLite\Core\Database::getRepo('\XLite\Model\Config') + ->findOneBy(array( + 'category' => \XLite\Model\Config::SHIPPING_CATEGORY, + 'name' => static::getDefaultFieldName($fieldName) + )); + + return $field ? $field->getValue() : ''; + } + + /** + * Return name of the address field in the default shipping category of the settings + * + * @param string $fieldName + * + * @return string + */ + protected static function getDefaultFieldName($fieldName) + { + $result = \XLite\Model\Config::SHIPPING_VALUES_PREFIX; + + switch ($fieldName) { + case 'country_code': + $result .= 'country'; + break; + + case 'state_id': + $result .= 'state'; + break; + + case 'street': + $result .= 'address'; + break; + + default: + $result .= $fieldName; + break; + } + + return $result; } /** diff --git a/src/classes/XLite/Model/Base/PersonalAddress.php b/src/classes/XLite/Model/Base/PersonalAddress.php index d0963aaaf0..8b0dfa4d38 100644 --- a/src/classes/XLite/Model/Base/PersonalAddress.php +++ b/src/classes/XLite/Model/Base/PersonalAddress.php @@ -33,44 +33,6 @@ */ abstract class PersonalAddress extends \XLite\Model\Base\Address { - /** - * Title - * - * @var string - * - * @Column (type="string", length=32) - */ - protected $title = ''; - - /** - * First name - * - * @var string - * - * @Column (type="string", length=128) - */ - protected $firstname = ''; - - /** - * Last name - * - * @var string - * - * @Column (type="string", length=128) - */ - protected $lastname = ''; - - /** - * Get address fields list - * - * @return array(string) - */ - public static function getAddressFields() - { - return array_merge(array('firstname', 'lastname'), parent::getAddressFields()); - } - - /** * Get full name * diff --git a/src/classes/XLite/Model/Config.php b/src/classes/XLite/Model/Config.php index 3b0ed06e4a..463e36065a 100644 --- a/src/classes/XLite/Model/Config.php +++ b/src/classes/XLite/Model/Config.php @@ -42,6 +42,16 @@ */ class Config extends \XLite\Model\Base\I18n { + /** + * Name for the Shipping category options + */ + const SHIPPING_CATEGORY = 'Shipping'; + + /** + * Prefix for the shipping values + */ + const SHIPPING_VALUES_PREFIX = 'anonymous_'; + /** * Option unique name * diff --git a/src/classes/XLite/Model/Payment/Base/Processor.php b/src/classes/XLite/Model/Payment/Base/Processor.php index fec03bbf9f..fa48ba31fd 100644 --- a/src/classes/XLite/Model/Payment/Base/Processor.php +++ b/src/classes/XLite/Model/Payment/Base/Processor.php @@ -234,6 +234,20 @@ public function isConfigured(\XLite\Model\Payment\Method $method) return true; } + /** + * Return true if payment method supports currency defined in store + * + * @param \XLite\Model\Payment\Method $method Payment method + * + * @return boolean + */ + public function isCurrencyApplicable(\XLite\Model\Payment\Method $method) + { + $currencies = $this->getAllowedCurrencies($method); + + return !$currencies || in_array(\XLite::getInstance()->getCurrency()->getCode(), $currencies); + } + /** * Check - payment processor is applicable for specified order or not * diff --git a/src/classes/XLite/Model/Payment/Method.php b/src/classes/XLite/Model/Payment/Method.php index 7f58db4b10..b65ae76337 100644 --- a/src/classes/XLite/Model/Payment/Method.php +++ b/src/classes/XLite/Model/Payment/Method.php @@ -338,7 +338,7 @@ public function getWarningNote() { $message = null; - if (!$this->getProcessor()->isConfigured($this)) { + if ($this->getProcessor() && !$this->getProcessor()->isConfigured($this)) { $message = static::t('The method is not configured and can\'t be used'); } diff --git a/src/classes/XLite/Model/Product.php b/src/classes/XLite/Model/Product.php index ad9e385bdc..9b5ee7891d 100644 --- a/src/classes/XLite/Model/Product.php +++ b/src/classes/XLite/Model/Product.php @@ -193,9 +193,20 @@ class Product extends \XLite\Model\Base\Catalog implements \XLite\Model\Base\IOr * joinColumns={@JoinColumn(name="product_id", referencedColumnName="product_id")}, * inverseJoinColumns={@JoinColumn(name="class_id", referencedColumnName="id")} * ) + * @OrderBy ({"position" = "ASC"}) */ protected $classes; + /** + * Show product attributes in a separate tab + * + * @var boolean + * + * @Column (type="boolean") + */ + protected $attrSepTab = true; + + /** * Constructor * @@ -605,4 +616,21 @@ protected function getLink($categoryId = null) return $result; } + + /** + * Return number of attributes associated with this product + * + * @return integer + */ + public function getAttributesCount() + { + $count = 0; + if ($this->getClasses()) { + foreach ($this->getClasses() as $class) { + $count += $class->getAttributesCount(); + } + } + + return $count; + } } diff --git a/src/classes/XLite/Model/ProductClass.php b/src/classes/XLite/Model/ProductClass.php index bcb21eebc9..891d1759b1 100644 --- a/src/classes/XLite/Model/ProductClass.php +++ b/src/classes/XLite/Model/ProductClass.php @@ -45,6 +45,16 @@ class ProductClass extends \XLite\Model\Base\I18n */ protected $id; + /** + * Position + * + * @var integer + * @see ____var_see____ + * @since 1.0.0 + * + * @Column (type="integer") + */ + protected $position = 0; /** * Products @@ -55,7 +65,6 @@ class ProductClass extends \XLite\Model\Base\I18n */ protected $products; - /** * Shipping methods * @@ -65,6 +74,24 @@ class ProductClass extends \XLite\Model\Base\I18n */ protected $shipping_methods; + /** + * Attributes + * + * @var \Doctrine\Common\Collections\Collection + * + * @OneToMany (targetEntity="XLite\Model\Attribute", mappedBy="product_class", cascade={"all"}) + */ + protected $attributes; + + /** + * Attribute groups + * + * @var \Doctrine\Common\Collections\Collection + * + * @OneToMany (targetEntity="XLite\Model\AttributeGroup", mappedBy="product_class", cascade={"all"}) + * @OrderBy ({"position" = "ASC"}) + */ + protected $attribute_groups; /** * Constructor @@ -77,7 +104,29 @@ public function __construct(array $data = array()) { $this->products = new \Doctrine\Common\Collections\ArrayCollection(); $this->shipping_methods = new \Doctrine\Common\Collections\ArrayCollection(); + $this->attributes = new \Doctrine\Common\Collections\ArrayCollection(); + $this->attribute_groups = new \Doctrine\Common\Collections\ArrayCollection(); parent::__construct($data); } + + /** + * Return number of products associated with this class + * + * @return integer + */ + public function getProductsCount() + { + return count($this->getProducts()); + } + + /** + * Return number of attributes associated with this class + * + * @return integer + */ + public function getAttributesCount() + { + return count($this->getAttributes()); + } } diff --git a/src/classes/XLite/Model/Profile.php b/src/classes/XLite/Model/Profile.php index 414697daa3..9b27067a44 100644 --- a/src/classes/XLite/Model/Profile.php +++ b/src/classes/XLite/Model/Profile.php @@ -257,6 +257,14 @@ class Profile extends \XLite\Model\AEntity protected $orders_count = null; + /** + * Cache for address types + * + * @var array Array of \XLite\Model\Address elements + */ + protected $addressCache = array(); + + /** * Set membership * @@ -308,7 +316,9 @@ public function getPendingMembershipId() */ public function getBillingAddress() { - return $this->getAddressByType(\XLite\Model\Address::BILLING); + return isset($this->addressCache[\XLite\Model\Address::BILLING]) + ? $this->addressCache[\XLite\Model\Address::BILLING] + : $this->getAddressByType(\XLite\Model\Address::BILLING); } /** @@ -318,7 +328,9 @@ public function getBillingAddress() */ public function getShippingAddress() { - return $this->getAddressByType(\XLite\Model\Address::SHIPPING); + return isset($this->addressCache[\XLite\Model\Address::SHIPPING]) + ? $this->addressCache[\XLite\Model\Address::SHIPPING] + : $this->getAddressByType(\XLite\Model\Address::SHIPPING); } /** @@ -479,13 +491,10 @@ public function isSameAddress() $methodName = 'get' . \XLite\Core\Converter::getInstance()->convertToCamelCase($name); - if (method_exists($billingAddress, $methodName)) { - - // Compare field values of billing and shipping addresses - if ($billingAddress->$methodName() != $shippingAddress->$methodName()) { - $result = false; - break; - } + // Compare field values of billing and shipping addresses + if ($billingAddress->$methodName() != $shippingAddress->$methodName()) { + $result = false; + break; } } } @@ -536,9 +545,11 @@ public function cloneEntity() $newBillingAddress->update(); } - if (!$this->isSameAddress() && $this->getShippingAddress()) { + $shippingAddress = $this->getShippingAddress(); + + if (!$this->isSameAddress() && $shippingAddress) { - $newShippingAddress = $this->getShippingAddress()->cloneEntity(); + $newShippingAddress = $shippingAddress->cloneEntity(); $newShippingAddress->setProfile($newProfile); $newProfile->addAddresses($newShippingAddress); $newShippingAddress->update(); @@ -578,7 +589,7 @@ public function setOrder(\XLite\Model\Order $order = null) /** * Get password hash algorhitm - * + * * @return string */ public function getPasswordAlgo() @@ -647,6 +658,8 @@ protected function getAddressByType($atype = \XLite\Model\Address::BILLING) } } + $this->addressCache[$atype] = $result; + return $result; } diff --git a/src/classes/XLite/Model/Repo/Address.php b/src/classes/XLite/Model/Repo/Address.php index 63fc7c8777..a35ce07d86 100644 --- a/src/classes/XLite/Model/Repo/Address.php +++ b/src/classes/XLite/Model/Repo/Address.php @@ -57,16 +57,6 @@ public function findAllCities() return $cities; } - /** - * Find address with same properties as specified address has - * - * @return \XLite\Model\Address - */ - public function findSameAddress($address) - { - return $address ? $this->defineFindSameAddressQuery($address)->getSingleResult() : null; - } - /** * defineFindAllCities * @@ -80,67 +70,6 @@ protected function defineFindAllCities() ->addOrderBy('a.city'); } - /** - * defineFindSameAddressQuery - * - * @return \Doctrine\ORM\QueryBuilder - */ - protected function defineFindSameAddressQuery($address) - { - $params = array(); - - $qb = $this->createQueryBuilder(); - - $qb ->innerJoin('a.profile', 'p') - ->andWhere('p.profile_id = :profile_id'); - - $params['profile_id'] = $address->getProfile()->getProfileId(); - - if ($address->getAddressId()) { - $qb->andWhere($qb->expr()->not('a.address_id = :address_id')); - $params['address_id'] = $address->getAddressId(); - } - - $fields = $address->getAddressFields(); - - foreach ($fields as $field) { - - if ('state_id' == $field) { - - if ($address->getStateId()) { - $qb->innerJoin('a.state', 's') - ->andWhere('s.state_id = :state_id'); - $params[$field] = $address->getStateId(); - - } else { - $qb->leftJoin('a.state', 's') - ->andWhere('s.state_id IS NULL'); - } - - } elseif ('country_code' == $field) { - $qb->innerJoin('a.country', 'c') - ->andWhere('c.code = :country_code'); - $params[$field] = $address->getCountryCode(); - - } else { - - $methodName = 'get' . \XLite\Core\Converter::getInstance()->convertToCamelCase($field); - - if (method_exists($address, $methodName)) { - - $qb->andWhere(sprintf('a.%s = :%s', $field, $field)); - - // Assign value from address - $params[$field] = $address->$methodName(); - } - } - } - - $qb->setParameters($params); - - return $qb; - } - /** * Get detailed foreign keys * diff --git a/src/classes/XLite/Model/Repo/AddressField.php b/src/classes/XLite/Model/Repo/AddressField.php new file mode 100644 index 0000000000..d75ca8c09f --- /dev/null +++ b/src/classes/XLite/Model/Repo/AddressField.php @@ -0,0 +1,266 @@ + + * @copyright Copyright (c) 2011-2012 Creative Development LLC . All rights reserved + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + * @link http://www.litecommerce.com/ + */ + +namespace XLite\Model\Repo; + +/** + * The "address field" model repository + * + */ +class AddressField extends \XLite\Model\Repo\Base\I18n +{ + /** + * Default 'order by' field name + * + * @var string + */ + protected $defaultOrderBy = 'position'; + + /** + * currentSearchCnd + * + * @var \XLite\Core\CommonCell + */ + protected $currentSearchCnd = null; + + + /** + * Common search + * + * @param \XLite\Core\CommonCell $cnd Search condition + * @param boolean $countOnly Return items list or only its size OPTIONAL + * + * @return \Doctrine\ORM\PersistentCollection|integer + */ + public function search(\XLite\Core\CommonCell $cnd, $countOnly = false) + { + $queryBuilder = $countOnly + ? $this->createPureQueryBuilder() + : $this->createQueryBuilder(); + + $this->currentSearchCnd = $cnd; + + foreach ($this->currentSearchCnd as $key => $value) { + $this->callSearchConditionHandler($value, $key, $queryBuilder, $countOnly); + } + + return $countOnly + ? $this->searchCount($queryBuilder) + : $this->searchResult($queryBuilder); + } + + /** + * Search count only routine. + * + * @param \Doctrine\ORM\QueryBuilder $qb Query builder routine + * + * @return \Doctrine\ORM\PersistentCollection|integer + */ + public function searchCount(\Doctrine\ORM\QueryBuilder $qb) + { + $qb->select('COUNT(DISTINCT ' . $this->getMainAlias($qb) . '.' . $this->getPrimaryKeyField() . ')'); + + return intval($qb->getSingleScalarResult()); + } + + /** + * Search result routine. + * + * @param \Doctrine\ORM\QueryBuilder $qb Query builder routine + * + * @return \Doctrine\ORM\PersistentCollection|integer + */ + public function searchResult(\Doctrine\ORM\QueryBuilder $qb) + { + return $qb->getResult(); + } + + /** + * Get all enabled address fields + * + * @return \Doctrine\ORM\PersistentCollection|integer + */ + public function findAllEnabled() + { + return $this->search(new \XLite\Core\CommonCell(array('enabled' => true))); + } + + /** + * Return address field service name value + * + * @param \XLite\Model\AddressField $field + * + * @return string + */ + public function getServiceName(\XLite\Model\AddressField $field) + { + return $field->getServiceName(); + } + + /** + * Get billing address-specified required fields + * + * @return array + */ + public function getBillingRequiredFields() + { + return $this->findRequiredFields(); + } + + /** + * Get shipping address-specified required fields + * + * @return array + */ + public function getShippingRequiredFields() + { + return $this->findRequiredFields(); + } + + /** + * Get all enabled and required address fields + * + * @return array + */ + public function findRequiredFields() + { + return array_map(array($this, 'getServiceName'), $this->search( + new \XLite\Core\CommonCell(array( + 'enabled' => true, + 'required' => true, + ) + ))); + } + + /** + * Get all enabled and required address fields + * + * @return array + */ + public function findEnabledFields() + { + return array_map(array($this, 'getServiceName'), $this->search( + new \XLite\Core\CommonCell(array( + 'enabled' => true, + ) + ))); + } + + /** + * Find one by record + * + * @param array $data Record + * @param \XLite\Model\AEntity $parent Parent model OPTIONAL + * + * @return \XLite\Model\AEntity + */ + public function findOneByRecord(array $data, \XLite\Model\AEntity $parent = null) + { + if (isset($data['serviceName'])) { + $result = $this->findOneByServiceName($data['serviceName']); + + } else { + $result = parent::findOneByRecord($data, $parent); + } + + return $result; + } + + /** + * Return list of handling search params + * + * @return array + */ + protected function getHandlingSearchParams() + { + return array( + 'enabled', + 'required', + ); + } + + /** + * Check if param can be used for search + * + * @param string $param Name of param to check + * + * @return boolean + */ + protected function isSearchParamHasHandler($param) + { + return in_array($param, $this->getHandlingSearchParams()); + } + + /** + * Call corresponded method to handle a search condition + * + * @param mixed $value Condition data + * @param string $key Condition name + * @param \Doctrine\ORM\QueryBuilder $queryBuilder Query builder to prepare + * + * @return void + */ + protected function callSearchConditionHandler($value, $key, \Doctrine\ORM\QueryBuilder $queryBuilder, $countOnly) + { + if ($this->isSearchParamHasHandler($key)) { + $this->{'prepareCnd' . ucfirst($key)}($queryBuilder, $value, $countOnly); + + } else { + // TODO - add logging here + } + } + + /** + * Prepare query builder for enabled status search + * + * @param \Doctrine\ORM\QueryBuilder $queryBuilder + * @param boolean $value + * @param boolean $countOnly + * + * @return void + */ + protected function prepareCndEnabled(\Doctrine\ORM\QueryBuilder $queryBuilder, $value, $countOnly) + { + $queryBuilder + ->andWhere($this->getMainAlias($queryBuilder) . '.enabled = :enabled_value') + ->setParameter('enabled_value', $value); + } + + /** + * Prepare query builder for required status search + * + * @param \Doctrine\ORM\QueryBuilder $queryBuilder + * @param boolean $value + * @param boolean $countOnly + * + * @return void + */ + protected function prepareCndRequired(\Doctrine\ORM\QueryBuilder $queryBuilder, $value, $countOnly) + { + $queryBuilder + ->andWhere($this->getMainAlias($queryBuilder) . '.required = :required_value') + ->setParameter('required_value', $value); + } +} diff --git a/src/classes/XLite/Model/Repo/Attribute.php b/src/classes/XLite/Model/Repo/Attribute.php new file mode 100644 index 0000000000..923bcc8693 --- /dev/null +++ b/src/classes/XLite/Model/Repo/Attribute.php @@ -0,0 +1,196 @@ + + * @copyright Copyright (c) 2011-2012 Creative Development LLC . All rights reserved + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + * @link http://www.litecommerce.com/ + */ + +namespace XLite\Model\Repo; + +/** + * Attributes repository + * + */ +class Attribute extends \XLite\Model\Repo\Base\I18n +{ + /** + * Allowable search params + */ + const SEARCH_PRODUCT = 'product'; + const SEARCH_PRODUCT_CLASS = 'productClass'; + const SEARCH_ATTRIBUTE_GROUP = 'attributeGroup'; + + // {{{ Search + + /** + * Common search + * + * @param \XLite\Core\CommonCell $cnd Search condition + * @param boolean $countOnly Return items list or only its size OPTIONAL + * + * @return \Doctrine\ORM\PersistentCollection|integer + */ + public function search(\XLite\Core\CommonCell $cnd, $countOnly = false) + { + $queryBuilder = $this->createQueryBuilder('a'); + $this->currentSearchCnd = $cnd; + + foreach ($this->currentSearchCnd as $key => $value) { + $this->callSearchConditionHandler($value, $key, $queryBuilder, $countOnly); + } + + return $countOnly + ? $this->searchCount($queryBuilder) + : $this->searchResult($queryBuilder); + } + + /** + * Search count only routine. + * + * @param \Doctrine\ORM\QueryBuilder $qb Query builder routine + * + * @return \Doctrine\ORM\PersistentCollection|integer + */ + public function searchCount(\Doctrine\ORM\QueryBuilder $qb) + { + $qb->select('COUNT(DISTINCT a.id)'); + + return intval($qb->getSingleScalarResult()); + } + + /** + * Search result routine. + * + * @param \Doctrine\ORM\QueryBuilder $qb Query builder routine + * + * @return \Doctrine\ORM\PersistentCollection|integer + */ + public function searchResult(\Doctrine\ORM\QueryBuilder $qb) + { + return $qb->addOrderBy('a.position', 'ASC')->getResult(); + } + + /** + * Call corresponded method to handle a search condition + * + * @param mixed $value Condition data + * @param string $key Condition name + * @param \Doctrine\ORM\QueryBuilder $queryBuilder Query builder to prepare + * @param boolean $countOnly Count only flag + * + * @return void + */ + protected function callSearchConditionHandler($value, $key, \Doctrine\ORM\QueryBuilder $queryBuilder, $countOnly) + { + if ($this->isSearchParamHasHandler($key)) { + $this->{'prepareCnd' . ucfirst($key)}($queryBuilder, $value, $countOnly); + } + } + + /** + * Check if param can be used for search + * + * @param string $param Name of param to check + * + * @return boolean + */ + protected function isSearchParamHasHandler($param) + { + return in_array($param, $this->getHandlingSearchParams()); + } + + /** + * Return list of handling search params + * + * @return array + */ + protected function getHandlingSearchParams() + { + return array( + static::SEARCH_PRODUCT, + static::SEARCH_PRODUCT_CLASS, + static::SEARCH_ATTRIBUTE_GROUP, + ); + } + + /** + * Prepare certain search condition + * + * @param \Doctrine\ORM\QueryBuilder $queryBuilder Query builder to prepare + * @param mixed $value Condition OPTIONAL + * + * @return void + * @see ____func_see____ + * @since 1.0.0 + */ + protected function prepareCndProduct(\Doctrine\ORM\QueryBuilder $queryBuilder, $value = null) + { + if ($value) { + $queryBuilder->linkInner('a.product_class') + ->linkInner('product_class.products') + ->andWhere('products.product_id = :productId') + ->addOrderBy('product_class.position', 'ASC') + ->setParameter('productId', $value->getProductId()); + } + } + + /** + * Prepare certain search condition + * + * @param \Doctrine\ORM\QueryBuilder $queryBuilder Query builder to prepare + * @param mixed $value Condition OPTIONAL + * + * @return void + * @see ____func_see____ + * @since 1.0.0 + */ + protected function prepareCndProductClass(\Doctrine\ORM\QueryBuilder $queryBuilder, $value = null) + { + if ($value) { + $queryBuilder->andWhere('a.product_class = :productClass') + ->setParameter('productClass', $value); + } + } + + /** + * Prepare certain search condition + * + * @param \Doctrine\ORM\QueryBuilder $queryBuilder Query builder to prepare + * @param mixed $value Condition OPTIONAL + * + * @return void + * @see ____func_see____ + * @since 1.0.0 + */ + protected function prepareCndAttributeGroup(\Doctrine\ORM\QueryBuilder $queryBuilder, $value = null) + { + if ($value) { + $queryBuilder->andWhere('a.attribute_group = :attributeGroup') + ->setParameter('attributeGroup', $value); + + } else { + $queryBuilder->andWhere('a.attribute_group is null'); + } + } + + // }}} + +} diff --git a/src/classes/XLite/Model/Repo/AttributeGroup.php b/src/classes/XLite/Model/Repo/AttributeGroup.php new file mode 100644 index 0000000000..b57edd9ef4 --- /dev/null +++ b/src/classes/XLite/Model/Repo/AttributeGroup.php @@ -0,0 +1,150 @@ + + * @copyright Copyright (c) 2011-2012 Creative Development LLC . All rights reserved + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + * @link http://www.litecommerce.com/ + */ + +namespace XLite\Model\Repo; + +/** + * Attribute groups repository + * + */ +class AttributeGroup extends \XLite\Model\Repo\Base\I18n +{ + /** + * Allowable search params + */ + const SEARCH_PRODUCT_CLASS = 'productClass'; + + // {{{ Search + + /** + * Common search + * + * @param \XLite\Core\CommonCell $cnd Search condition + * @param boolean $countOnly Return items list or only its size OPTIONAL + * + * @return \Doctrine\ORM\PersistentCollection|integer + */ + public function search(\XLite\Core\CommonCell $cnd, $countOnly = false) + { + $queryBuilder = $this->createQueryBuilder('a'); + $this->currentSearchCnd = $cnd; + + foreach ($this->currentSearchCnd as $key => $value) { + $this->callSearchConditionHandler($value, $key, $queryBuilder, $countOnly); + } + + return $countOnly + ? $this->searchCount($queryBuilder) + : $this->searchResult($queryBuilder); + } + + /** + * Search count only routine. + * + * @param \Doctrine\ORM\QueryBuilder $qb Query builder routine + * + * @return \Doctrine\ORM\PersistentCollection|integer + */ + public function searchCount(\Doctrine\ORM\QueryBuilder $qb) + { + $qb->select('COUNT(DISTINCT a.id)'); + + return intval($qb->getSingleScalarResult()); + } + + /** + * Search result routine. + * + * @param \Doctrine\ORM\QueryBuilder $qb Query builder routine + * + * @return \Doctrine\ORM\PersistentCollection|integer + */ + public function searchResult(\Doctrine\ORM\QueryBuilder $qb) + { + return $qb->addOrderBy('a.position', 'ASC')->getResult(); + } + + /** + * Call corresponded method to handle a search condition + * + * @param mixed $value Condition data + * @param string $key Condition name + * @param \Doctrine\ORM\QueryBuilder $queryBuilder Query builder to prepare + * @param boolean $countOnly Count only flag + * + * @return void + */ + protected function callSearchConditionHandler($value, $key, \Doctrine\ORM\QueryBuilder $queryBuilder, $countOnly) + { + if ($this->isSearchParamHasHandler($key)) { + $this->{'prepareCnd' . ucfirst($key)}($queryBuilder, $value, $countOnly); + } + } + + /** + * Check if param can be used for search + * + * @param string $param Name of param to check + * + * @return boolean + */ + protected function isSearchParamHasHandler($param) + { + return in_array($param, $this->getHandlingSearchParams()); + } + + /** + * Return list of handling search params + * + * @return array + */ + protected function getHandlingSearchParams() + { + return array( + static::SEARCH_PRODUCT_CLASS, + ); + } + + /** + * Prepare certain search condition + * + * @param \Doctrine\ORM\QueryBuilder $queryBuilder Query builder to prepare + * @param mixed $value Condition OPTIONAL + * + * @return void + * @see ____func_see____ + * @since 1.0.0 + */ + protected function prepareCndProductClass(\Doctrine\ORM\QueryBuilder $queryBuilder, $value = null) + { + if ($value) { + $queryBuilder->andWhere('a.product_class = :productClass') + ->setParameter('productClass', $value); + } + } + + // }}} + +} diff --git a/src/classes/XLite/Model/Repo/AttributeOption.php b/src/classes/XLite/Model/Repo/AttributeOption.php new file mode 100644 index 0000000000..56fb35b4f7 --- /dev/null +++ b/src/classes/XLite/Model/Repo/AttributeOption.php @@ -0,0 +1,190 @@ + + * @copyright Copyright (c) 2011-2012 Creative Development LLC . All rights reserved + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + * @link http://www.litecommerce.com/ + */ + +namespace XLite\Model\Repo; + +/** + * Attribute options repository + * + */ +class AttributeOption extends \XLite\Model\Repo\Base\I18n +{ + /** + * Allowable search params + */ + const SEARCH_ATTRIBUTE = 'attribute'; + const SEARCH_NAME = 'name'; + + // {{{ Search + + /** + * Common search + * + * @param \XLite\Core\CommonCell $cnd Search condition + * @param boolean $countOnly Return items list or only its size OPTIONAL + * + * @return \Doctrine\ORM\PersistentCollection|integer + */ + public function search(\XLite\Core\CommonCell $cnd, $countOnly = false) + { + $queryBuilder = $this->createQueryBuilder('a'); + $this->currentSearchCnd = $cnd; + + foreach ($this->currentSearchCnd as $key => $value) { + $this->callSearchConditionHandler($value, $key, $queryBuilder, $countOnly); + } + + return $countOnly + ? $this->searchCount($queryBuilder) + : $this->searchResult($queryBuilder); + } + + /** + * Search count only routine. + * + * @param \Doctrine\ORM\QueryBuilder $qb Query builder routine + * + * @return \Doctrine\ORM\PersistentCollection|integer + */ + public function searchCount(\Doctrine\ORM\QueryBuilder $qb) + { + $qb->select('COUNT(DISTINCT a.id)'); + + return intval($qb->getSingleScalarResult()); + } + + /** + * Search result routine. + * + * @param \Doctrine\ORM\QueryBuilder $qb Query builder routine + * + * @return \Doctrine\ORM\PersistentCollection|integer + */ + public function searchResult(\Doctrine\ORM\QueryBuilder $qb) + { + return $qb->getResult(); + } + + /** + * Find one option by name and attribute + * + * @param string $name Name + * @param \XLite\Model\Attribute $attribute Attribute + * + * @return \XLite\Model\AttributeOption + */ + public function findOneByNameAndAttribute($name, \XLite\Model\Attribute $attribute) + { + return $this->createQueryBuilder('a') + ->andWhere('translations.name = :name') + ->andWhere('a.attribute = :attribute') + ->setParameter('name', $name) + ->setParameter('attribute', $attribute) + ->setMaxResults(1) + ->getSingleResult(); + } + + /** + * Call corresponded method to handle a search condition + * + * @param mixed $value Condition data + * @param string $key Condition name + * @param \Doctrine\ORM\QueryBuilder $queryBuilder Query builder to prepare + * @param boolean $countOnly Count only flag + * + * @return void + */ + protected function callSearchConditionHandler($value, $key, \Doctrine\ORM\QueryBuilder $queryBuilder, $countOnly) + { + if ($this->isSearchParamHasHandler($key)) { + $this->{'prepareCnd' . ucfirst($key)}($queryBuilder, $value, $countOnly); + } + } + + /** + * Check if param can be used for search + * + * @param string $param Name of param to check + * + * @return boolean + */ + protected function isSearchParamHasHandler($param) + { + return in_array($param, $this->getHandlingSearchParams()); + } + + /** + * Return list of handling search params + * + * @return array + */ + protected function getHandlingSearchParams() + { + return array( + static::SEARCH_ATTRIBUTE, + static::SEARCH_NAME, + ); + } + + /** + * Prepare certain search condition + * + * @param \Doctrine\ORM\QueryBuilder $queryBuilder Query builder to prepare + * @param mixed $value Condition OPTIONAL + * + * @return void + */ + protected function prepareCndAttribute(\Doctrine\ORM\QueryBuilder $queryBuilder, $value = null) + { + if ($value) { + if (is_object($value)) { + $queryBuilder->andWhere('a.attribute = :attribute'); + + } else { + $queryBuilder->linkInner('a.attribute')->andWhere('attribute.id = :attribute'); + } + $queryBuilder->setParameter('attribute', $value); + } + } + + /** + * Prepare certain search condition + * + * @param \Doctrine\ORM\QueryBuilder $queryBuilder Query builder to prepare + * @param mixed $value Condition OPTIONAL + * + * @return void + */ + protected function prepareCndName(\Doctrine\ORM\QueryBuilder $queryBuilder, $value = null) + { + if ($value) { + $queryBuilder->andWhere('translations.name LIKE :name') + ->setParameter('name', '%' . $value . '%'); + } + } + + // }}} + +} diff --git a/src/classes/XLite/Model/Repo/AttributeValue/AAttributeValue.php b/src/classes/XLite/Model/Repo/AttributeValue/AAttributeValue.php new file mode 100644 index 0000000000..74781cf30e --- /dev/null +++ b/src/classes/XLite/Model/Repo/AttributeValue/AAttributeValue.php @@ -0,0 +1,170 @@ + + * @copyright Copyright (c) 2011-2012 Creative Development LLC . All rights reserved + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + * @link http://www.litecommerce.com/ + */ + +namespace XLite\Model\Repo\AttributeValue; + +/** + * Attribute values repository + * + */ +class AAttributeValue extends \XLite\Model\Repo\ARepo +{ + /** + * Allowable search params + */ + const SEARCH_PRODUCT = 'product'; + const SEARCH_ATTRIBUTE = 'attribute'; + + // {{{ Search + + /** + * Common search + * + * @param \XLite\Core\CommonCell $cnd Search condition + * @param boolean $countOnly Return items list or only its size OPTIONAL + * + * @return \Doctrine\ORM\PersistentCollection|integer + */ + public function search(\XLite\Core\CommonCell $cnd, $countOnly = false) + { + $queryBuilder = $this->createQueryBuilder('a'); + $this->currentSearchCnd = $cnd; + + foreach ($this->currentSearchCnd as $key => $value) { + $this->callSearchConditionHandler($value, $key, $queryBuilder, $countOnly); + } + + return $countOnly + ? $this->searchCount($queryBuilder) + : $this->searchResult($queryBuilder); + } + + /** + * Search count only routine. + * + * @param \Doctrine\ORM\QueryBuilder $qb Query builder routine + * + * @return \Doctrine\ORM\PersistentCollection|integer + */ + public function searchCount(\Doctrine\ORM\QueryBuilder $qb) + { + $qb->select('COUNT(DISTINCT a.id)'); + + return intval($qb->getSingleScalarResult()); + } + + /** + * Search result routine. + * + * @param \Doctrine\ORM\QueryBuilder $qb Query builder routine + * + * @return \Doctrine\ORM\PersistentCollection|integer + */ + public function searchResult(\Doctrine\ORM\QueryBuilder $qb) + { + return $qb->getResult(); + } + + /** + * Call corresponded method to handle a search condition + * + * @param mixed $value Condition data + * @param string $key Condition name + * @param \Doctrine\ORM\QueryBuilder $queryBuilder Query builder to prepare + * @param boolean $countOnly Count only flag + * + * @return void + */ + protected function callSearchConditionHandler($value, $key, \Doctrine\ORM\QueryBuilder $queryBuilder, $countOnly) + { + if ($this->isSearchParamHasHandler($key)) { + $this->{'prepareCnd' . ucfirst($key)}($queryBuilder, $value, $countOnly); + } + } + + /** + * Check if param can be used for search + * + * @param string $param Name of param to check + * + * @return boolean + */ + protected function isSearchParamHasHandler($param) + { + return in_array($param, $this->getHandlingSearchParams()); + } + + /** + * Return list of handling search params + * + * @return array + */ + protected function getHandlingSearchParams() + { + return array( + static::SEARCH_PRODUCT, + static::SEARCH_ATTRIBUTE, + ); + } + + /** + * Prepare certain search condition + * + * @param \Doctrine\ORM\QueryBuilder $queryBuilder Query builder to prepare + * @param mixed $value Condition OPTIONAL + * + * @return void + * @see ____func_see____ + * @since 1.0.0 + */ + protected function prepareCndProduct(\Doctrine\ORM\QueryBuilder $queryBuilder, $value = null) + { + if ($value) { + $queryBuilder->andWhere('a.product = :product') + ->setParameter('product', $value); + } + } + + /** + * Prepare certain search condition + * + * @param \Doctrine\ORM\QueryBuilder $queryBuilder Query builder to prepare + * @param mixed $value Condition OPTIONAL + * + * @return void + * @see ____func_see____ + * @since 1.0.0 + */ + protected function prepareCndAttribute(\Doctrine\ORM\QueryBuilder $queryBuilder, $value = null) + { + if ($value) { + $queryBuilder->andWhere('a.attribute = :attribute') + ->setParameter('attribute', $value); + } + } + + // }}} + +} diff --git a/src/classes/XLite/Model/Repo/AttributeValue/AttributeValueCheckbox.php b/src/classes/XLite/Model/Repo/AttributeValue/AttributeValueCheckbox.php new file mode 100644 index 0000000000..abcda37b26 --- /dev/null +++ b/src/classes/XLite/Model/Repo/AttributeValue/AttributeValueCheckbox.php @@ -0,0 +1,34 @@ + + * @copyright Copyright (c) 2011-2012 Creative Development LLC . All rights reserved + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + * @link http://www.litecommerce.com/ + */ + +namespace XLite\Model\Repo\AttributeValue; + +/** + * Attribute values repository + * + */ +class AttributeValueCheckbox extends \XLite\Model\Repo\AttributeValue\AAttributeValue +{ +} diff --git a/src/classes/XLite/Model/Repo/AttributeValue/AttributeValueNumber.php b/src/classes/XLite/Model/Repo/AttributeValue/AttributeValueNumber.php new file mode 100644 index 0000000000..14e64c63ba --- /dev/null +++ b/src/classes/XLite/Model/Repo/AttributeValue/AttributeValueNumber.php @@ -0,0 +1,34 @@ + + * @copyright Copyright (c) 2011-2012 Creative Development LLC . All rights reserved + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + * @link http://www.litecommerce.com/ + */ + +namespace XLite\Model\Repo\AttributeValue; + +/** + * Attribute values repository + * + */ +class AttributeValueNumber extends \XLite\Model\Repo\AttributeValue\AAttributeValue +{ +} diff --git a/src/classes/XLite/Model/Repo/AttributeValue/AttributeValueSelect.php b/src/classes/XLite/Model/Repo/AttributeValue/AttributeValueSelect.php new file mode 100644 index 0000000000..6ce646d9e2 --- /dev/null +++ b/src/classes/XLite/Model/Repo/AttributeValue/AttributeValueSelect.php @@ -0,0 +1,67 @@ + + * @copyright Copyright (c) 2011-2012 Creative Development LLC . All rights reserved + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + * @link http://www.litecommerce.com/ + */ + +namespace XLite\Model\Repo\AttributeValue; + +/** + * Attribute values repository + * + */ +class AttributeValueSelect extends \XLite\Model\Repo\AttributeValue\AAttributeValue +{ + /** + * Allowable search params + */ + const SEARCH_ATTRIBUTE_OPTION = 'attributeOption'; + + /** + * Return list of handling search params + * + * @return array + */ + protected function getHandlingSearchParams() + { + return array_merge(parent::getHandlingSearchParams(), array(static::SEARCH_ATTRIBUTE_OPTION)); + } + + /** + * Prepare certain search condition + * + * @param \Doctrine\ORM\QueryBuilder $queryBuilder Query builder to prepare + * @param mixed $value Condition + * + * @return void + * @see ____func_see____ + * @since 1.0.0 + */ + protected function prepareCndAttributeOption(\Doctrine\ORM\QueryBuilder $queryBuilder, $value) + { + if ($value) { + $queryBuilder->andWhere('a.attribute_option = :attributeOption') + ->setParameter('attributeOption', $value); + } + } + +} diff --git a/src/classes/XLite/Model/Repo/AttributeValue/AttributeValueText.php b/src/classes/XLite/Model/Repo/AttributeValue/AttributeValueText.php new file mode 100644 index 0000000000..c46ae10916 --- /dev/null +++ b/src/classes/XLite/Model/Repo/AttributeValue/AttributeValueText.php @@ -0,0 +1,34 @@ + + * @copyright Copyright (c) 2011-2012 Creative Development LLC . All rights reserved + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + * @link http://www.litecommerce.com/ + */ + +namespace XLite\Model\Repo\AttributeValue; + +/** + * Attribute values repository + * + */ +class AttributeValueText extends \XLite\Model\Repo\AttributeValue\AAttributeValue +{ +} diff --git a/src/classes/XLite/Model/Repo/Payment/Method.php b/src/classes/XLite/Model/Repo/Payment/Method.php index ff290f637a..e96e227c96 100644 --- a/src/classes/XLite/Model/Repo/Payment/Method.php +++ b/src/classes/XLite/Model/Repo/Payment/Method.php @@ -137,7 +137,7 @@ public function search(\XLite\Core\CommonCell $cnd, $countOnly = false) return $countOnly ? $this->searchCount($queryBuilder) - : $this->searchResult($queryBuilder); + : $this->correctSearchResult($this->searchResult($queryBuilder), $cnd->P_MODULE_ENABLED); } /** @@ -166,6 +166,35 @@ public function searchResult(\Doctrine\ORM\QueryBuilder $qb) return $qb->getResult(); } + /** + * Correct the list of payment methods + * FIXME: this should be moved to the module hooks + * + * @param array $methods List of payment methods + * @param boolean $moduleEnabledFlag True if list should contain methods of enabled modules + * + * @return array + */ + protected function correctSearchResult($methods, $moduleEnabledFlag) + { + if ($methods) { + foreach ($methods as $k => $method) { + if ($method->getModuleName()) { + $isReallyModuleEnabled = (bool)$method->getProcessor(); + if ($method->getModuleEnabled() != $isReallyModuleEnabled) { + $method->setModuleEnabled($isReallyModuleEnabled); + $this->update($method); + if ($moduleEnabledFlag && !$isReallyModuleEnabled || !$moduleEnabledFlag && $isReallyModuleEnabled) { + unset($methods[$k]); + } + } + } + } + } + + return $methods; + } + /** * Call corresponded method to handle a search condition * diff --git a/src/classes/XLite/Model/Repo/Product.php b/src/classes/XLite/Model/Repo/Product.php index 47e482d895..9f18dd135c 100644 --- a/src/classes/XLite/Model/Repo/Product.php +++ b/src/classes/XLite/Model/Repo/Product.php @@ -80,6 +80,36 @@ class Product extends \XLite\Model\Repo\Base\I18n implements \XLite\Base\IREST ); + /** + * Get the list of all clean URLS + * + * @return array + */ + public function findAllCleanURLs() + { + $result = array(); + + $products = $this->defineAllCleanURLsQuery()->getArrayResult(); + + foreach($products as $row) { + $result[$row['cleanURL']] = $row['product_id']; + } + + return $result; + } + + /** + * Define the Doctrine query + * + * @return \Doctrine\ORM\QueryBuilder + */ + protected function defineAllCleanURLsQuery() + { + return $this->createPureQueryBuilder() + ->select('p.product_id') + ->addSelect('p.cleanURL'); + } + /** * Common search * diff --git a/src/classes/XLite/Model/Repo/ProductClass.php b/src/classes/XLite/Model/Repo/ProductClass.php index 580fdd9c9b..c6f9dbb076 100644 --- a/src/classes/XLite/Model/Repo/ProductClass.php +++ b/src/classes/XLite/Model/Repo/ProductClass.php @@ -26,9 +26,107 @@ namespace XLite\Model\Repo; /** - * The product classes model repository + * Product classes repository * */ class ProductClass extends \XLite\Model\Repo\Base\I18n { + + // {{{ Search + + + /** + * Common search + * + * @param \XLite\Core\CommonCell $cnd Search condition OPTIONAL + * @param boolean $countOnly Return items list or only its size OPTIONAL + * + * @return \Doctrine\ORM\PersistentCollection|integer + */ + public function search(\XLite\Core\CommonCell $cnd = null, $countOnly = false) + { + $queryBuilder = $this->createQueryBuilder('p'); + $this->currentSearchCnd = $cnd; + + if ($this->currentSearchCnd) { + foreach ($this->currentSearchCnd as $key => $value) { + $this->callSearchConditionHandler($value, $key, $queryBuilder, $countOnly); + } + } + + return $countOnly + ? $this->searchCount($queryBuilder) + : $this->searchResult($queryBuilder); + } + + /** + * Search count only routine. + * + * @param \Doctrine\ORM\QueryBuilder $qb Query builder routine + * + * @return \Doctrine\ORM\PersistentCollection|integer + */ + public function searchCount(\Doctrine\ORM\QueryBuilder $qb) + { + $qb->select('COUNT(DISTINCT p.id)'); + + return intval($qb->getSingleScalarResult()); + } + + /** + * Search result routine. + * + * @param \Doctrine\ORM\QueryBuilder $qb Query builder routine + * + * @return \Doctrine\ORM\PersistentCollection|integer + */ + public function searchResult(\Doctrine\ORM\QueryBuilder $qb) + { + return $qb->addOrderBy('p.position', 'ASC')->getResult(); + } + + /** + * Call corresponded method to handle a search condition + * + * @param mixed $value Condition data + * @param string $key Condition name + * @param \Doctrine\ORM\QueryBuilder $queryBuilder Query builder to prepare + * @param boolean $countOnly Count only flag + * + * @return void + */ + protected function callSearchConditionHandler($value, $key, \Doctrine\ORM\QueryBuilder $queryBuilder, $countOnly) + { + if ($this->isSearchParamHasHandler($key)) { + $this->{'prepareCnd' . ucfirst($key)}($queryBuilder, $value, $countOnly); + } + } + + /** + * Check if param can be used for search + * + * @param string $param Name of param to check + * + * @return boolean + */ + protected function isSearchParamHasHandler($param) + { + return in_array($param, $this->getHandlingSearchParams()); + } + + /** + * Return list of handling search params + * + * @return array + */ + protected function getHandlingSearchParams() + { + return array( + + ); + } + + + // }}} + } diff --git a/src/classes/XLite/Model/Repo/Profile.php b/src/classes/XLite/Model/Repo/Profile.php index f80d59e98c..cbe815d571 100644 --- a/src/classes/XLite/Model/Repo/Profile.php +++ b/src/classes/XLite/Model/Repo/Profile.php @@ -318,27 +318,12 @@ protected function callSearchConditionHandler($value, $key, \Doctrine\ORM\QueryB protected function getNameSubstringSearchFields() { return array( - 'CONCAT(CONCAT(addresses.firstname, \' \'), addresses.lastname)', - 'CONCAT(CONCAT(addresses.lastname, \' \'), addresses.firstname)', + 'CONCAT(CONCAT(field_value_firstname.value, \' \'), field_value_lastname.value)', + 'CONCAT(CONCAT(field_value_lastname.value, \' \'), field_value_firstname.value)', 'p.login' ); } - /** - * List of fields to use in search by substring - * - * @return array - */ - protected function getAddressSubstringSearchFields() - { - return array( - 'addresses.street', - 'addresses.custom_state', - 'addresses.city', - 'addresses.zipcode', - ); - } - /** * prepareCndCommon * @@ -372,6 +357,45 @@ protected function prepareCndCommon(\Doctrine\ORM\QueryBuilder $queryBuilder, $v } } + /** + * Prepare field search query + * + * @param \Doctrine\ORM\QueryBuilder $queryBuilder + * @param type $fieldName + */ + protected function prepareField(\Doctrine\ORM\QueryBuilder $queryBuilder, $fieldName) + { + $queryBuilder->leftJoin( + 'addresses.addressFields', + 'field_value_' . $fieldName + )->leftJoin( + 'field_value_' . $fieldName . '.addressField', + 'field_' . $fieldName, + \Doctrine\ORM\Query\Expr\Join::WITH, + 'field_' . $fieldName . '.serviceName = :' . $fieldName + )->setParameter($fieldName, $fieldName); + } + + /** + * Prepare field search query + * + * @param \Doctrine\ORM\QueryBuilder $queryBuilder + * @param type $value + * @param type $fieldName + */ + protected function prepareCommonField(\Doctrine\ORM\QueryBuilder $queryBuilder, $value, $fieldName, $exactCmp = true) + { + if ($value) { + $this->prepareField($queryBuilder, $fieldName); + + $queryBuilder->andWhere( + $exactCmp + ? 'field_value_' . $fieldName . '.value = :field_value_' . $fieldName + : 'field_value_' . $fieldName . '.value LIKE :field_value_' . $fieldName + )->setParameter('field_value_' . $fieldName, $exactCmp ? $value : '%' . $value . '%'); + } + } + /** * prepareCndProfileId * @@ -396,13 +420,10 @@ protected function prepareCndProfileId(\Doctrine\ORM\QueryBuilder $queryBuilder, protected function prepareCndOrderId(\Doctrine\ORM\QueryBuilder $queryBuilder, $value) { if ($value) { - $queryBuilder->innerJoin('p.order', 'porder') ->andWhere('porder.order_id = :orderId') ->setParameter('orderId', $value); - } else { - $queryBuilder->andWhere('p.order is null'); } } @@ -526,6 +547,9 @@ protected function prepareCndPattern(\Doctrine\ORM\QueryBuilder $queryBuilder, $ if (!empty($value)) { $cnd = new \Doctrine\ORM\Query\Expr\Orx(); + $this->prepareField($queryBuilder, 'firstname'); + $this->prepareField($queryBuilder, 'lastname'); + foreach ($this->getNameSubstringSearchFields() as $field) { $cnd->add($field . ' LIKE :pattern'); } @@ -546,7 +570,7 @@ protected function prepareCndPattern(\Doctrine\ORM\QueryBuilder $queryBuilder, $ */ protected function prepareCndPhone(\Doctrine\ORM\QueryBuilder $queryBuilder, $value) { - $this->prepareCndCommon($queryBuilder, $value, 'phone', false, 'addresses'); + $this->prepareCommonField($queryBuilder, $value, 'name', false); } /** @@ -585,7 +609,7 @@ protected function prepareCndState(\Doctrine\ORM\QueryBuilder $queryBuilder, $va */ protected function prepareCndCustomState(\Doctrine\ORM\QueryBuilder $queryBuilder, $value) { - $this->prepareCndCommon($queryBuilder, $value, 'custom_state', true, 'addresses'); + $this->prepareCommonField($queryBuilder, $value, 'custom_state'); } /** @@ -599,15 +623,12 @@ protected function prepareCndCustomState(\Doctrine\ORM\QueryBuilder $queryBuilde protected function prepareCndAddress(\Doctrine\ORM\QueryBuilder $queryBuilder, $value) { if (!empty($value)) { - $cnd = new \Doctrine\ORM\Query\Expr\Orx(); - - foreach ($this->getAddressSubstringSearchFields() as $field) { - $cnd->add($field . ' LIKE :addressPattern'); - } - - $queryBuilder - ->andWhere($cnd) - ->setParameter('addressPattern', '%' . $value . '%'); + $queryBuilder->leftJoin( + 'addresses.addressFields', + 'field_value_address_pattern' + ) + ->andWhere('field_value_address_pattern.value LIKE :addressPattern') + ->setParameter('addressPattern', '%' . $value . '%'); } } diff --git a/src/classes/XLite/Model/Shipping/Markup.php b/src/classes/XLite/Model/Shipping/Markup.php index 6877eb705d..f2dbfc1be9 100644 --- a/src/classes/XLite/Model/Shipping/Markup.php +++ b/src/classes/XLite/Model/Shipping/Markup.php @@ -124,7 +124,7 @@ class Markup extends \XLite\Model\AEntity * * @var float * - * @Column (type="decimal", precision=4, scale=2) + * @Column (type="decimal", precision=14, scale=2) */ protected $markup_percent = 0; diff --git a/src/classes/XLite/Module/CDev/DrupalConnector/Model/Repo/Config.php b/src/classes/XLite/Module/CDev/DrupalConnector/Model/Repo/Config.php index e6a0d6aed2..6c70d1ef85 100644 --- a/src/classes/XLite/Module/CDev/DrupalConnector/Model/Repo/Config.php +++ b/src/classes/XLite/Module/CDev/DrupalConnector/Model/Repo/Config.php @@ -46,5 +46,6 @@ public function __construct(\Doctrine\ORM\EntityManager $em, \Doctrine\ORM\Mappi $this->disableOption('General', 'operation_presentation'); $this->disableOption('General', 'shop_closed'); $this->disableOption('General', 'subcategories_look'); + $this->disableOption('General', 'products_per_page'); } } diff --git a/src/classes/XLite/Module/CDev/Paypal/Main.php b/src/classes/XLite/Module/CDev/Paypal/Main.php index c3fe7e2bf7..292002f9b4 100644 --- a/src/classes/XLite/Module/CDev/Paypal/Main.php +++ b/src/classes/XLite/Module/CDev/Paypal/Main.php @@ -133,14 +133,18 @@ public static function addLog($message = null, $data = null) /** * Returns true if ExpressCheckout payment is enabled - * + * + * @param \XLite\Model\Cart $order Cart object OPTIONAL + * * @return boolean */ - public static function isExpressCheckoutEnabled() + public static function isExpressCheckoutEnabled($order = null) { static $result; - if (!isset($result)) { + $index = isset($order) ? 1 : 0; + + if (!isset($result[$index])) { $paymentMethod = \XLite\Core\Database::getRepo('XLite\Model\Payment\Method') ->findOneBy( array( @@ -148,10 +152,14 @@ public static function isExpressCheckoutEnabled() 'enabled' => true ) ); - $result = !empty($paymentMethod) && $paymentMethod->isEnabled(); + $result[$index] = !empty($paymentMethod) && $paymentMethod->isEnabled(); + + if ($order && $result[$index]) { + $result[$index] = $paymentMethod->getProcessor()->isApplicable($order, $paymentMethod); + } } - return $result; + return $result[$index]; } /** diff --git a/src/classes/XLite/Module/CDev/Paypal/Model/Payment/Processor/ExpressCheckout.php b/src/classes/XLite/Module/CDev/Paypal/Model/Payment/Processor/ExpressCheckout.php index 22d0054d7a..d48b199bbf 100644 --- a/src/classes/XLite/Module/CDev/Paypal/Model/Payment/Processor/ExpressCheckout.php +++ b/src/classes/XLite/Module/CDev/Paypal/Model/Payment/Processor/ExpressCheckout.php @@ -419,7 +419,7 @@ protected function doExpressCheckoutPayment() $status = self::PENDING; } - } elseif (preg_match('/^10486/', $responseData['RESPMSG'])) { + } elseif (preg_match('/^Generic processor error: 10486/', $responseData['RESPMSG'])) { $this->retryExpressCheckout(\XLite\Core\Session::getInstance()->ec_token); } else { diff --git a/src/classes/XLite/Module/CDev/Paypal/View/Button/ButtonsSeparator.php b/src/classes/XLite/Module/CDev/Paypal/View/Button/ButtonsSeparator.php index ecd007f0d5..0f7126f8af 100644 --- a/src/classes/XLite/Module/CDev/Paypal/View/Button/ButtonsSeparator.php +++ b/src/classes/XLite/Module/CDev/Paypal/View/Button/ButtonsSeparator.php @@ -42,8 +42,8 @@ class ButtonsSeparator extends \XLite\View\Button\ButtonsSeparator protected function isVisible() { return parent::isVisible() - && \XLite\Module\CDev\Paypal\Main::isExpressCheckoutEnabled() && $this->getCart() - && (0 < $this->getCart()->getTotal()); + && (0 < $this->getCart()->getTotal()) + && \XLite\Module\CDev\Paypal\Main::isExpressCheckoutEnabled($this->getCart()); } } diff --git a/src/classes/XLite/Module/CDev/Paypal/View/Button/ExpressCheckout.php b/src/classes/XLite/Module/CDev/Paypal/View/Button/ExpressCheckout.php index e0f49abaef..55399c08e1 100644 --- a/src/classes/XLite/Module/CDev/Paypal/View/Button/ExpressCheckout.php +++ b/src/classes/XLite/Module/CDev/Paypal/View/Button/ExpressCheckout.php @@ -64,9 +64,9 @@ protected function getTemplate() protected function isVisible() { return parent::isVisible() - && \XLite\Module\CDev\Paypal\Main::isExpressCheckoutEnabled() && $this->getCart() - && (0 < $this->getCart()->getTotal()); + && (0 < $this->getCart()->getTotal()) + && \XLite\Module\CDev\Paypal\Main::isExpressCheckoutEnabled($this->getCart()); } /** diff --git a/src/classes/XLite/Module/CDev/ProductComparison/Controller/Customer/ProductComparison.php b/src/classes/XLite/Module/CDev/ProductComparison/Controller/Customer/ProductComparison.php new file mode 100644 index 0000000000..77c79cbd38 --- /dev/null +++ b/src/classes/XLite/Module/CDev/ProductComparison/Controller/Customer/ProductComparison.php @@ -0,0 +1,92 @@ + + * @copyright Copyright (c) 2011-2012 Creative Development LLC . All rights reserved + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + * @link http://www.litecommerce.com/ + */ + +namespace XLite\Module\CDev\ProductComparison\Controller\Customer; + +/** + * Product comparison + * + */ +class ProductComparison extends \XLite\Controller\Customer\ACustomer +{ + /** + * Controller parameters + * + * @var array + */ + protected $params = array('target'); + + /** + * Product comparison delete + * + * @return void + */ + protected function doActionDelete() + { + $id = \XLite\Core\Request::getInstance()->product_id; + \XLite\Module\CDev\ProductComparison\Core\Data::getInstance()->deleteProductId($id); + \XLite\Core\Event::updateProductComparison( + array( + 'productId' => $id, + 'action' => 'delete', + 'title' => $this->getTitle() + ) + ); + } + + /** + * Product comparison add + * + * @return void + */ + protected function doActionAdd() + { + $id = \XLite\Core\Request::getInstance()->product_id; + \XLite\Module\CDev\ProductComparison\Core\Data::getInstance()->addProductId($id); + \XLite\Core\Event::updateProductComparison( + array( + 'productId' => $id, + 'action' => 'add', + 'title' => $this->getTitle() + ) + ); + } + + /** + * Get title + * + * @return string + */ + public function getTitle() + { + return static::t( + 'X products selected', + array( + 'count' => \XLite\Module\CDev\ProductComparison\Core\Data::getInstance()->getProductsCount() + ) + ); + } + +} diff --git a/src/classes/XLite/Module/CDev/ProductComparison/Core/CMSConnector.php b/src/classes/XLite/Module/CDev/ProductComparison/Core/CMSConnector.php new file mode 100644 index 0000000000..43ac0e51dd --- /dev/null +++ b/src/classes/XLite/Module/CDev/ProductComparison/Core/CMSConnector.php @@ -0,0 +1,45 @@ + + * @copyright Copyright (c) 2011-2012 Creative Development LLC . All rights reserved + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + * @link http://www.litecommerce.com/ + */ + +namespace XLite\Module\CDev\ProductComparison\Core; + +/** + * CMSConnector class + * + */ +abstract class CMSConnector extends \XLite\Core\CMSConnector implements \XLite\Base\IDecorator +{ + /** + * Constructor + * + * @return void + */ + protected function __construct() + { + parent::__construct(); + + $this->widgetsList['\XLite\Module\CDev\ProductComparison\View\ProductComparison'] = 'Product comparison list'; + } +} diff --git a/src/classes/XLite/Module/CDev/ProductComparison/Core/Data.php b/src/classes/XLite/Module/CDev/ProductComparison/Core/Data.php new file mode 100644 index 0000000000..6c9b546b4b --- /dev/null +++ b/src/classes/XLite/Module/CDev/ProductComparison/Core/Data.php @@ -0,0 +1,109 @@ + + * @copyright Copyright (c) 2011-2012 Creative Development LLC . All rights reserved + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + * @link http://www.litecommerce.com/ + */ + +namespace XLite\Module\CDev\ProductComparison\Core; + +/** + * Data class + * + */ +class Data extends \XLite\Base\Singleton +{ + /** + * Products count + * + * @var integer + */ + protected $productsCount; + + /** + * Product ids + * + * @var array + */ + protected $productIds; + + /** + * Get products count + * + * @return integer + */ + public function getProductsCount() + { + if (!isset($this->productsCount)) { + $this->productsCount = count($this->getProductIds()); + } + + return $this->productsCount; + } + + /** + * Add product id + * + * @param integer $productId Product id + * + * @return void + */ + public function addProductId($productId) + { + $ids = $this->getProductIds(); + $ids[$productId] = $productId; + $this->productIds = $ids; + \XLite\Core\Session::getInstance()->productComparisonIds = $ids; + } + + /** + * Delete product id + * + * @param integer $productId Product id + * + * @return void + */ + public function deleteProductId($productId) + { + $ids = $this->getProductIds(); + if (isset($ids[$productId])) { + unset($ids[$productId]); + } + $this->productIds = $ids; + \XLite\Core\Session::getInstance()->productComparisonIds = $ids; + } + + /** + * Get product ids + * + * @return array + */ + protected function getProductIds() + { + if (!isset($this->productIds)) { + $this->productIds = \XLite\Core\Session::getInstance()->productComparisonIds; + } + + return is_array($this->productIds) + ? $this->productIds + : array(); + } +} diff --git a/src/classes/XLite/Module/CDev/ProductComparison/Main.php b/src/classes/XLite/Module/CDev/ProductComparison/Main.php new file mode 100644 index 0000000000..b7585d71fa --- /dev/null +++ b/src/classes/XLite/Module/CDev/ProductComparison/Main.php @@ -0,0 +1,84 @@ + + * @copyright Copyright (c) 2011-2012 Creative Development LLC . All rights reserved + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + * @link http://www.litecommerce.com/ + */ + +namespace XLite\Module\CDev\ProductComparison; + +/** + * Product comparison module main class + * + */ +abstract class Main extends \XLite\Module\AModule +{ + /** + * Author name + * + * @return string + */ + public static function getAuthorName() + { + return 'Creative Development LLC'; + } + + /** + * Module version + * + * @return string + */ + public static function getMajorVersion() + { + return '1.1'; + } + + /** + * Module version + * + * @return string + */ + public static function getMinorVersion() + { + return '0'; + } + + /** + * Module name + * + * @return string + */ + public static function getModuleName() + { + return 'Product Comparison'; + } + + /** + * Module description + * + * @return string + */ + public static function getDescription() + { + return 'Allows customers to compare products.'; + } + +} diff --git a/src/classes/XLite/Module/CDev/ProductComparison/View/AddToCompare/AAddToCompare.php b/src/classes/XLite/Module/CDev/ProductComparison/View/AddToCompare/AAddToCompare.php new file mode 100644 index 0000000000..d4a7ea9bc1 --- /dev/null +++ b/src/classes/XLite/Module/CDev/ProductComparison/View/AddToCompare/AAddToCompare.php @@ -0,0 +1,123 @@ + + * @copyright Copyright (c) 2011-2012 Creative Development LLC . All rights reserved + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + * @link http://www.litecommerce.com/ + */ + +namespace XLite\Module\CDev\ProductComparison\View\AddToCompare; + +/** + * Add to compare widget + * + * + */ +abstract class AAddToCompare extends \XLite\View\Container +{ + /** + * Checkbox id + * + * @var string + */ + protected $checkboxId; + + /** + * Product id + * + * @var string + */ + protected $productId; + + /** + * Get checkbox id + * + * @param integer $productId Product id + * + * @return string + */ + public function getCheckboxId($productId) + { + if ( + !isset($this->checkboxId) + || $productId != $this->productId + ) { + $this->checkboxId = 'product' . rand() . $productId; + }; + $this->productId = $productId; + + return $this->checkboxId; + } + + /** + * Register JS files + * + * @return array + */ + public function getJSFiles() + { + $list = parent::getJSFiles(); + + $list[] = $this->getDir() . '/script.js'; + $list[] = 'modules/CDev/ProductComparison/compare/script.js'; + + return $list; + } + + /** + * Register CSS files + * + * @return array + */ + public function getCSSFiles() + { + $list = parent::getCSSFiles(); + + $list[] = $this->getDir() . '/style.css'; + $list[] = 'modules/CDev/ProductComparison/compare/style.css'; + + return $list; + } + + /** + * Return default template + * + * @return string + */ + protected function getDefaultTemplate() + { + return $this->getDir() . '/body.tpl'; + } + + /** + * Get title + * + * @return string + */ + public function getTitle() + { + return static::t( + 'X products selected', + array( + 'count' => \XLite\Module\CDev\ProductComparison\Core\Data::getInstance()->getProductsCount() + ) + ); + } +} diff --git a/src/classes/XLite/Module/CDev/ProductComparison/View/AddToCompare/Products.php b/src/classes/XLite/Module/CDev/ProductComparison/View/AddToCompare/Products.php new file mode 100644 index 0000000000..c3742f4aaf --- /dev/null +++ b/src/classes/XLite/Module/CDev/ProductComparison/View/AddToCompare/Products.php @@ -0,0 +1,45 @@ + + * @copyright Copyright (c) 2011-2012 Creative Development LLC . All rights reserved + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + * @link http://www.litecommerce.com/ + */ + +namespace XLite\Module\CDev\ProductComparison\View\AddToCompare; + +/** + * Add to compare widget + * + * + * @ListChild (list="itemsList.product.grid.customer.info", zone="customer", weight="120") + */ +class Products extends \XLite\Module\CDev\ProductComparison\View\AddToCompare\AAddToCompare +{ + /** + * Get widget templates directory + * + * @return string + */ + protected function getDir() + { + return 'modules/CDev/ProductComparison/compare/products'; + } +} diff --git a/src/classes/XLite/Module/CDev/ProductComparison/View/ProductComparison.php b/src/classes/XLite/Module/CDev/ProductComparison/View/ProductComparison.php new file mode 100644 index 0000000000..fa862cff71 --- /dev/null +++ b/src/classes/XLite/Module/CDev/ProductComparison/View/ProductComparison.php @@ -0,0 +1,99 @@ + + * @copyright Copyright (c) 2011-2012 Creative Development LLC . All rights reserved + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + * @link http://www.litecommerce.com/ + */ + +namespace XLite\Module\CDev\ProductComparison\View; + +/** + * Product comparison widget + * + * + * @ListChild (list="sidebar.first", zone="customer", weight="120") + */ +class ProductComparison extends \XLite\View\SideBarBox +{ + + /** + * Register JS files + * + * @return array + */ + public function getJSFiles() + { + $list = parent::getJSFiles(); + + $list[] = $this->getDir() . '/script.js'; + + return $list; + } + + /** + * Get title + * + * @return string + */ + protected function getHead() + { + return static::t( + 'Compare X products', + array( + 'count' => \XLite\Module\CDev\ProductComparison\Core\Data::getInstance()->getProductsCount() + ) + ); + } + + /** + * Register CSS files + * + * @return array + */ + public function getCSSFiles() + { + $list = parent::getCSSFiles(); + + $list[] = $this->getDir() . '/style.css'; + + return $list; + } + + /** + * Get widget templates directory + * + * @return string + */ + protected function getDir() + { + return 'modules/CDev/ProductComparison/sidebar'; + } + + /** + * Return default template + * + * @return string + */ + protected function getDefaultTemplate() + { + return $this->getDir() . '/body.tpl'; + } +} diff --git a/src/classes/XLite/Module/CDev/ProductComparison/install.yaml b/src/classes/XLite/Module/CDev/ProductComparison/install.yaml new file mode 100644 index 0000000000..e5fb29837f --- /dev/null +++ b/src/classes/XLite/Module/CDev/ProductComparison/install.yaml @@ -0,0 +1,12 @@ +# vim: set ts=2 sw=2 sts=2 et: +# +# Fixtures +# +# @author Creative Development LLC +# @copyright Copyright (c) 2012 Creative Development LLC . All rights reserved +# @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) +# @link http://www.litecommerce.com/ + +XLite\Model\LanguageLabel: + - { name: 'Compare X products', translations: [{ code: en, label: 'Compare {{count}} products' }] } + - { name: 'X products selected', translations: [{ code: en, label: '{{count}} products selected' }] } diff --git a/src/classes/XLite/Module/CDev/SalesTax/Logic/Order/Modifier/Tax.php b/src/classes/XLite/Module/CDev/SalesTax/Logic/Order/Modifier/Tax.php index 375f8f0e04..203b344dbd 100644 --- a/src/classes/XLite/Module/CDev/SalesTax/Logic/Order/Modifier/Tax.php +++ b/src/classes/XLite/Module/CDev/SalesTax/Logic/Order/Modifier/Tax.php @@ -67,7 +67,7 @@ public function canApply() public function calculate() { $zones = $this->getZonesList(); - $memebrship = $this->getMembership(); + $membership = $this->getMembership(); foreach ($this->getTaxes() as $tax) { $previousItems = array(); @@ -75,11 +75,12 @@ public function calculate() $cost = 0; $ratesExists = false; - foreach ($tax->getFilteredRates($zones, $memebrship) as $rate) { + foreach ($tax->getFilteredRates($zones, $membership) as $rate) { $ratesExists = true; $productClass = $rate->getProductClass() ?: null; if (!in_array($productClass, $previousClasses)) { + // Get tax cost for products in the cart with specified product class $items = $this->getTaxableItems($productClass, $previousItems); if ($items) { foreach ($items as $item) { @@ -88,6 +89,9 @@ public function calculate() $cost += $rate->calculate($items); } + // Add shipping tax cost + $cost += $rate->calculateShippingTax($this->getTaxableShippingCost($productClass)); + $previousClasses[] = $productClass; } } @@ -103,6 +107,31 @@ public function calculate() } } + /** + * Get taxable shipping cost + * + * @param \XLite\Model\ProductClass $class Product class object + * + * @return float + */ + protected function getTaxableShippingCost($class) + { + $result = 0; + + $modifier = $this->order->getModifier(\XLite\Model\Base\Surcharge::TYPE_SHIPPING, 'SHIPPING'); + + if ($modifier && $modifier->getSelectedRate() && $modifier->getSelectedRate()->getMethod()) { + + $rate = $modifier->getSelectedRate(); + + if (!$class || ($class && $rate->getMethod()->getClasses()->contains($class))) { + $result = $rate->getTaxableBasis(); + } + } + + return $result; + } + /** * Get taxes * diff --git a/src/classes/XLite/Module/CDev/SalesTax/Model/Tax/Rate.php b/src/classes/XLite/Module/CDev/SalesTax/Model/Tax/Rate.php index a141542d93..8bb447fa7f 100644 --- a/src/classes/XLite/Module/CDev/SalesTax/Model/Tax/Rate.php +++ b/src/classes/XLite/Module/CDev/SalesTax/Model/Tax/Rate.php @@ -179,7 +179,7 @@ public function setMembership(\XLite\Model\Membership $membership = null) * * @param array $items Items * - * @return array + * @return float */ public function calculate(array $items) { @@ -194,6 +194,27 @@ public function calculate(array $items) return $cost; } + /** + * Calculate shipping tax cost + * + * @param float $shippingCost Shipping cost + * + * @return float + */ + public function calculateShippingTax($shippingCost) + { + $cost = 0; + + if ($shippingCost) { + $cost = $this->getType() == static::TYPE_PERCENT + ? $shippingCost * $this->getValue() / 100 + : $this->getValue(); + } + + return $cost; + } + + /** * Get basis * diff --git a/src/classes/XLite/Upgrade/Cell.php b/src/classes/XLite/Upgrade/Cell.php index 103a1ea887..62fc1f2f21 100644 --- a/src/classes/XLite/Upgrade/Cell.php +++ b/src/classes/XLite/Upgrade/Cell.php @@ -667,8 +667,8 @@ public function upgrade($isTestMode = true, array $filesToOverwrite = array()) } /** - * Preload libraries - * + * Preload libraries + * * @return void */ protected function preloadLibraries() @@ -677,8 +677,11 @@ protected function preloadLibraries() $dirIterator = new \RecursiveDirectoryIterator(LC_DIR_LIB); $iterator = new \RecursiveIteratorIterator($dirIterator, \RecursiveIteratorIterator::CHILD_FIRST); + $logLibDir = LC_DIR_LIB . 'Log' . LC_DS; + foreach ($iterator as $filePath => $fileObject) { - if (preg_match('/\.php$/Ss', $filePath)) { + if (preg_match('/\.php$/Ss', $filePath) && (false === stristr($filePath, $logLibDir))) { + require_once $filePath; } } diff --git a/src/classes/XLite/View/AView.php b/src/classes/XLite/View/AView.php index 51fa3347f8..6d8e417de3 100644 --- a/src/classes/XLite/View/AView.php +++ b/src/classes/XLite/View/AView.php @@ -610,6 +610,7 @@ protected function getCommonFiles() 'js/jquery.mousewheel.js', $this->getValidationEngineLanguageResource(), 'js/validationEngine/jquery.validationEngine.js', + 'js/validationEngine/custom.validationEngine.js', ), static::RESOURCE_CSS => array( 'ui/jquery-ui.css', @@ -1840,4 +1841,31 @@ public function getInvoiceLogo() ); } + /** + * Return specific data for address entry. Helper. + * + * @param \XLite\Model\Address $address + * + * @return array + */ + protected function getAddressSectionData(\XLite\Model\Address $address) + { + $result = array(); + + foreach (\XLite\Core\Database::getRepo('XLite\Model\AddressField')->findAllEnabled() as $field) { + + $addressFieldValue = $address->{'get' . \Includes\Utils\Converter::convertToCamelCase($field->getViewGetterName() ?: $field->getServiceName())}(); + + if ($addressFieldValue) { + $result[$field->getServiceName()] = array( + 'css_class' => $field->getCSSFieldName(), + 'title' => $field->getName(), + 'value' => $addressFieldValue, + ); + } + } + + return $result; + } + } diff --git a/src/classes/XLite/View/Address.php b/src/classes/XLite/View/Address.php index 0ba26a8e12..99f5136178 100644 --- a/src/classes/XLite/View/Address.php +++ b/src/classes/XLite/View/Address.php @@ -56,73 +56,28 @@ class Address extends \XLite\View\Dialog * * @var array */ - protected $schema = array( - 'title' => array( - self::SCHEMA_CLASS => '\XLite\View\FormField\Select\Title', - self::SCHEMA_LABEL => 'Title', - ), - 'firstname' => array( - self::SCHEMA_CLASS => '\XLite\View\FormField\Input\Text', - self::SCHEMA_LABEL => 'First name', - self::SCHEMA_REQUIRED => true, - ), - 'lastname' => array( - self::SCHEMA_CLASS => '\XLite\View\FormField\Input\Text', - self::SCHEMA_LABEL => 'Last name', - self::SCHEMA_REQUIRED => true, - ), - 'street' => array( - self::SCHEMA_CLASS => '\XLite\View\FormField\Input\Text', - self::SCHEMA_LABEL => 'Street', - self::SCHEMA_REQUIRED => true, - ), - 'city' => array( - self::SCHEMA_CLASS => '\XLite\View\FormField\Input\Text', - self::SCHEMA_LABEL => 'City', - self::SCHEMA_REQUIRED => true, - ), - 'state_id' => array( - self::SCHEMA_CLASS => '\XLite\View\StateSelect', - self::SCHEMA_LABEL => 'State', - self::SCHEMA_REQUIRED => true, - ), - 'custom_state' => array( - self::SCHEMA_CLASS => '\XLite\View\FormField\Input\Text', - self::SCHEMA_LABEL => 'Another state', - self::SCHEMA_REQUIRED => false, - ), - 'zipcode' => array( - self::SCHEMA_CLASS => '\XLite\View\FormField\Input\Text', - self::SCHEMA_LABEL => 'Zip code', - self::SCHEMA_REQUIRED => true, - ), - 'country_code' => array( - self::SCHEMA_CLASS => '\XLite\View\CountrySelect', - self::SCHEMA_LABEL => 'Country', - self::SCHEMA_REQUIRED => true, - ), - 'phone' => array( - self::SCHEMA_CLASS => '\XLite\View\FormField\Input\Text', - self::SCHEMA_LABEL => 'Phone', - self::SCHEMA_REQUIRED => true, - ), - /* TODO: move to the shipping module where this field is required - 'address_type' => array( - self::SCHEMA_CLASS => '\XLite\View\FormField\Select\AddressType', - self::SCHEMA_LABEL => 'Address type', - self::SCHEMA_REQUIRED => true, - ), - */ - ); + protected $schema = array(); /** * getSchemaFields * - * @return void + * @return array */ public function getSchemaFields() { - return $this->schema; + $result = $this->schema; + + foreach ( + \XLite\Core\Database::getRepo('XLite\Model\AddressField')->search(new \XLite\Core\CommonCell(array('enabled' => true))) as $field + ) { + $result[$field->getServiceName()] = array( + static::SCHEMA_CLASS => $field->getSchemaClass(), + static::SCHEMA_LABEL => $field->getName(), + static::SCHEMA_REQUIRED => $field->getRequired(), + ); + } + + return $result; } /** @@ -141,23 +96,20 @@ public function getFieldValue($fieldName, $processValue = false) $methodName = 'get' . \XLite\Core\Converter::getInstance()->convertToCamelCase($fieldName); - if (method_exists($address, $methodName)) { - - // $methodName assembled from 'get' + camelized $fieldName - $result = $address->$methodName(); + // $methodName assembled from 'get' + camelized $fieldName + $result = $address->$methodName(); - if (false !== $processValue) { - switch($fieldName) { - case 'state_id': - $result = $address->getState()->getState(); - break; + if ($result && false !== $processValue) { + switch ($fieldName) { + case 'state_id': + $result = $address->getState()->getState(); + break; - case 'country_code': - $result = $address->getCountry()->getCountry(); - break; + case 'country_code': + $result = $address->getCountry()->getCountry(); + break; - default: - } + default: } } diff --git a/src/classes/XLite/View/Address/Field.php b/src/classes/XLite/View/Address/Field.php new file mode 100644 index 0000000000..f9e2271c57 --- /dev/null +++ b/src/classes/XLite/View/Address/Field.php @@ -0,0 +1,72 @@ + + * @copyright Copyright (c) 2011-2012 Creative Development LLC . All rights reserved + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + * @link http://www.litecommerce.com/ + */ + +namespace XLite\View\Address; + +/** + * Address Field form widget + * + * @ListChild (list="admin.center", zone="admin") + */ +class Field extends \XLite\View\Dialog +{ + /** + * Register CSS files + * + * @return array + */ + public function getCSSFiles() + { + $list = parent::getCSSFiles(); + + $list[] = $this->getDir() . '/style.css'; + + return $list; + } + + /** + * Return list of allowed targets + * + * @return array + */ + public static function getAllowedTargets() + { + $list = parent::getAllowedTargets(); + + $list[] = 'address_field'; + + return $list; + } + + /** + * Return templates directory name + * + * @return string + */ + protected function getDir() + { + return 'address/field'; + } +} diff --git a/src/classes/XLite/View/ProductClass/ProductClassesList.php b/src/classes/XLite/View/Address/Fields.php similarity index 65% rename from src/classes/XLite/View/ProductClass/ProductClassesList.php rename to src/classes/XLite/View/Address/Fields.php index 52cc5c7f2c..8d7499bc78 100644 --- a/src/classes/XLite/View/ProductClass/ProductClassesList.php +++ b/src/classes/XLite/View/Address/Fields.php @@ -23,32 +23,31 @@ * @link http://www.litecommerce.com/ */ -namespace XLite\View\ProductClass; +namespace XLite\View\Address; /** - * Product classes list - * + * Address fields list * * @ListChild (list="admin.center", zone="admin") */ -class ProductClassesList extends AProductClass +class Fields extends \XLite\View\Dialog { /** - * Return allowed targets + * Return list of allowed targets * * @return array */ public static function getAllowedTargets() { - $result = parent::getAllowedTargets(); + $list = parent::getAllowedTargets(); - $result[] = 'product_classes'; + $list[] = 'address_fields'; - return $result; + return $list; } /** - * Return CSS files list for widget + * Register CSS files * * @return array */ @@ -56,43 +55,30 @@ public function getCSSFiles() { $list = parent::getCSSFiles(); - $list[] = $this->getDir() . LC_DS . 'css' . LC_DS . 'style.css'; + $list[] = $this->getDir() . '/style.css'; return $list; } /** - * Return JS files list for widget + * Register JS files * - * @return void + * @return array */ public function getJSFiles() { $list = parent::getJSFiles(); - $list[] = $this->getDir() . LC_DS . 'js' . LC_DS . 'script.js'; - return $list; } - /** - * Return templates catalog + * Return templates directory name * * @return string */ protected function getDir() { - return parent::getDir() . LC_DS . 'list'; - } - - /** - * Return data - * - * @return array - */ - protected function getData() - { - return \XLite\Core\Database::getRepo('\XLite\Model\ProductClass')->findAll(); + return 'address/fields'; } } diff --git a/src/classes/XLite/View/JS/StatesList.php b/src/classes/XLite/View/Attribute.php similarity index 76% rename from src/classes/XLite/View/JS/StatesList.php rename to src/classes/XLite/View/Attribute.php index 9902630092..4d4231a115 100644 --- a/src/classes/XLite/View/JS/StatesList.php +++ b/src/classes/XLite/View/Attribute.php @@ -23,22 +23,24 @@ * @link http://www.litecommerce.com/ */ -namespace XLite\View\JS; +namespace XLite\View; /** - * \XLite\View\JS\StatesList + * Attribute page view * + * + * @ListChild (list="admin.center", zone="admin") */ -class StatesList extends \XLite\View\JS\AJS +class Attribute extends \XLite\View\AView { /** - * getCountriesStates + * Return list of allowed targets * * @return array */ - protected function getCountriesStates() + public static function getAllowedTargets() { - return \XLite\Core\Database::getRepo('XLite\Model\Country')->findCountriesStates(); + return array_merge(parent::getAllowedTargets(), array('attribute')); } /** @@ -48,6 +50,7 @@ protected function getCountriesStates() */ protected function getDefaultTemplate() { - return 'js/states_list.tpl'; + return 'attribute/body.tpl'; } -} + +} \ No newline at end of file diff --git a/src/classes/XLite/View/AttributeGroup.php b/src/classes/XLite/View/AttributeGroup.php new file mode 100644 index 0000000000..1be7467f07 --- /dev/null +++ b/src/classes/XLite/View/AttributeGroup.php @@ -0,0 +1,56 @@ + + * @copyright Copyright (c) 2011-2012 Creative Development LLC . All rights reserved + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + * @link http://www.litecommerce.com/ + */ + +namespace XLite\View; + +/** + * Attribute group page view + * + * + * @ListChild (list="admin.center", zone="admin") + */ +class AttributeGroup extends \XLite\View\AView +{ + /** + * Return list of allowed targets + * + * @return array + */ + public static function getAllowedTargets() + { + return array_merge(parent::getAllowedTargets(), array('attribute_group')); + } + + /** + * Return widget default template + * + * @return string + */ + protected function getDefaultTemplate() + { + return 'attribute_group/body.tpl'; + } + +} \ No newline at end of file diff --git a/src/classes/XLite/View/AttributeGroups.php b/src/classes/XLite/View/AttributeGroups.php new file mode 100644 index 0000000000..3c56dc53a2 --- /dev/null +++ b/src/classes/XLite/View/AttributeGroups.php @@ -0,0 +1,66 @@ + + * @copyright Copyright (c) 2011-2012 Creative Development LLC . All rights reserved + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + * @link http://www.litecommerce.com/ + */ + +namespace XLite\View; + +/** + * Attribute groups page view + * + * + * @ListChild (list="admin.center", zone="admin") + */ +class AttributeGroups extends \XLite\View\AView +{ + /** + * Return list of allowed targets + * + * @return array + */ + public static function getAllowedTargets() + { + return array_merge(parent::getAllowedTargets(), array('attribute_groups')); + } + + /** + * Return widget default template + * + * @return string + */ + protected function getDefaultTemplate() + { + return 'attribute_groups/body.tpl'; + } + + /** + * Check - search box is visible or not + * + * @return boolean + */ + protected function isSearchVisible() + { + return 0 < \XLite\Core\Database::getRepo('XLite\Model\AttributeGroup')->count(); + } + +} \ No newline at end of file diff --git a/src/classes/XLite/View/AttributeOption.php b/src/classes/XLite/View/AttributeOption.php new file mode 100644 index 0000000000..ed97f0a972 --- /dev/null +++ b/src/classes/XLite/View/AttributeOption.php @@ -0,0 +1,56 @@ + + * @copyright Copyright (c) 2011-2012 Creative Development LLC . All rights reserved + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + * @link http://www.litecommerce.com/ + */ + +namespace XLite\View; + +/** + * Attribute option page view + * + * + * @ListChild (list="admin.center", zone="admin") + */ +class AttributeOption extends \XLite\View\AView +{ + /** + * Return list of allowed targets + * + * @return array + */ + public static function getAllowedTargets() + { + return array_merge(parent::getAllowedTargets(), array('attribute_option')); + } + + /** + * Return widget default template + * + * @return string + */ + protected function getDefaultTemplate() + { + return 'attribute_option/body.tpl'; + } + +} \ No newline at end of file diff --git a/src/classes/XLite/View/AttributeOptions.php b/src/classes/XLite/View/AttributeOptions.php new file mode 100644 index 0000000000..22804d60bb --- /dev/null +++ b/src/classes/XLite/View/AttributeOptions.php @@ -0,0 +1,66 @@ + + * @copyright Copyright (c) 2011-2012 Creative Development LLC . All rights reserved + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + * @link http://www.litecommerce.com/ + */ + +namespace XLite\View; + +/** + * Attribute options page view + * + * + * @ListChild (list="admin.center", zone="admin") + */ +class AttributeOptions extends \XLite\View\AView +{ + /** + * Return list of allowed targets + * + * @return array + */ + public static function getAllowedTargets() + { + return array_merge(parent::getAllowedTargets(), array('attribute_options')); + } + + /** + * Return widget default template + * + * @return string + */ + protected function getDefaultTemplate() + { + return 'attribute_options/body.tpl'; + } + + /** + * Check - search box is visible or not + * + * @return boolean + */ + protected function isSearchVisible() + { + return 0 < \XLite\Core\Database::getRepo('XLite\Model\AttributeOption')->count(); + } + +} \ No newline at end of file diff --git a/src/classes/XLite/View/Attributes.php b/src/classes/XLite/View/Attributes.php new file mode 100644 index 0000000000..38aea8bcdd --- /dev/null +++ b/src/classes/XLite/View/Attributes.php @@ -0,0 +1,136 @@ + + * @copyright Copyright (c) 2011-2012 Creative Development LLC . All rights reserved + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + * @link http://www.litecommerce.com/ + */ + +namespace XLite\View; + +/** + * Attributes page view + * + * + * @ListChild (list="admin.center", zone="admin") + */ +class Attributes extends \XLite\View\AView +{ + /** + * Return list of allowed targets + * + * @return array + */ + public static function getAllowedTargets() + { + return array_merge(parent::getAllowedTargets(), array('attributes')); + } + + /** + * Get a list of CSS files required to display the widget properly + * + * @return array + */ + public function getCSSFiles() + { + $list = parent::getCSSFiles(); + + $list[] = 'attributes/style.css'; + $list[] = 'form_field/inline/style.css'; + $list[] = 'form_field/inline/input/text/position/move.css'; + $list[] = 'form_field/inline/input/text/position.css'; + $list[] = 'form_field/form_field.css'; + $list[] = 'form_field/input/text/position.css'; + $list[] = 'items_list/items_list.css'; + $list[] = 'items_list/model/style.css'; + $list[] = 'items_list/model/table/style.css'; + $list[] = 'form_field/inline/input/text.css'; + + return $list; + } + + /** + * Get a list of JavaScript files required to display the widget properly + * + * @return array + */ + public function getJSFiles() + { + $list = parent::getJSFiles(); + + $list[] = 'form_field/inline/controller.js'; + $list[] = 'form_field/inline/input/text/position/move.js'; + $list[] = 'form_field/js/text.js'; + $list[] = 'form_field/input/text/integer.js'; + $list[] = 'button/js/remove.js'; + $list[] = 'items_list/items_list.js'; + $list[] = 'items_list/model/table/controller.js'; + $list[] = 'attributes/script.js'; + $list[] = 'form_field/inline/input/text.js'; + + return $list; + } + + /** + * Register files from common repository + * + * @return array + */ + public function getCommonFiles() + { + $list = parent::getCommonFiles(); + $list['js'][] = 'js/jquery.blockUI.js'; + $list['js'][] = 'js/jquery.textarea-expander.js'; + + return $list; + } + + /** + * Return widget default template + * + * @return string + */ + protected function getDefaultTemplate() + { + return 'attributes/body.tpl'; + } + + /** + * Check - search box is visible or not + * + * @return boolean + */ + protected function isSearchVisible() + { + return 0 < \XLite\Core\Database::getRepo('XLite\Model\Attribute')->count(); + } + + /** + * Check - list box is visible or not + * + * @return boolean + */ + protected function isListVisible() + { + return $this->getProductClass()->getAttributesCount() + || $this->getProductClass()->getAttributeGroups()->count(); + } + +} diff --git a/src/classes/XLite/View/Checkout.php b/src/classes/XLite/View/Checkout.php index c747fd27ae..571addb1e2 100644 --- a/src/classes/XLite/View/Checkout.php +++ b/src/classes/XLite/View/Checkout.php @@ -53,6 +53,19 @@ public static function getAllowedTargets() return $result; } + /** + * Get a list of CSS files required to display the widget properly + * + * @return array + */ + public function getCSSFiles() + { + $list = parent::getCSSFiles(); + $list[] = 'checkout/checkout.css'; + + return $list; + } + /** * Get a list of JS files required to display the widget properly * FIXME - decompose these files diff --git a/src/classes/XLite/View/Checkout/AAddressBlock.php b/src/classes/XLite/View/Checkout/AAddressBlock.php new file mode 100644 index 0000000000..fbfdee3ab2 --- /dev/null +++ b/src/classes/XLite/View/Checkout/AAddressBlock.php @@ -0,0 +1,106 @@ + + * @copyright Copyright (c) 2011-2012 Creative Development LLC . All rights reserved + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + * @link http://www.litecommerce.com/ + */ + +namespace XLite\View\Checkout; + +/** + * Address block info + * + */ +abstract class AAddressBlock extends \XLite\View\AView +{ + /** + * Get address info model + * + * @return \XLite\Model\Address + */ + abstract protected function getAddressInfo(); + + /** + * getFieldValue + * + * @param string $fieldName Field name + * @param boolean $processValue Process value flag OPTIONAL + * + * @return string + */ + public function getFieldValue($fieldName, $processValue = false) + { + $result = ''; + + $address = $this->getAddressInfo(); + + if (isset($address)) { + + $methodName = 'get' . \XLite\Core\Converter::getInstance()->convertToCamelCase($fieldName); + + // $methodName assembled from 'get' + camelized $fieldName + $result = $address->$methodName(); + + if ($result && false !== $processValue) { + + switch ($fieldName) { + + case 'state_id': + $result = $address->getState()->getState(); + break; + + case 'country_code': + $result = $address->getCountry()->getCountry(); + break; + + default: + + } + } + } else { + + $result = \XLite\Model\Address::getDefaultFieldPlainValue($fieldName); + } + + return $result; + } + + /** + * Add CSS classes to the list of attributes + * + * @param string $fieldName Field service name + * @param array $fieldData Array of field properties (see getAddressFields() for the details) + * + * @return array + */ + public function getFieldAttributes($fieldName, $fieldData) + { + $classes = array('field-' . $fieldName); + + if ($fieldData[\XLite\View\Model\Address\Address::SCHEMA_REQUIRED]) { + $classes[] = 'field-required'; + } + + return array( + 'class' => implode(' ', $classes), + ); + } +} diff --git a/src/classes/XLite/View/Checkout/BillingAddress.php b/src/classes/XLite/View/Checkout/BillingAddress.php index b0b2f8cf27..d173c40991 100644 --- a/src/classes/XLite/View/Checkout/BillingAddress.php +++ b/src/classes/XLite/View/Checkout/BillingAddress.php @@ -29,7 +29,7 @@ * Billing address block * */ -class BillingAddress extends \XLite\View\AView +class BillingAddress extends \XLite\View\Checkout\AAddressBlock { /** * Modifier (cache) @@ -109,4 +109,14 @@ protected function getModifier() return $this->modifier; } + + /** + * Get address info model + * + * @return \XLite\Model\Address + */ + protected function getAddressInfo() + { + return $this->getSameAddress(); + } } diff --git a/src/classes/XLite/View/Checkout/ShippingAddress.php b/src/classes/XLite/View/Checkout/ShippingAddress.php index 118e2a07ea..5fff0348ae 100644 --- a/src/classes/XLite/View/Checkout/ShippingAddress.php +++ b/src/classes/XLite/View/Checkout/ShippingAddress.php @@ -29,14 +29,14 @@ * Shipping address block * */ -class ShippingAddress extends \XLite\View\AView +class ShippingAddress extends \XLite\View\Checkout\AAddressBlock { /** * Get shipping address * * @return \XLite\Model\Address */ - public function getAddress() + public function getShippingAddress() { $address = null; @@ -59,6 +59,39 @@ public function getAddress() return $address; } + /** + * Get an array of address fields + * + * @return array + */ + public function getAddressFields() + { + $result = array(); + + foreach (\XLite\Core\Database::getRepo('XLite\Model\AddressField')->findAllEnabled() as $field) { + $result[$field->getServiceName()] = array( + \XLite\View\Model\Address\Address::SCHEMA_CLASS => $field->getSchemaClass(), + \XLite\View\Model\Address\Address::SCHEMA_LABEL => $field->getName(), + \XLite\View\Model\Address\Address::SCHEMA_REQUIRED => $field->getRequired(), + \XLite\View\Model\Address\Address::SCHEMA_MODEL_ATTRIBUTES => array( + \XLite\View\FormField\Input\Base\String::PARAM_MAX_LENGTH => 'length', + ), + \XLite\View\FormField\AFormField::PARAM_WRAPPER_CLASS => 'address-' . $field->getServiceName(), + ); + } + + return $result; + } + + /** + * Get address info model + * + * @return \XLite\Model\Address + */ + protected function getAddressInfo() + { + return $this->getShippingAddress(); + } /** * Return widget default template diff --git a/src/classes/XLite/View/Checkout/Steps.php b/src/classes/XLite/View/Checkout/Steps.php index 2e3614bc18..dcbfc97c9a 100644 --- a/src/classes/XLite/View/Checkout/Steps.php +++ b/src/classes/XLite/View/Checkout/Steps.php @@ -54,6 +54,20 @@ class Steps extends \XLite\View\AView */ protected $currentStep; + + /** + * Register JS files + * + * @return array + */ + public function getJSFiles() + { + $list = parent::getJSFiles(); + + $list[] = 'form_field/select_country.js'; + + return $list; + } /** * Get steps diff --git a/src/classes/XLite/View/CountrySelect.php b/src/classes/XLite/View/CountrySelect.php index e971c23128..da01be03f1 100644 --- a/src/classes/XLite/View/CountrySelect.php +++ b/src/classes/XLite/View/CountrySelect.php @@ -42,6 +42,7 @@ class CountrySelect extends \XLite\View\FormField const PARAM_COUNTRY = 'country'; const PARAM_FIELD_ID = 'fieldId'; const PARAM_CLASS_NAME = 'className'; + const PARAM_SELECT_ONE = 'selectOne'; const PARAM_ALLOW_LABEL_COUNTRY = 'allowLabelCountry'; @@ -65,12 +66,13 @@ protected function defineWidgetParams() parent::defineWidgetParams(); $this->widgetParams += array( - self::PARAM_ALL => new \XLite\Model\WidgetParam\Bool('All', false), - self::PARAM_FIELD_NAME => new \XLite\Model\WidgetParam\String('Field name', ''), - self::PARAM_FIELD_ID => new \XLite\Model\WidgetParam\String('Field ID', ''), - self::PARAM_CLASS_NAME => new \XLite\Model\WidgetParam\String('Class name', ''), - self::PARAM_COUNTRY => new \XLite\Model\WidgetParam\String('Value', ''), - self::PARAM_ALLOW_LABEL_COUNTRY => new \XLite\Model\WidgetParam\Bool('Allow label-based country selector', false), + static::PARAM_ALL => new \XLite\Model\WidgetParam\Bool('All', false), + static::PARAM_FIELD_NAME => new \XLite\Model\WidgetParam\String('Field name', ''), + static::PARAM_FIELD_ID => new \XLite\Model\WidgetParam\String('Field ID', ''), + static::PARAM_CLASS_NAME => new \XLite\Model\WidgetParam\String('Class name', ''), + static::PARAM_COUNTRY => new \XLite\Model\WidgetParam\String('Value', ''), + static::PARAM_SELECT_ONE => new \XLite\Model\WidgetParam\Bool('Select one value', false), + static::PARAM_ALLOW_LABEL_COUNTRY => new \XLite\Model\WidgetParam\Bool('Allow label-based country selector', false), ); } @@ -81,17 +83,17 @@ protected function defineWidgetParams() */ protected function isEnabledOnly() { - return !$this->getParam(self::PARAM_ALL); + return !$this->getParam(static::PARAM_ALL); } /** - * Get selected value - * + * Get selected value + * * @return string */ protected function getSelectedValue() { - return $this->getParam(self::PARAM_COUNTRY); + return $this->getParam(static::PARAM_COUNTRY); } /** @@ -103,7 +105,7 @@ protected function getSelectedValue() */ protected function isSelectedCountry($countryCode) { - $country = $this->getParam(self::PARAM_COUNTRY); + $country = $this->getParam(static::PARAM_COUNTRY); if ('' == $country) { $country = \XLite\Core\Config::getInstance()->General->default_country; @@ -126,18 +128,18 @@ protected function getCountries() /** * Check - country selector is label-based - * + * * @return boolean */ protected function isLabelBasedSelector() { - return $this->getParam(self::PARAM_ALLOW_LABEL_COUNTRY) + return $this->getParam(static::PARAM_ALLOW_LABEL_COUNTRY) && 1 == count($this->getCountries()); } /** - * Get one country - * + * Get one country + * * @return \XLite\Model\Country */ protected function getOneCountry() @@ -146,4 +148,14 @@ protected function getOneCountry() return reset($list); } + + /** + * Return if the select one value is available + * + * @return boolean + */ + protected function hasSelectOne() + { + return $this->getParam(static::PARAM_SELECT_ONE); + } } diff --git a/src/classes/XLite/View/Form/AddressField.php b/src/classes/XLite/View/Form/AddressField.php new file mode 100644 index 0000000000..0ff46f70d2 --- /dev/null +++ b/src/classes/XLite/View/Form/AddressField.php @@ -0,0 +1,88 @@ + + * @copyright Copyright (c) 2011-2012 Creative Development LLC . All rights reserved + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + * @link http://www.litecommerce.com/ + */ + +namespace XLite\View\Form; + +/** + * Address field form + * + */ +class AddressField extends \XLite\View\Form\AForm +{ + /** + * Register CSS files + * + * @return array + */ + public function getCSSFiles() + { + $list = parent::getCSSFiles(); + + return $list; + } + + /** + * Return default value for the "target" parameter + * + * @return string + */ + protected function getDefaultTarget() + { + return 'address_field'; + } + + /** + * Return default value for the "action" parameter + * + * @return string + */ + protected function getDefaultAction() + { + return 'update'; + } + + /** + * Get default class name + * + * @return string + */ + protected function getDefaultClassName() + { + return trim(parent::getDefaultClassName() . ' validationEngine role'); + } + + /** + * Return list of the form default parameters + * + * @return array + */ + protected function getDefaultParams() + { + return array( + 'id' => \XLite\Core\Request::getInstance()->id, + ); + } +} + diff --git a/src/classes/XLite/View/Form/Checkout/UpdateProfile.php b/src/classes/XLite/View/Form/Checkout/UpdateProfile.php index 7cc587478d..c74186f9ba 100644 --- a/src/classes/XLite/View/Form/Checkout/UpdateProfile.php +++ b/src/classes/XLite/View/Form/Checkout/UpdateProfile.php @@ -78,12 +78,26 @@ protected function getValidator() new \XLite\Core\Validator\HashArray, \XLite\Core\Validator\Pair\APair::SOFT ); - $shippingAddress->addPair('name', new \XLite\Core\Validator\String($nonEmpty), $mode); - $shippingAddress->addPair('street', new \XLite\Core\Validator\String($nonEmpty), $mode); - $shippingAddress->addPair('city', new \XLite\Core\Validator\String($nonEmpty), $mode); - $shippingAddress->addPair('zipcode', new \XLite\Core\Validator\String(true)); - $shippingAddress->addPair('phone', new \XLite\Core\Validator\String(), $mode); - $shippingAddress->addPair(new \XLite\Core\Validator\Pair\CountryState()); + + $addressFields = \XLite::getController()->getAddressFields(); + + $isCountryStateAdded = false; + + foreach ($addressFields as $fieldName => $fieldData) { + + if (!$isCountryStateAdded && in_array($fieldName, array('country', 'state'))) { + $shippingAddress->addPair(new \XLite\Core\Validator\Pair\CountryState()); + $isCountryStateAdded = true; + + } else { + $shippingAddress->addPair( + $fieldName, + new \XLite\Core\Validator\String($nonEmpty && $fieldData[\XLite\View\Model\Address\Address::SCHEMA_REQUIRED]), + $mode + ); + } + } + $shippingAddress->addPair( 'save_as_new', new \XLite\Core\Validator\String\Switcher(), @@ -97,12 +111,24 @@ protected function getValidator() new \XLite\Core\Validator\HashArray, \XLite\Core\Validator\Pair\APair::SOFT ); - $billingAddress->addPair('name', new \XLite\Core\Validator\String(true)); - $billingAddress->addPair('street', new \XLite\Core\Validator\String(true)); - $billingAddress->addPair('city', new \XLite\Core\Validator\String(true)); - $billingAddress->addPair('zipcode', new \XLite\Core\Validator\String(true)); - $billingAddress->addPair('phone', new \XLite\Core\Validator\String()); - $billingAddress->addPair(new \XLite\Core\Validator\Pair\CountryState()); + + $isCountryStateAdded = false; + + foreach ($addressFields as $fieldName => $fieldData) { + + if (!$isCountryStateAdded && in_array($fieldName, array('country', 'state'))) { + $billingAddress->addPair(new \XLite\Core\Validator\Pair\CountryState()); + $isCountryStateAdded = true; + + } else { + $billingAddress->addPair( + $fieldName, + new \XLite\Core\Validator\String($nonEmpty && $fieldData[\XLite\View\Model\Address\Address::SCHEMA_REQUIRED]), + $mode + ); + } + } + $billingAddress->addPair( 'save_as_new', new \XLite\Core\Validator\String\Switcher(), diff --git a/src/classes/XLite/View/Form/ItemsList/AddressField/Main.php b/src/classes/XLite/View/Form/ItemsList/AddressField/Main.php new file mode 100644 index 0000000000..0ae03f02ef --- /dev/null +++ b/src/classes/XLite/View/Form/ItemsList/AddressField/Main.php @@ -0,0 +1,43 @@ + + * @copyright Copyright (c) 2011-2012 Creative Development LLC . All rights reserved + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + * @link http://www.litecommerce.com/ + */ + +namespace XLite\View\Form\ItemsList\AddressField; + +/** + * Main address fields items list form + * + */ +class Main extends \XLite\View\Form\ItemsList\AItemsList +{ + /** + * getDefaultTarget + * + * @return string + */ + protected function getDefaultTarget() + { + return 'address_fields'; + } +} diff --git a/src/classes/XLite/View/Form/ItemsList/Attribute/Table.php b/src/classes/XLite/View/Form/ItemsList/Attribute/Table.php new file mode 100644 index 0000000000..445d6fe909 --- /dev/null +++ b/src/classes/XLite/View/Form/ItemsList/Attribute/Table.php @@ -0,0 +1,66 @@ + + * @copyright Copyright (c) 2011-2012 Creative Development LLC . All rights reserved + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + * @link http://www.litecommerce.com/ + */ + +namespace XLite\View\Form\ItemsList\Attribute; + +/** + * Attributes list table form + * + */ +class Table extends \XLite\View\Form\ItemsList\AItemsList +{ + /** + * Return default value for the "target" parameter + * + * @return string + */ + protected function getDefaultTarget() + { + return 'attributes'; + } + + /** + * Return default value for the "action" parameter + * + * @return string + */ + protected function getDefaultAction() + { + return 'update'; + } + + /** + * Return list of the form default parameters + * + * @return array + */ + protected function getDefaultParams() + { + return array( + 'product_class_id' => intval(\XLite\Core\Request::getInstance()->product_class_id), + ); + } + +} diff --git a/src/classes/XLite/View/Form/ItemsList/AttributeGroup/Table.php b/src/classes/XLite/View/Form/ItemsList/AttributeGroup/Table.php new file mode 100644 index 0000000000..2aa3444dbf --- /dev/null +++ b/src/classes/XLite/View/Form/ItemsList/AttributeGroup/Table.php @@ -0,0 +1,66 @@ + + * @copyright Copyright (c) 2011-2012 Creative Development LLC . All rights reserved + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + * @link http://www.litecommerce.com/ + */ + +namespace XLite\View\Form\ItemsList\AttributeGroup; + +/** + * Attribute groups list table form + * + */ +class Table extends \XLite\View\Form\ItemsList\AItemsList +{ + /** + * Return default value for the "target" parameter + * + * @return string + */ + protected function getDefaultTarget() + { + return 'attribute_groups'; + } + + /** + * Return default value for the "action" parameter + * + * @return string + */ + protected function getDefaultAction() + { + return 'update'; + } + + /** + * Return list of the form default parameters + * + * @return array + */ + protected function getDefaultParams() + { + return array( + 'product_class_id' => intval(\XLite\Core\Request::getInstance()->product_class_id), + ); + } + +} diff --git a/src/classes/XLite/View/Form/ItemsList/AttributeOption/Table.php b/src/classes/XLite/View/Form/ItemsList/AttributeOption/Table.php new file mode 100644 index 0000000000..312bb3e438 --- /dev/null +++ b/src/classes/XLite/View/Form/ItemsList/AttributeOption/Table.php @@ -0,0 +1,53 @@ + + * @copyright Copyright (c) 2011-2012 Creative Development LLC . All rights reserved + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + * @link http://www.litecommerce.com/ + */ + +namespace XLite\View\Form\ItemsList\AttributeOption; + +/** + * Attribute options list table form + * + */ +class Table extends \XLite\View\Form\ItemsList\AItemsList +{ + /** + * Return default value for the "target" parameter + * + * @return string + */ + protected function getDefaultTarget() + { + return 'attribute_options'; + } + + /** + * Return default value for the "action" parameter + * + * @return string + */ + protected function getDefaultAction() + { + return 'update'; + } +} \ No newline at end of file diff --git a/src/classes/XLite/View/Form/ItemsList/ProductClass/Table.php b/src/classes/XLite/View/Form/ItemsList/ProductClass/Table.php new file mode 100644 index 0000000000..1543aac31e --- /dev/null +++ b/src/classes/XLite/View/Form/ItemsList/ProductClass/Table.php @@ -0,0 +1,53 @@ + + * @copyright Copyright (c) 2011-2012 Creative Development LLC . All rights reserved + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + * @link http://www.litecommerce.com/ + */ + +namespace XLite\View\Form\ItemsList\ProductClass; + +/** + * Product classes list table form + * + */ +class Table extends \XLite\View\Form\ItemsList\AItemsList +{ + /** + * Return default value for the "target" parameter + * + * @return string + */ + protected function getDefaultTarget() + { + return 'product_classes'; + } + + /** + * Return default value for the "action" parameter + * + * @return string + */ + protected function getDefaultAction() + { + return 'update'; + } +} \ No newline at end of file diff --git a/src/classes/XLite/View/Form/Model/Attribute.php b/src/classes/XLite/View/Form/Model/Attribute.php new file mode 100644 index 0000000000..da64f1c820 --- /dev/null +++ b/src/classes/XLite/View/Form/Model/Attribute.php @@ -0,0 +1,91 @@ + + * @copyright Copyright (c) 2011-2012 Creative Development LLC . All rights reserved + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + * @link http://www.litecommerce.com/ + */ + +namespace XLite\View\Form\Model; + +/** + * Attributes list search form + * + */ +class Attribute extends \XLite\View\Form\AForm +{ + /** + * Register CSS files + * + * @return array + */ + public function getCSSFiles() + { + $list = parent::getCSSFiles(); + + $list[] = 'attribute/style.css'; + + return $list; + } + + /** + * Return default value for the "target" parameter + * + * @return string + */ + protected function getDefaultTarget() + { + return 'attribute'; + } + + /** + * Return default value for the "action" parameter + * + * @return string + */ + protected function getDefaultAction() + { + return 'update'; + } + + /** + * Get default class name + * + * @return string + */ + protected function getDefaultClassName() + { + return trim(parent::getDefaultClassName() . ' validationEngine attribute'); + } + + /** + * Return list of the form default parameters + * + * @return array + */ + protected function getDefaultParams() + { + return array( + 'id' => \XLite\Core\Request::getInstance()->id, + 'product_class_id' => \XLite\Core\Request::getInstance()->product_class_id, + ); + } + +} diff --git a/src/classes/XLite/View/Form/Model/AttributeGroup.php b/src/classes/XLite/View/Form/Model/AttributeGroup.php new file mode 100644 index 0000000000..8a821e1082 --- /dev/null +++ b/src/classes/XLite/View/Form/Model/AttributeGroup.php @@ -0,0 +1,90 @@ + + * @copyright Copyright (c) 2011-2012 Creative Development LLC . All rights reserved + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + * @link http://www.litecommerce.com/ + */ + +namespace XLite\View\Form\Model; + +/** + * Attribute groups list search form + * + */ +class AttributeGroup extends \XLite\View\Form\AForm +{ + /** + * Register CSS files + * + * @return array + */ + public function getCSSFiles() + { + $list = parent::getCSSFiles(); + + $list[] = 'attribute_group/style.css'; + + return $list; + } + + /** + * Return default value for the "target" parameter + * + * @return string + */ + protected function getDefaultTarget() + { + return 'attribute_group'; + } + + /** + * Return default value for the "action" parameter + * + * @return string + */ + protected function getDefaultAction() + { + return 'update'; + } + + /** + * Get default class name + * + * @return string + */ + protected function getDefaultClassName() + { + return trim(parent::getDefaultClassName() . ' validationEngine attribute-group'); + } + + /** + * Return list of the form default parameters + * + * @return array + */ + protected function getDefaultParams() + { + return array( + 'id' => \XLite\Core\Request::getInstance()->id, + ); + } + +} \ No newline at end of file diff --git a/src/classes/XLite/View/Form/Model/AttributeOption.php b/src/classes/XLite/View/Form/Model/AttributeOption.php new file mode 100644 index 0000000000..28642ca745 --- /dev/null +++ b/src/classes/XLite/View/Form/Model/AttributeOption.php @@ -0,0 +1,90 @@ + + * @copyright Copyright (c) 2011-2012 Creative Development LLC . All rights reserved + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + * @link http://www.litecommerce.com/ + */ + +namespace XLite\View\Form\Model; + +/** + * Attribute options list search form + * + */ +class AttributeOption extends \XLite\View\Form\AForm +{ + /** + * Register CSS files + * + * @return array + */ + public function getCSSFiles() + { + $list = parent::getCSSFiles(); + + $list[] = 'attribute_option/style.css'; + + return $list; + } + + /** + * Return default value for the "target" parameter + * + * @return string + */ + protected function getDefaultTarget() + { + return 'attribute_option'; + } + + /** + * Return default value for the "action" parameter + * + * @return string + */ + protected function getDefaultAction() + { + return 'update'; + } + + /** + * Get default class name + * + * @return string + */ + protected function getDefaultClassName() + { + return trim(parent::getDefaultClassName() . ' validationEngine attribute-option'); + } + + /** + * Return list of the form default parameters + * + * @return array + */ + protected function getDefaultParams() + { + return array( + 'id' => \XLite\Core\Request::getInstance()->id, + ); + } + +} \ No newline at end of file diff --git a/src/classes/XLite/View/Form/Model/ProductClass.php b/src/classes/XLite/View/Form/Model/ProductClass.php new file mode 100644 index 0000000000..2f83ce9b9f --- /dev/null +++ b/src/classes/XLite/View/Form/Model/ProductClass.php @@ -0,0 +1,90 @@ + + * @copyright Copyright (c) 2011-2012 Creative Development LLC . All rights reserved + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + * @link http://www.litecommerce.com/ + */ + +namespace XLite\View\Form\Model; + +/** + * Product classes list search form + * + */ +class ProductClass extends \XLite\View\Form\AForm +{ + /** + * Register CSS files + * + * @return array + */ + public function getCSSFiles() + { + $list = parent::getCSSFiles(); + + $list[] = 'product_class/style.css'; + + return $list; + } + + /** + * Return default value for the "target" parameter + * + * @return string + */ + protected function getDefaultTarget() + { + return 'product_class'; + } + + /** + * Return default value for the "action" parameter + * + * @return string + */ + protected function getDefaultAction() + { + return 'update'; + } + + /** + * Get default class name + * + * @return string + */ + protected function getDefaultClassName() + { + return trim(parent::getDefaultClassName() . ' validationEngine product-class'); + } + + /** + * Return list of the form default parameters + * + * @return array + */ + protected function getDefaultParams() + { + return array( + 'id' => \XLite\Core\Request::getInstance()->id, + ); + } + +} \ No newline at end of file diff --git a/src/classes/XLite/View/Form/Product/Modify/Attributes.php b/src/classes/XLite/View/Form/Product/Modify/Attributes.php new file mode 100644 index 0000000000..a59648a6c4 --- /dev/null +++ b/src/classes/XLite/View/Form/Product/Modify/Attributes.php @@ -0,0 +1,43 @@ + + * @copyright Copyright (c) 2011-2012 Creative Development LLC . All rights reserved + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + * @link http://www.litecommerce.com/ + */ + +namespace XLite\View\Form\Product\Modify; + +/** + * Attributes + * + */ +class Attributes extends \XLite\View\Form\Product\Modify\Base\Single +{ + /** + * Get default action + * + * @return string + */ + protected function getDefaultAction() + { + return 'update_attributes'; + } +} diff --git a/src/classes/XLite/View/FormField/AFormField.php b/src/classes/XLite/View/FormField/AFormField.php index aa47ab9592..53537e536e 100644 --- a/src/classes/XLite/View/FormField/AFormField.php +++ b/src/classes/XLite/View/FormField/AFormField.php @@ -50,14 +50,15 @@ abstract class AFormField extends \XLite\View\AView /** * Available field types */ - const FIELD_TYPE_LABEL = 'label'; - const FIELD_TYPE_TEXT = 'text'; - const FIELD_TYPE_PASSWORD = 'password'; - const FIELD_TYPE_SELECT = 'select'; - const FIELD_TYPE_CHECKBOX = 'checkbox'; - const FIELD_TYPE_RADIO = 'radio'; - const FIELD_TYPE_TEXTAREA = 'textarea'; - const FIELD_TYPE_SEPARATOR = 'separator'; + const FIELD_TYPE_LABEL = 'label'; + const FIELD_TYPE_TEXT = 'text'; + const FIELD_TYPE_PASSWORD = 'password'; + const FIELD_TYPE_SELECT = 'select'; + const FIELD_TYPE_CHECKBOX = 'checkbox'; + const FIELD_TYPE_RADIO = 'radio'; + const FIELD_TYPE_TEXTAREA = 'textarea'; + const FIELD_TYPE_SEPARATOR = 'separator'; + const FIELD_TYPE_ITEMS_LIST = 'itemsList'; /** * name @@ -81,8 +82,8 @@ abstract class AFormField extends \XLite\View\AView protected $isAllowedForCustomer = true; /** - * Error message - * + * Error message + * * @var string */ protected $errorMessage; @@ -271,12 +272,12 @@ protected function getValidityFlag() /** * Sanitize value - * + * * @return mixed */ protected function sanitize() { - return $this->getValue(); + return $this->getValue(); } /** @@ -318,10 +319,10 @@ protected function setCommonAttributes(array $attrs) } /** - * Assemble classes - * + * Assemble classes + * * @param array $classes Classes - * + * * @return array */ protected function assembleClasses(array $classes) @@ -335,8 +336,8 @@ protected function assembleClasses(array $classes) } /** - * Assemble validation rules - * + * Assemble validation rules + * * @return array */ protected function assembleValidationRules() @@ -399,6 +400,7 @@ protected function getAttributesCode() /** * Some JavaScript code to insert * + * @todo Remove it. Use getFormFieldJSData method instead. * @return string */ protected function getInlineJSCode() @@ -563,8 +565,8 @@ protected function isVisible() } /** - * Get default wrapper class - * + * Get default wrapper class + * * @return string */ protected function getDefaultWrapperClass() @@ -576,8 +578,8 @@ protected function getDefaultWrapperClass() } /** - * Get label container class - * + * Get label container class + * * @return string */ protected function getLabelContainerClass() @@ -586,12 +588,22 @@ protected function getLabelContainerClass() } /** - * Get value container class - * + * Get value container class + * * @return string */ protected function getValueContainerClass() { return 'table-value ' . $this->getFieldId() . '-value'; } + + /** + * Return some data for JS external scripts if it is needed. + * + * @return null|array + */ + protected function getFormFieldJSData() + { + return null; + } } diff --git a/src/classes/XLite/View/FormField/Inline/Input/ServiceName.php b/src/classes/XLite/View/FormField/Inline/Input/ServiceName.php new file mode 100644 index 0000000000..b5dae17bd4 --- /dev/null +++ b/src/classes/XLite/View/FormField/Inline/Input/ServiceName.php @@ -0,0 +1,54 @@ + + * @copyright Copyright (c) 2011-2012 Creative Development LLC . All rights reserved + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + * @link http://www.litecommerce.com/ + */ + +namespace XLite\View\FormField\Inline\Input; + +/** + * Service name field for address field + * + */ +class ServiceName extends \XLite\View\FormField\Inline\Input\Text +{ + /** + * Define form field + * + * @return string + */ + protected function defineFieldClass() + { + return 'XLite\View\FormField\Input\Text\ServiceName'; + } + + /** + * Get container class + * + * @return string + */ + protected function getContainerClass() + { + return parent::getContainerClass() . ' inline-service-name'; + } +} + diff --git a/src/classes/XLite/View/FormField/Inline/Input/Text/ProductClass.php b/src/classes/XLite/View/FormField/Inline/Input/Text/ProductClass.php new file mode 100644 index 0000000000..bacd573e47 --- /dev/null +++ b/src/classes/XLite/View/FormField/Inline/Input/Text/ProductClass.php @@ -0,0 +1,79 @@ + + * @copyright Copyright (c) 2011-2012 Creative Development LLC . All rights reserved + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + * @link http://www.litecommerce.com/ + */ + +namespace XLite\View\FormField\Inline\Input\Text; + +/** + * Product class + * + */ +class ProductClass extends \XLite\View\FormField\Inline\Base\Single +{ + /** + * Register JS files + * + * @return array + */ + public function getJSFiles() + { + $list = parent::getJSFiles(); + + $list[] = 'form_field/inline/input/text/product-class.js'; + + return $list; + } + + /** + * Define form field + * + * @return string + */ + protected function defineFieldClass() + { + return 'XLite\View\FormField\Input\Text'; + } + + /** + * Get container class + * + * @return string + */ + protected function getContainerClass() + { + return parent::getContainerClass() . ' inline-product-class'; + } + + /** + * Get view template + * + * @return string + */ + protected function getViewTemplate() + { + return 'form_field/inline/input/text/product-class.tpl'; + } + +} + diff --git a/src/classes/XLite/View/ProductClass/AProductClass.php b/src/classes/XLite/View/FormField/Input/Radio.php similarity index 76% rename from src/classes/XLite/View/ProductClass/AProductClass.php rename to src/classes/XLite/View/FormField/Input/Radio.php index 5a8e30a50d..33840ca47f 100644 --- a/src/classes/XLite/View/ProductClass/AProductClass.php +++ b/src/classes/XLite/View/FormField/Input/Radio.php @@ -23,31 +23,31 @@ * @link http://www.litecommerce.com/ */ -namespace XLite\View\ProductClass; +namespace XLite\View\FormField\Input; /** - * Product class + * Radio * */ -abstract class AProductClass extends \XLite\View\Dialog +class Radio extends \XLite\View\FormField\Input\Checkbox { /** - * Return title + * Return field type * * @return string */ - protected function getHead() + public function getFieldType() { - return 'Product classes'; + return self::FIELD_TYPE_RADIO; } /** - * Return templates directory + * Return field template * * @return string */ - protected function getDir() + protected function getFieldTemplate() { - return 'product_classes'; + return 'radio.tpl'; } } diff --git a/src/classes/XLite/View/FormField/Input/Text/AttributeOption.php b/src/classes/XLite/View/FormField/Input/Text/AttributeOption.php new file mode 100644 index 0000000000..4659e2f575 --- /dev/null +++ b/src/classes/XLite/View/FormField/Input/Text/AttributeOption.php @@ -0,0 +1,91 @@ + + * @copyright Copyright (c) 2011 Creative Development LLC . All rights reserved + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + * @link http://www.litecommerce.com/ + */ + +namespace XLite\View\FormField\Input\Text; + +/** + * Atutribute option + * + */ +class AttributeOption extends \XLite\View\FormField\Input\Text\Base\Combobox +{ + /** + * Common params + */ + const PARAM_ATTRIBUTE = 'attribute'; + + /** + * Define widget params + * + * @return void + */ + protected function defineWidgetParams() + { + parent::defineWidgetParams(); + + $this->widgetParams += array( + self::PARAM_ATTRIBUTE => new \XLite\Model\WidgetParam\Object( + 'Attribute', null, false, 'XLite\Model\Attribute' + ), + ); + } + + /** + * Get URL + * + * @return string + */ + protected function getURL() + { + return parent::getURL() . '&id=' + . $this->getParam(self::PARAM_ATTRIBUTE)->getId(); + } + + /** + * Set value + * + * @param mixed $value Value to set + * + * @return void + */ + public function setValue($value) + { + if ($value && is_object($value) && $value instanceOf \XLite\Model\AttributeOption) { + $value = $value->getName(); + } + + parent::setValue($value); + } + + /** + * Get dictionary name + * + * @return string + */ + protected function getDictionary() + { + return 'attributeOption'; + } +} diff --git a/src/classes/XLite/View/FormField/Input/Text/Base/Autocomplete.php b/src/classes/XLite/View/FormField/Input/Text/Base/Autocomplete.php index aead0d936e..db3d938222 100644 --- a/src/classes/XLite/View/FormField/Input/Text/Base/Autocomplete.php +++ b/src/classes/XLite/View/FormField/Input/Text/Base/Autocomplete.php @@ -69,7 +69,7 @@ protected function assembleClasses(array $classes) } /** - * setCommonAttributes + * Set common attributes * * @param array $attrs Field attributes to prepare * diff --git a/src/classes/XLite/View/FormField/Input/Text/Base/Combobox.php b/src/classes/XLite/View/FormField/Input/Text/Base/Combobox.php new file mode 100644 index 0000000000..0f91bec0b0 --- /dev/null +++ b/src/classes/XLite/View/FormField/Input/Text/Base/Combobox.php @@ -0,0 +1,87 @@ + + * @copyright Copyright (c) 2011-2012 Creative Development LLC . All rights reserved + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + * @link http://www.litecommerce.com/ + */ + +namespace XLite\View\FormField\Input\Text\Base; + +/** + * Combobox + * + */ +abstract class Combobox extends \XLite\View\FormField\Input\Text\Base\Autocomplete +{ + /** + * Get a list of CSS files required to display the widget properly + * + * @return array + */ + public function getCSSFiles() + { + $list = parent::getCSSFiles(); + + $list[] = $this->getDir() . '/input/text/combobox.css'; + + return $list; + } + + /** + * Register JS files + * + * @return array + */ + public function getJSFiles() + { + $list = parent::getJSFiles(); + + $list[] = 'form_field/input/text/combobox.js'; + + return $list; + } + + /** + * Return field template + * + * @return string + */ + protected function getFieldTemplate() + { + return 'input/text/combobox.tpl'; + } + + /** + * Assemble classes + * + * @param array $classes Classes + * + * @return array + */ + protected function assembleClasses(array $classes) + { + $classes = parent::assembleClasses($classes); + + $classes[] = 'combobox'; + + return $classes; + } +} diff --git a/src/classes/XLite/View/FormField/Input/Text/Float.php b/src/classes/XLite/View/FormField/Input/Text/Float.php index 54df94d686..d42e1c3fce 100644 --- a/src/classes/XLite/View/FormField/Input/Text/Float.php +++ b/src/classes/XLite/View/FormField/Input/Text/Float.php @@ -50,6 +50,16 @@ public function getJSFiles() return $list; } + /** + * Get value + * + * @return float + */ + public function getValue() + { + return $this->sanitizeFloat(parent::getValue()); + } + /** * Define widget params * @@ -71,7 +81,17 @@ protected function defineWidgetParams() */ protected function sanitize() { - return round(doubleval(parent::sanitize()), $this->getParam(self::PARAM_E)); + return $this->sanitizeFloat(parent::sanitize()); + } + + /** + * Sanitize value + * + * @return mixed + */ + protected function sanitizeFloat($value) + { + return round(doubleval($value), $this->getParam(self::PARAM_E)); } /** diff --git a/src/classes/XLite/View/FormField/Input/Text/ServiceName.php b/src/classes/XLite/View/FormField/Input/Text/ServiceName.php new file mode 100644 index 0000000000..ff6936c1e0 --- /dev/null +++ b/src/classes/XLite/View/FormField/Input/Text/ServiceName.php @@ -0,0 +1,47 @@ + + * @copyright Copyright (c) 2011-2012 Creative Development LLC . All rights reserved + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + * @link http://www.litecommerce.com/ + */ + +namespace XLite\View\FormField\Input\Text; + +/** + * Service name for address fields items list + * + */ +class ServiceName extends \XLite\View\FormField\Input\Text +{ + /** + * Assemble validation rules + * + * @return array + */ + protected function assembleValidationRules() + { + $rules = parent::assembleValidationRules(); + + $rules[] = 'custom[onlySmallLetterNumberUnder]'; + + return $rules; + } +} diff --git a/src/classes/XLite/View/ProductClass/MainInput.php b/src/classes/XLite/View/FormField/ItemsList.php similarity index 61% rename from src/classes/XLite/View/ProductClass/MainInput.php rename to src/classes/XLite/View/FormField/ItemsList.php index 693f59a467..2a143f7f38 100644 --- a/src/classes/XLite/View/ProductClass/MainInput.php +++ b/src/classes/XLite/View/FormField/ItemsList.php @@ -23,34 +23,41 @@ * @link http://www.litecommerce.com/ */ -namespace XLite\View\ProductClass; +namespace XLite\View\FormField; /** - * Product classes main input widget + * Items list * */ -class MainInput extends \XLite\View\AView +class ItemsList extends \XLite\View\FormField\AFormField { - - const CLASS_NAME = 'className'; - const CLASS_ID = 'classId'; + /** + * Widget parameters + */ + const PARAM_LIST_CLASS = 'listClass'; /** - * Return allowed targets + * Return field type * - * @return array + * @return string */ - public static function getAllowedTargets() + public function getFieldType() { - $result = parent::getAllowedTargets(); - - $result[] = 'product_classes'; + return self::FIELD_TYPE_ITEMS_LIST; + } - return $result; + /** + * Return field template + * + * @return string + */ + protected function getFieldTemplate() + { + return 'items_list.tpl'; } /** - * Define widget parameters + * Define widget params * * @return void */ @@ -59,18 +66,18 @@ protected function defineWidgetParams() parent::defineWidgetParams(); $this->widgetParams += array( - self::CLASS_NAME => new \XLite\Model\WidgetParam\String('className', null), - self::CLASS_ID => new \XLite\Model\WidgetParam\String('classId', null), + self::PARAM_LIST_CLASS => new \XLite\Model\WidgetParam\String('List class', ''), ); } /** - * getDefaultTemplate() + * Get list class * * @return string */ - protected function getDefaultTemplate() + protected function getListClass() { - return 'product_classes/list/main_input.tpl'; + return $this->getParam(self::PARAM_LIST_CLASS); } + } diff --git a/src/classes/XLite/View/FormField/Select/AttributeGroups.php b/src/classes/XLite/View/FormField/Select/AttributeGroups.php new file mode 100644 index 0000000000..dadf0bc249 --- /dev/null +++ b/src/classes/XLite/View/FormField/Select/AttributeGroups.php @@ -0,0 +1,63 @@ + + * @copyright Copyright (c) 2011-2012 Creative Development LLC . All rights reserved + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + * @link http://www.litecommerce.com/ + */ + +namespace XLite\View\FormField\Select; + +/** + * Attribute groups selector + * + */ +class AttributeGroups extends \XLite\View\FormField\Select\Regular +{ + /** + * Get attribute groups list + * + * @return array + */ + protected function getAttributeGroupsList() + { + $list = array(); + $cnd = new \XLite\Core\CommonCell; + if ($this->getProductClass()) { + $cnd->productClass = $this->getProductClass(); + } + + foreach (\XLite\Core\Database::getRepo('\XLite\Model\AttributeGroup')->search($cnd) as $e) { + $list[$e->getId()] = htmlspecialchars($e->getName()); + } + + return $list; + } + + /** + * Get default options + * + * @return array + */ + protected function getDefaultOptions() + { + return array('0' => 'No group') + $this->getAttributeGroupsList(); + } +} diff --git a/src/classes/XLite/View/FormField/Select/AttributeTypes.php b/src/classes/XLite/View/FormField/Select/AttributeTypes.php new file mode 100644 index 0000000000..806746f36b --- /dev/null +++ b/src/classes/XLite/View/FormField/Select/AttributeTypes.php @@ -0,0 +1,59 @@ + + * @copyright Copyright (c) 2011-2012 Creative Development LLC . All rights reserved + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + * @link http://www.litecommerce.com/ + */ + +namespace XLite\View\FormField\Select; + +/** + * Attribute types selector + * + */ +class AttributeTypes extends \XLite\View\FormField\Select\Regular +{ + /** + * Get default options + * + * @return array + */ + protected function getDefaultOptions() + { + return \XLite\Model\Attribute::getTypes(); + } + + /** + * Set common attributes + * + * @param array $attrs Field attributes to prepare + * + * @return array + */ + protected function setCommonAttributes(array $attrs) + { + $attrs = parent::setCommonAttributes($attrs); + + $attrs['data-value'] = $this->getValue(); + + return $attrs; + } +} diff --git a/src/classes/XLite/View/FormField/Select/AttributeValues.php b/src/classes/XLite/View/FormField/Select/AttributeValues.php new file mode 100644 index 0000000000..15aa469fe8 --- /dev/null +++ b/src/classes/XLite/View/FormField/Select/AttributeValues.php @@ -0,0 +1,92 @@ + + * @copyright Copyright (c) 2011-2012 Creative Development LLC . All rights reserved + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + * @link http://www.litecommerce.com/ + */ + +namespace XLite\View\FormField\Select; + +/** + * Attribute groups selector + * + */ +class AttributeValues extends \XLite\View\FormField\Select\Regular +{ + /** + * Common params + */ + const PARAM_ATTRIBUTE = 'attribute'; + + /** + * Get attribute groups list + * + * @return array + */ + protected function getAttributeValuesList() + { + $list = array(); + $cnd = new \XLite\Core\CommonCell; + $cnd->attribute = $this->getParam(self::PARAM_ATTRIBUTE); + + foreach (\XLite\Core\Database::getRepo('\XLite\Model\AttributeOption')->search($cnd) as $e) { + $list[$e->getId()] = $e->getName(); + } + + return $list; + } + + /** + * Define widget params + * + * @return void + */ + protected function defineWidgetParams() + { + parent::defineWidgetParams(); + + $this->widgetParams += array( + self::PARAM_ATTRIBUTE => new \XLite\Model\WidgetParam\Object( + 'Attribute', null, false, 'XLite\Model\Attribute' + ), + ); + } + + /** + * Get options + * + * @return array + */ + protected function getOptions() + { + return $this->getAttributeValuesList(); + } + + /** + * Get default options + * + * @return array + */ + protected function getDefaultOptions() + { + return array(); + } +} diff --git a/src/classes/XLite/View/FormField/Select/Classes.php b/src/classes/XLite/View/FormField/Select/Classes.php index 230ac48ac2..054276c1a5 100644 --- a/src/classes/XLite/View/FormField/Select/Classes.php +++ b/src/classes/XLite/View/FormField/Select/Classes.php @@ -78,7 +78,7 @@ protected function getFieldTemplate() protected function getDefaultOptions() { $list = array(); - foreach (\XLite\Core\Database::getRepo('\XLite\Model\ProductClass')->findAll() as $class) { + foreach (\XLite\Core\Database::getRepo('\XLite\Model\ProductClass')->search() as $class) { $list[$class->getId()] = $class->getName(); } diff --git a/src/classes/XLite/View/FormField/Select/Country.php b/src/classes/XLite/View/FormField/Select/Country.php index cb5b65eaab..22e307a2c5 100644 --- a/src/classes/XLite/View/FormField/Select/Country.php +++ b/src/classes/XLite/View/FormField/Select/Country.php @@ -37,6 +37,7 @@ class Country extends \XLite\View\FormField\Select\Regular const PARAM_ALL = 'all'; const PARAM_STATE_SELECTOR_ID = 'stateSelectorId'; const PARAM_STATE_INPUT_ID = 'stateInputId'; + const PARAM_SELECT_ONE = 'selectOne'; /** * Display only enabled countries @@ -54,7 +55,7 @@ class Country extends \XLite\View\FormField\Select\Regular */ public function __construct(array $params = array()) { - if (!empty($params[self::PARAM_ALL])) { + if (!empty($params[static::PARAM_ALL])) { $this->onlyEnabled = false; } @@ -85,8 +86,8 @@ public function getJSFiles() */ public function setStateSelectorIds($selectorId, $inputId) { - $this->getWidgetParams(self::PARAM_STATE_SELECTOR_ID)->setValue($selectorId); - $this->getWidgetParams(self::PARAM_STATE_INPUT_ID)->setValue($inputId); + $this->getWidgetParams(static::PARAM_STATE_SELECTOR_ID)->setValue($selectorId); + $this->getWidgetParams(static::PARAM_STATE_INPUT_ID)->setValue($inputId); } @@ -100,9 +101,10 @@ protected function defineWidgetParams() parent::defineWidgetParams(); $this->widgetParams += array( - self::PARAM_ALL => new \XLite\Model\WidgetParam\Bool('All', false), - self::PARAM_STATE_SELECTOR_ID => new \XLite\Model\WidgetParam\String('State select ID', null), - self::PARAM_STATE_INPUT_ID => new \XLite\Model\WidgetParam\String('State input ID', null), + static::PARAM_ALL => new \XLite\Model\WidgetParam\Bool('All', false), + static::PARAM_STATE_SELECTOR_ID => new \XLite\Model\WidgetParam\String('State select ID', null), + static::PARAM_STATE_INPUT_ID => new \XLite\Model\WidgetParam\String('State input ID', null), + static::PARAM_SELECT_ONE => new \XLite\Model\WidgetParam\Bool('All', true), ); } @@ -118,6 +120,7 @@ protected function getDefaultOptions() : \XLite\Core\Database::getRepo('XLite\Model\Country')->findAllCountries(); $options = array(); + foreach ($list as $country) { $options[$country->getCode()] = $country->getCountry(); } @@ -132,8 +135,10 @@ protected function getDefaultOptions() */ protected function getOptions() { - return array('' => 'Select one...') - + parent::getOptions(); + return $this->getParam(static::PARAM_SELECT_ONE) + ? array('' => 'Select one...') + + parent::getOptions() + : parent::getOptions(); } /** @@ -147,17 +152,29 @@ protected function getDefaultValue() } /** - * Some JavaScript code to insert + * Return some data for JS external scripts if it is needed. + * + * @return null|array + */ + protected function getFormFieldJSData() + { + return array( + 'statesList' => \XLite\Core\Database::getRepo('XLite\Model\Country')->findCountriesStates(), + 'stateSelectors' => array( + 'fieldId' => $this->getFieldId(), + 'stateSelectorId' => $this->getParam(static::PARAM_STATE_SELECTOR_ID), + 'stateInputId' => $this->getParam(static::PARAM_STATE_INPUT_ID), + ), + ); + } + + /** + * Get value container class * * @return string */ - protected function getInlineJSCode() + protected function getValueContainerClass() { - return 'jQuery(document).ready(function() { ' - . 'stateSelectors[\'' . $this->getFieldId() . '\'] = new StateSelector(' - . '\'' . $this->getFieldId() . '\', ' - . '\'' . $this->getParam(self::PARAM_STATE_SELECTOR_ID) . '\', ' - . '\'' . $this->getParam(self::PARAM_STATE_INPUT_ID) . '\'); });' . PHP_EOL - . $this->getWidget(array(), '\XLite\View\JS\StatesList')->getContent(); + return parent::getValueContainerClass() . ' country-selector'; } } diff --git a/src/classes/XLite/View/FormField/Select/Decimals.php b/src/classes/XLite/View/FormField/Select/Decimals.php new file mode 100644 index 0000000000..98f27cee37 --- /dev/null +++ b/src/classes/XLite/View/FormField/Select/Decimals.php @@ -0,0 +1,49 @@ + + * @copyright Copyright (c) 2011-2012 Creative Development LLC . All rights reserved + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + * @link http://www.litecommerce.com/ + */ + +namespace XLite\View\FormField\Select; + +/** + * Decimals selector + * + */ +class Decimals extends \XLite\View\FormField\Select\Regular +{ + /** + * Get default options + * + * @return array + */ + protected function getDefaultOptions() + { + return array( + 0 => 0, + 1 => 1, + 2 => 2, + 3 => 3, + 4 => 4 + ); + } +} diff --git a/src/classes/XLite/View/FormField/Select/ProductClasses.php b/src/classes/XLite/View/FormField/Select/ProductClasses.php index e8e42e9fda..2ccf3221c9 100644 --- a/src/classes/XLite/View/FormField/Select/ProductClasses.php +++ b/src/classes/XLite/View/FormField/Select/ProductClasses.php @@ -39,7 +39,7 @@ class ProductClasses extends \XLite\View\FormField\Select\Multiple protected function getProductClassesList() { $list = array(); - foreach (\XLite\Core\Database::getRepo('\XLite\Model\ProductClass')->findAll() as $e) { + foreach (\XLite\Core\Database::getRepo('\XLite\Model\ProductClass')->search() as $e) { $list[$e->getId()] = $e->getName(); } diff --git a/src/classes/XLite/View/ItemsList/Model/AModel.php b/src/classes/XLite/View/ItemsList/Model/AModel.php index f969edd54f..21556b8365 100644 --- a/src/classes/XLite/View/ItemsList/Model/AModel.php +++ b/src/classes/XLite/View/ItemsList/Model/AModel.php @@ -494,11 +494,27 @@ protected function update() foreach ($this->getPageData() as $entity) { $entity->getRepository()->update($entity, array(), false); + if ($this->isDefault()) { + $entity->setDefaultValue($this->isDefaultEntity($entity)); + } } return $count; } + /** + * Is default entity + * + * @param \XLite\Model\AEntity $entity Line + * + * @return boolean + */ + protected function isDefaultEntity(\XLite\Model\AEntity $entity) + { + return isset($this->requestData['defaultValue']) + && $this->requestData['defaultValue'] == $entity->getId(); + } + /** * Process errors * @@ -791,8 +807,8 @@ protected function getListNameSuffixes() protected function buildEntityURL(\XLite\Model\AEntity $entity, array $column) { return \XLite\Core\Converter::buildURL( - $column[static::COLUMN_LINK], - '', + $column[static::COLUMN_LINK], + '', array($entity->getUniqueIdentifierName() => $entity->getUniqueIdentifier()) ); } @@ -853,7 +869,7 @@ protected function getSortableType() } /** - * Mark list as switchyabvle (enable / disable) + * Mark list as switchable (enable / disable) * * @return boolean */ @@ -872,6 +888,16 @@ protected function isRemoved() return false; } + /** + * Mark list iten as default + * + * @return boolean + */ + protected function isDefault() + { + return false; + } + /** * Mark list as selectable * diff --git a/src/classes/XLite/View/ItemsList/Model/Address/Fields.php b/src/classes/XLite/View/ItemsList/Model/Address/Fields.php new file mode 100644 index 0000000000..30cc39d8f9 --- /dev/null +++ b/src/classes/XLite/View/ItemsList/Model/Address/Fields.php @@ -0,0 +1,245 @@ + + * @copyright Copyright (c) 2010-2012 Creative Development LLC . All rights reserved + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + * @link http://www.litecommerce.com/ + */ + +namespace XLite\View\ItemsList\Model\Address; + +/** + * Address fields items list + * + */ +class Fields extends \XLite\View\ItemsList\Model\Table +{ + /** + * Get a list of CSS files + * + * @return array + */ + public function getCSSFiles() + { + $list = parent::getCSSFiles(); + + $list[] = $this->getDir() . '/' . $this->getPageBodyDir() . '/address_fields/style.css'; + + return $list; + } + + /** + * Define columns structure + * + * @return array + */ + protected function defineColumns() + { + return array( + 'name' => array( + static::COLUMN_NAME => static::t('Name'), + static::COLUMN_CLASS => 'XLite\View\FormField\Inline\Input\Text', + static::COLUMN_PARAMS => array('required' => true), + ), + 'serviceName' => array( + static::COLUMN_NAME => static::t('Service name'), + static::COLUMN_CLASS => 'XLite\View\FormField\Inline\Input\ServiceName', + static::COLUMN_TEMPLATE => 'items_list/model/table/field.tpl', + static::COLUMN_PARAMS => array('required' => true), + ), + 'required' => array( + static::COLUMN_NAME => static::t('Required'), + static::COLUMN_CLASS => 'XLite\View\FormField\Inline\Input\Checkbox\Switcher\Enabled', + static::COLUMN_PARAMS => array(), + ), + ); + } + + /** + * Define repository name + * + * @return string + */ + protected function defineRepositoryName() + { + return 'XLite\Model\AddressField'; + } + + // {{{ Behaviors + + /** + * Mark list as removable + * + * @return boolean + */ + protected function isRemoved() + { + return true; + } + + /** + * Mark list as switchable (enable / disable) + * + * @return boolean + */ + protected function isSwitchable() + { + return true; + } + + /** + * Mark list as sortable + * + * @return integer + */ + protected function getSortableType() + { + return static::SORT_TYPE_MOVE; + } + + /** + * Get create entity URL + * + * @return string + */ + protected function getCreateURL() + { + return \XLite\Core\Converter::buildURL('address_field'); + } + + /** + * Get create button label + * + * @return string + */ + protected function getCreateButtonLabel() + { + return 'New address field'; + } + + /** + * Creation button position + * + * @return integer + */ + protected function isCreation() + { + return static::CREATE_INLINE_TOP; + } + + // }}} + + /** + * Get container class + * + * @return string + */ + protected function getContainerClass() + { + return parent::getContainerClass() . ' address-fields'; + } + + /** + * Return params list to use for search + * + * @return \XLite\Core\CommonCell + */ + protected function getSearchCondition() + { + $result = parent::getSearchCondition(); + + return $result; + } + + /** + * Return "empty list" catalog + * + * @return string + */ + protected function getEmptyListDir() + { + return parent::getEmptyListDir(); + } + + /** + * Check - remove entity or not + * + * @param \XLite\Model\AEntity $entity Entity + * + * @return boolean + */ + protected function isAllowEntityRemove(\XLite\Model\AEntity $entity) + { + return parent::isAllowEntityRemove($entity) && $entity->getAdditional(); + } + + /** + * Check - switch entity or not + * + * @param \XLite\Model\AEntity $entity Entity + * + * @return boolean + */ + protected function isAllowEntitySwitch(\XLite\Model\AEntity $entity) + { + // Custom state is not allowed to switch off + return parent::isAllowEntitySwitch($entity) && 'custom_state' !== $entity->getServiceName(); + } + + /** + * Check if the column template is used for widget displaying + * + * @param array $column + * @param \XLite\Model\AEntity $entity + * + * @return boolean + */ + protected function isTemplateColumnVisible(array $column, \XLite\Model\AEntity $entity) + { + // Right now admin cannot directly edit serviceName values for additional fields + // and cannot change "Not required" state of "custom_state" field + // TODO: refactor it + return 'serviceName' !== $column[static::COLUMN_CODE] + ? parent::isTemplateColumnVisible($column, $entity) + : !$entity->getAdditional(); + } + + + /** + * Check if the simple class is used for widget displaying + * + * @param array $column + * @param \XLite\Model\AEntity $entity + * + * @return boolean + */ + protected function isClassColumnVisible(array $column, \XLite\Model\AEntity $entity) + { + // Right now admin cannot directly edit serviceName values for additional fields + // and cannot change "Not required" state of "custom_state" field + // TODO: refactor it + return 'serviceName' !== $column[static::COLUMN_CODE] + ? (('custom_state' === $entity->getServiceName() && 'required' === $column[static::COLUMN_CODE]) + ? false + : parent::isClassColumnVisible($column, $entity) + ) + : $entity->getAdditional(); + } +} diff --git a/src/classes/XLite/View/ItemsList/Model/Attribute.php b/src/classes/XLite/View/ItemsList/Model/Attribute.php new file mode 100644 index 0000000000..88685999a7 --- /dev/null +++ b/src/classes/XLite/View/ItemsList/Model/Attribute.php @@ -0,0 +1,261 @@ + + * @copyright Copyright (c) 2011-2012 Creative Development LLC . All rights reserved + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + * @link http://www.litecommerce.com/ + */ + +namespace XLite\View\ItemsList\Model; + +/** + * Attributes items list + * + */ +class Attribute extends \XLite\View\ItemsList\Model\Table +{ + /** + * Widget param names + */ + + const PARAM_GROUP = 'group'; + + /** + * Define columns structure + * + * @return array + */ + protected function defineColumns() + { + return array( + 'name' => array( + static::COLUMN_NAME => $this->getAttributeGroup() + ? $this->getAttributeGroup()->getName() + : \XLite\Core\Translation::lbl('No group'), + static::COLUMN_CLASS => 'XLite\View\FormField\Inline\Input\Text', + static::COLUMN_PARAMS => array('required' => true), + ), + 'type' => array( + static::COLUMN_NAME => $this->getAttributeGroup() + ? static::t( + 'X attributes in group', + array( + 'count' => $this->getAttributeGroup()->getAttributesCount() + ) + ) + : null, + static::COLUMN_TEMPLATE => 'attributes/parts/type.tpl', + ), + ); + } + + /** + * Define repository name + * + * @return string + */ + protected function defineRepositoryName() + { + return 'XLite\Model\Attribute'; + } + + /** + * Get create entity URL + * + * @return string + */ + protected function getCreateURL() + { + return \XLite\Core\Converter::buildUrl('attribute'); + } + + /** + * Get create button label + * + * @return string + */ + protected function getCreateButtonLabel() + { + return 'New attribute'; + } + + /** + * Define widget params + * + * @return void + */ + protected function defineWidgetParams() + { + parent::defineWidgetParams(); + + $this->widgetParams += array( + self::PARAM_GROUP => new \XLite\Model\WidgetParam\Object( + 'Group', null, false, '\XLite\Model\AttributeGroup' + ), + ); + } + + /** + * Get attribute group + * + * @return \XLite\Model\AttributeGroup + */ + protected function getAttributeGroup() + { + return $this->getParam(static::PARAM_GROUP); + } + + // {{{ Behaviors + + /** + * Mark list as removable + * + * @return boolean + */ + protected function isRemoved() + { + return true; + } + + /** + * Mark list as sortable + * + * @return integer + */ + protected function getSortableType() + { + return static::SORT_TYPE_MOVE; + } + + /** + * Check if there are any results to display in list + * + * @return void + */ + protected function hasResults() + { + return true; + } + + /** + * Check if widget is visible + * + * @return boolean + */ + protected function isVisible() + { + return $this->getAttributeGroup() + || 0 < $this->getItemsCount(); + } + + /** + * Check - pager box is visible or not + * + * @return boolean + */ + protected function isPagerVisible() + { + return false; + } + + // }}} + + /** + * Get container class + * + * @return string + */ + protected function getContainerClass() + { + $class = parent::getContainerClass() . ' attributes'; + + if ($this->getAttributeGroup()) { + $class = parent::getContainerClass() + . ' group'; + } + + return $class; + } + + /** + * Get panel class + * + * @return \XLite\View\Base\FormStickyPanel + */ + protected function getPanelClass() + { + $groups = $this->getAttributeGroups(); + + return ( + $this->getProductClass()->getAttributesCount() + && ( + !$groups->count() + || ( + $this->getAttributeGroup() + && $groups->last()->getId() == $this->getAttributeGroup()->getId() + ) + ) + ) + ? 'XLite\View\StickyPanel\ItemsList\Attribute' + : null; + } + + + // {{{ Search + + /** + * Return search parameters. + * + * @return array + */ + static public function getSearchParams() + { + return array(); + } + + /** + * Return params list to use for search + * TODO refactor + * + * @return \XLite\Core\CommonCell + */ + protected function getSearchCondition() + { + $result = parent::getSearchCondition(); + + foreach (static::getSearchParams() as $modelParam => $requestParam) { + $paramValue = $this->getParam($requestParam); + + if ('' !== $paramValue && 0 !== $paramValue) { + $result->$modelParam = $paramValue; + } + } + + $result->productClass = $this->getProductClass(); + if (\XLite\Core\Request::getInstance()->isGet()) { + $result->attributeGroup = $this->getAttributeGroup(); + } + + return $result; + } + + // }}} + +} diff --git a/src/classes/XLite/View/ItemsList/Model/AttributeGroup.php b/src/classes/XLite/View/ItemsList/Model/AttributeGroup.php new file mode 100644 index 0000000000..949f702f23 --- /dev/null +++ b/src/classes/XLite/View/ItemsList/Model/AttributeGroup.php @@ -0,0 +1,209 @@ + + * @copyright Copyright (c) 2011-2012 Creative Development LLC . All rights reserved + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + * @link http://www.litecommerce.com/ + */ + +namespace XLite\View\ItemsList\Model; + +/** + * Attribute groups items list + * + */ +class AttributeGroup extends \XLite\View\ItemsList\Model\Table +{ + /** + * Get a list of CSS files required to display the widget properly + * + * @return array + */ + public function getCSSFiles() + { + $list = parent::getCSSFiles(); + + $list[] = 'attribute_groups/style.css'; + + return $list; + } + + /** + * Define columns structure + * + * @return array + */ + protected function defineColumns() + { + return array( + 'name' => array( + static::COLUMN_CLASS => 'XLite\View\FormField\Inline\Input\Text', + static::COLUMN_MAIN => true, + static::COLUMN_PARAMS => array('required' => true), + ), + ); + } + + /** + * Define repository name + * + * @return string + */ + protected function defineRepositoryName() + { + return 'XLite\Model\AttributeGroup'; + } + + /** + * Get create entity URL + * + * @return string + */ + protected function getCreateURL() + { + return \XLite\Core\Converter::buildUrl('attribute_group'); + } + + /** + * Get create button label + * + * @return string + */ + protected function getCreateButtonLabel() + { + return 'New group'; + } + + /** + * Inline creation mechanism position + * + * @return integer + */ + protected function isInlineCreation() + { + return static::CREATE_INLINE_TOP; + } + + // {{{ Behaviors + + /** + * Mark list as removable + * + * @return boolean + */ + protected function isRemoved() + { + return true; + } + + /** + * Mark list as sortable + * + * @return integer + */ + protected function getSortableType() + { + return static::SORT_TYPE_MOVE; + } + + // }}} + + /** + * Get container class + * + * @return string + */ + protected function getContainerClass() + { + return parent::getContainerClass() . ' attribute_groups'; + } + + /** + * Get panel class + * + * @return \XLite\View\Base\FormStickyPanel + */ + protected function getPanelClass() + { + return null; + } + + /** + * Create entity + * + * @return \XLite\Model\AEntity + */ + protected function createEntity() + { + $entity = parent::createEntity(); + + $entity->setProductClass($this->getProductClass()); + + return $entity; + } + + /** + * Check - pager box is visible or not + * + * @return boolean + */ + protected function isPagerVisible() + { + return false; + } + + // {{{ Search + + /** + * Return search parameters. + * + * @return array + */ + static public function getSearchParams() + { + return array(); + } + + /** + * Return params list to use for search + * TODO refactor + * + * @return \XLite\Core\CommonCell + */ + protected function getSearchCondition() + { + $result = parent::getSearchCondition(); + + foreach (static::getSearchParams() as $modelParam => $requestParam) { + $paramValue = $this->getParam($requestParam); + + if ('' !== $paramValue && 0 !== $paramValue) { + $result->$modelParam = $paramValue; + } + } + + $result->productClass = $this->getProductClass(); + + return $result; + } + + // }}} + +} diff --git a/src/classes/XLite/View/ItemsList/Model/AttributeOption.php b/src/classes/XLite/View/ItemsList/Model/AttributeOption.php new file mode 100644 index 0000000000..572cb00eb3 --- /dev/null +++ b/src/classes/XLite/View/ItemsList/Model/AttributeOption.php @@ -0,0 +1,209 @@ + + * @copyright Copyright (c) 2011-2012 Creative Development LLC . All rights reserved + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + * @link http://www.litecommerce.com/ + */ + +namespace XLite\View\ItemsList\Model; + +/** + * Attribute options items list + * + */ +class AttributeOption extends \XLite\View\ItemsList\Model\Table +{ + /** + * Get a list of CSS files required to display the widget properly + * + * @return array + */ + public function getCSSFiles() + { + $list = parent::getCSSFiles(); + + $list[] = 'attribute_options/style.css'; + + return $list; + } + + /** + * Define columns structure + * + * @return array + */ + protected function defineColumns() + { + return array( + 'name' => array( + static::COLUMN_CLASS => 'XLite\View\FormField\Inline\Input\Text', + static::COLUMN_MAIN => true, + static::COLUMN_PARAMS => array('required' => true), + ), + ); + } + + /** + * Define repository name + * + * @return string + */ + protected function defineRepositoryName() + { + return 'XLite\Model\AttributeOption'; + } + + /** + * Get create entity URL + * + * @return string + */ + protected function getCreateURL() + { + return \XLite\Core\Converter::buildUrl('attribute_option'); + } + + /** + * Get create button label + * + * @return string + */ + protected function getCreateButtonLabel() + { + return 'New value'; + } + + /** + * Inline creation mechanism position + * + * @return integer + */ + protected function isInlineCreation() + { + return static::CREATE_INLINE_BOTTOM; + } + + // {{{ Behaviors + + /** + * Mark list as removable + * + * @return boolean + */ + protected function isRemoved() + { + return true; + } + + /** + * Mark list iten as default + * + * @return boolean + */ + protected function isDefault() + { + return true; + } + + // }}} + + /** + * Get container class + * + * @return string + */ + protected function getContainerClass() + { + return parent::getContainerClass() . ' attribute_options'; + } + + /** + * Get panel class + * + * @return \XLite\View\Base\FormStickyPanel + */ + protected function getPanelClass() + { + return null; + } + + /** + * Create entity + * + * @return \XLite\Model\AEntity + */ + protected function createEntity() + { + $entity = parent::createEntity(); + + $entity->setAttribute($this->getAttribute()); + + return $entity; + } + + /** + * Check - pager box is visible or not + * + * @return boolean + */ + protected function isPagerVisible() + { + return false; + } + + // {{{ Search + + /** + * Return search parameters. + * + * @return array + */ + static public function getSearchParams() + { + return array(); + } + + /** + * Return params list to use for search + * TODO refactor + * + * @return \XLite\Core\CommonCell + */ + protected function getSearchCondition() + { + $result = parent::getSearchCondition(); + + foreach (static::getSearchParams() as $modelParam => $requestParam) { + $paramValue = $this->getParam($requestParam); + + if ('' !== $paramValue && 0 !== $paramValue) { + $result->$modelParam = $paramValue; + } + } + + $result->attribute = $this->getAttribute(); + + return $result; + } + + // }}} + +} diff --git a/src/classes/XLite/View/ItemsList/Model/ProductClass.php b/src/classes/XLite/View/ItemsList/Model/ProductClass.php new file mode 100644 index 0000000000..102fbc543c --- /dev/null +++ b/src/classes/XLite/View/ItemsList/Model/ProductClass.php @@ -0,0 +1,187 @@ + + * @copyright Copyright (c) 2011-2012 Creative Development LLC . All rights reserved + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + * @link http://www.litecommerce.com/ + */ + +namespace XLite\View\ItemsList\Model; + +/** + * Product classes items list + * + */ +class ProductClass extends \XLite\View\ItemsList\Model\Table +{ + /** + * Get a list of CSS files required to display the widget properly + * + * @return array + */ + public function getCSSFiles() + { + $list = parent::getCSSFiles(); + + $list[] = 'product_classes/style.css'; + + return $list; + } + + /** + * Define columns structure + * + * @return array + */ + protected function defineColumns() + { + return array( + 'name' => array( + static::COLUMN_CLASS => 'XLite\View\FormField\Inline\Input\Text\ProductClass', + static::COLUMN_PARAMS => array('required' => true), + static::COLUMN_MAIN => true, + ), + 'attributes' => array( + static::COLUMN_TEMPLATE => 'product_classes/parts/edit_attributes.tpl', + ), + ); + } + + /** + * Define repository name + * + * @return string + */ + protected function defineRepositoryName() + { + return 'XLite\Model\ProductClass'; + } + + /** + * Get create entity URL + * + * @return string + */ + protected function getCreateURL() + { + return \XLite\Core\Converter::buildUrl('product_class'); + } + + /** + * Get create button label + * + * @return string + */ + protected function getCreateButtonLabel() + { + return 'New product class'; + } + + /** + * Inline creation mechanism position + * + * @return integer + */ + protected function isInlineCreation() + { + return static::CREATE_INLINE_TOP; + } + + + // {{{ Behaviors + + /** + * Mark list as removable + * + * @return boolean + */ + protected function isRemoved() + { + return true; + } + + /** + * Mark list as sortable + * + * @return integer + */ + protected function getSortableType() + { + return static::SORT_TYPE_MOVE; + } + + // }}} + + /** + * Get container class + * + * @return string + */ + protected function getContainerClass() + { + return parent::getContainerClass() . ' product_classes'; + } + + /** + * Get panel class + * + * @return \XLite\View\Base\FormStickyPanel + */ + protected function getPanelClass() + { + return 'XLite\View\StickyPanel\ItemsList\ProductClass'; + } + + + // {{{ Search + + /** + * Return search parameters. + * + * @return array + */ + static public function getSearchParams() + { + return array(); + } + + /** + * Return params list to use for search + * + * @return \XLite\Core\CommonCell + */ + protected function getSearchCondition() + { + $result = parent::getSearchCondition(); + + foreach (static::getSearchParams() as $modelParam => $requestParam) { + $paramValue = $this->getParam($requestParam); + + if ('' !== $paramValue && 0 !== $paramValue) { + $result->$modelParam = $paramValue; + } + } + + return $result; + } + + // }}} + +} diff --git a/src/classes/XLite/View/ItemsList/Model/Table.php b/src/classes/XLite/View/ItemsList/Model/Table.php index ad309227a6..bbd2d8bd49 100644 --- a/src/classes/XLite/View/ItemsList/Model/Table.php +++ b/src/classes/XLite/View/ItemsList/Model/Table.php @@ -149,7 +149,7 @@ protected function getColumns() /** * Returnd columns count - * + * * @return integer */ protected function getColumnsCount() @@ -159,7 +159,7 @@ protected function getColumnsCount() /** * Check - table header is visible or not - * + * * @return boolean */ protected function isTableHeaderVisible() @@ -296,8 +296,8 @@ protected function getFieldObjects() } /** - * Get switcher field - * + * Get switcher field + * * @return array */ protected function getSwitcherField() @@ -310,8 +310,8 @@ protected function getSwitcherField() } /** - * Get sort field - * + * Get sort field + * * @return array */ protected function getSortField() @@ -607,11 +607,15 @@ protected function getLeftActions() $list[] = 'items_list/model/table/parts/switcher.tpl'; } + if ($this->isDefault()) { + $list[] = 'items_list/model/table/parts/default.tpl'; + } + return $list; } /** - * Get right actions tempaltes + * Get right actions templates * * @return array */ @@ -628,9 +632,9 @@ protected function getRightActions() /** * Check - remove entity or not - * + * * @param \XLite\Model\AEntity $entity Entity - * + * * @return boolean */ protected function isAllowEntityRemove(\XLite\Model\AEntity $entity) @@ -638,6 +642,18 @@ protected function isAllowEntityRemove(\XLite\Model\AEntity $entity) return true; } + /** + * Check - switch entity or not + * + * @param \XLite\Model\AEntity $entity Entity + * + * @return boolean + */ + protected function isAllowEntitySwitch(\XLite\Model\AEntity $entity) + { + return (bool)$this->getSwitcherField(); + } + // }}} // {{{ Inherited methods @@ -710,9 +726,9 @@ protected function removeEntity(\XLite\Model\AEntity $entity) /** * Check - specified column is sorted or not - * + * * @param array $column COlumn - * + * * @return boolean */ protected function isColumnSorted(array $column) @@ -724,9 +740,9 @@ protected function isColumnSorted(array $column) /** * Get next sort direction - * + * * @param array $column Column - * + * * @return string */ protected function getSortDirectionNext(array $column) @@ -742,10 +758,10 @@ protected function getSortDirectionNext(array $column) } /** - * Get sort link class - * + * Get sort link class + * * @param array $column Column - * + * * @return string */ protected function getSortLinkClass(array $column) @@ -764,7 +780,7 @@ protected function getSortLinkClass(array $column) /** * Check - search-in-head mechanism is available or not - * + * * @return boolean */ protected function isHeadSearchVisible() @@ -783,9 +799,9 @@ protected function isHeadSearchVisible() /** * Check - specified column has search widget or not - * + * * @param array $column Column info - * + * * @return boolean */ protected function isSearchColumn(array $column) @@ -795,10 +811,10 @@ protected function isSearchColumn(array $column) /** - * Get search cell class - * + * Get search cell class + * * @param array $column ____param_comment____ - * + * * @return void */ protected function getSearchCellClass(array $column) @@ -808,5 +824,31 @@ protected function getSearchCellClass(array $column) } // }}} + + /** + * Check if the column template is used for widget displaying + * + * @param array $column + * @param \XLite\Model\AEntity $entity + * + * @return boolean + */ + protected function isTemplateColumnVisible(array $column, \XLite\Model\AEntity $entity) + { + return isset($column[static::COLUMN_TEMPLATE]); + } + + /** + * Check if the simple class is used for widget displaying + * + * @param array $column + * @param \XLite\Model\AEntity $entity + * + * @return boolean + */ + protected function isClassColumnVisible(array $column, \XLite\Model\AEntity $entity) + { + return !isset($column[static::COLUMN_TEMPLATE]); + } } diff --git a/src/classes/XLite/View/Model/AModel.php b/src/classes/XLite/View/Model/AModel.php index d0587d1ca3..dbce3f3267 100644 --- a/src/classes/XLite/View/Model/AModel.php +++ b/src/classes/XLite/View/Model/AModel.php @@ -1205,8 +1205,6 @@ protected function performActionDelete() return $this->getModelObject()->delete(); } - - /** * Retrieve property from the model object * @@ -1216,16 +1214,10 @@ protected function performActionDelete() */ protected function getModelObjectValue($name) { - $methodName = 'get' . \XLite\Core\Converter::getInstance()->convertToCamelCase($name); + $model = $this->getModelObject(); + $method = 'get' . \XLite\Core\Converter::convertToCamelCase($name); - $value = null; - - if (method_exists($this->getModelObject(), $methodName)) { - // Call the corresponded method - $value = $this->getModelObject()->$methodName(); - } - - return $value; + return method_exists($model, $method) ? $model->$method() : $model->getterProperty($name); } /** diff --git a/src/classes/XLite/View/Model/Address/Address.php b/src/classes/XLite/View/Model/Address/Address.php index 2e405d601e..e9a7dd2444 100644 --- a/src/classes/XLite/View/Model/Address/Address.php +++ b/src/classes/XLite/View/Model/Address/Address.php @@ -42,86 +42,7 @@ class Address extends \XLite\View\Model\AModel * * @var array */ - protected $addressSchema = array( - 'title' => array( - self::SCHEMA_CLASS => '\XLite\View\FormField\Select\Title', - self::SCHEMA_LABEL => 'Title', - self::SCHEMA_REQUIRED => false, - \XLite\View\FormField\AFormField::PARAM_WRAPPER_CLASS => 'address-title', - ), - 'firstname' => array( - self::SCHEMA_CLASS => '\XLite\View\FormField\Input\Text', - self::SCHEMA_LABEL => 'First name', - self::SCHEMA_REQUIRED => true, - \XLite\View\FormField\AFormField::PARAM_WRAPPER_CLASS => 'address-firstname', - self::SCHEMA_MODEL_ATTRIBUTES => array( - \XLite\View\FormField\Input\Base\String::PARAM_MAX_LENGTH => 'length', - ), - ), - 'lastname' => array( - self::SCHEMA_CLASS => '\XLite\View\FormField\Input\Text', - self::SCHEMA_LABEL => 'Last name', - self::SCHEMA_REQUIRED => true, - \XLite\View\FormField\AFormField::PARAM_WRAPPER_CLASS => 'address-lastname', - self::SCHEMA_MODEL_ATTRIBUTES => array( - \XLite\View\FormField\Input\Base\String::PARAM_MAX_LENGTH => 'length', - ), - ), - 'street' => array( - self::SCHEMA_CLASS => '\XLite\View\FormField\Input\Text', - self::SCHEMA_LABEL => 'Address', - self::SCHEMA_REQUIRED => true, - \XLite\View\FormField\AFormField::PARAM_WRAPPER_CLASS => 'address-street', - self::SCHEMA_MODEL_ATTRIBUTES => array( - \XLite\View\FormField\Input\Base\String::PARAM_MAX_LENGTH => 'length', - ), - ), - 'country_code' => array( - self::SCHEMA_CLASS => '\XLite\View\FormField\Select\Country', - self::SCHEMA_LABEL => 'Country', - self::SCHEMA_REQUIRED => true, - \XLite\View\FormField\AFormField::PARAM_WRAPPER_CLASS => 'address-country', - ), - 'state_id' => array( - self::SCHEMA_CLASS => '\XLite\View\FormField\Select\State', - self::SCHEMA_LABEL => 'State', - self::SCHEMA_REQUIRED => true, - \XLite\View\FormField\AFormField::PARAM_WRAPPER_CLASS => 'address-state', - ), - 'custom_state' => array( - self::SCHEMA_CLASS => '\XLite\View\FormField\Input\Text', - self::SCHEMA_LABEL => 'State', - self::SCHEMA_REQUIRED => false, - \XLite\View\FormField\AFormField::PARAM_WRAPPER_CLASS => 'address-customer-state', - ), - 'city' => array( - self::SCHEMA_CLASS => '\XLite\View\FormField\Input\Text', - self::SCHEMA_LABEL => 'City', - self::SCHEMA_REQUIRED => true, - \XLite\View\FormField\AFormField::PARAM_WRAPPER_CLASS => 'address-city', - self::SCHEMA_MODEL_ATTRIBUTES => array( - \XLite\View\FormField\Input\Base\String::PARAM_MAX_LENGTH => 'length', - ), - ), - 'zipcode' => array( - self::SCHEMA_CLASS => '\XLite\View\FormField\Input\Text', - self::SCHEMA_LABEL => 'Zip code', - self::SCHEMA_REQUIRED => true, - \XLite\View\FormField\AFormField::PARAM_WRAPPER_CLASS => 'address-zipcode', - self::SCHEMA_MODEL_ATTRIBUTES => array( - \XLite\View\FormField\Input\Base\String::PARAM_MAX_LENGTH => 'length', - ), - ), - 'phone' => array( - self::SCHEMA_CLASS => '\XLite\View\FormField\Input\Text', - self::SCHEMA_LABEL => 'Phone', - self::SCHEMA_REQUIRED => true, - \XLite\View\FormField\AFormField::PARAM_WRAPPER_CLASS => 'address-phone', - self::SCHEMA_MODEL_ATTRIBUTES => array( - \XLite\View\FormField\Input\Base\String::PARAM_MAX_LENGTH => 'length', - ), - ), - ); + protected $addressSchema = array(); /** * Address instance @@ -145,6 +66,19 @@ public function getAddressSchema() $result[$addressId . '_' . $key] = $data; } + foreach (\XLite\Core\Database::getRepo('XLite\Model\AddressField')->findAllEnabled() as $field) { + + $result[$addressId . '_' . $field->getServiceName()] = array( + static::SCHEMA_CLASS => $field->getSchemaClass(), + static::SCHEMA_LABEL => $field->getName(), + static::SCHEMA_REQUIRED => $field->getRequired(), + static::SCHEMA_MODEL_ATTRIBUTES => array( + \XLite\View\FormField\Input\Base\String::PARAM_MAX_LENGTH => 'length', + ), + \XLite\View\FormField\AFormField::PARAM_WRAPPER_CLASS => 'address-' . $field->getServiceName(), + ); + } + return $result; } @@ -239,8 +173,6 @@ protected function getDefaultModelObject() $this->address->setProfile($profile); } } - - $this->address->setZipcode(\XLite\Core\Config::getInstance()->General->default_zipcode); } } @@ -280,10 +212,12 @@ protected function setStateSelectorIds(array &$fields) { $addressId = $this->getAddressId(); - $fields[$addressId . '_country_code']->setStateSelectorIds( - $fields[$addressId . '_state_id']->getFieldId(), - $fields[$addressId . '_custom_state']->getFieldId() - ); + if ($fields[$addressId . '_state_id'] && $fields[$addressId . '_custom_state']) { + $fields[$addressId . '_country_code']->setStateSelectorIds( + $fields[$addressId . '_state_id']->getFieldId(), + $fields[$addressId . '_custom_state']->getFieldId() + ); + } } /** @@ -300,16 +234,6 @@ protected function getModelObjectValue($name) return parent::getModelObjectValue($name); } - /** - * Some JavaScript code to insert - * - * @return string - */ - protected function getTopInlineJSCode() - { - return $this->getWidget(array(), '\XLite\View\JS\StatesList')->getContent(); - } - /** * Return text for the "Submit" button * @@ -393,7 +317,7 @@ protected function validateFields(array $data, $section) { $this->prepareDataToValidate($data); - parent::validateFields($data); + parent::validateFields($data, $section); } /** diff --git a/src/classes/XLite/View/Model/Address/Field.php b/src/classes/XLite/View/Model/Address/Field.php new file mode 100644 index 0000000000..5dd059d974 --- /dev/null +++ b/src/classes/XLite/View/Model/Address/Field.php @@ -0,0 +1,155 @@ + + * @copyright Copyright (c) 2011-2012 Creative Development LLC . All rights reserved + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + * @link http://www.litecommerce.com/ + */ + +namespace XLite\View\Model\Address; + +/** + * Field + * + */ +class Field extends \XLite\View\Model\AModel +{ + /** + * Shema default + * + * @var array + */ + protected $schemaDefault = array( + 'name' => array( + self::SCHEMA_CLASS => 'XLite\View\FormField\Input\Text', + self::SCHEMA_LABEL => 'Name of address field', + self::SCHEMA_REQUIRED => true, + ), + 'serviceName' => array( + self::SCHEMA_CLASS => 'XLite\View\FormField\Input\Text\ServiceName', + self::SCHEMA_LABEL => 'Service name of address field', + self::SCHEMA_REQUIRED => true, + ), + ); + + /** + * Return current model ID + * + * @return integer + */ + public function getModelId() + { + return \XLite\Core\Request::getInstance()->id; + } + + /** + * Return fields list by the corresponding schema + * + * @return array + */ + protected function getFormFieldsForSectionDefault() + { + return $this->getFieldsBySchema($this->schemaDefault); + } + + /** + * This object will be used if another one is not pased + * + * @return \XLite\Model\AddressField + */ + protected function getDefaultModelObject() + { + $model = $this->getModelId() + ? \XLite\Core\Database::getRepo('XLite\Model\AddressField')->find($this->getModelId()) + : null; + + return $model ?: new \XLite\Model\AddressField(); + } + + /** + * Return name of web form widget class + * + * @return string + */ + protected function getFormClass() + { + return '\XLite\View\Form\AddressField'; + } + + /** + * Return list of the "Button" widgets + * + * @return array + */ + protected function getFormButtons() + { + $result = parent::getFormButtons(); + + $label = $this->getModelObject()->getId() ? 'Update' : 'Create'; + + $result['submit'] = new \XLite\View\Button\Submit( + array( + \XLite\View\Button\AButton::PARAM_LABEL => $label, + \XLite\View\Button\AButton::PARAM_STYLE => 'action', + ) + ); + + return $result; + } + + /** + * Populate model object properties by the passed data + * + * @param array $data Data to set + * + * @return void + */ + protected function setModelProperties(array $data) + { + parent::setModelProperties($data); + } + + /** + * Add top message + * + * @return void + */ + protected function addDataSavedTopMessage() + { + if ($this->getModelObject()->getId()) { + \XLite\Core\TopMessage::addInfo('The address field has been updated'); + } else { + \XLite\Core\TopMessage::addInfo('The address field has been added'); + } + } + + /** + * Retrieve property from the model object + * + * @param mixed $name Field/property name + * + * @return mixed + */ + protected function getModelObjectValue($name) + { + return parent::getModelObjectValue($name); + } + +} diff --git a/src/classes/XLite/View/Model/Attribute.php b/src/classes/XLite/View/Model/Attribute.php new file mode 100644 index 0000000000..57e3a35c80 --- /dev/null +++ b/src/classes/XLite/View/Model/Attribute.php @@ -0,0 +1,209 @@ + + * @copyright Copyright (c) 2011-2012 Creative Development LLC . All rights reserved + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + * @link http://www.litecommerce.com/ + */ + +namespace XLite\View\Model; + +/** + * Attribute view model + * + */ +class Attribute extends \XLite\View\Model\AModel +{ + /** + * Shema default + * + * @var array + */ + protected $schemaDefault = array( + 'name' => array( + self::SCHEMA_CLASS => 'XLite\View\FormField\Input\Text', + self::SCHEMA_LABEL => 'Attribute', + self::SCHEMA_REQUIRED => true, + ), + 'attribute_group' => array( + self::SCHEMA_CLASS => 'XLite\View\FormField\Select\AttributeGroups', + self::SCHEMA_LABEL => 'Attribute group', + self::SCHEMA_REQUIRED => false, + ), + 'type' => array( + self::SCHEMA_CLASS => 'XLite\View\FormField\Select\AttributeTypes', + self::SCHEMA_LABEL => 'Type', + self::SCHEMA_REQUIRED => false, + ), + ); + + /** + * Return current model ID + * + * @return integer + */ + public function getModelId() + { + return \XLite\Core\Request::getInstance()->id; + } + + /** + * Return fields list by the corresponding schema + * + * @return array + */ + protected function getFormFieldsForSectionDefault() + { + if ($this->getModelObject()->getId()) { + $this->schemaDefault['type'][self::SCHEMA_COMMENT] = 'Before editing attriubutes specific for the chosen type you should save the changes'; + + if ( + $this->getModelObject()->getAttributeValuesCount() + || $this->getModelObject()->getProductClass()->getProductsCount() + ) { + $this->schemaDefault['type'][self::SCHEMA_COMMENT] .= '

Changing the type of a product attribute after having defined values for this attribute for some products will result in losing the defined attribute values'; + } + + if ( + \XLite\Model\Attribute::TYPE_NUMBER == $this->getModelObject()->getType() + ) { + $this->schemaDefault['decimals'] = array( + self::SCHEMA_CLASS => 'XLite\View\FormField\Select\Decimals', + self::SCHEMA_LABEL => 'Decimals', + self::SCHEMA_REQUIRED => false, + \XLite\View\FormField\AFormField::PARAM_WRAPPER_CLASS => 'edit-decimals custom-field', + ); + $this->schemaDefault['unit'] = array( + self::SCHEMA_CLASS => 'XLite\View\FormField\Input\Text', + self::SCHEMA_LABEL => 'Unit', + self::SCHEMA_REQUIRED => false, + self::SCHEMA_COMMENT => '(suffix)', + \XLite\View\FormField\AFormField::PARAM_WRAPPER_CLASS => 'edit-unit custom-field', + ); + } + + if ( + \XLite\Model\Attribute::TYPE_NUMBER == $this->getModelObject()->getType() + || \XLite\Model\Attribute::TYPE_CHECKBOX == $this->getModelObject()->getType() + || \XLite\Model\Attribute::TYPE_TEXT == $this->getModelObject()->getType() + ) { + $this->schemaDefault['default_value'] = array( + self::SCHEMA_CLASS => $this->getModelObject()->getWidgetClass(), + self::SCHEMA_LABEL => 'Default value', + self::SCHEMA_REQUIRED => false, + 'rows' => 1, + 'maxHeight' => 100, + \XLite\View\FormField\AFormField::PARAM_WRAPPER_CLASS => 'custom-field', + ); + } + + if ( + \XLite\Model\Attribute::TYPE_SELECT == $this->getModelObject()->getType() + ) { + $this->schemaDefault['values'] = array( + self::SCHEMA_CLASS => 'XLite\View\FormField\ItemsList', + self::SCHEMA_LABEL => 'Allowed attribute values and default one', + self::SCHEMA_REQUIRED => false, + \XLite\View\FormField\ItemsList::PARAM_LIST_CLASS => 'XLite\View\ItemsList\Model\AttributeOption', + \XLite\View\FormField\AFormField::PARAM_WRAPPER_CLASS => 'custom-field', + ); + } + } + + return $this->getFieldsBySchema($this->schemaDefault); + } + + /** + * Populate model object properties by the passed data + * + * @param array $data Data to set + * + * @return void + */ + protected function setModelProperties(array $data) + { + $data['attribute_group'] = \XLite\Core\Database::getRepo('XLite\Model\AttributeGroup')->find($data['attribute_group']); + + parent::setModelProperties($data); + + $this->getModelObject()->setProductClass($this->getProductClass()); + } + + /** + * This object will be used if another one is not pased + * + * @return \XLite\Model\Attribute + */ + protected function getDefaultModelObject() + { + $model = $this->getModelId() + ? \XLite\Core\Database::getRepo('XLite\Model\Attribute')->find($this->getModelId()) + : null; + + return $model ?: new \XLite\Model\Attribute; + } + + /** + * Return name of web form widget class + * + * @return string + */ + protected function getFormClass() + { + return '\XLite\View\Form\Model\Attribute'; + } + + /** + * Return list of the "Button" widgets + * + * @return array + */ + protected function getFormButtons() + { + $result = parent::getFormButtons(); + + $label = $this->getModelObject()->getId() ? 'Save changes' : 'Next'; + + $result['submit'] = new \XLite\View\Button\Submit( + array( + \XLite\View\Button\AButton::PARAM_LABEL => $label, + \XLite\View\Button\AButton::PARAM_STYLE => 'action', + ) + ); + + return $result; + } + + /** + * Add top message + * + * @return void + */ + protected function addDataSavedTopMessage() + { + if ('create' != $this->currentAction) { + \XLite\Core\TopMessage::addInfo('The attribute has been updated'); + + } else { + \XLite\Core\TopMessage::addInfo('The attribute has been added'); + } + } + +} diff --git a/src/classes/XLite/View/Model/AttributeGroup.php b/src/classes/XLite/View/Model/AttributeGroup.php new file mode 100644 index 0000000000..3449627ffb --- /dev/null +++ b/src/classes/XLite/View/Model/AttributeGroup.php @@ -0,0 +1,122 @@ + + * @copyright Copyright (c) 2011-2012 Creative Development LLC . All rights reserved + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + * @link http://www.litecommerce.com/ + */ + +namespace XLite\View\Model; + +/** + * Attribute group view model + * + */ +class AttributeGroup extends \XLite\View\Model\AModel +{ + /** + * Shema default + * + * @var array + */ + protected $schemaDefault = array( + 'position' => array( + self::SCHEMA_CLASS => 'XLite\View\FormField\Input\Text\Integer', + self::SCHEMA_LABEL => 'Position', + self::SCHEMA_REQUIRED => false, + ), + 'name' => array( + self::SCHEMA_CLASS => 'XLite\View\FormField\Input\Text', + self::SCHEMA_LABEL => 'Name', + self::SCHEMA_REQUIRED => false, + ), + ); + + /** + * Return current model ID + * + * @return integer + */ + public function getModelId() + { + return \XLite\Core\Request::getInstance()->id; + } + + /** + * This object will be used if another one is not pased + * + * @return \XLite\Model\AttributeGroup + */ + protected function getDefaultModelObject() + { + $model = $this->getModelId() + ? \XLite\Core\Database::getRepo('XLite\Model\AttributeGroup')->find($this->getModelId()) + : null; + + return $model ?: new \XLite\Model\AttributeGroup; + } + + /** + * Return name of web form widget class + * + * @return string + */ + protected function getFormClass() + { + return '\XLite\View\Form\Model\AttributeGroup'; + } + + /** + * Return list of the "Button" widgets + * + * @return array + */ + protected function getFormButtons() + { + $result = parent::getFormButtons(); + + $label = $this->getModelObject()->getId() ? 'Update' : 'Create'; + + $result['submit'] = new \XLite\View\Button\Submit( + array( + \XLite\View\Button\AButton::PARAM_LABEL => $label, + \XLite\View\Button\AButton::PARAM_STYLE => 'action', + ) + ); + + return $result; + } + + /** + * Add top message + * + * @return void + */ + protected function addDataSavedTopMessage() + { + if ('create' != $this->currentAction) { + \XLite\Core\TopMessage::addInfo('The attribute group has been updated'); + + } else { + \XLite\Core\TopMessage::addInfo('The attribute group has been added'); + } + } + +} \ No newline at end of file diff --git a/src/classes/XLite/View/Model/AttributeOption.php b/src/classes/XLite/View/Model/AttributeOption.php new file mode 100644 index 0000000000..06804f3909 --- /dev/null +++ b/src/classes/XLite/View/Model/AttributeOption.php @@ -0,0 +1,122 @@ + + * @copyright Copyright (c) 2011-2012 Creative Development LLC . All rights reserved + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + * @link http://www.litecommerce.com/ + */ + +namespace XLite\View\Model; + +/** + * Attribute option view model + * + */ +class AttributeOption extends \XLite\View\Model\AModel +{ + /** + * Shema default + * + * @var array + */ + protected $schemaDefault = array( + 'default' => array( + self::SCHEMA_CLASS => 'XLite\View\FormField\Input\Checkbox\Enabled', + self::SCHEMA_LABEL => 'Default', + self::SCHEMA_REQUIRED => false, + ), + 'name' => array( + self::SCHEMA_CLASS => 'XLite\View\FormField\Input\Text', + self::SCHEMA_LABEL => 'Name', + self::SCHEMA_REQUIRED => false, + ), + ); + + /** + * Return current model ID + * + * @return integer + */ + public function getModelId() + { + return \XLite\Core\Request::getInstance()->id; + } + + /** + * This object will be used if another one is not pased + * + * @return \XLite\Model\AttributeOption + */ + protected function getDefaultModelObject() + { + $model = $this->getModelId() + ? \XLite\Core\Database::getRepo('XLite\Model\AttributeOption')->find($this->getModelId()) + : null; + + return $model ?: new \XLite\Model\AttributeOption; + } + + /** + * Return name of web form widget class + * + * @return string + */ + protected function getFormClass() + { + return '\XLite\View\Form\Model\AttributeOption'; + } + + /** + * Return list of the "Button" widgets + * + * @return array + */ + protected function getFormButtons() + { + $result = parent::getFormButtons(); + + $label = $this->getModelObject()->getId() ? 'Update' : 'Create'; + + $result['submit'] = new \XLite\View\Button\Submit( + array( + \XLite\View\Button\AButton::PARAM_LABEL => $label, + \XLite\View\Button\AButton::PARAM_STYLE => 'action', + ) + ); + + return $result; + } + + /** + * Add top message + * + * @return void + */ + protected function addDataSavedTopMessage() + { + if ('create' != $this->currentAction) { + \XLite\Core\TopMessage::addInfo('The attribute option has been updated'); + + } else { + \XLite\Core\TopMessage::addInfo('The attribute option has been added'); + } + } + +} \ No newline at end of file diff --git a/src/classes/XLite/View/Model/ProductClass.php b/src/classes/XLite/View/Model/ProductClass.php new file mode 100644 index 0000000000..9c7f902db8 --- /dev/null +++ b/src/classes/XLite/View/Model/ProductClass.php @@ -0,0 +1,117 @@ + + * @copyright Copyright (c) 2011-2012 Creative Development LLC . All rights reserved + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + * @link http://www.litecommerce.com/ + */ + +namespace XLite\View\Model; + +/** + * Product class view model + * + */ +class ProductClass extends \XLite\View\Model\AModel +{ + /** + * Shema default + * + * @var array + */ + protected $schemaDefault = array( + 'name' => array( + self::SCHEMA_CLASS => 'XLite\View\FormField\Input\Text', + self::SCHEMA_LABEL => 'Name', + self::SCHEMA_REQUIRED => false, + ), + ); + + /** + * Return current model ID + * + * @return integer + */ + public function getModelId() + { + return \XLite\Core\Request::getInstance()->id; + } + + /** + * This object will be used if another one is not pased + * + * @return \XLite\Model\ProductClass + */ + protected function getDefaultModelObject() + { + $model = $this->getModelId() + ? \XLite\Core\Database::getRepo('XLite\Model\ProductClass')->find($this->getModelId()) + : null; + + return $model ?: new \XLite\Model\ProductClass; + } + + /** + * Return name of web form widget class + * + * @return string + */ + protected function getFormClass() + { + return '\XLite\View\Form\Model\ProductClass'; + } + + /** + * Return list of the "Button" widgets + * + * @return array + */ + protected function getFormButtons() + { + $result = parent::getFormButtons(); + + $label = $this->getModelObject()->getId() ? 'Update' : 'Create'; + + $result['submit'] = new \XLite\View\Button\Submit( + array( + \XLite\View\Button\AButton::PARAM_LABEL => $label, + \XLite\View\Button\AButton::PARAM_STYLE => 'action', + ) + ); + + return $result; + } + + /** + * Add top message + * + * @return void + */ + protected function addDataSavedTopMessage() + { + if ('create' != $this->currentAction) { + \XLite\Core\TopMessage::addInfo('The product class has been updated'); + + } else { + \XLite\Core\TopMessage::addInfo('The product class has been added'); + } + } + +} \ No newline at end of file diff --git a/src/classes/XLite/View/Order/Details/Admin/Info.php b/src/classes/XLite/View/Order/Details/Admin/Info.php index b090d62406..f57b5f9165 100644 --- a/src/classes/XLite/View/Order/Details/Admin/Info.php +++ b/src/classes/XLite/View/Order/Details/Admin/Info.php @@ -268,6 +268,6 @@ protected function hasPaymentTransactionSums() } // }}} - + } diff --git a/src/classes/XLite/View/Product/Details/AAttributes.php b/src/classes/XLite/View/Product/Details/AAttributes.php new file mode 100644 index 0000000000..ca2e9b76bf --- /dev/null +++ b/src/classes/XLite/View/Product/Details/AAttributes.php @@ -0,0 +1,106 @@ + + * @copyright Copyright (c) 2011-2012 Creative Development LLC . All rights reserved + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + * @link http://www.litecommerce.com/ + */ + +namespace XLite\View\Product\Details; + +/** + * Product attributes + * + */ +abstract class AAttributes extends \XLite\View\AView +{ + /** + * Widget param names + */ + const PARAM_GROUP = 'group'; + + /** + * Get step title + * + * @return string + */ + public function getTitle() + { + return $this->getAttributeGroup() + ? $this->getAttributeGroup()->getName() + : null; + } + + /** + * Check if widget is visible + * + * @return boolean + */ + protected function isVisible() + { + return parent::isVisible() + && $this->getAttributesList(true); + } + + /** + * Define widget params + * + * @return void + */ + protected function defineWidgetParams() + { + parent::defineWidgetParams(); + + $this->widgetParams += array( + self::PARAM_GROUP => new \XLite\Model\WidgetParam\Object( + 'Group', null, false, '\XLite\Model\AttributeGroup' + ), + ); + } + + /** + * Get attribute group + * + * @return \XLite\Model\AttributeGroup + */ + protected function getAttributeGroup() + { + return $this->getParam(static::PARAM_GROUP); + } + + /** + * Get attributes list + * + * @param boolean $countOnly Return items list or only its size OPTIONAL + * + * @return array|integer + */ + protected function getAttributesList($countOnly = false) + { + $cnd = new \XLite\Core\CommonCell; + $cnd->attributeGroup = $this->getAttributeGroup(); + if (!$this->getAttributeGroup()) { + $cnd->product = $this->getProduct(); + } + + return \XLite\Core\Database::getRepo('\XLite\Model\Attribute')->search($cnd, $countOnly); + } + +} diff --git a/src/classes/XLite/View/Product/Details/Admin/Attributes.php b/src/classes/XLite/View/Product/Details/Admin/Attributes.php new file mode 100644 index 0000000000..44d271cf03 --- /dev/null +++ b/src/classes/XLite/View/Product/Details/Admin/Attributes.php @@ -0,0 +1,98 @@ + + * @copyright Copyright (c) 2011-2012 Creative Development LLC . All rights reserved + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + * @link http://www.litecommerce.com/ + */ + +namespace XLite\View\Product\Details\Admin; + +/** + * Product attributes + * + */ +class Attributes extends \XLite\View\Product\Details\AAttributes +{ + /** + * Register CSS files + * + * @return array + */ + public function getCSSFiles() + { + $list = parent::getCSSFiles(); + + $list[] = 'product/attributes/style.css'; + + return $list; + } + + /** + * Return widget default template + * + * @return string + */ + protected function getDefaultTemplate() + { + return 'product/attributes/fields.tpl'; + } + + /** + * Get attributes list + * + * @param boolean $countOnly Return items list or only its size OPTIONAL + * + * @return array|integer + */ + protected function getAttributesList($countOnly = false) + { + $cnd = new \XLite\Core\CommonCell; + $cnd->attributeGroup = $this->getAttributeGroup(); + if (!$this->getAttributeGroup()) { + $cnd->product = $this->getProduct(); + } + + $data = parent::getAttributesList($countOnly); + + if ($countOnly) { + $result = $data; + + } else { + $result = array(); + foreach ($data as $attribute) { + $result[] = $this->getWidget( + array( + 'fieldName' => 'attributeValues[' . $attribute->getId() . ']', + 'label' => $attribute->getName(), + 'maxHeight' => 100, + 'rows' => 1, + 'attribute' => $attribute, + 'comment' => $attribute->getFieldComment(), + 'value' => $attribute->getAttributeValue($this->getProduct()) + ), + $attribute->getWidgetClass() + ); + } + } + + return $result; + } +} diff --git a/src/classes/XLite/View/Product/Details/Customer/Attributes.php b/src/classes/XLite/View/Product/Details/Customer/Attributes.php new file mode 100644 index 0000000000..d5b1b9dbf8 --- /dev/null +++ b/src/classes/XLite/View/Product/Details/Customer/Attributes.php @@ -0,0 +1,103 @@ + + * @copyright Copyright (c) 2011-2012 Creative Development LLC . All rights reserved + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + * @link http://www.litecommerce.com/ + */ + +namespace XLite\View\Product\Details\Customer; + +/** + * Product attributes + * + */ +class Attributes extends \XLite\View\Product\Details\AAttributes +{ + /** + * Attributes + * + * @var array + */ + protected $attributes; + + /** + * Register CSS files + * + * @return array + */ + public function getAttrList() + { + if (is_null($this->attributes)) { + $this->attributes = array(); + foreach ($this->getAttributesList() as $a) { + $value = $a->getAttributeValue($this->getProduct(), true); + if ($value) { + $this->attributes[] = array( + 'name' => $a->getName(), + 'value' => htmlspecialchars($value), + 'class' => $this->getFieldClass($a, $value) + ); + } + } + } + + return $this->attributes; + } + + /** + * Return field class + * + * @param \XLite\Model\Attribute $attribute Attribute + * @param string $value Value + * + * @return string + */ + protected function getFieldClass(\XLite\Model\Attribute $attribute, $value) + { + $class = strtolower($attribute->getTypes($attribute->getType())); + if (\XLite\Model\Attribute::TYPE_CHECKBOX == $attribute->getType()) { + $class .= ' ' . (static::t('yes') == $value ? 'checked' : 'no-checked'); + } + + return $class; + } + + /** + * Return widget default template + * + * @return string + */ + protected function getDefaultTemplate() + { + return 'product/details/parts/attribute.tpl'; + } + + /** + * Check if widget is visible + * + * @return boolean + */ + protected function isVisible() + { + return parent::isVisible() + && $this->getAttrList(); + } +} diff --git a/src/classes/XLite/View/Product/Details/Customer/Page/APage.php b/src/classes/XLite/View/Product/Details/Customer/Page/APage.php index acc1458a85..6c5b1c925f 100644 --- a/src/classes/XLite/View/Product/Details/Customer/Page/APage.php +++ b/src/classes/XLite/View/Product/Details/Customer/Page/APage.php @@ -135,6 +135,15 @@ protected function defineTabs() ); } + if ( + $this->getProduct()->getAttrSepTab() + && $this->getProduct()->getAttributesCount() + ) { + $list['Specification'] = array( + 'list' => 'product.details.page.tab.attributes' + ); + } + return $list; } diff --git a/src/classes/XLite/View/ProductClass.php b/src/classes/XLite/View/ProductClass.php new file mode 100644 index 0000000000..299c2abe42 --- /dev/null +++ b/src/classes/XLite/View/ProductClass.php @@ -0,0 +1,56 @@ + + * @copyright Copyright (c) 2011-2012 Creative Development LLC . All rights reserved + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + * @link http://www.litecommerce.com/ + */ + +namespace XLite\View; + +/** + * Product class page view + * + * + * @ListChild (list="admin.center", zone="admin") + */ +class ProductClass extends \XLite\View\AView +{ + /** + * Return list of allowed targets + * + * @return array + */ + public static function getAllowedTargets() + { + return array_merge(parent::getAllowedTargets(), array('product_class')); + } + + /** + * Return widget default template + * + * @return string + */ + protected function getDefaultTemplate() + { + return 'product_class/body.tpl'; + } + +} diff --git a/src/classes/XLite/View/ProductClasses.php b/src/classes/XLite/View/ProductClasses.php new file mode 100644 index 0000000000..536b92a2d7 --- /dev/null +++ b/src/classes/XLite/View/ProductClasses.php @@ -0,0 +1,66 @@ + + * @copyright Copyright (c) 2011-2012 Creative Development LLC . All rights reserved + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + * @link http://www.litecommerce.com/ + */ + +namespace XLite\View; + +/** + * Product classes page view + * + * + * @ListChild (list="admin.center", zone="admin") + */ +class ProductClasses extends \XLite\View\AView +{ + /** + * Return list of allowed targets + * + * @return array + */ + public static function getAllowedTargets() + { + return array_merge(parent::getAllowedTargets(), array('product_classes')); + } + + /** + * Return widget default template + * + * @return string + */ + protected function getDefaultTemplate() + { + return 'product_classes/body.tpl'; + } + + /** + * Check - search box is visible or not + * + * @return boolean + */ + protected function isSearchVisible() + { + return 0 < \XLite\Core\Database::getRepo('XLite\Model\ProductClass')->count(); + } + +} \ No newline at end of file diff --git a/src/classes/XLite/View/ShippingEstimate.php b/src/classes/XLite/View/ShippingEstimate.php index bd31889988..f651a583c8 100644 --- a/src/classes/XLite/View/ShippingEstimate.php +++ b/src/classes/XLite/View/ShippingEstimate.php @@ -79,6 +79,21 @@ protected function getCountries() ->findByEnabled(true); } + /** + * Check if the enabled address field with the given name exists + * + * @param string $fieldName + * + * @return boolean + */ + protected function hasField($fieldName) + { + return (bool) \XLite\Core\Database::getRepo('XLite\Model\AddressField')->findOneBy(array( + 'serviceName' => $fieldName, + 'enabled' => true, + )); + } + /** * Get selected country code * diff --git a/src/classes/XLite/View/JS/AJS.php b/src/classes/XLite/View/StickyPanel/ItemsList/Attribute.php similarity index 85% rename from src/classes/XLite/View/JS/AJS.php rename to src/classes/XLite/View/StickyPanel/ItemsList/Attribute.php index f21566721c..5621f22647 100644 --- a/src/classes/XLite/View/JS/AJS.php +++ b/src/classes/XLite/View/StickyPanel/ItemsList/Attribute.php @@ -23,12 +23,12 @@ * @link http://www.litecommerce.com/ */ -namespace XLite\View\JS; +namespace XLite\View\StickyPanel\ItemsList; /** - * \XLite\View\JS\AJS + * Attributes items list's sticky panel * */ -abstract class AJS extends \XLite\View\AView +class Attribute extends \XLite\View\StickyPanel\ItemsListForm { -} +} \ No newline at end of file diff --git a/src/classes/XLite/View/StickyPanel/ItemsList/ProductClass.php b/src/classes/XLite/View/StickyPanel/ItemsList/ProductClass.php new file mode 100644 index 0000000000..2a5c19787f --- /dev/null +++ b/src/classes/XLite/View/StickyPanel/ItemsList/ProductClass.php @@ -0,0 +1,34 @@ + + * @copyright Copyright (c) 2011-2012 Creative Development LLC . All rights reserved + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + * @link http://www.litecommerce.com/ + */ + +namespace XLite\View\StickyPanel\ItemsList; + +/** + * Product classes items list's sticky panel + * + */ +class ProductClass extends \XLite\View\StickyPanel\ItemsListForm +{ +} \ No newline at end of file diff --git a/src/classes/XLite/View/TopMenu.php b/src/classes/XLite/View/TopMenu.php index 3f0acc033b..74fac00e17 100644 --- a/src/classes/XLite/View/TopMenu.php +++ b/src/classes/XLite/View/TopMenu.php @@ -65,6 +65,10 @@ class TopMenu extends \XLite\View\AView 'db_backup' => array( 'db_restore', ), + 'product_classes' => array( + 'product_class', + 'attributes', + ), ); diff --git a/src/classes/XLite/View/TopMenu/Node/Users/AddressFields.php b/src/classes/XLite/View/TopMenu/Node/Users/AddressFields.php new file mode 100644 index 0000000000..83043c7a74 --- /dev/null +++ b/src/classes/XLite/View/TopMenu/Node/Users/AddressFields.php @@ -0,0 +1,49 @@ + + * @copyright Copyright (c) 2011-2012 Creative Development LLC . All rights reserved + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + * @link http://www.litecommerce.com/ + */ + +namespace XLite\View\TopMenu\Node\Users; + +/** + * Address fields management + * + * + * @ListChild (list="menu.users", weight="600", zone="admin") + */ +class AddressFields extends \XLite\View\TopMenu\Node\Users\AUsers +{ + /** + * Define widget parameters + * + * @return void + */ + protected function defineWidgetParams() + { + parent::defineWidgetParams(); + + $this->widgetParams[self::PARAM_TITLE]->setValue(static::t('Address fields')); + $this->widgetParams[self::PARAM_TARGET]->setValue('address_fields'); + } +} + diff --git a/src/skins/admin/en/product_classes/list/main_input.tpl b/src/skins/admin/en/address/field/body.tpl similarity index 68% rename from src/skins/admin/en/product_classes/list/main_input.tpl rename to src/skins/admin/en/address/field/body.tpl index 31fb47d8ef..13840ce996 100644 --- a/src/skins/admin/en/product_classes/list/main_input.tpl +++ b/src/skins/admin/en/address/field/body.tpl @@ -1,7 +1,7 @@ {* vim: set ts=2 sw=2 sts=2 et: *} {** - * Product classes main input widget + * Address field modify * * @author Creative Development LLC * @copyright Copyright (c) 2011-2012 Creative Development LLC . All rights reserved @@ -9,6 +9,4 @@ * @link http://www.litecommerce.com/ *} - - - + diff --git a/src/skins/admin/en/address/field/style.css b/src/skins/admin/en/address/field/style.css new file mode 100644 index 0000000000..05498678e0 --- /dev/null +++ b/src/skins/admin/en/address/field/style.css @@ -0,0 +1,14 @@ +/* vim: set ts=2 sw=2 sts=2 et: */ + +/** + * Address form styles + * + * @author Creative Development LLC + * @copyright Copyright (c) 2011-2012 Creative Development LLC . All rights reserved + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + * @link http://www.litecommerce.com/ + */ + +div.model-properties ul.table div.table-label label { + width: 180px; +} \ No newline at end of file diff --git a/src/skins/admin/en/js/states_list.tpl b/src/skins/admin/en/address/fields/body.tpl similarity index 53% rename from src/skins/admin/en/js/states_list.tpl rename to src/skins/admin/en/address/fields/body.tpl index 5c4395c9ed..3f8fd4d99b 100644 --- a/src/skins/admin/en/js/states_list.tpl +++ b/src/skins/admin/en/address/fields/body.tpl @@ -1,18 +1,13 @@ {* vim: set ts=2 sw=2 sts=2 et: *} {** - * States lsit controller + * Address fields page * * @author Creative Development LLC * @copyright Copyright (c) 2011-2012 Creative Development LLC . All rights reserved * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) * @link http://www.litecommerce.com/ *} -{foreach:getCountriesStates(),countryCode,data} - {if:data} - statesList['{countryCode}'] = []; - {foreach:data,stateId,state} - statesList['{countryCode}'][statesList['{countryCode}'].length] = { id: '{stateId}', state: '{state}' } - {end:} - {end:} -{end:} + + + \ No newline at end of file diff --git a/src/skins/admin/en/address/fields/style.css b/src/skins/admin/en/address/fields/style.css new file mode 100644 index 0000000000..6f1a32320c --- /dev/null +++ b/src/skins/admin/en/address/fields/style.css @@ -0,0 +1,23 @@ +/* vim: set ts=2 sw=2 sts=2 et: */ + +/** + * CSS styles for address fields management page + * + * @author Creative Development LLC + * @copyright Copyright (c) 2011-2012 Creative Development LLC . All rights reserved + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + * @link http://www.litecommerce.com/ + */ + +.items-list-table.address-fields table.list tbody td.name { + width: 200px; +} + +.items-list-table.address-fields table.list tbody td.serviceName { + width: 200px; +} + +.items-list-table.address-fields table.list tbody td input[type="text"] { + width: 150px; +} + diff --git a/src/skins/admin/en/address/style.css b/src/skins/admin/en/address/style.css index c9536b3fe2..fa5da4474c 100644 --- a/src/skins/admin/en/address/style.css +++ b/src/skins/admin/en/address/style.css @@ -23,7 +23,7 @@ padding-bottom: 10px; } -.address-dialog label { +.address-dialog .model-properties label { font-size: 14px; font-weight: normal; color: #53769d; @@ -36,44 +36,44 @@ margin-bottom: 6px; } -.address-dialog ul li +.address-dialog .model-properties ul li { padding: 0px 5px 6px 0px; } -.address-dialog input { +.address-dialog .model-properties input { width: 300px; } -span.address-firstname input { +.address-dialog .model-properties span.address-firstname input { width: 240px; } -span.address-lastname input { +.address-dialog .model-properties span.address-lastname input { width: 240px; } -span.address-street input { +.address-dialog .model-properties span.address-street input { width: 290px; } -li.address-country select { +.address-dialog .model-properties li.address-country select { width: 300px; } -li.address-state select { +.address-dialog .model-properties li.address-state select { width: 240px; } -span.address-city input { +.address-dialog .model-properties span.address-city input { width: 240px; } -span.address-zipcode input { +.address-dialog .model-properties span.address-zipcode input { width: 75px; } -span.address-phone input { +.address-dialog .model-properties span.address-phone input { width: 125px; } @@ -82,12 +82,20 @@ span.address-phone input { border: 1px solid #ddd; } -ul.default-table li.address-phone { - clear: none; +.address-dialog .model-properties ul.table.default-table { + min-width: 600px; +} + +.address-dialog .model-properties ul.default-table li div.table-label label { + width: 70px; } -ul.default-table li.address-phone label { - width: 50px; +.address-dialog .model-properties ul.default-table li.address-zipcode { + float: left; +} + +.address-dialog .model-properties ul.default-table li.address-phone { + clear: none; } .address-dialog .button { diff --git a/src/skins/admin/en/attribute/body.tpl b/src/skins/admin/en/attribute/body.tpl new file mode 100644 index 0000000000..31de80cd6f --- /dev/null +++ b/src/skins/admin/en/attribute/body.tpl @@ -0,0 +1,11 @@ +{* vim: set ts=2 sw=2 sts=2 et: *} + +{** + * Attribute page template + * + * @author Creative Development LLC + * @copyright Copyright (c) 2011-2012 Creative Development LLC . All rights reserved + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + * @link http://www.litecommerce.com/ + *} + diff --git a/src/skins/admin/en/attribute/footer.tpl b/src/skins/admin/en/attribute/footer.tpl new file mode 100644 index 0000000000..6507546d56 --- /dev/null +++ b/src/skins/admin/en/attribute/footer.tpl @@ -0,0 +1,14 @@ +{* vim: set ts=2 sw=2 sts=2 et: *} + +{** + * Attribute footer + * + * @author Creative Development LLC + * @copyright Copyright (c) 2011-2012 Creative Development LLC . All rights reserved + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + * @link http://www.litecommerce.com/ + * + * @ListChild (list="crud.attribute.footer", zone="admin", weight="100") + *} + +
{t(#Editing attribute groups on this page won't affect other product classes which use these groups. Removing a group doesn't delete attributes from the group, but makes them show up among other attributes having no associated groups.#)}
diff --git a/src/skins/admin/en/attribute/style.css b/src/skins/admin/en/attribute/style.css new file mode 100644 index 0000000000..c0837929f8 --- /dev/null +++ b/src/skins/admin/en/attribute/style.css @@ -0,0 +1,10 @@ +/* vim: set ts=2 sw=2 sts=2 et: */ + +/** + * Attribute view model styles + * + * @author Creative Development LLC + * @copyright Copyright (c) 2011-2012 Creative Development LLC . All rights reserved + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + * @link http://www.litecommerce.com/ + */ diff --git a/src/skins/admin/en/attribute_group/body.tpl b/src/skins/admin/en/attribute_group/body.tpl new file mode 100644 index 0000000000..df399b6405 --- /dev/null +++ b/src/skins/admin/en/attribute_group/body.tpl @@ -0,0 +1,11 @@ +{* vim: set ts=2 sw=2 sts=2 et: *} + +{** + * Attribute group page template + * + * @author Creative Development LLC + * @copyright Copyright (c) 2011-2012 Creative Development LLC . All rights reserved + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + * @link http://www.litecommerce.com/ + *} + \ No newline at end of file diff --git a/src/skins/admin/en/attribute_group/style.css b/src/skins/admin/en/attribute_group/style.css new file mode 100644 index 0000000000..d52a4746b2 --- /dev/null +++ b/src/skins/admin/en/attribute_group/style.css @@ -0,0 +1,10 @@ +/* vim: set ts=2 sw=2 sts=2 et: */ + +/** + * Attribute group view model styles + * + * @author Creative Development LLC + * @copyright Copyright (c) 2011-2012 Creative Development LLC . All rights reserved + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + * @link http://www.litecommerce.com/ + */ diff --git a/src/skins/admin/en/attribute_groups/body.tpl b/src/skins/admin/en/attribute_groups/body.tpl new file mode 100644 index 0000000000..239c7e60d7 --- /dev/null +++ b/src/skins/admin/en/attribute_groups/body.tpl @@ -0,0 +1,12 @@ +{* vim: set ts=2 sw=2 sts=2 et: *} + +{** + * Attribute groups page template + * + * @author Creative Development LLC + * @copyright Copyright (c) 2011-2012 Creative Development LLC . All rights reserved + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + * @link http://www.litecommerce.com/ + *} + + diff --git a/src/skins/admin/en/attribute_groups/list.tpl b/src/skins/admin/en/attribute_groups/list.tpl new file mode 100644 index 0000000000..7192e584be --- /dev/null +++ b/src/skins/admin/en/attribute_groups/list.tpl @@ -0,0 +1,18 @@ +{* vim: set ts=2 sw=2 sts=2 et: *} + +{** + * Attribute groups list table template + * + * @author Creative Development LLC + * @copyright Copyright (c) 2011-2012 Creative Development LLC . All rights reserved + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + * @link http://www.litecommerce.com/ + *} + + + +
+ +
+ +
{t(#Editing attribute groups on this page won't affect other product classes which use these groups. Removing a group doesn't delete attributes from the group, but makes them show up among other attributes having no associated groups.#)}
diff --git a/src/skins/admin/en/attribute_groups/style.css b/src/skins/admin/en/attribute_groups/style.css new file mode 100644 index 0000000000..880d5660fa --- /dev/null +++ b/src/skins/admin/en/attribute_groups/style.css @@ -0,0 +1,10 @@ +/* vim: set ts=2 sw=2 sts=2 et: */ + +/** + * Attribute groups list styles + * + * @author Creative Development LLC + * @copyright Copyright (c) 2011-2012 Creative Development LLC . All rights reserved + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + * @link http://www.litecommerce.com/ + */ diff --git a/src/skins/admin/en/attribute_option/body.tpl b/src/skins/admin/en/attribute_option/body.tpl new file mode 100644 index 0000000000..8b1aa553f4 --- /dev/null +++ b/src/skins/admin/en/attribute_option/body.tpl @@ -0,0 +1,11 @@ +{* vim: set ts=2 sw=2 sts=2 et: *} + +{** + * Attribute option page template + * + * @author Creative Development LLC + * @copyright Copyright (c) 2011-2012 Creative Development LLC . All rights reserved + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + * @link http://www.litecommerce.com/ + *} + \ No newline at end of file diff --git a/src/skins/admin/en/attribute_option/style.css b/src/skins/admin/en/attribute_option/style.css new file mode 100644 index 0000000000..ac508f99cd --- /dev/null +++ b/src/skins/admin/en/attribute_option/style.css @@ -0,0 +1,10 @@ +/* vim: set ts=2 sw=2 sts=2 et: */ + +/** + * Attribute option view model styles + * + * @author Creative Development LLC + * @copyright Copyright (c) 2011-2012 Creative Development LLC . All rights reserved + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + * @link http://www.litecommerce.com/ + */ diff --git a/src/skins/admin/en/attribute_options/body.tpl b/src/skins/admin/en/attribute_options/body.tpl new file mode 100644 index 0000000000..c5d0cf00b1 --- /dev/null +++ b/src/skins/admin/en/attribute_options/body.tpl @@ -0,0 +1,12 @@ +{* vim: set ts=2 sw=2 sts=2 et: *} + +{** + * Attribute options page template + * + * @author Creative Development LLC + * @copyright Copyright (c) 2011-2012 Creative Development LLC . All rights reserved + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + * @link http://www.litecommerce.com/ + *} + + \ No newline at end of file diff --git a/src/skins/admin/en/attribute_options/list.tpl b/src/skins/admin/en/attribute_options/list.tpl new file mode 100644 index 0000000000..35e1d099f8 --- /dev/null +++ b/src/skins/admin/en/attribute_options/list.tpl @@ -0,0 +1,14 @@ +{* vim: set ts=2 sw=2 sts=2 et: *} + +{** + * Attribute options list table template + * + * @author Creative Development LLC + * @copyright Copyright (c) 2011-2012 Creative Development LLC . All rights reserved + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + * @link http://www.litecommerce.com/ + *} + + + + \ No newline at end of file diff --git a/src/skins/admin/en/attribute_options/style.css b/src/skins/admin/en/attribute_options/style.css new file mode 100644 index 0000000000..3e84d34c29 --- /dev/null +++ b/src/skins/admin/en/attribute_options/style.css @@ -0,0 +1,10 @@ +/* vim: set ts=2 sw=2 sts=2 et: */ + +/** + * Attribute options list styles + * + * @author Creative Development LLC + * @copyright Copyright (c) 2011-2012 Creative Development LLC . All rights reserved + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + * @link http://www.litecommerce.com/ + */ diff --git a/src/skins/admin/en/attributes/body.tpl b/src/skins/admin/en/attributes/body.tpl new file mode 100644 index 0000000000..f55463e21e --- /dev/null +++ b/src/skins/admin/en/attributes/body.tpl @@ -0,0 +1,21 @@ +{* vim: set ts=2 sw=2 sts=2 et: *} + +{** + * Attributes page template + * + * @author Creative Development LLC + * @copyright Copyright (c) 2011-2012 Creative Development LLC . All rights reserved + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + * @link http://www.litecommerce.com/ + *} + +
+ + +
+ +{if:isListVisible()} + +{else:} +{t(#No attributes are defined for the product class yet.#)} +{end:} diff --git a/src/skins/admin/en/attributes/list.tpl b/src/skins/admin/en/attributes/list.tpl new file mode 100644 index 0000000000..1505da9488 --- /dev/null +++ b/src/skins/admin/en/attributes/list.tpl @@ -0,0 +1,17 @@ +{* vim: set ts=2 sw=2 sts=2 et: *} + +{** + * Attributes list table template + * + * @author Creative Development LLC + * @copyright Copyright (c) 2011-2012 Creative Development LLC . All rights reserved + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + * @link http://www.litecommerce.com/ + *} + + + +{foreach:getAttributeGroups(),group} + +{end:} + diff --git a/src/skins/admin/en/attributes/parts/type.tpl b/src/skins/admin/en/attributes/parts/type.tpl new file mode 100644 index 0000000000..5c9ce926cf --- /dev/null +++ b/src/skins/admin/en/attributes/parts/type.tpl @@ -0,0 +1,15 @@ +{* vim: set ts=2 sw=2 sts=2 et: *} + +{** + * Type + * + * @author Creative Development LLC + * @copyright Copyright (c) 2011-2012 Creative Development LLC . All rights reserved + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + * @link http://www.litecommerce.com/ + *} + +
+{t(#Edit attribute#)} +{t(entity.getTypes(entity.getType()))} +
diff --git a/src/skins/admin/en/attributes/script.js b/src/skins/admin/en/attributes/script.js new file mode 100644 index 0000000000..63e28a03c7 --- /dev/null +++ b/src/skins/admin/en/attributes/script.js @@ -0,0 +1,66 @@ +/* vim: set ts=2 sw=2 sts=2 et: */ + +/** + * Attributes + * + * @author Creative Development LLC + * @copyright Copyright (c) 2011-2012 Creative Development LLC . All rights reserved + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + * @link http://www.litecommerce.com/ + */ + +var ppr = popup.postprocessRequest; +popup.postprocessRequest = function(XMLHttpRequest, textStatus, data, isValid) { + ppr.call(this, XMLHttpRequest, textStatus, data, isValid); + TableItemsListQueue(); + + jQuery('.select-attributetypes select').change( + function () { + if (jQuery(this).data('value') == jQuery(this).val()) { + jQuery('.select-attributetypes .form-field-comment').hide(); + jQuery('li.custom-field').show(); + } else { + jQuery('.select-attributetypes .form-field-comment').show(); + jQuery('li.custom-field').hide(); + } + } + ); + + jQuery('.ajax-container-loadable form.attribute', this.base).commonController('submitOnlyChanged', false); +} + +jQuery().ready( + function () { + jQuery('button.manage-groups').click( + function () { + return !popup.load( + URLHandler.buildURL({ + target: 'attribute_groups', + product_class_id: jQuery(this).parent().data('class-id'), + widget: 'XLite\\View\\AttributeGroups' + }), + null, + function () { + self.location.reload(); + } + ); + } + ); + jQuery('button.new-attribute, a.edit-attribute').click( + function () { + return !popup.load( + URLHandler.buildURL({ + target: 'attribute', + product_class_id: jQuery(this).parent().data('class-id'), + id: jQuery(this).parent().data('id'), + widget: 'XLite\\View\\Attribute' + }), + null, + function () { + self.location.reload(); + } + ); + } + ); + } +); diff --git a/src/skins/admin/en/attributes/style.css b/src/skins/admin/en/attributes/style.css new file mode 100644 index 0000000000..0036ccd427 --- /dev/null +++ b/src/skins/admin/en/attributes/style.css @@ -0,0 +1,313 @@ +/* vim: set ts=2 sw=2 sts=2 et: */ + +/** + * Attributes list styles + * + * @author Creative Development LLC + * @copyright Copyright (c) 2011-2012 Creative Development LLC . All rights reserved + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + * @link http://www.litecommerce.com/ + */ + +.items-list-table table.list th.name { + width: 500px; + color: #456583; + font-size: 16px; +} + +.items-list-table table.list th.type { + width: 200px; + text-align: right; +} + +.items-list-table table.list td.type { + text-align: right; + color: #8f8f8f; +} + +.items-list-table table.list .edit-mark td.type { + color: #333333; +} + +.items-list-table table.list th.actions.left { + width: 30px; +} + +.items-list-table table.list th.actions.right { + width: 25px; +} + +.items-list-table.group { + margin-top: 20px; +} + +button.new-attribute span { + background: url("../images/icon_list.png") no-repeat scroll left top transparent; + padding: 2px 0 2px 25px; +} + +button.manage-groups span { + background: url("../images/icon_folder.png") no-repeat scroll left top transparent; + padding: 2px 0 2px 25px; +} + +div.buttons { + margin-bottom: 25px; +} + +div.group table.list th.actions.left { + background: url("../images/icon_folder.png") no-repeat scroll center center transparent; +} + +/* + * Popup box + */ + +.blockMsg +{ + background: transparent none; + margin: 0px; + padding: 0px; + z-index: 1001; + position: absolute; + top: 30%; +} + +.blockMsg .close-link +{ + display: block; + position: absolute; + background: transparent url(../../../common/ui/images/icon_window_close.png) no-repeat 10px 10px; + top: 0px; + right: 0px; + width: 41px; + height: 41px; + outline: none; + -moz-border-radius-bottomright: 11px; + -moz-border-radius-topright: 11px; + -webkit-border-bottom-right-radius: 11px; + -webkit-border-top-right-radius: 11px; + border-bottom-right-radius: 11px; + border-top-right-radius: 11px; +} + +.blockMsg .block-container +{ + margin-right: 31px; + border-style: none; + -moz-border-radius: 11px; + -webkit-border-radius: 11px; + border-radius: 11px; + padding: 10px; +} + +.blockMsg .block-subcontainer +{ + padding: 40px; + padding-top: 30px; + background: white; + overflow: auto; + -moz-border-radius: 4px; + -webkit-border-radius: 4px; + border-radius: 4px; +} + +.block-wait +{ + text-align: left; + vertical-align: middle; + font-weight: bold; + min-width: 200px; + border: 1px solid #cadce8; + background: #fff none; +} + +.block-wait div +{ + background: transparent url(../images/progress.gif) repeat-x left top; + height: 11px; + margin: 10px; +} + +.mini-block-wait div +{ + margin: 0px; +} + +/* Background overlay */ + +.blockOverlay +{ + background: transparent url(../../../common/ui/images/popup_overlay.png) repeat top left !important; +} + +.blockMsg .close-link, +.blockMsg .block-container +{ + background-color: #7a7a7a; +} + +/* Common popup styles */ + +.blockMsg h2 +{ + margin-top: 0px; + font-size: 32px; +} + +.blockMsg h3 +{ + font-size: 24px; +} + +.blockMsg .model-properties ul.table { + min-width: 450px; +} + +.edit-attribute { + background: url("../images/tri_right_button.png") no-repeat right top transparent; + padding-right: 13px; + display: none; + line-height: 26px; +} +.edit-mark .edit-attribute { + display: inline-block; +} +.edit-attribute span { + -moz-top-left-border-radius: 3px; + -moz-bottom-left-border-radius: 3px; + -webkit-top-left-border-radius: 3px; + -webkit-bottom-left-border-radius: 3px; + border-top-left-radius: 3px; + border-bottom-left-radius: 3px; + padding-left: 10px; + line-height: 24px; + background-color: #eff8fe; + color: #154e9c; + border: 1px solid #cadce8; + border-right: 0 none; + display: inline-block; +} + +.items-list-table table.list tbody.lines td .edit-attribute, +.items-list-table table.list tbody.lines td .edit-attribute span { + vertical-align: top; +} + +.ajax-container-loadable .model-properties ul.table div.table-label label { + font-size: 16px; + color: #456583; + width: auto; +} + +.ajax-container-loadable .model-properties div.table-value { + width: auto; + margin-left: 10px; + float: left; + max-width: 440px; +} + +.ajax-container-loadable .model-properties div.table-value.values-value { + width: 400px; +} + +.ajax-container-loadable div.button.submit { + text-align: center; +} + +.ajax-container-loadable div.table-value select { + width: auto; + max-width: 200px; + float: left; +} + +.ajax-container-loadable .select-attributetypes div.table-value .form-field-comment { + background: url("../images/icon_warning_round.png") no-repeat scroll 0 0 transparent; + padding-left: 30px; + color: #456583; + float: left; + display: none; + line-height: 14px; + width: 360px; + margin-top: 25px; +} + +.ajax-container-loadable div.table-value .form-field-comment { + float: right; + font-size: 12px; +} + +.ajax-container-loadable div.table-value .input-field-wrapper { + float: left; +} + +.ajax-container-loadable .star { + display: none; +} + +.ajax-container-loadable li.edit-unit { + display: inline; + position: absolute; + margin-left: 10px; +} + +.ajax-container-loadable li.edit-unit div.table-value input { + width: 50px; + margin-right: 5px; +} + +.ajax-container-loadable .model-properties ul.table li { + margin-bottom: 10px; +} + +.ajax-container-loadable li.edit-decimals { + float: left; +} + +.ajax-container-loadable li.edit-unit { + left: 180px; +} + +.ajax-container-loadable div.note { + color: #456583; + text-align: center; + width: 440px; + margin-top: 10px; + padding: 0 30px; +} + +.ajax-container-loadable .model-form-buttons { + padding: 0px; +} + +.ajax-container-loadable { + width: 500px; +} + +.ajax-container-loadable .list-footer { + margin: 0; + padding: 0; +} + +.ajax-container-loadable .itemslist button { + border: 0; + background: none; +} + +.ajax-container-loadable .itemslist button span { + text-decoration: underline; + font-size: 14px; +} + +.ajax-container-loadable .items-list-table table.list tbody td.main .attributeoption-name .view { + max-width: 300px; +} + +.ajax-container-loadable .items-list-table table.list tbody td.main .view { + position: relative; + max-width: 350px; +} + +.items-list-table table.list tbody td.main .view { + max-width: 500px; +} diff --git a/src/skins/admin/en/button/js/add_address.js b/src/skins/admin/en/button/js/add_address.js index bb82bd8c63..4ec3e10e16 100644 --- a/src/skins/admin/en/button/js/add_address.js +++ b/src/skins/admin/en/button/js/add_address.js @@ -24,6 +24,7 @@ decorate( function (selector) { // Some autoloading could be added + UpdateStatesList(); } ); diff --git a/src/skins/admin/en/button/js/modify_address.js b/src/skins/admin/en/button/js/modify_address.js index 9bbfd7c44f..264c85293b 100644 --- a/src/skins/admin/en/button/js/modify_address.js +++ b/src/skins/admin/en/button/js/modify_address.js @@ -24,6 +24,7 @@ decorate( function (selector) { // Some autoloading could be added + UpdateStatesList(); } ); diff --git a/src/skins/admin/en/button/js/remove.js b/src/skins/admin/en/button/js/remove.js index f4eeea1bc8..b1cc68a1d0 100644 --- a/src/skins/admin/en/button/js/remove.js +++ b/src/skins/admin/en/button/js/remove.js @@ -11,21 +11,20 @@ CommonForm.elementControllers.push( { - pattern: '.line .actions button.remove', + pattern: '.line .actions .remove-wrapper', handler: function () { - var inp = jQuery('input', this); - var btn = jQuery(this); + var inp = jQuery('input', this).eq(0); + var btn = jQuery('button.remove', this); var cell = btn.parents('.line').eq(0); btn.click( function () { if (inp.attr('checked')) { inp.removeAttr('checked'); - } else { inp.attr('checked', 'checked'); - inp.get(0).setAttribute('checked', 'checked'); } + inp.change(); } ); diff --git a/src/skins/admin/en/button/remove.tpl b/src/skins/admin/en/button/remove.tpl index 8073282629..2c781ca8a1 100644 --- a/src/skins/admin/en/button/remove.tpl +++ b/src/skins/admin/en/button/remove.tpl @@ -8,8 +8,9 @@ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) * @link http://www.litecommerce.com/ *} - - - - + diff --git a/src/skins/admin/en/common/select_country.tpl b/src/skins/admin/en/common/select_country.tpl index ff441a7456..62f0a4366d 100644 --- a/src/skins/admin/en/common/select_country.tpl +++ b/src/skins/admin/en/common/select_country.tpl @@ -9,6 +9,6 @@ * @link http://www.litecommerce.com/ *} diff --git a/src/skins/admin/en/css/style.css b/src/skins/admin/en/css/style.css index 6f455ab61e..4536a8dbf1 100644 --- a/src/skins/admin/en/css/style.css +++ b/src/skins/admin/en/css/style.css @@ -1639,16 +1639,21 @@ div.model-form-buttons { div.table-label { float: left; + padding-right: 35px; } .model-properties ul.table div.table-label label { width: 80px; } +.model-properties ul.table li.itemslist div.table-value { + width: 100%; +} + div.star { - float: right; width: 10px; padding: 12px 0px 5px 0px; + display: inline-block; } .table-label, @@ -1663,8 +1668,7 @@ div.star { } div.table-value { - float: right; - width: 80%; + display: inline-block; } div.table-value input[type="text"], diff --git a/src/skins/admin/en/form_field.tpl b/src/skins/admin/en/form_field.tpl index 26f3385734..05c285851c 100644 --- a/src/skins/admin/en/form_field.tpl +++ b/src/skins/admin/en/form_field.tpl @@ -15,15 +15,19 @@ {end:} +{if:!getParam(#fieldOnly#)} +
*
+
 
+{end:} +
{t(getParam(#comment#)):r}
+ {if:getFormFieldJSData()}{displayCommentedData(getFormFieldJSData())}{end:}
{if:!getParam(#fieldOnly#)} -
*
-
 
{end:} diff --git a/src/skins/admin/en/form_field/inline/input/text/product-class.js b/src/skins/admin/en/form_field/inline/input/text/product-class.js new file mode 100644 index 0000000000..870502eb28 --- /dev/null +++ b/src/skins/admin/en/form_field/inline/input/text/product-class.js @@ -0,0 +1,19 @@ +/* vim: set ts=2 sw=2 sts=2 et: */ + +/** + * Product class field controller + * + * @author Creative Development LLC + * @copyright Copyright (c) 2011-2012 Creative Development LLC . All rights reserved + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + * @link http://www.litecommerce.com/ + */ + +CommonForm.elementControllers.push( + { + pattern: '.inline-field.inline-product-class', + handler: function () { + this.viewValuePattern = '.view .value'; + } + } +); diff --git a/src/skins/admin/en/form_field/inline/input/text/product-class.tpl b/src/skins/admin/en/form_field/inline/input/text/product-class.tpl new file mode 100644 index 0000000000..8cb033d9c4 --- /dev/null +++ b/src/skins/admin/en/form_field/inline/input/text/product-class.tpl @@ -0,0 +1,13 @@ +{* vim: set ts=2 sw=2 sts=2 et: *} + +{** + * Product class inline view + * + * @author Creative Development LLC + * @copyright Copyright (c) 2011-2012 Creative Development LLC . All rights reserved + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + * @link http://www.litecommerce.com/ + *} + +{getViewValue(singleField)} +({entity.getProductsCount()} {t(#products#)}) diff --git a/src/skins/admin/en/form_field/input/text/autocomplete.js b/src/skins/admin/en/form_field/input/text/autocomplete.js index 84ebfa96b6..fce8bf8501 100644 --- a/src/skins/admin/en/form_field/input/text/autocomplete.js +++ b/src/skins/admin/en/form_field/input/text/autocomplete.js @@ -18,7 +18,7 @@ CommonForm.elementControllers.push( this.autocompleteSource = function(request, response) { core.get( - jQuery(this).data('source-url').replace('%term%', request.term), + unescape(jQuery(this).data('source-url')).replace('%term%', request.term), null, {}, { diff --git a/src/skins/admin/en/form_field/input/text/combobox.css b/src/skins/admin/en/form_field/input/text/combobox.css new file mode 100644 index 0000000000..0144459090 --- /dev/null +++ b/src/skins/admin/en/form_field/input/text/combobox.css @@ -0,0 +1,27 @@ +/* vim: set ts=2 sw=2 sts=2 et: */ + +/** + * Combobox styles + * + * @author Creative Development LLC + * @copyright Copyright (c) 2011-2012 Creative Development LLC . All rights reserved + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + * @link http://www.litecommerce.com/ + */ + +input.combobox { + float: left; + padding-right: 21px; +} + +div.combobox-select { + background: transparent url(../../../images/arrows-select.png) center center no-repeat; + width: 21px; + height: 21px; + float: left; + display: inline; + position: relative; + top: 1px; + right: 22px; + cursor: pointer; +} diff --git a/src/skins/admin/en/form_field/input/text/combobox.js b/src/skins/admin/en/form_field/input/text/combobox.js new file mode 100644 index 0000000000..532b3e6f98 --- /dev/null +++ b/src/skins/admin/en/form_field/input/text/combobox.js @@ -0,0 +1,29 @@ +/* vim: set ts=2 sw=2 sts=2 et: */ + +/** + * Float field microcontroller + * + * @author Creative Development LLC + * @copyright Copyright (c) 2011-2012 Creative Development LLC . All rights reserved + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + * @link http://www.litecommerce.com/ + */ + +CommonForm.elementControllers.push( + { + pattern: '.input-field-wrapper div.combobox-select', + handler: function () { + + jQuery(this).click( + function () { + var input = jQuery(this).parent().find('input'); + var minLength = input.autocomplete('option', 'minLength'); + input.autocomplete('option', 'minLength', 0); + input.autocomplete('search', ''); + input.autocomplete('option', 'minLength', minLength); + input.focus(); + } + ); + } + } +); diff --git a/src/skins/admin/en/form_field/input/text/combobox.tpl b/src/skins/admin/en/form_field/input/text/combobox.tpl new file mode 100644 index 0000000000..3b1f000416 --- /dev/null +++ b/src/skins/admin/en/form_field/input/text/combobox.tpl @@ -0,0 +1,16 @@ +{* vim: set ts=2 sw=2 sts=2 et: *} + +{** + * Common input template + * + * @author Creative Development LLC + * @copyright Copyright (c) 2011-2012 Creative Development LLC . All rights reserved + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + * @link http://www.litecommerce.com/ + *} + + + {displayCommentedData(getCommentedData())} + +
+
diff --git a/src/skins/admin/en/form_field/items_list.tpl b/src/skins/admin/en/form_field/items_list.tpl new file mode 100644 index 0000000000..7697b01a79 --- /dev/null +++ b/src/skins/admin/en/form_field/items_list.tpl @@ -0,0 +1,12 @@ +{* vim: set ts=2 sw=2 sts=2 et: *} + +{** + * Items list + * + * @author Creative Development LLC + * @copyright Copyright (c) 2011-2012 Creative Development LLC . All rights reserved + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + * @link http://www.litecommerce.com/ + *} + + diff --git a/src/skins/admin/en/form_field/radio.tpl b/src/skins/admin/en/form_field/radio.tpl new file mode 100644 index 0000000000..8c73e31668 --- /dev/null +++ b/src/skins/admin/en/form_field/radio.tpl @@ -0,0 +1,12 @@ +{* vim: set ts=2 sw=2 sts=2 et: *} + +{** + * Radio template + * + * @author Creative Development LLC + * @copyright Copyright (c) 2011-2012 Creative Development LLC . All rights reserved + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + * @link http://www.litecommerce.com/ + *} + + diff --git a/src/skins/admin/en/form_field/select_country.js b/src/skins/admin/en/form_field/select_country.js index cbd50d524b..68de1c59d7 100644 --- a/src/skins/admin/en/form_field/select_country.js +++ b/src/skins/admin/en/form_field/select_country.js @@ -9,9 +9,6 @@ * @link http://www.litecommerce.com/ */ -var statesList = []; -var stateSelectors = []; - function StateSelector(countrySelectorId, stateSelectorId, stateInputId) { var o = this; @@ -135,11 +132,13 @@ StateSelector.prototype.addStates = function(states) var s = this.stateSelectBox.get(0); var added = s.options.length; + var i = 0; if (states) { - for (var i = 0; i < states.length; i++) { - s.options[i + added] = new Option(states[i].state, states[i].id); - } + for (var key in states) { + s.options[i + added] = new Option(states[key], key); + i++; + } } if (this.stateSavedValue) { @@ -147,3 +146,7 @@ StateSelector.prototype.addStates = function(states) } } } + +jQuery(document).ready(function () { + UpdateStatesList(); +}); diff --git a/src/skins/admin/en/images/arrows-select.png b/src/skins/admin/en/images/arrows-select.png new file mode 100644 index 0000000000..ef4fef9586 Binary files /dev/null and b/src/skins/admin/en/images/arrows-select.png differ diff --git a/src/skins/admin/en/images/icon_folder.png b/src/skins/admin/en/images/icon_folder.png new file mode 100644 index 0000000000..92d96393d1 Binary files /dev/null and b/src/skins/admin/en/images/icon_folder.png differ diff --git a/src/skins/admin/en/images/icon_list.png b/src/skins/admin/en/images/icon_list.png new file mode 100644 index 0000000000..60de63671b Binary files /dev/null and b/src/skins/admin/en/images/icon_list.png differ diff --git a/src/skins/admin/en/images/icon_warning_round.png b/src/skins/admin/en/images/icon_warning_round.png new file mode 100644 index 0000000000..b67449b362 Binary files /dev/null and b/src/skins/admin/en/images/icon_warning_round.png differ diff --git a/src/skins/admin/en/items_list/model/style.css b/src/skins/admin/en/items_list/model/style.css index 46c45f5179..7e8c0a47e6 100644 --- a/src/skins/admin/en/items_list/model/style.css +++ b/src/skins/admin/en/items_list/model/style.css @@ -9,7 +9,7 @@ * @link http://www.litecommerce.com/ */ -.items-list button.remove input { +.items-list .remove-wrapper input { display: none; } diff --git a/src/skins/admin/en/items_list/model/table/address_fields/style.css b/src/skins/admin/en/items_list/model/table/address_fields/style.css new file mode 100644 index 0000000000..5e126f2da0 --- /dev/null +++ b/src/skins/admin/en/items_list/model/table/address_fields/style.css @@ -0,0 +1,16 @@ +/* vim: set ts=2 sw=2 sts=2 et: */ + +/** + * Address fields list styles + * + * @author Creative Development LLC + * @copyright Copyright (c) 2011-2012 Creative Development LLC . All rights reserved + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + * @link http://www.litecommerce.com/ + */ + +.items-list-table table.list tbody.lines td .view, + .items-list-table table.list tbody.lines td .view * +{ + width: 300px; +} diff --git a/src/skins/admin/en/items_list/model/table/body.tpl b/src/skins/admin/en/items_list/model/table/body.tpl index 415fdad6ca..8abe34708f 100644 --- a/src/skins/admin/en/items_list/model/table/body.tpl +++ b/src/skins/admin/en/items_list/model/table/body.tpl @@ -31,11 +31,8 @@ {foreach:getPageData(),idx,entity} - {if:column.template} - - {else:} - - {end:} + + diff --git a/src/skins/admin/en/items_list/model/table/parts/default.tpl b/src/skins/admin/en/items_list/model/table/parts/default.tpl new file mode 100644 index 0000000000..e024205f49 --- /dev/null +++ b/src/skins/admin/en/items_list/model/table/parts/default.tpl @@ -0,0 +1,12 @@ +{* vim: set ts=2 sw=2 sts=2 et: *} + +{** + * Default radio + * + * @author Creative Development LLC + * @copyright Copyright (c) 2011-2012 Creative Development LLC . All rights reserved + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + * @link http://www.litecommerce.com/ + *} + + diff --git a/src/skins/admin/en/items_list/model/table/parts/switcher.tpl b/src/skins/admin/en/items_list/model/table/parts/switcher.tpl index fab680e88a..78651b1dde 100644 --- a/src/skins/admin/en/items_list/model/table/parts/switcher.tpl +++ b/src/skins/admin/en/items_list/model/table/parts/switcher.tpl @@ -9,4 +9,4 @@ * @link http://www.litecommerce.com/ *} - + diff --git a/src/skins/admin/en/items_list/model/table/product/style.css b/src/skins/admin/en/items_list/model/table/product/style.css index 9ef0b68ab7..c1fcf8b2d0 100644 --- a/src/skins/admin/en/items_list/model/table/product/style.css +++ b/src/skins/admin/en/items_list/model/table/product/style.css @@ -1,7 +1,7 @@ /* vim: set ts=2 sw=2 sts=2 et: */ /** - * Product items lsit styles + * Product items list styles * * @author Creative Development LLC * @copyright Copyright (c) 2011-2012 Creative Development LLC . All rights reserved diff --git a/src/skins/admin/en/items_list/model/table/style.css b/src/skins/admin/en/items_list/model/table/style.css index 4c9076de11..4109d63722 100644 --- a/src/skins/admin/en/items_list/model/table/style.css +++ b/src/skins/admin/en/items_list/model/table/style.css @@ -4,9 +4,10 @@ * Table-based model list * * @author Creative Development LLC - * @copyright Copyright (c) 2011-2012 Creative Development LLC . All rights reserved + * @copyright Copyright (c) 2011 Creative Development LLC . All rights reserved * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) * @link http://www.litecommerce.com/ + * @since 1.0.15 */ /** @@ -35,46 +36,25 @@ border-bottom: 1px solid #d5d5d5; } -.items-list-table table.list tbody tr.line td { +.items-list-table table.list tbody.lines tr.line td { border-top: 1px solid #e9e9e9; padding: 8px 12px 6px; line-height: 30px; white-space: nowrap; } -.items-list-table table.list tbody.lines tr.line td .plain-value { - line-height: 30px; - white-space: nowrap; -} - .items-list-table table.list tbody.lines tr.line.last td { border-bottom: 1px solid #e9e9e9; } -.items-list-table table.list tbody td.main { +.items-list-table table.list tbody.lines td.main { } .items-list-table table.list tbody.lines td, - .items-list-table table.list tbody.lines td .view, - .items-list-table table.list tbody.lines td .view *, - .items-list-table table.list tbody.lines td .plain-value -{ - font-size: 14px; -} - -.items-list-table table.list tbody.lines td.no-wrap .plain-value { - position: relative; - overflow: hidden; -} - -.items-list-table table.list tbody.lines td { - cursor: pointer; -} - .items-list-table table.list tbody.lines td .view, - .items-list-table table.list tbody.lines td .view * +.items-list-table table.list tbody.lines td .view * { - cursor: text; + font-size: 14px; } .items-list-table table.list tbody.lines td, @@ -83,9 +63,8 @@ vertical-align: middle; } -.items-list-table table.list tbody td.actions .separator { - position: absolute; - top: 16px; +.items-list-table table.list tbody.lines td.actions .separator { + display: inline-block; width: 3px; height: 20px; background-image: url(images/line-separator.png); @@ -93,36 +72,36 @@ background-position: top left; } -.items-list-table table.list tbody td.actions.left { - padding-right: 6px; +.items-list-table table.list tbody.lines td.actions.left { + padding-right: 0px; padding-left: 7px; } -.items-list-table table.list tbody td.actions.left .separator { - right: 0px; +.items-list-table table.list tbody.lines td.actions.left .separator { + margin-left: 6px; } -.items-list-table table.list tbody td.actions.right { - padding-left: 15px; +.items-list-table table.list tbody.lines td.actions.right { + padding-left: 0px; padding-right: 6px; } -.items-list-table table.list tbody td.actions.right .separator { - left: 0px; +.items-list-table table.list tbody.lines td.actions.right .separator { + margin-right: 12px; } -.items-list-table table.list tbody td.actions .action { +.items-list-table table.list tbody.lines td.actions .action { display: inline-block; padding-right: 2px; vertical-align: top; } -.items-list-table table.list tbody td.actions .action.next { +.items-list-table table.list tbody.lines td.actions .action.next { padding-left: 7px; background: transparent url(../../../images/actions_separator.png) no-repeat left 7px; } -.items-list-table table.list tbody td.actions div.selector { +.items-list-table table.list tbody.lines td.actions div.selector { width: 31px; height: 31px; text-align: center; @@ -130,68 +109,74 @@ margin-right: 5px; } -.items-list-table table.list tbody td.actions div.selector.checked { +.items-list-table table.list tbody.lines td.actions div.selector.checked { background-color: #d2f5cc; } -.items-list-table table.list tbody td.actions div.selector input { +.items-list-table table.list tbody.lines td.actions div.selector input { margin: 0px; vertical-align: middle; } -.items-list-table table.list tbody td.actions .inline-field .view { +.items-list-table table.list tbody.lines td.actions .inline-field .view { padding-top: 4px; } -.items-list-table table.list tbody td.actions .inline-switcher { +.items-list-table table.list tbody.lines td.actions .inline-switcher { width: 31px; padding-top: 7px; } -.items-list-table table.list tbody td.actions .inline-move { +.items-list-table table.list tbody.lines td.actions .inline-move { + height: 31px; padding-top: 8px; width: 37px; } -.items-list-table table.list tbody td.actions .inline-switcher .field { +.items-list-table table.list tbody.lines td.actions .inline-switcher .field { text-align: center; } -.items-list-table table.list tbody td a.link { +.items-list-table table.list tbody.lines td a.link { text-decoration: none; color: #456583; } -.items-list-table table.list tbody td.attention, -.items-list-table table.list tbody td.attention .view, -.items-list-table table.list tbody td.attention .view * +.items-list-table table.list tbody.lines td.attention, +.items-list-table table.list tbody.lines td.attention .view, +.items-list-table table.list tbody.lines td.attention .view * { color: #d91a1a; } -.items-list-table table.list tbody tr.line.remove-mark { +.items-list-table table.list tbody tr.line.remove-mark * { + opacity: .7; + filter: alpha(opacity=70); +} + +.items-list-table table.list tbody.lines tr.line.remove-mark { opacity: .3; } -.items-list-table table.list tbody .inline-field .field { +.items-list-table table.list tbody.lines .inline-field .field { line-height: normal; } -.items-list-table table.list tbody .inline-field .field input, -.items-list-table table.list tbody .inline-field .field select, -.items-list-table table.list tbody .inline-field .field textarea, -.items-list-table table.list tbody .inline-field .field span.text +.items-list-table table.list tbody.lines .inline-field .field input, +.items-list-table table.list tbody.lines .inline-field .field select, +.items-list-table table.list tbody.lines .inline-field .field textarea, +.items-list-table table.list tbody.lines .inline-field .field span.text { font-size: 14px; } -.items-list-table table.list tbody .inline-field .field input, -.items-list-table table.list tbody .inline-field .field select +.items-list-table table.list tbody.lines .inline-field .field input, +.items-list-table table.list tbody.lines .inline-field .field select { line-height: 18px; } -.items-list-table table.list tbody .inline-field .field input { +.items-list-table table.list tbody.lines .inline-field .field input { height: 19px; padding-top: 5px; padding-left: 6px; @@ -199,14 +184,14 @@ font-size: 14px; } -.items-list-table table.list tbody .inline-field .field select { +.items-list-table table.list tbody.lines .inline-field .field select { height: 29px; width: auto; margin-bottom: -2px; padding-top: 6px; } -.items-list-table table.list tbody .inline-field .table-value { +.items-list-table table.list tbody.lines .inline-field .table-value { float: none; } @@ -214,8 +199,8 @@ text-align: center; } -.items-list-table table.list tbody .field .subfield, -.items-list-table table.list tbody .field .subfield .table-value +.items-list-table table.list tbody.lines .field .subfield, +.items-list-table table.list tbody.lines .field .subfield .table-value { display: inline; } @@ -249,3 +234,13 @@ margin-top: 3px; margin-bottom: 3px; } + +.items-list-table table.list tbody td.main div span.value, +.items-list-table table.list tbody td.main div { + color: #456583; + font-size: 16px; +} + +.items-list-table table.list tbody td.main { + width: 300px; +} diff --git a/src/skins/admin/en/items_list/payment/methods/parts/action.right.tpl b/src/skins/admin/en/items_list/payment/methods/parts/action.right.tpl index a26222a077..0953c0ba4e 100644 --- a/src/skins/admin/en/items_list/payment/methods/parts/action.right.tpl +++ b/src/skins/admin/en/items_list/payment/methods/parts/action.right.tpl @@ -20,6 +20,9 @@ {if:method.getWarningNote()}
{method.getWarningNote()}
+ {elseif:!method.isCurrencyApplicable()} + +
{t(#This method does not support the current store currency and is not available for customers#)}
{elseif:method.isTestMode()}
{t(#This method is in test mode#)}
diff --git a/src/skins/admin/en/modules_manager/license/body.tpl b/src/skins/admin/en/modules_manager/license/body.tpl index 9a30702cc3..7db47424b6 100644 --- a/src/skins/admin/en/modules_manager/license/body.tpl +++ b/src/skins/admin/en/modules_manager/license/body.tpl @@ -40,8 +40,10 @@
- - +
diff --git a/src/skins/admin/en/order/invoice/parts/bottom.address.billing.tpl b/src/skins/admin/en/order/invoice/parts/bottom.address.billing.tpl index 6786323c56..31b9126f13 100644 --- a/src/skins/admin/en/order/invoice/parts/bottom.address.billing.tpl +++ b/src/skins/admin/en/order/invoice/parts/bottom.address.billing.tpl @@ -12,19 +12,14 @@ *} {t(#Billing address#)} -

- {order.profile.billing_address.title} {order.profile.billing_address.firstname} {order.profile.billing_address.lastname} -

- -

- {order.profile.billing_address.street}
- {order.profile.billing_address.city}, {order.profile.billing_address.state.state}, {order.profile.billing_address.zipcode}
- {order.profile.billing_address.country.country} -

-

- {t(#Phone#)}: {order.profile.billing_address.phone} -

+
    +
  • + {t(field.title)}: + {field.value} + , +
  • +

{t(#E-mail#)}: {order.profile.login} diff --git a/src/skins/admin/en/order/invoice/parts/bottom.address.shipping.tpl b/src/skins/admin/en/order/invoice/parts/bottom.address.shipping.tpl index a236824fee..6589e3b912 100644 --- a/src/skins/admin/en/order/invoice/parts/bottom.address.shipping.tpl +++ b/src/skins/admin/en/order/invoice/parts/bottom.address.shipping.tpl @@ -12,17 +12,13 @@ *} {t(#Shipping address#)} -

- {order.profile.shipping_address.title} {order.profile.shipping_address.firstname} {order.profile.shipping_address.lastname} -

-

- {order.profile.shipping_address.street}
- {order.profile.shipping_address.city}, {order.profile.shipping_address.state.state}, {order.profile.shipping_address.zipcode}
- {order.profile.shipping_address.country.country} -

+
    +
  • + {t(field.title)}: + {field.value} + , +
  • +
-

- {t(#Phone#)}: {order.profile.shipping_address.phone} -

diff --git a/src/skins/admin/en/order/invoice/style.css b/src/skins/admin/en/order/invoice/style.css index 305e46f354..f7b4e7ceb8 100644 --- a/src/skins/admin/en/order/invoice/style.css +++ b/src/skins/admin/en/order/invoice/style.css @@ -258,9 +258,57 @@ text-align: center; } -.invoice-box .deleted-product-note +.invoice-box .deleted-product-note { color: #999; font-size: 12px; font-style: italic; } + + .addresses ul.address-section li { + background: none; + padding: 0px; + margin: 0px; + } + +.addresses ul.address-section { + padding-top: 12px; +} + +.addresses ul.address-section li.address-field { + padding-right: 4px; +} + +.addresses ul.address-section li.address-field.address-custom_state { + display: none; +} + +.addresses ul.address-section li.address-field span { + font-size: 14px; + line-height: 20px; + padding-top: 8px; +} + +ul.address-section li.address-field .address-title, + ul.address-section li.address-field .address-comma +{ + display: none; +} + +ul.address-section li.address-field.address-phone .address-title, + ul.address-section li.address-field.field-additional .address-title, + ul.address-section li.address-field.address-city .address-comma, + ul.address-section li.address-field.address-street .address-comma, + ul.address-section li.address-field.address-state .address-comma +{ + display: inline; +} + +ul.address-section li.address-field.address-title, + ul.address-section li.address-field.address-firstname, + ul.address-section li.address-field.address-city, + ul.address-section li.address-field.address-state +{ + float: left; +} + diff --git a/src/skins/admin/en/order/page/info.css b/src/skins/admin/en/order/page/info.css index 0b2c975f21..2d4914b7c5 100644 --- a/src/skins/admin/en/order/page/info.css +++ b/src/skins/admin/en/order/page/info.css @@ -166,16 +166,48 @@ div.line-2 .box .address strong { display: block; } -div.line-2 .box .address p { +div.line-2 .box .address ul.address-section { + padding-top: 12px; +} + +div.line-2 .box .address ul.address-section li.address-field { + padding-right: 4px; +} + +div.line-2 .box .address ul.address-section li.address-field.address-custom_state { + display: none; +} + +div.line-2 .box .address ul.address-section li.address-field span { font-size: 14px; line-height: 20px; padding-top: 8px; } -div.line-2 .box .address p.name { - padding-top: 12px; +ul.address-section li.address-field .address-title, + ul.address-section li.address-field .address-comma +{ + display: none; } +ul.address-section li.address-field.address-phone .address-title, + ul.address-section li.address-field.field-additional .address-title, + ul.address-section li.address-field.address-city .address-comma, + ul.address-section li.address-field.address-street .address-comma, + ul.address-section li.address-field.address-state .address-comma +{ + display: inline; +} + +ul.address-section li.address-field.address-title, + ul.address-section li.address-field.address-firstname, + ul.address-section li.address-field.address-city, + ul.address-section li.address-field.address-state +{ + float: left; +} + + /* Payment */ div.payment { float: left; diff --git a/src/skins/admin/en/order/page/parts/payment.address.tpl b/src/skins/admin/en/order/page/parts/payment.address.tpl index 73ed39864d..8496235560 100644 --- a/src/skins/admin/en/order/page/parts/payment.address.tpl +++ b/src/skins/admin/en/order/page/parts/payment.address.tpl @@ -13,15 +13,12 @@
{t(#Billing address#)} -

{order.profile.billing_address.title} {order.profile.billing_address.firstname} {order.profile.billing_address.lastname}

-

- {order.profile.billing_address.street}
- {order.profile.billing_address.city}, {order.profile.billing_address.state.state}, {order.profile.billing_address.zipcode}
- {order.profile.billing_address.country.country} -

- -

- {t(#Phone#)}: {order.profile.billing_address.phone} -

+
    +
  • + {field.title}: + {field.value} + , +
  • +
diff --git a/src/skins/admin/en/order/page/parts/shipping.address.tpl b/src/skins/admin/en/order/page/parts/shipping.address.tpl index 09af8d6817..b7b64cc43a 100644 --- a/src/skins/admin/en/order/page/parts/shipping.address.tpl +++ b/src/skins/admin/en/order/page/parts/shipping.address.tpl @@ -13,15 +13,12 @@
{t(#Shipping address#)} -

{order.profile.shipping_address.title} {order.profile.shipping_address.firstname} {order.profile.shipping_address.lastname}

-

- {order.profile.shipping_address.street}
- {order.profile.shipping_address.city}, {order.profile.shipping_address.state.state}, {order.profile.shipping_address.zipcode}
- {order.profile.shipping_address.country.country} -

- -

- {t(#Phone#)}: {order.profile.shipping_address.phone} -

+
    +
  • + {t(field.title)}: + {field.value} + , +
  • +
diff --git a/src/skins/admin/en/payment/configuration/style.css b/src/skins/admin/en/payment/configuration/style.css index a68154edd8..7120585baf 100644 --- a/src/skins/admin/en/payment/configuration/style.css +++ b/src/skins/admin/en/payment/configuration/style.css @@ -336,6 +336,10 @@ background-color: #f4f4f4; } +.add-payment-box .alternative-methods .body .body-box { + border: solid 1px #c2cbd2; +} + .add-payment-box .body .body-item.selected { display: block; } diff --git a/src/skins/admin/en/product/attributes.tpl b/src/skins/admin/en/product/attributes.tpl new file mode 100644 index 0000000000..344c59e7d7 --- /dev/null +++ b/src/skins/admin/en/product/attributes.tpl @@ -0,0 +1,31 @@ +{* vim: set ts=2 sw=2 sts=2 et: *} + +{** + * "Attributes" tab + * + * @author Creative Development LLC + * @copyright Copyright (c) 2011-2012 Creative Development LLC . All rights reserved + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + * @link http://www.litecommerce.com/ + *} + + + +{foreach:product.getClasses(),class} + {foreach:class.getAttributeGroups(),group} + + {end:} +{end:} +
+ + +
+
+ +
+ diff --git a/src/skins/admin/en/product/attributes/fields.tpl b/src/skins/admin/en/product/attributes/fields.tpl new file mode 100644 index 0000000000..302fa2af59 --- /dev/null +++ b/src/skins/admin/en/product/attributes/fields.tpl @@ -0,0 +1,17 @@ +{* vim: set ts=2 sw=2 sts=2 et: *} + +{** + * Fields + * + * @author Creative Development LLC + * @copyright Copyright (c) 2011-2012 Creative Development LLC . All rights reserved + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + * @link http://www.litecommerce.com/ + *} + +

{getTitle()}

+
    +
  • + {w.display()} +
  • +
diff --git a/src/skins/admin/en/product/attributes/style.css b/src/skins/admin/en/product/attributes/style.css new file mode 100644 index 0000000000..0df36ef121 --- /dev/null +++ b/src/skins/admin/en/product/attributes/style.css @@ -0,0 +1,57 @@ +/* vim: set ts=2 sw=2 sts=2 et: */ + +/** + * Attributes + * + * @author Creative Development LLC + * @copyright Copyright (c) 2011-2012 Creative Development LLC . All rights reserved + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + * @link http://www.litecommerce.com/ + */ + +.tab-content h3 { + margin-top: 32px; + color: #333; +} + +.table-label label { + color: #456583; + font-size: 14px; +} + +.table-value span.input-field-wrapper { + float: left; +} + +.tab-content .form-field-comment { + font-size: 16px; + color: #8f8f8f; +} + +.tab-content label.separ-tab { + color: #456583; + font-size: 16px; + float: left; + margin: 5px; +} + +.tab-content .attrSepTab-value { + width: auto; + float: left; +} + +.tab-content li { + margin-bottom: 8px; +} + +.table-value.checkbox label { + margin: 0; +} + +.table-label.checkbox { + float: right; +} + +.table-value .main-button { + line-height: 14px; +} diff --git a/src/skins/admin/en/product_class/body.tpl b/src/skins/admin/en/product_class/body.tpl new file mode 100644 index 0000000000..14db7a8af5 --- /dev/null +++ b/src/skins/admin/en/product_class/body.tpl @@ -0,0 +1,11 @@ +{* vim: set ts=2 sw=2 sts=2 et: *} + +{** + * Product class page template + * + * @author Creative Development LLC + * @copyright Copyright (c) 2011-2012 Creative Development LLC . All rights reserved + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + * @link http://www.litecommerce.com/ + *} + \ No newline at end of file diff --git a/src/skins/admin/en/product_class/style.css b/src/skins/admin/en/product_class/style.css new file mode 100644 index 0000000000..1eeef3b5b2 --- /dev/null +++ b/src/skins/admin/en/product_class/style.css @@ -0,0 +1,10 @@ +/* vim: set ts=2 sw=2 sts=2 et: */ + +/** + * Product class view model styles + * + * @author Creative Development LLC + * @copyright Copyright (c) 2011-2012 Creative Development LLC . All rights reserved + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + * @link http://www.litecommerce.com/ + */ diff --git a/src/skins/admin/en/product_classes/body.tpl b/src/skins/admin/en/product_classes/body.tpl new file mode 100644 index 0000000000..f6a9b2fab1 --- /dev/null +++ b/src/skins/admin/en/product_classes/body.tpl @@ -0,0 +1,12 @@ +{* vim: set ts=2 sw=2 sts=2 et: *} + +{** + * Product classes page template + * + * @author Creative Development LLC + * @copyright Copyright (c) 2011-2012 Creative Development LLC . All rights reserved + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + * @link http://www.litecommerce.com/ + *} + + \ No newline at end of file diff --git a/src/skins/admin/en/product_classes/list.tpl b/src/skins/admin/en/product_classes/list.tpl new file mode 100644 index 0000000000..0f0fbf9121 --- /dev/null +++ b/src/skins/admin/en/product_classes/list.tpl @@ -0,0 +1,14 @@ +{* vim: set ts=2 sw=2 sts=2 et: *} + +{** + * Product classes list table template + * + * @author Creative Development LLC + * @copyright Copyright (c) 2011-2012 Creative Development LLC . All rights reserved + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + * @link http://www.litecommerce.com/ + *} + + + + \ No newline at end of file diff --git a/src/skins/admin/en/product_classes/list/body.tpl b/src/skins/admin/en/product_classes/list/body.tpl deleted file mode 100644 index fca0463e90..0000000000 --- a/src/skins/admin/en/product_classes/list/body.tpl +++ /dev/null @@ -1,36 +0,0 @@ -{* vim: set ts=2 sw=2 sts=2 et: *} - -{** - * Product classes list page - * - * @author Creative Development LLC - * @copyright Copyright (c) 2011-2012 Creative Development LLC . All rights reserved - * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) - * @link http://www.litecommerce.com/ - *} - -{* Refactor to ItemsList*} - -
- -
- - - - - - - - - - - - -
- - - -
-
diff --git a/src/skins/admin/en/product_classes/list/css/style.css b/src/skins/admin/en/product_classes/list/css/style.css deleted file mode 100644 index 03868b4690..0000000000 --- a/src/skins/admin/en/product_classes/list/css/style.css +++ /dev/null @@ -1,49 +0,0 @@ -/* vim: set ts=2 sw=2 sts=2 et: */ - -/** - * Product classes list styles - * - * @author Creative Development LLC - * @copyright Copyright (c) 2011-2012 Creative Development LLC . All rights reserved - * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) - * @link http://www.litecommerce.com/ - */ - -table.product-classes-list { - border-spacing: 0px; -} - -table.product-classes-list td { - border-bottom: solid 1px #eaeaea; -} - -table.product-classes-list tr:first-child td { - border-top: solid 1px #eaeaea; -} - -table.product-classes-list td.input-name { - width: 530px; -} - -.remove-product-class img.remove { - background: transparent url(../images/trash.png) 0 0 no-repeat; - width: 17px; - height: 16px; -} - -.remove-product-class img.separator { - background: transparent url(../images/separator.png) 0 0 repeat-y; - width: 1px; - height: 15px; - margin-right: 10px; -} - -.new-product-class .advanced-input-text .original-label:hover { - background-color: inherit; -} - -.new-product-class .advanced-input-text .original-label { - text-decoration: underline; - color: #154E9C; - cursor: pointer; -} diff --git a/src/skins/admin/en/product_classes/list/images/separator.png b/src/skins/admin/en/product_classes/list/images/separator.png deleted file mode 100644 index 6dab8c00eb..0000000000 Binary files a/src/skins/admin/en/product_classes/list/images/separator.png and /dev/null differ diff --git a/src/skins/admin/en/product_classes/list/images/trash.png b/src/skins/admin/en/product_classes/list/images/trash.png deleted file mode 100644 index 25cda0df6e..0000000000 Binary files a/src/skins/admin/en/product_classes/list/images/trash.png and /dev/null differ diff --git a/src/skins/admin/en/product_classes/list/js/script.js b/src/skins/admin/en/product_classes/list/js/script.js deleted file mode 100644 index f6c9206508..0000000000 --- a/src/skins/admin/en/product_classes/list/js/script.js +++ /dev/null @@ -1,221 +0,0 @@ -/* vim: set ts=2 sw=2 sts=2 et: */ - -/** - * Product classes list controller - * - * @author Creative Development LLC - * @copyright Copyright (c) 2011-2012 Creative Development LLC . All rights reserved - * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) - * @link http://www.litecommerce.com/ - */ - -// Update with AJAX product class widget -window.core.updateProductClassAJAX = function (obj, widget) -{ - widget.input.attr('readonly', 'readonly'); - jQuery('img.progress', widget.inputBlock).addClass('ajax-progress'); - widget.cancel.hide(); - - var id = core.getProductClassId(widget); - var name = widget.input.val(); - var action = core.getProductClassAction(widget); - - jQuery.ajax( - { - type: 'get', - url: URLHandler.buildURL({'target': 'product_class', 'action': action, 'name': name, 'id' : id}), - timeout: 15000, - complete: function(xhr, s) { - widget.input.removeAttr('readonly'); - jQuery('img.progress', widget.inputBlock).removeClass('ajax-progress'); - widget.cancel.show(); - widget.cancelValue = name; - - obj.enterValue(widget); - - if ('add' === action) { - widget.input.val(''); - core.addProductClass(widget, jQuery.parseJSON(xhr.responseText).data); - } - } - } - ); // jQuery.ajax - -} - -window.core.addProductClass = function (widget, data) -{ - jQuery('img.progress', widget.inputBlock).addClass('ajax-progress'); - - jQuery.ajax( - { - type: 'get', - url: URLHandler.buildURL( - { - 'target': 'product_classes', - 'widget': '\\XLite\\View\\ProductClass\\MainInput', - 'className': data.name, - 'classId' : data.id - } - ), - timeout: 15000, - complete: function(xhr, s) { - - // TODO!!!! change it - var newRow = xhr.responseText.match(/
((\W|\w)+)<\/div>$/)[1]; - - jQuery('table.product-classes-list tr:last-child').before(newRow); - - var newHandler = new AdvancedInputHandler(); - - newHandler.changeActions(); - - jQuery('img.progress', widget.inputBlock).removeClass('ajax-progress'); - } - } - ); -} - -// Return product class id from widget -window.core.getProductClassId = function (widget) -{ - return widget.input.attr('id').toString().replace(/posteddata-|-name/g, ''); -} - -// Return product class action from widget -window.core.getProductClassAction = function (widget) -{ - return 'new' == core.getProductClassId(widget) ? 'add' : 'update'; -} - -// Decoration of the products list widget class -core.bind( - 'load', - function() { - - // Standard submit event handler is removed (AJAX is used) - jQuery('#product-class-form').submit( - function (event) { - event.preventDefault(); - } - ); - - // Decoration of 'enterValue' method of Advanced Input widget - decorate( - 'AdvancedInputHandler', - 'enterValue', - function (widget) - { - var prevLabel = widget.label.html(); - arguments.callee.previousMethod.apply(this, arguments); - - if (widget.label.closest('td').hasClass('new-product-class')) { - widget.label.html(prevLabel); - } - } - ); - - // Decoration of 'addActions' method of Advanced Input widget - decorate( - 'AdvancedInputHandler', - 'addActions', - function(widget) - { - // previous method call - arguments.callee.previousMethod.apply(this, arguments); - - var o = this; - - widget.input.keypress( - function (event) { - event.stopImmediatePropagation(); - - if (13 === event.which) { - event.preventDefault(); - - core.updateProductClassAJAX(o, widget); - } - } - ); - - widget.label.click(function (e) { - var obj = jQuery(this); - - e.stopImmediatePropagation(); - - jQuery(o.pattern).each(function () { - var widgetToUpdate = this.widget; - - if ( - widget.input.attr('name') != widgetToUpdate.input.attr('name') - ) { - if ( - 'add' != core.getProductClassAction(widgetToUpdate) - && 'none' != widgetToUpdate.inputBlock.css('display') - && widgetToUpdate.input.cancelValue != widgetToUpdate.input.val() - ) { - core.updateProductClassAJAX(o, widgetToUpdate); - } else { - o.enterValue(widgetToUpdate); - } - } - }); - - jQuery('body') - .unbind('click') - .bind( - 'click', - function (event) { - event.stopImmediatePropagation(); - - if ( - widget.input.cancelValue !== widget.input.val() - && 'update' === core.getProductClassAction(widget) - ) { - core.updateProductClassAJAX(o, widget); - } else { - o.enterValue(widget); - } - - }); - }); - - widget.cancel.click(function (event) { - event.stopImmediatePropagation(); - - o.cancel(widget); - }); - - var removeActionObject = jQuery('.remove-product-class a.remove', widget.inputBlock.closest('tr')); - var href = removeActionObject.attr('href'); - - removeActionObject.attr('href', 'javascript:void(0);'); - - removeActionObject.click( - function (event) { - var o = jQuery(this); - - event.stopPropagation(); - - jQuery('img.remove', o).removeClass('remove').addClass('ajax-progress'); - - jQuery.ajax( - { - type: 'get', - url: href, - timeout: 15000, - complete: function(xhr, s) { - jQuery('img.ajax-progress', o).addClass('remove').removeClass('ajax-progress'); - - o.closest('tr').slideUp('slow').remove(); - } - } - ); // jQuery.ajax - } - ); // o.click - - } // addActions method - ); // 'postprocess' method decoration (EXISTING method) - - } -); // core.bind() diff --git a/src/skins/admin/en/product_classes/list/parts/columns/new.tpl b/src/skins/admin/en/product_classes/list/parts/columns/new.tpl deleted file mode 100644 index a30ebcb3b1..0000000000 --- a/src/skins/admin/en/product_classes/list/parts/columns/new.tpl +++ /dev/null @@ -1,17 +0,0 @@ -{* vim: set ts=2 sw=2 sts=2 et: *} - -{** - * Product class new element - * - * @author Creative Development LLC - * @copyright Copyright (c) 2011-2012 Creative Development LLC . All rights reserved - * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) - * @link http://www.litecommerce.com/ - * - * @ListChild (list="productClasses.list.columns.new", weight="100") - *} - - - - -  diff --git a/src/skins/admin/en/product_classes/list/parts/columns/remove.tpl b/src/skins/admin/en/product_classes/list/parts/columns/remove.tpl deleted file mode 100644 index dfba38d548..0000000000 --- a/src/skins/admin/en/product_classes/list/parts/columns/remove.tpl +++ /dev/null @@ -1,17 +0,0 @@ -{* vim: set ts=2 sw=2 sts=2 et: *} - -{** - * Remove button - * - * @author Creative Development LLC - * @copyright Copyright (c) 2011-2012 Creative Development LLC . All rights reserved - * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) - * @link http://www.litecommerce.com/ - * - * @ListChild (list="product_classes.main_input", weight="200") - *} - - - | - {t(#Remove#)} - diff --git a/src/skins/admin/en/product_classes/parts/edit_attributes.tpl b/src/skins/admin/en/product_classes/parts/edit_attributes.tpl new file mode 100644 index 0000000000..10c734ddc7 --- /dev/null +++ b/src/skins/admin/en/product_classes/parts/edit_attributes.tpl @@ -0,0 +1,12 @@ +{* vim: set ts=2 sw=2 sts=2 et: *} + +{** + * Edit attributes + * + * @author Creative Development LLC + * @copyright Copyright (c) 2011-2012 Creative Development LLC . All rights reserved + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + * @link http://www.litecommerce.com/ + *} + +{t(#Edit attributes#)} ({entity.getAttributesCount()}) diff --git a/src/skins/admin/en/product_classes/style.css b/src/skins/admin/en/product_classes/style.css new file mode 100644 index 0000000000..8e5d03470d --- /dev/null +++ b/src/skins/admin/en/product_classes/style.css @@ -0,0 +1,19 @@ +/* vim: set ts=2 sw=2 sts=2 et: */ + +/** + * Product classes list styles + * + * @author Creative Development LLC + * @copyright Copyright (c) 2011-2012 Creative Development LLC . All rights reserved + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + * @link http://www.litecommerce.com/ + */ + +.items-list-table table.list tbody.lines td.cell span.products, +.items-list-table table.list tbody.lines td.cell a +{ + color: #8f8f8f; +} +.items-list-table table.list tbody.lines td.cell a { + text-decoration: underline; +} diff --git a/src/skins/admin/en/shipping/settings.tpl b/src/skins/admin/en/shipping/settings.tpl index 1e439a9744..387c771a81 100644 --- a/src/skins/admin/en/shipping/settings.tpl +++ b/src/skins/admin/en/shipping/settings.tpl @@ -35,7 +35,7 @@ {end:} {if:option.type=#country#"} - + {end:} {if:option.type=#state#"} diff --git a/src/skins/common/js/common.js b/src/skins/common/js/common.js index 18fb29144d..21b27b427e 100644 --- a/src/skins/common/js/common.js +++ b/src/skins/common/js/common.js @@ -1,3 +1,4 @@ + /* vim: set ts=2 sw=2 sts=2 et: */ /** @@ -154,6 +155,11 @@ function openDialog(selector, additionalOptions) overflow: 'visible' } ); + }, + close: function (event) { + jQuery('form', jQuery('.ui-dialog ' + selector)).each(function (index, elem) { + jQuery(elem).validationEngine('hide'); + }); } } @@ -502,3 +508,26 @@ function attachTooltip(elm, content) { } ); } + +/** + * State widget specific objects and methods (used in select_country.js ) + * @TODO : Move it to the one object after dynamic loading widgets JS implementation + */ +var statesList = []; +var stateSelectors = []; + +function UpdateStatesList() +{ + var _stateSelectors; + + jQuery('.country-selector').each(function (index, elem) { + statesList = array_merge(statesList, core.getCommentedData(elem, 'statesList')); + _stateSelectors = core.getCommentedData(elem, 'stateSelectors'); + + stateSelectors[_stateSelectors.fieldId] = new StateSelector( + _stateSelectors.fieldId, + _stateSelectors.stateSelectorId, + _stateSelectors.stateInputId + ); + }); +} diff --git a/src/skins/common/js/core.popup.js b/src/skins/common/js/core.popup.js index 63e6060f8f..8ed1776d49 100644 --- a/src/skins/common/js/core.popup.js +++ b/src/skins/common/js/core.popup.js @@ -307,6 +307,9 @@ popup.open = function(box) var o = this; jQuery('.blockMsg a.close-link').click( function(event) { + jQuery('form', jQuery(o)).each(function (index, elem) { + jQuery(elem).validationEngine('hide'); + }); o.close(); return false; } diff --git a/src/skins/common/js/php.js b/src/skins/common/js/php.js index 30419eca1c..78bf5888fe 100644 --- a/src/skins/common/js/php.js +++ b/src/skins/common/js/php.js @@ -527,3 +527,69 @@ function str_replace (search, replace, subject, count) { return sa ? s : s[0]; } +function array_merge () { + // Merges elements from passed arrays into one array + // + // version: 1109.2015 + // discuss at: http://phpjs.org/functions/array_merge + // + original by: Brett Zamir (http://brett-zamir.me) + // + bugfixed by: Nate + // + input by: josh + // + bugfixed by: Brett Zamir (http://brett-zamir.me) + // * example 1: arr1 = {"color": "red", 0: 2, 1: 4} + // * example 1: arr2 = {0: "a", 1: "b", "color": "green", "shape": "trapezoid", 2: 4} + // * example 1: array_merge(arr1, arr2) + // * returns 1: {"color": "green", 0: 2, 1: 4, 2: "a", 3: "b", "shape": "trapezoid", 4: 4} + // * example 2: arr1 = [] + // * example 2: arr2 = {1: "data"} + // * example 2: array_merge(arr1, arr2) + // * returns 2: {0: "data"} + var args = Array.prototype.slice.call(arguments), + argl = args.length, + arg, + retObj = {}, + k = '', + argil = 0, + j = 0, + i = 0, + ct = 0, + toStr = Object.prototype.toString, + retArr = true; + + for (i = 0; i < argl; i++) { + if (toStr.call(args[i]) !== '[object Array]') { + retArr = false; + break; + } + } + + if (retArr) { + retArr = []; + for (i = 0; i < argl; i++) { + retArr = retArr.concat(args[i]); + } + return retArr; + } + + for (i = 0, ct = 0; i < argl; i++) { + arg = args[i]; + if (toStr.call(arg) === '[object Array]') { + for (j = 0, argil = arg.length; j < argil; j++) { + retObj[ct++] = arg[j]; + } + } + else { + for (k in arg) { + if (arg.hasOwnProperty(k)) { + if (parseInt(k, 10) + '' === k) { + retObj[ct++] = arg[k]; + } + else { + retObj[k] = arg[k]; + } + } + } + } + } + return retObj; +} diff --git a/src/skins/common/js/validationEngine/custom.validationEngine.js b/src/skins/common/js/validationEngine/custom.validationEngine.js new file mode 100644 index 0000000000..26c93ca794 --- /dev/null +++ b/src/skins/common/js/validationEngine/custom.validationEngine.js @@ -0,0 +1,8 @@ +(function($){ + + $.validationEngineLanguage.allRules.onlySmallLetterNumberUnder = { + "regex": /^[a-z][0-9a-z_]+$/, + "alertText": "* Only small letter, digits and undescore sign are allowed" + }; + +})(jQuery); \ No newline at end of file diff --git a/src/skins/default/en/address/style.css b/src/skins/default/en/address/style.css index 2c2eb8fcc0..f3b3b33136 100644 --- a/src/skins/default/en/address/style.css +++ b/src/skins/default/en/address/style.css @@ -272,6 +272,3 @@ ul.default-table li.address-phone { clear: none; } -ul.default-table li.address-phone label { - width: 50px; -} diff --git a/src/skins/default/en/button/js/add_address.js b/src/skins/default/en/button/js/add_address.js index bb82bd8c63..4ec3e10e16 100644 --- a/src/skins/default/en/button/js/add_address.js +++ b/src/skins/default/en/button/js/add_address.js @@ -24,6 +24,7 @@ decorate( function (selector) { // Some autoloading could be added + UpdateStatesList(); } ); diff --git a/src/skins/default/en/button/js/modify_address.js b/src/skins/default/en/button/js/modify_address.js index 6946f75b84..af9981e374 100644 --- a/src/skins/default/en/button/js/modify_address.js +++ b/src/skins/default/en/button/js/modify_address.js @@ -24,6 +24,7 @@ decorate( function (selector) { // Some autoloading could be added + UpdateStatesList(); } ); diff --git a/src/skins/default/en/checkout/checkout.css b/src/skins/default/en/checkout/checkout.css index eb61826c19..d73e671f55 100644 --- a/src/skins/default/en/checkout/checkout.css +++ b/src/skins/default/en/checkout/checkout.css @@ -19,3 +19,41 @@ color: #EE0000; padding-bottom: 25px; } + +.item-custom_state { + display: none; +} + +.address-text-label, + .address-text-comma +{ + display: none; +} + +ul.address-box > li { + padding: 0px 0px 2px 2px; + float: left; + clear: left; +} + +ul.address-box li ul li { + float: left; + clear: none; +} + +ul.address-box li.address-text-lastname, + ul.address-box li.address-text-firstname, + ul.address-box li.address-text-state_id, + ul.address-box li.address-text-zipcode +{ + clear: none; +} + +ul.address-box li.address-text-city .address-text-comma, + ul.address-box li.address-text-state_id .address-text-comma, + ul.address-box li.address-text-country_code .address-text-comma, + ul.address-box li.address-text-phone .address-text-label +{ + display: inherit; +} + diff --git a/src/skins/default/en/checkout/controller.js b/src/skins/default/en/checkout/controller.js index 5a66ef0e5f..844f55d19d 100644 --- a/src/skins/default/en/checkout/controller.js +++ b/src/skins/default/en/checkout/controller.js @@ -43,16 +43,16 @@ function CheckoutView(base) core.bind( 'updateCart', function(event, data) { - if (data.billingAddress && jQuery('.payment-step .same-address #same_address').length && !o.isLoadingStart) { + if (data.billingAddress && jQuery('#same_address').length && !o.isLoadingStart) { // Change same-address checkbox and reload billing address after change address into address book popup if ( - (data.billingAddress.same && 0 == jQuery('.payment-step .same-address #same_address:checked').length) - || (!data.billingAddress.same && 1 == jQuery('.payment-step .same-address #same_address:checked').length) + (data.billingAddress.same && 0 == jQuery('#same_address:checked').length) + || (!data.billingAddress.same && 1 == jQuery('#same_address:checked').length) ) { // Change from not-same-address to same-address or revert - var chk = jQuery('.payment-step .same-address #same_address').get(0); + var chk = jQuery('#same_address').get(0); if (chk) { chk.checked = !chk.checked; } @@ -320,7 +320,7 @@ CheckoutView.prototype.postprocess = function(isSuccess, initial) o.isLoadingStart = true; - return jQuery('.payment-step .same-address #same_address:checked', o.base).length + return jQuery('#same_address:checked').length ? !o.load() : !(jQuery('.payment-step.current .secondary form', o.base).submit() && o.shade()); } @@ -442,6 +442,8 @@ CheckoutView.prototype.postprocess = function(isSuccess, initial) } ); + UpdateStatesList(); + // Refresh state this.refreshState(); } @@ -622,7 +624,7 @@ CheckoutView.prototype.refreshState = function() var paymentIsReady = (jQuery('ul.payments').length > 0) ? (1 == jQuery('ul.payments input:checked', this.base).length) : true; // Billing address is ready (completed) - isSameAddress = 1 == jQuery('.same-address #same_address:checked', this.base).length; + isSameAddress = 1 == jQuery('#same_address:checked').length; var billingAddressIsReady = isSameAddress || (0 < jQuery('form.billing-address ul.form :input', this.base).length && jQuery('form.billing-address', this.base).get(0).validate(true)); @@ -807,7 +809,7 @@ ShippingAddressView.prototype.postprocess = function(isSuccess, initial) form.getElements().each( function() { var t = jQuery(this); - if (t.hasClass('field-zipcode') || t.hasClass('field-country') || t.hasClass('field-state')) { + if (t.hasClass('field-street') || t.hasClass('field-zipcode') || t.hasClass('field-country') || t.hasClass('field-state')) { this.markAsWatcher( function(element) { o.parentWidget.refreshSignificantShippingFields(element); @@ -873,7 +875,7 @@ BillingAddressView.prototype.postprocess = function(isSuccess, initial) } ); - jQuery('.same-address #same_address', this.base).change( + jQuery('#same_address').change( function(event) { o.changeSameAddress = true; o.parentWidget.refreshState(); @@ -892,6 +894,10 @@ BillingAddressView.prototype.postprocess = function(isSuccess, initial) if (!initial) { this.parentWidget.refreshState(); } + + if (this.parentWidget) { + UpdateStatesList(); + } } } diff --git a/src/skins/default/en/checkout/parts/address.plain.tpl b/src/skins/default/en/checkout/parts/address.plain.tpl index b9731d11b7..130fa5a08a 100644 --- a/src/skins/default/en/checkout/parts/address.plain.tpl +++ b/src/skins/default/en/checkout/parts/address.plain.tpl @@ -8,12 +8,17 @@ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) * @link http://www.litecommerce.com/ *} -
-
{address.name}
-
- {address.street}
- {address.city}, {address.state.state}, {address.zipcode}
- {address.country.country}
-
-
{t(#Phone#)}: {address.phone}
-
+ +
    + {foreach:getAddressFields(),fieldName,fieldData} +
  • +
      +
    • {fieldData.label}:
    • +
    • {getFieldValue(fieldName,address,1)}
    • +
    • ,
    • +
    +
  • + {end:} +
+ +
diff --git a/src/skins/default/en/checkout/steps/payment/address.tpl b/src/skins/default/en/checkout/steps/payment/address.tpl index f9d3ebedb1..b548046f80 100644 --- a/src/skins/default/en/checkout/steps/payment/address.tpl +++ b/src/skins/default/en/checkout/steps/payment/address.tpl @@ -21,7 +21,18 @@ {else:}
    - +
  • + +
  • +
{if:!isAnonymous()} diff --git a/src/skins/default/en/checkout/steps/payment/parts/address.address.tpl b/src/skins/default/en/checkout/steps/payment/parts/address.address.tpl deleted file mode 100644 index c28f35a3fc..0000000000 --- a/src/skins/default/en/checkout/steps/payment/parts/address.address.tpl +++ /dev/null @@ -1,16 +0,0 @@ -{* vim: set ts=2 sw=2 sts=2 et: *} - -{** - * Billing address : street - * - * @author Creative Development LLC - * @copyright Copyright (c) 2011-2012 Creative Development LLC . All rights reserved - * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) - * @link http://www.litecommerce.com/ - * - * @ListChild (list="checkout.payment.address", weight="20") - *} -
  • - - -
  • diff --git a/src/skins/default/en/checkout/steps/payment/parts/address.country.tpl b/src/skins/default/en/checkout/steps/payment/parts/address.country.tpl deleted file mode 100644 index 620805ccce..0000000000 --- a/src/skins/default/en/checkout/steps/payment/parts/address.country.tpl +++ /dev/null @@ -1,16 +0,0 @@ -{* vim: set ts=2 sw=2 sts=2 et: *} - -{** - * Billing address : country - * - * @author Creative Development LLC - * @copyright Copyright (c) 2011-2012 Creative Development LLC . All rights reserved - * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) - * @link http://www.litecommerce.com/ - * - * @ListChild (list="checkout.payment.address", weight="30") - *} -
  • - - -
  • diff --git a/src/skins/default/en/checkout/steps/payment/parts/address.name.tpl b/src/skins/default/en/checkout/steps/payment/parts/address.name.tpl deleted file mode 100644 index 8dfffb9ec2..0000000000 --- a/src/skins/default/en/checkout/steps/payment/parts/address.name.tpl +++ /dev/null @@ -1,16 +0,0 @@ -{* vim: set ts=2 sw=2 sts=2 et: *} - -{** - * Billing address : name - * - * @author Creative Development LLC - * @copyright Copyright (c) 2011-2012 Creative Development LLC . All rights reserved - * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) - * @link http://www.litecommerce.com/ - * - * @ListChild (list="checkout.payment.address", weight="10") - *} -
  • - - -
  • diff --git a/src/skins/default/en/checkout/steps/payment/parts/address.phone.tpl b/src/skins/default/en/checkout/steps/payment/parts/address.phone.tpl deleted file mode 100644 index 5f3dbc6327..0000000000 --- a/src/skins/default/en/checkout/steps/payment/parts/address.phone.tpl +++ /dev/null @@ -1,16 +0,0 @@ -{* vim: set ts=2 sw=2 sts=2 et: *} - -{** - * Billing address : phone - * - * @author Creative Development LLC - * @copyright Copyright (c) 2011-2012 Creative Development LLC . All rights reserved - * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) - * @link http://www.litecommerce.com/ - * - * @ListChild (list="checkout.payment.address", weight="70") - *} -
  • - - -
  • diff --git a/src/skins/default/en/checkout/steps/payment/parts/address.state.tpl b/src/skins/default/en/checkout/steps/payment/parts/address.state.tpl deleted file mode 100644 index 6714a9fa47..0000000000 --- a/src/skins/default/en/checkout/steps/payment/parts/address.state.tpl +++ /dev/null @@ -1,16 +0,0 @@ -{* vim: set ts=2 sw=2 sts=2 et: *} - -{** - * Billing address : state - * - * @author Creative Development LLC - * @copyright Copyright (c) 2011-2012 Creative Development LLC . All rights reserved - * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) - * @link http://www.litecommerce.com/ - * - * @ListChild (list="checkout.payment.address", weight="40") - *} -
  • - - -
  • diff --git a/src/skins/default/en/checkout/steps/payment/parts/address.zipcode.tpl b/src/skins/default/en/checkout/steps/payment/parts/address.zipcode.tpl deleted file mode 100644 index b6ce4b798d..0000000000 --- a/src/skins/default/en/checkout/steps/payment/parts/address.zipcode.tpl +++ /dev/null @@ -1,16 +0,0 @@ -{* vim: set ts=2 sw=2 sts=2 et: *} - -{** - * Billing address : zipcode - * - * @author Creative Development LLC - * @copyright Copyright (c) 2011-2012 Creative Development LLC . All rights reserved - * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) - * @link http://www.litecommerce.com/ - * - * @ListChild (list="checkout.payment.address", weight="60") - *} -
  • - - -
  • diff --git a/src/skins/default/en/checkout/steps/shipping/address.tpl b/src/skins/default/en/checkout/steps/shipping/address.tpl index 85bb47e2c0..745ee33f6c 100644 --- a/src/skins/default/en/checkout/steps/shipping/address.tpl +++ b/src/skins/default/en/checkout/steps/shipping/address.tpl @@ -8,6 +8,18 @@ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) * @link http://www.litecommerce.com/ *} +
      - +
    • + +
    • +
    diff --git a/src/skins/default/en/checkout/steps/shipping/parts/address.address.tpl b/src/skins/default/en/checkout/steps/shipping/parts/address.address.tpl deleted file mode 100644 index f0fe061b57..0000000000 --- a/src/skins/default/en/checkout/steps/shipping/parts/address.address.tpl +++ /dev/null @@ -1,16 +0,0 @@ -{* vim: set ts=2 sw=2 sts=2 et: *} - -{** - * Shipping address : street - * - * @author Creative Development LLC - * @copyright Copyright (c) 2011-2012 Creative Development LLC . All rights reserved - * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) - * @link http://www.litecommerce.com/ - * - * @ListChild (list="checkout.shipping.address", weight="20") - *} -
  • - - -
  • diff --git a/src/skins/default/en/checkout/steps/shipping/parts/address.city.tpl b/src/skins/default/en/checkout/steps/shipping/parts/address.city.tpl deleted file mode 100644 index b3a7b46da7..0000000000 --- a/src/skins/default/en/checkout/steps/shipping/parts/address.city.tpl +++ /dev/null @@ -1,16 +0,0 @@ -{* vim: set ts=2 sw=2 sts=2 et: *} - -{** - * Shipping address : city - * - * @author Creative Development LLC - * @copyright Copyright (c) 2011-2012 Creative Development LLC . All rights reserved - * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) - * @link http://www.litecommerce.com/ - * - * @ListChild (list="checkout.shipping.address", weight="50") - *} -
  • - - -
  • diff --git a/src/skins/default/en/checkout/steps/shipping/parts/address.country.tpl b/src/skins/default/en/checkout/steps/shipping/parts/address.country.tpl deleted file mode 100644 index f2984db817..0000000000 --- a/src/skins/default/en/checkout/steps/shipping/parts/address.country.tpl +++ /dev/null @@ -1,16 +0,0 @@ -{* vim: set ts=2 sw=2 sts=2 et: *} - -{** - * Shipping address : country - * - * @author Creative Development LLC - * @copyright Copyright (c) 2011-2012 Creative Development LLC . All rights reserved - * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) - * @link http://www.litecommerce.com/ - * - * @ListChild (list="checkout.shipping.address", weight="30") - *} -
  • - - -
  • diff --git a/src/skins/default/en/checkout/steps/shipping/parts/address.name.tpl b/src/skins/default/en/checkout/steps/shipping/parts/address.name.tpl deleted file mode 100644 index 42ebc21b6f..0000000000 --- a/src/skins/default/en/checkout/steps/shipping/parts/address.name.tpl +++ /dev/null @@ -1,16 +0,0 @@ -{* vim: set ts=2 sw=2 sts=2 et: *} - -{** - * Shipping address : name - * - * @author Creative Development LLC - * @copyright Copyright (c) 2011-2012 Creative Development LLC . All rights reserved - * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) - * @link http://www.litecommerce.com/ - * - * @ListChild (list="checkout.shipping.address", weight="10") - *} -
  • - - -
  • diff --git a/src/skins/default/en/checkout/steps/shipping/parts/address.phone.tpl b/src/skins/default/en/checkout/steps/shipping/parts/address.phone.tpl deleted file mode 100644 index f657b59cf7..0000000000 --- a/src/skins/default/en/checkout/steps/shipping/parts/address.phone.tpl +++ /dev/null @@ -1,16 +0,0 @@ -{* vim: set ts=2 sw=2 sts=2 et: *} - -{** - * Shipping address : phone - * - * @author Creative Development LLC - * @copyright Copyright (c) 2011-2012 Creative Development LLC . All rights reserved - * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) - * @link http://www.litecommerce.com/ - * - * @ListChild (list="checkout.shipping.address", weight="70") - *} -
  • - - -
  • diff --git a/src/skins/default/en/checkout/steps/shipping/parts/address.state.tpl b/src/skins/default/en/checkout/steps/shipping/parts/address.state.tpl deleted file mode 100644 index 05a4eb187c..0000000000 --- a/src/skins/default/en/checkout/steps/shipping/parts/address.state.tpl +++ /dev/null @@ -1,16 +0,0 @@ -{* vim: set ts=2 sw=2 sts=2 et: *} - -{** - * Shipping address : state - * - * @author Creative Development LLC - * @copyright Copyright (c) 2011-2012 Creative Development LLC . All rights reserved - * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) - * @link http://www.litecommerce.com/ - * - * @ListChild (list="checkout.shipping.address", weight="40") - *} -
  • - - -
  • diff --git a/src/skins/default/en/checkout/steps/shipping/parts/address.zipcode.tpl b/src/skins/default/en/checkout/steps/shipping/parts/address.zipcode.tpl deleted file mode 100644 index 5832653d1e..0000000000 --- a/src/skins/default/en/checkout/steps/shipping/parts/address.zipcode.tpl +++ /dev/null @@ -1,16 +0,0 @@ -{* vim: set ts=2 sw=2 sts=2 et: *} - -{** - * Shipping address : zipcode - * - * @author Creative Development LLC - * @copyright Copyright (c) 2011-2012 Creative Development LLC . All rights reserved - * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) - * @link http://www.litecommerce.com/ - * - * @ListChild (list="checkout.shipping.address", weight="60") - *} -
  • - - -
  • diff --git a/src/skins/default/en/css/lc.css b/src/skins/default/en/css/lc.css index af073fe2bf..18d7d5c6f7 100644 --- a/src/skins/default/en/css/lc.css +++ b/src/skins/default/en/css/lc.css @@ -1237,15 +1237,62 @@ div.product-details .continue-button-intend padding: 4px 0px; margin: 0px; background-image: none; - font-size: 16px; + font-size: 14px; } .product-details .extra-fields li strong { - width: 80px; font-weight: normal; + background-color: #fff; + padding-right: 3px; +} + +.product-details .extra-fields li h3 +{ + margin: 11px 0 0 0; + color: #456583; + font-size: 16px; +} + +.product-details .extra-fields li span +{ + display: inline-block; + color: #1f1f1f; + vertical-align: bottom; + max-width: 700px; +} + +.product-details .extra-fields li span.checkbox.no-checked +{ + color: #7e7e7e; +} + +.product-details .extra-fields li div +{ + width: 246px; display: inline-block; color: #7e7e7e; + background: url(../images/dotted.png) repeat-x scroll 0 bottom transparent; + vertical-align: top; +} + +.product-details .extra-fields li ul li div +{ + width: 226px; +} + +.product-details .extra-fields li ul li +{ + margin-top: 5px; +} + +.product-details .extra-fields li ul +{ + margin: 0 0 0 20px; +} + +.product-details .extra-fields ul { + line-height: 20px; } table.list-body td.hproduct a.product-thumbnail @@ -2356,6 +2403,7 @@ form.estimator .main, margin-top: 12px; margin-right: 4px; padding: 16px 20px; + height: 120px; } /* Step: order review */ @@ -2585,6 +2633,12 @@ form.estimator .main, } .select-address ul.addresses li { + background: none; + margin: 0px; + padding-left: 2px; +} + +.select-address ul.addresses > li { list-style: none; width: 278px; float: left; @@ -2601,11 +2655,11 @@ form.estimator .main, cursor: pointer; } -.select-address ul.addresses li.last { +.select-address ul.addresses > li.last { margin-right: 0px; } -.select-address ul.addresses li .shipping { +.select-address ul.addresses > li .shipping { position: absolute; right: 8px; bottom: 15px; @@ -2614,7 +2668,7 @@ form.estimator .main, height: 20px; } -.select-address ul.addresses li .billing { +.select-address ul.addresses > li .billing { position: absolute; right: 9px; bottom: 47px; diff --git a/src/skins/default/en/form_field.tpl b/src/skins/default/en/form_field.tpl index e7e3ff4161..d0862565b5 100644 --- a/src/skins/default/en/form_field.tpl +++ b/src/skins/default/en/form_field.tpl @@ -10,7 +10,7 @@ *} {if:!getParam(#fieldOnly#)} -
    +
    @@ -18,10 +18,11 @@
    {end:} -
    +
    {t(getParam(#comment#)):r}
    + {if:getFormFieldJSData()}{displayCommentedData(getFormFieldJSData())}{end:}
    diff --git a/src/skins/default/en/form_field/select_country.js b/src/skins/default/en/form_field/select_country.js index d4d86d9163..98104b6435 100644 --- a/src/skins/default/en/form_field/select_country.js +++ b/src/skins/default/en/form_field/select_country.js @@ -9,9 +9,6 @@ * @link http://www.litecommerce.com/ */ -var statesList = []; -var stateSelectors = []; - function StateSelector(countrySelectorId, stateSelectorId, stateInputId) { this.countrySelectBox = jQuery('#' + countrySelectorId); @@ -113,12 +110,19 @@ StateSelector.prototype.addStates = function(states) var s = this.stateSelectBox.get(0); var added = s.options.length; + var i = 0; if (states) { - for (var i = 0; i < states.length; i++) { - s.options[i + added] = new Option(states[i].state, states[i].id); + for (var key in states) { + s.options[i + added] = new Option(states[key], key); + i++; } } this.stateSelectBox.val(this.stateSavedValue); } + +jQuery(document).ready(function () { + UpdateStatesList(); +}); + diff --git a/src/skins/default/en/form_field/select_country.tpl b/src/skins/default/en/form_field/select_country.tpl index cc915650dc..69d31384ed 100644 --- a/src/skins/default/en/form_field/select_country.tpl +++ b/src/skins/default/en/form_field/select_country.tpl @@ -10,5 +10,5 @@ *} diff --git a/src/skins/default/en/form_field/select_state.tpl b/src/skins/default/en/form_field/select_state.tpl index 2bd4c1bc57..589166a7ba 100644 --- a/src/skins/default/en/form_field/select_state.tpl +++ b/src/skins/default/en/form_field/select_state.tpl @@ -12,5 +12,5 @@ diff --git a/src/skins/default/en/images/dotted.png b/src/skins/default/en/images/dotted.png new file mode 100644 index 0000000000..e790c20f51 Binary files /dev/null and b/src/skins/default/en/images/dotted.png differ diff --git a/src/skins/default/en/modules/CDev/ProductComparison/compare/products/body.tpl b/src/skins/default/en/modules/CDev/ProductComparison/compare/products/body.tpl new file mode 100644 index 0000000000..679c9bcdc8 --- /dev/null +++ b/src/skins/default/en/modules/CDev/ProductComparison/compare/products/body.tpl @@ -0,0 +1,22 @@ +{* vim: set ts=2 sw=2 sts=2 et: *} + +{** + * Body + * + * @author Creative Development LLC + * @copyright Copyright (c) 2011-2012 Creative Development LLC . All rights reserved + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + * @link http://www.litecommerce.com/ + *} +
    +
    +
    + + +
    +
    + {getTitle()} + +
    +
    +
    diff --git a/src/skins/default/en/modules/CDev/ProductComparison/compare/products/script.js b/src/skins/default/en/modules/CDev/ProductComparison/compare/products/script.js new file mode 100644 index 0000000000..858eeeeec8 --- /dev/null +++ b/src/skins/default/en/modules/CDev/ProductComparison/compare/products/script.js @@ -0,0 +1,94 @@ +/* vim: set ts=2 sw=2 sts=2 et: */ + +/** + * Product comparison + * + * @author Creative Development LLC + * @copyright Copyright (c) 2011-2012 Creative Development LLC . All rights reserved + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + * @link http://www.litecommerce.com/ + */ + +core.bind( + 'load', + function() { + decorate( + 'ProductsListView', + 'postprocess', + function(isSuccess, initial) + { + arguments.callee.previousMethod.apply(this, arguments); + + if (isSuccess) { + + var o = this; + + jQuery('div.product').mouseover( + function() { + jQuery(this).addClass('compare'); + } + ).mouseout( + function() { + jQuery(this).removeClass('compare'); + } + ); + + jQuery('div.compare-checkbox').mouseover( + function() { + jQuery(this).parent().addClass('visible'); + } + ); + + jQuery('div.compare-popup').mouseleave( + function() { + jQuery(this).removeClass('visible'); + } + ); + + jQuery('.compare-checkbox input').not('.binded').each( + function() { + var pr = jQuery(this); + pr.change( + function() { + pr.attr('disabled', 'disabled'); + var action = pr.attr('checked') ? 'add' : 'delete'; + core.post( + URLHandler.buildURL( + { + target: 'product_comparison', + action: action + } + ), + function(){}, + { + target: 'product_comparison', + action: action, + product_id: pr.data('id') + }, + { + rpc: true + } + ); + } + ); + core.bind('updateProductComparison', + function(event, data) { + if (data.productId == pr.data('id')) { + pr.removeAttr('disabled'); + if (data.action == 'add') { + pr.attr('checked', 'checked'); + + } else { + pr.removeAttr('checked'); + } + } + pr.parent().parent().find('.compare-products-selected').text(data.title); + } + ); + } + ).addClass('binded'); + } + } + ); + } +); diff --git a/src/skins/default/en/modules/CDev/ProductComparison/compare/products/style.css b/src/skins/default/en/modules/CDev/ProductComparison/compare/products/style.css new file mode 100644 index 0000000000..4ca93fc004 --- /dev/null +++ b/src/skins/default/en/modules/CDev/ProductComparison/compare/products/style.css @@ -0,0 +1,80 @@ +/* vim: set ts=2 sw=2 sts=2 et: */ + +/** + * Styles + * + * @author Creative Development LLC + * @copyright Copyright (c) 2011-2012 Creative Development LLC . All rights reserved + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + * @link http://www.litecommerce.com/ + */ +div.add-to-compare { + display: none; + width: 100%; + text-align: center; + position: absolute; + top: 170px; + left: 0; +} + +div.add-to-compare div.compare-popup { + margin: 0 30px; + top: 1px; + position: relative; +} + +div.add-to-compare div.compare-popup.visible { + margin: 0 29px; + top: 0; + -moz-border-radius: 4px; + -webkit-border-radius: 4px; + border-radius: 4px; + border: solid 1px #bbc7d2; + box-shadow: 2px 2px 3px #bbc7d2; + -moz-box-shadow: 2px 2px 3px #bbc7d2; + -webkit-box-shadow: 2px 2px 3px #bbc7d2; + background-color: #fff; +} + +div.add-to-compare div.compare-checkbox { + margin: 10px 30px; + position: relative; + top: 0; + padding: 2px; + -moz-border-radius: 4px; + -webkit-border-radius: 4px; + border-radius: 4px; + border: solid 1px #d7e1e8; + background-color: #eaf6fe; +} + +div.add-to-compare div.compare-checkbox label { + font-size: 12px; + color: #446482; +} + +div.add-to-compare div.compare-button { + display: none; + margin: 10px 0; + background-color: #fff; + color: #2c5fa6; + font-size: 14px; +} + +div.add-to-compare div.compare-popup.visible div.compare-button { + display: block; +} + +div.product.compare div.add-to-compare { + display: block; +} + +div.compare-button button { + margin: 10px 0 5px 0; + padding: 6px 6px; +} + +div.compare-button button span { + background: url(../../scales_icon.png) no-repeat 4px top transparent; + padding: 4px 4px 4px 36px; +} diff --git a/src/skins/default/en/modules/CDev/ProductComparison/compare/script.js b/src/skins/default/en/modules/CDev/ProductComparison/compare/script.js new file mode 100644 index 0000000000..6c76fba7cc --- /dev/null +++ b/src/skins/default/en/modules/CDev/ProductComparison/compare/script.js @@ -0,0 +1,15 @@ +/* vim: set ts=2 sw=2 sts=2 et: */ + +/** + * Product comparison + * + * @author Creative Development LLC + * @copyright Copyright (c) 2011-2012 Creative Development LLC . All rights reserved + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + * @link http://www.litecommerce.com/ + */ + +function addToCompare(id) +{ + alert(id); +} diff --git a/src/skins/default/en/modules/CDev/ProductComparison/scales_icon.png b/src/skins/default/en/modules/CDev/ProductComparison/scales_icon.png new file mode 100644 index 0000000000..3a54c9f0d5 Binary files /dev/null and b/src/skins/default/en/modules/CDev/ProductComparison/scales_icon.png differ diff --git a/src/skins/default/en/modules/CDev/ProductComparison/sidebar/body.tpl b/src/skins/default/en/modules/CDev/ProductComparison/sidebar/body.tpl new file mode 100644 index 0000000000..fc26c2283c --- /dev/null +++ b/src/skins/default/en/modules/CDev/ProductComparison/sidebar/body.tpl @@ -0,0 +1,16 @@ +{* vim: set ts=2 sw=2 sts=2 et: *} + +{** + * Body + * + * @author Creative Development LLC + * @copyright Copyright (c) 2011-2012 Creative Development LLC . All rights reserved + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + * @link http://www.litecommerce.com/ + *} +
    +
    +

    {t(getHead())}

    + {t(#Clear list#)} +
    +
    diff --git a/src/skins/default/en/modules/CDev/ProductComparison/sidebar/script.js b/src/skins/default/en/modules/CDev/ProductComparison/sidebar/script.js new file mode 100644 index 0000000000..11d6437294 --- /dev/null +++ b/src/skins/default/en/modules/CDev/ProductComparison/sidebar/script.js @@ -0,0 +1,69 @@ +/* vim: set ts=2 sw=2 sts=2 et: */ + +/** + * Product comparison + * + * @author Creative Development LLC + * @copyright Copyright (c) 2011-2012 Creative Development LLC . All rights reserved + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + * @link http://www.litecommerce.com/ + */ + +/** + * Widget + */ +function ProductComparisonView(base) +{ + this.callSupermethod('constructor', arguments); + var o = this; + core.bind( + 'updateProductComparison', + function(event, data) { + o.load(); + } + ); +} + +extend(ProductComparisonView, ALoadable); + +ProductComparisonView.autoload = function(){ + new ProductComparisonView(jQuery('.product-comparison')); +}; + +// No shade widget +ProductComparisonView.prototype.shadeWidget = false; + +// Widget target +ProductComparisonView.prototype.widgetTarget = 'main'; + +// Widget class name +ProductComparisonView.prototype.widgetClass = '\\XLite\\Module\\CDev\\ProductComparison\\View\\ProductComparison'; + +// Body handler is binded or not +ProductComparisonView.prototype.bodyHandlerBinded = false; + +// Clear list +ProductComparisonView.prototype.clearList = function() +{ + this.load({action: 'clear'}); + + return false; +} + +// Postprocess widget +ProductComparisonView.prototype.postprocess = function(isSuccess) +{ + this.callSupermethod('postprocess', arguments); + + if (isSuccess) { + var o = this; + + jQuery('.clear-list').click( + function() { + return o.clearList(); + } + ); + } +} + +core.autoload(ProductComparisonView); diff --git a/src/skins/default/en/order/invoice/parts/bottom.address.billing.tpl b/src/skins/default/en/order/invoice/parts/bottom.address.billing.tpl index 6786323c56..ea0b08fd45 100644 --- a/src/skins/default/en/order/invoice/parts/bottom.address.billing.tpl +++ b/src/skins/default/en/order/invoice/parts/bottom.address.billing.tpl @@ -12,19 +12,13 @@ *} {t(#Billing address#)} -

    - {order.profile.billing_address.title} {order.profile.billing_address.firstname} {order.profile.billing_address.lastname} -

    - -

    - {order.profile.billing_address.street}
    - {order.profile.billing_address.city}, {order.profile.billing_address.state.state}, {order.profile.billing_address.zipcode}
    - {order.profile.billing_address.country.country} -

    - -

    - {t(#Phone#)}: {order.profile.billing_address.phone} -

    +
      +
    • + {t(field.title)}: + {field.value} + , +
    • +

    {t(#E-mail#)}: {order.profile.login} diff --git a/src/skins/default/en/order/invoice/parts/bottom.address.shipping.tpl b/src/skins/default/en/order/invoice/parts/bottom.address.shipping.tpl index a236824fee..d1660e70ac 100644 --- a/src/skins/default/en/order/invoice/parts/bottom.address.shipping.tpl +++ b/src/skins/default/en/order/invoice/parts/bottom.address.shipping.tpl @@ -10,19 +10,14 @@ * * @ListChild (list="invoice.bottom.address", weight="10") *} - + {t(#Shipping address#)} -

    - {order.profile.shipping_address.title} {order.profile.shipping_address.firstname} {order.profile.shipping_address.lastname} -

    -

    - {order.profile.shipping_address.street}
    - {order.profile.shipping_address.city}, {order.profile.shipping_address.state.state}, {order.profile.shipping_address.zipcode}
    - {order.profile.shipping_address.country.country} -

    - -

    - {t(#Phone#)}: {order.profile.shipping_address.phone} -

    +
      +
    • + {t(field.title)}: + {field.value} + , +
    • +
    diff --git a/src/skins/default/en/order/invoice/parts/bottom.address.tpl b/src/skins/default/en/order/invoice/parts/bottom.address.tpl index b763e4bf7f..3533bf7096 100644 --- a/src/skins/default/en/order/invoice/parts/bottom.address.tpl +++ b/src/skins/default/en/order/invoice/parts/bottom.address.tpl @@ -10,4 +10,4 @@ * * @ListChild (list="invoice.bottom", weight="10") *} - + diff --git a/src/skins/default/en/order/invoice/style.css b/src/skins/default/en/order/invoice/style.css new file mode 100644 index 0000000000..07feba889e --- /dev/null +++ b/src/skins/default/en/order/invoice/style.css @@ -0,0 +1,58 @@ +/* vim: set ts=2 sw=2 sts=2 et: */ + +/** + * Invoice styles + * + * @author Creative Development LLC + * @copyright Copyright (c) 2011-2012 Creative Development LLC . All rights reserved + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + * @link http://www.litecommerce.com/ + */ + + .addresses ul.address-section li { + background: none; + padding: 0px; + margin: 0px; + } + +.addresses ul.address-section { + padding-top: 12px; +} + +.addresses ul.address-section li.address-field { + padding-right: 4px; +} + +.addresses ul.address-section li.address-field.address-custom_state { + display: none; +} + +.addresses ul.address-section li.address-field span { + font-size: 14px; + line-height: 20px; + padding-top: 8px; +} + +ul.address-section li.address-field .address-title, + ul.address-section li.address-field .address-comma +{ + display: none; +} + +ul.address-section li.address-field.address-phone .address-title, + ul.address-section li.address-field.field-additional .address-title, + ul.address-section li.address-field.address-city .address-comma, + ul.address-section li.address-field.address-street .address-comma, + ul.address-section li.address-field.address-state .address-comma +{ + display: inline; +} + +ul.address-section li.address-field.address-title, + ul.address-section li.address-field.address-firstname, + ul.address-section li.address-field.address-city, + ul.address-section li.address-field.address-state +{ + float: left; +} + diff --git a/src/skins/default/en/js/states_list.tpl b/src/skins/default/en/product/details/parts/attribute.tpl similarity index 54% rename from src/skins/default/en/js/states_list.tpl rename to src/skins/default/en/product/details/parts/attribute.tpl index 9c53594c6b..df6f8db47c 100644 --- a/src/skins/default/en/js/states_list.tpl +++ b/src/skins/default/en/product/details/parts/attribute.tpl @@ -1,18 +1,22 @@ {* vim: set ts=2 sw=2 sts=2 et: *} {** - * ____file_title____ + * Attribute * * @author Creative Development LLC * @copyright Copyright (c) 2011-2012 Creative Development LLC . All rights reserved * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) * @link http://www.litecommerce.com/ *} -{foreach:getCountriesStates(),countryCode,data} - {if:data} - statesList['{countryCode}'] = []; - {foreach:data,stateId,state} - statesList['{countryCode}'][statesList['{countryCode}'].length] = { id: '{stateId}', state: '{state}' } - {end:} - {end:} +{if:getAttributeGroup()} +
  • {getTitle()}

    +
      +{end:} +
    • +
      {a.name}
      + {a.value:nl2br} +
    • +{if:getAttributeGroup()} +
    +
  • {end:} diff --git a/src/skins/default/en/product/details/parts/common.product-attributes-list.tpl b/src/skins/default/en/product/details/parts/common.product-attributes-list.tpl new file mode 100644 index 0000000000..f7f265a275 --- /dev/null +++ b/src/skins/default/en/product/details/parts/common.product-attributes-list.tpl @@ -0,0 +1,18 @@ +{* vim: set ts=2 sw=2 sts=2 et: *} + +{** + * Product attributes + * + * @author Creative Development LLC + * @copyright Copyright (c) 2011-2012 Creative Development LLC . All rights reserved + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + * @link http://www.litecommerce.com/ + * + * @ListChild (list="product.details.common.product-attributes.attributes", weight="10") + *} + +{foreach:product.getClasses(),class} + {foreach:class.getAttributeGroups(),group} + + {end:} +{end:} diff --git a/src/skins/admin/en/product_classes/list/parts/columns/main.tpl b/src/skins/default/en/product/details/parts/common.product-attributes.attributes.tpl similarity index 55% rename from src/skins/admin/en/product_classes/list/parts/columns/main.tpl rename to src/skins/default/en/product/details/parts/common.product-attributes.attributes.tpl index 6c5ce34dbe..218a8127c6 100644 --- a/src/skins/admin/en/product_classes/list/parts/columns/main.tpl +++ b/src/skins/default/en/product/details/parts/common.product-attributes.attributes.tpl @@ -1,16 +1,14 @@ {* vim: set ts=2 sw=2 sts=2 et: *} {** - * Product classes list item + * Product attributes * * @author Creative Development LLC * @copyright Copyright (c) 2011-2012 Creative Development LLC . All rights reserved * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) * @link http://www.litecommerce.com/ * - * @ListChild (list="product_classes.main_input", weight="100") + * @ListChild (list="product.details.common.product-attributes", weight="300") *} - - - + diff --git a/src/skins/default/en/product/details/parts/common.product-attributes.sku.tpl b/src/skins/default/en/product/details/parts/common.product-attributes.sku.tpl index 54a51128f2..4ed35ef694 100644 --- a/src/skins/default/en/product/details/parts/common.product-attributes.sku.tpl +++ b/src/skins/default/en/product/details/parts/common.product-attributes.sku.tpl @@ -11,6 +11,6 @@ * @ListChild (list="product.details.common.product-attributes", weight="200") *}
  • - {t(#SKU#)}: +
    {t(#SKU#)}
    {product.sku}
  • diff --git a/src/skins/default/en/product/details/parts/common.product-attributes.weight.tpl b/src/skins/default/en/product/details/parts/common.product-attributes.weight.tpl index fe587bea36..3dad39bc8b 100644 --- a/src/skins/default/en/product/details/parts/common.product-attributes.weight.tpl +++ b/src/skins/default/en/product/details/parts/common.product-attributes.weight.tpl @@ -11,6 +11,6 @@ * @ListChild (list="product.details.common.product-attributes", weight="100") *}
  • - {t(#Weight#)}: +
    {t(#Weight#)}
    {product.weight} {config.General.weight_symbol}
  • diff --git a/src/skins/default/en/checkout/steps/payment/parts/address.city.tpl b/src/skins/default/en/product/details/parts/page.tabs.attributes.tpl similarity index 53% rename from src/skins/default/en/checkout/steps/payment/parts/address.city.tpl rename to src/skins/default/en/product/details/parts/page.tabs.attributes.tpl index 1ebb56c099..9de4974935 100644 --- a/src/skins/default/en/checkout/steps/payment/parts/address.city.tpl +++ b/src/skins/default/en/product/details/parts/page.tabs.attributes.tpl @@ -1,16 +1,15 @@ {* vim: set ts=2 sw=2 sts=2 et: *} {** - * Billing address : city + * Product details attributes tab * * @author Creative Development LLC * @copyright Copyright (c) 2011-2012 Creative Development LLC . All rights reserved * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) * @link http://www.litecommerce.com/ * - * @ListChild (list="checkout.payment.address", weight="50") + * @ListChild (list="product.details.page.tab.attributes", weight="10") *} -
  • - - -
  • +
      + +
    diff --git a/src/skins/default/en/shopping_cart/shipping_estimator/parts/address.country.tpl b/src/skins/default/en/shopping_cart/shipping_estimator/parts/address.country.tpl index 4a25d44c8f..61171ff9cb 100644 --- a/src/skins/default/en/shopping_cart/shipping_estimator/parts/address.country.tpl +++ b/src/skins/default/en/shopping_cart/shipping_estimator/parts/address.country.tpl @@ -10,7 +10,7 @@ * * @ListChild (list="shippingEstimator.address", weight="10") *} -
  • +
  • diff --git a/src/skins/default/en/shopping_cart/shipping_estimator/parts/address.state.tpl b/src/skins/default/en/shopping_cart/shipping_estimator/parts/address.state.tpl index 7f3ab54ff4..b1e8e03480 100644 --- a/src/skins/default/en/shopping_cart/shipping_estimator/parts/address.state.tpl +++ b/src/skins/default/en/shopping_cart/shipping_estimator/parts/address.state.tpl @@ -10,7 +10,7 @@ * * @ListChild (list="shippingEstimator.address", weight="20") *} -
  • +
  • diff --git a/src/skins/default/en/shopping_cart/shipping_estimator/parts/address.zipcode.tpl b/src/skins/default/en/shopping_cart/shipping_estimator/parts/address.zipcode.tpl index 1d1d82e300..5251190386 100644 --- a/src/skins/default/en/shopping_cart/shipping_estimator/parts/address.zipcode.tpl +++ b/src/skins/default/en/shopping_cart/shipping_estimator/parts/address.zipcode.tpl @@ -10,7 +10,7 @@ * * @ListChild (list="shippingEstimator.address", weight="30") *} -
  • +
  • diff --git a/src/skins/mail/en/order/invoice/body.tpl b/src/skins/mail/en/order/invoice/body.tpl index 4b0af4c78c..3f14fb9cb9 100644 --- a/src/skins/mail/en/order/invoice/body.tpl +++ b/src/skins/mail/en/order/invoice/body.tpl @@ -8,6 +8,10 @@ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) * @link http://www.litecommerce.com/ *} -
    + + + + +
    - +
    diff --git a/src/skins/mail/en/order/invoice/parts/bottom.address.billing.tpl b/src/skins/mail/en/order/invoice/parts/bottom.address.billing.tpl index b966a74949..d1ba772f96 100644 --- a/src/skins/mail/en/order/invoice/parts/bottom.address.billing.tpl +++ b/src/skins/mail/en/order/invoice/parts/bottom.address.billing.tpl @@ -12,19 +12,14 @@ *} {t(#Billing address#)} -

    - {order.profile.billing_address.title} {order.profile.billing_address.firstname:h} {order.profile.billing_address.lastname:h} -

    - -

    - {order.profile.billing_address.street:h}
    - {order.profile.billing_address.city:h}, {order.profile.billing_address.state.state:h}, {order.profile.billing_address.zipcode:h}
    - {order.profile.billing_address.country.country:h} -

    -

    - {t(#Phone#)}: {order.profile.billing_address.phone:h} -

    +
      +
    • + {t(field.title)}: + {field.value} + , +
    • +

    {t(#E-mail#)}: {order.profile.login:h} diff --git a/src/skins/mail/en/order/invoice/parts/bottom.address.shipping.tpl b/src/skins/mail/en/order/invoice/parts/bottom.address.shipping.tpl index ea309c8449..6589e3b912 100644 --- a/src/skins/mail/en/order/invoice/parts/bottom.address.shipping.tpl +++ b/src/skins/mail/en/order/invoice/parts/bottom.address.shipping.tpl @@ -12,17 +12,13 @@ *} {t(#Shipping address#)} -

    - {order.profile.shipping_address.title} {order.profile.shipping_address.firstname:h} {order.profile.shipping_address.lastname:h} -

    -

    - {order.profile.shipping_address.street:h}
    - {order.profile.shipping_address.city:h}, {order.profile.shipping_address.state.state:h}, {order.profile.shipping_address.zipcode:h}
    - {order.profile.shipping_address.country.country:h} -

    +
      +
    • + {t(field.title)}: + {field.value} + , +
    • +
    -

    - {t(#Phone#)}: {order.profile.shipping_address.phone:h} -

    diff --git a/src/skins/mail/en/order/invoice/parts/bottom.methods.payment.tpl b/src/skins/mail/en/order/invoice/parts/bottom.methods.payment.tpl index 6f1303f924..9de1cc26bb 100644 --- a/src/skins/mail/en/order/invoice/parts/bottom.methods.payment.tpl +++ b/src/skins/mail/en/order/invoice/parts/bottom.methods.payment.tpl @@ -11,6 +11,7 @@ * @ListChild (list="invoice.bottom.methods", weight="20") *} +
    {t(#Payment method#)}: {foreach:order.getVisiblePaymentMethods(),m} {m.getName():h}
    diff --git a/src/skins/mail/en/order/invoice/parts/bottom.methods.shipping.tpl b/src/skins/mail/en/order/invoice/parts/bottom.methods.shipping.tpl index 78b2700635..a0c6b23b93 100644 --- a/src/skins/mail/en/order/invoice/parts/bottom.methods.shipping.tpl +++ b/src/skins/mail/en/order/invoice/parts/bottom.methods.shipping.tpl @@ -11,6 +11,7 @@ * @ListChild (list="invoice.bottom.methods", weight="10") *} +
    {t(#Shipping method#)}: {shippingModifier.method.getName():h} diff --git a/src/skins/mail/en/order/invoice/parts/bottom.tpl b/src/skins/mail/en/order/invoice/parts/bottom.tpl index 0acf8339c1..9b4f41da17 100644 --- a/src/skins/mail/en/order/invoice/parts/bottom.tpl +++ b/src/skins/mail/en/order/invoice/parts/bottom.tpl @@ -10,7 +10,7 @@ * * @ListChild (list="invoice.base", weight="50") *} - +
    {w.display()} diff --git a/src/skins/mail/en/order/invoice/parts/footer.tpl b/src/skins/mail/en/order/invoice/parts/footer.tpl index 1fdfa41fce..6d504e98e6 100644 --- a/src/skins/mail/en/order/invoice/parts/footer.tpl +++ b/src/skins/mail/en/order/invoice/parts/footer.tpl @@ -10,4 +10,8 @@ * * @ListChild (list="invoice.base", weight="60") *} + +
    +
    +
    {t(#Thank you for your order FOOTER#):h}
    diff --git a/src/skins/mail/en/order/invoice/parts/head.tpl b/src/skins/mail/en/order/invoice/parts/head.tpl index c25cd3e61a..ac3cf2fdc2 100644 --- a/src/skins/mail/en/order/invoice/parts/head.tpl +++ b/src/skins/mail/en/order/invoice/parts/head.tpl @@ -10,7 +10,7 @@ * * @ListChild (list="invoice.base", weight="10") *} -
    +
    diff --git a/src/skins/mail/en/order/invoice/parts/item.name.tpl b/src/skins/mail/en/order/invoice/parts/item.name.tpl index 07bd0eb5c4..2b0b83bc25 100644 --- a/src/skins/mail/en/order/invoice/parts/item.name.tpl +++ b/src/skins/mail/en/order/invoice/parts/item.name.tpl @@ -10,8 +10,8 @@ * * @ListChild (list="invoice.item", weight="10") *} - + diff --git a/src/skins/mail/en/order/invoice/parts/item.qty.tpl b/src/skins/mail/en/order/invoice/parts/item.qty.tpl index 9a1c7ba3b5..967abc0a57 100644 --- a/src/skins/mail/en/order/invoice/parts/item.qty.tpl +++ b/src/skins/mail/en/order/invoice/parts/item.qty.tpl @@ -10,4 +10,4 @@ * * @ListChild (list="invoice.subitem", weight="20") *} - + diff --git a/src/skins/mail/en/order/invoice/parts/item.total.tpl b/src/skins/mail/en/order/invoice/parts/item.total.tpl index f8757be129..182fec2369 100644 --- a/src/skins/mail/en/order/invoice/parts/item.total.tpl +++ b/src/skins/mail/en/order/invoice/parts/item.total.tpl @@ -10,4 +10,4 @@ * * @ListChild (list="invoice.item", weight="40") *} - + diff --git a/src/skins/mail/en/order/invoice/parts/items.tpl b/src/skins/mail/en/order/invoice/parts/items.tpl index 80268154d7..40a48b513a 100644 --- a/src/skins/mail/en/order/invoice/parts/items.tpl +++ b/src/skins/mail/en/order/invoice/parts/items.tpl @@ -10,16 +10,16 @@ * * @ListChild (list="invoice.base", weight="30") *} -
    - {item.getName()} + + {item.getName()}
    diff --git a/src/skins/mail/en/order/invoice/parts/item.price.tpl b/src/skins/mail/en/order/invoice/parts/item.price.tpl index ff9bd44c9c..7de714713c 100644 --- a/src/skins/mail/en/order/invoice/parts/item.price.tpl +++ b/src/skins/mail/en/order/invoice/parts/item.price.tpl @@ -10,4 +10,4 @@ * * @ListChild (list="invoice.subitem", weight="30") *} -
    {formatPrice(item.getNetPrice(),order.getCurrency())}{formatPrice(item.getNetPrice(),order.getCurrency())}{item.getAmount()}{item.getAmount()}{formatPrice(item.getTotal(),order.getCurrency())}{formatPrice(item.getTotal(),order.getCurrency())}
    +
    - + - + - + {foreach:order.getItems(),index,item} @@ -29,8 +29,8 @@ - - + + {end:} diff --git a/src/skins/mail/en/order/invoice/parts/totals.modifiers.tpl b/src/skins/mail/en/order/invoice/parts/totals.modifiers.tpl index 02da02aeba..43dc18ef00 100644 --- a/src/skins/mail/en/order/invoice/parts/totals.modifiers.tpl +++ b/src/skins/mail/en/order/invoice/parts/totals.modifiers.tpl @@ -11,13 +11,13 @@ * @ListChild (list="invoice.base.totals", weight="200") *} - + {if:surcharge.count=#1#} {else:} {end:} - + - + diff --git a/src/skins/mail/en/order/invoice/parts/totals.total.tpl b/src/skins/mail/en/order/invoice/parts/totals.total.tpl index 6b71e5d763..cf91e95029 100644 --- a/src/skins/mail/en/order/invoice/parts/totals.total.tpl +++ b/src/skins/mail/en/order/invoice/parts/totals.total.tpl @@ -10,7 +10,7 @@ * * @ListChild (list="invoice.base.totals", weight="300") *} - - - + + + diff --git a/src/skins/mail/en/order/invoice/parts/totals.tpl b/src/skins/mail/en/order/invoice/parts/totals.tpl index 8edfeb0a65..9c5531736e 100644 --- a/src/skins/mail/en/order/invoice/parts/totals.tpl +++ b/src/skins/mail/en/order/invoice/parts/totals.tpl @@ -10,6 +10,10 @@ * * @ListChild (list="invoice.base", weight="40") *} -
    {surcharge.lastName}:{surcharge.name}: + {if:surcharge.available} {formatPrice(surcharge.cost,order.getCurrency())} {else:} diff --git a/src/skins/mail/en/order/invoice/parts/totals.subtotal.tpl b/src/skins/mail/en/order/invoice/parts/totals.subtotal.tpl index 68d9ccf809..b476228d47 100644 --- a/src/skins/mail/en/order/invoice/parts/totals.subtotal.tpl +++ b/src/skins/mail/en/order/invoice/parts/totals.subtotal.tpl @@ -10,7 +10,7 @@ * * @ListChild (list="invoice.base.totals", weight="100") *} -
    {t(#Subtotal#)}:{formatPrice(order.getSubtotal(),order.getCurrency())}{formatPrice(order.getSubtotal(),order.getCurrency())}
    {t(#Grand total#)}:{formatPrice(order.getTotal(),order.getCurrency())}
    {t(#Grand total#)}:{formatPrice(order.getTotal(),order.getCurrency())}
    + +
    +{t(#Totals#)} +
    +
    diff --git a/src/skins/mail/en/order/invoice/style.css b/src/skins/mail/en/order/invoice/style.css index 3de124498a..2452050ea2 100644 --- a/src/skins/mail/en/order/invoice/style.css +++ b/src/skins/mail/en/order/invoice/style.css @@ -63,3 +63,51 @@ ul.invoice-totals li { padding: 3px 0; } + + .addresses ul.address-section li { + background: none; + padding: 0px; + margin: 0px; + } + +.addresses ul.address-section { + padding-top: 12px; +} + +.addresses ul.address-section li.address-field { + padding-right: 4px; +} + +.addresses ul.address-section li.address-field.address-custom_state { + display: none; +} + +.addresses ul.address-section li.address-field span { + font-size: 14px; + line-height: 20px; + padding-top: 8px; +} + +ul.address-section li.address-field .address-title, + ul.address-section li.address-field .address-comma +{ + display: none; +} + +ul.address-section li.address-field.address-phone .address-title, + ul.address-section li.address-field.field-additional .address-title, + ul.address-section li.address-field.address-city .address-comma, + ul.address-section li.address-field.address-street .address-comma, + ul.address-section li.address-field.address-state .address-comma +{ + display: inline; +} + +ul.address-section li.address-field.address-title, + ul.address-section li.address-field.address-firstname, + ul.address-section li.address-field.address-city, + ul.address-section li.address-field.address-state +{ + float: left; +} + diff --git a/src/skins/mail/en/order_processed/body.tpl b/src/skins/mail/en/order_processed/body.tpl index 5207cf5d75..0ea186d9f9 100644 --- a/src/skins/mail/en/order_processed/body.tpl +++ b/src/skins/mail/en/order_processed/body.tpl @@ -13,6 +13,7 @@ {t(#Dear X#,_ARRAY_(#firstname#^order.profile.billing_address.firstname,#lastname#^order.profile.billing_address.lastname)):h}

    {t(#Your order has been processed#,_ARRAY_(#id#^order.order_id)):h} {t(#Thank you for your order FOOTER#):h} +


    diff --git a/src/sql/demo/xlite_demo_orders.yaml b/src/sql/demo/xlite_demo_orders.yaml index a51d139da4..90a30b939e 100644 --- a/src/sql/demo/xlite_demo_orders.yaml +++ b/src/sql/demo/xlite_demo_orders.yaml @@ -8,7 +8,7 @@ # @link http://www.litecommerce.com/ XLite\Model\Order: - - profile: { login: rnd_tester@rrf.ru, password: 084e0343a0486ff05530df6c705c8bb4, access_level: 0, status: E, cms_profile_id: 0, addresses: [{ is_billing: true, is_shipping: true, title: Mr., firstname: Admin, lastname: Admin, phone: '0123456789', street: '51 apt, 87 street', city: Edmond, state: { country_code: US, code: OK }, country: { code: US }, zipcode: '73003' }] } + - profile: { login: rnd_tester@rrf.ru, cms_profile_id: 0 } orig_profile: { login: rnd_tester@rrf.ru } total: 20.7599 subtotal: 17.99 @@ -37,7 +37,7 @@ XLite\Model\Order: description: Order placed - code: TRANSACTION description: "Payment transaction [method: Money Ordering, type: sale, amount: 17.99, status: Pending]" - - profile: { login: rnd_tester@rrf.ru, password: 084e0343a0486ff05530df6c705c8bb4, access_level: 0, status: E, cms_profile_id: 0, addresses: [{ is_billing: true, is_shipping: true, title: Mr., firstname: Admin, lastname: Admin, phone: '0123456789', street: '51 apt, 87 street', city: Edmond, state: { country_code: US, code: OK }, country: { code: US }, zipcode: '73003' }] } + - profile: { login: rnd_tester@rrf.ru, cms_profile_id: 0 } orig_profile: { login: rnd_tester@rrf.ru } total: 121.1137 subtotal: 116.91 diff --git a/src/sql/demo/xlite_demo_user.yaml b/src/sql/demo/xlite_demo_user.yaml index 910a892e87..82385fbf85 100644 --- a/src/sql/demo/xlite_demo_user.yaml +++ b/src/sql/demo/xlite_demo_user.yaml @@ -8,5 +8,55 @@ # @link http://www.litecommerce.com/ XLite\Model\Profile: -# - { login: rnd_tester@cdev.ru, password: eb0a191797624dd3a48fa681d3061212, access_level: 100, status: E, cms_profile_id: 1, cms_name: ____DRUPAL____, addresses: [{ is_billing: true, is_shipping: true, title: Mr., firstname: Admin, lastname: Admin, phone: '0123456789', street: '51 apt, 87 street', city: Edmond, state: { country_code: US, code: OK }, country: { code: US }, zipcode: '73003' }] } - - { login: rnd_tester@rrf.ru, password: 084e0343a0486ff05530df6c705c8bb4, status: E, cms_profile_id: 0, addresses: [{ is_billing: true, is_shipping: false, title: Mr., firstname: Guest, lastname: Guest, phone: '0123456789', street: '51 apt, 87 street', city: Edmond, state: { country_code: US, code: OK }, country: { code: US }, zipcode: '73003' }, { is_billing: false, is_shipping: true, title: Mr., firstname: Guest, lastname: Guest, phone: '9876543210', street: '12 apt, 34 street', city: 'New York', state: { country_code: US, code: OK }, country: { code: US }, zipcode: '10001' }] } + - login: rnd_tester@rrf.ru + password: 084e0343a0486ff05530df6c705c8bb4 + status: E + cms_profile_id: 0 + addresses: + - is_billing: true + is_shipping: false + state: { country_code: US, code: OK } + country: { code: US } + addressFields : + - addressField: { serviceName: title } + value : 'Mr.' + - addressField: { serviceName: firstname } + value: Guest + - addressField: { serviceName: lastname } + value: Guest + - addressField: { serviceName: phone } + value: '0123456789' + - addressField: { serviceName: street } + value: '51 apt, 87 street' + - addressField: { serviceName: city } + value: Edmond + - addressField: { serviceName: state_id } + value: 185 + - addressField: { serviceName: country_code } + value: US + - addressField: { serviceName: zipcode } + value: '73003' + - is_billing: false + is_shipping: true + state: { country_code: US, code: OK } + country: { code: US } + addressFields : + - addressField: { serviceName: title } + value : 'Mr.' + - addressField: { serviceName: firstname } + value: Guest + - addressField: { serviceName: lastname } + value: Guest + - addressField: { serviceName: phone } + value: '9876543210' + - addressField: { serviceName: street } + value: '12 apt, 34 street' + - addressField: { serviceName: city } + value: 'New York' + - addressField: { serviceName: state_id } + value: 185 + - addressField: { serviceName: country_code } + value: US + - addressField: { serviceName: zipcode } + value: '10001' + diff --git a/src/sql/demo/xlite_demo_user_admin.yaml b/src/sql/demo/xlite_demo_user_admin.yaml index ae6af813b5..24b95963c8 100644 --- a/src/sql/demo/xlite_demo_user_admin.yaml +++ b/src/sql/demo/xlite_demo_user_admin.yaml @@ -8,4 +8,35 @@ # @link http://www.litecommerce.com/ XLite\Model\Profile: - - { login: rnd_tester@cdev.ru, password: eb0a191797624dd3a48fa681d3061212, access_level: 100, status: E, cms_profile_id: 1, cms_name: ____DRUPAL____, addresses: [{ is_billing: true, is_shipping: true, title: Mr., firstname: Admin, lastname: Admin, phone: '0123456789', street: '51 apt, 87 street', city: Edmond, state: { country_code: US, code: OK }, country: { code: US }, zipcode: '73003' }], roles: [{ translations: [{ name: Administrator }] }] } + - login: rnd_tester@cdev.ru + password: eb0a191797624dd3a48fa681d3061212 + access_level: 100 + status: E + cms_profile_id: 1 + cms_name: ____DRUPAL____ + roles: [{ translations: [{ name: Administrator }] }] + addresses: + - is_billing: true + is_shipping: true + state: { country_code: US, code: OK } + country: { code: US } + addressFields : + - addressField: { serviceName: title } + value : 'Mr.' + - addressField: { serviceName: firstname } + value: Admin + - addressField: { serviceName: lastname } + value: Admin + - addressField: { serviceName: phone } + value: '0123456789' + - addressField: { serviceName: street } + value: '51 apt, 87 street' + - addressField: { serviceName: city } + value: Edmond + - addressField: { serviceName: state_id } + value: 185 + - addressField: { serviceName: country_code } + value: US + - addressField: { serviceName: zipcode } + value: '73003' + diff --git a/src/sql/xlite_data.yaml b/src/sql/xlite_data.yaml index 52b0851472..3733d1491b 100644 --- a/src/sql/xlite_data.yaml +++ b/src/sql/xlite_data.yaml @@ -491,6 +491,10 @@ XLite\Model\LanguageLabel: - { name: 'Payment method has been enabled successfully', translations: [{ code: en, label: 'Payment method has been enabled successfully' }] } - { name: 'Payment method has been disabled successfully', translations: [{ code: en, label: 'Payment method has been disabled successfully' }] } - { name: 'Payment method has been removed successfully', translations: [{ code: en, label: 'Payment method has been removed successfully' }] } + - { name: 'Duplicated clean URL: X', translations: [{ code: en, label: 'Duplicated clean URL: {{value}}' }] } + - { name: 'Attributes for X product class', translations: [{ code: en, label: 'Attributes for "{{class}}" product class' }] } + - { name: 'X attributes in group', translations: [{ code: en, label: '{{count}} attributes in group' }] } + XLite\Model\Membership: directives: { insert: true } - { orderby: 10, translations: [{ code: en, name: Gold }] } @@ -682,7 +686,7 @@ XLite\Model\Language: XLite\Model\Payment\Method: directives: { insert: true } - { service_name: PurchaseOrder, class: 'Model\Payment\Processor\PurchaseOrder', added: true, orderby: 20, translations: [{ code: en, name: 'Purchase Order' }] } - - { service_name: PhoneOrdering, class: 'Model\Payment\Processor\Offline', added: true, orderby: 30, translations: [{ code: en, name: 'Phone Ordering', description: 'Phone: (555) 555-5555' }] } + - { service_name: PhoneOrdering, class: 'Model\Payment\Processor\Offline', added: true, enabled: true, orderby: 30, translations: [{ code: en, name: 'Phone Ordering', description: 'Phone: (555) 555-5555' }] } - { service_name: FaxOrdering, class: 'Model\Payment\Processor\Offline', added: true, orderby: 40, translations: [{ code: en, name: 'Fax Ordering', description: 'Fax: (555) 555-5555' }] } - { service_name: MoneyOrdering, class: 'Model\Payment\Processor\Offline', added: true, orderby: 50, translations: [{ code: en, name: 'Money Order', description: 'US Banks Only' }] } - { service_name: Echeck, class: 'Model\Payment\Processor\Check', added: true, orderby: 60, translations: [{ code: en, name: Check, description: 'Check payment' }] } @@ -1169,3 +1173,17 @@ XLite\Model\Role\Permission: - { code: manage catalog, section: Catalog, translations: [{ code: en, name: Manage catalog }] } - { code: manage users, section: Users, translations: [{ code: en, name: Manage users }] } - { code: manage orders, section: Sales, translations: [{ code: en, name: Manage orders }] } + +XLite\Model\AddressField: + - { serviceName: title, additional: false, required: false, translations: [{ code: en, name: Title }], schemaClass: \XLite\View\FormField\Select\Title } + - { serviceName: firstname, additional: false, required: true, translations: [{ code: en, name: First name }] } + - { serviceName: lastname, additional: false, required: true, translations: [{ code: en, name: Last name }] } + - { serviceName: street, additional: false, required: true, translations: [{ code: en, name: Address }] } + - { serviceName: city, additional: false, required: true, translations: [{ code: en, name: City }] } + - { serviceName: country_code, additional: false, required: true, translations: [{ code: en, name: Country }], schemaClass: \XLite\View\FormField\Select\Country, viewGetterName: country_name } + - { serviceName: state_id, additional: false, required: true, translations: [{ code: en, name: State }], schemaClass: \XLite\View\FormField\Select\State, viewGetterName: state_name } + - { serviceName: custom_state, additional: false, required: false, translations: [{ code: en, name: State }], viewGetterName: state_name } + - { serviceName: zipcode, additional: false, required: true, translations: [{ code: en, name: Zip code }] } + - { serviceName: phone, additional: false, required: true, translations: [{ code: en, name: Phone }] } + + diff --git a/src/upgrade/1.1/3/post_rebuild.php b/src/upgrade/1.1/3/post_rebuild.php new file mode 100644 index 0000000000..5805e4f22c --- /dev/null +++ b/src/upgrade/1.1/3/post_rebuild.php @@ -0,0 +1,60 @@ + + * @copyright Copyright (c) 2011 Creative Development LLC . All rights reserved + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + * @link http://www.litecommerce.com/ + */ + +return function() +{ + // Loading data to the database from yaml file + $yamlFile = __DIR__ . LC_DS . 'post_rebuild.yaml'; + + if (\Includes\Utils\FileManager::isFileReadable($yamlFile)) { + \XLite\Core\Database::getInstance()->loadFixturesFromYaml($yamlFile); + } + + // Import profile addresses from the temporary YAML file storage + $yamlProfileStorageFile = LC_DIR_VAR . 'temporary.storage.profiles.yaml'; + + foreach (\Includes\Utils\Operator::loadServiceYAML($yamlProfileStorageFile) as $address) { + + $entity = \XLite\Core\Database::getRepo('XLite\Model\Address') + ->findOneBy(array( + 'address_id' => $address['address_id'], + 'profile' => $address['profile_id'], + ) + ); + + $entity->setProfile(\XLite\Core\Database::getRepo('XLite\Model\Profile')->find($address['profile_id'])); + $entity->setCountry(\XLite\Core\Database::getRepo('XLite\Model\Country')->findOneByCode($address['country_code'])); + $entity->setState(\XLite\Core\Database::getRepo('XLite\Model\State')->find($address['state_id'])); + + unset($address['profile_id'], $address['state_id'], $address['country_code']); + $entity->map($address); + + $entity->update(); + \XLite\Core\Database::getEM()->flush($entity); + } + + \Includes\Utils\FileManager::deleteFile($yamlProfileStorageFile); + +}; diff --git a/src/upgrade/1.1/3/post_rebuild.yaml b/src/upgrade/1.1/3/post_rebuild.yaml new file mode 100644 index 0000000000..bf02df15db --- /dev/null +++ b/src/upgrade/1.1/3/post_rebuild.yaml @@ -0,0 +1,20 @@ +# vim: set ts=2 sw=2 sts=2 et: +# +# Data for core upgrading 1.1.1 -> 1.1.3 +# +# @author Creative Development LLC +# @copyright Copyright (c) 2011-2012 Creative Development LLC . All rights reserved +# @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) +# @link http://www.litecommerce.com/ + +XLite\Model\AddressField: + - { serviceName: title, additional: false, required: false, translations: [{ code: en, name: Title }], schemaClass: \XLite\View\FormField\Select\Title } + - { serviceName: firstname, additional: false, required: true, translations: [{ code: en, name: First name }] } + - { serviceName: lastname, additional: false, required: true, translations: [{ code: en, name: Last name }] } + - { serviceName: street, additional: false, required: true, translations: [{ code: en, name: Address }] } + - { serviceName: city, additional: false, required: true, translations: [{ code: en, name: City }] } + - { serviceName: country_code, additional: false, required: true, translations: [{ code: en, name: Country }], schemaClass: \XLite\View\FormField\Select\Country, viewGetterName: country_name } + - { serviceName: state_id, additional: false, required: true, translations: [{ code: en, name: State }], schemaClass: \XLite\View\FormField\Select\State, viewGetterName: state_name } + - { serviceName: custom_state, additional: false, required: false, translations: [{ code: en, name: State }], viewGetterName: state_name } + - { serviceName: zipcode, additional: false, required: true, translations: [{ code: en, name: Zip code }] } + - { serviceName: phone, additional: false, required: true, translations: [{ code: en, name: Phone }] } diff --git a/src/upgrade/1.1/3/pre_upgrade.php b/src/upgrade/1.1/3/pre_upgrade.php new file mode 100644 index 0000000000..ac30172f36 --- /dev/null +++ b/src/upgrade/1.1/3/pre_upgrade.php @@ -0,0 +1,51 @@ + + * @copyright Copyright (c) 2011 Creative Development LLC . All rights reserved + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + * @link http://www.litecommerce.com/ + */ + +return function() +{ + // Store the profiles into the temporary YAML file + \Includes\Utils\Operator::saveServiceYAML( + LC_DIR_VAR . 'temporary.storage.profiles.yaml', + array_map( + function ($address) { + return array( + 'address_id' => $address->getAddressId(), + 'profile_id' => $address->getProfile()->getProfileId(), + 'title' => $address->getTitle(), + 'firstname' => $address->getFirstname(), + 'lastname' => $address->getLastname(), + 'phone' => $address->getPhone(), + 'street' => $address->getStreet(), + 'city' => $address->getCity(), + 'state_id' => $address->getState()->getStateId(), + 'custom_state' => $address->getCustomState(), + 'country_code' => $address->getCountry()->getCode(), + 'zipcode' => $address->getZipcode(), + ); + }, + \XLite\Core\Database::getRepo('XLite\Model\Address')->findAll() + ) + ); +};